Skip to content

Commit 6e99e75

Browse files
authored
use operator(pg_catalog.operator) to fully qualify the operator (#139)
1 parent 6e9a1f8 commit 6e99e75

File tree

1 file changed

+71
-71
lines changed

1 file changed

+71
-71
lines changed

info.c

Lines changed: 71 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1725,8 +1725,8 @@ MYLOG(0, "leaving output=%s(%d)\n", dest, outlen);
17251725

17261726
CSTR like_op_sp = "like ";
17271727
CSTR like_op_ext = "like E";
1728-
CSTR eq_op_sp = "= ";
1729-
CSTR eq_op_ext = "= E";
1728+
CSTR eq_op_sp = "operator(pg_catalog.=) ";
1729+
CSTR eq_op_ext = "operator(pg_catalog.=) E";
17301730

17311731
#define IS_VALID_NAME(str) ((str) && (str)[0])
17321732

@@ -2460,7 +2460,7 @@ PGAPI_Columns(HSTMT hstmt,
24602460
appendPQExpBufferStr(&columns_query, ") inner join pg_catalog.pg_attribute a"
24612461
" on (not a.attisdropped)");
24622462
if (0 == attnum && (NULL == escColumnName || like_or_eq != eqop))
2463-
appendPQExpBufferStr(&columns_query, " and a.attnum > 0");
2463+
appendPQExpBufferStr(&columns_query, " and a.attnum operator(pg_catalog.>) 0");
24642464
if (search_by_ids)
24652465
{
24662466
if (attnum != 0)
@@ -2469,9 +2469,9 @@ PGAPI_Columns(HSTMT hstmt,
24692469
else if (escColumnName)
24702470
appendPQExpBuffer(&columns_query, " and a.attname %s'%s'", op_string, escColumnName);
24712471
appendPQExpBufferStr(&columns_query,
2472-
" and a.attrelid = c.oid) inner join pg_catalog.pg_type t"
2473-
" on t.oid = a.atttypid) left outer join pg_attrdef d"
2474-
" on a.atthasdef and d.adrelid = a.attrelid and d.adnum = a.attnum");
2472+
" and a.attrelid operator(pg_catalog.=) c.oid) inner join pg_catalog.pg_type t"
2473+
" on t.oid operator(pg_catalog.=) a.atttypid) left outer join pg_attrdef d"
2474+
" on a.atthasdef and d.adrelid operator(pg_catalog.=) a.attrelid and d.adnum operator(pg_catalog.=) a.attnum");
24752475
appendPQExpBufferStr(&columns_query, " order by n.nspname, c.relname, attnum");
24762476
if (PQExpBufferDataBroken(columns_query))
24772477
{
@@ -2485,7 +2485,7 @@ PGAPI_Columns(HSTMT hstmt,
24852485
goto cleanup;
24862486
}
24872487

2488-
MYLOG(0, "col_stmt = %p\n", col_stmt);
2488+
MYLOG(0, "col_stmt operator(pg_catalog.=) %p\n", col_stmt);
24892489

24902490
result = PGAPI_ExecDirect(col_stmt, (SQLCHAR *) columns_query.data, SQL_NTS, PODBC_RDONLY);
24912491
if (!SQL_SUCCEEDED(result))
@@ -3044,7 +3044,7 @@ PGAPI_SpecialColumns(HSTMT hstmt,
30443044

30453045
appendPQExpBufferStr(&columns_query, " from pg_catalog.pg_namespace u,"
30463046
" pg_catalog.pg_class c where "
3047-
"u.oid = c.relnamespace");
3047+
"u.oid operator(pg_catalog.=) c.relnamespace");
30483048

30493049
/* TableName cannot contain a string search pattern */
30503050
if (escTableName)
@@ -3482,10 +3482,10 @@ PGAPI_Statistics(HSTMT hstmt,
34823482
" pg_catalog.pg_namespace n"
34833483
" where d.relname %s'%s'"
34843484
" and n.nspname %s'%s'"
3485-
" and n.oid = d.relnamespace"
3486-
" and d.oid = i.indrelid"
3487-
" and i.indexrelid = c.oid"
3488-
" and c.relam = a.oid order by"
3485+
" and n.oid operator(pg_catalog.=) d.relnamespace"
3486+
" and d.oid operator(pg_catalog.=) i.indrelid"
3487+
" and i.indexrelid operator(pg_catalog.=) c.oid"
3488+
" and c.relam operator(pg_catalog.=) a.oid order by"
34893489
, PG_VERSION_LT(conn, 12.0) ? "d.relhasoids" : "0"
34903490
, PG_VERSION_GE(conn, 8.3) ? "i.indoption" : "0"
34913491
, eq_string, escTableName, eq_string, escSchemaName);
@@ -4047,15 +4047,15 @@ PGAPI_PrimaryKeys(HSTMT hstmt,
40474047
appendPQExpBuffer(&tables_query, " where tc.oid = %u", reloid);
40484048

40494049
appendPQExpBufferStr(&tables_query,
4050-
" AND tc.oid = i.indrelid"
4051-
" AND n.oid = tc.relnamespace"
4052-
" AND i.indisprimary = 't'"
4053-
" AND ia.attrelid = i.indexrelid"
4054-
" AND ta.attrelid = i.indrelid"
4055-
" AND ta.attnum = i.indkey[ia.attnum-1]"
4050+
" AND tc.oid operator(pg_catalog.=) i.indrelid"
4051+
" AND n.oid operator(pg_catalog.=) tc.relnamespace"
4052+
" AND i.indisprimary operator(pg_catalog.=) 't'"
4053+
" AND ia.attrelid operator(pg_catalog.=) i.indexrelid"
4054+
" AND ta.attrelid operator(pg_catalog.=) i.indrelid"
4055+
" AND ta.attnum operator(pg_catalog.=) i.indkey[ia.attnum-1]"
40564056
" AND (NOT ta.attisdropped)"
40574057
" AND (NOT ia.attisdropped)"
4058-
" AND ic.oid = i.indexrelid"
4058+
" AND ic.oid operator(pg_catalog.=) i.indexrelid"
40594059
" order by ia.attnum");
40604060
break;
40614061
case 2:
@@ -4069,11 +4069,11 @@ PGAPI_PrimaryKeys(HSTMT hstmt,
40694069
" pg_catalog.pg_index i, pg_catalog.pg_namespace n"
40704070
" where ic.relname %s'%s_pkey'"
40714071
" AND n.nspname %s'%s'"
4072-
" AND ic.oid = i.indexrelid"
4073-
" AND n.oid = ic.relnamespace"
4074-
" AND ia.attrelid = i.indexrelid"
4075-
" AND ta.attrelid = i.indrelid"
4076-
" AND ta.attnum = i.indkey[ia.attnum-1]"
4072+
" AND ic.oid operator(pg_catalog.=) i.indexrelid"
4073+
" AND n.oid operator(pg_catalog.=) ic.relnamespace"
4074+
" AND ia.attrelid operator(pg_catalog.=) i.indexrelid"
4075+
" AND ta.attrelid operator(pg_catalog.=) i.indrelid"
4076+
" AND ta.attnum operator(pg_catalog.=) i.indkey[ia.attnum-1]"
40774077
" AND (NOT ta.attisdropped)"
40784078
" AND (NOT ia.attisdropped)"
40794079
" order by ia.attnum", eq_string, escTableName, eq_string, pkscm);
@@ -4225,7 +4225,7 @@ getClientColumnName(ConnectionClass *conn, UInt4 relid, char *serverColumnName,
42254225
if (!bError && continueExec)
42264226
{
42274227
SPRINTF_FIXED(query, "select attnum from pg_attribute "
4228-
"where attrelid = %u and attname %s'%s'",
4228+
"where attrelid operator(pg_catalog.=) %u and attname %s'%s'",
42294229
relid, eq_string, serverColumnName);
42304230
if (res = CC_send_query(conn, query, NULL, flag, NULL), QR_command_maybe_successful(res))
42314231
{
@@ -4247,7 +4247,7 @@ getClientColumnName(ConnectionClass *conn, UInt4 relid, char *serverColumnName,
42474247
QR_Destructor(res);
42484248
if (bError || !continueExec)
42494249
return ret;
4250-
SPRINTF_FIXED(query, "select attname from pg_attribute where attrelid = %u and attnum = %s", relid, saveattnum);
4250+
SPRINTF_FIXED(query, "select attname from pg_attribute where attrelid operator(pg_catalog.=) %u and attnum operator(pg_catalog.=) %s", relid, saveattnum);
42514251
if (res = CC_send_query(conn, query, NULL, flag, NULL), QR_command_maybe_successful(res))
42524252
{
42534253
if (QR_get_num_cached_tuples(res) > 0)
@@ -4445,25 +4445,25 @@ PGAPI_ForeignKeys_old(HSTMT hstmt,
44454445
" pg_catalog.pg_class pc1, "
44464446
" pg_catalog.pg_namespace pn, "
44474447
" pg_catalog.pg_namespace pn1 "
4448-
"WHERE pt.tgrelid = pc.oid "
4449-
"AND pp.oid = pt.tgfoid "
4450-
"AND pt1.tgconstrrelid = pc.oid "
4451-
"AND pp1.oid = pt1.tgfoid "
4452-
"AND pt2.tgfoid = pp2.oid "
4453-
"AND pt2.tgconstrrelid = pc.oid "
4448+
"WHERE pt.tgrelid operator(pg_catalog.=) pc.oid "
4449+
"AND pp.oid operator(pg_catalog.=) pt.tgfoid "
4450+
"AND pt1.tgconstrrelid operator(pg_catalog.=) pc.oid "
4451+
"AND pp1.oid operator(pg_catalog.=) pt1.tgfoid "
4452+
"AND pt2.tgfoid operator(pg_catalog.=) pp2.oid "
4453+
"AND pt2.tgconstrrelid operator(pg_catalog.=) pc.oid "
44544454
"AND ((pc.relname %s'%s') "
4455-
"AND (pn1.oid = pc.relnamespace) "
4455+
"AND (pn1.oid operator(pg_catalog.=) pc.relnamespace) "
44564456
"AND (pn1.nspname %s'%s') "
44574457
"AND (pp.proname LIKE '%%ins') "
44584458
"AND (pp1.proname LIKE '%%upd') "
44594459
"AND (pp1.proname not LIKE '%%check%%') "
44604460
"AND (pp2.proname LIKE '%%del') "
4461-
"AND (pt1.tgrelid=pt.tgconstrrelid) "
4462-
"AND (pt1.tgconstrname=pt.tgconstrname) "
4463-
"AND (pt2.tgrelid=pt.tgconstrrelid) "
4464-
"AND (pt2.tgconstrname=pt.tgconstrname) "
4465-
"AND (pt.tgconstrrelid=pc1.oid) "
4466-
"AND (pc1.relnamespace=pn.oid))"
4461+
"AND (pt1.tgrelid operator(pg_catalog.=) pt.tgconstrrelid) "
4462+
"AND (pt1.tgconstrname operator(pg_catalog.=) pt.tgconstrname) "
4463+
"AND (pt2.tgrelid operator(pg_catalog.=) pt.tgconstrrelid) "
4464+
"AND (pt2.tgconstrname operator(pg_catalog.=) pt.tgconstrname) "
4465+
"AND (pt.tgconstrrelid operator(pg_catalog.=) pc1.oid) "
4466+
"AND (pc1.relnamespace operator(pg_catalog.=) pn.oid))"
44674467
" order by pt.tgconstrname",
44684468
eq_string, escFkTableName, eq_string, escSchemaName);
44694469
free(escSchemaName);
@@ -4769,23 +4769,23 @@ PGAPI_ForeignKeys_old(HSTMT hstmt,
47694769
" pg_catalog.pg_namespace pn1 "
47704770
"WHERE pc.relname %s'%s' "
47714771
" AND pn.nspname %s'%s' "
4772-
" AND pc.relnamespace = pn.oid "
4773-
" AND pt.tgconstrrelid = pc.oid "
4774-
" AND pp.oid = pt.tgfoid "
4772+
" AND pc.relnamespace operator(pg_catalog.=) pn.oid "
4773+
" AND pt.tgconstrrelid operator(pg_catalog.=) pc.oid "
4774+
" AND pp.oid operator(pg_catalog.=) pt.tgfoid "
47754775
" AND pp.proname Like '%%ins' "
4776-
" AND pt1.tgconstrname = pt.tgconstrname "
4777-
" AND pt1.tgconstrrelid = pt.tgrelid "
4778-
" AND pt1.tgrelid = pc.oid "
4779-
" AND pc1.oid = pt.tgrelid "
4780-
" AND pp1.oid = pt1.tgfoid "
4776+
" AND pt1.tgconstrname operator(pg_catalog.=) pt.tgconstrname "
4777+
" AND pt1.tgconstrrelid operator(pg_catalog.=) pt.tgrelid "
4778+
" AND pt1.tgrelid operator(pg_catalog.=) pc.oid "
4779+
" AND pc1.oid operator(pg_catalog.=) pt.tgrelid "
4780+
" AND pp1.oid operator(pg_catalog.=) pt1.tgfoid "
47814781
" AND pp1.proname like '%%upd' "
47824782
" AND (pp1.proname not like '%%check%%') "
4783-
" AND pt2.tgconstrname = pt.tgconstrname "
4784-
" AND pt2.tgconstrrelid = pt.tgrelid "
4785-
" AND pt2.tgrelid = pc.oid "
4786-
" AND pp2.oid = pt2.tgfoid "
4783+
" AND pt2.tgconstrname operator(pg_catalog.=) pt.tgconstrname "
4784+
" AND pt2.tgconstrrelid operator(pg_catalog.=) pt.tgrelid "
4785+
" AND pt2.tgrelid operator(pg_catalog.=) pc.oid "
4786+
" AND pp2.oid operator(pg_catalog.=) pt2.tgfoid "
47874787
" AND pp2.proname Like '%%del' "
4788-
" AND pn1.oid = pc1.relnamespace "
4788+
" AND pn1.oid operator(pg_catalog.=) pc1.relnamespace "
47894789
" order by pt.tgconstrname",
47904790
eq_string, escPkTableName, eq_string, escSchemaName);
47914791
free(escSchemaName);
@@ -5197,14 +5197,14 @@ PGAPI_ProcedureColumns(HSTMT hstmt,
51975197
}
51985198
#ifdef PRORET_COUNT
51995199
appendPQExpBufferStr(&proc_query, " from ((pg_catalog.pg_namespace n inner join"
5200-
" pg_catalog.pg_proc p on p.pronamespace = n.oid)"
5201-
" inner join pg_type t on t.oid = p.prorettype)"
5202-
" left outer join pg_attribute a on a.attrelid = t.typrelid "
5203-
" and attnum > 0 and not attisdropped where");
5200+
" pg_catalog.pg_proc p on p.pronamespace operator(pg_catalog.=) n.oid)"
5201+
" inner join pg_type t on t.oid operator(pg_catalog.=) p.prorettype)"
5202+
" left outer join pg_attribute a on a.attrelid operator(pg_catalog.=) t.typrelid "
5203+
" and attnum operator(pg_catalog.>) 0 and not attisdropped where");
52045204
#else
52055205
appendPQExpBufferStr(&proc_query, " from pg_catalog.pg_namespace n,"
52065206
" pg_catalog.pg_proc p where");
5207-
" p.pronamespace = n.oid and"
5207+
" p.pronamespace operator(pg_catalog.=) n.oid and"
52085208
" (not proretset) and");
52095209
#endif /* PRORET_COUNT */
52105210
appendPQExpBuffer(&proc_query,
@@ -5769,11 +5769,11 @@ PGAPI_TablePrivileges(HSTMT hstmt,
57695769

57705770
if (escTableName)
57715771
appendPQExpBuffer(&proc_query, " relname %s'%s' and", op_string, escTableName);
5772-
appendPQExpBufferStr(&proc_query, " pg_namespace.oid = relnamespace and relkind in " TABLE_IN_RELKIND " and");
5772+
appendPQExpBufferStr(&proc_query, " pg_namespace.oid operator(pg_catalog.=) relnamespace and relkind in " TABLE_IN_RELKIND " and");
57735773
if ((!escTableName) && (!escSchemaName))
57745774
appendPQExpBufferStr(&proc_query, " nspname not in ('pg_catalog', 'information_schema') and");
57755775

5776-
appendPQExpBufferStr(&proc_query, " pg_user.usesysid = relowner");
5776+
appendPQExpBufferStr(&proc_query, " pg_user.usesysid operator(pg_catalog.=) relowner");
57775777
if (PQExpBufferDataBroken(proc_query))
57785778
{
57795779
SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Out of memory in PGAPI_TablePrivileges()", func);
@@ -6101,28 +6101,28 @@ PGAPI_ForeignKeys_new(HSTMT hstmt,
61016101
"\n from pg_catalog.pg_constraint cn"
61026102
",\n pg_catalog.pg_class c"
61036103
",\n pg_catalog.pg_namespace n"
6104-
"\n where contype = 'f' %s"
6104+
"\n where contype operator(pg_catalog.=) 'f' %s"
61056105
"\n and relname %s'%s'"
6106-
"\n and n.oid = c.relnamespace"
6106+
"\n and n.oid operator(pg_catalog.=) c.relnamespace"
61076107
"\n and n.nspname %s'%s'"
61086108
"\n ) ref"
61096109
"\n inner join pg_catalog.pg_class c1"
6110-
"\n on c1.oid = ref.conrelid)"
6110+
"\n on c1.oid operator(pg_catalog.=) ref.conrelid)"
61116111
"\n inner join pg_catalog.pg_namespace n1"
6112-
"\n on n1.oid = c1.relnamespace)"
6112+
"\n on n1.oid operator(pg_catalog.=) c1.relnamespace)"
61136113
"\n inner join pg_catalog.pg_attribute a1"
6114-
"\n on a1.attrelid = c1.oid"
6115-
"\n and a1.attnum = conkey[i])"
6114+
"\n on a1.attrelid operator(pg_catalog.=) c1.oid"
6115+
"\n and a1.attnum operator(pg_catalog.=) conkey[i])"
61166116
"\n inner join pg_catalog.pg_class c2"
6117-
"\n on c2.oid = ref.confrelid)"
6117+
"\n on c2.oid operator(pg_catalog.=) ref.confrelid)"
61186118
"\n inner join pg_catalog.pg_namespace n2"
6119-
"\n on n2.oid = c2.relnamespace)"
6119+
"\n on n2.oid operator(pg_catalog.=) c2.relnamespace)"
61206120
"\n inner join pg_catalog.pg_attribute a2"
6121-
"\n on a2.attrelid = c2.oid"
6122-
"\n and a2.attnum = confkey[i])"
6121+
"\n on a2.attrelid operator(pg_catalog.=) c2.oid"
6122+
"\n and a2.attnum operator(pg_catalog.=) confkey[i])"
61236123
"\n left outer join pg_catalog.pg_constraint cn"
6124-
"\n on cn.conrelid = ref.confrelid"
6125-
"\n and cn.contype = 'p')"
6124+
"\n on cn.conrelid operator(pg_catalog.=) ref.confrelid"
6125+
"\n and cn.contype operator(pg_catalog.=) 'p')"
61266126
, catName
61276127
, scmName1
61286128
, catName

0 commit comments

Comments
 (0)