Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita0db74a

Browse files
committed
This patch adds the following options to pg_dumpall, to be passed to
pg_dump:-S, --superuser=NAME-O, --no-owner-X disable-dollar-quoting, --disable-dollar-quoting-X disable-triggers, --disable-triggersChristopher Kings-Lynne
1 parent96b9dc1 commita0db74a

File tree

2 files changed

+136
-5
lines changed

2 files changed

+136
-5
lines changed

‎doc/src/sgml/ref/pg_dumpall.sgml

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/pg_dumpall.sgml,v 1.44 2004/06/07 20:35:57 momjian Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/pg_dumpall.sgml,v 1.45 2004/07/12 14:35:43 momjian Exp $
33
PostgreSQL documentation
44
-->
55

@@ -176,6 +176,25 @@ PostgreSQL documentation
176176
</listitem>
177177
</varlistentry>
178178

179+
<varlistentry>
180+
<term><option>-O</></term>
181+
<term><option>--no-owner</option></term>
182+
<listitem>
183+
<para>
184+
Do not output commands to set
185+
ownership of objects to match the original database.
186+
By default, <application>pg_dumpall</application> issues
187+
<command>SET SESSION AUTHORIZATION</command>
188+
statements to set ownership of created schema elements.
189+
These statements
190+
will fail when the script is run unless it is started by a superuser
191+
(or the same user that owns all of the objects in the script).
192+
To make a script that can be restored by any user, but will give
193+
that user ownership of all the objects, specify <option>-O</>.
194+
</para>
195+
</listitem>
196+
</varlistentry>
197+
179198
<varlistentry>
180199
<term><option>-s</option></term>
181200
<term><option>--schema-only</option></term>
@@ -186,6 +205,19 @@ PostgreSQL documentation
186205
</listitem>
187206
</varlistentry>
188207

208+
<varlistentry>
209+
<term><option>-S <replaceable class="parameter">username</replaceable></option></term>
210+
<term><option>--superuser=<replaceable class="parameter">username</replaceable></option></term>
211+
<listitem>
212+
<para>
213+
Specify the superuser user name to use when disabling triggers.
214+
This is only relevant if <option>--disable-triggers</> is used.
215+
(Usually, it's better to leave this out, and instead start the
216+
resulting script as superuser.)
217+
</para>
218+
</listitem>
219+
</varlistentry>
220+
189221
<varlistentry>
190222
<term><option>-v</></term>
191223
<term><option>--verbose</></term>
@@ -209,6 +241,50 @@ PostgreSQL documentation
209241
</para>
210242
</listitem>
211243
</varlistentry>
244+
245+
<varlistentry>
246+
<term><option>-X disable-dollar-quoting</></term>
247+
<term><option>--disable-dollar-quoting</></term>
248+
<listitem>
249+
<para>
250+
This option disables the use of dollar quoting for function bodies,
251+
and forces them to be quoted using SQL standard string syntax.
252+
</para>
253+
</listitem>
254+
</varlistentry>
255+
256+
<varlistentry>
257+
<term><option>-X disable-triggers</></term>
258+
<term><option>--disable-triggers</></term>
259+
<listitem>
260+
<para>
261+
This option is only relevant when creating a data-only dump.
262+
It instructs <application>pg_dumpall</application> to include commands
263+
to temporarily disable triggers on the target tables while
264+
the data is reloaded. Use this if you have referential
265+
integrity checks or other triggers on the tables that you
266+
do not want to invoke during data reload.
267+
</para>
268+
269+
<para>
270+
Presently, the commands emitted for <option>--disable-triggers</>
271+
must be done as superuser. So, you should also specify
272+
a superuser name with <option>-S</>, or preferably be careful to
273+
start the resulting script as a superuser.
274+
</para>
275+
</listitem>
276+
</varlistentry>
277+
278+
<varlistentry>
279+
<term><option>-X use-set-session-authorization</></term>
280+
<term><option>--use-set-session-authorization</></term>
281+
<listitem>
282+
<para>
283+
This option is obsolete but still accepted for backwards
284+
compatibility with <application>pg_dump</application>.
285+
</para>
286+
</listitem>
287+
</varlistentry>
212288
</variablelist>
213289
</para>
214290

‎src/bin/pg_dump/pg_dumpall.c

Lines changed: 59 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1994, Regents of the University of California
77
*
88
*
9-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.43 2004/06/21 13:36:42 tgl Exp $
9+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.44 2004/07/12 14:35:45 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -59,15 +59,17 @@ static PGconn *connectDatabase(const char *dbname, const char *pghost, const cha
5959
constchar*pguser,boolrequire_password);
6060
staticPGresult*executeQuery(PGconn*conn,constchar*query);
6161

62-
6362
charpg_dump_bin[MAXPGPATH];
6463
PQExpBufferpgdumpopts;
6564
booloutput_clean= false;
6665
boolskip_acls= false;
6766
boolverbose= false;
6867
intserver_version;
6968

70-
69+
/* flags for -X long options */
70+
intdisable_dollar_quoting=0;
71+
intdisable_triggers=0;
72+
intuse_setsessauth=0;
7173

