diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 51b6d3ae77ed6dcfe8effd3e89e8d6b9d79e3351..87dadbf08a596e445cf7464ab31621d3c7bba2d7 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -3513,7 +3513,7 @@ getTypes(Archive *fout, int *numTypes) else if (fout->remoteVersion >= 80300) { appendPQExpBuffer(query, "SELECT tableoid, oid, typname, " - "typnamespace, '{=U}' AS typacl, " + "typnamespace, NULL AS typacl, " "(%s typowner) AS rolname, " "typinput::oid AS typinput, " "typoutput::oid AS typoutput, typelem, typrelid, " @@ -3528,7 +3528,7 @@ getTypes(Archive *fout, int *numTypes) else if (fout->remoteVersion >= 70300) { appendPQExpBuffer(query, "SELECT tableoid, oid, typname, " - "typnamespace, '{=U}' AS typacl, " + "typnamespace, NULL AS typacl, " "(%s typowner) AS rolname, " "typinput::oid AS typinput, " "typoutput::oid AS typoutput, typelem, typrelid, " @@ -3542,7 +3542,7 @@ getTypes(Archive *fout, int *numTypes) else if (fout->remoteVersion >= 70100) { appendPQExpBuffer(query, "SELECT tableoid, oid, typname, " - "0::oid AS typnamespace, '{=U}' AS typacl, " + "0::oid AS typnamespace, NULL AS typacl, " "(%s typowner) AS rolname, " "typinput::oid AS typinput, " "typoutput::oid AS typoutput, typelem, typrelid, " @@ -3558,7 +3558,7 @@ getTypes(Archive *fout, int *numTypes) appendPQExpBuffer(query, "SELECT " "(SELECT oid FROM pg_class WHERE relname = 'pg_type') AS tableoid, " "oid, typname, " - "0::oid AS typnamespace, '{=U}' AS typacl, " + "0::oid AS typnamespace, NULL AS typacl, " "(%s typowner) AS rolname, " "typinput::oid AS typinput, " "typoutput::oid AS typoutput, typelem, typrelid, " @@ -4249,7 +4249,7 @@ getAggregates(Archive *fout, DumpOptions *dopt, int *numAggs) "CASE WHEN aggbasetype = 0 THEN 0 ELSE 1 END AS pronargs, " "aggbasetype AS proargtypes, " "(%s aggowner) AS rolname, " - "'{=X}' AS aggacl " + "NULL AS aggacl " "FROM pg_aggregate " "where oid > '%u'::oid", username_subquery, @@ -4264,7 +4264,7 @@ getAggregates(Archive *fout, DumpOptions *dopt, int *numAggs) "CASE WHEN aggbasetype = 0 THEN 0 ELSE 1 END AS pronargs, " "aggbasetype AS proargtypes, " "(%s aggowner) AS rolname, " - "'{=X}' AS aggacl " + "NULL AS aggacl " "FROM pg_aggregate " "where oid > '%u'::oid", username_subquery, @@ -4408,7 +4408,7 @@ getFuncs(Archive *fout, DumpOptions *dopt, int *numFuncs) appendPQExpBuffer(query, "SELECT tableoid, oid, proname, prolang, " "pronargs, proargtypes, prorettype, " - "'{=X}' AS proacl, " + "NULL AS proacl, " "0::oid AS pronamespace, " "(%s proowner) AS rolname " "FROM pg_proc " @@ -4424,7 +4424,7 @@ getFuncs(Archive *fout, DumpOptions *dopt, int *numFuncs) " WHERE relname = 'pg_proc') AS tableoid, " "oid, proname, prolang, " "pronargs, proargtypes, prorettype, " - "'{=X}' AS proacl, " + "NULL AS proacl, " "0::oid AS pronamespace, " "(%s proowner) AS rolname " "FROM pg_proc " @@ -6317,7 +6317,7 @@ getProcLangs(Archive *fout, int *numProcLangs) /* pg_language has a laninline column */ appendPQExpBuffer(query, "SELECT tableoid, oid, " "lanname, lanpltrusted, lanplcallfoid, " - "laninline, lanvalidator, lanacl, " + "laninline, lanvalidator, lanacl, " "(%s lanowner) AS lanowner " "FROM pg_language " "WHERE lanispl " @@ -6329,7 +6329,7 @@ getProcLangs(Archive *fout, int *numProcLangs) /* pg_language has a lanowner column */ appendPQExpBuffer(query, "SELECT tableoid, oid, " "lanname, lanpltrusted, lanplcallfoid, " - "lanvalidator, lanacl, " + "0 AS laninline, lanvalidator, lanacl, " "(%s lanowner) AS lanowner " "FROM pg_language " "WHERE lanispl " @@ -6339,7 +6339,9 @@ getProcLangs(Archive *fout, int *numProcLangs) else if (fout->remoteVersion >= 80100) { /* Languages are owned by the bootstrap superuser, OID 10 */ - appendPQExpBuffer(query, "SELECT tableoid, oid, *, " + appendPQExpBuffer(query, "SELECT tableoid, oid, " + "lanname, lanpltrusted, lanplcallfoid, " + "0 AS laninline, lanvalidator, lanacl, " "(%s '10') AS lanowner " "FROM pg_language " "WHERE lanispl " @@ -6349,27 +6351,47 @@ getProcLangs(Archive *fout, int *numProcLangs) else if (fout->remoteVersion >= 70400) { /* Languages are owned by the bootstrap superuser, sysid 1 */ - appendPQExpBuffer(query, "SELECT tableoid, oid, *, " + appendPQExpBuffer(query, "SELECT tableoid, oid, " + "lanname, lanpltrusted, lanplcallfoid, " + "0 AS laninline, lanvalidator, lanacl, " "(%s '1') AS lanowner " "FROM pg_language " "WHERE lanispl " "ORDER BY oid", username_subquery); } - else if (fout->remoteVersion >= 70100) + else if (fout->remoteVersion >= 70300) { /* No clear notion of an owner at all before 7.4 ... */ - appendPQExpBufferStr(query, "SELECT tableoid, oid, * FROM pg_language " - "WHERE lanispl " - "ORDER BY oid"); + appendPQExpBuffer(query, "SELECT tableoid, oid, " + "lanname, lanpltrusted, lanplcallfoid, " + "0 AS laninline, lanvalidator, lanacl, " + "NULL AS lanowner " + "FROM pg_language " + "WHERE lanispl " + "ORDER BY oid"); + } + else if (fout->remoteVersion >= 70100) + { + appendPQExpBuffer(query, "SELECT tableoid, oid, " + "lanname, lanpltrusted, lanplcallfoid, " + "0 AS laninline, 0 AS lanvalidator, NULL AS lanacl, " + "NULL AS lanowner " + "FROM pg_language " + "WHERE lanispl " + "ORDER BY oid"); } else { - appendPQExpBufferStr(query, "SELECT " - "(SELECT oid FROM pg_class WHERE relname = 'pg_language') AS tableoid, " - "oid, * FROM pg_language " - "WHERE lanispl " - "ORDER BY oid"); + appendPQExpBuffer(query, "SELECT " + "(SELECT oid FROM pg_class WHERE relname = 'pg_language') AS tableoid, " + "oid, " + "lanname, lanpltrusted, lanplcallfoid, " + "0 AS laninline, 0 AS lanvalidator, NULL AS lanacl, " + "NULL AS lanowner " + "FROM pg_language " + "WHERE lanispl " + "ORDER BY oid"); } res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK); @@ -6385,7 +6407,6 @@ getProcLangs(Archive *fout, int *numProcLangs) i_lanname = PQfnumber(res, "lanname"); i_lanpltrusted = PQfnumber(res, "lanpltrusted"); i_lanplcallfoid = PQfnumber(res, "lanplcallfoid"); - /* these may fail and return -1: */ i_laninline = PQfnumber(res, "laninline"); i_lanvalidator = PQfnumber(res, "lanvalidator"); i_lanacl = PQfnumber(res, "lanacl"); @@ -6401,22 +6422,10 @@ getProcLangs(Archive *fout, int *numProcLangs) planginfo[i].dobj.name = pg_strdup(PQgetvalue(res, i, i_lanname)); planginfo[i].lanpltrusted = *(PQgetvalue(res, i, i_lanpltrusted)) == 't'; planginfo[i].lanplcallfoid = atooid(PQgetvalue(res, i, i_lanplcallfoid)); - if (i_laninline >= 0) - planginfo[i].laninline = atooid(PQgetvalue(res, i, i_laninline)); - else - planginfo[i].laninline = InvalidOid; - if (i_lanvalidator >= 0) - planginfo[i].lanvalidator = atooid(PQgetvalue(res, i, i_lanvalidator)); - else - planginfo[i].lanvalidator = InvalidOid; - if (i_lanacl >= 0) - planginfo[i].lanacl = pg_strdup(PQgetvalue(res, i, i_lanacl)); - else - planginfo[i].lanacl = pg_strdup("{=U}"); - if (i_lanowner >= 0) - planginfo[i].lanowner = pg_strdup(PQgetvalue(res, i, i_lanowner)); - else - planginfo[i].lanowner = pg_strdup(""); + planginfo[i].laninline = atooid(PQgetvalue(res, i, i_laninline)); + planginfo[i].lanvalidator = atooid(PQgetvalue(res, i, i_lanvalidator)); + planginfo[i].lanacl = pg_strdup(PQgetvalue(res, i, i_lanacl)); + planginfo[i].lanowner = pg_strdup(PQgetvalue(res, i, i_lanowner)); if (fout->remoteVersion < 70300) {