From 363fc966f5227a7101e8907200a2f3d7bbd700ea Mon Sep 17 00:00:00 2001 From: anolis-bot Date: Wed, 6 Jul 2022 11:12:18 +0800 Subject: [PATCH 1/2] update to postgresql-odbc-10.03.0000-3.el8_6.src.rpm --- 1001-postgresql-odbc-gcc10.patch | 25 --- postgresql-odbc-10.03.0000-pg12-fixes.patch | 217 ++++++++++++++++++++ postgresql-odbc.spec | 15 +- 3 files changed, 223 insertions(+), 34 deletions(-) delete mode 100644 1001-postgresql-odbc-gcc10.patch create mode 100644 postgresql-odbc-10.03.0000-pg12-fixes.patch diff --git a/1001-postgresql-odbc-gcc10.patch b/1001-postgresql-odbc-gcc10.patch deleted file mode 100644 index 3d3288b..0000000 --- a/1001-postgresql-odbc-gcc10.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 8e79318bf7b32715433f6135cf4e324067c5b737 Mon Sep 17 00:00:00 2001 -From: Hiroshi Inoue -Date: Sun, 26 Jul 2020 18:29:49 +0900 -Subject: [PATCH] Fix a compilation error with GCC 10 due to conflicting - variable names. Patch by Paul Wise. - ---- - test/reset-db.c | 2 -- - 1 file changed, 2 deletions(-) - -diff --git a/test/reset-db.c b/test/reset-db.c -index 80946c8..5e05019 100644 ---- a/test/reset-db.c -+++ b/test/reset-db.c -@@ -17,8 +17,6 @@ - - #include "src/common.h" - --SQLHENV env; --SQLHDBC conn; - static HSTMT hstmt = SQL_NULL_HSTMT; - - static void --- -2.20.1 diff --git a/postgresql-odbc-10.03.0000-pg12-fixes.patch b/postgresql-odbc-10.03.0000-pg12-fixes.patch new file mode 100644 index 0000000..2c1b63e --- /dev/null +++ b/postgresql-odbc-10.03.0000-pg12-fixes.patch @@ -0,0 +1,217 @@ +Backport PG12>= fixes from upstream. +Commits: + - 2be35a64b0143cb8648f44ed4745bfddfeb96e55 + - 4ee79572296a8b3ca234c9521391bac86a18ec59 + +Description: 'relhasoids' was dropped in PG12 and that caused issues with predefined queries in odbc. + +Resolves: #2061312 + +--- a/configure.ac 2018-05-19 12:43:56.000000000 +0200 ++++ b/configure.ac 2022-03-24 15:45:03.420713295 +0100 +@@ -138,7 +138,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 +--- a/info.c 2018-05-19 12:32:53.000000000 +0200 ++++ b/info.c 2022-03-24 15:44:11.294453181 +0100 +@@ -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,12 @@ + /* + * 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"); +@@ -3243,7 +3250,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" +@@ -3253,7 +3260,8 @@ + " and d.oid = i.indrelid" + " and i.indexrelid = c.oid" + " and c.relam = a.oid order by" +- , PG_VERSION_GE(conn, 8.3) ? "i.indoption" : "0" ++ , 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,"); + appendPQExpBufferStr(&index_query, " i.indisunique, n.nspname, c.relname"); +--- a/parse.c 2022-03-24 15:41:07.544536251 +0100 ++++ b/parse.c 2022-03-28 12:10:34.656785167 +0200 +@@ -379,12 +379,22 @@ + } + } + +-static BOOL CheckHasOidsUsingSaved(StatementClass *stmt, TABLE_INFO *ti) ++/* ++ * Check relhasoids(before PG12), relhssubclass and get some relevant information. ++ */ ++BOOL CheckPgClassInfo(StatementClass *stmt) + { + const COL_INFO *coli; + int table_info; ++ TABLE_INFO *ti; + BOOL hasoids = FALSE, hassubclass =FALSE, keyFound = FALSE; + ++MYLOG(0, "Entering\n"); ++ if (0 != SC_checked_hasoids(stmt)) ++ return TRUE; ++ if (!stmt->ti || !stmt->ti[0]) ++ return FALSE; ++ ti = stmt->ti[0]; + MYLOG(DETAIL_LOG_LEVEL, "ti->col_info=%p\n", ti->col_info); + if (TI_checked_hasoids(ti)) + ; +@@ -465,93 +475,6 @@ + return TRUE; + } + +-static BOOL CheckHasOids(StatementClass * stmt) +-{ +- QResultClass *res; +- BOOL hasoids = TRUE, hassubclass =FALSE, foundKey = FALSE; +- char query[512]; +- ConnectionClass *conn = SC_get_conn(stmt); +- TABLE_INFO *ti; +- +-MYLOG(0, "Entering\n"); +- if (0 != SC_checked_hasoids(stmt)) +- return TRUE; +- if (!stmt->ti || !stmt->ti[0]) +- return FALSE; +- ti = stmt->ti[0]; +- if (CheckHasOidsUsingSaved(stmt, ti)) +- return TRUE; +- // no longer come here?? +- SPRINTF_FIXED(query, +- "select relhasoids, c.oid, relhassubclass from pg_class c, pg_namespace n where relname = '%s' and nspname = '%s' and c.relnamespace = n.oid", +- SAFE_NAME(ti->table_name), SAFE_NAME(ti->schema_name)); +- res = CC_send_query(conn, query, NULL, READ_ONLY_QUERY, NULL); +- if (QR_command_maybe_successful(res)) +- { +- stmt->num_key_fields = PG_NUM_NORMAL_KEYS; +- if (1 == QR_get_num_total_tuples(res)) +- { +- const char *value = QR_get_value_backend_text(res, 0, 0); +- const char *value2 = QR_get_value_backend_text(res, 0, 2); +- if (value && ('f' == *value || '0' == *value)) +- { +- hasoids = FALSE; +- TI_set_has_no_oids(ti); +- } +- else +- { +- TI_set_hasoids(ti); +- foundKey = TRUE; +- STR_TO_NAME(ti->bestitem, OID_NAME); +- STRX_TO_NAME(ti->bestqual, "\"" OID_NAME "\" = %u"); +- } +- if (value2 && ('f' == *value2 || '0' == *value2)) +- { +- TI_set_has_no_subclass(ti); +- } +- else +- { +- hassubclass = TRUE; +- TI_set_hassubclass(ti); +- STR_TO_NAME(ti->bestitem, TABLEOID_NAME); +- STRX_TO_NAME(ti->bestqual, "\"" TABLEOID_NAME "\" = %u"); +- } +- TI_set_hasoids_checked(ti); +- ti->table_oid = (OID) strtoul(QR_get_value_backend_text(res, 0, 1), NULL, 10); +- } +- QR_Destructor(res); +- res = NULL; +- if (!hasoids && !hassubclass) +- { +- SPRINTF_FIXED(query, "select a.attname, a.atttypid from pg_index i, pg_attribute a where indrelid=%u and indnatts=1 and indisunique and indexprs is null and indpred is null and i.indrelid = a.attrelid and a.attnum=i.indkey[0] and attnotnull and atttypid in (%d, %d)", ti->table_oid, PG_TYPE_INT4, PG_TYPE_OID); +- res = CC_send_query(conn, query, NULL, READ_ONLY_QUERY, NULL); +- if (QR_command_maybe_successful(res) && QR_get_num_total_tuples(res) > 0) +- { +- foundKey = TRUE; +- STR_TO_NAME(ti->bestitem, QR_get_value_backend_text(res, 0, 0)); +- SPRINTF_FIXED(query, "\"%s\" = %%", SAFE_NAME(ti->bestitem)); +- if (PG_TYPE_INT4 == (OID) QR_get_value_backend_int(res, 0, 1, NULL)) +- STRCAT_FIXED(query, "d"); +- else +- STRCAT_FIXED(query, "u"); +- STRX_TO_NAME(ti->bestqual, query); +- } +- else +- { +- /* stmt->updatable = FALSE; */ +- foundKey = TRUE; +- stmt->num_key_fields--; +- } +- } +- } +- QR_Destructor(res); +- SC_set_checked_hasoids(stmt, foundKey); +- +- MYLOG(DETAIL_LOG_LEVEL, "subclass=%d oids=%d bestqual=%s foundKey=%d num_key_fields=%d\n", TI_has_subclass(ti), TI_has_oids(ti), PRINT_NAME(ti->bestqual), foundKey, stmt->num_key_fields); +- +- return TRUE; +-} +- + static BOOL increaseNtab(StatementClass *stmt, const char *func) + { + TABLE_INFO **ti = stmt->ti, *wti; +@@ -1383,7 +1304,7 @@ + if (SC_parsed_status(stmt) != STMT_PARSE_NONE) + { + if (check_hasoids) +- CheckHasOids(stmt); ++ CheckPgClassInfo(stmt); + return TRUE; + } + nfields = 0; +@@ -2261,7 +2182,7 @@ + } + + if (check_hasoids && updatable) +- CheckHasOids(stmt); ++ CheckPgClassInfo(stmt); + SC_set_parse_status(stmt, parse ? STMT_PARSE_COMPLETE : STMT_PARSE_INCOMPLETE); + for (i = 0; i < (int) irdflds->nfields; i++) + { +--- a/statement.h 2018-05-19 12:32:53.000000000 +0200 ++++ b/statement.h 2022-03-28 12:11:20.015023357 +0200 +@@ -542,6 +542,7 @@ + RETCODE DiscardStatementSvp(StatementClass *self, RETCODE, BOOL errorOnly); + + QResultClass *ParseAndDescribeWithLibpq(StatementClass *stmt, const char *plan_name, const char *query_p, Int2 num_params, const char *comment, QResultClass *res); ++BOOL CheckPgClassInfo(StatementClass *); + + /* + * Macros to convert global index <-> relative index in resultset/rowset diff --git a/postgresql-odbc.spec b/postgresql-odbc.spec index 6315cfa..0ce24ca 100644 --- a/postgresql-odbc.spec +++ b/postgresql-odbc.spec @@ -1,10 +1,9 @@ -%define anolis_release .0.1 %global upstream_name psqlodbc Name: postgresql-odbc Summary: PostgreSQL ODBC driver Version: 10.03.0000 -Release: 2%{anolis_release}%{?dist} +Release: 3%{?dist} License: LGPLv2+ Group: Applications/Databases URL: https://odbc.postgresql.org/ @@ -13,11 +12,8 @@ Source0: http://ftp.postgresql.org/pub/odbc/versions/src/%{upstream_name}-%{vers Patch0: postgresql-odbc-09.06.0200-revert-money-fix.patch Patch1: postgresql-odbc-09.05.0400-revert-money-testsuite-fix.patch - -# Begin: Anolis customized patches -# backport patch from upstream -Patch1001: 1001-postgresql-odbc-gcc10.patch -# End: Anolis customized patches +# This patch (backport) can be removed during rebase to version >= 12.00.xxx +Patch2: postgresql-odbc-10.03.0000-pg12-fixes.patch BuildRequires: unixODBC-devel postgresql-devel BuildRequires: libpq-devel @@ -110,8 +106,9 @@ the PostgreSQL unixODBC driver. %changelog -* Tue Nov 30 2021 Weitao Zhou 10.03.0000-2.0.1 -- Fix a compilation error with GCC 10 due to conflicting variable names +* Mon Mar 28 2022 Marek Kulik - 10.03.0000-3 +- add patch postgresql-odbc-10.03.0000-pg12-fixes + Resolves: #2080179 * Wed May 30 2018 Pavel Raiskup - 10.03.0000-2 - rebuild for metadata fix (upstream URL) -- Gitee From 781c9f8e35bb3b6db2b4ddc7c01c3b98b7041a05 Mon Sep 17 00:00:00 2001 From: Liwei Ge Date: Fri, 9 Oct 2020 16:02:01 +0800 Subject: [PATCH 2/2] Fix a compilation error with GCC 10 due to conflicting variable names this change has given better compatible with both gcc8 and gcc10 toolchain, should be maintained util upstream fixes Signed-off-by: Liwei Ge Signed-off-by: weitao zhou --- 1001-postgresql-odbc-gcc10.patch | 25 +++++++++++++++++++++++++ postgresql-odbc.spec | 11 ++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 1001-postgresql-odbc-gcc10.patch diff --git a/1001-postgresql-odbc-gcc10.patch b/1001-postgresql-odbc-gcc10.patch new file mode 100644 index 0000000..3d3288b --- /dev/null +++ b/1001-postgresql-odbc-gcc10.patch @@ -0,0 +1,25 @@ +From 8e79318bf7b32715433f6135cf4e324067c5b737 Mon Sep 17 00:00:00 2001 +From: Hiroshi Inoue +Date: Sun, 26 Jul 2020 18:29:49 +0900 +Subject: [PATCH] Fix a compilation error with GCC 10 due to conflicting + variable names. Patch by Paul Wise. + +--- + test/reset-db.c | 2 -- + 1 file changed, 2 deletions(-) + +diff --git a/test/reset-db.c b/test/reset-db.c +index 80946c8..5e05019 100644 +--- a/test/reset-db.c ++++ b/test/reset-db.c +@@ -17,8 +17,6 @@ + + #include "src/common.h" + +-SQLHENV env; +-SQLHDBC conn; + static HSTMT hstmt = SQL_NULL_HSTMT; + + static void +-- +2.20.1 diff --git a/postgresql-odbc.spec b/postgresql-odbc.spec index 0ce24ca..aaccce5 100644 --- a/postgresql-odbc.spec +++ b/postgresql-odbc.spec @@ -1,9 +1,10 @@ +%define anolis_release .0.1 %global upstream_name psqlodbc Name: postgresql-odbc Summary: PostgreSQL ODBC driver Version: 10.03.0000 -Release: 3%{?dist} +Release: 3%{anolis_release}%{?dist} License: LGPLv2+ Group: Applications/Databases URL: https://odbc.postgresql.org/ @@ -15,6 +16,11 @@ Patch1: postgresql-odbc-09.05.0400-revert-money-testsuite-fix.patch # This patch (backport) can be removed during rebase to version >= 12.00.xxx Patch2: postgresql-odbc-10.03.0000-pg12-fixes.patch +# Begin: Anolis customized patches +# backport patch from upstream +Patch1001: 1001-postgresql-odbc-gcc10.patch +# End: Anolis customized patches + BuildRequires: unixODBC-devel postgresql-devel BuildRequires: libpq-devel @@ -106,6 +112,9 @@ the PostgreSQL unixODBC driver. %changelog +* Thu Jul 07 2022 Weitao Zhou 10.03.0000-3.0.1 +- Fix a compilation error with GCC 10 due to conflicting variable names + * Mon Mar 28 2022 Marek Kulik - 10.03.0000-3 - add patch postgresql-odbc-10.03.0000-pg12-fixes Resolves: #2080179 -- Gitee