7274
int
7375
main(intargc,char*argv[])
@@ -92,13 +94,24 @@ main(int argc, char *argv[])
9294
{"host",required_argument,NULL,'h'},
9395
{"ignore-version",no_argument,NULL,'i'},
9496
{"oids",no_argument,NULL,'o'},
97+
{"no-owner",no_argument,NULL,'O'},
9598
{"port",required_argument,NULL,'p'},
9699
{"password",no_argument,NULL,'W'},
97100
{"schema-only",no_argument,NULL,'s'},
101+
{"superuser",required_argument,NULL,'S'},
98102
{"username",required_argument,NULL,'U'},
99103
{"verbose",no_argument,NULL,'v'},
100104
{"no-privileges",no_argument,NULL,'x'},
101105
{"no-acl",no_argument,NULL,'x'},
106+
107+
/*
108+
* the following options don't have an equivalent short option
109+
* letter, but are available as '-X long-name'
110+
*/
111+
{"disable-dollar-quoting",no_argument,&disable_dollar_quoting,1},
112+
{"disable-triggers",no_argument,&disable_triggers,1},
113+
{"use-set-session-authorization",no_argument,&use_setsessauth,1},
114+
102115
{NULL,0,NULL,0}
103116
};
104117

@@ -142,7 +155,7 @@ main(int argc, char *argv[])
142155

143156
pgdumpopts=createPQExpBuffer();
144157

145-
while ((c=getopt_long(argc,argv,"acdDgh:iop:sU:vWx",long_options,&optindex))!=-1)
158+
while ((c=getopt_long(argc,argv,"acdDgh:ioOp:sS:U:vWxX:",long_options,&optindex))!=-1)
146159
{
147160
switch (c)
148161
{
@@ -174,6 +187,10 @@ main(int argc, char *argv[])
174187
appendPQExpBuffer(pgdumpopts," -%c",c);
175188
break;
176189

190+
case'O':
191+
appendPQExpBuffer(pgdumpopts," -O");
192+
break;
193+
177194
case'p':
178195
pgport=optarg;
179196
appendPQExpBuffer(pgdumpopts," -p '%s'",pgport);
@@ -184,6 +201,10 @@ main(int argc, char *argv[])
184201
appendPQExpBuffer(pgdumpopts," -s");
185202
break;
186203

204+
case'S':
205+
appendPQExpBuffer(pgdumpopts," -S '%s'",optarg);
206+
break;
207+
187208
case'U':
188209
pguser=optarg;
189210
appendPQExpBuffer(pgdumpopts," -U '%s'",pguser);
@@ -204,12 +225,40 @@ main(int argc, char *argv[])
204225
appendPQExpBuffer(pgdumpopts," -x");
205226
break;
206227

228+
case'X':
229+
if (strcmp(optarg,"disable-dollar-quoting")==0)
230+
appendPQExpBuffer(pgdumpopts," -X disable-dollar-quoting");
231+
elseif (strcmp(optarg,"disable-triggers")==0)
232+
appendPQExpBuffer(pgdumpopts," -X disable-triggers");
233+
elseif (strcmp(optarg,"use-set-session-authorization")==0)
234+
/* no-op, still allowed for compatibility */ ;
235+
else
236+
{
237+
fprintf(stderr,
238+
_("%s: invalid -X option -- %s\n"),
239+
progname,optarg);
240+
fprintf(stderr,_("Try \"%s --help\" for more information.\n"),progname);
241+
exit(1);
242+
}
243+
break;
244+
245+
case0:
246+
break;
247+
207248
default:
208249
fprintf(stderr,_("Try \"%s --help\" for more information.\n"),progname);
209250
exit(1);
210251
}
211252
}
212253

254+
/* Add long options to the pg_dump argument list */
255+
if (disable_dollar_quoting)
256+
appendPQExpBuffer(pgdumpopts," -X disable-dollar-quoting");
257+
if (disable_triggers)
258+
appendPQExpBuffer(pgdumpopts," -X disable-triggers");
259+
if (use_setsessauth)
260+
/* no-op, still allowed for compatibility */ ;
261+
213262
if (optind<argc)
214263
{
215264
fprintf(stderr,_("%s: too many command-line arguments (first is \"%s\")\n"),
@@ -270,9 +319,15 @@ help(void)
270319
printf(_(" -i, --ignore-version proceed even when server version mismatches\n"
271320
" pg_dumpall version\n"));
272321
printf(_(" -s, --schema-only dump only the schema, no data\n"));
322+
printf(_(" -S, --superuser=NAME specify the superuser user name to use in the dump\n"));
273323
printf(_(" -o, --oids include OIDs in dump\n"));
324+
printf(_(" -O, --no-owner do not output commands to set object ownership\n"));
274325
printf(_(" -v, --verbose verbose mode\n"));
275326
printf(_(" -x, --no-privileges do not dump privileges (grant/revoke)\n"));
327+
printf(_(" -X disable-dollar-quoting, --disable-dollar-quoting\n"
328+
" disable dollar quoting, use SQL standard quoting\n"));
329+
printf(_(" -X disable-triggers, --disable-triggers\n"
330+
" disable triggers during data-only restore\n"));
276331
printf(_(" --help show this help, then exit\n"));
277332
printf(_(" --version output version information, then exit\n"));
278333

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp