PG12 patch
gmail Vladimir Koković <[email protected]> Mon, 4 Feb 2019 20:00:51 +0100
| Newsgroups | gmane.comp.db.postgresql.odbc |
|---|---|
| Message-ID | <[email protected]> |
Hello, I use the PostgreSQL-devel server with which the psqlodbc-git version does not work because the field 'relhasoids' was dropped in PG12. After applying the patch that I send you, my huge c++ ODBC application now works again with PostgreSQL-devel server. Vladimir Koković DP senior(69), Belgrade, Serbia
pg12.patch
(text/x-patch, 2.8 KB)
diff --git a/configure.ac b/configure.ac
index 12f3844..bff7f5a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -152,7 +152,7 @@
if test "$with_libpq" != yes; then
if test -d "$with_libpq"; then
- PATH="$PATH:$with_libpq/bin"
+ PATH="$with_libpq/bin:$PATH"
CPPFLAGS="$CPPFLAGS -I$with_libpq/include -I$with_libpq/include/postgresql/internal"
LDFLAGS="$LDFLAGS -L$with_libpq/lib"
else
diff --git a/info.c b/info.c
index 052f0ae..451b1d4 100644
--- a/info.c
+++ b/info.c
@@ -2341,9 +2341,11 @@
"t.typname, a.attnum, a.attlen, a.atttypmod, a.attnotnull, "
"c.relhasrules, c.relkind, c.oid, pg_get_expr(d.adbin, d.adrelid), "
"case t.typtype when 'd' then t.typbasetype else 0 end, t.typtypmod, "
- "c.relhasoids, %s, c.relhassubclass "
+ "%s, %s, c.relhassubclass "
"from (((pg_catalog.pg_class c "
- "inner join pg_catalog.pg_namespace n on n.oid = c.relnamespace", PG_VERSION_GE(conn, 10.0) ? "attidentity" : "''");
+ "inner join pg_catalog.pg_namespace n on n.oid = c.relnamespace",
+ PG_VERSION_GE(conn, 12.0) ? "0" : "c.relhasoids",
+ PG_VERSION_GE(conn, 10.0) ? "attidentity" : "''");
if (search_by_ids)
appendPQExpBuffer(&columns_query, " and c.oid = %u", reloid);
else
@@ -2857,7 +2859,11 @@
/*
* Create the query to find out if this is a view or not...
*/
- appendPQExpBufferStr(&columns_query, "select c.relhasrules, c.relkind, c.relhasoids");
+ appendPQExpBufferStr(&columns_query, "select c.relhasrules, c.relkind");
+ if (PG_VERSION_LT(conn, 12.0))
+ appendPQExpBufferStr(&columns_query, ", c.relhasoids");
+ else
+ appendPQExpBufferStr(&columns_query, ", 0 as relhasoids");
appendPQExpBufferStr(&columns_query, " from pg_catalog.pg_namespace u,"
" pg_catalog.pg_class c where "
"u.oid = c.relnamespace");
@@ -3246,7 +3252,7 @@
initPQExpBuffer(&index_query);
printfPQExpBuffer(&index_query, "select c.relname, i.indkey, i.indisunique"
", i.indisclustered, a.amname, c.relhasrules, n.nspname"
- ", c.oid, d.relhasoids, %s"
+ ", c.oid, %s, %s"
" from pg_catalog.pg_index i, pg_catalog.pg_class c,"
" pg_catalog.pg_class d, pg_catalog.pg_am a,"
" pg_catalog.pg_namespace n"
@@ -3256,6 +3262,7 @@
" and d.oid = i.indrelid"
" and i.indexrelid = c.oid"
" and c.relam = a.oid order by"
+ , PG_VERSION_LT(conn, 12.0) ? "d.relhasoids" : "0"
, PG_VERSION_GE(conn, 8.3) ? "i.indoption" : "0"
, eq_string, escTableName, eq_string, escSchemaName);
appendPQExpBufferStr(&index_query, " i.indisprimary desc,");
diff --git a/parse.c b/parse.c
index e7cb847..0ff76bc 100644
--- a/parse.c
+++ b/parse.c
@@ -474,6 +474,8 @@
TABLE_INFO *ti;
MYLOG(0, "Entering\n");
+ if (PG_VERSION_GE(conn, 12.0))
+ return FALSE;
if (0 != SC_checked_hasoids(stmt))
return TRUE;
if (!stmt->ti || !stmt->ti[0])