summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Golle <daniel@makrotopia.org>2020-09-27 19:55:09 +0100
committerDaniel Golle <daniel@makrotopia.org>2020-10-05 15:39:05 +0100
commitdaa0f22b63c1442ad51122e5ba140c1ae5890267 (patch)
treef732b1eb5f78482ff0a7a367a6bce2eff9608437
parent400f527fbd5cb6d9523374f6f8d1320339c5b71a (diff)
postgres: drop use of 'WITH OIDS'
PostgreSQL since version 12 no longer supports 'WITH OIDS': Previously, a normally-invisible oid column could be specified during table creation using WITH OIDS; that ability has been removed. Columns can still be explicitly declared as type oid. Operations on tables that have columns created using WITH OIDS will need adjustment. The system catalogs that previously had hidden oid columns now have ordinary oid columns. Hence, SELECT * will now output those columns, whereas previously they would be displayed only if selected explicitly. Drop 'WITH OIDS' as it was stated even on tables for plugins which didn't make any use of the then exposed 'oid' column. In the case of datacache and datastore the 'oid' column is used, so replace the 'WITH OIDS' statement with an explicit 'oid' column having 'OID' type and a corresponding sequence. No measures are taken to still work with PostgreSQL before version 12. Users should update PostgreSQL to version 12 or newer. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
-rw-r--r--configure.ac2
-rw-r--r--src/datacache/plugin_datacache_postgres.c9
-rw-r--r--src/datastore/plugin_datastore_postgres.c14
-rw-r--r--src/namecache/plugin_namecache_postgres.c6
-rw-r--r--src/namestore/plugin_namestore_postgres.c6
5 files changed, 22 insertions, 15 deletions
diff --git a/configure.ac b/configure.ac
index 946b6f58a..581764b52 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1335,7 +1335,7 @@ CPPFLAGS=$SAVE_CPPFLAGS
# test for postgres:
postgres=false
-AX_LIB_POSTGRESQL([9.5],
+AX_LIB_POSTGRESQL([12.0],
[CPPFLAGS="$CPPFLAGS $POSTGRESQL_CPPFLAGS"
AC_CHECK_HEADERS([libpq-fe.h],
postgres=true)
diff --git a/src/datacache/plugin_datacache_postgres.c b/src/datacache/plugin_datacache_postgres.c
index c21be9219..724324ca4 100644
--- a/src/datacache/plugin_datacache_postgres.c
+++ b/src/datacache/plugin_datacache_postgres.c
@@ -67,14 +67,19 @@ static int
init_connection (struct Plugin *plugin)
{
struct GNUNET_PQ_ExecuteStatement es[] = {
+ GNUNET_PQ_make_try_execute ("CREATE TEMPORARY SEQUENCE IF NOT EXISTS gn011dc_oid_seq"),
GNUNET_PQ_make_execute ("CREATE TEMPORARY TABLE IF NOT EXISTS gn011dc ("
+ " oid OID NOT NULL DEFAULT nextval('gn011dc_oid_seq'),"
" type INTEGER NOT NULL,"
" prox INTEGER NOT NULL,"
" discard_time BIGINT NOT NULL,"
" key BYTEA NOT NULL,"
" value BYTEA NOT NULL,"
- " path BYTEA DEFAULT NULL)"
- "WITH OIDS"),
+ " path BYTEA DEFAULT NULL)"),
+ GNUNET_PQ_make_try_execute (
+ "ALTER SEQUENCE gnu011dc_oid_seq OWNED BY gn011dc.oid"),
+ GNUNET_PQ_make_try_execute (
+ "CREATE INDEX IF NOT EXISTS idx_oid ON gn011dc (oid)"),
GNUNET_PQ_make_try_execute (
"CREATE INDEX IF NOT EXISTS idx_key ON gn011dc (key)"),
GNUNET_PQ_make_try_execute (
diff --git a/src/datastore/plugin_datastore_postgres.c b/src/datastore/plugin_datastore_postgres.c
index 88ceb1b0a..6a5d45832 100644
--- a/src/datastore/plugin_datastore_postgres.c
+++ b/src/datastore/plugin_datastore_postgres.c
@@ -72,8 +72,10 @@ init_connection (struct Plugin *plugin)
* we only test equality on it and can cast it to/from uint32_t. For repl, prio, and anonLevel
* we do math or inequality tests, so we can't handle the entire range of uint32_t.
* This will also cause problems for expiration times after 294247-01-10-04:00:54 UTC.
- * PostgreSQL also recommends against using WITH OIDS.
- */GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS gn090 ("
+ */
+ GNUNET_PQ_make_try_execute (
+ "CREATE SEQUENCE IF NOT EXISTS gn090_oid_seq"),
+ GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS gn090 ("
" repl INTEGER NOT NULL DEFAULT 0,"
" type INTEGER NOT NULL DEFAULT 0,"
" prio INTEGER NOT NULL DEFAULT 0,"
@@ -82,8 +84,12 @@ init_connection (struct Plugin *plugin)
" rvalue BIGINT NOT NULL DEFAULT 0,"
" hash BYTEA NOT NULL DEFAULT '',"
" vhash BYTEA NOT NULL DEFAULT '',"
- " value BYTEA NOT NULL DEFAULT '')"
- "WITH OIDS"),
+ " value BYTEA NOT NULL DEFAULT '',"
+ " oid OID NOT NULL DEFAULT nextval('gn090_oid_seq'))"),
+ GNUNET_PQ_make_try_execute (
+ "ALTER SEQUENCE gn090_oid_seq OWNED BY gn090.oid"),
+ GNUNET_PQ_make_try_execute (
+ "CREATE INDEX IF NOT EXISTS oid_hash ON gn090 (oid)"),
GNUNET_PQ_make_try_execute (
"CREATE INDEX IF NOT EXISTS idx_hash ON gn090 (hash)"),
GNUNET_PQ_make_try_execute (
diff --git a/src/namecache/plugin_namecache_postgres.c b/src/namecache/plugin_namecache_postgres.c
index 0e947e9c5..654a3ae81 100644
--- a/src/namecache/plugin_namecache_postgres.c
+++ b/src/namecache/plugin_namecache_postgres.c
@@ -64,15 +64,13 @@ database_setup (struct Plugin *plugin)
" query BYTEA NOT NULL DEFAULT '',"
" block BYTEA NOT NULL DEFAULT '',"
" expiration_time BIGINT NOT NULL DEFAULT 0"
- ")"
- "WITH OIDS");
+ ")");
struct GNUNET_PQ_ExecuteStatement es_default =
GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS ns096blocks ("
" query BYTEA NOT NULL DEFAULT '',"
" block BYTEA NOT NULL DEFAULT '',"
" expiration_time BIGINT NOT NULL DEFAULT 0"
- ")"
- "WITH OIDS");
+ ")");
const struct GNUNET_PQ_ExecuteStatement *cr;
if (GNUNET_YES ==
diff --git a/src/namestore/plugin_namestore_postgres.c b/src/namestore/plugin_namestore_postgres.c
index 01dddde9e..04100567c 100644
--- a/src/namestore/plugin_namestore_postgres.c
+++ b/src/namestore/plugin_namestore_postgres.c
@@ -73,8 +73,7 @@ database_setup (struct Plugin *plugin)
" record_data BYTEA NOT NULL DEFAULT '',"
" label TEXT NOT NULL DEFAULT '',"
" CONSTRAINT zl UNIQUE (zone_private_key,label)"
- ")"
- "WITH OIDS");
+ ")");
struct GNUNET_PQ_ExecuteStatement es_default =
GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS ns098records ("
" seq BIGSERIAL PRIMARY KEY,"
@@ -85,8 +84,7 @@ database_setup (struct Plugin *plugin)
" record_data BYTEA NOT NULL DEFAULT '',"
" label TEXT NOT NULL DEFAULT '',"
" CONSTRAINT zl UNIQUE (zone_private_key,label)"
- ")"
- "WITH OIDS");
+ ")");
const struct GNUNET_PQ_ExecuteStatement *cr;
struct GNUNET_PQ_ExecuteStatement sc = GNUNET_PQ_EXECUTE_STATEMENT_END;