psycstore: postgres: introduce LENGTH check for pub_key field
authorDaniel Golle <daniel@makrotopia.org>
Tue, 18 Oct 2016 10:36:46 +0000 (10:36 +0000)
committerDaniel Golle <daniel@makrotopia.org>
Tue, 18 Oct 2016 10:36:46 +0000 (10:36 +0000)
src/psycstore/plugin_psycstore_postgres.c

index 9240d33348a9504bb3be20f133b3c96eac595fae..c6d274a78cc41998458213da1d832f6f066c037a 100644 (file)
@@ -100,7 +100,7 @@ database_setup (struct Plugin *plugin)
          GNUNET_POSTGRES_exec(plugin->dbh,
                               "CREATE TABLE IF NOT EXISTS channels (\n"
                               " id SERIAL,\n"
-                              " pub_key BYTEA,\n"
+                              " pub_key BYTEA NOT NULL CHECK (LENGTH(pub_key)=32),\n"
                               " max_state_message_id BIGINT,\n"
                               " state_hash_message_id BIGINT,\n"
                               " PRIMARY KEY(id)\n"
@@ -121,7 +121,7 @@ database_setup (struct Plugin *plugin)
          GNUNET_POSTGRES_exec(plugin->dbh,
                               "CREATE TABLE IF NOT EXISTS slaves (\n"
                               " id SERIAL,\n"
-                              " pub_key BYTEA,\n"
+                              " pub_key BYTEA NOT NULL CHECK (LENGTH(pub_key)=32),\n"
                               " PRIMARY KEY(id)\n"
                               ")" "WITH OIDS")) ||