diff options
Diffstat (limited to 'src/bin/pg_dump/pg_dumpall.c')
-rw-r--r-- | src/bin/pg_dump/pg_dumpall.c | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c index 003a6704c65..9436b87ec7d 100644 --- a/src/bin/pg_dump/pg_dumpall.c +++ b/src/bin/pg_dump/pg_dumpall.c @@ -52,9 +52,10 @@ static void dumpDatabases(PGconn *conn); static void dumpTimestamp(const char *msg); static int runPgDump(const char *dbname); -static void buildShSecLabels(PGconn *conn, const char *catalog_name, - uint32 objectId, PQExpBuffer buffer, - const char *target, const char *objname); +static void buildShSecLabels(PGconn *conn, + const char *catalog_name, Oid objectId, + const char *objtype, const char *objname, + PQExpBuffer buffer); static PGconn *connectDatabase(const char *dbname, const char *connstr, const char *pghost, const char *pgport, const char *pguser, trivalue prompt_password, bool fail_on_error); static char *constructConnStr(const char **keywords, const char **values); @@ -877,7 +878,8 @@ dumpRoles(PGconn *conn) if (!no_security_labels && server_version >= 90200) buildShSecLabels(conn, "pg_authid", auth_oid, - buf, "ROLE", rolename); + "ROLE", rolename, + buf); fprintf(OPF, "%s", buf->data); } @@ -1138,7 +1140,7 @@ dumpTablespaces(PGconn *conn) for (i = 0; i < PQntuples(res); i++) { PQExpBuffer buf = createPQExpBuffer(); - uint32 spcoid = atooid(PQgetvalue(res, i, 0)); + Oid spcoid = atooid(PQgetvalue(res, i, 0)); char *spcname = PQgetvalue(res, i, 1); char *spcowner = PQgetvalue(res, i, 2); char *spclocation = PQgetvalue(res, i, 3); @@ -1163,11 +1165,12 @@ dumpTablespaces(PGconn *conn) fspcname, spcoptions); if (!skip_acls && - !buildACLCommands(fspcname, NULL, "TABLESPACE", spcacl, rspcacl, + !buildACLCommands(fspcname, NULL, NULL, "TABLESPACE", + spcacl, rspcacl, spcowner, "", server_version, buf)) { fprintf(stderr, _("%s: could not parse ACL list (%s) for tablespace \"%s\"\n"), - progname, spcacl, fspcname); + progname, spcacl, spcname); PQfinish(conn); exit_nicely(1); } @@ -1181,7 +1184,8 @@ dumpTablespaces(PGconn *conn) if (!no_security_labels && server_version >= 90200) buildShSecLabels(conn, "pg_tablespace", spcoid, - buf, "TABLESPACE", fspcname); + "TABLESPACE", spcname, + buf); fprintf(OPF, "%s", buf->data); @@ -1530,7 +1534,7 @@ dumpCreateDB(PGconn *conn) } if (!skip_acls && - !buildACLCommands(fdbname, NULL, "DATABASE", + !buildACLCommands(fdbname, NULL, NULL, "DATABASE", dbacl, rdbacl, dbowner, "", server_version, buf)) { @@ -1848,19 +1852,23 @@ runPgDump(const char *dbname) * * Build SECURITY LABEL command(s) for a shared object * - * The caller has to provide object type and identifier to select security - * labels from pg_seclabels system view. + * The caller has to provide object type and identity in two separate formats: + * catalog_name (e.g., "pg_database") and object OID, as well as + * type name (e.g., "DATABASE") and object name (not pre-quoted). + * + * The command(s) are appended to "buffer". */ static void -buildShSecLabels(PGconn *conn, const char *catalog_name, uint32 objectId, - PQExpBuffer buffer, const char *target, const char *objname) +buildShSecLabels(PGconn *conn, const char *catalog_name, Oid objectId, + const char *objtype, const char *objname, + PQExpBuffer buffer) { PQExpBuffer sql = createPQExpBuffer(); PGresult *res; buildShSecLabelQuery(conn, catalog_name, objectId, sql); res = executeQuery(conn, sql->data); - emitShSecLabels(conn, res, buffer, target, objname); + emitShSecLabels(conn, res, buffer, objtype, objname); PQclear(res); destroyPQExpBuffer(sql); |