6
6
* Portions Copyright (c) 1994, Regents of the University of California
7
7
*
8
8
*
9
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.19 2003/05/30 22 :55:16 tgl Exp $
9
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.20 2003/05/30 23 :55:10 tgl Exp $
10
10
*
11
11
*-------------------------------------------------------------------------
12
12
*/
@@ -60,6 +60,7 @@ static char *findPgDump(const char *argv0);
60
60
char * pgdumploc ;
61
61
PQExpBuffer pgdumpopts ;
62
62
bool output_clean = false;
63
+ bool skip_acls = false;
63
64
bool verbose = false;
64
65
int server_version ;
65
66
@@ -72,11 +73,14 @@ main(int argc, char *argv[])
72
73
char * pgport = NULL ;
73
74
char * pguser = NULL ;
74
75
bool force_password = false;
76
+ bool data_only = false;
75
77
bool globals_only = false;
78
+ bool schema_only = false;
76
79
PGconn * conn ;
77
80
int c ;
78
81
79
82
static struct option long_options [] = {
83
+ {"data-only" , no_argument , NULL , 'a' },
80
84
{"clean" , no_argument , NULL , 'c' },
81
85
{"inserts" , no_argument , NULL , 'd' },
82
86
{"attribute-inserts" , no_argument , NULL , 'D' },
@@ -87,8 +91,11 @@ main(int argc, char *argv[])
87
91
{"oids" , no_argument , NULL , 'o' },
88
92
{"port" , required_argument , NULL , 'p' },
89
93
{"password" , no_argument , NULL , 'W' },
94
+ {"schema-only" , no_argument , NULL , 's' },
90
95
{"username" , required_argument , NULL , 'U' },
91
96
{"verbose" , no_argument , NULL , 'v' },
97
+ {"no-privileges" , no_argument , NULL , 'x' },
98
+ {"no-acl" , no_argument , NULL , 'x' },
92
99
{NULL , 0 , NULL , 0 }
93
100
};
94
101
@@ -119,10 +126,15 @@ main(int argc, char *argv[])
119
126
pgdumploc = findPgDump (argv [0 ]);
120
127
pgdumpopts = createPQExpBuffer ();
121
128
122
- while ((c = getopt_long (argc , argv , "cdDgh :iop:U:vW " , long_options , & optindex )) != -1 )
129
+ while ((c = getopt_long (argc , argv , "acdDgh :iop:sU:vWx " , long_options , & optindex )) != -1 )
123
130
{
124
131
switch (c )
125
132
{
133
+ case 'a' :
134
+ data_only = true;
135
+ appendPQExpBuffer (pgdumpopts , " -a" );
136
+ break ;
137
+
126
138
case 'c' :
127
139
output_clean = true;
128
140
break ;
@@ -151,6 +163,11 @@ main(int argc, char *argv[])
151
163
appendPQExpBuffer (pgdumpopts , " -p '%s'" , pgport );
152
164
break ;
153
165
166
+ case 's' :
167
+ schema_only = true;
168
+ appendPQExpBuffer (pgdumpopts , " -s" );
169
+ break ;
170
+
154
171
case 'U' :
155
172
pguser = optarg ;
156
173
appendPQExpBuffer (pgdumpopts , " -U '%s'" , pguser );
@@ -166,6 +183,11 @@ main(int argc, char *argv[])
166
183
appendPQExpBuffer (pgdumpopts , " -W" );
167
184
break ;
168
185
186
+ case 'x' :
187
+ skip_acls = true;
188
+ appendPQExpBuffer (pgdumpopts , " -x" );
189
+ break ;
190
+
169
191
default :
170
192
fprintf (stderr , _ ("Try '%s --help' for more information.\n" ), progname );
171
193
exit (1 );
@@ -189,16 +211,19 @@ main(int argc, char *argv[])
189
211
printf ("--\n\n" );
190
212
printf ("\\connect \"template1\"\n\n" );
191
213
192
- dumpUsers ( conn );
193
- dumpGroups ( conn );
194
-
195
- if ( globals_only )
196
- goto end ;
214
+ if (! data_only )
215
+ {
216
+ dumpUsers ( conn );
217
+ dumpGroups ( conn );
218
+ }
197
219
198
- dumpCreateDB (conn );
199
- dumpDatabases (conn );
220
+ if (!globals_only )
221
+ {
222
+ if (!data_only )
223
+ dumpCreateDB (conn );
224
+ dumpDatabases (conn );
225
+ }
200
226
201
- end :
202
227
PQfinish (conn );
203
228
exit (0 );
204
229
}
@@ -213,14 +238,17 @@ help(void)
213
238
printf (_ (" %s [OPTION]...\n" ), progname );
214
239
215
240
printf (_ ("\nOptions:\n" ));
241
+ printf (_ (" -a, --data-only dump only the data, not the schema\n" ));
216
242
printf (_ (" -c, --clean clean (drop) databases prior to create\n" ));
217
243
printf (_ (" -d, --inserts dump data as INSERT, rather than COPY, commands\n" ));
218
244
printf (_ (" -D, --column-inserts dump data as INSERT commands with column names\n" ));
219
245
printf (_ (" -g, --globals-only dump only global objects, no databases\n" ));
220
246
printf (_ (" -i, --ignore-version proceed even when server version mismatches\n"
221
247
" pg_dumpall version\n" ));
248
+ printf (_ (" -s, --schema-only dump only the schema, no data\n" ));
222
249
printf (_ (" -o, --oids include OIDs in dump\n" ));
223
250
printf (_ (" -v, --verbose verbose mode\n" ));
251
+ printf (_ (" -x, --no-privileges do not dump privileges (grant/revoke)\n" ));
224
252
printf (_ (" --help show this help, then exit\n" ));
225
253
printf (_ (" --version output version information, then exit\n" ));
226
254
@@ -462,7 +490,8 @@ dumpCreateDB(PGconn *conn)
462
490
appendPQExpBuffer (buf , ";\n" );
463
491
}
464
492
465
- if (!buildACLCommands (fdbname , "DATABASE" , dbacl , dbowner ,
493
+ if (!skip_acls &&
494
+ !buildACLCommands (fdbname , "DATABASE" , dbacl , dbowner ,
466
495
server_version , buf ))
467
496
{
468
497
fprintf (stderr , _ ("%s: could not parse ACL list (%s) for database %s\n" ),
0 commit comments