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

Commit9e1e72b

Browse files
committed
Cause pg_dumpall to support the -a, -s, -x options of pg_dump.
1 parentdf1df6b commit9e1e72b

File tree

2 files changed

+76
-15
lines changed

2 files changed

+76
-15
lines changed

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

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/pg_dumpall.sgml,v 1.38 2003/03/24 14:32:51 petere Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/pg_dumpall.sgml,v 1.39 2003/05/30 23:55:10 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -35,8 +35,8 @@ PostgreSQL documentation
3535
<application>pg_dumpall</application> also dumps global objects
3636
that are common to all databases.
3737
(<application>pg_dump</application> does not save these objects.)
38-
This currently includestheinformation about database users and
39-
groups.
38+
This currently includes information about database users and
39+
groups, and access permissions that apply to databases as a whole.
4040
</para>
4141

4242
<para>
@@ -75,9 +75,20 @@ PostgreSQL documentation
7575
<title>Options</title>
7676

7777
<para>
78-
The following command-line options are used to control the output format.
78+
The following command-line options are used to control the content and
79+
format of the output.
7980

8081
<variablelist>
82+
<varlistentry>
83+
<term><option>-a</></term>
84+
<term><option>--data-only</></term>
85+
<listitem>
86+
<para>
87+
Dump only the data, not the schema (data definitions).
88+
</para>
89+
</listitem>
90+
</varlistentry>
91+
8192
<varlistentry>
8293
<term><option>-c</option></term>
8394
<term><option>--clean</option></term>
@@ -161,6 +172,16 @@ PostgreSQL documentation
161172
</listitem>
162173
</varlistentry>
163174

175+
<varlistentry>
176+
<term><option>-s</option></term>
177+
<term><option>--schema-only</option></term>
178+
<listitem>
179+
<para>
180+
Dump only the schema (data definitions), no data.
181+
</para>
182+
</listitem>
183+
</varlistentry>
184+
164185
<varlistentry>
165186
<term><option>-v</></term>
166187
<term><option>--verbose</></term>
@@ -172,6 +193,17 @@ PostgreSQL documentation
172193
</para>
173194
</listitem>
174195
</varlistentry>
196+
197+
<varlistentry>
198+
<term><option>-x</></term>
199+
<term><option>--no-privileges</></term>
200+
<term><option>--no-acl</></term>
201+
<listitem>
202+
<para>
203+
Prevent dumping of access privileges (grant/revoke commands).
204+
</para>
205+
</listitem>
206+
</varlistentry>
175207
</variablelist>
176208
</para>
177209

‎src/bin/pg_dump/pg_dumpall.c

Lines changed: 40 additions & 11 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-
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.19 2003/05/3022:55:16 tgl Exp $
9+
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.20 2003/05/3023:55:10 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -60,6 +60,7 @@ static char *findPgDump(const char *argv0);
6060
char*pgdumploc;
6161
PQExpBufferpgdumpopts;
6262
booloutput_clean= false;
63+
boolskip_acls= false;
6364
boolverbose= false;
6465
intserver_version;
6566

@@ -72,11 +73,14 @@ main(int argc, char *argv[])
7273
char*pgport=NULL;
7374
char*pguser=NULL;
7475
boolforce_password= false;
76+
booldata_only= false;
7577
boolglobals_only= false;
78+
boolschema_only= false;
7679
PGconn*conn;
7780
intc;
7881

7982
staticstructoptionlong_options[]= {
83+
{"data-only",no_argument,NULL,'a'},
8084
{"clean",no_argument,NULL,'c'},
8185
{"inserts",no_argument,NULL,'d'},
8286
{"attribute-inserts",no_argument,NULL,'D'},
@@ -87,8 +91,11 @@ main(int argc, char *argv[])
8791
{"oids",no_argument,NULL,'o'},
8892
{"port",required_argument,NULL,'p'},
8993
{"password",no_argument,NULL,'W'},
94+
{"schema-only",no_argument,NULL,'s'},
9095
{"username",required_argument,NULL,'U'},
9196
{"verbose",no_argument,NULL,'v'},
97+
{"no-privileges",no_argument,NULL,'x'},
98+
{"no-acl",no_argument,NULL,'x'},
9299
{NULL,0,NULL,0}
93100
};
94101

