missing schema qualifications in psql
While psql is careful to schema-qualify all references to built-in
objects (pg_catalog.*), it completely neglects to do this for built-in
operators, which can lead to surprising misbehaviors when users have
created custom operators. Here is a patch to address that. It will
need a bit of testing.
pg_dump has similar problems, probably other components as well.
Attachments:
schema-qual.difftext/x-patch; charset=UTF-8; name=schema-qual.diffDownload
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 67a2b47..3ddcacc 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -71,7 +71,7 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem)
if (pset.sversion >= 80200)
appendPQExpBuffer(&buf,
- " CASE WHEN p.pronargs = 0\n"
+ " CASE WHEN p.pronargs OPERATOR(pg_catalog.=) 0\n"
" THEN CAST('*' AS pg_catalog.text)\n"
" ELSE\n"
" pg_catalog.array_to_string(ARRAY(\n"
@@ -90,13 +90,13 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem)
appendPQExpBuffer(&buf,
" pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n"
"FROM pg_catalog.pg_proc p\n"
- " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n"
+ " LEFT JOIN pg_catalog.pg_namespace n ON n.oid OPERATOR(pg_catalog.=) p.pronamespace\n"
"WHERE p.proisagg\n",
gettext_noop("Description"));
if (!showSystem && !pattern)
- appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"
- " AND n.nspname <> 'information_schema'\n");
+ appendPQExpBuffer(&buf, " AND n.nspname OPERATOR(pg_catalog.<>) 'pg_catalog'\n"
+ " AND n.nspname OPERATOR(pg_catalog.<>) 'information_schema'\n");
processSQLNamePattern(pset.db, &buf, pattern, true, false,
"n.nspname", "p.proname", NULL,
@@ -242,7 +242,7 @@ describeFunctions(const char *functypes, const char *pattern, bool verbose, bool
" CASE\n"
" WHEN p.proisagg THEN '%s'\n"
" WHEN p.proiswindow THEN '%s'\n"
- " WHEN p.prorettype = 'pg_catalog.trigger'::pg_catalog.regtype THEN '%s'\n"
+ " WHEN p.prorettype OPERATOR(pg_catalog.=) 'pg_catalog.trigger'::pg_catalog.regtype THEN '%s'\n"
" ELSE '%s'\n"
"END as \"%s\"",
gettext_noop("Result data type"),
@@ -255,21 +255,21 @@ describeFunctions(const char *functypes, const char *pattern, bool verbose, bool
gettext_noop("Type"));
else if (pset.sversion >= 80100)
appendPQExpBuffer(&buf,
- " CASE WHEN p.proretset THEN 'SETOF ' ELSE '' END ||\n"
+ " CASE WHEN p.proretset THEN 'SETOF ' ELSE '' END OPERATOR(pg_catalog.||)\n"
" pg_catalog.format_type(p.prorettype, NULL) as \"%s\",\n"
" CASE WHEN proallargtypes IS NOT NULL THEN\n"
" pg_catalog.array_to_string(ARRAY(\n"
" SELECT\n"
" CASE\n"
- " WHEN p.proargmodes[s.i] = 'i' THEN ''\n"
- " WHEN p.proargmodes[s.i] = 'o' THEN 'OUT '\n"
- " WHEN p.proargmodes[s.i] = 'b' THEN 'INOUT '\n"
- " WHEN p.proargmodes[s.i] = 'v' THEN 'VARIADIC '\n"
- " END ||\n"
+ " WHEN p.proargmodes[s.i] OPERATOR(pg_catalog.=) 'i' THEN ''\n"
+ " WHEN p.proargmodes[s.i] OPERATOR(pg_catalog.=) 'o' THEN 'OUT '\n"
+ " WHEN p.proargmodes[s.i] OPERATOR(pg_catalog.=) 'b' THEN 'INOUT '\n"
+ " WHEN p.proargmodes[s.i] OPERATOR(pg_catalog.=) 'v' THEN 'VARIADIC '\n"
+ " END OPERATOR(pg_catalog.||)\n"
" CASE\n"
- " WHEN COALESCE(p.proargnames[s.i], '') = '' THEN ''\n"
- " ELSE p.proargnames[s.i] || ' ' \n"
- " END ||\n"
+ " WHEN COALESCE(p.proargnames[s.i], '') OPERATOR(pg_catalog.=) '' THEN ''\n"
+ " ELSE p.proargnames[s.i] OPERATOR(pg_catalog.||) ' ' \n"
+ " END OPERATOR(pg_catalog.||)\n"
" pg_catalog.format_type(p.proallargtypes[s.i], NULL)\n"
" FROM\n"
" pg_catalog.generate_series(1, pg_catalog.array_upper(p.proallargtypes, 1)) AS s(i)\n"
@@ -278,9 +278,9 @@ describeFunctions(const char *functypes, const char *pattern, bool verbose, bool
" pg_catalog.array_to_string(ARRAY(\n"
" SELECT\n"
" CASE\n"
- " WHEN COALESCE(p.proargnames[s.i+1], '') = '' THEN ''\n"
- " ELSE p.proargnames[s.i+1] || ' '\n"
- " END ||\n"
+ " WHEN COALESCE(p.proargnames[s.i+1], '') OPERATOR(pg_catalog.=) '' THEN ''\n"
+ " ELSE p.proargnames[s.i+1] OPERATOR(pg_catalog.||) ' '\n"
+ " END OPERATOR(pg_catalog.||)\n"
" pg_catalog.format_type(p.proargtypes[s.i], NULL)\n"
" FROM\n"
" pg_catalog.generate_series(0, pg_catalog.array_upper(p.proargtypes, 1)) AS s(i)\n"
@@ -288,7 +288,7 @@ describeFunctions(const char *functypes, const char *pattern, bool verbose, bool
" END AS \"%s\",\n"
" CASE\n"
" WHEN p.proisagg THEN '%s'\n"
- " WHEN p.prorettype = 'pg_catalog.trigger'::pg_catalog.regtype THEN '%s'\n"
+ " WHEN p.prorettype OPERATOR(pg_catalog.=) 'pg_catalog.trigger'::pg_catalog.regtype THEN '%s'\n"
" ELSE '%s'\n"
" END AS \"%s\"",
gettext_noop("Result data type"),
@@ -300,12 +300,12 @@ describeFunctions(const char *functypes, const char *pattern, bool verbose, bool
gettext_noop("Type"));
else
appendPQExpBuffer(&buf,
- " CASE WHEN p.proretset THEN 'SETOF ' ELSE '' END ||\n"
+ " CASE WHEN p.proretset THEN 'SETOF ' ELSE '' END OPERATOR(pg_catalog.||)\n"
" pg_catalog.format_type(p.prorettype, NULL) as \"%s\",\n"
" pg_catalog.oidvectortypes(p.proargtypes) as \"%s\",\n"
" CASE\n"
" WHEN p.proisagg THEN '%s'\n"
- " WHEN p.prorettype = 'pg_catalog.trigger'::pg_catalog.regtype THEN '%s'\n"
+ " WHEN p.prorettype OPERATOR(pg_catalog.=) 'pg_catalog.trigger'::pg_catalog.regtype THEN '%s'\n"
" ELSE '%s'\n"
" END AS \"%s\"",
gettext_noop("Result data type"),
@@ -319,9 +319,9 @@ describeFunctions(const char *functypes, const char *pattern, bool verbose, bool
if (verbose)
appendPQExpBuffer(&buf,
",\n CASE\n"
- " WHEN p.provolatile = 'i' THEN '%s'\n"
- " WHEN p.provolatile = 's' THEN '%s'\n"
- " WHEN p.provolatile = 'v' THEN '%s'\n"
+ " WHEN p.provolatile OPERATOR(pg_catalog.=) 'i' THEN '%s'\n"
+ " WHEN p.provolatile OPERATOR(pg_catalog.=) 's' THEN '%s'\n"
+ " WHEN p.provolatile OPERATOR(pg_catalog.=) 'v' THEN '%s'\n"
"END as \"%s\""
",\n pg_catalog.pg_get_userbyid(p.proowner) as \"%s\",\n"
" l.lanname as \"%s\",\n"
@@ -338,11 +338,11 @@ describeFunctions(const char *functypes, const char *pattern, bool verbose, bool
appendPQExpBuffer(&buf,
"\nFROM pg_catalog.pg_proc p"
- "\n LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n");
+ "\n LEFT JOIN pg_catalog.pg_namespace n ON n.oid OPERATOR(pg_catalog.=) p.pronamespace\n");
if (verbose)
appendPQExpBuffer(&buf,
- " LEFT JOIN pg_catalog.pg_language l ON l.oid = p.prolang\n");
+ " LEFT JOIN pg_catalog.pg_language l ON l.oid OPERATOR(pg_catalog.=) p.prolang\n");
have_where = false;
@@ -371,7 +371,7 @@ describeFunctions(const char *functypes, const char *pattern, bool verbose, bool
appendPQExpBuffer(&buf, "WHERE ");
have_where = true;
}
- appendPQExpBuffer(&buf, "p.prorettype <> 'pg_catalog.trigger'::pg_catalog.regtype\n");
+ appendPQExpBuffer(&buf, "p.prorettype OPERATOR(pg_catalog.<>) 'pg_catalog.trigger'::pg_catalog.regtype\n");
}
if (!showWindow && pset.sversion >= 80400)
{
@@ -402,7 +402,7 @@ describeFunctions(const char *functypes, const char *pattern, bool verbose, bool
if (needs_or)
appendPQExpBuffer(&buf, " OR ");
appendPQExpBuffer(&buf,
- "p.prorettype = 'pg_catalog.trigger'::pg_catalog.regtype\n");
+ "p.prorettype OPERATOR(pg_catalog.=) 'pg_catalog.trigger'::pg_catalog.regtype\n");
needs_or = true;
}
if (showWindow)
@@ -420,8 +420,8 @@ describeFunctions(const char *functypes, const char *pattern, bool verbose, bool
"pg_catalog.pg_function_is_visible(p.oid)");
if (!showSystem && !pattern)
- appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"
- " AND n.nspname <> 'information_schema'\n");
+ appendPQExpBuffer(&buf, " AND n.nspname OPERATOR(pg_catalog.<>) 'pg_catalog'\n"
+ " AND n.nspname OPERATOR(pg_catalog.<>) 'information_schema'\n");
appendPQExpBuffer(&buf, "ORDER BY 1, 2, 4;");
@@ -464,9 +464,9 @@ describeTypes(const char *pattern, bool verbose, bool showSystem)
if (verbose)
appendPQExpBuffer(&buf,
" t.typname AS \"%s\",\n"
- " CASE WHEN t.typrelid != 0\n"
+ " CASE WHEN t.typrelid OPERATOR(pg_catalog.!=) 0\n"
" THEN CAST('tuple' AS pg_catalog.text)\n"
- " WHEN t.typlen < 0\n"
+ " WHEN t.typlen OPERATOR(pg_catalog.<) 0\n"
" THEN CAST('var' AS pg_catalog.text)\n"
" ELSE CAST(t.typlen AS pg_catalog.text)\n"
" END AS \"%s\",\n",
@@ -478,7 +478,7 @@ describeTypes(const char *pattern, bool verbose, bool showSystem)
" ARRAY(\n"
" SELECT e.enumlabel\n"
" FROM pg_catalog.pg_enum e\n"
- " WHERE e.enumtypid = t.oid\n"
+ " WHERE e.enumtypid OPERATOR(pg_catalog.=) t.oid\n"
" ORDER BY e.oid\n"
" ),\n"
" E'\\n'\n"
@@ -490,28 +490,28 @@ describeTypes(const char *pattern, bool verbose, bool showSystem)
gettext_noop("Description"));
appendPQExpBuffer(&buf, "FROM pg_catalog.pg_type t\n"
- " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace\n");
+ " LEFT JOIN pg_catalog.pg_namespace n ON n.oid OPERATOR(pg_catalog.=) t.typnamespace\n");
/*
* do not include complex types (typrelid!=0) unless they are standalone
* composite types
*/
- appendPQExpBuffer(&buf, "WHERE (t.typrelid = 0 ");
- appendPQExpBuffer(&buf, "OR (SELECT c.relkind = 'c' FROM pg_catalog.pg_class c "
- "WHERE c.oid = t.typrelid))\n");
+ appendPQExpBuffer(&buf, "WHERE (t.typrelid OPERATOR(pg_catalog.=) 0 ");
+ appendPQExpBuffer(&buf, "OR (SELECT c.relkind OPERATOR(pg_catalog.=) 'c' FROM pg_catalog.pg_class c "
+ "WHERE c.oid OPERATOR(pg_catalog.=) t.typrelid))\n");
/*
* do not include array types (before 8.3 we have to use the assumption
* that their names start with underscore)
*/
if (pset.sversion >= 80300)
- appendPQExpBuffer(&buf, " AND NOT EXISTS(SELECT 1 FROM pg_catalog.pg_type el WHERE el.oid = t.typelem AND el.typarray = t.oid)\n");
+ appendPQExpBuffer(&buf, " AND NOT EXISTS(SELECT 1 FROM pg_catalog.pg_type el WHERE el.oid OPERATOR(pg_catalog.=) t.typelem AND el.typarray OPERATOR(pg_catalog.=) t.oid)\n");
else
- appendPQExpBuffer(&buf, " AND t.typname !~ '^_'\n");
+ appendPQExpBuffer(&buf, " AND t.typname OPERATOR(pg_catalog.!~) '^_'\n");
if (!showSystem && !pattern)
- appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"
- " AND n.nspname <> 'information_schema'\n");
+ appendPQExpBuffer(&buf, " AND n.nspname OPERATOR(pg_catalog.<>) 'pg_catalog'\n"
+ " AND n.nspname OPERATOR(pg_catalog.<>) 'information_schema'\n");
/* Match name pattern against either internal or external name */
processSQLNamePattern(pset.db, &buf, pattern, true, false,
@@ -551,13 +551,13 @@ describeOperators(const char *pattern, bool showSystem)
printfPQExpBuffer(&buf,
"SELECT n.nspname as \"%s\",\n"
" o.oprname AS \"%s\",\n"
- " CASE WHEN o.oprkind='l' THEN NULL ELSE pg_catalog.format_type(o.oprleft, NULL) END AS \"%s\",\n"
- " CASE WHEN o.oprkind='r' THEN NULL ELSE pg_catalog.format_type(o.oprright, NULL) END AS \"%s\",\n"
+ " CASE WHEN o.oprkind OPERATOR(pg_catalog.=) 'l' THEN NULL ELSE pg_catalog.format_type(o.oprleft, NULL) END AS \"%s\",\n"
+ " CASE WHEN o.oprkind OPERATOR(pg_catalog.=) 'r' THEN NULL ELSE pg_catalog.format_type(o.oprright, NULL) END AS \"%s\",\n"
" pg_catalog.format_type(o.oprresult, NULL) AS \"%s\",\n"
" coalesce(pg_catalog.obj_description(o.oid, 'pg_operator'),\n"
" pg_catalog.obj_description(o.oprcode, 'pg_proc')) AS \"%s\"\n"
"FROM pg_catalog.pg_operator o\n"
- " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = o.oprnamespace\n",
+ " LEFT JOIN pg_catalog.pg_namespace n ON n.oid OPERATOR(pg_catalog.=) o.oprnamespace\n",
gettext_noop("Schema"),
gettext_noop("Name"),
gettext_noop("Left arg type"),
@@ -566,8 +566,8 @@ describeOperators(const char *pattern, bool showSystem)
gettext_noop("Description"));
if (!showSystem && !pattern)
- appendPQExpBuffer(&buf, "WHERE n.nspname <> 'pg_catalog'\n"
- " AND n.nspname <> 'information_schema'\n");
+ appendPQExpBuffer(&buf, "WHERE n.nspname OPERATOR(pg_catalog.<>) 'pg_catalog'\n"
+ " AND n.nspname OPERATOR(pg_catalog.<>) 'information_schema'\n");
processSQLNamePattern(pset.db, &buf, pattern, !showSystem && !pattern, true,
"n.nspname", "o.oprname", NULL,
@@ -639,7 +639,7 @@ listAllDbs(bool verbose)
"\nFROM pg_catalog.pg_database d\n");
if (verbose && pset.sversion >= 80000)
appendPQExpBuffer(&buf,
- " JOIN pg_catalog.pg_tablespace t on d.dattablespace = t.oid\n");
+ " JOIN pg_catalog.pg_tablespace t on d.dattablespace OPERATOR(pg_catalog.=) t.oid\n");
appendPQExpBuffer(&buf, "ORDER BY 1;");
res = PSQLexec(buf.data, false);
termPQExpBuffer(&buf);
@@ -689,14 +689,14 @@ permissionsList(const char *pattern)
if (pset.sversion >= 80400)
appendPQExpBuffer(&buf,
",\n pg_catalog.array_to_string(ARRAY(\n"
- " SELECT attname || E':\\n ' || pg_catalog.array_to_string(attacl, E'\\n ')\n"
+ " SELECT attname OPERATOR(pg_catalog.||) E':\\n ' OPERATOR(pg_catalog.||) pg_catalog.array_to_string(attacl, E'\\n ')\n"
" FROM pg_catalog.pg_attribute a\n"
- " WHERE attrelid = c.oid AND NOT attisdropped AND attacl IS NOT NULL\n"
+ " WHERE attrelid OPERATOR(pg_catalog.=) c.oid AND NOT attisdropped AND attacl IS NOT NULL\n"
" ), E'\\n') AS \"%s\"",
gettext_noop("Column access privileges"));
appendPQExpBuffer(&buf, "\nFROM pg_catalog.pg_class c\n"
- " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n"
+ " LEFT JOIN pg_catalog.pg_namespace n ON n.oid OPERATOR(pg_catalog.=) c.relnamespace\n"
"WHERE c.relkind IN ('r', 'v', 'S')\n");
/*
@@ -707,7 +707,7 @@ permissionsList(const char *pattern)
*/
processSQLNamePattern(pset.db, &buf, pattern, true, false,
"n.nspname", "c.relname", NULL,
- "n.nspname !~ '^pg_' AND pg_catalog.pg_table_is_visible(c.oid)");
+ "n.nspname OPERATOR(pg_catalog.!~) '^pg_' AND pg_catalog.pg_table_is_visible(c.oid)");
appendPQExpBuffer(&buf, "ORDER BY 1, 2;");
@@ -769,7 +769,7 @@ listDefaultACLs(const char *pattern)
printACLColumn(&buf, "d.defaclacl");
appendPQExpBuffer(&buf, "\nFROM pg_catalog.pg_default_acl d\n"
- " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = d.defaclnamespace\n");
+ " LEFT JOIN pg_catalog.pg_namespace n ON n.oid OPERATOR(pg_catalog.=) d.defaclnamespace\n");
processSQLNamePattern(pset.db, &buf, pattern, false, false,
NULL,
@@ -833,13 +833,13 @@ objectDescription(const char *pattern, bool showSystem)
" CAST(p.proname AS pg_catalog.text) as name,"
" CAST('%s' AS pg_catalog.text) as object\n"
" FROM pg_catalog.pg_proc p\n"
- " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n"
+ " LEFT JOIN pg_catalog.pg_namespace n ON n.oid OPERATOR(pg_catalog.=) p.pronamespace\n"
" WHERE p.proisagg\n",
gettext_noop("aggregate"));
if (!showSystem && !pattern)
- appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"
- " AND n.nspname <> 'information_schema'\n");
+ appendPQExpBuffer(&buf, " AND n.nspname OPERATOR(pg_catalog.<>) 'pg_catalog'\n"
+ " AND n.nspname OPERATOR(pg_catalog.<>) 'information_schema'\n");
processSQLNamePattern(pset.db, &buf, pattern, true, false,
"n.nspname", "p.proname", NULL,
@@ -853,13 +853,13 @@ objectDescription(const char *pattern, bool showSystem)
" CAST(p.proname AS pg_catalog.text) as name,"
" CAST('%s' AS pg_catalog.text) as object\n"
" FROM pg_catalog.pg_proc p\n"
- " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n"
+ " LEFT JOIN pg_catalog.pg_namespace n ON n.oid OPERATOR(pg_catalog.=) p.pronamespace\n"
" WHERE NOT p.proisagg\n",
gettext_noop("function"));
if (!showSystem && !pattern)
- appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"
- " AND n.nspname <> 'information_schema'\n");
+ appendPQExpBuffer(&buf, " AND n.nspname OPERATOR(pg_catalog.<>) 'pg_catalog'\n"
+ " AND n.nspname OPERATOR(pg_catalog.<>) 'information_schema'\n");
processSQLNamePattern(pset.db, &buf, pattern, true, false,
"n.nspname", "p.proname", NULL,
@@ -873,12 +873,12 @@ objectDescription(const char *pattern, bool showSystem)
" CAST(o.oprname AS pg_catalog.text) as name,"
" CAST('%s' AS pg_catalog.text) as object\n"
" FROM pg_catalog.pg_operator o\n"
- " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = o.oprnamespace\n",
+ " LEFT JOIN pg_catalog.pg_namespace n ON n.oid OPERATOR(pg_catalog.=) o.oprnamespace\n",
gettext_noop("operator"));
if (!showSystem && !pattern)
- appendPQExpBuffer(&buf, "WHERE n.nspname <> 'pg_catalog'\n"
- " AND n.nspname <> 'information_schema'\n");
+ appendPQExpBuffer(&buf, "WHERE n.nspname OPERATOR(pg_catalog.<>) 'pg_catalog'\n"
+ " AND n.nspname OPERATOR(pg_catalog.<>) 'information_schema'\n");
processSQLNamePattern(pset.db, &buf, pattern, !showSystem && !pattern, false,
"n.nspname", "o.oprname", NULL,
@@ -892,12 +892,12 @@ objectDescription(const char *pattern, bool showSystem)
" pg_catalog.format_type(t.oid, NULL) as name,"
" CAST('%s' AS pg_catalog.text) as object\n"
" FROM pg_catalog.pg_type t\n"
- " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace\n",
+ " LEFT JOIN pg_catalog.pg_namespace n ON n.oid OPERATOR(pg_catalog.=) t.typnamespace\n",
gettext_noop("data type"));
if (!showSystem && !pattern)
- appendPQExpBuffer(&buf, "WHERE n.nspname <> 'pg_catalog'\n"
- " AND n.nspname <> 'information_schema'\n");
+ appendPQExpBuffer(&buf, "WHERE n.nspname OPERATOR(pg_catalog.<>) 'pg_catalog'\n"
+ " AND n.nspname OPERATOR(pg_catalog.<>) 'information_schema'\n");
processSQLNamePattern(pset.db, &buf, pattern, !showSystem && !pattern, false,
"n.nspname", "pg_catalog.format_type(t.oid, NULL)",
@@ -914,7 +914,7 @@ objectDescription(const char *pattern, bool showSystem)
" CASE c.relkind WHEN 'r' THEN '%s' WHEN 'v' THEN '%s' WHEN 'i' THEN '%s' WHEN 'S' THEN '%s' END"
" AS pg_catalog.text) as object\n"
" FROM pg_catalog.pg_class c\n"
- " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n"
+ " LEFT JOIN pg_catalog.pg_namespace n ON n.oid OPERATOR(pg_catalog.=) c.relnamespace\n"
" WHERE c.relkind IN ('r', 'v', 'i', 'S')\n",
gettext_noop("table"),
gettext_noop("view"),
@@ -922,8 +922,8 @@ objectDescription(const char *pattern, bool showSystem)
gettext_noop("sequence"));
if (!showSystem && !pattern)
- appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"
- " AND n.nspname <> 'information_schema'\n");
+ appendPQExpBuffer(&buf, " AND n.nspname OPERATOR(pg_catalog.<>) 'pg_catalog'\n"
+ " AND n.nspname OPERATOR(pg_catalog.<>) 'information_schema'\n");
processSQLNamePattern(pset.db, &buf, pattern, true, false,
"n.nspname", "c.relname", NULL,
@@ -937,14 +937,14 @@ objectDescription(const char *pattern, bool showSystem)
" CAST(r.rulename AS pg_catalog.text) as name,"
" CAST('%s' AS pg_catalog.text) as object\n"
" FROM pg_catalog.pg_rewrite r\n"
- " JOIN pg_catalog.pg_class c ON c.oid = r.ev_class\n"
- " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n"
- " WHERE r.rulename != '_RETURN'\n",
+ " JOIN pg_catalog.pg_class c ON c.oid OPERATOR(pg_catalog.=) r.ev_class\n"
+ " LEFT JOIN pg_catalog.pg_namespace n ON n.oid OPERATOR(pg_catalog.=) c.relnamespace\n"
+ " WHERE r.rulename OPERATOR(pg_catalog.!=) '_RETURN'\n",
gettext_noop("rule"));
if (!showSystem && !pattern)
- appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"
- " AND n.nspname <> 'information_schema'\n");
+ appendPQExpBuffer(&buf, " AND n.nspname OPERATOR(pg_catalog.<>) 'pg_catalog'\n"
+ " AND n.nspname OPERATOR(pg_catalog.<>) 'information_schema'\n");
/* XXX not sure what to do about visibility rule here? */
processSQLNamePattern(pset.db, &buf, pattern, true, false,
@@ -959,13 +959,13 @@ objectDescription(const char *pattern, bool showSystem)
" CAST(t.tgname AS pg_catalog.text) as name,"
" CAST('%s' AS pg_catalog.text) as object\n"
" FROM pg_catalog.pg_trigger t\n"
- " JOIN pg_catalog.pg_class c ON c.oid = t.tgrelid\n"
- " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n",
+ " JOIN pg_catalog.pg_class c ON c.oid OPERATOR(pg_catalog.=) t.tgrelid\n"
+ " LEFT JOIN pg_catalog.pg_namespace n ON n.oid OPERATOR(pg_catalog.=) c.relnamespace\n",
gettext_noop("trigger"));
if (!showSystem && !pattern)
- appendPQExpBuffer(&buf, "WHERE n.nspname <> 'pg_catalog'\n"
- " AND n.nspname <> 'information_schema'\n");
+ appendPQExpBuffer(&buf, "WHERE n.nspname OPERATOR(pg_catalog.<>) 'pg_catalog'\n"
+ " AND n.nspname OPERATOR(pg_catalog.<>) 'information_schema'\n");
/* XXX not sure what to do about visibility rule here? */
processSQLNamePattern(pset.db, &buf, pattern, !showSystem && !pattern, false,
@@ -974,7 +974,7 @@ objectDescription(const char *pattern, bool showSystem)
appendPQExpBuffer(&buf,
") AS tt\n"
- " JOIN pg_catalog.pg_description d ON (tt.oid = d.objoid AND tt.tableoid = d.classoid AND d.objsubid = 0)\n");
+ " JOIN pg_catalog.pg_description d ON (tt.oid OPERATOR(pg_catalog.=) d.objoid AND tt.tableoid OPERATOR(pg_catalog.=) d.classoid AND d.objsubid OPERATOR(pg_catalog.=) 0)\n");
appendPQExpBuffer(&buf, "ORDER BY 1, 2, 3;");
@@ -1017,11 +1017,11 @@ describeTableDetails(const char *pattern, bool verbose, bool showSystem)
" n.nspname,\n"
" c.relname\n"
"FROM pg_catalog.pg_class c\n"
- " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n");
+ " LEFT JOIN pg_catalog.pg_namespace n ON n.oid OPERATOR(pg_catalog.=) c.relnamespace\n");
if (!showSystem && !pattern)
- appendPQExpBuffer(&buf, "WHERE n.nspname <> 'pg_catalog'\n"
- " AND n.nspname <> 'information_schema'\n");
+ appendPQExpBuffer(&buf, "WHERE n.nspname OPERATOR(pg_catalog.<>) 'pg_catalog'\n"
+ " AND n.nspname OPERATOR(pg_catalog.<>) 'information_schema'\n");
processSQLNamePattern(pset.db, &buf, pattern, !showSystem && !pattern, false,
"n.nspname", "c.relname", NULL,
@@ -1128,13 +1128,13 @@ describeOneTableDetails(const char *schemaname,
"SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
"c.relhastriggers, c.relhasoids, "
"%s, c.reltablespace, "
- "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END\n"
+ "CASE WHEN c.reloftype OPERATOR(pg_catalog.=) 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END\n"
"FROM pg_catalog.pg_class c\n "
- "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n"
- "WHERE c.oid = '%s'\n",
+ "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid OPERATOR(pg_catalog.=) tc.oid)\n"
+ "WHERE c.oid OPERATOR(pg_catalog.=) '%s'\n",
(verbose ?
- "pg_catalog.array_to_string(c.reloptions || "
- "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
+ "pg_catalog.array_to_string(c.reloptions OPERATOR(pg_catalog.||) "
+ "array(select 'toast.' OPERATOR(pg_catalog.||) x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
: "''"),
oid);
}
@@ -1145,11 +1145,11 @@ describeOneTableDetails(const char *schemaname,
"c.relhastriggers, c.relhasoids, "
"%s, c.reltablespace\n"
"FROM pg_catalog.pg_class c\n "
- "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n"
- "WHERE c.oid = '%s'\n",
+ "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid OPERATOR(pg_catalog.=) tc.oid)\n"
+ "WHERE c.oid OPERATOR(pg_catalog.=) '%s'\n",
(verbose ?
- "pg_catalog.array_to_string(c.reloptions || "
- "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
+ "pg_catalog.array_to_string(c.reloptions OPERATOR(pg_catalog.||) "
+ "array(select 'toast.' OPERATOR(pg_catalog.||) x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
: "''"),
oid);
}
@@ -1157,9 +1157,9 @@ describeOneTableDetails(const char *schemaname,
{
printfPQExpBuffer(&buf,
"SELECT relchecks, relkind, relhasindex, relhasrules, "
- "reltriggers <> 0, relhasoids, "
+ "reltriggers OPERATOR(pg_catalog.<>) 0, relhasoids, "
"%s, reltablespace\n"
- "FROM pg_catalog.pg_class WHERE oid = '%s'",
+ "FROM pg_catalog.pg_class WHERE oid OPERATOR(pg_catalog.=) '%s'",
(verbose ?
"pg_catalog.array_to_string(reloptions, E', ')" : "''"),
oid);
@@ -1168,18 +1168,18 @@ describeOneTableDetails(const char *schemaname,
{
printfPQExpBuffer(&buf,
"SELECT relchecks, relkind, relhasindex, relhasrules, "
- "reltriggers <> 0, relhasoids, "
+ "reltriggers OPERATOR(pg_catalog.<>) 0, relhasoids, "
"'', reltablespace\n"
- "FROM pg_catalog.pg_class WHERE oid = '%s'",
+ "FROM pg_catalog.pg_class WHERE oid OPERATOR(pg_catalog.=) '%s'",
oid);
}
else
{
printfPQExpBuffer(&buf,
"SELECT relchecks, relkind, relhasindex, relhasrules, "
- "reltriggers <> 0, relhasoids, "
+ "reltriggers OPERATOR(pg_catalog.<>) 0, relhasoids, "
"'', ''\n"
- "FROM pg_catalog.pg_class WHERE oid = '%s'",
+ "FROM pg_catalog.pg_class WHERE oid OPERATOR(pg_catalog.=) '%s'",
oid);
}
@@ -1240,14 +1240,14 @@ describeOneTableDetails(const char *schemaname,
appendPQExpBuffer(&buf, "\n pg_catalog.format_type(a.atttypid, a.atttypmod),"
"\n (SELECT substring(pg_catalog.pg_get_expr(d.adbin, d.adrelid) for 128)"
"\n FROM pg_catalog.pg_attrdef d"
- "\n WHERE d.adrelid = a.attrelid AND d.adnum = a.attnum AND a.atthasdef),"
+ "\n WHERE d.adrelid OPERATOR(pg_catalog.=) a.attrelid AND d.adnum OPERATOR(pg_catalog.=) a.attnum AND a.atthasdef),"
"\n a.attnotnull, a.attnum");
if (tableinfo.relkind == 'i')
appendPQExpBuffer(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef");
if (verbose)
appendPQExpBuffer(&buf, ",\n a.attstorage, pg_catalog.col_description(a.attrelid, a.attnum)");
appendPQExpBuffer(&buf, "\nFROM pg_catalog.pg_attribute a");
- appendPQExpBuffer(&buf, "\nWHERE a.attrelid = '%s' AND a.attnum > 0 AND NOT a.attisdropped", oid);
+ appendPQExpBuffer(&buf, "\nWHERE a.attrelid OPERATOR(pg_catalog.=) '%s' AND a.attnum OPERATOR(pg_catalog.>) 0 AND NOT a.attisdropped", oid);
appendPQExpBuffer(&buf, "\nORDER BY a.attnum");
res = PSQLexec(buf.data, false);
@@ -1415,14 +1415,14 @@ describeOneTableDetails(const char *schemaname,
appendPQExpBuffer(&buf,
" (NOT i.indimmediate) AND "
"EXISTS (SELECT 1 FROM pg_catalog.pg_constraint "
- "WHERE conrelid = i.indrelid AND "
- "conindid = i.indexrelid AND "
+ "WHERE conrelid OPERATOR(pg_catalog.=) i.indrelid AND "
+ "conindid OPERATOR(pg_catalog.=) i.indexrelid AND "
"contype IN ('p','u','x') AND "
"condeferrable) AS condeferrable,\n"
" (NOT i.indimmediate) AND "
"EXISTS (SELECT 1 FROM pg_catalog.pg_constraint "
- "WHERE conrelid = i.indrelid AND "
- "conindid = i.indexrelid AND "
+ "WHERE conrelid OPERATOR(pg_catalog.=) i.indrelid AND "
+ "conindid OPERATOR(pg_catalog.=) i.indexrelid AND "
"contype IN ('p','u','x') AND "
"condeferred) AS condeferred,\n");
else
@@ -1431,8 +1431,8 @@ describeOneTableDetails(const char *schemaname,
appendPQExpBuffer(&buf, " a.amname, c2.relname, "
"pg_catalog.pg_get_expr(i.indpred, i.indrelid, true)\n"
"FROM pg_catalog.pg_index i, pg_catalog.pg_class c, pg_catalog.pg_class c2, pg_catalog.pg_am a\n"
- "WHERE i.indexrelid = c.oid AND c.oid = '%s' AND c.relam = a.oid\n"
- "AND i.indrelid = c2.oid",
+ "WHERE i.indexrelid OPERATOR(pg_catalog.=) c.oid AND c.oid OPERATOR(pg_catalog.=) '%s' AND c.relam OPERATOR(pg_catalog.=) a.oid\n"
+ "AND i.indrelid OPERATOR(pg_catalog.=) c2.oid",
oid);
result = PSQLexec(buf.data, false);
@@ -1503,7 +1503,7 @@ describeOneTableDetails(const char *schemaname,
printfPQExpBuffer(&buf,
"SELECT r.rulename, trim(trailing ';' from pg_catalog.pg_get_ruledef(r.oid, true))\n"
"FROM pg_catalog.pg_rewrite r\n"
- "WHERE r.ev_class = '%s' AND r.rulename != '_RETURN' ORDER BY 1",
+ "WHERE r.ev_class OPERATOR(pg_catalog.=) '%s' AND r.rulename OPERATOR(pg_catalog.!=) '_RETURN' ORDER BY 1",
oid);
result = PSQLexec(buf.data, false);
if (!result)
@@ -1557,9 +1557,9 @@ describeOneTableDetails(const char *schemaname,
"\nFROM pg_catalog.pg_class c, pg_catalog.pg_class c2, pg_catalog.pg_index i\n");
if (pset.sversion >= 90000)
appendPQExpBuffer(&buf,
- " LEFT JOIN pg_catalog.pg_constraint con ON (conrelid = i.indrelid AND conindid = i.indexrelid AND contype IN ('p','u','x'))\n");
+ " LEFT JOIN pg_catalog.pg_constraint con ON (conrelid OPERATOR(pg_catalog.=) i.indrelid AND conindid OPERATOR(pg_catalog.=) i.indexrelid AND contype IN ('p','u','x'))\n");
appendPQExpBuffer(&buf,
- "WHERE c.oid = '%s' AND c.oid = i.indrelid AND i.indexrelid = c2.oid\n"
+ "WHERE c.oid OPERATOR(pg_catalog.=) '%s' AND c.oid OPERATOR(pg_catalog.=) i.indrelid AND i.indexrelid OPERATOR(pg_catalog.=) c2.oid\n"
"ORDER BY i.indisprimary DESC, i.indisunique DESC, c2.relname",
oid);
result = PSQLexec(buf.data, false);
@@ -1635,7 +1635,7 @@ describeOneTableDetails(const char *schemaname,
"SELECT r.conname, "
"pg_catalog.pg_get_constraintdef(r.oid, true)\n"
"FROM pg_catalog.pg_constraint r\n"
- "WHERE r.conrelid = '%s' AND r.contype = 'c'\nORDER BY 1",
+ "WHERE r.conrelid OPERATOR(pg_catalog.=) '%s' AND r.contype OPERATOR(pg_catalog.=) 'c'\nORDER BY 1",
oid);
result = PSQLexec(buf.data, false);
if (!result)
@@ -1666,7 +1666,7 @@ describeOneTableDetails(const char *schemaname,
"SELECT conname,\n"
" pg_catalog.pg_get_constraintdef(r.oid, true) as condef\n"
"FROM pg_catalog.pg_constraint r\n"
- "WHERE r.conrelid = '%s' AND r.contype = 'f' ORDER BY 1",
+ "WHERE r.conrelid OPERATOR(pg_catalog.=) '%s' AND r.contype OPERATOR(pg_catalog.=) 'f' ORDER BY 1",
oid);
result = PSQLexec(buf.data, false);
if (!result)
@@ -1697,7 +1697,7 @@ describeOneTableDetails(const char *schemaname,
"SELECT conname, conrelid::pg_catalog.regclass,\n"
" pg_catalog.pg_get_constraintdef(c.oid, true) as condef\n"
"FROM pg_catalog.pg_constraint c\n"
- "WHERE c.confrelid = '%s' AND c.contype = 'f' ORDER BY 1",
+ "WHERE c.confrelid OPERATOR(pg_catalog.=) '%s' AND c.contype OPERATOR(pg_catalog.=) 'f' ORDER BY 1",
oid);
result = PSQLexec(buf.data, false);
if (!result)
@@ -1730,7 +1730,7 @@ describeOneTableDetails(const char *schemaname,
"SELECT r.rulename, trim(trailing ';' from pg_catalog.pg_get_ruledef(r.oid, true)), "
"ev_enabled\n"
"FROM pg_catalog.pg_rewrite r\n"
- "WHERE r.ev_class = '%s' ORDER BY 1",
+ "WHERE r.ev_class OPERATOR(pg_catalog.=) '%s' ORDER BY 1",
oid);
}
else
@@ -1739,7 +1739,7 @@ describeOneTableDetails(const char *schemaname,
"SELECT r.rulename, trim(trailing ';' from pg_catalog.pg_get_ruledef(r.oid, true)), "
"'O'::char AS ev_enabled\n"
"FROM pg_catalog.pg_rewrite r\n"
- "WHERE r.ev_class = '%s' ORDER BY 1",
+ "WHERE r.ev_class OPERATOR(pg_catalog.=) '%s' ORDER BY 1",
oid);
}
result = PSQLexec(buf.data, false);
@@ -1824,20 +1824,20 @@ describeOneTableDetails(const char *schemaname,
"pg_catalog.pg_get_triggerdef(t.oid%s), "
"t.tgenabled\n"
"FROM pg_catalog.pg_trigger t\n"
- "WHERE t.tgrelid = '%s' AND ",
+ "WHERE t.tgrelid OPERATOR(pg_catalog.=) '%s' AND ",
(pset.sversion >= 90000 ? ", true" : ""),
oid);
if (pset.sversion >= 90000)
appendPQExpBuffer(&buf, "NOT t.tgisinternal");
else if (pset.sversion >= 80300)
- appendPQExpBuffer(&buf, "t.tgconstraint = 0");
+ appendPQExpBuffer(&buf, "t.tgconstraint OPERATOR(pg_catalog.=) 0");
else
appendPQExpBuffer(&buf,
"(NOT tgisconstraint "
" OR NOT EXISTS"
" (SELECT 1 FROM pg_catalog.pg_depend d "
- " JOIN pg_catalog.pg_constraint c ON (d.refclassid = c.tableoid AND d.refobjid = c.oid) "
- " WHERE d.classid = t.tableoid AND d.objid = t.oid AND d.deptype = 'i' AND c.contype = 'f'))");
+ " JOIN pg_catalog.pg_constraint c ON (d.refclassid OPERATOR(pg_catalog.=) c.tableoid AND d.refobjid OPERATOR(pg_catalog.=) c.oid) "
+ " WHERE d.classid OPERATOR(pg_catalog.=) t.tableoid AND d.objid OPERATOR(pg_catalog.=) t.oid AND d.deptype OPERATOR(pg_catalog.=) 'i' AND c.contype OPERATOR(pg_catalog.=) 'f'))");
appendPQExpBuffer(&buf, "\nORDER BY 1");
result = PSQLexec(buf.data, false);
@@ -1932,7 +1932,7 @@ describeOneTableDetails(const char *schemaname,
}
/* print inherited tables */
- printfPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i WHERE c.oid=i.inhparent AND i.inhrelid = '%s' ORDER BY inhseqno", oid);
+ printfPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i WHERE c.oid OPERATOR(pg_catalog.=) i.inhparent AND i.inhrelid OPERATOR(pg_catalog.=) '%s' ORDER BY inhseqno", oid);
result = PSQLexec(buf.data, false);
if (!result)
@@ -1957,9 +1957,9 @@ describeOneTableDetails(const char *schemaname,
/* print child tables */
if (pset.sversion >= 80300)
- printfPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i WHERE c.oid=i.inhrelid AND i.inhparent = '%s' ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", oid);
+ printfPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i WHERE c.oid OPERATOR(pg_catalog.=) i.inhrelid AND i.inhparent OPERATOR(pg_catalog.=) '%s' ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", oid);
else
- printfPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i WHERE c.oid=i.inhrelid AND i.inhparent = '%s' ORDER BY c.relname;", oid);
+ printfPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i WHERE c.oid OPERATOR(pg_catalog.=) i.inhrelid AND i.inhparent OPERATOR(pg_catalog.=) '%s' ORDER BY c.relname;", oid);
result = PSQLexec(buf.data, false);
if (!result)
@@ -2094,7 +2094,7 @@ add_tablespace_footer(printTableContent *const cont, char relkind,
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf,
"SELECT spcname FROM pg_catalog.pg_tablespace\n"
- "WHERE oid = '%u'", tablespace);
+ "WHERE oid OPERATOR(pg_catalog.=) '%u'", tablespace);
result = PSQLexec(buf.data, false);
if (!result)
return;
@@ -2157,8 +2157,8 @@ describeRoles(const char *pattern, bool verbose)
" r.rolconnlimit,\n"
" ARRAY(SELECT b.rolname\n"
" FROM pg_catalog.pg_auth_members m\n"
- " JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid)\n"
- " WHERE m.member = r.oid) as memberof");
+ " JOIN pg_catalog.pg_roles b ON (m.roleid OPERATOR(pg_catalog.=) b.oid)\n"
+ " WHERE m.member OPERATOR(pg_catalog.=) r.oid) as memberof");
if (verbose && pset.sversion >= 80200)
{
@@ -2179,7 +2179,7 @@ describeRoles(const char *pattern, bool verbose)
" true AS rolinherit, false AS rolcreaterole,\n"
" u.usecreatedb AS rolcreatedb, true AS rolcanlogin,\n"
" -1 AS rolconnlimit,\n"
- " ARRAY(SELECT g.groname FROM pg_catalog.pg_group g WHERE u.usesysid = ANY(g.grolist)) as memberof"
+ " ARRAY(SELECT g.groname FROM pg_catalog.pg_group g WHERE u.usesysid OPERATOR(pg_catalog.=) ANY(g.grolist)) as memberof"
"\nFROM pg_catalog.pg_user u\n");
processSQLNamePattern(pset.db, &buf, pattern, false, false,
@@ -2289,8 +2289,8 @@ listDbRoleSettings(const char *pattern, const char *pattern2)
printfPQExpBuffer(&buf, "SELECT rolname AS role, datname AS database,\n"
"pg_catalog.array_to_string(setconfig, E'\\n') AS settings\n"
"FROM pg_db_role_setting AS s\n"
- "LEFT JOIN pg_database ON pg_database.oid = setdatabase\n"
- "LEFT JOIN pg_roles ON pg_roles.oid = setrole\n");
+ "LEFT JOIN pg_database ON pg_database.oid OPERATOR(pg_catalog.=) setdatabase\n"
+ "LEFT JOIN pg_roles ON pg_roles.oid OPERATOR(pg_catalog.=) setrole\n");
havewhere = processSQLNamePattern(pset.db, &buf, pattern, false, false,
NULL, "pg_roles.rolname", NULL, NULL);
processSQLNamePattern(pset.db, &buf, pattern2, havewhere, false,
@@ -2396,11 +2396,11 @@ listTables(const char *tabtypes, const char *pattern, bool verbose, bool showSys
appendPQExpBuffer(&buf,
"\nFROM pg_catalog.pg_class c"
- "\n LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace");
+ "\n LEFT JOIN pg_catalog.pg_namespace n ON n.oid OPERATOR(pg_catalog.=) c.relnamespace");
if (showIndexes)
appendPQExpBuffer(&buf,
- "\n LEFT JOIN pg_catalog.pg_index i ON i.indexrelid = c.oid"
- "\n LEFT JOIN pg_catalog.pg_class c2 ON i.indrelid = c2.oid");
+ "\n LEFT JOIN pg_catalog.pg_index i ON i.indexrelid OPERATOR(pg_catalog.=) c.oid"
+ "\n LEFT JOIN pg_catalog.pg_class c2 ON i.indrelid OPERATOR(pg_catalog.=) c2.oid");
appendPQExpBuffer(&buf, "\nWHERE c.relkind IN (");
if (showTables)
@@ -2418,8 +2418,8 @@ listTables(const char *tabtypes, const char *pattern, bool verbose, bool showSys
appendPQExpBuffer(&buf, ")\n");
if (!showSystem && !pattern)
- appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"
- " AND n.nspname <> 'information_schema'\n");
+ appendPQExpBuffer(&buf, " AND n.nspname OPERATOR(pg_catalog.<>) 'pg_catalog'\n"
+ " AND n.nspname OPERATOR(pg_catalog.<>) 'information_schema'\n");
/*
* TOAST objects are suppressed unconditionally. Since we don't provide
@@ -2427,7 +2427,7 @@ listTables(const char *tabtypes, const char *pattern, bool verbose, bool showSys
* in any case; it seems a bit confusing to allow their indexes to be
* shown. Use plain \d if you really need to look at a TOAST table/index.
*/
- appendPQExpBuffer(&buf, " AND n.nspname !~ '^pg_toast'\n");
+ appendPQExpBuffer(&buf, " AND n.nspname OPERATOR(pg_catalog.!~) '^pg_toast'\n");
processSQLNamePattern(pset.db, &buf, pattern, true, false,
"n.nspname", "c.relname", NULL,
@@ -2480,17 +2480,17 @@ listDomains(const char *pattern, bool showSystem)
"SELECT n.nspname as \"%s\",\n"
" t.typname as \"%s\",\n"
" pg_catalog.format_type(t.typbasetype, t.typtypmod) as \"%s\",\n"
- " CASE WHEN t.typnotnull AND t.typdefault IS NOT NULL THEN 'not null default '||t.typdefault\n"
+ " CASE WHEN t.typnotnull AND t.typdefault IS NOT NULL THEN 'not null default ' OPERATOR(pg_catalog.||) t.typdefault\n"
" WHEN t.typnotnull AND t.typdefault IS NULL THEN 'not null'\n"
- " WHEN NOT t.typnotnull AND t.typdefault IS NOT NULL THEN 'default '||t.typdefault\n"
+ " WHEN NOT t.typnotnull AND t.typdefault IS NOT NULL THEN 'default ' OPERATOR(pg_catalog.||) t.typdefault\n"
" ELSE ''\n"
" END as \"%s\",\n"
" pg_catalog.array_to_string(ARRAY(\n"
- " SELECT pg_catalog.pg_get_constraintdef(r.oid, true) FROM pg_catalog.pg_constraint r WHERE t.oid = r.contypid\n"
+ " SELECT pg_catalog.pg_get_constraintdef(r.oid, true) FROM pg_catalog.pg_constraint r WHERE t.oid OPERATOR(pg_catalog.=) r.contypid\n"
" ), ' ') as \"%s\"\n"
"FROM pg_catalog.pg_type t\n"
- " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace\n"
- "WHERE t.typtype = 'd'\n",
+ " LEFT JOIN pg_catalog.pg_namespace n ON n.oid OPERATOR(pg_catalog.=) t.typnamespace\n"
+ "WHERE t.typtype OPERATOR(pg_catalog.=) 'd'\n",
gettext_noop("Schema"),
gettext_noop("Name"),
gettext_noop("Type"),
@@ -2498,8 +2498,8 @@ listDomains(const char *pattern, bool showSystem)
gettext_noop("Check"));
if (!showSystem && !pattern)
- appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"
- " AND n.nspname <> 'information_schema'\n");
+ appendPQExpBuffer(&buf, " AND n.nspname OPERATOR(pg_catalog.<>) 'pg_catalog'\n"
+ " AND n.nspname OPERATOR(pg_catalog.<>) 'information_schema'\n");
processSQLNamePattern(pset.db, &buf, pattern, true, false,
"n.nspname", "t.typname", NULL,
@@ -2545,7 +2545,7 @@ listConversions(const char *pattern, bool showSystem)
" CASE WHEN c.condefault THEN '%s'\n"
" ELSE '%s' END AS \"%s\"\n"
"FROM pg_catalog.pg_conversion c, pg_catalog.pg_namespace n\n"
- "WHERE n.oid = c.connamespace\n",
+ "WHERE n.oid OPERATOR(pg_catalog.=) c.connamespace\n",
gettext_noop("Schema"),
gettext_noop("Name"),
gettext_noop("Source"),
@@ -2554,8 +2554,8 @@ listConversions(const char *pattern, bool showSystem)
gettext_noop("Default?"));
if (!showSystem && !pattern)
- appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"
- " AND n.nspname <> 'information_schema'\n");
+ appendPQExpBuffer(&buf, " AND n.nspname OPERATOR(pg_catalog.<>) 'pg_catalog'\n"
+ " AND n.nspname OPERATOR(pg_catalog.<>) 'information_schema'\n");
processSQLNamePattern(pset.db, &buf, pattern, true, false,
"n.nspname", "c.conname", NULL,
@@ -2603,23 +2603,23 @@ listCasts(const char *pattern)
printfPQExpBuffer(&buf,
"SELECT pg_catalog.format_type(castsource, NULL) AS \"%s\",\n"
" pg_catalog.format_type(casttarget, NULL) AS \"%s\",\n"
- " CASE WHEN castfunc = 0 THEN '(binary coercible)'\n"
+ " CASE WHEN castfunc OPERATOR(pg_catalog.=) 0 THEN '(binary coercible)'\n"
" ELSE p.proname\n"
" END as \"%s\",\n"
- " CASE WHEN c.castcontext = 'e' THEN '%s'\n"
- " WHEN c.castcontext = 'a' THEN '%s'\n"
+ " CASE WHEN c.castcontext OPERATOR(pg_catalog.=) 'e' THEN '%s'\n"
+ " WHEN c.castcontext OPERATOR(pg_catalog.=) 'a' THEN '%s'\n"
" ELSE '%s'\n"
" END as \"%s\"\n"
"FROM pg_catalog.pg_cast c LEFT JOIN pg_catalog.pg_proc p\n"
- " ON c.castfunc = p.oid\n"
+ " ON c.castfunc OPERATOR(pg_catalog.=) p.oid\n"
" LEFT JOIN pg_catalog.pg_type ts\n"
- " ON c.castsource = ts.oid\n"
+ " ON c.castsource OPERATOR(pg_catalog.=) ts.oid\n"
" LEFT JOIN pg_catalog.pg_namespace ns\n"
- " ON ns.oid = ts.typnamespace\n"
+ " ON ns.oid OPERATOR(pg_catalog.=) ts.typnamespace\n"
" LEFT JOIN pg_catalog.pg_type tt\n"
- " ON c.casttarget = tt.oid\n"
+ " ON c.casttarget OPERATOR(pg_catalog.=) tt.oid\n"
" LEFT JOIN pg_catalog.pg_namespace nt\n"
- " ON nt.oid = tt.typnamespace\n"
+ " ON nt.oid OPERATOR(pg_catalog.=) tt.typnamespace\n"
"WHERE (true",
gettext_noop("Source type"),
gettext_noop("Target type"),
@@ -2691,8 +2691,8 @@ listSchemas(const char *pattern, bool verbose)
appendPQExpBuffer(&buf,
"\nFROM pg_catalog.pg_namespace n\n"
- "WHERE (n.nspname !~ '^pg_temp_' OR\n"
- " n.nspname = (pg_catalog.current_schemas(true))[1])\n"); /* temp schema is first */
+ "WHERE (n.nspname OPERATOR(pg_catalog.!~) '^pg_temp_' OR\n"
+ " n.nspname OPERATOR(pg_catalog.=) (pg_catalog.current_schemas(true))[1])\n"); /* temp schema is first */
processSQLNamePattern(pset.db, &buf, pattern, true, false,
NULL, "n.nspname", NULL,
@@ -2745,7 +2745,7 @@ listTSParsers(const char *pattern, bool verbose)
" p.prsname as \"%s\",\n"
" pg_catalog.obj_description(p.oid, 'pg_ts_parser') as \"%s\"\n"
"FROM pg_catalog.pg_ts_parser p \n"
- "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.prsnamespace\n",
+ "LEFT JOIN pg_catalog.pg_namespace n ON n.oid OPERATOR(pg_catalog.=) p.prsnamespace\n",
gettext_noop("Schema"),
gettext_noop("Name"),
gettext_noop("Description")
@@ -2789,7 +2789,7 @@ listTSParsersVerbose(const char *pattern)
" n.nspname, \n"
" p.prsname \n"
"FROM pg_catalog.pg_ts_parser p\n"
- "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.prsnamespace\n"
+ "LEFT JOIN pg_catalog.pg_namespace n ON n.oid OPERATOR(pg_catalog.=) p.prsnamespace\n"
);
processSQLNamePattern(pset.db, &buf, pattern, false, false,
@@ -2856,31 +2856,31 @@ describeOneTSParser(const char *oid, const char *nspname, const char *prsname)
" p.prsstart::pg_catalog.regproc AS \"%s\", \n"
" pg_catalog.obj_description(p.prsstart, 'pg_proc') as \"%s\" \n"
" FROM pg_catalog.pg_ts_parser p \n"
- " WHERE p.oid = '%s' \n"
+ " WHERE p.oid OPERATOR(pg_catalog.=) '%s' \n"
"UNION ALL \n"
"SELECT '%s', \n"
" p.prstoken::pg_catalog.regproc, \n"
" pg_catalog.obj_description(p.prstoken, 'pg_proc') \n"
" FROM pg_catalog.pg_ts_parser p \n"
- " WHERE p.oid = '%s' \n"
+ " WHERE p.oid OPERATOR(pg_catalog.=) '%s' \n"
"UNION ALL \n"
"SELECT '%s', \n"
" p.prsend::pg_catalog.regproc, \n"
" pg_catalog.obj_description(p.prsend, 'pg_proc') \n"
" FROM pg_catalog.pg_ts_parser p \n"
- " WHERE p.oid = '%s' \n"
+ " WHERE p.oid OPERATOR(pg_catalog.=) '%s' \n"
"UNION ALL \n"
"SELECT '%s', \n"
" p.prsheadline::pg_catalog.regproc, \n"
" pg_catalog.obj_description(p.prsheadline, 'pg_proc') \n"
" FROM pg_catalog.pg_ts_parser p \n"
- " WHERE p.oid = '%s' \n"
+ " WHERE p.oid OPERATOR(pg_catalog.=) '%s' \n"
"UNION ALL \n"
"SELECT '%s', \n"
" p.prslextype::pg_catalog.regproc, \n"
" pg_catalog.obj_description(p.prslextype, 'pg_proc') \n"
" FROM pg_catalog.pg_ts_parser p \n"
- " WHERE p.oid = '%s' \n",
+ " WHERE p.oid OPERATOR(pg_catalog.=) '%s' \n",
gettext_noop("Start parse"),
gettext_noop("Method"),
gettext_noop("Function"),
@@ -2979,10 +2979,10 @@ listTSDictionaries(const char *pattern, bool verbose)
if (verbose)
{
appendPQExpBuffer(&buf,
- " ( SELECT COALESCE(nt.nspname, '(null)')::pg_catalog.text || '.' || t.tmplname FROM \n"
+ " ( SELECT COALESCE(nt.nspname, '(null)')::pg_catalog.text OPERATOR(pg_catalog.||) '.' OPERATOR(pg_catalog.||) t.tmplname FROM \n"
" pg_catalog.pg_ts_template t \n"
- " LEFT JOIN pg_catalog.pg_namespace nt ON nt.oid = t.tmplnamespace \n"
- " WHERE d.dicttemplate = t.oid ) AS \"%s\", \n"
+ " LEFT JOIN pg_catalog.pg_namespace nt ON nt.oid OPERATOR(pg_catalog.=) t.tmplnamespace \n"
+ " WHERE d.dicttemplate OPERATOR(pg_catalog.=) t.oid ) AS \"%s\", \n"
" d.dictinitoption as \"%s\", \n",
gettext_noop("Template"),
gettext_noop("Init options"));
@@ -2993,7 +2993,7 @@ listTSDictionaries(const char *pattern, bool verbose)
gettext_noop("Description"));
appendPQExpBuffer(&buf, "FROM pg_catalog.pg_ts_dict d\n"
- "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = d.dictnamespace\n");
+ "LEFT JOIN pg_catalog.pg_namespace n ON n.oid OPERATOR(pg_catalog.=) d.dictnamespace\n");
processSQLNamePattern(pset.db, &buf, pattern, false, false,
"n.nspname", "d.dictname", NULL,
@@ -3061,7 +3061,7 @@ listTSTemplates(const char *pattern, bool verbose)
gettext_noop("Description"));
appendPQExpBuffer(&buf, "FROM pg_catalog.pg_ts_template t\n"
- "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.tmplnamespace\n");
+ "LEFT JOIN pg_catalog.pg_namespace n ON n.oid OPERATOR(pg_catalog.=) t.tmplnamespace\n");
processSQLNamePattern(pset.db, &buf, pattern, false, false,
"n.nspname", "t.tmplname", NULL,
@@ -3114,7 +3114,7 @@ listTSConfigs(const char *pattern, bool verbose)
" c.cfgname as \"%s\",\n"
" pg_catalog.obj_description(c.oid, 'pg_ts_config') as \"%s\"\n"
"FROM pg_catalog.pg_ts_config c\n"
- "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.cfgnamespace \n",
+ "LEFT JOIN pg_catalog.pg_namespace n ON n.oid OPERATOR(pg_catalog.=) c.cfgnamespace \n",
gettext_noop("Schema"),
gettext_noop("Name"),
gettext_noop("Description")
@@ -3156,10 +3156,10 @@ listTSConfigsVerbose(const char *pattern)
" p.prsname, \n"
" np.nspname as pnspname \n"
"FROM pg_catalog.pg_ts_config c \n"
- " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.cfgnamespace, \n"
+ " LEFT JOIN pg_catalog.pg_namespace n ON n.oid OPERATOR(pg_catalog.=) c.cfgnamespace, \n"
" pg_catalog.pg_ts_parser p \n"
- " LEFT JOIN pg_catalog.pg_namespace np ON np.oid = p.prsnamespace \n"
- "WHERE p.oid = c.cfgparser\n"
+ " LEFT JOIN pg_catalog.pg_namespace np ON np.oid OPERATOR(pg_catalog.=) p.prsnamespace \n"
+ "WHERE p.oid OPERATOR(pg_catalog.=) c.cfgparser\n"
);
processSQLNamePattern(pset.db, &buf, pattern, true, false,
@@ -3230,16 +3230,16 @@ describeOneTSConfig(const char *oid, const char *nspname, const char *cfgname,
"SELECT \n"
" ( SELECT t.alias FROM \n"
" pg_catalog.ts_token_type(c.cfgparser) AS t \n"
- " WHERE t.tokid = m.maptokentype ) AS \"%s\", \n"
+ " WHERE t.tokid OPERATOR(pg_catalog.=) m.maptokentype ) AS \"%s\", \n"
" pg_catalog.btrim( \n"
" ARRAY( SELECT mm.mapdict::pg_catalog.regdictionary \n"
" FROM pg_catalog.pg_ts_config_map AS mm \n"
- " WHERE mm.mapcfg = m.mapcfg AND mm.maptokentype = m.maptokentype \n"
+ " WHERE mm.mapcfg OPERATOR(pg_catalog.=) m.mapcfg AND mm.maptokentype OPERATOR(pg_catalog.=) m.maptokentype \n"
" ORDER BY mapcfg, maptokentype, mapseqno \n"
" ) :: pg_catalog.text , \n"
" '{}') AS \"%s\" \n"
"FROM pg_catalog.pg_ts_config AS c, pg_catalog.pg_ts_config_map AS m \n"
- "WHERE c.oid = '%s' AND m.mapcfg = c.oid \n"
+ "WHERE c.oid OPERATOR(pg_catalog.=) '%s' AND m.mapcfg OPERATOR(pg_catalog.=) c.oid \n"
"GROUP BY m.mapcfg, m.maptokentype, c.cfgparser \n"
"ORDER BY 1",
gettext_noop("Token"),
@@ -3385,7 +3385,7 @@ listForeignServers(const char *pattern, bool verbose)
appendPQExpBuffer(&buf,
"\nFROM pg_catalog.pg_foreign_server s\n"
- " JOIN pg_catalog.pg_foreign_data_wrapper f ON f.oid=s.srvfdw\n");
+ " JOIN pg_catalog.pg_foreign_data_wrapper f ON f.oid OPERATOR(pg_catalog.=) s.srvfdw\n");
processSQLNamePattern(pset.db, &buf, pattern, false, false,
NULL, "s.srvname", NULL, NULL);
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 51d1292..0298730 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -216,8 +216,8 @@ static const SchemaQuery Query_for_list_of_datatypes = {
"pg_catalog.pg_type t",
/* selcondition --- ignore table rowtypes and array types */
"(t.typrelid = 0 "
- " OR (SELECT c.relkind = 'c' FROM pg_catalog.pg_class c WHERE c.oid = t.typrelid)) "
- "AND t.typname !~ '^_'",
+ " OR (SELECT c.relkind OPERATOR(pg_catalog.=) 'c' FROM pg_catalog.pg_class c WHERE c.oid OPERATOR(pg_catalog.=) t.typrelid)) "
+ "AND t.typname OPERATOR(pg_catalog.!~) '^_'",
/* viscondition */
"pg_catalog.pg_type_is_visible(t.oid)",
/* namespace */
@@ -366,53 +366,53 @@ static const SchemaQuery Query_for_list_of_views = {
#define Query_for_list_of_attributes \
"SELECT pg_catalog.quote_ident(attname) "\
" FROM pg_catalog.pg_attribute a, pg_catalog.pg_class c "\
-" WHERE c.oid = a.attrelid "\
-" AND a.attnum > 0 "\
+" WHERE c.oid OPERATOR(pg_catalog.=) a.attrelid "\
+" AND a.attnum OPERATOR(pg_catalog.>) 0 "\
" AND NOT a.attisdropped "\
-" AND substring(pg_catalog.quote_ident(attname),1,%d)='%s' "\
-" AND (pg_catalog.quote_ident(relname)='%s' "\
-" OR '\"' || relname || '\"'='%s') "\
+" AND substring(pg_catalog.quote_ident(attname),1,%d) OPERATOR(pg_catalog.=) '%s' "\
+" AND (pg_catalog.quote_ident(relname) OPERATOR(pg_catalog.=) '%s' "\
+" OR '\"' OPERATOR(pg_catalog.||) relname OPERATOR(pg_catalog.||) '\"' OPERATOR(pg_catalog.=) '%s') "\
" AND pg_catalog.pg_table_is_visible(c.oid)"
#define Query_for_list_of_attributes_with_schema \
"SELECT pg_catalog.quote_ident(attname) "\
" FROM pg_catalog.pg_attribute a, pg_catalog.pg_class c, pg_catalog.pg_namespace n "\
-" WHERE c.oid = a.attrelid "\
-" AND n.oid = c.relnamespace "\
-" AND a.attnum > 0 "\
+" WHERE c.oid OPERATOR(pg_catalog.=) a.attrelid "\
+" AND n.oid OPERATOR(pg_catalog.=) c.relnamespace "\
+" AND a.attnum OPERATOR(pg_catalog.>) 0 "\
" AND NOT a.attisdropped "\
-" AND substring(pg_catalog.quote_ident(attname),1,%d)='%s' "\
-" AND (pg_catalog.quote_ident(relname)='%s' "\
-" OR '\"' || relname || '\"' ='%s') "\
-" AND (pg_catalog.quote_ident(nspname)='%s' "\
-" OR '\"' || nspname || '\"' ='%s') "
+" AND substring(pg_catalog.quote_ident(attname),1,%d) OPERATOR(pg_catalog.=) '%s' "\
+" AND (pg_catalog.quote_ident(relname) OPERATOR(pg_catalog.=) '%s' "\
+" OR '\"' OPERATOR(pg_catalog.||) relname OPERATOR(pg_catalog.||) '\"' OPERATOR(pg_catalog.=) '%s') "\
+" AND (pg_catalog.quote_ident(nspname) OPERATOR(pg_catalog.=) '%s' "\
+" OR '\"' OPERATOR(pg_catalog.||) nspname OPERATOR(pg_catalog.||) '\"' OPERATOR(pg_catalog.=) '%s') "
#define Query_for_list_of_template_databases \
"SELECT pg_catalog.quote_ident(datname) FROM pg_catalog.pg_database "\
-" WHERE substring(pg_catalog.quote_ident(datname),1,%d)='%s' AND datistemplate"
+" WHERE substring(pg_catalog.quote_ident(datname),1,%d) OPERATOR(pg_catalog.=) '%s' AND datistemplate"
#define Query_for_list_of_databases \
"SELECT pg_catalog.quote_ident(datname) FROM pg_catalog.pg_database "\
-" WHERE substring(pg_catalog.quote_ident(datname),1,%d)='%s'"
+" WHERE substring(pg_catalog.quote_ident(datname),1,%d) OPERATOR(pg_catalog.=) '%s'"
#define Query_for_list_of_tablespaces \
"SELECT pg_catalog.quote_ident(spcname) FROM pg_catalog.pg_tablespace "\
-" WHERE substring(pg_catalog.quote_ident(spcname),1,%d)='%s'"
+" WHERE substring(pg_catalog.quote_ident(spcname),1,%d) OPERATOR(pg_catalog.=) '%s'"
#define Query_for_list_of_encodings \
" SELECT DISTINCT pg_catalog.pg_encoding_to_char(conforencoding) "\
" FROM pg_catalog.pg_conversion "\
-" WHERE substring(pg_catalog.pg_encoding_to_char(conforencoding),1,%d)=UPPER('%s')"
+" WHERE substring(pg_catalog.pg_encoding_to_char(conforencoding),1,%d) OPERATOR(pg_catalog.=) UPPER('%s')"
#define Query_for_list_of_languages \
"SELECT pg_catalog.quote_ident(lanname) "\
" FROM pg_catalog.pg_language "\
-" WHERE lanname != 'internal' "\
-" AND substring(pg_catalog.quote_ident(lanname),1,%d)='%s'"
+" WHERE lanname OPERATOR(pg_catalog.!=) 'internal' "\
+" AND substring(pg_catalog.quote_ident(lanname),1,%d) OPERATOR(pg_catalog.=) '%s'"
#define Query_for_list_of_schemas \
"SELECT pg_catalog.quote_ident(nspname) FROM pg_catalog.pg_namespace "\
-" WHERE substring(pg_catalog.quote_ident(nspname),1,%d)='%s'"
+" WHERE substring(pg_catalog.quote_ident(nspname),1,%d) OPERATOR(pg_catalog.=) '%s'"
#define Query_for_list_of_set_vars \
"SELECT name FROM "\
@@ -424,88 +424,88 @@ static const SchemaQuery Query_for_list_of_views = {
" UNION ALL SELECT 'role' "\
" UNION ALL SELECT 'tablespace' "\
" UNION ALL SELECT 'all') ss "\
-" WHERE substring(name,1,%d)='%s'"
+" WHERE substring(name,1,%d) OPERATOR(pg_catalog.=) '%s'"
#define Query_for_list_of_show_vars \
"SELECT name FROM "\
" (SELECT pg_catalog.lower(name) AS name FROM pg_catalog.pg_settings "\
" UNION ALL SELECT 'session authorization' "\
" UNION ALL SELECT 'all') ss "\
-" WHERE substring(name,1,%d)='%s'"
+" WHERE substring(name,1,%d) OPERATOR(pg_catalog.=) '%s'"
#define Query_for_list_of_roles \
" SELECT pg_catalog.quote_ident(rolname) "\
" FROM pg_catalog.pg_roles "\
-" WHERE substring(pg_catalog.quote_ident(rolname),1,%d)='%s'"
+" WHERE substring(pg_catalog.quote_ident(rolname),1,%d) OPERATOR(pg_catalog.=) '%s'"
#define Query_for_list_of_grant_roles \
" SELECT pg_catalog.quote_ident(rolname) "\
" FROM pg_catalog.pg_roles "\
-" WHERE substring(pg_catalog.quote_ident(rolname),1,%d)='%s'"\
+" WHERE substring(pg_catalog.quote_ident(rolname),1,%d) OPERATOR(pg_catalog.=) '%s'"\
" UNION ALL SELECT 'PUBLIC'"
/* the silly-looking length condition is just to eat up the current word */
#define Query_for_table_owning_index \
"SELECT pg_catalog.quote_ident(c1.relname) "\
" FROM pg_catalog.pg_class c1, pg_catalog.pg_class c2, pg_catalog.pg_index i"\
-" WHERE c1.oid=i.indrelid and i.indexrelid=c2.oid"\
-" and (%d = pg_catalog.length('%s'))"\
-" and pg_catalog.quote_ident(c2.relname)='%s'"\
+" WHERE c1.oid OPERATOR(pg_catalog.=) i.indrelid and i.indexrelid OPERATOR(pg_catalog.=) c2.oid"\
+" and (%d OPERATOR(pg_catalog.=) pg_catalog.length('%s'))"\
+" and pg_catalog.quote_ident(c2.relname) OPERATOR(pg_catalog.=) '%s'"\
" and pg_catalog.pg_table_is_visible(c2.oid)"
/* the silly-looking length condition is just to eat up the current word */
#define Query_for_index_of_table \
"SELECT pg_catalog.quote_ident(c2.relname) "\
" FROM pg_catalog.pg_class c1, pg_catalog.pg_class c2, pg_catalog.pg_index i"\
-" WHERE c1.oid=i.indrelid and i.indexrelid=c2.oid"\
-" and (%d = pg_catalog.length('%s'))"\
-" and pg_catalog.quote_ident(c1.relname)='%s'"\
+" WHERE c1.oid OPERATOR(pg_catalog.=) i.indrelid and i.indexrelid OPERATOR(pg_catalog.=) c2.oid"\
+" and (%d OPERATOR(pg_catalog.=) pg_catalog.length('%s'))"\
+" and pg_catalog.quote_ident(c1.relname) OPERATOR(pg_catalog.=) '%s'"\
" and pg_catalog.pg_table_is_visible(c2.oid)"
/* the silly-looking length condition is just to eat up the current word */
#define Query_for_list_of_tables_for_trigger \
"SELECT pg_catalog.quote_ident(relname) "\
" FROM pg_catalog.pg_class"\
-" WHERE (%d = pg_catalog.length('%s'))"\
+" WHERE (%d OPERATOR(pg_catalog.=) pg_catalog.length('%s'))"\
" AND oid IN "\
" (SELECT tgrelid FROM pg_catalog.pg_trigger "\
-" WHERE pg_catalog.quote_ident(tgname)='%s')"
+" WHERE pg_catalog.quote_ident(tgname) OPERATOR(pg_catalog.=) '%s')"
#define Query_for_list_of_ts_configurations \
"SELECT pg_catalog.quote_ident(cfgname) FROM pg_catalog.pg_ts_config "\
-" WHERE substring(pg_catalog.quote_ident(cfgname),1,%d)='%s'"
+" WHERE substring(pg_catalog.quote_ident(cfgname),1,%d) OPERATOR(pg_catalog.=) '%s'"
#define Query_for_list_of_ts_dictionaries \
"SELECT pg_catalog.quote_ident(dictname) FROM pg_catalog.pg_ts_dict "\
-" WHERE substring(pg_catalog.quote_ident(dictname),1,%d)='%s'"
+" WHERE substring(pg_catalog.quote_ident(dictname),1,%d) OPERATOR(pg_catalog.=) '%s'"
#define Query_for_list_of_ts_parsers \
"SELECT pg_catalog.quote_ident(prsname) FROM pg_catalog.pg_ts_parser "\
-" WHERE substring(pg_catalog.quote_ident(prsname),1,%d)='%s'"
+" WHERE substring(pg_catalog.quote_ident(prsname),1,%d) OPERATOR(pg_catalog.=) '%s'"
#define Query_for_list_of_ts_templates \
"SELECT pg_catalog.quote_ident(tmplname) FROM pg_catalog.pg_ts_template "\
-" WHERE substring(pg_catalog.quote_ident(tmplname),1,%d)='%s'"
+" WHERE substring(pg_catalog.quote_ident(tmplname),1,%d) OPERATOR(pg_catalog.=) '%s'"
#define Query_for_list_of_fdws \
" SELECT pg_catalog.quote_ident(fdwname) "\
" FROM pg_catalog.pg_foreign_data_wrapper "\
-" WHERE substring(pg_catalog.quote_ident(fdwname),1,%d)='%s'"
+" WHERE substring(pg_catalog.quote_ident(fdwname),1,%d) OPERATOR(pg_catalog.=) '%s'"
#define Query_for_list_of_servers \
" SELECT pg_catalog.quote_ident(srvname) "\
" FROM pg_catalog.pg_foreign_server "\
-" WHERE substring(pg_catalog.quote_ident(srvname),1,%d)='%s'"
+" WHERE substring(pg_catalog.quote_ident(srvname),1,%d) OPERATOR(pg_catalog.=) '%s'"
#define Query_for_list_of_user_mappings \
" SELECT pg_catalog.quote_ident(usename) "\
" FROM pg_catalog.pg_user_mappings "\
-" WHERE substring(pg_catalog.quote_ident(usename),1,%d)='%s'"
+" WHERE substring(pg_catalog.quote_ident(usename),1,%d) OPERATOR(pg_catalog.=) '%s'"
#define Query_for_list_of_access_methods \
" SELECT pg_catalog.quote_ident(amname) "\
" FROM pg_catalog.pg_am "\
-" WHERE substring(pg_catalog.quote_ident(amname),1,%d)='%s'"
+" WHERE substring(pg_catalog.quote_ident(amname),1,%d) OPERATOR(pg_catalog.=) '%s'"
/*
* This is a list of all "things" in Pgsql, which can show up after CREATE or
@@ -531,7 +531,7 @@ static const pgsql_thing_t words_after_create[] = {
* to be used only by pg_dump.
*/
{"CONFIGURATION", Query_for_list_of_ts_configurations, NULL, true},
- {"CONVERSION", "SELECT pg_catalog.quote_ident(conname) FROM pg_catalog.pg_conversion WHERE substring(pg_catalog.quote_ident(conname),1,%d)='%s'"},
+ {"CONVERSION", "SELECT pg_catalog.quote_ident(conname) FROM pg_catalog.pg_conversion WHERE substring(pg_catalog.quote_ident(conname),1,%d) OPERATOR(pg_catalog.=) '%s'"},
{"DATABASE", Query_for_list_of_databases},
{"DICTIONARY", Query_for_list_of_ts_dictionaries, NULL, true},
{"DOMAIN", NULL, &Query_for_list_of_domains},
@@ -544,7 +544,7 @@ static const pgsql_thing_t words_after_create[] = {
* good idea. */
{"PARSER", Query_for_list_of_ts_parsers, NULL, true},
{"ROLE", Query_for_list_of_roles},
- {"RULE", "SELECT pg_catalog.quote_ident(rulename) FROM pg_catalog.pg_rules WHERE substring(pg_catalog.quote_ident(rulename),1,%d)='%s'"},
+ {"RULE", "SELECT pg_catalog.quote_ident(rulename) FROM pg_catalog.pg_rules WHERE substring(pg_catalog.quote_ident(rulename),1,%d) OPERATOR(pg_catalog.=) '%s'"},
{"SCHEMA", Query_for_list_of_schemas},
{"SEQUENCE", NULL, &Query_for_list_of_sequences},
{"SERVER", Query_for_list_of_servers},
@@ -553,7 +553,7 @@ static const pgsql_thing_t words_after_create[] = {
{"TEMP", NULL, NULL}, /* for CREATE TEMP TABLE ... */
{"TEMPLATE", Query_for_list_of_ts_templates, NULL, true},
{"TEXT SEARCH", NULL, NULL},
- {"TRIGGER", "SELECT pg_catalog.quote_ident(tgname) FROM pg_catalog.pg_trigger WHERE substring(pg_catalog.quote_ident(tgname),1,%d)='%s'"},
+ {"TRIGGER", "SELECT pg_catalog.quote_ident(tgname) FROM pg_catalog.pg_trigger WHERE substring(pg_catalog.quote_ident(tgname),1,%d) OPERATOR(pg_catalog.=) '%s'"},
{"TYPE", NULL, &Query_for_list_of_datatypes},
{"UNIQUE", NULL, NULL}, /* for CREATE UNIQUE INDEX ... */
{"USER", Query_for_list_of_roles},
@@ -1761,7 +1761,7 @@ psql_completion(char *text, int start, int end)
pg_strcasecmp(prev3_wd, "FUNCTION") == 0) &&
pg_strcasecmp(prev_wd, "(") == 0)
{
- static const char func_args_query[] = "select pg_catalog.oidvectortypes(proargtypes)||')' from pg_proc where proname='%s'";
+ static const char func_args_query[] = "select pg_catalog.oidvectortypes(proargtypes) OPERATOR(pg_catalog.||) ')' from pg_proc where proname OPERATOR(pg_catalog.=) '%s'";
char *tmp_buf = malloc(strlen(func_args_query) + strlen(prev2_wd));
sprintf(tmp_buf, func_args_query, prev2_wd);
@@ -2038,7 +2038,7 @@ psql_completion(char *text, int start, int end)
/* NOTIFY */
else if (pg_strcasecmp(prev_wd, "NOTIFY") == 0)
- COMPLETE_WITH_QUERY("SELECT pg_catalog.quote_ident(channel) FROM pg_catalog.pg_listening_channels() AS channel WHERE substring(pg_catalog.quote_ident(channel),1,%d)='%s'");
+ COMPLETE_WITH_QUERY("SELECT pg_catalog.quote_ident(channel) FROM pg_catalog.pg_listening_channels() AS channel WHERE substring(pg_catalog.quote_ident(channel),1,%d) OPERATOR(pg_catalog.=) '%s'");
/* OPTIONS */
else if (pg_strcasecmp(prev_wd, "OPTIONS") == 0)
@@ -2280,7 +2280,7 @@ psql_completion(char *text, int start, int end)
/* UNLISTEN */
else if (pg_strcasecmp(prev_wd, "UNLISTEN") == 0)
- COMPLETE_WITH_QUERY("SELECT pg_catalog.quote_ident(channel) FROM pg_catalog.pg_listening_channels() AS channel WHERE substring(pg_catalog.quote_ident(channel),1,%d)='%s' UNION SELECT '*'");
+ COMPLETE_WITH_QUERY("SELECT pg_catalog.quote_ident(channel) FROM pg_catalog.pg_listening_channels() AS channel WHERE substring(pg_catalog.quote_ident(channel),1,%d) OPERATOR(pg_catalog.=) '%s' UNION SELECT '*'");
/* UPDATE */
/* If prev. word is UPDATE suggest a list of tables */
@@ -2713,7 +2713,7 @@ _complete_from_query(int is_schema_query, const char *text, int state)
if (completion_squery->selcondition)
appendPQExpBuffer(&query_buffer, "%s AND ",
completion_squery->selcondition);
- appendPQExpBuffer(&query_buffer, "substring(%s,1,%d)='%s'",
+ appendPQExpBuffer(&query_buffer, "substring(%s,1,%d) OPERATOR(pg_catalog.=) '%s'",
completion_squery->result,
string_length, e_text);
appendPQExpBuffer(&query_buffer, " AND %s",
@@ -2730,8 +2730,8 @@ _complete_from_query(int is_schema_query, const char *text, int state)
strncmp(text, "pg_", 3) !=0)
{
appendPQExpBuffer(&query_buffer,
- " AND c.relnamespace <> (SELECT oid FROM"
- " pg_catalog.pg_namespace WHERE nspname = 'pg_catalog')");
+ " AND c.relnamespace OPERATOR(pg_catalog.<>) (SELECT oid FROM"
+ " pg_catalog.pg_namespace WHERE nspname OPERATOR(pg_catalog.=) 'pg_catalog')");
}
/*
@@ -2739,15 +2739,15 @@ _complete_from_query(int is_schema_query, const char *text, int state)
* one potential match among schema names.
*/
appendPQExpBuffer(&query_buffer, "\nUNION\n"
- "SELECT pg_catalog.quote_ident(n.nspname) || '.' "
+ "SELECT pg_catalog.quote_ident(n.nspname) OPERATOR(pg_catalog.||) '.' "
"FROM pg_catalog.pg_namespace n "
- "WHERE substring(pg_catalog.quote_ident(n.nspname) || '.',1,%d)='%s'",
+ "WHERE substring(pg_catalog.quote_ident(n.nspname) OPERATOR(pg_catalog.||) '.',1,%d) OPERATOR(pg_catalog.=) '%s'",
string_length, e_text);
appendPQExpBuffer(&query_buffer,
" AND (SELECT pg_catalog.count(*)"
" FROM pg_catalog.pg_namespace"
- " WHERE substring(pg_catalog.quote_ident(nspname) || '.',1,%d) ="
- " substring('%s',1,pg_catalog.length(pg_catalog.quote_ident(nspname))+1)) > 1",
+ " WHERE substring(pg_catalog.quote_ident(nspname) OPERATOR(pg_catalog.||) '.',1,%d) OPERATOR(pg_catalog.=)"
+ " substring('%s',1,pg_catalog.length(pg_catalog.quote_ident(nspname)) OPERATOR(pg_catalog.+) 1)) OPERATOR(pg_catalog.>) 1",
string_length, e_text);
/*
@@ -2755,16 +2755,16 @@ _complete_from_query(int is_schema_query, const char *text, int state)
* one schema matching the input-so-far.
*/
appendPQExpBuffer(&query_buffer, "\nUNION\n"
- "SELECT pg_catalog.quote_ident(n.nspname) || '.' || %s "
+ "SELECT pg_catalog.quote_ident(n.nspname) OPERATOR(pg_catalog.||) '.' OPERATOR(pg_catalog.||) %s "
"FROM %s, pg_catalog.pg_namespace n "
- "WHERE %s = n.oid AND ",
+ "WHERE %s OPERATOR(pg_catalog.=) n.oid AND ",
qualresult,
completion_squery->catname,
completion_squery->namespace);
if (completion_squery->selcondition)
appendPQExpBuffer(&query_buffer, "%s AND ",
completion_squery->selcondition);
- appendPQExpBuffer(&query_buffer, "substring(pg_catalog.quote_ident(n.nspname) || '.' || %s,1,%d)='%s'",
+ appendPQExpBuffer(&query_buffer, "substring(pg_catalog.quote_ident(n.nspname) OPERATOR(pg_catalog.||) '.' OPERATOR(pg_catalog.||) %s,1,%d) OPERATOR(pg_catalog.=) '%s'",
qualresult,
string_length, e_text);
@@ -2773,14 +2773,14 @@ _complete_from_query(int is_schema_query, const char *text, int state)
* speed up the query
*/
appendPQExpBuffer(&query_buffer,
- " AND substring(pg_catalog.quote_ident(n.nspname) || '.',1,%d) ="
- " substring('%s',1,pg_catalog.length(pg_catalog.quote_ident(n.nspname))+1)",
+ " AND substring(pg_catalog.quote_ident(n.nspname) OPERATOR(pg_catalog.||) '.',1,%d) OPERATOR(pg_catalog.=)"
+ " substring('%s',1,pg_catalog.length(pg_catalog.quote_ident(n.nspname)) OPERATOR(pg_catalog.+) 1)",
string_length, e_text);
appendPQExpBuffer(&query_buffer,
" AND (SELECT pg_catalog.count(*)"
" FROM pg_catalog.pg_namespace"
- " WHERE substring(pg_catalog.quote_ident(nspname) || '.',1,%d) ="
- " substring('%s',1,pg_catalog.length(pg_catalog.quote_ident(nspname))+1)) = 1",
+ " WHERE substring(pg_catalog.quote_ident(nspname) OPERATOR(pg_catalog.||) '.',1,%d) OPERATOR(pg_catalog.=)"
+ " substring('%s',1,pg_catalog.length(pg_catalog.quote_ident(nspname)) OPERATOR(pg_catalog.+) 1)) OPERATOR(pg_catalog.=) 1",
string_length, e_text);
/* If an addon query was provided, use it */
-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160
While psql is careful to schema-qualify all references to built-in
objects (pg_catalog.*), it completely neglects to do this for built-in
operators, which can lead to surprising misbehaviors when users have
created custom operators. Here is a patch to address that. It will
need a bit of testing.
Er...wouldn't this only be a problem if someone creates custom operators
*and* forces pg_catalog to the end of the search_path? Wouldn't an easier
solution be to prepend pg_catalog to the search_path when doing backslash
commands?
- --
Greg Sabino Mullane greg@turnstep.com
PGP Key: 0x14964AC8 201004010941
http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
-----BEGIN PGP SIGNATURE-----
iEYEAREDAAYFAku0oqQACgkQvJuQZxSWSsiJmACghUKR/i+uyJ2n+beuAid4w432
s0oAnArOf1npuMF/7QJ87ZVmSYMlJTRp
=/+yd
-----END PGP SIGNATURE-----
Peter Eisentraut <peter_e@gmx.net> writes:
While psql is careful to schema-qualify all references to built-in
objects (pg_catalog.*), it completely neglects to do this for built-in
operators,
That's intentional because of the utter lack of readability that
results if you try to use OPERATOR() everywhere ...
regards, tom lane
On Thu, Apr 1, 2010 at 9:59 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Peter Eisentraut <peter_e@gmx.net> writes:
While psql is careful to schema-qualify all references to built-in
objects (pg_catalog.*), it completely neglects to do this for built-in
operators,That's intentional because of the utter lack of readability that
results if you try to use OPERATOR() everywhere ...
I was mulling over in my head the possibility that the date on which
this patch was posted was deliberate...
...Robert