6
6
* Portions Copyright (c) 1994, Regents of the University of California
7
7
*
8
8
*
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 $
10
10
*
11
11
*-------------------------------------------------------------------------
12
12
*/
@@ -59,15 +59,17 @@ static PGconn *connectDatabase(const char *dbname, const char *pghost, const cha
59
59
const char * pguser ,bool require_password );
60
60
static PGresult * executeQuery (PGconn * conn ,const char * query );
61
61
62
-
63
62
char pg_dump_bin [MAXPGPATH ];
64
63
PQExpBuffer pgdumpopts ;
65
64
bool output_clean = false;
66
65
bool skip_acls = false;
67
66
bool verbose = false;
68
67
int server_version ;
69
68
70
-
69
+ /* flags for -X long options */
70
+ int disable_dollar_quoting = 0 ;
71
+ int disable_triggers = 0 ;
72
+ int use_setsessauth = 0 ;
71
73
72
74
int
73
75
main (int argc ,char * argv [])
@@ -92,13 +94,24 @@ main(int argc, char *argv[])
92
94
{"host" ,required_argument ,NULL ,'h' },
93
95
{"ignore-version" ,no_argument ,NULL ,'i' },
94
96
{"oids" ,no_argument ,NULL ,'o' },
97
+ {"no-owner" ,no_argument ,NULL ,'O' },
95
98
{"port" ,required_argument ,NULL ,'p' },
96
99
{"password" ,no_argument ,NULL ,'W' },
97
100
{"schema-only" ,no_argument ,NULL ,'s' },
101
+ {"superuser" ,required_argument ,NULL ,'S' },
98
102
{"username" ,required_argument ,NULL ,'U' },
99
103
{"verbose" ,no_argument ,NULL ,'v' },
100
104
{"no-privileges" ,no_argument ,NULL ,'x' },
101
105
{"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
+
102
115
{NULL ,0 ,NULL ,0 }
103
116
};
104
117
@@ -142,7 +155,7 @@ main(int argc, char *argv[])
142
155
143
156
pgdumpopts = createPQExpBuffer ();
144
157
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 )
146
159
{
147
160
switch (c )
148
161
{
@@ -174,6 +187,10 @@ main(int argc, char *argv[])
174
187
appendPQExpBuffer (pgdumpopts ," -%c" ,c );
175
188
break ;
176
189
190
+ case 'O' :
191
+ appendPQExpBuffer (pgdumpopts ," -O" );
192
+ break ;
193
+
177
194
case 'p' :
178
195
pgport = optarg ;
179
196
appendPQExpBuffer (pgdumpopts ," -p '%s'" ,pgport );
@@ -184,6 +201,10 @@ main(int argc, char *argv[])
184
201
appendPQExpBuffer (pgdumpopts ," -s" );
185
202
break ;
186
203
204
+ case 'S' :
205
+ appendPQExpBuffer (pgdumpopts ," -S '%s'" ,optarg );
206
+ break ;
207
+
187
208
case 'U' :
188
209
pguser = optarg ;
189
210
appendPQExpBuffer (pgdumpopts ," -U '%s'" ,pguser );
@@ -204,12 +225,40 @@ main(int argc, char *argv[])
204
225
appendPQExpBuffer (pgdumpopts ," -x" );
205
226
break ;
206
227
228
+ case 'X' :
229
+ if (strcmp (optarg ,"disable-dollar-quoting" )== 0 )
230
+ appendPQExpBuffer (pgdumpopts ," -X disable-dollar-quoting" );
231
+ else if (strcmp (optarg ,"disable-triggers" )== 0 )
232
+ appendPQExpBuffer (pgdumpopts ," -X disable-triggers" );
233
+ else if (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
+ case 0 :
246
+ break ;
247
+
207
248
default :
208
249
fprintf (stderr ,_ ("Try \"%s --help\" for more information.\n" ),progname );
209
250
exit (1 );
210
251
}
211
252
}
212
253
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
+
213
262
if (optind < argc )
214
263
{
215
264
fprintf (stderr ,_ ("%s: too many command-line arguments (first is \"%s\")\n" ),
@@ -270,9 +319,15 @@ help(void)
270
319
printf (_ (" -i, --ignore-version proceed even when server version mismatches\n"
271
320
" pg_dumpall version\n" ));
272
321
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" ));
273
323
printf (_ (" -o, --oids include OIDs in dump\n" ));
324
+ printf (_ (" -O, --no-owner do not output commands to set object ownership\n" ));
274
325
printf (_ (" -v, --verbose verbose mode\n" ));
275
326
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" ));
276
331
printf (_ (" --help show this help, then exit\n" ));
277
332
printf (_ (" --version output version information, then exit\n" ));
278
333