@@ -119,10 +126,15 @@ main(int argc, char *argv[])
119126
pgdumploc=findPgDump(argv[0]);
120127
pgdumpopts=createPQExpBuffer();
121128

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)
123130
{
124131
switch (c)
125132
{
133+
case'a':
134+
data_only= true;
135+
appendPQExpBuffer(pgdumpopts," -a");
136+
break;
137+
126138
case'c':
127139
output_clean= true;
128140
break;
@@ -151,6 +163,11 @@ main(int argc, char *argv[])
151163
appendPQExpBuffer(pgdumpopts," -p '%s'",pgport);
152164
break;
153165

166+
case's':
167+
schema_only= true;
168+
appendPQExpBuffer(pgdumpopts," -s");
169+
break;
170+
154171
case'U':
155172
pguser=optarg;
156173
appendPQExpBuffer(pgdumpopts," -U '%s'",pguser);
@@ -166,6 +183,11 @@ main(int argc, char *argv[])
166183
appendPQExpBuffer(pgdumpopts," -W");
167184
break;
168185

186+
case'x':
187+
skip_acls= true;
188+
appendPQExpBuffer(pgdumpopts," -x");
189+
break;
190+
169191
default:
170192
fprintf(stderr,_("Try '%s --help' for more information.\n"),progname);
171193
exit(1);
@@ -189,16 +211,19 @@ main(int argc, char *argv[])
189211
printf("--\n\n");
190212
printf("\\connect \"template1\"\n\n");
191213

192-
dumpUsers(conn);
193-
dumpGroups(conn);
194-
195-
if (globals_only)
196-
gotoend;
214+
if (!data_only)
215+
{
216+
dumpUsers(conn);
217+
dumpGroups(conn);
218+
}
197219

198-
dumpCreateDB(conn);
199-
dumpDatabases(conn);
220+
if (!globals_only)
221+
{
222+
if (!data_only)
223+
dumpCreateDB(conn);
224+
dumpDatabases(conn);
225+
}
200226

201-
end:
202227
PQfinish(conn);
203228
exit(0);
204229
}
@@ -213,14 +238,17 @@ help(void)
213238
printf(_(" %s [OPTION]...\n"),progname);
214239

215240
printf(_("\nOptions:\n"));
241+
printf(_(" -a, --data-only dump only the data, not the schema\n"));
216242
printf(_(" -c, --clean clean (drop) databases prior to create\n"));
217243
printf(_(" -d, --inserts dump data as INSERT, rather than COPY, commands\n"));
218244
printf(_(" -D, --column-inserts dump data as INSERT commands with column names\n"));
219245
printf(_(" -g, --globals-only dump only global objects, no databases\n"));
220246
printf(_(" -i, --ignore-version proceed even when server version mismatches\n"
221247
" pg_dumpall version\n"));
248+
printf(_(" -s, --schema-only dump only the schema, no data\n"));
222249
printf(_(" -o, --oids include OIDs in dump\n"));
223250
printf(_(" -v, --verbose verbose mode\n"));
251+
printf(_(" -x, --no-privileges do not dump privileges (grant/revoke)\n"));
224252
printf(_(" --help show this help, then exit\n"));
225253
printf(_(" --version output version information, then exit\n"));
226254

@@ -462,7 +490,8 @@ dumpCreateDB(PGconn *conn)
462490
appendPQExpBuffer(buf,";\n");
463491
}
464492

465-
if (!buildACLCommands(fdbname,"DATABASE",dbacl,dbowner,
493+
if (!skip_acls&&
494+
!buildACLCommands(fdbname,"DATABASE",dbacl,dbowner,
466495
server_version,buf))
467496
{
468497
fprintf(stderr,_("%s: could not parse ACL list (%s) for database %s\n"),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp