21
21
*
22
22
*
23
23
* IDENTIFICATION
24
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.109 1999/05/26 14:50:38 momjian Exp $
24
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.110 1999/05/26 16:06:45 momjian Exp $
25
25
*
26
26
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
27
27
*
@@ -112,12 +112,12 @@ FILE *g_fout; /* the script file */
112
112
PGconn * g_conn ; /* the database connection */
113
113
114
114
bool force_quotes ; /* User wants to suppress double-quotes */
115
- int dumpData ; /* dump data using proper insert strings */
116
- int attrNames ; /* put attr names into insert strings */
117
- int schemaOnly ;
118
- int dataOnly ;
119
- int aclsOption ;
120
- bool drop_schema ;
115
+ bool dumpData ; /* dump data using proper insert strings */
116
+ bool attrNames ; /* put attr names into insert strings */
117
+ bool schemaOnly ;
118
+ bool dataOnly ;
119
+ bool aclsOption ;
120
+ bool dropSchema ;
121
121
122
122
char g_opaque_type [10 ]; /* name for the opaque type */
123
123
@@ -233,7 +233,7 @@ dumpClasses_nodumpData(FILE *fout, const char *classname, const bool oids)
233
233
bool copydone ;
234
234
char copybuf [COPYBUFSIZ ];
235
235
236
- if (oids )
236
+ if (oids == true )
237
237
{
238
238
fprintf (fout , "COPY %s WITH OIDS FROM stdin;\n" ,
239
239
fmtId (classname , force_quotes ));
@@ -336,7 +336,7 @@ dumpClasses_dumpData(FILE *fout, const char *classname,
336
336
for (tuple = 0 ; tuple < PQntuples (res ); tuple ++ )
337
337
{
338
338
fprintf (fout , "INSERT INTO %s " , fmtId (classname , force_quotes ));
339
- if (attrNames )
339
+ if (attrNames == true )
340
340
{
341
341
sprintf (q , "(" );
342
342
for (field = 0 ; field < PQnfields (res ); field ++ )
@@ -545,7 +545,7 @@ main(int argc, char **argv)
545
545
const char * pghost = NULL ;
546
546
const char * pgport = NULL ;
547
547
char * tablename = NULL ;
548
- int oids = 0 ;
548
+ bool oids = false ;
549
549
TableInfo * tblinfo ;
550
550
int numTables ;
551
551
char connect_string [512 ] = "" ;
@@ -556,13 +556,13 @@ main(int argc, char **argv)
556
556
557
557
g_verbose = false;
558
558
force_quotes = true;
559
- drop_schema = false;
559
+ dropSchema = false;
560
560
561
561
strcpy (g_comment_start , "-- " );
562
562
g_comment_end [0 ] = '\0' ;
563
563
strcpy (g_opaque_type , "opaque" );
564
564
565
- dataOnly = schemaOnly = dumpData = attrNames = 0 ;
565
+ dataOnly = schemaOnly = dumpData = attrNames = false ;
566
566
567
567
progname = * argv ;
568
568
@@ -571,19 +571,19 @@ main(int argc, char **argv)
571
571
switch (c )
572
572
{
573
573
case 'a' : /* Dump data only */
574
- dataOnly = 1 ;
574
+ dataOnly = true ;
575
575
break ;
576
576
case 'c' : /* clean (i.e., drop) schema prior to
577
577
* create */
578
- drop_schema = true;
578
+ dropSchema = true;
579
579
break ;
580
580
case 'd' : /* dump data as proper insert strings */
581
- dumpData = 1 ;
581
+ dumpData = true ;
582
582
break ;
583
583
case 'D' : /* dump data as proper insert strings with
584
584
* attr names */
585
- dumpData = 1 ;
586
- attrNames = 1 ;
585
+ dumpData = true ;
586
+ attrNames = true ;
587
587
break ;
588
588
case 'f' : /* output file name */
589
589
filename = optarg ;
@@ -599,13 +599,13 @@ main(int argc, char **argv)
599
599
force_quotes = true;
600
600
break ;
601
601
case 'o' : /* Dump oids */
602
- oids = 1 ;
602
+ oids = true ;
603
603
break ;
604
604
case 'p' : /* server port */
605
605
pgport = optarg ;
606
606
break ;
607
607
case 's' : /* dump schema only */
608
- schemaOnly = 1 ;
608
+ schemaOnly = true ;
609
609
break ;
610
610
case 't' : /* Dump data for this table only */
611
611
{
@@ -637,7 +637,7 @@ main(int argc, char **argv)
637
637
g_verbose = true;
638
638
break ;
639
639
case 'z' : /* Dump ACLs and table ownership info */
640
- aclsOption = 1 ;
640
+ aclsOption = true ;
641
641
break ;
642
642
case 'u' :
643
643
use_password = 1 ;
@@ -648,6 +648,14 @@ main(int argc, char **argv)
648
648
}
649
649
}
650
650
651
+ if (dumpData == true && oids == true)
652
+ {
653
+ fprintf (stderr ,
654
+ "%s: INSERT's can not set oids, so INSERT and OID options can not be used together.\n" ,
655
+ progname );
656
+ exit (2 );
657
+ }
658
+
651
659
/* open the output file */
652
660
if (filename == NULL )
653
661
g_fout = stdout ;
@@ -714,7 +722,7 @@ main(int argc, char **argv)
714
722
715
723
g_last_builtin_oid = findLastBuiltinOid ();
716
724
717
- if (oids )
725
+ if (oids == true )
718
726
setMaxOid (g_fout );
719
727
if (!dataOnly )
720
728
{
@@ -1663,7 +1671,7 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
1663
1671
1664
1672
#if 0
1665
1673
/* XXX - how to emit this DROP TRIGGER? */
1666
- if (drop_schema )
1674
+ if (dropSchema )
1667
1675
{
1668
1676
sprintf (query , "DROP TRIGGER %s ON %s;\n" ,
1669
1677
fmtId (PQgetvalue (res2 , i2 , i_tgname ), force_quotes ),
@@ -2067,7 +2075,7 @@ dumpTypes(FILE *fout, FuncInfo *finfo, int numFuncs,
2067
2075
2068
2076
becomeUser (fout , tinfo [i ].usename );
2069
2077
2070
- if (drop_schema )
2078
+ if (dropSchema )
2071
2079
{
2072
2080
sprintf (q , "DROP TYPE %s;\n" , fmtId (tinfo [i ].typname , force_quotes ));
2073
2081
fputs (q , fout );
@@ -2170,7 +2178,7 @@ dumpProcLangs(FILE *fout, FuncInfo *finfo, int numFuncs,
2170
2178
lanname = checkForQuote (PQgetvalue (res , i , i_lanname ));
2171
2179
lancompiler = checkForQuote (PQgetvalue (res , i , i_lancompiler ));
2172
2180
2173
- if (drop_schema )
2181
+ if (dropSchema )
2174
2182
fprintf (fout , "DROP PROCEDURAL LANGUAGE '%s';\n" , lanname );
2175
2183
2176
2184
fprintf (fout , "CREATE %sPROCEDURAL LANGUAGE '%s' "
@@ -2288,7 +2296,7 @@ dumpOneFunc(FILE *fout, FuncInfo *finfo, int i,
2288
2296
PQclear (res );
2289
2297
}
2290
2298
2291
- if (drop_schema )
2299
+ if (dropSchema )
2292
2300
{
2293
2301
sprintf (q , "DROP FUNCTION %s (" , fmtId (finfo [i ].proname , force_quotes ));
2294
2302
for (j = 0 ; j < finfo [i ].nargs ; j ++ )
@@ -2415,7 +2423,7 @@ dumpOprs(FILE *fout, OprInfo *oprinfo, int numOperators,
2415
2423
2416
2424
becomeUser (fout , oprinfo [i ].usename );
2417
2425
2418
- if (drop_schema )
2426
+ if (dropSchema )
2419
2427
{
2420
2428
sprintf (q , "DROP OPERATOR %s (%s, %s);\n" , oprinfo [i ].oprname ,
2421
2429
fmtId (findTypeByOid (tinfo , numTypes , oprinfo [i ].oprleft ), false),
@@ -2519,7 +2527,7 @@ dumpAggs(FILE *fout, AggInfo *agginfo, int numAggs,
2519
2527
2520
2528
becomeUser (fout , agginfo [i ].usename );
2521
2529
2522
- if (drop_schema )
2530
+ if (dropSchema )
2523
2531
{
2524
2532
sprintf (q , "DROP AGGREGATE %s %s;\n" , agginfo [i ].aggname ,
2525
2533
fmtId (findTypeByOid (tinfo , numTypes , agginfo [i ].aggbasetype ), false));
@@ -2739,7 +2747,7 @@ dumpTables(FILE *fout, TableInfo *tblinfo, int numTables,
2739
2747
2740
2748
becomeUser (fout , tblinfo [i ].usename );
2741
2749
2742
- if (drop_schema )
2750
+ if (dropSchema )
2743
2751
{
2744
2752
sprintf (q , "DROP TABLE %s;\n" , fmtId (tblinfo [i ].relname , force_quotes ));
2745
2753
fputs (q , fout );
@@ -2979,7 +2987,7 @@ dumpIndices(FILE *fout, IndInfo *indinfo, int numIndices,
2979
2987
strcpy (id1 , fmtId (indinfo [i ].indexrelname , force_quotes ));
2980
2988
strcpy (id2 , fmtId (indinfo [i ].indrelname , force_quotes ));
2981
2989
2982
- if (drop_schema )
2990
+ if (dropSchema )
2983
2991
{
2984
2992
sprintf (q , "DROP INDEX %s;\n" , id1 );
2985
2993
fputs (q , fout );
@@ -3245,7 +3253,7 @@ dumpSequence(FILE *fout, TableInfo tbinfo)
3245
3253
3246
3254
PQclear (res );
3247
3255
3248
- if (drop_schema )
3256
+ if (dropSchema )
3249
3257
{
3250
3258
sprintf (query , "DROP SEQUENCE %s;\n" , fmtId (tbinfo .relname , force_quotes ));
3251
3259
fputs (query , fout );
0 commit comments