mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
Here is another patch that fixes a stack of pg_dump bugs:
* Fix help text ordering * Add back --set-session-authorization to pg_dumpall. Updated the docs for that. Updated help for that. * Dump ALTER USER commands for the cluster owner ("pgsql"). These are dumped AFTER the create user and create database commands in case the permissions to do these have been revoked. * Dump ALTER OWNER for public schema (because it's possible to change it). This was done by adding TOC entries for the public schema, and filtering them out at archiver time. I also save the owner in the TOC entry just for the public schema. * Suppress dumping single quotes around schema_path and DateStyle options when they are set using ALTER USER or ALTER DATABASE. Added a comment to the steps in guc.c to remind people to update that list. * Fix dumping in --clean mode against a pre-7.3 server. It just sets all drop statements to assume the public schema, allowing it to restore without error. * Cleaned up text output. eg. Don't output -- Tablespaces comment if there are none. Same for groups and users. * Make the commands to DELETE FROM pg_shadow and DELETE FROM pg_group only be output when -c mode is enabled. I'm not sure why that hasn't been done before?!?! This should be good for application asap, after which I will start on regression dumping 7.0-7.4 databases. Christopher Kings-Lynne
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
* by PostgreSQL
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.379 2004/07/13 03:00:17 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.380 2004/07/19 21:39:48 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -1492,7 +1492,7 @@ getNamespaces(int *numNamespaces)
|
||||
nsinfo[0].dobj.catId.tableoid = 0;
|
||||
nsinfo[0].dobj.catId.oid = 0;
|
||||
AssignDumpId(&nsinfo[0].dobj);
|
||||
nsinfo[0].dobj.name = strdup("");
|
||||
nsinfo[0].dobj.name = strdup("public");
|
||||
nsinfo[0].usename = strdup("");
|
||||
nsinfo[0].nspacl = strdup("");
|
||||
nsinfo[0].nsptablespace = strdup("");
|
||||
@@ -4381,11 +4381,6 @@ dumpNamespace(Archive *fout, NamespaceInfo *nspinfo)
|
||||
qnspname = strdup(fmtId(nspinfo->dobj.name));
|
||||
|
||||
/*
|
||||
* If it's the PUBLIC namespace, suppress the CREATE SCHEMA record
|
||||
* for it, since we expect PUBLIC to exist already in the
|
||||
* destination database. But do emit ACL in case it's not standard,
|
||||
* likewise comment.
|
||||
*
|
||||
* Note that ownership is shown in the AUTHORIZATION clause,
|
||||
* while the archive entry is listed with empty owner (causing
|
||||
* it to be emitted with SET SESSION AUTHORIZATION DEFAULT).
|
||||
@@ -4393,27 +4388,24 @@ dumpNamespace(Archive *fout, NamespaceInfo *nspinfo)
|
||||
* users without CREATE SCHEMA privilege. Further hacking has
|
||||
* to be applied for --no-owner mode, though!
|
||||
*/
|
||||
if (strcmp(nspinfo->dobj.name, "public") != 0)
|
||||
{
|
||||
appendPQExpBuffer(delq, "DROP SCHEMA %s;\n", qnspname);
|
||||
appendPQExpBuffer(delq, "DROP SCHEMA %s;\n", qnspname);
|
||||
|
||||
appendPQExpBuffer(q, "CREATE SCHEMA %s AUTHORIZATION %s",
|
||||
qnspname, fmtId(nspinfo->usename));
|
||||
appendPQExpBuffer(q, "CREATE SCHEMA %s AUTHORIZATION %s",
|
||||
qnspname, fmtId(nspinfo->usename));
|
||||
|
||||
/* Add tablespace qualifier, if not default */
|
||||
if (strlen(nspinfo->nsptablespace) != 0)
|
||||
appendPQExpBuffer(q, " TABLESPACE %s",
|
||||
fmtId(nspinfo->nsptablespace));
|
||||
/* Add tablespace qualifier, if not default */
|
||||
if (strlen(nspinfo->nsptablespace) != 0)
|
||||
appendPQExpBuffer(q, " TABLESPACE %s",
|
||||
fmtId(nspinfo->nsptablespace));
|
||||
|
||||
appendPQExpBuffer(q, ";\n");
|
||||
appendPQExpBuffer(q, ";\n");
|
||||
|
||||
ArchiveEntry(fout, nspinfo->dobj.catId, nspinfo->dobj.dumpId,
|
||||
nspinfo->dobj.name,
|
||||
NULL, "",
|
||||
false, "SCHEMA", q->data, delq->data, NULL,
|
||||
nspinfo->dobj.dependencies, nspinfo->dobj.nDeps,
|
||||
NULL, NULL);
|
||||
}
|
||||
ArchiveEntry(fout, nspinfo->dobj.catId, nspinfo->dobj.dumpId,
|
||||
nspinfo->dobj.name,
|
||||
NULL, strcmp(nspinfo->dobj.name, "public") == 0 ? nspinfo->usename : "",
|
||||
false, "SCHEMA", q->data, delq->data, NULL,
|
||||
nspinfo->dobj.dependencies, nspinfo->dobj.nDeps,
|
||||
NULL, NULL);
|
||||
|
||||
/* Dump Schema Comments */
|
||||
resetPQExpBuffer(q);
|
||||
|
Reference in New Issue
Block a user