From 4ee79572296a8b3ca234c9521391bac86a18ec59 Mon Sep 17 00:00:00 2001 From: Hiroshi Inoue Date: Sun, 28 Apr 2019 13:13:26 +0900 Subject: [PATCH] =?utf8?q?Because=20the=20field=20'relhasoids'=20was=20dro?= =?utf8?q?pped=20in=20PG12,=20psqlodbc=20drivers=20would=20have=20some=20t?= =?utf8?q?roubles=20with=20PG12=20servers.=20Report=20and=20patch=20by=20V?= =?utf8?q?ladimir=20Kokovi=C4=87.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- configure.ac | 2 +- info.c | 15 +++++++++++---- parse.c | 2 ++ 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 12f3844..bff7f5a 100644 --- a/configure.ac +++ b/configure.ac @@ -152,7 +152,7 @@ fi 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 aac845f..3090723 100644 --- a/info.c +++ b/info.c @@ -2346,9 +2346,11 @@ retry_public_schema: "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 @@ -2862,7 +2864,11 @@ retry_public_schema: /* * 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"); @@ -3251,7 +3257,7 @@ PGAPI_Statistics(HSTMT hstmt, 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" @@ -3261,6 +3267,7 @@ PGAPI_Statistics(HSTMT hstmt, " 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 @@ static BOOL CheckHasOids(StatementClass * stmt) 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]) -- 2.39.5