2121 *
2222 *
2323 * IDENTIFICATION
24- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.109 1999/05/2614:50:38 momjian Exp $
24+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.110 1999/05/2616:06:45 momjian Exp $
2525 *
2626 * Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
2727 *
@@ -112,12 +112,12 @@ FILE *g_fout;/* the script file */
112112PGconn * g_conn ;/* the database connection */
113113
114114bool 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 ;
121121
122122char g_opaque_type [10 ];/* name for the opaque type */
123123
@@ -233,7 +233,7 @@ dumpClasses_nodumpData(FILE *fout, const char *classname, const bool oids)
233233bool copydone ;
234234char copybuf [COPYBUFSIZ ];
235235
236- if (oids )
236+ if (oids == true )
237237{
238238fprintf (fout ,"COPY %s WITH OIDS FROM stdin;\n" ,
239239fmtId (classname ,force_quotes ));
@@ -336,7 +336,7 @@ dumpClasses_dumpData(FILE *fout, const char *classname,
336336for (tuple = 0 ;tuple < PQntuples (res );tuple ++ )
337337{
338338fprintf (fout ,"INSERT INTO %s " ,fmtId (classname ,force_quotes ));
339- if (attrNames )
339+ if (attrNames == true )
340340{
341341sprintf (q ,"(" );
342342for (field = 0 ;field < PQnfields (res );field ++ )
@@ -545,7 +545,7 @@ main(int argc, char **argv)
545545const char * pghost = NULL ;
546546const char * pgport = NULL ;
547547char * tablename = NULL ;
548- int oids = 0 ;
548+ bool oids = false ;
549549TableInfo * tblinfo ;
550550int numTables ;
551551char connect_string [512 ]= "" ;
@@ -556,13 +556,13 @@ main(int argc, char **argv)
556556
557557g_verbose = false;
558558force_quotes = true;
559- drop_schema = false;
559+ dropSchema = false;
560560
561561strcpy (g_comment_start ,"-- " );
562562g_comment_end [0 ]= '\0' ;
563563strcpy (g_opaque_type ,"opaque" );
564564
565- dataOnly = schemaOnly = dumpData = attrNames = 0 ;
565+ dataOnly = schemaOnly = dumpData = attrNames = false ;
566566
567567progname = * argv ;
568568
@@ -571,19 +571,19 @@ main(int argc, char **argv)
571571switch (c )
572572{
573573case 'a' :/* Dump data only */
574- dataOnly = 1 ;
574+ dataOnly = true ;
575575break ;
576576case 'c' :/* clean (i.e., drop) schema prior to
577577 * create */
578- drop_schema = true;
578+ dropSchema = true;
579579break ;
580580case 'd' :/* dump data as proper insert strings */
581- dumpData = 1 ;
581+ dumpData = true ;
582582break ;
583583case 'D' :/* dump data as proper insert strings with
584584 * attr names */
585- dumpData = 1 ;
586- attrNames = 1 ;
585+ dumpData = true ;
586+ attrNames = true ;
587587break ;
588588case 'f' :/* output file name */
589589filename = optarg ;
@@ -599,13 +599,13 @@ main(int argc, char **argv)
599599force_quotes = true;
600600break ;
601601case 'o' :/* Dump oids */
602- oids = 1 ;
602+ oids = true ;
603603break ;
604604case 'p' :/* server port */
605605pgport = optarg ;
606606break ;
607607case 's' :/* dump schema only */
608- schemaOnly = 1 ;
608+ schemaOnly = true ;
609609break ;
610610case 't' :/* Dump data for this table only */
611611{
@@ -637,7 +637,7 @@ main(int argc, char **argv)
637637g_verbose = true;
638638break ;
639639case 'z' :/* Dump ACLs and table ownership info */
640- aclsOption = 1 ;
640+ aclsOption = true ;
641641break ;
642642case 'u' :
643643use_password = 1 ;
@@ -648,6 +648,14 @@ main(int argc, char **argv)
648648}
649649}
650650
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+
651659/* open the output file */
652660if (filename == NULL )
653661g_fout = stdout ;
@@ -714,7 +722,7 @@ main(int argc, char **argv)
714722
715723g_last_builtin_oid = findLastBuiltinOid ();
716724
717- if (oids )
725+ if (oids == true )
718726setMaxOid (g_fout );
719727if (!dataOnly )
720728{
@@ -1663,7 +1671,7 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
16631671
16641672#if 0
16651673/* XXX - how to emit this DROP TRIGGER? */
1666- if (drop_schema )
1674+ if (dropSchema )
16671675{
16681676sprintf (query ,"DROP TRIGGER %s ON %s;\n" ,
16691677fmtId (PQgetvalue (res2 ,i2 ,i_tgname ),force_quotes ),
@@ -2067,7 +2075,7 @@ dumpTypes(FILE *fout, FuncInfo *finfo, int numFuncs,
20672075
20682076becomeUser (fout ,tinfo [i ].usename );
20692077
2070- if (drop_schema )
2078+ if (dropSchema )
20712079{
20722080sprintf (q ,"DROP TYPE %s;\n" ,fmtId (tinfo [i ].typname ,force_quotes ));
20732081fputs (q ,fout );
@@ -2170,7 +2178,7 @@ dumpProcLangs(FILE *fout, FuncInfo *finfo, int numFuncs,
21702178lanname = checkForQuote (PQgetvalue (res ,i ,i_lanname ));
21712179lancompiler = checkForQuote (PQgetvalue (res ,i ,i_lancompiler ));
21722180
2173- if (drop_schema )
2181+ if (dropSchema )
21742182fprintf (fout ,"DROP PROCEDURAL LANGUAGE '%s';\n" ,lanname );
21752183
21762184fprintf (fout ,"CREATE %sPROCEDURAL LANGUAGE '%s' "
@@ -2288,7 +2296,7 @@ dumpOneFunc(FILE *fout, FuncInfo *finfo, int i,
22882296PQclear (res );
22892297}
22902298
2291- if (drop_schema )
2299+ if (dropSchema )
22922300{
22932301sprintf (q ,"DROP FUNCTION %s (" ,fmtId (finfo [i ].proname ,force_quotes ));
22942302for (j = 0 ;j < finfo [i ].nargs ;j ++ )
@@ -2415,7 +2423,7 @@ dumpOprs(FILE *fout, OprInfo *oprinfo, int numOperators,
24152423
24162424becomeUser (fout ,oprinfo [i ].usename );
24172425
2418- if (drop_schema )
2426+ if (dropSchema )
24192427{
24202428sprintf (q ,"DROP OPERATOR %s (%s, %s);\n" ,oprinfo [i ].oprname ,
24212429fmtId (findTypeByOid (tinfo ,numTypes ,oprinfo [i ].oprleft ), false),
@@ -2519,7 +2527,7 @@ dumpAggs(FILE *fout, AggInfo *agginfo, int numAggs,
25192527
25202528becomeUser (fout ,agginfo [i ].usename );
25212529
2522- if (drop_schema )
2530+ if (dropSchema )
25232531{
25242532sprintf (q ,"DROP AGGREGATE %s %s;\n" ,agginfo [i ].aggname ,
25252533fmtId (findTypeByOid (tinfo ,numTypes ,agginfo [i ].aggbasetype ), false));
@@ -2739,7 +2747,7 @@ dumpTables(FILE *fout, TableInfo *tblinfo, int numTables,
27392747
27402748becomeUser (fout ,tblinfo [i ].usename );
27412749
2742- if (drop_schema )
2750+ if (dropSchema )
27432751{
27442752sprintf (q ,"DROP TABLE %s;\n" ,fmtId (tblinfo [i ].relname ,force_quotes ));
27452753fputs (q ,fout );
@@ -2979,7 +2987,7 @@ dumpIndices(FILE *fout, IndInfo *indinfo, int numIndices,
29792987strcpy (id1 ,fmtId (indinfo [i ].indexrelname ,force_quotes ));
29802988strcpy (id2 ,fmtId (indinfo [i ].indrelname ,force_quotes ));
29812989
2982- if (drop_schema )
2990+ if (dropSchema )
29832991{
29842992sprintf (q ,"DROP INDEX %s;\n" ,id1 );
29852993fputs (q ,fout );
@@ -3245,7 +3253,7 @@ dumpSequence(FILE *fout, TableInfo tbinfo)
32453253
32463254PQclear (res );
32473255
3248- if (drop_schema )
3256+ if (dropSchema )
32493257{
32503258sprintf (query ,"DROP SEQUENCE %s;\n" ,fmtId (tbinfo .relname ,force_quotes ));
32513259fputs (query ,fout );