Commit dc0e76ca authored by Bruce Momjian's avatar Bruce Momjian

Change pg_dump to use ALTER OWNER commands instead of SET SESSION

AUTHORIZATION commands by default.  Move all GRANT and REVOKE commands
to the end of the dump to avoid restore failures in several situations.
Bring back --use-set-session-authorization option to get previous SET
behaviour

Christopher Kings-Lyne
parent e419c84c
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/ref/pg_dump.sgml,v 1.72 2004/07/10 15:51:28 momjian Exp $ $PostgreSQL: pgsql/doc/src/sgml/ref/pg_dump.sgml,v 1.73 2004/07/13 02:59:49 momjian Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
...@@ -464,10 +464,10 @@ PostgreSQL documentation ...@@ -464,10 +464,10 @@ PostgreSQL documentation
<term><option>--use-set-session-authorization</></term> <term><option>--use-set-session-authorization</></term>
<listitem> <listitem>
<para> <para>
This option is obsolete but still accepted for backwards Output SQL standard SET SESSION AUTHORIZATION commands instead
compatibility. of OWNER TO commands. This makes the dump more standards compatible,
<application>pg_dump</application> now always behaves in the but depending on the history of the objects in the dump, may not
way formerly selected by this option. restore properly.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/ref/pg_restore.sgml,v 1.46 2004/02/17 09:07:16 neilc Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/ref/pg_restore.sgml,v 1.47 2004/07/13 02:59:49 momjian Exp $ -->
<refentry id="APP-PGRESTORE"> <refentry id="APP-PGRESTORE">
<refmeta> <refmeta>
...@@ -337,10 +337,10 @@ ...@@ -337,10 +337,10 @@
<term><option>--use-set-session-authorization</option></term> <term><option>--use-set-session-authorization</option></term>
<listitem> <listitem>
<para> <para>
This option is obsolete but still accepted for backwards Output SQL standard SET SESSION AUTHORIZATION commands instead
compatibility. of OWNER TO commands. This makes the dump more standards compatible,
<application>pg_restore</application> now always behaves in the but depending on the history of the objects in the dump, may not
way formerly selected by this option. restore properly.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup.h,v 1.30 2004/04/22 02:39:09 momjian Exp $ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup.h,v 1.31 2004/07/13 03:00:17 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -73,6 +73,7 @@ typedef struct _restoreOptions ...@@ -73,6 +73,7 @@ typedef struct _restoreOptions
int noOwner; /* Don't try to match original object owner */ int noOwner; /* Don't try to match original object owner */
int disable_triggers; /* disable triggers during int disable_triggers; /* disable triggers during
* data-only restore */ * data-only restore */
int use_setsessauth; /* Use SET SESSION AUTHORIZATION commands instead of OWNER TO */
char *superuser; /* Username to use as superuser */ char *superuser; /* Username to use as superuser */
int dataOnly; int dataOnly;
int dropSchema; int dropSchema;
......
This diff is collapsed.
...@@ -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.378 2004/07/12 05:37:53 tgl Exp $ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.379 2004/07/13 03:00:17 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -392,7 +392,7 @@ main(int argc, char **argv) ...@@ -392,7 +392,7 @@ main(int argc, char **argv)
else if (strcmp(optarg, "disable-triggers") == 0) else if (strcmp(optarg, "disable-triggers") == 0)
disable_triggers = 1; disable_triggers = 1;
else if (strcmp(optarg, "use-set-session-authorization") == 0) else if (strcmp(optarg, "use-set-session-authorization") == 0)
/* no-op, still allowed for compatibility */ ; use_setsessauth = 1;
else else
{ {
fprintf(stderr, fprintf(stderr,
...@@ -636,6 +636,7 @@ main(int argc, char **argv) ...@@ -636,6 +636,7 @@ main(int argc, char **argv)
ropt->create = outputCreate; ropt->create = outputCreate;
ropt->noOwner = outputNoOwner; ropt->noOwner = outputNoOwner;
ropt->disable_triggers = disable_triggers; ropt->disable_triggers = disable_triggers;
ropt->use_setsessauth = use_setsessauth;
if (compressLevel == -1) if (compressLevel == -1)
ropt->compression = 0; ropt->compression = 0;
...@@ -693,6 +694,9 @@ help(const char *progname) ...@@ -693,6 +694,9 @@ help(const char *progname)
" disable dollar quoting, use SQL standard quoting\n")); " disable dollar quoting, use SQL standard quoting\n"));
printf(_(" -X disable-triggers, --disable-triggers\n" printf(_(" -X disable-triggers, --disable-triggers\n"
" disable triggers during data-only restore\n")); " disable triggers during data-only restore\n"));
printf(_(" -X use-set-session-authorization, --use-set-session-authorization\n"
" use SESSION AUTHORIZATION commands instead of\n"
" OWNER TO commands\n"));
printf(_("\nConnection options:\n")); printf(_("\nConnection options:\n"));
printf(_(" -h, --host=HOSTNAME database server host or socket directory\n")); printf(_(" -h, --host=HOSTNAME database server host or socket directory\n"));
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_restore.c,v 1.58 2004/06/03 00:07:37 momjian Exp $ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_restore.c,v 1.59 2004/07/13 03:00:17 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -243,7 +243,7 @@ main(int argc, char **argv) ...@@ -243,7 +243,7 @@ main(int argc, char **argv)
case 'X': case 'X':
if (strcmp(optarg, "use-set-session-authorization") == 0) if (strcmp(optarg, "use-set-session-authorization") == 0)
/* no-op, still allowed for compatibility */ ; use_setsessauth = 1;
else if (strcmp(optarg, "disable-triggers") == 0) else if (strcmp(optarg, "disable-triggers") == 0)
disable_triggers = 1; disable_triggers = 1;
else else
...@@ -286,6 +286,7 @@ main(int argc, char **argv) ...@@ -286,6 +286,7 @@ main(int argc, char **argv)
} }
opts->disable_triggers = disable_triggers; opts->disable_triggers = disable_triggers;
opts->use_setsessauth = use_setsessauth;
if (opts->formatName) if (opts->formatName)
{ {
...@@ -381,6 +382,9 @@ usage(const char *progname) ...@@ -381,6 +382,9 @@ usage(const char *progname)
printf(_(" -x, --no-privileges skip restoration of access privileges (grant/revoke)\n")); printf(_(" -x, --no-privileges skip restoration of access privileges (grant/revoke)\n"));
printf(_(" -X disable-triggers, --disable-triggers\n" printf(_(" -X disable-triggers, --disable-triggers\n"
" disable triggers during data-only restore\n")); " disable triggers during data-only restore\n"));
printf(_(" -X use-set-session-authorization, --use-set-session-authorization\n"
" use SESSION AUTHORIZATION commands instead of\n"
" OWNER TO commands\n"));
printf(_("\nConnection options:\n")); printf(_("\nConnection options:\n"));
printf(_(" -h, --host=HOSTNAME database server host or socket directory\n")); printf(_(" -h, --host=HOSTNAME database server host or socket directory\n"));
......
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