Commit 98ffcb66 authored by Bruce Momjian's avatar Bruce Momjian

Uppercase keywords in pg_dump.c

parent ce6e31de
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* by PostgreSQL * by PostgreSQL
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.519 2009/02/02 20:07:37 adunstan Exp $ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.520 2009/02/16 22:50:41 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1604,11 +1604,11 @@ dumpDatabase(Archive *AH) ...@@ -1604,11 +1604,11 @@ dumpDatabase(Archive *AH)
if (g_fout->remoteVersion >= 80400) if (g_fout->remoteVersion >= 80400)
{ {
appendPQExpBuffer(dbQry, "SELECT tableoid, oid, " appendPQExpBuffer(dbQry, "SELECT tableoid, oid, "
"(%s datdba) as dba, " "(%s datdba) AS dba, "
"pg_encoding_to_char(encoding) as encoding, " "pg_encoding_to_char(encoding) AS encoding, "
"datcollate, datctype, " "datcollate, datctype, "
"(SELECT spcname FROM pg_tablespace t WHERE t.oid = dattablespace) as tablespace, " "(SELECT spcname FROM pg_tablespace t WHERE t.oid = dattablespace) AS tablespace, "
"shobj_description(oid, 'pg_database') as description " "shobj_description(oid, 'pg_database') AS description "
"FROM pg_database " "FROM pg_database "
"WHERE datname = ", "WHERE datname = ",
...@@ -1618,11 +1618,11 @@ dumpDatabase(Archive *AH) ...@@ -1618,11 +1618,11 @@ dumpDatabase(Archive *AH)
else if (g_fout->remoteVersion >= 80200) else if (g_fout->remoteVersion >= 80200)
{ {
appendPQExpBuffer(dbQry, "SELECT tableoid, oid, " appendPQExpBuffer(dbQry, "SELECT tableoid, oid, "
"(%s datdba) as dba, " "(%s datdba) AS dba, "
"pg_encoding_to_char(encoding) as encoding, " "pg_encoding_to_char(encoding) AS encoding, "
"NULL as datcollate, NULL as datctype, " "NULL AS datcollate, NULL AS datctype, "
"(SELECT spcname FROM pg_tablespace t WHERE t.oid = dattablespace) as tablespace, " "(SELECT spcname FROM pg_tablespace t WHERE t.oid = dattablespace) AS tablespace, "
"shobj_description(oid, 'pg_database') as description " "shobj_description(oid, 'pg_database') AS description "
"FROM pg_database " "FROM pg_database "
"WHERE datname = ", "WHERE datname = ",
...@@ -1632,10 +1632,10 @@ dumpDatabase(Archive *AH) ...@@ -1632,10 +1632,10 @@ dumpDatabase(Archive *AH)
else if (g_fout->remoteVersion >= 80000) else if (g_fout->remoteVersion >= 80000)
{ {
appendPQExpBuffer(dbQry, "SELECT tableoid, oid, " appendPQExpBuffer(dbQry, "SELECT tableoid, oid, "
"(%s datdba) as dba, " "(%s datdba) AS dba, "
"pg_encoding_to_char(encoding) as encoding, " "pg_encoding_to_char(encoding) AS encoding, "
"NULL as datcollate, NULL as datctype, " "NULL AS datcollate, NULL AS datctype, "
"(SELECT spcname FROM pg_tablespace t WHERE t.oid = dattablespace) as tablespace " "(SELECT spcname FROM pg_tablespace t WHERE t.oid = dattablespace) AS tablespace "
"FROM pg_database " "FROM pg_database "
"WHERE datname = ", "WHERE datname = ",
username_subquery); username_subquery);
...@@ -1644,10 +1644,10 @@ dumpDatabase(Archive *AH) ...@@ -1644,10 +1644,10 @@ dumpDatabase(Archive *AH)
else if (g_fout->remoteVersion >= 70100) else if (g_fout->remoteVersion >= 70100)
{ {
appendPQExpBuffer(dbQry, "SELECT tableoid, oid, " appendPQExpBuffer(dbQry, "SELECT tableoid, oid, "
"(%s datdba) as dba, " "(%s datdba) AS dba, "
"pg_encoding_to_char(encoding) as encoding, " "pg_encoding_to_char(encoding) AS encoding, "
"NULL as datcollate, NULL as datctype, " "NULL AS datcollate, NULL AS datctype, "
"NULL as tablespace " "NULL AS tablespace "
"FROM pg_database " "FROM pg_database "
"WHERE datname = ", "WHERE datname = ",
username_subquery); username_subquery);
...@@ -1658,10 +1658,10 @@ dumpDatabase(Archive *AH) ...@@ -1658,10 +1658,10 @@ dumpDatabase(Archive *AH)
appendPQExpBuffer(dbQry, "SELECT " appendPQExpBuffer(dbQry, "SELECT "
"(SELECT oid FROM pg_class WHERE relname = 'pg_database') AS tableoid, " "(SELECT oid FROM pg_class WHERE relname = 'pg_database') AS tableoid, "
"oid, " "oid, "
"(%s datdba) as dba, " "(%s datdba) AS dba, "
"pg_encoding_to_char(encoding) as encoding, " "pg_encoding_to_char(encoding) AS encoding, "
"NULL as datcollate, NULL as datctype, " "NULL AS datcollate, NULL AS datctype, "
"NULL as tablespace " "NULL AS tablespace "
"FROM pg_database " "FROM pg_database "
"WHERE datname = ", "WHERE datname = ",
username_subquery); username_subquery);
...@@ -1979,11 +1979,21 @@ dumpBlobComments(Archive *AH, void *arg) ...@@ -1979,11 +1979,21 @@ dumpBlobComments(Archive *AH, void *arg)
/* Cursor to get all BLOB comments */ /* Cursor to get all BLOB comments */
if (AH->remoteVersion >= 70200) if (AH->remoteVersion >= 70200)
blobQry = "DECLARE blobcmt CURSOR FOR SELECT loid, obj_description(loid, 'pg_largeobject') FROM (SELECT DISTINCT loid FROM pg_largeobject) ss"; blobQry = "DECLARE blobcmt CURSOR FOR SELECT loid, "
"obj_description(loid, 'pg_largeobject') "
"FROM (SELECT DISTINCT loid FROM pg_largeobject) ss";
else if (AH->remoteVersion >= 70100) else if (AH->remoteVersion >= 70100)
blobQry = "DECLARE blobcmt CURSOR FOR SELECT loid, obj_description(loid) FROM (SELECT DISTINCT loid FROM pg_largeobject) ss"; blobQry = "DECLARE blobcmt CURSOR FOR SELECT loid, "
"obj_description(loid) "
"FROM (SELECT DISTINCT loid FROM pg_largeobject) ss";
else else
blobQry = "DECLARE blobcmt CURSOR FOR SELECT oid, (SELECT description FROM pg_description pd WHERE pd.objoid=pc.oid) FROM pg_class pc WHERE relkind = 'l'"; blobQry = "DECLARE blobcmt CURSOR FOR SELECT oid, "
" ( "
" SELECT description "
" FROM pg_description pd "
" WHERE pd.objoid=pc.oid "
" ) "
"FROM pg_class pc WHERE relkind = 'l'";
res = PQexec(g_conn, blobQry); res = PQexec(g_conn, blobQry);
check_sql_result(res, g_conn, blobQry, PGRES_COMMAND_OK); check_sql_result(res, g_conn, blobQry, PGRES_COMMAND_OK);
...@@ -2095,7 +2105,7 @@ getNamespaces(int *numNamespaces) ...@@ -2095,7 +2105,7 @@ getNamespaces(int *numNamespaces)
* read in can be linked to a containing namespace. * read in can be linked to a containing namespace.
*/ */
appendPQExpBuffer(query, "SELECT tableoid, oid, nspname, " appendPQExpBuffer(query, "SELECT tableoid, oid, nspname, "
"(%s nspowner) as rolname, " "(%s nspowner) AS rolname, "
"nspacl FROM pg_namespace", "nspacl FROM pg_namespace",
username_subquery); username_subquery);
...@@ -2233,11 +2243,11 @@ getTypes(int *numTypes) ...@@ -2233,11 +2243,11 @@ getTypes(int *numTypes)
{ {
appendPQExpBuffer(query, "SELECT tableoid, oid, typname, " appendPQExpBuffer(query, "SELECT tableoid, oid, typname, "
"typnamespace, " "typnamespace, "
"(%s typowner) as rolname, " "(%s typowner) AS rolname, "
"typinput::oid as typinput, " "typinput::oid AS typinput, "
"typoutput::oid as typoutput, typelem, typrelid, " "typoutput::oid AS typoutput, typelem, typrelid, "
"CASE WHEN typrelid = 0 THEN ' '::\"char\" " "CASE WHEN typrelid = 0 THEN ' '::\"char\" "
"ELSE (SELECT relkind FROM pg_class WHERE oid = typrelid) END as typrelkind, " "ELSE (SELECT relkind FROM pg_class WHERE oid = typrelid) END AS typrelkind, "
"typtype, typisdefined, " "typtype, typisdefined, "
"typname[0] = '_' AND typelem != 0 AND " "typname[0] = '_' AND typelem != 0 AND "
"(SELECT typarray FROM pg_type te WHERE oid = pg_type.typelem) = oid AS isarray " "(SELECT typarray FROM pg_type te WHERE oid = pg_type.typelem) = oid AS isarray "
...@@ -2248,11 +2258,11 @@ getTypes(int *numTypes) ...@@ -2248,11 +2258,11 @@ getTypes(int *numTypes)
{ {
appendPQExpBuffer(query, "SELECT tableoid, oid, typname, " appendPQExpBuffer(query, "SELECT tableoid, oid, typname, "
"typnamespace, " "typnamespace, "
"(%s typowner) as rolname, " "(%s typowner) AS rolname, "
"typinput::oid as typinput, " "typinput::oid AS typinput, "
"typoutput::oid as typoutput, typelem, typrelid, " "typoutput::oid AS typoutput, typelem, typrelid, "
"CASE WHEN typrelid = 0 THEN ' '::\"char\" " "CASE WHEN typrelid = 0 THEN ' '::\"char\" "
"ELSE (SELECT relkind FROM pg_class WHERE oid = typrelid) END as typrelkind, " "ELSE (SELECT relkind FROM pg_class WHERE oid = typrelid) END AS typrelkind, "
"typtype, typisdefined, " "typtype, typisdefined, "
"typname[0] = '_' AND typelem != 0 AS isarray " "typname[0] = '_' AND typelem != 0 AS isarray "
"FROM pg_type", "FROM pg_type",
...@@ -2261,12 +2271,12 @@ getTypes(int *numTypes) ...@@ -2261,12 +2271,12 @@ getTypes(int *numTypes)
else if (g_fout->remoteVersion >= 70100) else if (g_fout->remoteVersion >= 70100)
{ {
appendPQExpBuffer(query, "SELECT tableoid, oid, typname, " appendPQExpBuffer(query, "SELECT tableoid, oid, typname, "
"0::oid as typnamespace, " "0::oid AS typnamespace, "
"(%s typowner) as rolname, " "(%s typowner) AS rolname, "
"typinput::oid as typinput, " "typinput::oid AS typinput, "
"typoutput::oid as typoutput, typelem, typrelid, " "typoutput::oid AS typoutput, typelem, typrelid, "
"CASE WHEN typrelid = 0 THEN ' '::\"char\" " "CASE WHEN typrelid = 0 THEN ' '::\"char\" "
"ELSE (SELECT relkind FROM pg_class WHERE oid = typrelid) END as typrelkind, " "ELSE (SELECT relkind FROM pg_class WHERE oid = typrelid) END AS typrelkind, "
"typtype, typisdefined, " "typtype, typisdefined, "
"typname[0] = '_' AND typelem != 0 AS isarray " "typname[0] = '_' AND typelem != 0 AS isarray "
"FROM pg_type", "FROM pg_type",
...@@ -2277,12 +2287,12 @@ getTypes(int *numTypes) ...@@ -2277,12 +2287,12 @@ getTypes(int *numTypes)
appendPQExpBuffer(query, "SELECT " appendPQExpBuffer(query, "SELECT "
"(SELECT oid FROM pg_class WHERE relname = 'pg_type') AS tableoid, " "(SELECT oid FROM pg_class WHERE relname = 'pg_type') AS tableoid, "
"oid, typname, " "oid, typname, "
"0::oid as typnamespace, " "0::oid AS typnamespace, "
"(%s typowner) as rolname, " "(%s typowner) AS rolname, "
"typinput::oid as typinput, " "typinput::oid AS typinput, "
"typoutput::oid as typoutput, typelem, typrelid, " "typoutput::oid AS typoutput, typelem, typrelid, "
"CASE WHEN typrelid = 0 THEN ' '::\"char\" " "CASE WHEN typrelid = 0 THEN ' '::\"char\" "
"ELSE (SELECT relkind FROM pg_class WHERE oid = typrelid) END as typrelkind, " "ELSE (SELECT relkind FROM pg_class WHERE oid = typrelid) END AS typrelkind, "
"typtype, typisdefined, " "typtype, typisdefined, "
"typname[0] = '_' AND typelem != 0 AS isarray " "typname[0] = '_' AND typelem != 0 AS isarray "
"FROM pg_type", "FROM pg_type",
...@@ -2465,17 +2475,17 @@ getOperators(int *numOprs) ...@@ -2465,17 +2475,17 @@ getOperators(int *numOprs)
{ {
appendPQExpBuffer(query, "SELECT tableoid, oid, oprname, " appendPQExpBuffer(query, "SELECT tableoid, oid, oprname, "
"oprnamespace, " "oprnamespace, "
"(%s oprowner) as rolname, " "(%s oprowner) AS rolname, "
"oprcode::oid as oprcode " "oprcode::oid AS oprcode "
"FROM pg_operator", "FROM pg_operator",
username_subquery); username_subquery);
} }
else if (g_fout->remoteVersion >= 70100) else if (g_fout->remoteVersion >= 70100)
{ {
appendPQExpBuffer(query, "SELECT tableoid, oid, oprname, " appendPQExpBuffer(query, "SELECT tableoid, oid, oprname, "
"0::oid as oprnamespace, " "0::oid AS oprnamespace, "
"(%s oprowner) as rolname, " "(%s oprowner) AS rolname, "
"oprcode::oid as oprcode " "oprcode::oid AS oprcode "
"FROM pg_operator", "FROM pg_operator",
username_subquery); username_subquery);
} }
...@@ -2484,9 +2494,9 @@ getOperators(int *numOprs) ...@@ -2484,9 +2494,9 @@ getOperators(int *numOprs)
appendPQExpBuffer(query, "SELECT " appendPQExpBuffer(query, "SELECT "
"(SELECT oid FROM pg_class WHERE relname = 'pg_operator') AS tableoid, " "(SELECT oid FROM pg_class WHERE relname = 'pg_operator') AS tableoid, "
"oid, oprname, " "oid, oprname, "
"0::oid as oprnamespace, " "0::oid AS oprnamespace, "
"(%s oprowner) as rolname, " "(%s oprowner) AS rolname, "
"oprcode::oid as oprcode " "oprcode::oid AS oprcode "
"FROM pg_operator", "FROM pg_operator",
username_subquery); username_subquery);
} }
...@@ -2571,7 +2581,7 @@ getConversions(int *numConversions) ...@@ -2571,7 +2581,7 @@ getConversions(int *numConversions)
appendPQExpBuffer(query, "SELECT tableoid, oid, conname, " appendPQExpBuffer(query, "SELECT tableoid, oid, conname, "
"connamespace, " "connamespace, "
"(%s conowner) as rolname " "(%s conowner) AS rolname "
"FROM pg_conversion", "FROM pg_conversion",
username_subquery); username_subquery);
...@@ -2644,15 +2654,15 @@ getOpclasses(int *numOpclasses) ...@@ -2644,15 +2654,15 @@ getOpclasses(int *numOpclasses)
{ {
appendPQExpBuffer(query, "SELECT tableoid, oid, opcname, " appendPQExpBuffer(query, "SELECT tableoid, oid, opcname, "
"opcnamespace, " "opcnamespace, "
"(%s opcowner) as rolname " "(%s opcowner) AS rolname "
"FROM pg_opclass", "FROM pg_opclass",
username_subquery); username_subquery);
} }
else if (g_fout->remoteVersion >= 70100) else if (g_fout->remoteVersion >= 70100)
{ {
appendPQExpBuffer(query, "SELECT tableoid, oid, opcname, " appendPQExpBuffer(query, "SELECT tableoid, oid, opcname, "
"0::oid as opcnamespace, " "0::oid AS opcnamespace, "
"''::name as rolname " "''::name AS rolname "
"FROM pg_opclass"); "FROM pg_opclass");
} }
else else
...@@ -2660,8 +2670,8 @@ getOpclasses(int *numOpclasses) ...@@ -2660,8 +2670,8 @@ getOpclasses(int *numOpclasses)
appendPQExpBuffer(query, "SELECT " appendPQExpBuffer(query, "SELECT "
"(SELECT oid FROM pg_class WHERE relname = 'pg_opclass') AS tableoid, " "(SELECT oid FROM pg_class WHERE relname = 'pg_opclass') AS tableoid, "
"oid, opcname, " "oid, opcname, "
"0::oid as opcnamespace, " "0::oid AS opcnamespace, "
"''::name as rolname " "''::name AS rolname "
"FROM pg_opclass"); "FROM pg_opclass");
} }
...@@ -2748,7 +2758,7 @@ getOpfamilies(int *numOpfamilies) ...@@ -2748,7 +2758,7 @@ getOpfamilies(int *numOpfamilies)
appendPQExpBuffer(query, "SELECT tableoid, oid, opfname, " appendPQExpBuffer(query, "SELECT tableoid, oid, opfname, "
"opfnamespace, " "opfnamespace, "
"(%s opfowner) as rolname " "(%s opfowner) AS rolname "
"FROM pg_opfamily", "FROM pg_opfamily",
username_subquery); username_subquery);
...@@ -2826,39 +2836,39 @@ getAggregates(int *numAggs) ...@@ -2826,39 +2836,39 @@ getAggregates(int *numAggs)
if (g_fout->remoteVersion >= 80200) if (g_fout->remoteVersion >= 80200)
{ {
appendPQExpBuffer(query, "SELECT tableoid, oid, proname as aggname, " appendPQExpBuffer(query, "SELECT tableoid, oid, proname AS aggname, "
"pronamespace as aggnamespace, " "pronamespace AS aggnamespace, "
"pronargs, proargtypes, " "pronargs, proargtypes, "
"(%s proowner) as rolname, " "(%s proowner) AS rolname, "
"proacl as aggacl " "proacl AS aggacl "
"FROM pg_proc " "FROM pg_proc "
"WHERE proisagg " "WHERE proisagg "
"AND pronamespace != " "AND pronamespace != "
"(select oid from pg_namespace where nspname = 'pg_catalog')", "(SELECT oid FROM pg_namespace WHERE nspname = 'pg_catalog')",
username_subquery); username_subquery);
} }
else if (g_fout->remoteVersion >= 70300) else if (g_fout->remoteVersion >= 70300)
{ {
appendPQExpBuffer(query, "SELECT tableoid, oid, proname as aggname, " appendPQExpBuffer(query, "SELECT tableoid, oid, proname AS aggname, "
"pronamespace as aggnamespace, " "pronamespace AS aggnamespace, "
"CASE WHEN proargtypes[0] = 'pg_catalog.\"any\"'::pg_catalog.regtype THEN 0 ELSE 1 END as pronargs, " "CASE WHEN proargtypes[0] = 'pg_catalog.\"any\"'::pg_catalog.regtype THEN 0 ELSE 1 END AS pronargs, "
"proargtypes, " "proargtypes, "
"(%s proowner) as rolname, " "(%s proowner) AS rolname, "
"proacl as aggacl " "proacl AS aggacl "
"FROM pg_proc " "FROM pg_proc "
"WHERE proisagg " "WHERE proisagg "
"AND pronamespace != " "AND pronamespace != "
"(select oid from pg_namespace where nspname = 'pg_catalog')", "(SELECT oid FROM pg_namespace WHERE nspname = 'pg_catalog')",
username_subquery); username_subquery);
} }
else if (g_fout->remoteVersion >= 70100) else if (g_fout->remoteVersion >= 70100)
{ {
appendPQExpBuffer(query, "SELECT tableoid, oid, aggname, " appendPQExpBuffer(query, "SELECT tableoid, oid, aggname, "
"0::oid as aggnamespace, " "0::oid AS aggnamespace, "
"CASE WHEN aggbasetype = 0 THEN 0 ELSE 1 END as pronargs, " "CASE WHEN aggbasetype = 0 THEN 0 ELSE 1 END AS pronargs, "
"aggbasetype as proargtypes, " "aggbasetype AS proargtypes, "
"(%s aggowner) as rolname, " "(%s aggowner) AS rolname, "
"'{=X}' as aggacl " "'{=X}' AS aggacl "
"FROM pg_aggregate " "FROM pg_aggregate "
"where oid > '%u'::oid", "where oid > '%u'::oid",
username_subquery, username_subquery,
...@@ -2869,11 +2879,11 @@ getAggregates(int *numAggs) ...@@ -2869,11 +2879,11 @@ getAggregates(int *numAggs)
appendPQExpBuffer(query, "SELECT " appendPQExpBuffer(query, "SELECT "
"(SELECT oid FROM pg_class WHERE relname = 'pg_aggregate') AS tableoid, " "(SELECT oid FROM pg_class WHERE relname = 'pg_aggregate') AS tableoid, "
"oid, aggname, " "oid, aggname, "
"0::oid as aggnamespace, " "0::oid AS aggnamespace, "
"CASE WHEN aggbasetype = 0 THEN 0 ELSE 1 END as pronargs, " "CASE WHEN aggbasetype = 0 THEN 0 ELSE 1 END AS pronargs, "
"aggbasetype as proargtypes, " "aggbasetype AS proargtypes, "
"(%s aggowner) as rolname, " "(%s aggowner) AS rolname, "
"'{=X}' as aggacl " "'{=X}' AS aggacl "
"FROM pg_aggregate " "FROM pg_aggregate "
"where oid > '%u'::oid", "where oid > '%u'::oid",
username_subquery, username_subquery,
...@@ -2976,12 +2986,12 @@ getFuncs(int *numFuncs) ...@@ -2976,12 +2986,12 @@ getFuncs(int *numFuncs)
"SELECT tableoid, oid, proname, prolang, " "SELECT tableoid, oid, proname, prolang, "
"pronargs, proargtypes, prorettype, proacl, " "pronargs, proargtypes, prorettype, proacl, "
"pronamespace, " "pronamespace, "
"(%s proowner) as rolname " "(%s proowner) AS rolname "
"FROM pg_proc " "FROM pg_proc "
"WHERE NOT proisagg " "WHERE NOT proisagg "
"AND pronamespace != " "AND pronamespace != "
"(select oid from pg_namespace" "(SELECT oid FROM pg_namespace "
" where nspname = 'pg_catalog')", "WHERE nspname = 'pg_catalog')",
username_subquery); username_subquery);
} }
else if (g_fout->remoteVersion >= 70100) else if (g_fout->remoteVersion >= 70100)
...@@ -2989,11 +2999,11 @@ getFuncs(int *numFuncs) ...@@ -2989,11 +2999,11 @@ getFuncs(int *numFuncs)
appendPQExpBuffer(query, appendPQExpBuffer(query,
"SELECT tableoid, oid, proname, prolang, " "SELECT tableoid, oid, proname, prolang, "
"pronargs, proargtypes, prorettype, " "pronargs, proargtypes, prorettype, "
"'{=X}' as proacl, " "'{=X}' AS proacl, "
"0::oid as pronamespace, " "0::oid AS pronamespace, "
"(%s proowner) as rolname " "(%s proowner) AS rolname "
"FROM pg_proc " "FROM pg_proc "
"where pg_proc.oid > '%u'::oid", "WHERE pg_proc.oid > '%u'::oid",
username_subquery, username_subquery,
g_last_builtin_oid); g_last_builtin_oid);
} }
...@@ -3005,9 +3015,9 @@ getFuncs(int *numFuncs) ...@@ -3005,9 +3015,9 @@ getFuncs(int *numFuncs)
" WHERE relname = 'pg_proc') AS tableoid, " " WHERE relname = 'pg_proc') AS tableoid, "
"oid, proname, prolang, " "oid, proname, prolang, "
"pronargs, proargtypes, prorettype, " "pronargs, proargtypes, prorettype, "
"'{=X}' as proacl, " "'{=X}' AS proacl, "
"0::oid as pronamespace, " "0::oid AS pronamespace, "
"(%s proowner) as rolname " "(%s proowner) AS rolname "
"FROM pg_proc " "FROM pg_proc "
"where pg_proc.oid > '%u'::oid", "where pg_proc.oid > '%u'::oid",
username_subquery, username_subquery,
...@@ -3139,23 +3149,23 @@ getTables(int *numTables) ...@@ -3139,23 +3149,23 @@ getTables(int *numTables)
appendPQExpBuffer(query, appendPQExpBuffer(query,
"SELECT c.tableoid, c.oid, c.relname, " "SELECT c.tableoid, c.oid, c.relname, "
"c.relacl, c.relkind, c.relnamespace, " "c.relacl, c.relkind, c.relnamespace, "
"(%s c.relowner) as rolname, " "(%s c.relowner) AS rolname, "
"c.relchecks, c.relhastriggers, " "c.relchecks, c.relhastriggers, "
"c.relhasindex, c.relhasrules, c.relhasoids, " "c.relhasindex, c.relhasrules, c.relhasoids, "
"d.refobjid as owning_tab, " "d.refobjid AS owning_tab, "
"d.refobjsubid as owning_col, " "d.refobjsubid AS owning_col, "
"(SELECT spcname FROM pg_tablespace t WHERE t.oid = c.reltablespace) AS reltablespace, " "(SELECT spcname FROM pg_tablespace t WHERE t.oid = c.reltablespace) AS reltablespace, "
"array_to_string(c.reloptions, ', ') as reloptions, " "array_to_string(c.reloptions, ', ') AS reloptions, "
"array_to_string(array(select 'toast.' || x from unnest(tc.reloptions) x), ', ') as toast_reloptions " "array_to_string(array(SELECT 'toast.' || x FROM unnest(tc.reloptions) x), ', ') AS toast_reloptions "
"from pg_class c " "FROM pg_class c "
"left join pg_depend d on " "LEFT JOIN pg_depend d ON "
"(c.relkind = '%c' and " "(c.relkind = '%c' AND "
"d.classid = c.tableoid and d.objid = c.oid and " "d.classid = c.tableoid AND d.objid = c.oid AND "
"d.objsubid = 0 and " "d.objsubid = 0 AND "
"d.refclassid = c.tableoid and d.deptype = 'a') " "d.refclassid = c.tableoid AND d.deptype = 'a') "
"left join pg_class tc on (c.reltoastrelid = tc.oid) " "LEFT JOIN pg_class tc ON (c.reltoastrelid = tc.oid) "
"where c.relkind in ('%c', '%c', '%c', '%c') " "WHERE c.relkind in ('%c', '%c', '%c', '%c') "
"order by c.oid", "ORDER BY c.oid",
username_subquery, username_subquery,
RELKIND_SEQUENCE, RELKIND_SEQUENCE,
RELKIND_RELATION, RELKIND_SEQUENCE, RELKIND_RELATION, RELKIND_SEQUENCE,
...@@ -3170,22 +3180,22 @@ getTables(int *numTables) ...@@ -3170,22 +3180,22 @@ getTables(int *numTables)
appendPQExpBuffer(query, appendPQExpBuffer(query,
"SELECT c.tableoid, c.oid, relname, " "SELECT c.tableoid, c.oid, relname, "
"relacl, relkind, relnamespace, " "relacl, relkind, relnamespace, "
"(%s relowner) as rolname, " "(%s relowner) AS rolname, "
"relchecks, (reltriggers <> 0) as relhastriggers, " "relchecks, (reltriggers <> 0) AS relhastriggers, "
"relhasindex, relhasrules, relhasoids, " "relhasindex, relhasrules, relhasoids, "
"d.refobjid as owning_tab, " "d.refobjid AS owning_tab, "
"d.refobjsubid as owning_col, " "d.refobjsubid AS owning_col, "
"(SELECT spcname FROM pg_tablespace t WHERE t.oid = c.reltablespace) AS reltablespace, " "(SELECT spcname FROM pg_tablespace t WHERE t.oid = c.reltablespace) AS reltablespace, "
"array_to_string(c.reloptions, ', ') as reloptions, " "array_to_string(c.reloptions, ', ') AS reloptions, "
"NULL as toast_reloptions " "NULL AS toast_reloptions "
"from pg_class c " "FROM pg_class c "
"left join pg_depend d on " "LEFT JOIN pg_depend d ON "
"(c.relkind = '%c' and " "(c.relkind = '%c' AND "
"d.classid = c.tableoid and d.objid = c.oid and " "d.classid = c.tableoid AND d.objid = c.oid AND "
"d.objsubid = 0 and " "d.objsubid = 0 AND "
"d.refclassid = c.tableoid and d.deptype = 'a') " "d.refclassid = c.tableoid AND d.deptype = 'a') "
"where relkind in ('%c', '%c', '%c', '%c') " "WHERE relkind in ('%c', '%c', '%c', '%c') "
"order by c.oid", "ORDER BY c.oid",
username_subquery, username_subquery,
RELKIND_SEQUENCE, RELKIND_SEQUENCE,
RELKIND_RELATION, RELKIND_SEQUENCE, RELKIND_RELATION, RELKIND_SEQUENCE,
...@@ -3200,22 +3210,22 @@ getTables(int *numTables) ...@@ -3200,22 +3210,22 @@ getTables(int *numTables)
appendPQExpBuffer(query, appendPQExpBuffer(query,
"SELECT c.tableoid, c.oid, relname, " "SELECT c.tableoid, c.oid, relname, "
"relacl, relkind, relnamespace, " "relacl, relkind, relnamespace, "
"(%s relowner) as rolname, " "(%s relowner) AS rolname, "
"relchecks, (reltriggers <> 0) as relhastriggers, " "relchecks, (reltriggers <> 0) AS relhastriggers, "
"relhasindex, relhasrules, relhasoids, " "relhasindex, relhasrules, relhasoids, "
"d.refobjid as owning_tab, " "d.refobjid AS owning_tab, "
"d.refobjsubid as owning_col, " "d.refobjsubid AS owning_col, "
"(SELECT spcname FROM pg_tablespace t WHERE t.oid = c.reltablespace) AS reltablespace, " "(SELECT spcname FROM pg_tablespace t WHERE t.oid = c.reltablespace) AS reltablespace, "
"NULL as reloptions, " "NULL AS reloptions, "
"NULL as toast_reloptions " "NULL AS toast_reloptions "
"from pg_class c " "FROM pg_class c "
"left join pg_depend d on " "LEFT JOIN pg_depend d ON "
"(c.relkind = '%c' and " "(c.relkind = '%c' AND "
"d.classid = c.tableoid and d.objid = c.oid and " "d.classid = c.tableoid AND d.objid = c.oid AND "
"d.objsubid = 0 and " "d.objsubid = 0 AND "
"d.refclassid = c.tableoid and d.deptype = 'i') " "d.refclassid = c.tableoid AND d.deptype = 'i') "
"where relkind in ('%c', '%c', '%c', '%c') " "WHERE relkind in ('%c', '%c', '%c', '%c') "
"order by c.oid", "ORDER BY c.oid",
username_subquery, username_subquery,
RELKIND_SEQUENCE, RELKIND_SEQUENCE,
RELKIND_RELATION, RELKIND_SEQUENCE, RELKIND_RELATION, RELKIND_SEQUENCE,
...@@ -3230,22 +3240,22 @@ getTables(int *numTables) ...@@ -3230,22 +3240,22 @@ getTables(int *numTables)
appendPQExpBuffer(query, appendPQExpBuffer(query,
"SELECT c.tableoid, c.oid, relname, " "SELECT c.tableoid, c.oid, relname, "
"relacl, relkind, relnamespace, " "relacl, relkind, relnamespace, "
"(%s relowner) as rolname, " "(%s relowner) AS rolname, "
"relchecks, (reltriggers <> 0) as relhastriggers, " "relchecks, (reltriggers <> 0) AS relhastriggers, "
"relhasindex, relhasrules, relhasoids, " "relhasindex, relhasrules, relhasoids, "
"d.refobjid as owning_tab, " "d.refobjid AS owning_tab, "
"d.refobjsubid as owning_col, " "d.refobjsubid AS owning_col, "
"NULL as reltablespace, " "NULL AS reltablespace, "
"NULL as reloptions, " "NULL AS reloptions, "
"NULL as toast_reloptions " "NULL AS toast_reloptions "
"from pg_class c " "FROM pg_class c "
"left join pg_depend d on " "LEFT JOIN pg_depend d ON "
"(c.relkind = '%c' and " "(c.relkind = '%c' AND "
"d.classid = c.tableoid and d.objid = c.oid and " "d.classid = c.tableoid AND d.objid = c.oid AND "
"d.objsubid = 0 and " "d.objsubid = 0 AND "
"d.refclassid = c.tableoid and d.deptype = 'i') " "d.refclassid = c.tableoid AND d.deptype = 'i') "
"where relkind in ('%c', '%c', '%c', '%c') " "WHERE relkind IN ('%c', '%c', '%c', '%c') "
"order by c.oid", "ORDER BY c.oid",
username_subquery, username_subquery,
RELKIND_SEQUENCE, RELKIND_SEQUENCE,
RELKIND_RELATION, RELKIND_SEQUENCE, RELKIND_RELATION, RELKIND_SEQUENCE,
...@@ -3255,18 +3265,18 @@ getTables(int *numTables) ...@@ -3255,18 +3265,18 @@ getTables(int *numTables)
{ {
appendPQExpBuffer(query, appendPQExpBuffer(query,
"SELECT tableoid, oid, relname, relacl, relkind, " "SELECT tableoid, oid, relname, relacl, relkind, "
"0::oid as relnamespace, " "0::oid AS relnamespace, "
"(%s relowner) as rolname, " "(%s relowner) AS rolname, "
"relchecks, (reltriggers <> 0) as relhastriggers, " "relchecks, (reltriggers <> 0) AS relhastriggers, "
"relhasindex, relhasrules, relhasoids, " "relhasindex, relhasrules, relhasoids, "
"NULL::oid as owning_tab, " "NULL::oid AS owning_tab, "
"NULL::int4 as owning_col, " "NULL::int4 AS owning_col, "
"NULL as reltablespace, " "NULL AS reltablespace, "
"NULL as reloptions, " "NULL AS reloptions, "
"NULL as toast_reloptions " "NULL AS toast_reloptions "
"from pg_class " "FROM pg_class "
"where relkind in ('%c', '%c', '%c') " "WHERE relkind IN ('%c', '%c', '%c') "
"order by oid", "ORDER BY oid",
username_subquery, username_subquery,
RELKIND_RELATION, RELKIND_SEQUENCE, RELKIND_VIEW); RELKIND_RELATION, RELKIND_SEQUENCE, RELKIND_VIEW);
} }
...@@ -3275,19 +3285,19 @@ getTables(int *numTables) ...@@ -3275,19 +3285,19 @@ getTables(int *numTables)
/* all tables have oids in 7.1 */ /* all tables have oids in 7.1 */
appendPQExpBuffer(query, appendPQExpBuffer(query,
"SELECT tableoid, oid, relname, relacl, relkind, " "SELECT tableoid, oid, relname, relacl, relkind, "
"0::oid as relnamespace, " "0::oid AS relnamespace, "
"(%s relowner) as rolname, " "(%s relowner) AS rolname, "
"relchecks, (reltriggers <> 0) as relhastriggers, " "relchecks, (reltriggers <> 0) AS relhastriggers, "
"relhasindex, relhasrules, " "relhasindex, relhasrules, "
"'t'::bool as relhasoids, " "'t'::bool AS relhasoids, "
"NULL::oid as owning_tab, " "NULL::oid AS owning_tab, "
"NULL::int4 as owning_col, " "NULL::int4 AS owning_col, "
"NULL as reltablespace, " "NULL AS reltablespace, "
"NULL as reloptions, " "NULL AS reloptions, "
"NULL as toast_reloptions " "NULL AS toast_reloptions "
"from pg_class " "FROM pg_class "
"where relkind in ('%c', '%c', '%c') " "WHERE relkind IN ('%c', '%c', '%c') "
"order by oid", "ORDER BY oid",
username_subquery, username_subquery,
RELKIND_RELATION, RELKIND_SEQUENCE, RELKIND_VIEW); RELKIND_RELATION, RELKIND_SEQUENCE, RELKIND_VIEW);
} }
...@@ -3306,19 +3316,19 @@ getTables(int *numTables) ...@@ -3306,19 +3316,19 @@ getTables(int *numTables)
" r.ev_class = c.oid AND r.ev_type = '1') " " r.ev_class = c.oid AND r.ev_type = '1') "
"THEN '%c'::\"char\" " "THEN '%c'::\"char\" "
"ELSE relkind END AS relkind," "ELSE relkind END AS relkind,"
"0::oid as relnamespace, " "0::oid AS relnamespace, "
"(%s relowner) as rolname, " "(%s relowner) AS rolname, "
"relchecks, (reltriggers <> 0) as relhastriggers, " "relchecks, (reltriggers <> 0) AS relhastriggers, "
"relhasindex, relhasrules, " "relhasindex, relhasrules, "
"'t'::bool as relhasoids, " "'t'::bool AS relhasoids, "
"NULL::oid as owning_tab, " "NULL::oid AS owning_tab, "
"NULL::int4 as owning_col, " "NULL::int4 AS owning_col, "
"NULL as reltablespace, " "NULL AS reltablespace, "
"NULL as reloptions, " "NULL AS reloptions, "
"NULL as toast_reloptions " "NULL AS toast_reloptions "
"from pg_class c " "FROM pg_class c "
"where relkind in ('%c', '%c') " "WHERE relkind IN ('%c', '%c') "
"order by oid", "ORDER BY oid",
RELKIND_VIEW, RELKIND_VIEW,
username_subquery, username_subquery,
RELKIND_RELATION, RELKIND_SEQUENCE); RELKIND_RELATION, RELKIND_SEQUENCE);
...@@ -3509,7 +3519,7 @@ getInherits(int *numInherits) ...@@ -3509,7 +3519,7 @@ getInherits(int *numInherits)
/* find all the inheritance information */ /* find all the inheritance information */
appendPQExpBuffer(query, "SELECT inhrelid, inhparent from pg_inherits"); appendPQExpBuffer(query, "SELECT inhrelid, inhparent FROM pg_inherits");
res = PQexec(g_conn, query->data); res = PQexec(g_conn, query->data);
check_sql_result(res, g_conn, query->data, PGRES_TUPLES_OK); check_sql_result(res, g_conn, query->data, PGRES_TUPLES_OK);
...@@ -3597,15 +3607,15 @@ getIndexes(TableInfo tblinfo[], int numTables) ...@@ -3597,15 +3607,15 @@ getIndexes(TableInfo tblinfo[], int numTables)
{ {
appendPQExpBuffer(query, appendPQExpBuffer(query,
"SELECT t.tableoid, t.oid, " "SELECT t.tableoid, t.oid, "
"t.relname as indexname, " "t.relname AS indexname, "
"pg_catalog.pg_get_indexdef(i.indexrelid) as indexdef, " "pg_catalog.pg_get_indexdef(i.indexrelid) AS indexdef, "
"t.relnatts as indnkeys, " "t.relnatts AS indnkeys, "
"i.indkey, i.indisclustered, " "i.indkey, i.indisclustered, "
"c.contype, c.conname, " "c.contype, c.conname, "
"c.tableoid as contableoid, " "c.tableoid AS contableoid, "
"c.oid as conoid, " "c.oid AS conoid, "
"(SELECT spcname FROM pg_catalog.pg_tablespace s WHERE s.oid = t.reltablespace) as tablespace, " "(SELECT spcname FROM pg_catalog.pg_tablespace s WHERE s.oid = t.reltablespace) AS tablespace, "
"array_to_string(t.reloptions, ', ') as options " "array_to_string(t.reloptions, ', ') AS options "
"FROM pg_catalog.pg_index i " "FROM pg_catalog.pg_index i "
"JOIN pg_catalog.pg_class t ON (t.oid = i.indexrelid) " "JOIN pg_catalog.pg_class t ON (t.oid = i.indexrelid) "
"LEFT JOIN pg_catalog.pg_depend d " "LEFT JOIN pg_catalog.pg_depend d "
...@@ -3623,15 +3633,15 @@ getIndexes(TableInfo tblinfo[], int numTables) ...@@ -3623,15 +3633,15 @@ getIndexes(TableInfo tblinfo[], int numTables)
{ {
appendPQExpBuffer(query, appendPQExpBuffer(query,
"SELECT t.tableoid, t.oid, " "SELECT t.tableoid, t.oid, "
"t.relname as indexname, " "t.relname AS indexname, "
"pg_catalog.pg_get_indexdef(i.indexrelid) as indexdef, " "pg_catalog.pg_get_indexdef(i.indexrelid) AS indexdef, "
"t.relnatts as indnkeys, " "t.relnatts AS indnkeys, "
"i.indkey, i.indisclustered, " "i.indkey, i.indisclustered, "
"c.contype, c.conname, " "c.contype, c.conname, "
"c.tableoid as contableoid, " "c.tableoid AS contableoid, "
"c.oid as conoid, " "c.oid AS conoid, "
"(SELECT spcname FROM pg_catalog.pg_tablespace s WHERE s.oid = t.reltablespace) as tablespace, " "(SELECT spcname FROM pg_catalog.pg_tablespace s WHERE s.oid = t.reltablespace) AS tablespace, "
"null as options " "null AS options "
"FROM pg_catalog.pg_index i " "FROM pg_catalog.pg_index i "
"JOIN pg_catalog.pg_class t ON (t.oid = i.indexrelid) " "JOIN pg_catalog.pg_class t ON (t.oid = i.indexrelid) "
"LEFT JOIN pg_catalog.pg_depend d " "LEFT JOIN pg_catalog.pg_depend d "
...@@ -3649,15 +3659,15 @@ getIndexes(TableInfo tblinfo[], int numTables) ...@@ -3649,15 +3659,15 @@ getIndexes(TableInfo tblinfo[], int numTables)
{ {
appendPQExpBuffer(query, appendPQExpBuffer(query,
"SELECT t.tableoid, t.oid, " "SELECT t.tableoid, t.oid, "
"t.relname as indexname, " "t.relname AS indexname, "
"pg_catalog.pg_get_indexdef(i.indexrelid) as indexdef, " "pg_catalog.pg_get_indexdef(i.indexrelid) AS indexdef, "
"t.relnatts as indnkeys, " "t.relnatts AS indnkeys, "
"i.indkey, i.indisclustered, " "i.indkey, i.indisclustered, "
"c.contype, c.conname, " "c.contype, c.conname, "
"c.tableoid as contableoid, " "c.tableoid AS contableoid, "
"c.oid as conoid, " "c.oid AS conoid, "
"NULL as tablespace, " "NULL AS tablespace, "
"null as options " "null AS options "
"FROM pg_catalog.pg_index i " "FROM pg_catalog.pg_index i "
"JOIN pg_catalog.pg_class t ON (t.oid = i.indexrelid) " "JOIN pg_catalog.pg_class t ON (t.oid = i.indexrelid) "
"LEFT JOIN pg_catalog.pg_depend d " "LEFT JOIN pg_catalog.pg_depend d "
...@@ -3675,17 +3685,17 @@ getIndexes(TableInfo tblinfo[], int numTables) ...@@ -3675,17 +3685,17 @@ getIndexes(TableInfo tblinfo[], int numTables)
{ {
appendPQExpBuffer(query, appendPQExpBuffer(query,
"SELECT t.tableoid, t.oid, " "SELECT t.tableoid, t.oid, "
"t.relname as indexname, " "t.relname AS indexname, "
"pg_get_indexdef(i.indexrelid) as indexdef, " "pg_get_indexdef(i.indexrelid) AS indexdef, "
"t.relnatts as indnkeys, " "t.relnatts AS indnkeys, "
"i.indkey, false as indisclustered, " "i.indkey, false AS indisclustered, "
"CASE WHEN i.indisprimary THEN 'p'::char " "CASE WHEN i.indisprimary THEN 'p'::char "
"ELSE '0'::char END as contype, " "ELSE '0'::char END AS contype, "
"t.relname as conname, " "t.relname AS conname, "
"0::oid as contableoid, " "0::oid AS contableoid, "
"t.oid as conoid, " "t.oid AS conoid, "
"NULL as tablespace, " "NULL AS tablespace, "
"null as options " "null AS options "
"FROM pg_index i, pg_class t " "FROM pg_index i, pg_class t "
"WHERE t.oid = i.indexrelid " "WHERE t.oid = i.indexrelid "
"AND i.indrelid = '%u'::oid " "AND i.indrelid = '%u'::oid "
...@@ -3698,17 +3708,17 @@ getIndexes(TableInfo tblinfo[], int numTables) ...@@ -3698,17 +3708,17 @@ getIndexes(TableInfo tblinfo[], int numTables)
"SELECT " "SELECT "
"(SELECT oid FROM pg_class WHERE relname = 'pg_class') AS tableoid, " "(SELECT oid FROM pg_class WHERE relname = 'pg_class') AS tableoid, "
"t.oid, " "t.oid, "
"t.relname as indexname, " "t.relname AS indexname, "
"pg_get_indexdef(i.indexrelid) as indexdef, " "pg_get_indexdef(i.indexrelid) AS indexdef, "
"t.relnatts as indnkeys, " "t.relnatts AS indnkeys, "
"i.indkey, false as indisclustered, " "i.indkey, false AS indisclustered, "
"CASE WHEN i.indisprimary THEN 'p'::char " "CASE WHEN i.indisprimary THEN 'p'::char "
"ELSE '0'::char END as contype, " "ELSE '0'::char END AS contype, "
"t.relname as conname, " "t.relname AS conname, "
"0::oid as contableoid, " "0::oid AS contableoid, "
"t.oid as conoid, " "t.oid AS conoid, "
"NULL as tablespace, " "NULL AS tablespace, "
"null as options " "null AS options "
"FROM pg_index i, pg_class t " "FROM pg_index i, pg_class t "
"WHERE t.oid = i.indexrelid " "WHERE t.oid = i.indexrelid "
"AND i.indrelid = '%u'::oid " "AND i.indrelid = '%u'::oid "
...@@ -3862,7 +3872,7 @@ getConstraints(TableInfo tblinfo[], int numTables) ...@@ -3862,7 +3872,7 @@ getConstraints(TableInfo tblinfo[], int numTables)
resetPQExpBuffer(query); resetPQExpBuffer(query);
appendPQExpBuffer(query, appendPQExpBuffer(query,
"SELECT tableoid, oid, conname, confrelid, " "SELECT tableoid, oid, conname, confrelid, "
"pg_catalog.pg_get_constraintdef(oid) as condef " "pg_catalog.pg_get_constraintdef(oid) AS condef "
"FROM pg_catalog.pg_constraint " "FROM pg_catalog.pg_constraint "
"WHERE conrelid = '%u'::pg_catalog.oid " "WHERE conrelid = '%u'::pg_catalog.oid "
"AND contype = 'f'", "AND contype = 'f'",
...@@ -4023,7 +4033,7 @@ getRules(int *numRules) ...@@ -4023,7 +4033,7 @@ getRules(int *numRules)
{ {
appendPQExpBuffer(query, "SELECT " appendPQExpBuffer(query, "SELECT "
"tableoid, oid, rulename, " "tableoid, oid, rulename, "
"ev_class as ruletable, ev_type, is_instead, " "ev_class AS ruletable, ev_type, is_instead, "
"ev_enabled " "ev_enabled "
"FROM pg_rewrite " "FROM pg_rewrite "
"ORDER BY oid"); "ORDER BY oid");
...@@ -4032,8 +4042,8 @@ getRules(int *numRules) ...@@ -4032,8 +4042,8 @@ getRules(int *numRules)
{ {
appendPQExpBuffer(query, "SELECT " appendPQExpBuffer(query, "SELECT "
"tableoid, oid, rulename, " "tableoid, oid, rulename, "
"ev_class as ruletable, ev_type, is_instead, " "ev_class AS ruletable, ev_type, is_instead, "
"'O'::char as ev_enabled " "'O'::char AS ev_enabled "
"FROM pg_rewrite " "FROM pg_rewrite "
"ORDER BY oid"); "ORDER BY oid");
} }
...@@ -4042,8 +4052,8 @@ getRules(int *numRules) ...@@ -4042,8 +4052,8 @@ getRules(int *numRules)
appendPQExpBuffer(query, "SELECT " appendPQExpBuffer(query, "SELECT "
"(SELECT oid FROM pg_class WHERE relname = 'pg_rewrite') AS tableoid, " "(SELECT oid FROM pg_class WHERE relname = 'pg_rewrite') AS tableoid, "
"oid, rulename, " "oid, rulename, "
"ev_class as ruletable, ev_type, is_instead, " "ev_class AS ruletable, ev_type, is_instead, "
"'O'::char as ev_enabled " "'O'::char AS ev_enabled "
"FROM pg_rewrite " "FROM pg_rewrite "
"ORDER BY oid"); "ORDER BY oid");
} }
...@@ -4177,14 +4187,14 @@ getTriggers(TableInfo tblinfo[], int numTables) ...@@ -4177,14 +4187,14 @@ getTriggers(TableInfo tblinfo[], int numTables)
*/ */
appendPQExpBuffer(query, appendPQExpBuffer(query,
"SELECT tgname, " "SELECT tgname, "
"tgfoid::pg_catalog.regproc as tgfname, " "tgfoid::pg_catalog.regproc AS tgfname, "
"tgtype, tgnargs, tgargs, tgenabled, " "tgtype, tgnargs, tgargs, tgenabled, "
"tgisconstraint, tgconstrname, tgdeferrable, " "tgisconstraint, tgconstrname, tgdeferrable, "
"tgconstrrelid, tginitdeferred, tableoid, oid, " "tgconstrrelid, tginitdeferred, tableoid, oid, "
"tgconstrrelid::pg_catalog.regclass as tgconstrrelname " "tgconstrrelid::pg_catalog.regclass AS tgconstrrelname "
"from pg_catalog.pg_trigger t " "FROM pg_catalog.pg_trigger t "
"where tgrelid = '%u'::pg_catalog.oid " "WHERE tgrelid = '%u'::pg_catalog.oid "
"and tgconstraint = 0", "AND tgconstraint = 0",
tbinfo->dobj.catId.oid); tbinfo->dobj.catId.oid);
} }
else if (g_fout->remoteVersion >= 70300) else if (g_fout->remoteVersion >= 70300)
...@@ -4196,14 +4206,14 @@ getTriggers(TableInfo tblinfo[], int numTables) ...@@ -4196,14 +4206,14 @@ getTriggers(TableInfo tblinfo[], int numTables)
*/ */
appendPQExpBuffer(query, appendPQExpBuffer(query,
"SELECT tgname, " "SELECT tgname, "
"tgfoid::pg_catalog.regproc as tgfname, " "tgfoid::pg_catalog.regproc AS tgfname, "
"tgtype, tgnargs, tgargs, tgenabled, " "tgtype, tgnargs, tgargs, tgenabled, "
"tgisconstraint, tgconstrname, tgdeferrable, " "tgisconstraint, tgconstrname, tgdeferrable, "
"tgconstrrelid, tginitdeferred, tableoid, oid, " "tgconstrrelid, tginitdeferred, tableoid, oid, "
"tgconstrrelid::pg_catalog.regclass as tgconstrrelname " "tgconstrrelid::pg_catalog.regclass AS tgconstrrelname "
"from pg_catalog.pg_trigger t " "FROM pg_catalog.pg_trigger t "
"where tgrelid = '%u'::pg_catalog.oid " "WHERE tgrelid = '%u'::pg_catalog.oid "
"and (not tgisconstraint " "AND (NOT tgisconstraint "
" OR NOT EXISTS" " OR NOT EXISTS"
" (SELECT 1 FROM pg_catalog.pg_depend d " " (SELECT 1 FROM pg_catalog.pg_depend d "
" JOIN pg_catalog.pg_constraint c ON (d.refclassid = c.tableoid AND d.refobjid = c.oid) " " JOIN pg_catalog.pg_constraint c ON (d.refclassid = c.tableoid AND d.refobjid = c.oid) "
...@@ -4213,30 +4223,29 @@ getTriggers(TableInfo tblinfo[], int numTables) ...@@ -4213,30 +4223,29 @@ getTriggers(TableInfo tblinfo[], int numTables)
else if (g_fout->remoteVersion >= 70100) else if (g_fout->remoteVersion >= 70100)
{ {
appendPQExpBuffer(query, appendPQExpBuffer(query,
"SELECT tgname, tgfoid::regproc as tgfname, " "SELECT tgname, tgfoid::regproc AS tgfname, "
"tgtype, tgnargs, tgargs, tgenabled, " "tgtype, tgnargs, tgargs, tgenabled, "
"tgisconstraint, tgconstrname, tgdeferrable, " "tgisconstraint, tgconstrname, tgdeferrable, "
"tgconstrrelid, tginitdeferred, tableoid, oid, " "tgconstrrelid, tginitdeferred, tableoid, oid, "
"(select relname from pg_class where oid = tgconstrrelid) " "(SELECT relname FROM pg_class WHERE oid = tgconstrrelid) "
" as tgconstrrelname " " AS tgconstrrelname "
"from pg_trigger " "FROM pg_trigger "
"where tgrelid = '%u'::oid", "WHERE tgrelid = '%u'::oid",
tbinfo->dobj.catId.oid); tbinfo->dobj.catId.oid);
} }
else else
{ {
appendPQExpBuffer(query, appendPQExpBuffer(query,
"SELECT tgname, tgfoid::regproc as tgfname, " "SELECT tgname, tgfoid::regproc AS tgfname, "
"tgtype, tgnargs, tgargs, tgenabled, " "tgtype, tgnargs, tgargs, tgenabled, "
"tgisconstraint, tgconstrname, tgdeferrable, " "tgisconstraint, tgconstrname, tgdeferrable, "
"tgconstrrelid, tginitdeferred, " "tgconstrrelid, tginitdeferred, "
"(SELECT oid FROM pg_class WHERE relname = 'pg_trigger') AS tableoid, " "(SELECT oid FROM pg_class WHERE relname = 'pg_trigger') AS tableoid, "
"oid, " "oid, "
"(select relname from pg_class where oid = tgconstrrelid) " "(SELECT relname FROM pg_class WHERE oid = tgconstrrelid) "
" as tgconstrrelname " " AS tgconstrrelname "
"from pg_trigger " "FROM pg_trigger "
"where tgrelid = '%u'::oid", "WHERE tgrelid = '%u'::oid",
tbinfo->dobj.catId.oid); tbinfo->dobj.catId.oid);
} }
res = PQexec(g_conn, query->data); res = PQexec(g_conn, query->data);
...@@ -4346,7 +4355,7 @@ getProcLangs(int *numProcLangs) ...@@ -4346,7 +4355,7 @@ getProcLangs(int *numProcLangs)
appendPQExpBuffer(query, "SELECT tableoid, oid, " appendPQExpBuffer(query, "SELECT tableoid, oid, "
"lanname, lanpltrusted, lanplcallfoid, " "lanname, lanpltrusted, lanplcallfoid, "
"lanvalidator, lanacl, " "lanvalidator, lanacl, "
"(%s lanowner) as lanowner " "(%s lanowner) AS lanowner "
"FROM pg_language " "FROM pg_language "
"WHERE lanispl " "WHERE lanispl "
"ORDER BY oid", "ORDER BY oid",
...@@ -4356,7 +4365,7 @@ getProcLangs(int *numProcLangs) ...@@ -4356,7 +4365,7 @@ getProcLangs(int *numProcLangs)
{ {
/* Languages are owned by the bootstrap superuser, OID 10 */ /* Languages are owned by the bootstrap superuser, OID 10 */
appendPQExpBuffer(query, "SELECT tableoid, oid, *, " appendPQExpBuffer(query, "SELECT tableoid, oid, *, "
"(%s '10') as lanowner " "(%s '10') AS lanowner "
"FROM pg_language " "FROM pg_language "
"WHERE lanispl " "WHERE lanispl "
"ORDER BY oid", "ORDER BY oid",
...@@ -4366,7 +4375,7 @@ getProcLangs(int *numProcLangs) ...@@ -4366,7 +4375,7 @@ getProcLangs(int *numProcLangs)
{ {
/* Languages are owned by the bootstrap superuser, sysid 1 */ /* Languages are owned by the bootstrap superuser, sysid 1 */
appendPQExpBuffer(query, "SELECT tableoid, oid, *, " appendPQExpBuffer(query, "SELECT tableoid, oid, *, "
"(%s '1') as lanowner " "(%s '1') AS lanowner "
"FROM pg_language " "FROM pg_language "
"WHERE lanispl " "WHERE lanispl "
"ORDER BY oid", "ORDER BY oid",
...@@ -4493,10 +4502,10 @@ getCasts(int *numCasts) ...@@ -4493,10 +4502,10 @@ getCasts(int *numCasts)
} }
else else
{ {
appendPQExpBuffer(query, "SELECT 0 as tableoid, p.oid, " appendPQExpBuffer(query, "SELECT 0 AS tableoid, p.oid, "
"t1.oid as castsource, t2.oid as casttarget, " "t1.oid AS castsource, t2.oid AS casttarget, "
"p.oid as castfunc, 'e' as castcontext, " "p.oid AS castfunc, 'e' AS castcontext, "
"'f' as castmethod " "'f' AS castmethod "
"FROM pg_type t1, pg_type t2, pg_proc p " "FROM pg_type t1, pg_type t2, pg_proc p "
"WHERE p.pronargs = 1 AND " "WHERE p.pronargs = 1 AND "
"p.proargtypes[0] = t1.oid AND " "p.proargtypes[0] = t1.oid AND "
...@@ -4645,12 +4654,12 @@ getTableAttrs(TableInfo *tblinfo, int numTables) ...@@ -4645,12 +4654,12 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
/* need left join here to not fail on dropped columns ... */ /* need left join here to not fail on dropped columns ... */
appendPQExpBuffer(q, "SELECT a.attnum, a.attname, a.atttypmod, a.attstattarget, a.attstorage, t.typstorage, " appendPQExpBuffer(q, "SELECT a.attnum, a.attname, a.atttypmod, a.attstattarget, a.attstorage, t.typstorage, "
"a.attnotnull, a.atthasdef, a.attisdropped, a.attislocal, " "a.attnotnull, a.atthasdef, a.attisdropped, a.attislocal, "
"pg_catalog.format_type(t.oid,a.atttypmod) as atttypname " "pg_catalog.format_type(t.oid,a.atttypmod) AS atttypname "
"from pg_catalog.pg_attribute a left join pg_catalog.pg_type t " "FROM pg_catalog.pg_attribute a LEFT JOIN pg_catalog.pg_type t "
"on a.atttypid = t.oid " "ON a.atttypid = t.oid "
"where a.attrelid = '%u'::pg_catalog.oid " "WHERE a.attrelid = '%u'::pg_catalog.oid "
"and a.attnum > 0::pg_catalog.int2 " "AND a.attnum > 0::pg_catalog.int2 "
"order by a.attrelid, a.attnum", "ORDER BY a.attrelid, a.attnum",
tbinfo->dobj.catId.oid); tbinfo->dobj.catId.oid);
} }
else if (g_fout->remoteVersion >= 70100) else if (g_fout->remoteVersion >= 70100)
...@@ -4660,26 +4669,26 @@ getTableAttrs(TableInfo *tblinfo, int numTables) ...@@ -4660,26 +4669,26 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
* we don't dump it because we can't tell whether it's been * we don't dump it because we can't tell whether it's been
* explicitly set or was just a default. * explicitly set or was just a default.
*/ */
appendPQExpBuffer(q, "SELECT a.attnum, a.attname, a.atttypmod, -1 as attstattarget, a.attstorage, t.typstorage, " appendPQExpBuffer(q, "SELECT a.attnum, a.attname, a.atttypmod, -1 AS attstattarget, a.attstorage, t.typstorage, "
"a.attnotnull, a.atthasdef, false as attisdropped, false as attislocal, " "a.attnotnull, a.atthasdef, false AS attisdropped, false AS attislocal, "
"format_type(t.oid,a.atttypmod) as atttypname " "format_type(t.oid,a.atttypmod) AS atttypname "
"from pg_attribute a left join pg_type t " "FROM pg_attribute a LEFT JOIN pg_type t "
"on a.atttypid = t.oid " "ON a.atttypid = t.oid "
"where a.attrelid = '%u'::oid " "WHERE a.attrelid = '%u'::oid "
"and a.attnum > 0::int2 " "AND a.attnum > 0::int2 "
"order by a.attrelid, a.attnum", "ORDER BY a.attrelid, a.attnum",
tbinfo->dobj.catId.oid); tbinfo->dobj.catId.oid);
} }
else else
{ {
/* format_type not available before 7.1 */ /* format_type not available before 7.1 */
appendPQExpBuffer(q, "SELECT attnum, attname, atttypmod, -1 as attstattarget, attstorage, attstorage as typstorage, " appendPQExpBuffer(q, "SELECT attnum, attname, atttypmod, -1 AS attstattarget, attstorage, attstorage AS typstorage, "
"attnotnull, atthasdef, false as attisdropped, false as attislocal, " "attnotnull, atthasdef, false AS attisdropped, false AS attislocal, "
"(select typname from pg_type where oid = atttypid) as atttypname " "(SELECT typname FROM pg_type WHERE oid = atttypid) AS atttypname "
"from pg_attribute a " "FROM pg_attribute a "
"where attrelid = '%u'::oid " "WHERE attrelid = '%u'::oid "
"and attnum > 0::int2 " "AND attnum > 0::int2 "
"order by attrelid, attnum", "ORDER BY attrelid, attnum",
tbinfo->dobj.catId.oid); tbinfo->dobj.catId.oid);
} }
...@@ -4768,7 +4777,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables) ...@@ -4768,7 +4777,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
else if (g_fout->remoteVersion >= 70200) else if (g_fout->remoteVersion >= 70200)
{ {
/* 7.2 did not have OIDs in pg_attrdef */ /* 7.2 did not have OIDs in pg_attrdef */
appendPQExpBuffer(q, "SELECT tableoid, 0 as oid, adnum, " appendPQExpBuffer(q, "SELECT tableoid, 0 AS oid, adnum, "
"pg_get_expr(adbin, adrelid) AS adsrc " "pg_get_expr(adbin, adrelid) AS adsrc "
"FROM pg_attrdef " "FROM pg_attrdef "
"WHERE adrelid = '%u'::oid", "WHERE adrelid = '%u'::oid",
...@@ -4875,7 +4884,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables) ...@@ -4875,7 +4884,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
{ {
appendPQExpBuffer(q, "SELECT tableoid, oid, conname, " appendPQExpBuffer(q, "SELECT tableoid, oid, conname, "
"pg_catalog.pg_get_constraintdef(oid) AS consrc, " "pg_catalog.pg_get_constraintdef(oid) AS consrc, "
"true as conislocal " "true AS conislocal "
"FROM pg_catalog.pg_constraint " "FROM pg_catalog.pg_constraint "
"WHERE conrelid = '%u'::pg_catalog.oid " "WHERE conrelid = '%u'::pg_catalog.oid "
" AND contype = 'c' " " AND contype = 'c' "
...@@ -4887,7 +4896,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables) ...@@ -4887,7 +4896,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
/* no pg_get_constraintdef, must use consrc */ /* no pg_get_constraintdef, must use consrc */
appendPQExpBuffer(q, "SELECT tableoid, oid, conname, " appendPQExpBuffer(q, "SELECT tableoid, oid, conname, "
"'CHECK (' || consrc || ')' AS consrc, " "'CHECK (' || consrc || ')' AS consrc, "
"true as conislocal " "true AS conislocal "
"FROM pg_catalog.pg_constraint " "FROM pg_catalog.pg_constraint "
"WHERE conrelid = '%u'::pg_catalog.oid " "WHERE conrelid = '%u'::pg_catalog.oid "
" AND contype = 'c' " " AND contype = 'c' "
...@@ -4897,10 +4906,10 @@ getTableAttrs(TableInfo *tblinfo, int numTables) ...@@ -4897,10 +4906,10 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
else if (g_fout->remoteVersion >= 70200) else if (g_fout->remoteVersion >= 70200)
{ {
/* 7.2 did not have OIDs in pg_relcheck */ /* 7.2 did not have OIDs in pg_relcheck */
appendPQExpBuffer(q, "SELECT tableoid, 0 as oid, " appendPQExpBuffer(q, "SELECT tableoid, 0 AS oid, "
"rcname AS conname, " "rcname AS conname, "
"'CHECK (' || rcsrc || ')' AS consrc, " "'CHECK (' || rcsrc || ')' AS consrc, "
"true as conislocal " "true AS conislocal "
"FROM pg_relcheck " "FROM pg_relcheck "
"WHERE rcrelid = '%u'::oid " "WHERE rcrelid = '%u'::oid "
"ORDER BY rcname", "ORDER BY rcname",
...@@ -4911,7 +4920,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables) ...@@ -4911,7 +4920,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
appendPQExpBuffer(q, "SELECT tableoid, oid, " appendPQExpBuffer(q, "SELECT tableoid, oid, "
"rcname AS conname, " "rcname AS conname, "
"'CHECK (' || rcsrc || ')' AS consrc, " "'CHECK (' || rcsrc || ')' AS consrc, "
"true as conislocal " "true AS conislocal "
"FROM pg_relcheck " "FROM pg_relcheck "
"WHERE rcrelid = '%u'::oid " "WHERE rcrelid = '%u'::oid "
"ORDER BY rcname", "ORDER BY rcname",
...@@ -4924,7 +4933,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables) ...@@ -4924,7 +4933,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
"(SELECT oid FROM pg_class WHERE relname = 'pg_relcheck') AS tableoid, " "(SELECT oid FROM pg_class WHERE relname = 'pg_relcheck') AS tableoid, "
"oid, rcname AS conname, " "oid, rcname AS conname, "
"'CHECK (' || rcsrc || ')' AS consrc, " "'CHECK (' || rcsrc || ')' AS consrc, "
"true as conislocal " "true AS conislocal "
"FROM pg_relcheck " "FROM pg_relcheck "
"WHERE rcrelid = '%u'::oid " "WHERE rcrelid = '%u'::oid "
"ORDER BY rcname", "ORDER BY rcname",
...@@ -5110,7 +5119,7 @@ getTSDictionaries(int *numTSDicts) ...@@ -5110,7 +5119,7 @@ getTSDictionaries(int *numTSDicts)
selectSourceSchema("pg_catalog"); selectSourceSchema("pg_catalog");
appendPQExpBuffer(query, "SELECT tableoid, oid, dictname, " appendPQExpBuffer(query, "SELECT tableoid, oid, dictname, "
"dictnamespace, (%s dictowner) as rolname, " "dictnamespace, (%s dictowner) AS rolname, "
"dicttemplate, dictinitoption " "dicttemplate, dictinitoption "
"FROM pg_ts_dict", "FROM pg_ts_dict",
username_subquery); username_subquery);
...@@ -5265,7 +5274,7 @@ getTSConfigurations(int *numTSConfigs) ...@@ -5265,7 +5274,7 @@ getTSConfigurations(int *numTSConfigs)
selectSourceSchema("pg_catalog"); selectSourceSchema("pg_catalog");
appendPQExpBuffer(query, "SELECT tableoid, oid, cfgname, " appendPQExpBuffer(query, "SELECT tableoid, oid, cfgname, "
"cfgnamespace, (%s cfgowner) as rolname, cfgparser " "cfgnamespace, (%s cfgowner) AS rolname, cfgparser "
"FROM pg_ts_config", "FROM pg_ts_config",
username_subquery); username_subquery);
...@@ -5340,8 +5349,10 @@ getForeignDataWrappers(int *numForeignDataWrappers) ...@@ -5340,8 +5349,10 @@ getForeignDataWrappers(int *numForeignDataWrappers)
selectSourceSchema("pg_catalog"); selectSourceSchema("pg_catalog");
appendPQExpBuffer(query, "SELECT oid, fdwname, " appendPQExpBuffer(query, "SELECT oid, fdwname, "
"(%s fdwowner) as rolname, fdwlibrary, fdwacl," "(%s fdwowner) AS rolname, fdwlibrary, fdwacl,"
"array_to_string(ARRAY(select option_name || ' ' || quote_literal(option_value) from pg_options_to_table(fdwoptions)), ', ') AS fdwoptions " "array_to_string(ARRAY("
" SELECT option_name || ' ' || quote_literal(option_value) "
" FROM pg_options_to_table(fdwoptions)), ', ') AS fdwoptions "
"FROM pg_foreign_data_wrapper", "FROM pg_foreign_data_wrapper",
username_subquery); username_subquery);
...@@ -5419,9 +5430,11 @@ getForeignServers(int *numForeignServers) ...@@ -5419,9 +5430,11 @@ getForeignServers(int *numForeignServers)
selectSourceSchema("pg_catalog"); selectSourceSchema("pg_catalog");
appendPQExpBuffer(query, "SELECT oid, srvname, " appendPQExpBuffer(query, "SELECT oid, srvname, "
"(%s srvowner) as rolname, " "(%s srvowner) AS rolname, "
"srvfdw, srvtype, srvversion, srvacl," "srvfdw, srvtype, srvversion, srvacl,"
"array_to_string(ARRAY(select option_name || ' ' || quote_literal(option_value) from pg_options_to_table(srvoptions)), ', ') as srvoptions " "array_to_string(ARRAY("
" SELECT option_name || ' ' || quote_literal(option_value) "
" FROM pg_options_to_table(srvoptions)), ', ') AS srvoptions "
"FROM pg_foreign_server", "FROM pg_foreign_server",
username_subquery); username_subquery);
...@@ -5757,7 +5770,7 @@ collectComments(Archive *fout, CommentItem **items) ...@@ -5757,7 +5770,7 @@ collectComments(Archive *fout, CommentItem **items)
else else
{ {
/* Note: this will fail to find attribute comments in pre-7.2... */ /* Note: this will fail to find attribute comments in pre-7.2... */
appendPQExpBuffer(query, "SELECT description, 0 as classoid, objoid, 0 as objsubid " appendPQExpBuffer(query, "SELECT description, 0 AS classoid, objoid, 0 AS objsubid "
"FROM pg_description " "FROM pg_description "
"ORDER BY objoid"); "ORDER BY objoid");
} }
...@@ -6099,16 +6112,16 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo) ...@@ -6099,16 +6112,16 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo)
appendPQExpBuffer(query, "SELECT typlen, " appendPQExpBuffer(query, "SELECT typlen, "
"typinput, typoutput, typreceive, typsend, " "typinput, typoutput, typreceive, typsend, "
"typmodin, typmodout, typanalyze, " "typmodin, typmodout, typanalyze, "
"typinput::pg_catalog.oid as typinputoid, " "typinput::pg_catalog.oid AS typinputoid, "
"typoutput::pg_catalog.oid as typoutputoid, " "typoutput::pg_catalog.oid AS typoutputoid, "
"typreceive::pg_catalog.oid as typreceiveoid, " "typreceive::pg_catalog.oid AS typreceiveoid, "
"typsend::pg_catalog.oid as typsendoid, " "typsend::pg_catalog.oid AS typsendoid, "
"typmodin::pg_catalog.oid as typmodinoid, " "typmodin::pg_catalog.oid AS typmodinoid, "
"typmodout::pg_catalog.oid as typmodoutoid, " "typmodout::pg_catalog.oid AS typmodoutoid, "
"typanalyze::pg_catalog.oid as typanalyzeoid, " "typanalyze::pg_catalog.oid AS typanalyzeoid, "
"typcategory, typispreferred, " "typcategory, typispreferred, "
"typdelim, typbyval, typalign, typstorage, " "typdelim, typbyval, typalign, typstorage, "
"pg_catalog.pg_get_expr(typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) as typdefaultbin, typdefault " "pg_catalog.pg_get_expr(typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin, typdefault "
"FROM pg_catalog.pg_type " "FROM pg_catalog.pg_type "
"WHERE oid = '%u'::pg_catalog.oid", "WHERE oid = '%u'::pg_catalog.oid",
tinfo->dobj.catId.oid); tinfo->dobj.catId.oid);
...@@ -6118,16 +6131,16 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo) ...@@ -6118,16 +6131,16 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo)
appendPQExpBuffer(query, "SELECT typlen, " appendPQExpBuffer(query, "SELECT typlen, "
"typinput, typoutput, typreceive, typsend, " "typinput, typoutput, typreceive, typsend, "
"typmodin, typmodout, typanalyze, " "typmodin, typmodout, typanalyze, "
"typinput::pg_catalog.oid as typinputoid, " "typinput::pg_catalog.oid AS typinputoid, "
"typoutput::pg_catalog.oid as typoutputoid, " "typoutput::pg_catalog.oid AS typoutputoid, "
"typreceive::pg_catalog.oid as typreceiveoid, " "typreceive::pg_catalog.oid AS typreceiveoid, "
"typsend::pg_catalog.oid as typsendoid, " "typsend::pg_catalog.oid AS typsendoid, "
"typmodin::pg_catalog.oid as typmodinoid, " "typmodin::pg_catalog.oid AS typmodinoid, "
"typmodout::pg_catalog.oid as typmodoutoid, " "typmodout::pg_catalog.oid AS typmodoutoid, "
"typanalyze::pg_catalog.oid as typanalyzeoid, " "typanalyze::pg_catalog.oid AS typanalyzeoid, "
"'U' as typcategory, false as typispreferred, " "'U' AS typcategory, false AS typispreferred, "
"typdelim, typbyval, typalign, typstorage, " "typdelim, typbyval, typalign, typstorage, "
"pg_catalog.pg_get_expr(typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) as typdefaultbin, typdefault " "pg_catalog.pg_get_expr(typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin, typdefault "
"FROM pg_catalog.pg_type " "FROM pg_catalog.pg_type "
"WHERE oid = '%u'::pg_catalog.oid", "WHERE oid = '%u'::pg_catalog.oid",
tinfo->dobj.catId.oid); tinfo->dobj.catId.oid);
...@@ -6136,17 +6149,17 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo) ...@@ -6136,17 +6149,17 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo)
{ {
appendPQExpBuffer(query, "SELECT typlen, " appendPQExpBuffer(query, "SELECT typlen, "
"typinput, typoutput, typreceive, typsend, " "typinput, typoutput, typreceive, typsend, "
"'-' as typmodin, '-' as typmodout, " "'-' AS typmodin, '-' AS typmodout, "
"typanalyze, " "typanalyze, "
"typinput::pg_catalog.oid as typinputoid, " "typinput::pg_catalog.oid AS typinputoid, "
"typoutput::pg_catalog.oid as typoutputoid, " "typoutput::pg_catalog.oid AS typoutputoid, "
"typreceive::pg_catalog.oid as typreceiveoid, " "typreceive::pg_catalog.oid AS typreceiveoid, "
"typsend::pg_catalog.oid as typsendoid, " "typsend::pg_catalog.oid AS typsendoid, "
"0 as typmodinoid, 0 as typmodoutoid, " "0 AS typmodinoid, 0 AS typmodoutoid, "
"typanalyze::pg_catalog.oid as typanalyzeoid, " "typanalyze::pg_catalog.oid AS typanalyzeoid, "
"'U' as typcategory, false as typispreferred, " "'U' AS typcategory, false AS typispreferred, "
"typdelim, typbyval, typalign, typstorage, " "typdelim, typbyval, typalign, typstorage, "
"pg_catalog.pg_get_expr(typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) as typdefaultbin, typdefault " "pg_catalog.pg_get_expr(typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin, typdefault "
"FROM pg_catalog.pg_type " "FROM pg_catalog.pg_type "
"WHERE oid = '%u'::pg_catalog.oid", "WHERE oid = '%u'::pg_catalog.oid",
tinfo->dobj.catId.oid); tinfo->dobj.catId.oid);
...@@ -6155,17 +6168,17 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo) ...@@ -6155,17 +6168,17 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo)
{ {
appendPQExpBuffer(query, "SELECT typlen, " appendPQExpBuffer(query, "SELECT typlen, "
"typinput, typoutput, typreceive, typsend, " "typinput, typoutput, typreceive, typsend, "
"'-' as typmodin, '-' as typmodout, " "'-' AS typmodin, '-' AS typmodout, "
"'-' as typanalyze, " "'-' AS typanalyze, "
"typinput::pg_catalog.oid as typinputoid, " "typinput::pg_catalog.oid AS typinputoid, "
"typoutput::pg_catalog.oid as typoutputoid, " "typoutput::pg_catalog.oid AS typoutputoid, "
"typreceive::pg_catalog.oid as typreceiveoid, " "typreceive::pg_catalog.oid AS typreceiveoid, "
"typsend::pg_catalog.oid as typsendoid, " "typsend::pg_catalog.oid AS typsendoid, "
"0 as typmodinoid, 0 as typmodoutoid, " "0 AS typmodinoid, 0 AS typmodoutoid, "
"0 as typanalyzeoid, " "0 AS typanalyzeoid, "
"'U' as typcategory, false as typispreferred, " "'U' AS typcategory, false AS typispreferred, "
"typdelim, typbyval, typalign, typstorage, " "typdelim, typbyval, typalign, typstorage, "
"pg_catalog.pg_get_expr(typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) as typdefaultbin, typdefault " "pg_catalog.pg_get_expr(typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin, typdefault "
"FROM pg_catalog.pg_type " "FROM pg_catalog.pg_type "
"WHERE oid = '%u'::pg_catalog.oid", "WHERE oid = '%u'::pg_catalog.oid",
tinfo->dobj.catId.oid); tinfo->dobj.catId.oid);
...@@ -6174,17 +6187,17 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo) ...@@ -6174,17 +6187,17 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo)
{ {
appendPQExpBuffer(query, "SELECT typlen, " appendPQExpBuffer(query, "SELECT typlen, "
"typinput, typoutput, " "typinput, typoutput, "
"'-' as typreceive, '-' as typsend, " "'-' AS typreceive, '-' AS typsend, "
"'-' as typmodin, '-' as typmodout, " "'-' AS typmodin, '-' AS typmodout, "
"'-' as typanalyze, " "'-' AS typanalyze, "
"typinput::pg_catalog.oid as typinputoid, " "typinput::pg_catalog.oid AS typinputoid, "
"typoutput::pg_catalog.oid as typoutputoid, " "typoutput::pg_catalog.oid AS typoutputoid, "
"0 as typreceiveoid, 0 as typsendoid, " "0 AS typreceiveoid, 0 AS typsendoid, "
"0 as typmodinoid, 0 as typmodoutoid, " "0 AS typmodinoid, 0 AS typmodoutoid, "
"0 as typanalyzeoid, " "0 AS typanalyzeoid, "
"'U' as typcategory, false as typispreferred, " "'U' AS typcategory, false AS typispreferred, "
"typdelim, typbyval, typalign, typstorage, " "typdelim, typbyval, typalign, typstorage, "
"pg_catalog.pg_get_expr(typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) as typdefaultbin, typdefault " "pg_catalog.pg_get_expr(typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin, typdefault "
"FROM pg_catalog.pg_type " "FROM pg_catalog.pg_type "
"WHERE oid = '%u'::pg_catalog.oid", "WHERE oid = '%u'::pg_catalog.oid",
tinfo->dobj.catId.oid); tinfo->dobj.catId.oid);
...@@ -6197,17 +6210,17 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo) ...@@ -6197,17 +6210,17 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo)
*/ */
appendPQExpBuffer(query, "SELECT typlen, " appendPQExpBuffer(query, "SELECT typlen, "
"typinput, typoutput, " "typinput, typoutput, "
"'-' as typreceive, '-' as typsend, " "'-' AS typreceive, '-' AS typsend, "
"'-' as typmodin, '-' as typmodout, " "'-' AS typmodin, '-' AS typmodout, "
"'-' as typanalyze, " "'-' AS typanalyze, "
"typinput::oid as typinputoid, " "typinput::oid AS typinputoid, "
"typoutput::oid as typoutputoid, " "typoutput::oid AS typoutputoid, "
"0 as typreceiveoid, 0 as typsendoid, " "0 AS typreceiveoid, 0 AS typsendoid, "
"0 as typmodinoid, 0 as typmodoutoid, " "0 AS typmodinoid, 0 AS typmodoutoid, "
"0 as typanalyzeoid, " "0 AS typanalyzeoid, "
"'U' as typcategory, false as typispreferred, " "'U' AS typcategory, false AS typispreferred, "
"typdelim, typbyval, typalign, typstorage, " "typdelim, typbyval, typalign, typstorage, "
"NULL as typdefaultbin, typdefault " "NULL AS typdefaultbin, typdefault "
"FROM pg_type " "FROM pg_type "
"WHERE oid = '%u'::oid", "WHERE oid = '%u'::oid",
tinfo->dobj.catId.oid); tinfo->dobj.catId.oid);
...@@ -6220,17 +6233,17 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo) ...@@ -6220,17 +6233,17 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo)
*/ */
appendPQExpBuffer(query, "SELECT typlen, " appendPQExpBuffer(query, "SELECT typlen, "
"typinput, typoutput, " "typinput, typoutput, "
"'-' as typreceive, '-' as typsend, " "'-' AS typreceive, '-' AS typsend, "
"'-' as typmodin, '-' as typmodout, " "'-' AS typmodin, '-' AS typmodout, "
"'-' as typanalyze, " "'-' AS typanalyze, "
"typinput::oid as typinputoid, " "typinput::oid AS typinputoid, "
"typoutput::oid as typoutputoid, " "typoutput::oid AS typoutputoid, "
"0 as typreceiveoid, 0 as typsendoid, " "0 AS typreceiveoid, 0 AS typsendoid, "
"0 as typmodinoid, 0 as typmodoutoid, " "0 AS typmodinoid, 0 AS typmodoutoid, "
"0 as typanalyzeoid, " "0 AS typanalyzeoid, "
"'U' as typcategory, false as typispreferred, " "'U' AS typcategory, false AS typispreferred, "
"typdelim, typbyval, typalign, typstorage, " "typdelim, typbyval, typalign, typstorage, "
"NULL as typdefaultbin, NULL as typdefault " "NULL AS typdefaultbin, NULL AS typdefault "
"FROM pg_type " "FROM pg_type "
"WHERE oid = '%u'::oid", "WHERE oid = '%u'::oid",
tinfo->dobj.catId.oid); tinfo->dobj.catId.oid);
...@@ -6239,18 +6252,18 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo) ...@@ -6239,18 +6252,18 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo)
{ {
appendPQExpBuffer(query, "SELECT typlen, " appendPQExpBuffer(query, "SELECT typlen, "
"typinput, typoutput, " "typinput, typoutput, "
"'-' as typreceive, '-' as typsend, " "'-' AS typreceive, '-' AS typsend, "
"'-' as typmodin, '-' as typmodout, " "'-' AS typmodin, '-' AS typmodout, "
"'-' as typanalyze, " "'-' AS typanalyze, "
"typinput::oid as typinputoid, " "typinput::oid AS typinputoid, "
"typoutput::oid as typoutputoid, " "typoutput::oid AS typoutputoid, "
"0 as typreceiveoid, 0 as typsendoid, " "0 AS typreceiveoid, 0 AS typsendoid, "
"0 as typmodinoid, 0 as typmodoutoid, " "0 AS typmodinoid, 0 AS typmodoutoid, "
"0 as typanalyzeoid, " "0 AS typanalyzeoid, "
"'U' as typcategory, false as typispreferred, " "'U' AS typcategory, false AS typispreferred, "
"typdelim, typbyval, typalign, " "typdelim, typbyval, typalign, "
"'p'::char as typstorage, " "'p'::char AS typstorage, "
"NULL as typdefaultbin, NULL as typdefault " "NULL AS typdefaultbin, NULL AS typdefault "
"FROM pg_type " "FROM pg_type "
"WHERE oid = '%u'::oid", "WHERE oid = '%u'::oid",
tinfo->dobj.catId.oid); tinfo->dobj.catId.oid);
...@@ -6447,8 +6460,8 @@ dumpDomain(Archive *fout, TypeInfo *tinfo) ...@@ -6447,8 +6460,8 @@ dumpDomain(Archive *fout, TypeInfo *tinfo)
/* Fetch domain specific details */ /* Fetch domain specific details */
/* We assume here that remoteVersion must be at least 70300 */ /* We assume here that remoteVersion must be at least 70300 */
appendPQExpBuffer(query, "SELECT typnotnull, " appendPQExpBuffer(query, "SELECT typnotnull, "
"pg_catalog.format_type(typbasetype, typtypmod) as typdefn, " "pg_catalog.format_type(typbasetype, typtypmod) AS typdefn, "
"pg_catalog.pg_get_expr(typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) as typdefaultbin, typdefault " "pg_catalog.pg_get_expr(typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin, typdefault "
"FROM pg_catalog.pg_type " "FROM pg_catalog.pg_type "
"WHERE oid = '%u'::pg_catalog.oid", "WHERE oid = '%u'::pg_catalog.oid",
tinfo->dobj.catId.oid); tinfo->dobj.catId.oid);
...@@ -6565,7 +6578,7 @@ dumpCompositeType(Archive *fout, TypeInfo *tinfo) ...@@ -6565,7 +6578,7 @@ dumpCompositeType(Archive *fout, TypeInfo *tinfo)
/* We assume here that remoteVersion must be at least 70300 */ /* We assume here that remoteVersion must be at least 70300 */
appendPQExpBuffer(query, "SELECT a.attname, " appendPQExpBuffer(query, "SELECT a.attname, "
"pg_catalog.format_type(a.atttypid, a.atttypmod) as atttypdefn " "pg_catalog.format_type(a.atttypid, a.atttypmod) AS atttypdefn "
"FROM pg_catalog.pg_type t, pg_catalog.pg_attribute a " "FROM pg_catalog.pg_type t, pg_catalog.pg_attribute a "
"WHERE t.oid = '%u'::pg_catalog.oid " "WHERE t.oid = '%u'::pg_catalog.oid "
"AND a.attrelid = t.typrelid " "AND a.attrelid = t.typrelid "
...@@ -7001,12 +7014,12 @@ dumpFunc(Archive *fout, FuncInfo *finfo) ...@@ -7001,12 +7014,12 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
*/ */
appendPQExpBuffer(query, appendPQExpBuffer(query,
"SELECT proretset, prosrc, probin, " "SELECT proretset, prosrc, probin, "
"pg_catalog.pg_get_function_arguments(oid) as funcargs, " "pg_catalog.pg_get_function_arguments(oid) AS funcargs, "
"pg_catalog.pg_get_function_identity_arguments(oid) as funciargs, " "pg_catalog.pg_get_function_identity_arguments(oid) AS funciargs, "
"pg_catalog.pg_get_function_result(oid) as funcresult, " "pg_catalog.pg_get_function_result(oid) AS funcresult, "
"proiswindow, provolatile, proisstrict, prosecdef, " "proiswindow, provolatile, proisstrict, prosecdef, "
"proconfig, procost, prorows, " "proconfig, procost, prorows, "
"(SELECT lanname FROM pg_catalog.pg_language WHERE oid = prolang) as lanname " "(SELECT lanname FROM pg_catalog.pg_language WHERE oid = prolang) AS lanname "
"FROM pg_catalog.pg_proc " "FROM pg_catalog.pg_proc "
"WHERE oid = '%u'::pg_catalog.oid", "WHERE oid = '%u'::pg_catalog.oid",
finfo->dobj.catId.oid); finfo->dobj.catId.oid);
...@@ -7016,10 +7029,10 @@ dumpFunc(Archive *fout, FuncInfo *finfo) ...@@ -7016,10 +7029,10 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
appendPQExpBuffer(query, appendPQExpBuffer(query,
"SELECT proretset, prosrc, probin, " "SELECT proretset, prosrc, probin, "
"proallargtypes, proargmodes, proargnames, " "proallargtypes, proargmodes, proargnames, "
"false as proiswindow, " "false AS proiswindow, "
"provolatile, proisstrict, prosecdef, " "provolatile, proisstrict, prosecdef, "
"proconfig, procost, prorows, " "proconfig, procost, prorows, "
"(SELECT lanname FROM pg_catalog.pg_language WHERE oid = prolang) as lanname " "(SELECT lanname FROM pg_catalog.pg_language WHERE oid = prolang) AS lanname "
"FROM pg_catalog.pg_proc " "FROM pg_catalog.pg_proc "
"WHERE oid = '%u'::pg_catalog.oid", "WHERE oid = '%u'::pg_catalog.oid",
finfo->dobj.catId.oid); finfo->dobj.catId.oid);
...@@ -7029,10 +7042,10 @@ dumpFunc(Archive *fout, FuncInfo *finfo) ...@@ -7029,10 +7042,10 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
appendPQExpBuffer(query, appendPQExpBuffer(query,
"SELECT proretset, prosrc, probin, " "SELECT proretset, prosrc, probin, "
"proallargtypes, proargmodes, proargnames, " "proallargtypes, proargmodes, proargnames, "
"false as proiswindow, " "false AS proiswindow, "
"provolatile, proisstrict, prosecdef, " "provolatile, proisstrict, prosecdef, "
"null as proconfig, 0 as procost, 0 as prorows, " "null AS proconfig, 0 AS procost, 0 AS prorows, "
"(SELECT lanname FROM pg_catalog.pg_language WHERE oid = prolang) as lanname " "(SELECT lanname FROM pg_catalog.pg_language WHERE oid = prolang) AS lanname "
"FROM pg_catalog.pg_proc " "FROM pg_catalog.pg_proc "
"WHERE oid = '%u'::pg_catalog.oid", "WHERE oid = '%u'::pg_catalog.oid",
finfo->dobj.catId.oid); finfo->dobj.catId.oid);
...@@ -7041,13 +7054,13 @@ dumpFunc(Archive *fout, FuncInfo *finfo) ...@@ -7041,13 +7054,13 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
{ {
appendPQExpBuffer(query, appendPQExpBuffer(query,
"SELECT proretset, prosrc, probin, " "SELECT proretset, prosrc, probin, "
"null as proallargtypes, " "null AS proallargtypes, "
"null as proargmodes, " "null AS proargmodes, "
"proargnames, " "proargnames, "
"false as proiswindow, " "false AS proiswindow, "
"provolatile, proisstrict, prosecdef, " "provolatile, proisstrict, prosecdef, "
"null as proconfig, 0 as procost, 0 as prorows, " "null AS proconfig, 0 AS procost, 0 AS prorows, "
"(SELECT lanname FROM pg_catalog.pg_language WHERE oid = prolang) as lanname " "(SELECT lanname FROM pg_catalog.pg_language WHERE oid = prolang) AS lanname "
"FROM pg_catalog.pg_proc " "FROM pg_catalog.pg_proc "
"WHERE oid = '%u'::pg_catalog.oid", "WHERE oid = '%u'::pg_catalog.oid",
finfo->dobj.catId.oid); finfo->dobj.catId.oid);
...@@ -7056,13 +7069,13 @@ dumpFunc(Archive *fout, FuncInfo *finfo) ...@@ -7056,13 +7069,13 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
{ {
appendPQExpBuffer(query, appendPQExpBuffer(query,
"SELECT proretset, prosrc, probin, " "SELECT proretset, prosrc, probin, "
"null as proallargtypes, " "null AS proallargtypes, "
"null as proargmodes, " "null AS proargmodes, "
"null as proargnames, " "null AS proargnames, "
"false as proiswindow, " "false AS proiswindow, "
"provolatile, proisstrict, prosecdef, " "provolatile, proisstrict, prosecdef, "
"null as proconfig, 0 as procost, 0 as prorows, " "null AS proconfig, 0 AS procost, 0 AS prorows, "
"(SELECT lanname FROM pg_catalog.pg_language WHERE oid = prolang) as lanname " "(SELECT lanname FROM pg_catalog.pg_language WHERE oid = prolang) AS lanname "
"FROM pg_catalog.pg_proc " "FROM pg_catalog.pg_proc "
"WHERE oid = '%u'::pg_catalog.oid", "WHERE oid = '%u'::pg_catalog.oid",
finfo->dobj.catId.oid); finfo->dobj.catId.oid);
...@@ -7071,15 +7084,15 @@ dumpFunc(Archive *fout, FuncInfo *finfo) ...@@ -7071,15 +7084,15 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
{ {
appendPQExpBuffer(query, appendPQExpBuffer(query,
"SELECT proretset, prosrc, probin, " "SELECT proretset, prosrc, probin, "
"null as proallargtypes, " "null AS proallargtypes, "
"null as proargmodes, " "null AS proargmodes, "
"null as proargnames, " "null AS proargnames, "
"false as proiswindow, " "false AS proiswindow, "
"case when proiscachable then 'i' else 'v' end as provolatile, " "case when proiscachable then 'i' else 'v' end AS provolatile, "
"proisstrict, " "proisstrict, "
"false as prosecdef, " "false AS prosecdef, "
"null as proconfig, 0 as procost, 0 as prorows, " "null AS proconfig, 0 AS procost, 0 AS prorows, "
"(SELECT lanname FROM pg_language WHERE oid = prolang) as lanname " "(SELECT lanname FROM pg_language WHERE oid = prolang) AS lanname "
"FROM pg_proc " "FROM pg_proc "
"WHERE oid = '%u'::oid", "WHERE oid = '%u'::oid",
finfo->dobj.catId.oid); finfo->dobj.catId.oid);
...@@ -7088,15 +7101,15 @@ dumpFunc(Archive *fout, FuncInfo *finfo) ...@@ -7088,15 +7101,15 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
{ {
appendPQExpBuffer(query, appendPQExpBuffer(query,
"SELECT proretset, prosrc, probin, " "SELECT proretset, prosrc, probin, "
"null as proallargtypes, " "null AS proallargtypes, "
"null as proargmodes, " "null AS proargmodes, "
"null as proargnames, " "null AS proargnames, "
"false as proiswindow, " "false AS proiswindow, "
"case when proiscachable then 'i' else 'v' end as provolatile, " "CASE WHEN proiscachable THEN 'i' ELSE 'v' END AS provolatile, "
"false as proisstrict, " "false AS proisstrict, "
"false as prosecdef, " "false AS prosecdef, "
"null as proconfig, 0 as procost, 0 as prorows, " "NULL AS proconfig, 0 AS procost, 0 AS prorows, "
"(SELECT lanname FROM pg_language WHERE oid = prolang) as lanname " "(SELECT lanname FROM pg_language WHERE oid = prolang) AS lanname "
"FROM pg_proc " "FROM pg_proc "
"WHERE oid = '%u'::oid", "WHERE oid = '%u'::oid",
finfo->dobj.catId.oid); finfo->dobj.catId.oid);
...@@ -7588,8 +7601,8 @@ dumpOpr(Archive *fout, OprInfo *oprinfo) ...@@ -7588,8 +7601,8 @@ dumpOpr(Archive *fout, OprInfo *oprinfo)
"oprrest::pg_catalog.regprocedure, " "oprrest::pg_catalog.regprocedure, "
"oprjoin::pg_catalog.regprocedure, " "oprjoin::pg_catalog.regprocedure, "
"oprcanmerge, oprcanhash " "oprcanmerge, oprcanhash "
"from pg_catalog.pg_operator " "FROM pg_catalog.pg_operator "
"where oid = '%u'::pg_catalog.oid", "WHERE oid = '%u'::pg_catalog.oid",
oprinfo->dobj.catId.oid); oprinfo->dobj.catId.oid);
} }
else if (g_fout->remoteVersion >= 70300) else if (g_fout->remoteVersion >= 70300)
...@@ -7602,38 +7615,38 @@ dumpOpr(Archive *fout, OprInfo *oprinfo) ...@@ -7602,38 +7615,38 @@ dumpOpr(Archive *fout, OprInfo *oprinfo)
"oprnegate::pg_catalog.regoperator, " "oprnegate::pg_catalog.regoperator, "
"oprrest::pg_catalog.regprocedure, " "oprrest::pg_catalog.regprocedure, "
"oprjoin::pg_catalog.regprocedure, " "oprjoin::pg_catalog.regprocedure, "
"(oprlsortop != 0) as oprcanmerge, " "(oprlsortop != 0) AS oprcanmerge, "
"oprcanhash " "oprcanhash "
"from pg_catalog.pg_operator " "FROM pg_catalog.pg_operator "
"where oid = '%u'::pg_catalog.oid", "WHERE oid = '%u'::pg_catalog.oid",
oprinfo->dobj.catId.oid); oprinfo->dobj.catId.oid);
} }
else if (g_fout->remoteVersion >= 70100) else if (g_fout->remoteVersion >= 70100)
{ {
appendPQExpBuffer(query, "SELECT oprkind, oprcode, " appendPQExpBuffer(query, "SELECT oprkind, oprcode, "
"CASE WHEN oprleft = 0 THEN '-' " "CASE WHEN oprleft = 0 THEN '-' "
"ELSE format_type(oprleft, NULL) END as oprleft, " "ELSE format_type(oprleft, NULL) END AS oprleft, "
"CASE WHEN oprright = 0 THEN '-' " "CASE WHEN oprright = 0 THEN '-' "
"ELSE format_type(oprright, NULL) END as oprright, " "ELSE format_type(oprright, NULL) END AS oprright, "
"oprcom, oprnegate, oprrest, oprjoin, " "oprcom, oprnegate, oprrest, oprjoin, "
"(oprlsortop != 0) as oprcanmerge, " "(oprlsortop != 0) AS oprcanmerge, "
"oprcanhash " "oprcanhash "
"from pg_operator " "FROM pg_operator "
"where oid = '%u'::oid", "WHERE oid = '%u'::oid",
oprinfo->dobj.catId.oid); oprinfo->dobj.catId.oid);
} }
else else
{ {
appendPQExpBuffer(query, "SELECT oprkind, oprcode, " appendPQExpBuffer(query, "SELECT oprkind, oprcode, "
"CASE WHEN oprleft = 0 THEN '-'::name " "CASE WHEN oprleft = 0 THEN '-'::name "
"ELSE (select typname from pg_type where oid = oprleft) END as oprleft, " "ELSE (SELECT typname FROM pg_type WHERE oid = oprleft) END AS oprleft, "
"CASE WHEN oprright = 0 THEN '-'::name " "CASE WHEN oprright = 0 THEN '-'::name "
"ELSE (select typname from pg_type where oid = oprright) END as oprright, " "ELSE (SELECT typname FROM pg_type WHERE oid = oprright) END AS oprright, "
"oprcom, oprnegate, oprrest, oprjoin, " "oprcom, oprnegate, oprrest, oprjoin, "
"(oprlsortop != 0) as oprcanmerge, " "(oprlsortop != 0) AS oprcanmerge, "
"oprcanhash " "oprcanhash "
"from pg_operator " "FROM pg_operator "
"where oid = '%u'::oid", "WHERE oid = '%u'::oid",
oprinfo->dobj.catId.oid); oprinfo->dobj.catId.oid);
} }
...@@ -8071,7 +8084,7 @@ dumpOpclass(Archive *fout, OpclassInfo *opcinfo) ...@@ -8071,7 +8084,7 @@ dumpOpclass(Archive *fout, OpclassInfo *opcinfo)
* an older server's table in which it is used. Would it be better * an older server's table in which it is used. Would it be better
* to silently ignore it? * to silently ignore it?
*/ */
appendPQExpBuffer(query, "SELECT amopstrategy, false as amopreqcheck, " appendPQExpBuffer(query, "SELECT amopstrategy, false AS amopreqcheck, "
"amopopr::pg_catalog.regoperator " "amopopr::pg_catalog.regoperator "
"FROM pg_catalog.pg_amop ao, pg_catalog.pg_depend " "FROM pg_catalog.pg_amop ao, pg_catalog.pg_depend "
"WHERE refclassid = 'pg_catalog.pg_opclass'::pg_catalog.regclass " "WHERE refclassid = 'pg_catalog.pg_opclass'::pg_catalog.regclass "
...@@ -8282,7 +8295,7 @@ dumpOpfamily(Archive *fout, OpfamilyInfo *opfinfo) ...@@ -8282,7 +8295,7 @@ dumpOpfamily(Archive *fout, OpfamilyInfo *opfinfo)
* an older server's table in which it is used. Would it be better * an older server's table in which it is used. Would it be better
* to silently ignore it? * to silently ignore it?
*/ */
appendPQExpBuffer(query, "SELECT amopstrategy, false as amopreqcheck, " appendPQExpBuffer(query, "SELECT amopstrategy, false AS amopreqcheck, "
"amopopr::pg_catalog.regoperator " "amopopr::pg_catalog.regoperator "
"FROM pg_catalog.pg_amop ao, pg_catalog.pg_depend " "FROM pg_catalog.pg_amop ao, pg_catalog.pg_depend "
"WHERE refclassid = 'pg_catalog.pg_opfamily'::pg_catalog.regclass " "WHERE refclassid = 'pg_catalog.pg_opfamily'::pg_catalog.regclass "
...@@ -8695,45 +8708,45 @@ dumpAgg(Archive *fout, AggInfo *agginfo) ...@@ -8695,45 +8708,45 @@ dumpAgg(Archive *fout, AggInfo *agginfo)
"aggfinalfn, aggtranstype::pg_catalog.regtype, " "aggfinalfn, aggtranstype::pg_catalog.regtype, "
"aggsortop::pg_catalog.regoperator, " "aggsortop::pg_catalog.regoperator, "
"agginitval, " "agginitval, "
"'t'::boolean as convertok " "'t'::boolean AS convertok "
"from pg_catalog.pg_aggregate a, pg_catalog.pg_proc p " "FROM pg_catalog.pg_aggregate a, pg_catalog.pg_proc p "
"where a.aggfnoid = p.oid " "WHERE a.aggfnoid = p.oid "
"and p.oid = '%u'::pg_catalog.oid", "AND p.oid = '%u'::pg_catalog.oid",
agginfo->aggfn.dobj.catId.oid); agginfo->aggfn.dobj.catId.oid);
} }
else if (g_fout->remoteVersion >= 70300) else if (g_fout->remoteVersion >= 70300)
{ {
appendPQExpBuffer(query, "SELECT aggtransfn, " appendPQExpBuffer(query, "SELECT aggtransfn, "
"aggfinalfn, aggtranstype::pg_catalog.regtype, " "aggfinalfn, aggtranstype::pg_catalog.regtype, "
"0 as aggsortop, " "0 AS aggsortop, "
"agginitval, " "agginitval, "
"'t'::boolean as convertok " "'t'::boolean AS convertok "
"from pg_catalog.pg_aggregate a, pg_catalog.pg_proc p " "FROM pg_catalog.pg_aggregate a, pg_catalog.pg_proc p "
"where a.aggfnoid = p.oid " "WHERE a.aggfnoid = p.oid "
"and p.oid = '%u'::pg_catalog.oid", "AND p.oid = '%u'::pg_catalog.oid",
agginfo->aggfn.dobj.catId.oid); agginfo->aggfn.dobj.catId.oid);
} }
else if (g_fout->remoteVersion >= 70100) else if (g_fout->remoteVersion >= 70100)
{ {
appendPQExpBuffer(query, "SELECT aggtransfn, aggfinalfn, " appendPQExpBuffer(query, "SELECT aggtransfn, aggfinalfn, "
"format_type(aggtranstype, NULL) as aggtranstype, " "format_type(aggtranstype, NULL) AS aggtranstype, "
"0 as aggsortop, " "0 AS aggsortop, "
"agginitval, " "agginitval, "
"'t'::boolean as convertok " "'t'::boolean AS convertok "
"from pg_aggregate " "FROM pg_aggregate "
"where oid = '%u'::oid", "WHERE oid = '%u'::oid",
agginfo->aggfn.dobj.catId.oid); agginfo->aggfn.dobj.catId.oid);
} }
else else
{ {
appendPQExpBuffer(query, "SELECT aggtransfn1 as aggtransfn, " appendPQExpBuffer(query, "SELECT aggtransfn1 AS aggtransfn, "
"aggfinalfn, " "aggfinalfn, "
"(select typname from pg_type where oid = aggtranstype1) as aggtranstype, " "(SELECT typname FROM pg_type WHERE oid = aggtranstype1) AS aggtranstype, "
"0 as aggsortop, " "0 AS aggsortop, "
"agginitval1 as agginitval, " "agginitval1 AS agginitval, "
"(aggtransfn2 = 0 and aggtranstype2 = 0 and agginitval2 is null) as convertok " "(aggtransfn2 = 0 and aggtranstype2 = 0 and agginitval2 is null) AS convertok "
"from pg_aggregate " "FROM pg_aggregate "
"where oid = '%u'::oid", "WHERE oid = '%u'::oid",
agginfo->aggfn.dobj.catId.oid); agginfo->aggfn.dobj.catId.oid);
} }
...@@ -9386,7 +9399,8 @@ dumpUserMappings(Archive *fout, const char *target, ...@@ -9386,7 +9399,8 @@ dumpUserMappings(Archive *fout, const char *target,
appendPQExpBuffer(query, appendPQExpBuffer(query,
"SELECT (%s umuser) AS umuser, " "SELECT (%s umuser) AS umuser, "
"array_to_string(ARRAY(SELECT option_name || ' ' || quote_literal(option_value) FROM pg_options_to_table(umoptions)), ', ') AS umoptions\n" "array_to_string(ARRAY(SELECT option_name || ' ' || quote_literal(option_value) FROM pg_options_to_table(umoptions)), ', ') AS umoptions\n"
"FROM pg_user_mapping WHERE umserver=%u", "FROM pg_user_mapping "
"WHERE umserver=%u",
username_subquery, username_subquery,
catalogId.oid); catalogId.oid);
...@@ -9590,13 +9604,13 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) ...@@ -9590,13 +9604,13 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
{ {
/* Beginning in 7.3, viewname is not unique; rely on OID */ /* Beginning in 7.3, viewname is not unique; rely on OID */
appendPQExpBuffer(query, appendPQExpBuffer(query,
"SELECT pg_catalog.pg_get_viewdef('%u'::pg_catalog.oid) as viewdef", "SELECT pg_catalog.pg_get_viewdef('%u'::pg_catalog.oid) AS viewdef",
tbinfo->dobj.catId.oid); tbinfo->dobj.catId.oid);
} }
else else
{ {
appendPQExpBuffer(query, "SELECT definition as viewdef " appendPQExpBuffer(query, "SELECT definition AS viewdef "
" from pg_views where viewname = "); "FROM pg_views WHERE viewname = ");
appendStringLiteralAH(query, tbinfo->dobj.name, fout); appendStringLiteralAH(query, tbinfo->dobj.name, fout);
appendPQExpBuffer(query, ";"); appendPQExpBuffer(query, ";");
} }
...@@ -10364,7 +10378,7 @@ dumpSequence(Archive *fout, TableInfo *tbinfo) ...@@ -10364,7 +10378,7 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
{ {
appendPQExpBuffer(query, appendPQExpBuffer(query,
"SELECT sequence_name, " "SELECT sequence_name, "
"0 as start_value, last_value, increment_by, " "0 AS start_value, last_value, increment_by, "
"CASE WHEN increment_by > 0 AND max_value = %s THEN NULL " "CASE WHEN increment_by > 0 AND max_value = %s THEN NULL "
" WHEN increment_by < 0 AND max_value = -1 THEN NULL " " WHEN increment_by < 0 AND max_value = -1 THEN NULL "
" ELSE max_value " " ELSE max_value "
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment