12
12
* by PostgreSQL
13
13
*
14
14
* IDENTIFICATION
15
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.529 2009/03/17 10:10:13 petere Exp $
15
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.530 2009/03/22 16:44:26 tgl Exp $
16
16
*
17
17
*-------------------------------------------------------------------------
18
18
*/
@@ -67,8 +67,6 @@ Archive *g_fout; /* the script file */
67
67
PGconn * g_conn ; /* the database connection */
68
68
69
69
/* various user-settable parameters */
70
- bool dumpInserts ; /* dump data using proper insert strings */
71
- bool attrNames ; /* put attr names into insert strings */
72
70
bool schemaOnly ;
73
71
bool dataOnly ;
74
72
bool aclsSkip ;
@@ -99,8 +97,6 @@ static SimpleOidList table_exclude_oids = {NULL, NULL};
99
97
/* default, if no "inclusion" switches appear, is to dump everything */
100
98
static bool include_everything = true;
101
99
102
- static int binary_upgrade = 0 ;
103
-
104
100
char g_opaque_type [10 ]; /* name for the opaque type */
105
101
106
102
/* placeholders for the delimiters for comments */
@@ -113,8 +109,11 @@ static const CatalogId nilCatalogId = {0, 0};
113
109
static NamespaceInfo * g_namespaces ;
114
110
static int g_numNamespaces ;
115
111
116
- /* flag to turn on/off dollar quoting */
112
+ /* flags for various command-line long options */
113
+ static int binary_upgrade = 0 ;
117
114
static int disable_dollar_quoting = 0 ;
115
+ static int dump_inserts = 0 ;
116
+ static int column_inserts = 0 ;
118
117
119
118
120
119
static void help (const char * progname );
@@ -239,16 +238,12 @@ main(int argc, char **argv)
239
238
static int use_setsessauth = 0 ;
240
239
241
240
struct option long_options [] = {
242
- {"binary-upgrade" , no_argument , & binary_upgrade , 1 }, /* not documented */
243
241
{"data-only" , no_argument , NULL , 'a' },
244
242
{"blobs" , no_argument , NULL , 'b' },
245
243
{"clean" , no_argument , NULL , 'c' },
246
244
{"create" , no_argument , NULL , 'C' },
247
245
{"file" , required_argument , NULL , 'f' },
248
246
{"format" , required_argument , NULL , 'F' },
249
- {"inserts" , no_argument , NULL , 'd' },
250
- {"attribute-inserts" , no_argument , NULL , 'D' },
251
- {"column-inserts" , no_argument , NULL , 'D' },
252
247
{"host" , required_argument , NULL , 'h' },
253
248
{"ignore-version" , no_argument , NULL , 'i' },
254
249
{"no-reconnect" , no_argument , NULL , 'R' },
@@ -275,8 +270,12 @@ main(int argc, char **argv)
275
270
/*
276
271
* the following options don't have an equivalent short option letter
277
272
*/
273
+ {"attribute-inserts" , no_argument , & column_inserts , 1 },
274
+ {"binary-upgrade" , no_argument , & binary_upgrade , 1 },
275
+ {"column-inserts" , no_argument , & column_inserts , 1 },
278
276
{"disable-dollar-quoting" , no_argument , & disable_dollar_quoting , 1 },
279
277
{"disable-triggers" , no_argument , & disable_triggers , 1 },
278
+ {"inserts" , no_argument , & dump_inserts , 1 },
280
279
{"lock-wait-timeout" , required_argument , NULL , 2 },
281
280
{"no-tablespaces" , no_argument , & outputNoTablespaces , 1 },
282
281
{"role" , required_argument , NULL , 3 },
@@ -293,7 +292,7 @@ main(int argc, char **argv)
293
292
g_comment_end [0 ] = '\0' ;
294
293
strcpy (g_opaque_type , "opaque" );
295
294
296
- dataOnly = schemaOnly = dumpInserts = attrNames = false;
295
+ dataOnly = schemaOnly = false;
297
296
lockWaitTimeout = NULL ;
298
297
299
298
progname = get_progname (argv [0 ]);
@@ -316,7 +315,7 @@ main(int argc, char **argv)
316
315
}
317
316
}
318
317
319
- while ((c = getopt_long (argc , argv , "abcCdDE :f:F:h:in:N:oOp:RsS:t:T:U:vwWxX:Z:" ,
318
+ while ((c = getopt_long (argc , argv , "abcCE :f:F:h:in:N:oOp:RsS:t:T:U:vwWxX:Z:" ,
320
319
long_options , & optindex )) != -1 )
321
320
{
322
321
switch (c )
@@ -337,16 +336,6 @@ main(int argc, char **argv)
337
336
outputCreate = 1 ;
338
337
break ;
339
338
340
- case 'd' : /* dump data as proper insert strings */
341
- dumpInserts = true;
342
- break ;
343
-
344
- case 'D' : /* dump data as proper insert strings with
345
- * attr names */
346
- dumpInserts = true;
347
- attrNames = true;
348
- break ;
349
-
350
339
case 'E' : /* Dump encoding */
351
340
dumpencoding = optarg ;
352
341
break ;
@@ -484,6 +473,10 @@ main(int argc, char **argv)
484
473
if (optind < argc )
485
474
dbname = argv [optind ];
486
475
476
+ /* --column-inserts implies --inserts */
477
+ if (column_inserts )
478
+ dump_inserts = 1 ;
479
+
487
480
if (dataOnly && schemaOnly )
488
481
{
489
482
write_msg (NULL , "options -s/--schema-only and -a/--data-only cannot be used together\n" );
@@ -496,9 +489,9 @@ main(int argc, char **argv)
496
489
exit (1 );
497
490
}
498
491
499
- if (dumpInserts == true && oids == true )
492
+ if (dump_inserts && oids )
500
493
{
501
- write_msg (NULL , "options -d/-D/- -inserts/--column-inserts and -o/--oids cannot be used together\n" );
494
+ write_msg (NULL , "options --inserts/--column-inserts and -o/--oids cannot be used together\n" );
502
495
write_msg (NULL , "(The INSERT command cannot set OIDs.)\n" );
503
496
exit (1 );
504
497
}
@@ -815,8 +808,6 @@ help(const char *progname)
815
808
printf (_ (" -b, --blobs include large objects in dump\n" ));
816
809
printf (_ (" -c, --clean clean (drop) database objects before recreating\n" ));
817
810
printf (_ (" -C, --create include commands to create database in dump\n" ));
818
- printf (_ (" -d, --inserts dump data as INSERT commands, rather than COPY\n" ));
819
- printf (_ (" -D, --column-inserts dump data as INSERT commands with column names\n" ));
820
811
printf (_ (" -E, --encoding=ENCODING dump the data in encoding ENCODING\n" ));
821
812
printf (_ (" -n, --schema=SCHEMA dump the named schema(s) only\n" ));
822
813
printf (_ (" -N, --exclude-schema=SCHEMA do NOT dump the named schema(s)\n" ));
@@ -829,6 +820,8 @@ help(const char *progname)
829
820
printf (_ (" -T, --exclude-table=TABLE do NOT dump the named table(s)\n" ));
830
821
printf (_ (" -x, --no-privileges do not dump privileges (grant/revoke)\n" ));
831
822
printf (_ (" --binary-upgrade for use by upgrade utilities only\n" ));
823
+ printf (_ (" --inserts dump data as INSERT commands, rather than COPY\n" ));
824
+ printf (_ (" --column-inserts dump data as INSERT commands with column names\n" ));
832
825
printf (_ (" --disable-dollar-quoting disable dollar quoting, use SQL standard quoting\n" ));
833
826
printf (_ (" --disable-triggers disable triggers during data-only restore\n" ));
834
827
printf (_ (" --no-tablespaces do not dump tablespace assignments\n" ));
@@ -1269,7 +1262,7 @@ dumpTableData_insert(Archive *fout, void *dcontext)
1269
1262
archprintf (fout , "DEFAULT VALUES;\n" );
1270
1263
continue ;
1271
1264
}
1272
- if (attrNames == true )
1265
+ if (column_inserts )
1273
1266
{
1274
1267
resetPQExpBuffer (q );
1275
1268
appendPQExpBuffer (q , "(" );
@@ -1376,7 +1369,7 @@ dumpTableData(Archive *fout, TableDataInfo *tdinfo)
1376
1369
DataDumperPtr dumpFn ;
1377
1370
char * copyStmt ;
1378
1371
1379
- if (!dumpInserts )
1372
+ if (!dump_inserts )
1380
1373
{
1381
1374
/* Dump/restore using COPY */
1382
1375
dumpFn = dumpTableData_copy ;
0 commit comments