*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.109 1999/05/26 14:50:38 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.110 1999/05/26 16:06:45 momjian Exp $
*
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
*
PGconn *g_conn; /* the database connection */
bool force_quotes; /* User wants to suppress double-quotes */
-int dumpData; /* dump data using proper insert strings */
-int attrNames; /* put attr names into insert strings */
-int schemaOnly;
-int dataOnly;
-int aclsOption;
-bool drop_schema;
+bool dumpData; /* dump data using proper insert strings */
+bool attrNames; /* put attr names into insert strings */
+bool schemaOnly;
+bool dataOnly;
+bool aclsOption;
+bool dropSchema;
char g_opaque_type[10]; /* name for the opaque type */
bool copydone;
char copybuf[COPYBUFSIZ];
- if (oids)
+ if (oids == true)
{
fprintf(fout, "COPY %s WITH OIDS FROM stdin;\n",
fmtId(classname, force_quotes));
for (tuple = 0; tuple < PQntuples(res); tuple++)
{
fprintf(fout, "INSERT INTO %s ", fmtId(classname, force_quotes));
- if (attrNames)
+ if (attrNames == true)
{
sprintf(q, "(");
for (field = 0; field < PQnfields(res); field++)
const char *pghost = NULL;
const char *pgport = NULL;
char *tablename = NULL;
- int oids = 0;
+ bool oids = false;
TableInfo *tblinfo;
int numTables;
char connect_string[512] = "";
g_verbose = false;
force_quotes = true;
- drop_schema = false;
+ dropSchema = false;
strcpy(g_comment_start, "-- ");
g_comment_end[0] = '\0';
strcpy(g_opaque_type, "opaque");
- dataOnly = schemaOnly = dumpData = attrNames = 0;
+ dataOnly = schemaOnly = dumpData = attrNames = false;
progname = *argv;
switch (c)
{
case 'a': /* Dump data only */
- dataOnly = 1;
+ dataOnly = true;
break;
case 'c': /* clean (i.e., drop) schema prior to
* create */
- drop_schema = true;
+ dropSchema = true;
break;
case 'd': /* dump data as proper insert strings */
- dumpData = 1;
+ dumpData = true;
break;
case 'D': /* dump data as proper insert strings with
* attr names */
- dumpData = 1;
- attrNames = 1;
+ dumpData = true;
+ attrNames = true;
break;
case 'f': /* output file name */
filename = optarg;
force_quotes = true;
break;
case 'o': /* Dump oids */
- oids = 1;
+ oids = true;
break;
case 'p': /* server port */
pgport = optarg;
break;
case 's': /* dump schema only */
- schemaOnly = 1;
+ schemaOnly = true;
break;
case 't': /* Dump data for this table only */
{
g_verbose = true;
break;
case 'z': /* Dump ACLs and table ownership info */
- aclsOption = 1;
+ aclsOption = true;
break;
case 'u':
use_password = 1;
}
}
+ if (dumpData == true && oids == true)
+ {
+ fprintf(stderr,
+ "%s: INSERT's can not set oids, so INSERT and OID options can not be used together.\n",
+ progname);
+ exit(2);
+ }
+
/* open the output file */
if (filename == NULL)
g_fout = stdout;
g_last_builtin_oid = findLastBuiltinOid();
- if (oids)
+ if (oids == true)
setMaxOid(g_fout);
if (!dataOnly)
{
#if 0
/* XXX - how to emit this DROP TRIGGER? */
- if (drop_schema)
+ if (dropSchema)
{
sprintf(query, "DROP TRIGGER %s ON %s;\n",
fmtId(PQgetvalue(res2, i2, i_tgname), force_quotes),
becomeUser(fout, tinfo[i].usename);
- if (drop_schema)
+ if (dropSchema)
{
sprintf(q, "DROP TYPE %s;\n", fmtId(tinfo[i].typname, force_quotes));
fputs(q, fout);
lanname = checkForQuote(PQgetvalue(res, i, i_lanname));
lancompiler = checkForQuote(PQgetvalue(res, i, i_lancompiler));
- if (drop_schema)
+ if (dropSchema)
fprintf(fout, "DROP PROCEDURAL LANGUAGE '%s';\n", lanname);
fprintf(fout, "CREATE %sPROCEDURAL LANGUAGE '%s' "
PQclear(res);
}
- if (drop_schema)
+ if (dropSchema)
{
sprintf(q, "DROP FUNCTION %s (", fmtId(finfo[i].proname, force_quotes));
for (j = 0; j < finfo[i].nargs; j++)
becomeUser(fout, oprinfo[i].usename);
- if (drop_schema)
+ if (dropSchema)
{
sprintf(q, "DROP OPERATOR %s (%s, %s);\n", oprinfo[i].oprname,
fmtId(findTypeByOid(tinfo, numTypes, oprinfo[i].oprleft), false),
becomeUser(fout, agginfo[i].usename);
- if (drop_schema)
+ if (dropSchema)
{
sprintf(q, "DROP AGGREGATE %s %s;\n", agginfo[i].aggname,
fmtId(findTypeByOid(tinfo, numTypes, agginfo[i].aggbasetype), false));
becomeUser(fout, tblinfo[i].usename);
- if (drop_schema)
+ if (dropSchema)
{
sprintf(q, "DROP TABLE %s;\n", fmtId(tblinfo[i].relname, force_quotes));
fputs(q, fout);
strcpy(id1, fmtId(indinfo[i].indexrelname, force_quotes));
strcpy(id2, fmtId(indinfo[i].indrelname, force_quotes));
- if (drop_schema)
+ if (dropSchema)
{
sprintf(q, "DROP INDEX %s;\n", id1);
fputs(q, fout);
PQclear(res);
- if (drop_schema)
+ if (dropSchema)
{
sprintf(query, "DROP SEQUENCE %s;\n", fmtId(tbinfo.relname, force_quotes));
fputs(query, fout);