From edfca4b98b44f336ca88b2adf4dfbe6b59d7b146 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Tue, 23 Jan 2001 20:36:30 +0000 Subject: [PATCH] Subject: Bug in SQLForeignKeys() Query used for checking foreign key triggers returns too many results when there're more than one foreign key in a table. It happens because only table's oid is used to link between pg_trigger with INSERT check and pg_trigger with UPDATE/DELETE check. I think there should be enough to add following conditions into WHERE clause of that query: AND pt.tgconstrname = pg_trigger.tgconstrname AND pt.tgconstrname = pg_trigger_1.tgconstrname /Constantin --- src/interfaces/odbc/info.c | 4 +++- src/interfaces/odbc/pgtypes.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/interfaces/odbc/info.c b/src/interfaces/odbc/info.c index 165fd0bcae..cebc305da3 100644 --- a/src/interfaces/odbc/info.c +++ b/src/interfaces/odbc/info.c @@ -2368,7 +2368,9 @@ Int2 result_cols; "AND (pg_proc.proname LIKE '%%upd') " "AND (pg_proc_1.proname LIKE '%%del') " "AND (pg_trigger.tgrelid=pt.tgconstrrelid) " - "AND (pg_trigger_1.tgrelid = pt.tgconstrrelid))", + "AND (pg_trigger.tgconstrname=pt.tgconstrname) " + "AND (pg_trigger_1.tgrelid=pt.tgconstrrelid) " + "AND (pg_trigger_1.tgconstrname=pt.tgconstrname))", fk_table_needed); result = SQLExecDirect(htbl_stmt, tables_query, strlen(tables_query)); diff --git a/src/interfaces/odbc/pgtypes.c b/src/interfaces/odbc/pgtypes.c index 4263eea7b8..ebee8ab262 100644 --- a/src/interfaces/odbc/pgtypes.c +++ b/src/interfaces/odbc/pgtypes.c @@ -217,7 +217,9 @@ Int2 pgtype_to_sqltype(StatementClass *stmt, Int4 type) case PG_TYPE_XID: case PG_TYPE_INT4: return SQL_INTEGER; - case PG_TYPE_INT8: return SQL_BIGINT; + /* Change this to SQL_BIGINT for ODBC v3 bjm 2001-01-23 */ + case PG_TYPE_INT8: return SQL_CHAR; + case PG_TYPE_NUMERIC: return SQL_NUMERIC; case PG_TYPE_FLOAT4: return SQL_REAL;