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
5959const char * pguser ,bool require_password );
6060static PGresult * executeQuery (PGconn * conn ,const char * query );
6161
62-
6362char pg_dump_bin [MAXPGPATH ];
6463PQExpBuffer pgdumpopts ;
6564bool output_clean = false;
6665bool skip_acls = false;
6766bool verbose = false;
6867int server_version ;
6968
70-
69+ /* flags for -X long options */
70+ int disable_dollar_quoting = 0 ;
71+ int disable_triggers = 0 ;
72+ int use_setsessauth = 0 ;
7173
7274int
7375main (int argc ,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
143156pgdumpopts = 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{
147160switch (c )
148161{
@@ -174,6 +187,10 @@ main(int argc, char *argv[])
174187appendPQExpBuffer (pgdumpopts ," -%c" ,c );
175188break ;
176189
190+ case 'O' :
191+ appendPQExpBuffer (pgdumpopts ," -O" );
192+ break ;
193+
177194case 'p' :
178195pgport = optarg ;
179196appendPQExpBuffer (pgdumpopts ," -p '%s'" ,pgport );
@@ -184,6 +201,10 @@ main(int argc, char *argv[])
184201appendPQExpBuffer (pgdumpopts ," -s" );
185202break ;
186203
204+ case 'S' :
205+ appendPQExpBuffer (pgdumpopts ," -S '%s'" ,optarg );
206+ break ;
207+
187208case 'U' :
188209pguser = optarg ;
189210appendPQExpBuffer (pgdumpopts ," -U '%s'" ,pguser );
@@ -204,12 +225,40 @@ main(int argc, char *argv[])
204225appendPQExpBuffer (pgdumpopts ," -x" );
205226break ;
206227
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+
207248default :
208249fprintf (stderr ,_ ("Try \"%s --help\" for more information.\n" ),progname );
209250exit (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+
213262if (optind < argc )
214263{
215264fprintf (stderr ,_ ("%s: too many command-line arguments (first is \"%s\")\n" ),
@@ -270,9 +319,15 @@ help(void)
270319printf (_ (" -i, --ignore-version proceed even when server version mismatches\n"
271320" pg_dumpall version\n" ));
272321printf (_ (" -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" ));
273323printf (_ (" -o, --oids include OIDs in dump\n" ));
324+ printf (_ (" -O, --no-owner do not output commands to set object ownership\n" ));
274325printf (_ (" -v, --verbose verbose mode\n" ));
275326printf (_ (" -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" ));
276331printf (_ (" --help show this help, then exit\n" ));
277332printf (_ (" --version output version information, then exit\n" ));
278333