aboutsummaryrefslogtreecommitdiff
path: root/src/bin/pg_dump
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/pg_dump')
-rw-r--r--src/bin/pg_dump/common.c28
-rw-r--r--src/bin/pg_dump/dumputils.c19
-rw-r--r--src/bin/pg_dump/dumputils.h10
-rw-r--r--src/bin/pg_dump/pg_backup.h10
-rw-r--r--src/bin/pg_dump/pg_backup_archiver.c154
-rw-r--r--src/bin/pg_dump/pg_backup_archiver.h33
-rw-r--r--src/bin/pg_dump/pg_backup_db.c173
-rw-r--r--src/bin/pg_dump/pg_backup_tar.c4
-rw-r--r--src/bin/pg_dump/pg_dump.c331
-rw-r--r--src/bin/pg_dump/pg_dump.h23
-rw-r--r--src/bin/pg_dump/pg_dump_sort.c209
-rw-r--r--src/bin/pg_dump/pg_dumpall.c88
-rw-r--r--src/bin/pg_dump/pg_restore.c9
13 files changed, 570 insertions, 521 deletions
diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c
index 9243763e539..cbf1b8a3bb2 100644
--- a/src/bin/pg_dump/common.c
+++ b/src/bin/pg_dump/common.c
@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/common.c,v 1.83 2004/08/29 04:13:01 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/common.c,v 1.84 2004/08/29 05:06:53 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -49,14 +49,14 @@ static int numCatalogIds = 0;
* These variables are static to avoid the notational cruft of having to pass
* them into findTableByOid() and friends.
*/
-static TableInfo *tblinfo;
-static TypeInfo *typinfo;
-static FuncInfo *funinfo;
-static OprInfo *oprinfo;
-static int numTables;
-static int numTypes;
-static int numFuncs;
-static int numOperators;
+static TableInfo *tblinfo;
+static TypeInfo *typinfo;
+static FuncInfo *funinfo;
+static OprInfo *oprinfo;
+static int numTables;
+static int numTypes;
+static int numFuncs;
+static int numOperators;
static void flagInhTables(TableInfo *tbinfo, int numTables,
@@ -65,7 +65,7 @@ static void flagInhAttrs(TableInfo *tbinfo, int numTables,
InhInfo *inhinfo, int numInherits);
static int DOCatalogIdCompare(const void *p1, const void *p2);
static void findParentsByOid(TableInfo *self,
- InhInfo *inhinfo, int numInherits);
+ InhInfo *inhinfo, int numInherits);
static int strInArray(const char *pattern, char **arr, int arr_size);
@@ -302,7 +302,7 @@ flagInhAttrs(TableInfo *tblinfo, int numTables,
{
defaultsFound = true;
defaultsMatch &= (strcmp(attrDef->adef_expr,
- inhDef->adef_expr) == 0);
+ inhDef->adef_expr) == 0);
}
}
}
@@ -358,7 +358,7 @@ flagInhAttrs(TableInfo *tblinfo, int numTables,
for (k = 0; k < numParents; k++)
{
- int l;
+ int l;
parent = parents[k];
for (l = 0; l < parent->ncheck; l++)
@@ -403,7 +403,7 @@ AssignDumpId(DumpableObject *dobj)
while (dobj->dumpId >= allocedDumpIds)
{
- int newAlloc;
+ int newAlloc;
if (allocedDumpIds <= 0)
{
@@ -470,7 +470,7 @@ findObjectByDumpId(DumpId dumpId)
*
* We use binary search in a sorted list that is built on first call.
* If AssignDumpId() and findObjectByCatalogId() calls were intermixed,
- * the code would work, but possibly be very slow. In the current usage
+ * the code would work, but possibly be very slow. In the current usage
* pattern that does not happen, indeed we only need to build the list once.
*/
DumpableObject *
diff --git a/src/bin/pg_dump/dumputils.c b/src/bin/pg_dump/dumputils.c
index f2f9cf80d48..dabb6159028 100644
--- a/src/bin/pg_dump/dumputils.c
+++ b/src/bin/pg_dump/dumputils.c
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/bin/pg_dump/dumputils.c,v 1.14 2004/08/29 04:13:01 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/dumputils.c,v 1.15 2004/08/29 05:06:53 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -154,7 +154,7 @@ void
appendStringLiteralDQ(PQExpBuffer buf, const char *str, const char *dqprefix)
{
static const char suffixes[] = "_XXXXXXX";
- int nextchar = 0;
+ int nextchar = 0;
PQExpBuffer delimBuf = createPQExpBuffer();
/* start with $ + dqprefix if not NULL */
@@ -163,15 +163,15 @@ appendStringLiteralDQ(PQExpBuffer buf, const char *str, const char *dqprefix)
appendPQExpBuffer(delimBuf, dqprefix);
/*
- * Make sure we choose a delimiter which (without the trailing $)
- * is not present in the string being quoted. We don't check with the
+ * Make sure we choose a delimiter which (without the trailing $) is
+ * not present in the string being quoted. We don't check with the
* trailing $ because a string ending in $foo must not be quoted with
* $foo$.
*/
while (strstr(str, delimBuf->data) != NULL)
{
appendPQExpBufferChar(delimBuf, suffixes[nextchar++]);
- nextchar %= sizeof(suffixes)-1;
+ nextchar %= sizeof(suffixes) - 1;
}
/* add trailing $ */
@@ -195,9 +195,9 @@ appendStringLiteralDQOpt(PQExpBuffer buf, const char *str,
bool escapeAll, const char *dqprefix)
{
if (strchr(str, '\'') == NULL && strchr(str, '\\') == NULL)
- appendStringLiteral(buf,str,escapeAll);
+ appendStringLiteral(buf, str, escapeAll);
else
- appendStringLiteralDQ(buf,str,dqprefix);
+ appendStringLiteralDQ(buf, str, dqprefix);
}
@@ -621,7 +621,10 @@ copyAclUserName(PQExpBuffer output, char *input)
while (*input && *input != '=')
{
- /* If user name isn't quoted, then just add it to the output buffer */
+ /*
+ * If user name isn't quoted, then just add it to the output
+ * buffer
+ */
if (*input != '"')
appendPQExpBufferChar(output, *input++);
else
diff --git a/src/bin/pg_dump/dumputils.h b/src/bin/pg_dump/dumputils.h
index a0476bb6d39..40e1942e07a 100644
--- a/src/bin/pg_dump/dumputils.h
+++ b/src/bin/pg_dump/dumputils.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/bin/pg_dump/dumputils.h,v 1.12 2004/08/29 04:13:01 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/dumputils.h,v 1.13 2004/08/29 05:06:53 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -21,10 +21,10 @@
extern const char *fmtId(const char *identifier);
extern void appendStringLiteral(PQExpBuffer buf, const char *str,
bool escapeAll);
-extern void appendStringLiteralDQ(PQExpBuffer buf, const char *str,
- const char *dqprefix);
-extern void appendStringLiteralDQOpt(PQExpBuffer buf, const char *str,
- bool escapeAll, const char *dqprefix);
+extern void appendStringLiteralDQ(PQExpBuffer buf, const char *str,
+ const char *dqprefix);
+extern void appendStringLiteralDQOpt(PQExpBuffer buf, const char *str,
+ bool escapeAll, const char *dqprefix);
extern int parse_version(const char *versionString);
extern bool parsePGArray(const char *atext, char ***itemarray, int *nitems);
extern bool buildACLCommands(const char *name, const char *type,
diff --git a/src/bin/pg_dump/pg_backup.h b/src/bin/pg_dump/pg_backup.h
index 7723203df7f..293985508f1 100644
--- a/src/bin/pg_dump/pg_backup.h
+++ b/src/bin/pg_dump/pg_backup.h
@@ -15,7 +15,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup.h,v 1.32 2004/08/20 04:20:22 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup.h,v 1.33 2004/08/29 05:06:53 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -70,10 +70,12 @@ typedef int (*DataDumperPtr) (Archive *AH, void *userArg);
typedef struct _restoreOptions
{
int create; /* Issue commands to create the database */
- int noOwner; /* Don't try to match original object owner */
+ int noOwner; /* Don't try to match original object
+ * owner */
int disable_triggers; /* disable triggers during
* data-only restore */
- int use_setsessauth; /* Use SET SESSION AUTHORIZATION commands instead of OWNER TO */
+ int use_setsessauth;/* Use SET SESSION AUTHORIZATION commands
+ * instead of OWNER TO */
char *superuser; /* Username to use as superuser */
int dataOnly;
int dropSchema;
@@ -179,4 +181,4 @@ archprintf(Archive *AH, const char *fmt,...)
/* This extension allows gcc to check the format string */
__attribute__((format(printf, 2, 3)));
-#endif /* PG_BACKUP_H */
+#endif /* PG_BACKUP_H */
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index 698e7fd524e..a4786e4b62c 100644
--- a/src/bin/pg_dump/pg_backup_archiver.c
+++ b/src/bin/pg_dump/pg_backup_archiver.c
@@ -15,7 +15,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.94 2004/08/20 20:00:34 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.95 2004/08/29 05:06:53 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -47,12 +47,12 @@ static char *modulename = gettext_noop("archiver");
static ArchiveHandle *_allocAH(const char *FileSpec, const ArchiveFormat fmt,
const int compression, ArchiveMode mode);
-static char *_getObjectFromDropStmt(const char *dropStmt, const char *type);
+static char *_getObjectFromDropStmt(const char *dropStmt, const char *type);
static void _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isData, bool acl_pass);
static void fixPriorBlobRefs(ArchiveHandle *AH, TocEntry *blobte,
- RestoreOptions *ropt);
+ RestoreOptions *ropt);
static void _doSetFixedOutputState(ArchiveHandle *AH);
static void _doSetSessionAuth(ArchiveHandle *AH, const char *user);
static void _doSetWithOids(ArchiveHandle *AH, const bool withOids);
@@ -167,7 +167,11 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
ConnectDatabase(AHX, ropt->dbname,
ropt->pghost, ropt->pgport, ropt->username,
ropt->requirePassword, ropt->ignoreVersion);
- /* If we're talking to the DB directly, don't send comments since they obscure SQL when displaying errors */
+
+ /*
+ * If we're talking to the DB directly, don't send comments since
+ * they obscure SQL when displaying errors
+ */
AH->noTocComments = 1;
}
@@ -294,7 +298,7 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
/*
* If we can output the data, then restore it.
*/
- if (AH->PrintTocDataPtr != NULL && (reqs & REQ_DATA) != 0)
+ if (AH->PrintTocDataPtr !=NULL && (reqs & REQ_DATA) != 0)
{
#ifndef HAVE_LIBZ
if (AH->compression != 0)
@@ -350,10 +354,10 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
* If we just restored blobs, fix references in
* previously-loaded tables; otherwise, if we
* previously restored blobs, fix references in
- * this table. Note that in standard cases the BLOBS
- * entry comes after all TABLE DATA entries, but
- * we should cope with other orders in case the
- * user demands reordering.
+ * this table. Note that in standard cases the
+ * BLOBS entry comes after all TABLE DATA entries,
+ * but we should cope with other orders in case
+ * the user demands reordering.
*/
if (strcmp(te->desc, "BLOBS") == 0)
fixPriorBlobRefs(AH, te, ropt);
@@ -376,7 +380,7 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
}
}
te = te->next;
- } /* end loop over TOC entries */
+ } /* end loop over TOC entries */
/*
* Scan TOC again to output ownership commands and ACLs
@@ -424,7 +428,7 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
/*
* After restoring BLOBS, fix all blob references in previously-restored
- * tables. (Normally, the BLOBS entry should appear after all TABLE DATA
+ * tables. (Normally, the BLOBS entry should appear after all TABLE DATA
* entries, so this will in fact handle all blob references.)
*/
static void
@@ -504,8 +508,8 @@ _disableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te, RestoreOptions *rop
/*
* Become superuser if possible, since they are the only ones who can
- * update pg_class. If -S was not given, assume the initial user identity
- * is a superuser.
+ * update pg_class. If -S was not given, assume the initial user
+ * identity is a superuser.
*/
_becomeUser(AH, ropt->superuser);
@@ -543,8 +547,8 @@ _enableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt
/*
* Become superuser if possible, since they are the only ones who can
- * update pg_class. If -S was not given, assume the initial user identity
- * is a superuser.
+ * update pg_class. If -S was not given, assume the initial user
+ * identity is a superuser.
*/
_becomeUser(AH, ropt->superuser);
@@ -650,7 +654,7 @@ ArchiveEntry(Archive *AHX,
newToc->formatData = NULL;
- if (AH->ArchiveEntryPtr != NULL)
+ if (AH->ArchiveEntryPtr !=NULL)
(*AH->ArchiveEntryPtr) (AH, newToc);
}
@@ -664,7 +668,7 @@ PrintTOCSummary(Archive *AHX, RestoreOptions *ropt)
char *fmtName;
if (ropt->filename)
- sav = SetOutput(AH, ropt->filename, 0 /* no compression */);
+ sav = SetOutput(AH, ropt->filename, 0 /* no compression */ );
ahprintf(AH, ";\n; Archive created at %s", ctime(&AH->createDate));
ahprintf(AH, "; dbname: %s\n; TOC Entries: %d\n; Compression: %d\n",
@@ -942,9 +946,8 @@ archprintf(Archive *AH, const char *fmt,...)
/*
* This is paranoid: deal with the possibility that vsnprintf is
- * willing to ignore trailing null
- * or returns > 0 even if string does not fit. It may be the case that
- * it returns cnt = bufsize
+ * willing to ignore trailing null or returns > 0 even if string does
+ * not fit. It may be the case that it returns cnt = bufsize
*/
while (cnt < 0 || cnt >= (bSize - 1))
{
@@ -1236,48 +1239,45 @@ die_horribly(ArchiveHandle *AH, const char *modulename, const char *fmt,...)
/* on some error, we may decide to go on... */
void
-warn_or_die_horribly(ArchiveHandle *AH,
- const char *modulename, const char *fmt, ...)
+warn_or_die_horribly(ArchiveHandle *AH,
+ const char *modulename, const char *fmt,...)
{
- va_list ap;
+ va_list ap;
- switch(AH->stage) {
+ switch (AH->stage)
+ {
case STAGE_NONE:
/* Do nothing special */
break;
case STAGE_INITIALIZING:
- if (AH->stage != AH->lastErrorStage) {
+ if (AH->stage != AH->lastErrorStage)
write_msg(modulename, "Error while INITIALIZING:\n");
- }
break;
case STAGE_PROCESSING:
- if (AH->stage != AH->lastErrorStage) {
+ if (AH->stage != AH->lastErrorStage)
write_msg(modulename, "Error while PROCESSING TOC:\n");
- }
break;
case STAGE_FINALIZING:
- if (AH->stage != AH->lastErrorStage) {
+ if (AH->stage != AH->lastErrorStage)
write_msg(modulename, "Error while FINALIZING:\n");
- }
break;
}
- if (AH->currentTE != NULL && AH->currentTE != AH->lastErrorTE) {
+ if (AH->currentTE != NULL && AH->currentTE != AH->lastErrorTE)
+ {
write_msg(modulename, "Error from TOC Entry %d; %u %u %s %s %s\n", AH->currentTE->dumpId,
- AH->currentTE->catalogId.tableoid, AH->currentTE->catalogId.oid,
- AH->currentTE->desc, AH->currentTE->tag, AH->currentTE->owner);
+ AH->currentTE->catalogId.tableoid, AH->currentTE->catalogId.oid,
+ AH->currentTE->desc, AH->currentTE->tag, AH->currentTE->owner);
}
AH->lastErrorStage = AH->stage;
AH->lastErrorTE = AH->currentTE;
va_start(ap, fmt);
if (AH->public.exit_on_error)
- {
_die_horribly(AH, modulename, fmt, ap);
- }
else
{
_write_msg(modulename, fmt, ap);
@@ -1312,7 +1312,6 @@ _moveBefore(ArchiveHandle *AH, TocEntry *pos, TocEntry *te)
pos->prev->next = te;
pos->prev = te;
}
-
#endif
static TocEntry *
@@ -1689,7 +1688,7 @@ _allocAH(const char *FileSpec, const ArchiveFormat fmt,
* later if necessary */
AH->currSchema = strdup(""); /* ditto */
AH->currWithOids = -1; /* force SET */
-
+
AH->toc = (TocEntry *) calloc(1, sizeof(TocEntry));
if (!AH->toc)
die_horribly(AH, modulename, "out of memory\n");
@@ -1863,7 +1862,7 @@ ReadToc(ArchiveHandle *AH)
/* Sanity check */
if (te->dumpId <= 0)
die_horribly(AH, modulename,
- "entry ID %d out of range -- perhaps a corrupt TOC\n",
+ "entry ID %d out of range -- perhaps a corrupt TOC\n",
te->dumpId);
te->hadDumper = ReadInt(AH);
@@ -1901,7 +1900,7 @@ ReadToc(ArchiveHandle *AH)
}
else
te->withOids = true;
-
+
/* Read TOC entry dependencies */
if (AH->version >= K_VERS_1_5)
{
@@ -2129,7 +2128,7 @@ _doSetWithOids(ArchiveHandle *AH, const bool withOids)
PQExpBuffer cmd = createPQExpBuffer();
appendPQExpBuffer(cmd, "SET default_with_oids = %s;", withOids ?
- "true" : "false");
+ "true" : "false");
if (RestoringToDB(AH))
{
@@ -2138,7 +2137,7 @@ _doSetWithOids(ArchiveHandle *AH, const bool withOids)
res = PQexec(AH->connection, cmd->data);
if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
- warn_or_die_horribly(AH, modulename,
+ warn_or_die_horribly(AH, modulename,
"could not set default_with_oids: %s",
PQerrorMessage(AH->connection));
@@ -2192,7 +2191,7 @@ _reconnectToDB(ArchiveHandle *AH, const char *dbname, const char *user)
free(AH->currSchema);
AH->currSchema = strdup("");
AH->currWithOids = -1;
-
+
/* re-establish fixed state */
_doSetFixedOutputState(AH);
}
@@ -2224,7 +2223,7 @@ _becomeUser(ArchiveHandle *AH, const char *user)
}
/*
- * Become the owner of the the given TOC entry object. If
+ * Become the owner of the the given TOC entry object. If
* changes in ownership are not allowed, this doesn't do anything.
*/
static void
@@ -2278,9 +2277,9 @@ _selectOutputSchema(ArchiveHandle *AH, const char *schemaName)
res = PQexec(AH->connection, qry->data);
if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
- warn_or_die_horribly(AH, modulename,
- "could not set search_path to \"%s\": %s",
- schemaName, PQerrorMessage(AH->connection));
+ warn_or_die_horribly(AH, modulename,
+ "could not set search_path to \"%s\": %s",
+ schemaName, PQerrorMessage(AH->connection));
PQclear(res);
}
@@ -2304,21 +2303,27 @@ static char *
_getObjectFromDropStmt(const char *dropStmt, const char *type)
{
/* Chop "DROP" off the front and make a copy */
- char *first = strdup(dropStmt + 5);
- char *last = first + strlen(first) - 1; /* Points to the last real char in extract */
- char *buf = NULL;
+ char *first = strdup(dropStmt + 5);
+ char *last = first + strlen(first) - 1; /* Points to the last
+ * real char in extract */
+ char *buf = NULL;
- /* Loop from the end of the string until last char is no longer '\n' or ';' */
- while (last >= first && (*last == '\n' || *last == ';')) {
+ /*
+ * Loop from the end of the string until last char is no longer '\n'
+ * or ';'
+ */
+ while (last >= first && (*last == '\n' || *last == ';'))
last--;
- }
/* Insert end of string one place after last */
*(last + 1) = '\0';
- /* Take off CASCADE if necessary. Only TYPEs seem to have this, but may
- * as well check for all */
- if ((last - first) >= 8) {
+ /*
+ * Take off CASCADE if necessary. Only TYPEs seem to have this, but
+ * may as well check for all
+ */
+ if ((last - first) >= 8)
+ {
if (strcmp(last - 7, " CASCADE") == 0)
last -= 8;
}
@@ -2329,22 +2334,22 @@ _getObjectFromDropStmt(const char *dropStmt, const char *type)
/* Special case VIEWs and SEQUENCEs. They must use ALTER TABLE. */
if (strcmp(type, "VIEW") == 0 && (last - first) >= 5)
{
- int len = 6 + strlen(first + 5) + 1;
+ int len = 6 + strlen(first + 5) + 1;
+
buf = malloc(len);
snprintf(buf, len, "TABLE %s", first + 5);
- free (first);
+ free(first);
}
else if (strcmp(type, "SEQUENCE") == 0 && (last - first) >= 9)
{
- int len = 6 + strlen(first + 9) + 1;
+ int len = 6 + strlen(first + 9) + 1;
+
buf = malloc(len);
snprintf(buf, len, "TABLE %s", first + 9);
- free (first);
+ free(first);
}
else
- {
buf = first;
- }
return buf;
}
@@ -2352,7 +2357,7 @@ _getObjectFromDropStmt(const char *dropStmt, const char *type)
static void
_printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isData, bool acl_pass)
{
- const char *pfx;
+ const char *pfx;
/* ACLs are dumped only during acl pass */
if (acl_pass)
@@ -2366,7 +2371,7 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat
return;
}
- if (AH->noTocComments)
+ if (AH->noTocComments)
return;
/*
@@ -2399,7 +2404,7 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat
te->dumpId, te->catalogId.tableoid, te->catalogId.oid);
if (te->nDeps > 0)
{
- int i;
+ int i;
ahprintf(AH, "-- Dependencies:");
for (i = 0; i < te->nDeps; i++)
@@ -2411,16 +2416,16 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat
pfx, te->tag, te->desc,
te->namespace ? te->namespace : "-",
te->owner);
- if (AH->PrintExtraTocPtr != NULL)
+ if (AH->PrintExtraTocPtr !=NULL)
(*AH->PrintExtraTocPtr) (AH, te);
ahprintf(AH, "--\n\n");
/*
* Actually print the definition.
*
- * Really crude hack for suppressing AUTHORIZATION clause of CREATE SCHEMA
- * when --no-owner mode is selected. This is ugly, but I see no other
- * good way ...
+ * Really crude hack for suppressing AUTHORIZATION clause of CREATE
+ * SCHEMA when --no-owner mode is selected. This is ugly, but I see
+ * no other good way ...
*/
if (AH->ropt && AH->ropt->noOwner && strcmp(te->desc, "SCHEMA") == 0)
{
@@ -2434,10 +2439,10 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat
/*
* If we aren't using SET SESSION AUTH to determine ownership, we must
- * instead issue an ALTER OWNER command. Ugly, since we have to
- * cons one up based on the dropStmt. We don't need this for schemas
- * (since we use CREATE SCHEMA AUTHORIZATION instead), nor for some other
- * object types.
+ * instead issue an ALTER OWNER command. Ugly, since we have to cons
+ * one up based on the dropStmt. We don't need this for schemas
+ * (since we use CREATE SCHEMA AUTHORIZATION instead), nor for some
+ * other object types.
*/
if (!ropt->noOwner && !ropt->use_setsessauth &&
strlen(te->owner) > 0 && strlen(te->dropStmt) > 0 &&
@@ -2452,7 +2457,7 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat
strcmp(te->desc, "VIEW") == 0 ||
strcmp(te->desc, "SEQUENCE") == 0))
{
- char *temp = _getObjectFromDropStmt(te->dropStmt, te->desc);
+ char *temp = _getObjectFromDropStmt(te->dropStmt, te->desc);
ahprintf(AH, "ALTER %s OWNER TO %s;\n\n", temp, fmtId(te->owner));
free(temp);
@@ -2460,7 +2465,8 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat
/*
* If it's an ACL entry, it might contain SET SESSION AUTHORIZATION
- * commands, so we can no longer assume we know the current auth setting.
+ * commands, so we can no longer assume we know the current auth
+ * setting.
*/
if (strncmp(te->desc, "ACL", 3) == 0)
{
diff --git a/src/bin/pg_dump/pg_backup_archiver.h b/src/bin/pg_dump/pg_backup_archiver.h
index 9664ab23651..c44a0ad1bf8 100644
--- a/src/bin/pg_dump/pg_backup_archiver.h
+++ b/src/bin/pg_dump/pg_backup_archiver.h
@@ -17,7 +17,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.60 2004/08/20 20:00:34 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.61 2004/08/29 05:06:53 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -79,8 +79,11 @@ typedef z_stream *z_streamp;
#define K_VERS_1_6 (( (1 * 256 + 6) * 256 + 0) * 256 + 0) /* Schema field in TOCs */
#define K_VERS_1_7 (( (1 * 256 + 7) * 256 + 0) * 256 + 0) /* File Offset size in
* header */
-#define K_VERS_1_8 (( (1 * 256 + 8) * 256 + 0) * 256 + 0) /* change interpretation of ID numbers and dependencies */
-#define K_VERS_1_9 (( (1 * 256 + 9) * 256 + 0) * 256 + 0) /* add default_with_oids tracking */
+#define K_VERS_1_8 (( (1 * 256 + 8) * 256 + 0) * 256 + 0) /* change interpretation
+ * of ID numbers and
+ * dependencies */
+#define K_VERS_1_9 (( (1 * 256 + 9) * 256 + 0) * 256 + 0) /* add default_with_oids
+ * tracking */
#define K_VERS_MAX (( (1 * 256 + 9) * 256 + 255) * 256 + 0)
@@ -149,15 +152,15 @@ typedef struct
char lastChar;
char quoteChar;
int braceDepth;
- PQExpBuffer tagBuf;
+ PQExpBuffer tagBuf;
} sqlparseInfo;
-typedef enum
+typedef enum
{
- STAGE_NONE = 0,
- STAGE_INITIALIZING,
- STAGE_PROCESSING,
- STAGE_FINALIZING
+ STAGE_NONE = 0,
+ STAGE_INITIALIZING,
+ STAGE_PROCESSING,
+ STAGE_FINALIZING
} ArchiverStage;
typedef struct _archiveHandle
@@ -258,16 +261,16 @@ typedef struct _archiveHandle
char *currUser; /* current username */
char *currSchema; /* current schema */
bool currWithOids; /* current default_with_oids setting */
-
+
void *lo_buf;
size_t lo_buf_used;
size_t lo_buf_size;
- int noTocComments;
- ArchiverStage stage;
- ArchiverStage lastErrorStage;
- struct _tocEntry *currentTE;
- struct _tocEntry *lastErrorTE;
+ int noTocComments;
+ ArchiverStage stage;
+ ArchiverStage lastErrorStage;
+ struct _tocEntry *currentTE;
+ struct _tocEntry *lastErrorTE;
} ArchiveHandle;
typedef struct _tocEntry
diff --git a/src/bin/pg_dump/pg_backup_db.c b/src/bin/pg_dump/pg_backup_db.c
index 7ae61c80825..1489bfbc167 100644
--- a/src/bin/pg_dump/pg_backup_db.c
+++ b/src/bin/pg_dump/pg_backup_db.c
@@ -5,7 +5,7 @@
* Implements the basic DB functions used by the archiver.
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.56 2004/08/28 22:52:50 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.57 2004/08/29 05:06:53 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -37,8 +37,8 @@ static void notice_processor(void *arg, const char *message);
static char *_sendSQLLine(ArchiveHandle *AH, char *qry, char *eos);
static char *_sendCopyLine(ArchiveHandle *AH, char *qry, char *eos);
-static int _isIdentChar(unsigned char c);
-static int _isDQChar(unsigned char c, int atStart);
+static int _isIdentChar(unsigned char c);
+static int _isDQChar(unsigned char c, int atStart);
#define DB_MAX_ERR_STMT 128
@@ -304,7 +304,7 @@ static int
_executeSqlCommand(ArchiveHandle *AH, PGconn *conn, PQExpBuffer qry, char *desc)
{
PGresult *res;
- char errStmt[DB_MAX_ERR_STMT];
+ char errStmt[DB_MAX_ERR_STMT];
/* fprintf(stderr, "Executing: '%s'\n\n", qry->data); */
res = PQexec(conn, qry->data);
@@ -323,15 +323,16 @@ _executeSqlCommand(ArchiveHandle *AH, PGconn *conn, PQExpBuffer qry, char *desc)
else
{
strncpy(errStmt, qry->data, DB_MAX_ERR_STMT);
- if (errStmt[DB_MAX_ERR_STMT-1] != '\0') {
- errStmt[DB_MAX_ERR_STMT-4] = '.';
- errStmt[DB_MAX_ERR_STMT-3] = '.';
- errStmt[DB_MAX_ERR_STMT-2] = '.';
- errStmt[DB_MAX_ERR_STMT-1] = '\0';
+ if (errStmt[DB_MAX_ERR_STMT - 1] != '\0')
+ {
+ errStmt[DB_MAX_ERR_STMT - 4] = '.';
+ errStmt[DB_MAX_ERR_STMT - 3] = '.';
+ errStmt[DB_MAX_ERR_STMT - 2] = '.';
+ errStmt[DB_MAX_ERR_STMT - 1] = '\0';
}
warn_or_die_horribly(AH, modulename, "%s: %s Command was: %s\n",
- desc, PQerrorMessage(AH->connection),
- errStmt);
+ desc, PQerrorMessage(AH->connection),
+ errStmt);
}
}
@@ -431,8 +432,8 @@ static char *
_sendSQLLine(ArchiveHandle *AH, char *qry, char *eos)
{
int pos = 0; /* Current position */
- char *sqlPtr;
- int consumed;
+ char *sqlPtr;
+ int consumed;
int startDT = 0;
/*
@@ -454,22 +455,24 @@ _sendSQLLine(ArchiveHandle *AH, char *qry, char *eos)
/* Loop until character consumed */
do
{
- /* If a character needs to be scanned in a different state,
- * consumed can be set to 0 to avoid advancing. Care must
- * be taken to ensure internal state is not damaged.
+ /*
+ * If a character needs to be scanned in a different state,
+ * consumed can be set to 0 to avoid advancing. Care must be
+ * taken to ensure internal state is not damaged.
*/
consumed = 1;
switch (AH->sqlparse.state)
- {
-
- case SQL_SCAN: /* Default state == 0, set in _allocAH */
+ {
+
+ case SQL_SCAN: /* Default state == 0, set in _allocAH */
if (qry[pos] == ';' && AH->sqlparse.braceDepth == 0)
{
- /* We've got the end of a statement.
- * Send It & reset the buffer.
+ /*
+ * We've got the end of a statement. Send It &
+ * reset the buffer.
*/
-
+
/*
* fprintf(stderr, " sending: '%s'\n\n",
* AH->sqlBuf->data);
@@ -477,28 +480,30 @@ _sendSQLLine(ArchiveHandle *AH, char *qry, char *eos)
ExecuteSqlCommand(AH, AH->sqlBuf, "could not execute query", false);
resetPQExpBuffer(AH->sqlBuf);
AH->sqlparse.lastChar = '\0';
-
+
/*
- * Remove any following newlines - so that embedded
- * COPY commands don't get a starting newline.
+ * Remove any following newlines - so that
+ * embedded COPY commands don't get a starting
+ * newline.
*/
pos++;
for (; pos < (eos - qry) && qry[pos] == '\n'; pos++);
-
+
/* We've got our line, so exit */
return qry + pos;
}
else
{
- /*
- * Look for normal boring quote chars, or dollar-quotes. We make
- * the assumption that $-quotes will not have an ident character
+ /*
+ * Look for normal boring quote chars, or
+ * dollar-quotes. We make the assumption that
+ * $-quotes will not have an ident character
* before them in all pg_dump output.
*/
- if ( qry[pos] == '"'
- || qry[pos] == '\''
- || ( qry[pos] == '$' && _isIdentChar(AH->sqlparse.lastChar) == 0 )
- )
+ if (qry[pos] == '"'
+ || qry[pos] == '\''
+ || (qry[pos] == '$' && _isIdentChar(AH->sqlparse.lastChar) == 0)
+ )
{
/* fprintf(stderr,"[startquote]\n"); */
AH->sqlparse.state = SQL_IN_QUOTE;
@@ -524,18 +529,20 @@ _sendSQLLine(ArchiveHandle *AH, char *qry, char *eos)
AH->sqlparse.braceDepth++;
else if (qry[pos] == ')')
AH->sqlparse.braceDepth--;
-
+
AH->sqlparse.lastChar = qry[pos];
}
break;
-
+
case SQL_IN_DOLLARTAG:
-
- /* Like a quote, we look for a closing char *but* we only
- * allow a very limited set of contained chars, and no escape chars.
- * If invalid chars are found, we abort tag processing.
+
+ /*
+ * Like a quote, we look for a closing char *but* we
+ * only allow a very limited set of contained chars,
+ * and no escape chars. If invalid chars are found, we
+ * abort tag processing.
*/
-
+
if (qry[pos] == '$')
{
/* fprintf(stderr,"[endquote]\n"); */
@@ -545,18 +552,21 @@ _sendSQLLine(ArchiveHandle *AH, char *qry, char *eos)
}
else
{
- if ( _isDQChar(qry[pos], startDT) )
+ if (_isDQChar(qry[pos], startDT))
{
/* Valid, so add */
appendPQExpBufferChar(AH->sqlparse.tagBuf, qry[pos]);
}
else
{
- /* Jump back to 'scan' state, we're not really in a tag,
- * and valid tag chars do not include the various chars
- * we look for in this state machine, so it's safe to just
- * jump from this state back to SCAN. We set consumed = 0
- * so that this char gets rescanned in new state.
+ /*
+ * Jump back to 'scan' state, we're not really
+ * in a tag, and valid tag chars do not
+ * include the various chars we look for in
+ * this state machine, so it's safe to just
+ * jump from this state back to SCAN. We set
+ * consumed = 0 so that this char gets
+ * rescanned in new state.
*/
destroyPQExpBuffer(AH->sqlparse.tagBuf);
AH->sqlparse.state = SQL_SCAN;
@@ -565,32 +575,35 @@ _sendSQLLine(ArchiveHandle *AH, char *qry, char *eos)
}
startDT = 0;
break;
-
+
case SQL_IN_DOLLARQUOTE:
+
/*
- * Comparing the entire string backwards each time is NOT efficient,
- * but dollar quotes in pg_dump are small and the code is a lot simpler.
+ * Comparing the entire string backwards each time is
+ * NOT efficient, but dollar quotes in pg_dump are
+ * small and the code is a lot simpler.
*/
sqlPtr = AH->sqlBuf->data + AH->sqlBuf->len - AH->sqlparse.tagBuf->len;
-
- if (strncmp(AH->sqlparse.tagBuf->data, sqlPtr, AH->sqlparse.tagBuf->len) == 0) {
+
+ if (strncmp(AH->sqlparse.tagBuf->data, sqlPtr, AH->sqlparse.tagBuf->len) == 0)
+ {
/* End of $-quote */
AH->sqlparse.state = SQL_SCAN;
destroyPQExpBuffer(AH->sqlparse.tagBuf);
}
break;
-
+
case SQL_IN_SQL_COMMENT:
if (qry[pos] == '\n')
AH->sqlparse.state = SQL_SCAN;
break;
-
+
case SQL_IN_EXT_COMMENT:
if (AH->sqlparse.lastChar == '*' && qry[pos] == '/')
AH->sqlparse.state = SQL_SCAN;
break;
-
+
case SQL_IN_QUOTE:
if (!AH->sqlparse.backSlash && AH->sqlparse.quoteChar == qry[pos])
@@ -600,7 +613,7 @@ _sendSQLLine(ArchiveHandle *AH, char *qry, char *eos)
}
else
{
-
+
if (qry[pos] == '\\')
{
if (AH->sqlparse.lastChar == '\\')
@@ -612,13 +625,13 @@ _sendSQLLine(ArchiveHandle *AH, char *qry, char *eos)
AH->sqlparse.backSlash = 0;
}
break;
-
+
}
} while (consumed == 0);
- AH->sqlparse.lastChar = qry[pos];
- /* fprintf(stderr, "\n"); */
+ AH->sqlparse.lastChar = qry[pos];
+ /* fprintf(stderr, "\n"); */
}
/*
@@ -804,7 +817,7 @@ InsertBlobXref(ArchiveHandle *AH, Oid old, Oid new)
PQExpBuffer qry = createPQExpBuffer();
appendPQExpBuffer(qry,
- "INSERT INTO %s(oldOid, newOid) VALUES ('%u', '%u')",
+ "INSERT INTO %s(oldOid, newOid) VALUES ('%u', '%u')",
BLOB_XREF_TABLE, old, new);
ExecuteSqlCommand(AH, qry, "could not create large object cross-reference entry", true);
@@ -864,37 +877,33 @@ CommitTransactionXref(ArchiveHandle *AH)
destroyPQExpBuffer(qry);
}
-static int _isIdentChar(unsigned char c)
+static int
+_isIdentChar(unsigned char c)
{
- if ( (c >= 'a' && c <= 'z')
- || (c >= 'A' && c <= 'Z')
- || (c >= '0' && c <= '9')
- || (c == '_')
- || (c == '$')
- || (c >= (unsigned char)'\200') /* no need to check <= \377 */
- )
- {
+ if ((c >= 'a' && c <= 'z')
+ || (c >= 'A' && c <= 'Z')
+ || (c >= '0' && c <= '9')
+ || (c == '_')
+ || (c == '$')
+ || (c >= (unsigned char) '\200') /* no need to check <=
+ * \377 */
+ )
return 1;
- }
else
- {
return 0;
- }
}
-static int _isDQChar(unsigned char c, int atStart)
+static int
+_isDQChar(unsigned char c, int atStart)
{
- if ( (c >= 'a' && c <= 'z')
- || (c >= 'A' && c <= 'Z')
- || (c == '_')
- || (atStart == 0 && c >= '0' && c <= '9')
- || (c >= (unsigned char)'\200') /* no need to check <= \377 */
- )
- {
+ if ((c >= 'a' && c <= 'z')
+ || (c >= 'A' && c <= 'Z')
+ || (c == '_')
+ || (atStart == 0 && c >= '0' && c <= '9')
+ || (c >= (unsigned char) '\200') /* no need to check <=
+ * \377 */
+ )
return 1;
- }
else
- {
return 0;
- }
}
diff --git a/src/bin/pg_dump/pg_backup_tar.c b/src/bin/pg_dump/pg_backup_tar.c
index f472c9de02d..c01ff2066d1 100644
--- a/src/bin/pg_dump/pg_backup_tar.c
+++ b/src/bin/pg_dump/pg_backup_tar.c
@@ -16,7 +16,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.43 2004/05/07 00:24:58 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.44 2004/08/29 05:06:53 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -160,7 +160,7 @@ InitArchiveFmt_Tar(ArchiveHandle *AH)
AH->formatData = (void *) ctx;
ctx->filePos = 0;
ctx->isSpecialScript = 0;
-
+
/* Initialize LO buffering */
AH->lo_buf_size = LOBBUFSIZE;
AH->lo_buf = (void *) malloc(LOBBUFSIZE);
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 4baecec11d5..fce0b6e7767 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -12,7 +12,7 @@
* by PostgreSQL
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.385 2004/08/29 04:13:01 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.386 2004/08/29 05:06:53 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -102,14 +102,14 @@ char g_opaque_type[10]; /* name for the opaque type */
char g_comment_start[10];
char g_comment_end[10];
-static const CatalogId nilCatalogId = { 0, 0 };
+static const CatalogId nilCatalogId = {0, 0};
/* these are to avoid passing around info for findNamespace() */
static NamespaceInfo *g_namespaces;
static int g_numNamespaces;
/* flag to turn on/off dollar quoting */
-static int disable_dollar_quoting = 0;
+static int disable_dollar_quoting = 0;
static void help(const char *progname);
@@ -118,8 +118,8 @@ static void dumpTableData(Archive *fout, TableDataInfo *tdinfo);
static void dumpComment(Archive *fout, const char *target,
const char *namespace, const char *owner,
CatalogId catalogId, int subid, DumpId dumpId);
-static int findComments(Archive *fout, Oid classoid, Oid objoid,
- CommentItem **items);
+static int findComments(Archive *fout, Oid classoid, Oid objoid,
+ CommentItem **items);
static int collectComments(Archive *fout, CommentItem **items);
static void dumpDumpableObject(Archive *fout, DumpableObject *dobj);
static void dumpNamespace(Archive *fout, NamespaceInfo *nspinfo);
@@ -152,7 +152,7 @@ static void getDependencies(void);
static void getDomainConstraints(TypeInfo *tinfo);
static void getTableData(TableInfo *tblinfo, int numTables, bool oids);
static char *format_function_signature(FuncInfo *finfo, char **argnames,
- bool honor_quotes);
+ bool honor_quotes);
static const char *convertRegProcReference(const char *proc);
static const char *convertOperatorReference(const char *opr);
static Oid findLastBuiltinOid_V71(const char *);
@@ -170,7 +170,7 @@ static const char *getAttrName(int attrnum, TableInfo *tblInfo);
static const char *fmtCopyColumnList(const TableInfo *ti);
static void do_sql_command(PGconn *conn, const char *query);
static void check_sql_result(PGresult *res, PGconn *conn, const char *query,
- ExecStatusType expected);
+ ExecStatusType expected);
int
@@ -582,9 +582,10 @@ main(int argc, char **argv)
*
* In 7.3 or later, we can rely on dependency information to help us
* determine a safe order, so the initial sort is mostly for cosmetic
- * purposes: we sort by name to ensure that logically identical schemas
- * will dump identically. Before 7.3 we don't have dependencies and
- * we use OID ordering as an (unreliable) guide to creation order.
+ * purposes: we sort by name to ensure that logically identical
+ * schemas will dump identically. Before 7.3 we don't have
+ * dependencies and we use OID ordering as an (unreliable) guide to
+ * creation order.
*/
getDumpableObjects(&dobjs, &numObjs);
@@ -596,8 +597,8 @@ main(int argc, char **argv)
sortDumpableObjects(dobjs, numObjs);
/*
- * Create archive TOC entries for all the objects to be dumped,
- * in a safe order.
+ * Create archive TOC entries for all the objects to be dumped, in a
+ * safe order.
*/
if (g_fout->verbose)
@@ -616,9 +617,7 @@ main(int argc, char **argv)
/* Now the rearrangeable objects. */
for (i = 0; i < numObjs; i++)
- {
dumpDumpableObject(g_fout, dobjs[i]);
- }
if (g_fout->verbose)
dumpTimestamp(g_fout, "Completed on");
@@ -820,15 +819,15 @@ dumpTableData_copy(Archive *fout, void *dcontext)
if (oids && hasoids)
{
appendPQExpBuffer(q, "COPY %s %s WITH OIDS TO stdout;",
- fmtQualifiedId(tbinfo->dobj.namespace->dobj.name,
- classname),
+ fmtQualifiedId(tbinfo->dobj.namespace->dobj.name,
+ classname),
column_list);
}
else
{
appendPQExpBuffer(q, "COPY %s %s TO stdout;",
- fmtQualifiedId(tbinfo->dobj.namespace->dobj.name,
- classname),
+ fmtQualifiedId(tbinfo->dobj.namespace->dobj.name,
+ classname),
column_list);
}
res = PQexec(g_conn, q->data);
@@ -943,15 +942,15 @@ dumpTableData_insert(Archive *fout, void *dcontext)
{
appendPQExpBuffer(q, "DECLARE _pg_dump_cursor CURSOR FOR "
"SELECT * FROM ONLY %s",
- fmtQualifiedId(tbinfo->dobj.namespace->dobj.name,
- classname));
+ fmtQualifiedId(tbinfo->dobj.namespace->dobj.name,
+ classname));
}
else
{
appendPQExpBuffer(q, "DECLARE _pg_dump_cursor CURSOR FOR "
"SELECT * FROM %s",
- fmtQualifiedId(tbinfo->dobj.namespace->dobj.name,
- classname));
+ fmtQualifiedId(tbinfo->dobj.namespace->dobj.name,
+ classname));
}
res = PQexec(g_conn, q->data);
@@ -1089,7 +1088,7 @@ dumpTableData(Archive *fout, TableDataInfo *tdinfo)
fmtId(tbinfo->dobj.name));
appendPQExpBuffer(copyBuf, "%s %sFROM stdin;\n",
fmtCopyColumnList(tbinfo),
- (tdinfo->oids && tbinfo->hasoids) ? "WITH OIDS " : "");
+ (tdinfo->oids && tbinfo->hasoids) ? "WITH OIDS " : "");
copyStmt = copyBuf->data;
}
else
@@ -1135,6 +1134,7 @@ getTableData(TableInfo *tblinfo, int numTables, bool oids)
tdinfo = (TableDataInfo *) malloc(sizeof(TableDataInfo));
tdinfo->dobj.objType = DO_TABLE_DATA;
+
/*
* Note: use tableoid 0 so that this object won't be mistaken
* for something that pg_depend entries apply to.
@@ -1188,7 +1188,7 @@ dumpDatabase(Archive *AH)
if (g_fout->remoteVersion >= 80000)
{
appendPQExpBuffer(dbQry, "SELECT tableoid, oid, "
- "(SELECT usename FROM pg_user WHERE usesysid = datdba) as dba, "
+ "(SELECT usename FROM pg_user WHERE usesysid = datdba) as dba, "
"pg_encoding_to_char(encoding) as encoding, "
"(SELECT spcname FROM pg_tablespace t WHERE t.oid = dattablespace) as tablespace "
"FROM pg_database "
@@ -1198,7 +1198,7 @@ dumpDatabase(Archive *AH)
else if (g_fout->remoteVersion >= 70100)
{
appendPQExpBuffer(dbQry, "SELECT tableoid, oid, "
- "(SELECT usename FROM pg_user WHERE usesysid = datdba) as dba, "
+ "(SELECT usename FROM pg_user WHERE usesysid = datdba) as dba, "
"pg_encoding_to_char(encoding) as encoding, "
"NULL as tablespace "
"FROM pg_database "
@@ -1210,7 +1210,7 @@ dumpDatabase(Archive *AH)
appendPQExpBuffer(dbQry, "SELECT "
"(SELECT oid FROM pg_class WHERE relname = 'pg_database') AS tableoid, "
"oid, "
- "(SELECT usename FROM pg_user WHERE usesysid = datdba) as dba, "
+ "(SELECT usename FROM pg_user WHERE usesysid = datdba) as dba, "
"pg_encoding_to_char(encoding) as encoding, "
"NULL as tablespace "
"FROM pg_database "
@@ -1257,9 +1257,7 @@ dumpDatabase(Archive *AH)
appendStringLiteral(creaQry, encoding, true);
}
if (strlen(tablespace) > 0 && strcmp(tablespace, "pg_default") != 0)
- {
appendPQExpBuffer(creaQry, " TABLESPACE = %s", fmtId(tablespace));
- }
appendPQExpBuffer(creaQry, ";\n");
appendPQExpBuffer(delQry, "DROP DATABASE %s;\n",
@@ -1303,11 +1301,11 @@ dumpDatabase(Archive *AH)
static void
dumpTimestamp(Archive *AH, char *msg)
{
- char buf[256];
- time_t now = time(NULL);
+ char buf[256];
+ time_t now = time(NULL);
if (strftime(buf, 256, "%Y-%m-%d %H:%M:%S %Z", localtime(&now)) != 0)
- {
+ {
PQExpBuffer qry = createPQExpBuffer();
appendPQExpBuffer(qry, "-- ");
@@ -1528,15 +1526,15 @@ getNamespaces(int *numNamespaces)
if (g_fout->remoteVersion >= 80000)
{
appendPQExpBuffer(query, "SELECT tableoid, oid, nspname, "
- "(select usename from pg_user where nspowner = usesysid) as usename, "
+ "(select usename from pg_user where nspowner = usesysid) as usename, "
"nspacl, "
- "(SELECT spcname FROM pg_tablespace t WHERE t.oid = nsptablespace) AS nsptablespace "
+ "(SELECT spcname FROM pg_tablespace t WHERE t.oid = nsptablespace) AS nsptablespace "
"FROM pg_namespace");
}
else
{
appendPQExpBuffer(query, "SELECT tableoid, oid, nspname, "
- "(select usename from pg_user where nspowner = usesysid) as usename, "
+ "(select usename from pg_user where nspowner = usesysid) as usename, "
"nspacl, NULL AS nsptablespace "
"FROM pg_namespace");
}
@@ -1689,7 +1687,7 @@ getTypes(int *numTypes)
"typnamespace, "
"(select usename from pg_user where typowner = usesysid) as usename, "
"typinput::oid as typinput, "
- "typoutput::oid as typoutput, typelem, typrelid, "
+ "typoutput::oid as typoutput, typelem, typrelid, "
"CASE WHEN typrelid = 0 THEN ' '::\"char\" "
"ELSE (SELECT relkind FROM pg_class WHERE oid = typrelid) END as typrelkind, "
"typtype, typisdefined "
@@ -1701,7 +1699,7 @@ getTypes(int *numTypes)
"0::oid as typnamespace, "
"(select usename from pg_user where typowner = usesysid) as usename, "
"typinput::oid as typinput, "
- "typoutput::oid as typoutput, typelem, typrelid, "
+ "typoutput::oid as typoutput, typelem, typrelid, "
"CASE WHEN typrelid = 0 THEN ' '::\"char\" "
"ELSE (SELECT relkind FROM pg_class WHERE oid = typrelid) END as typrelkind, "
"typtype, typisdefined "
@@ -1715,7 +1713,7 @@ getTypes(int *numTypes)
"0::oid as typnamespace, "
"(select usename from pg_user where typowner = usesysid) as usename, "
"typinput::oid as typinput, "
- "typoutput::oid as typoutput, typelem, typrelid, "
+ "typoutput::oid as typoutput, typelem, typrelid, "
"CASE WHEN typrelid = 0 THEN ' '::\"char\" "
"ELSE (SELECT relkind FROM pg_class WHERE oid = typrelid) END as typrelkind, "
"typtype, typisdefined "
@@ -1753,7 +1751,7 @@ getTypes(int *numTypes)
AssignDumpId(&tinfo[i].dobj);
tinfo[i].dobj.name = strdup(PQgetvalue(res, i, i_typname));
tinfo[i].dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_typnamespace)),
- tinfo[i].dobj.catId.oid);
+ tinfo[i].dobj.catId.oid);
tinfo[i].usename = strdup(PQgetvalue(res, i, i_usename));
tinfo[i].typinput = atooid(PQgetvalue(res, i, i_typinput));
typoutput = atooid(PQgetvalue(res, i, i_typoutput));
@@ -1764,7 +1762,7 @@ getTypes(int *numTypes)
/*
* If it's a table's rowtype, use special type code to facilitate
- * sorting into the desired order. (We don't want to consider it
+ * sorting into the desired order. (We don't want to consider it
* an ordinary type because that would bring the table up into the
* datatype part of the dump order.)
*/
@@ -1795,9 +1793,9 @@ getTypes(int *numTypes)
/*
* Make sure there are dependencies from the type to its input and
- * output functions. (We don't worry about typsend, typreceive, or
- * typanalyze since those are only valid in 7.4 and later, wherein
- * the standard dependency mechanism will pick them up.)
+ * output functions. (We don't worry about typsend, typreceive,
+ * or typanalyze since those are only valid in 7.4 and later,
+ * wherein the standard dependency mechanism will pick them up.)
*/
funcInfo = findFuncByOid(tinfo[i].typinput);
if (funcInfo)
@@ -1902,7 +1900,7 @@ getOperators(int *numOprs)
AssignDumpId(&oprinfo[i].dobj);
oprinfo[i].dobj.name = strdup(PQgetvalue(res, i, i_oprname));
oprinfo[i].dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_oprnamespace)),
- oprinfo[i].dobj.catId.oid);
+ oprinfo[i].dobj.catId.oid);
oprinfo[i].usename = strdup(PQgetvalue(res, i, i_usename));
oprinfo[i].oprcode = atooid(PQgetvalue(res, i, i_oprcode));
@@ -1932,7 +1930,7 @@ getConversions(int *numConversions)
int ntups;
int i;
PQExpBuffer query = createPQExpBuffer();
- ConvInfo *convinfo;
+ ConvInfo *convinfo;
int i_tableoid;
int i_oid;
int i_conname;
@@ -1940,7 +1938,8 @@ getConversions(int *numConversions)
int i_usename;
/* Conversions didn't exist pre-7.3 */
- if (g_fout->remoteVersion < 70300) {
+ if (g_fout->remoteVersion < 70300)
+ {
*numConversions = 0;
return NULL;
}
@@ -1955,7 +1954,7 @@ getConversions(int *numConversions)
appendPQExpBuffer(query, "SELECT tableoid, oid, conname, "
"connamespace, "
- "(select usename from pg_user where conowner = usesysid) as usename "
+ "(select usename from pg_user where conowner = usesysid) as usename "
"FROM pg_conversion");
res = PQexec(g_conn, query->data);
@@ -1980,7 +1979,7 @@ getConversions(int *numConversions)
AssignDumpId(&convinfo[i].dobj);
convinfo[i].dobj.name = strdup(PQgetvalue(res, i, i_conname));
convinfo[i].dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_connamespace)),
- convinfo[i].dobj.catId.oid);
+ convinfo[i].dobj.catId.oid);
convinfo[i].usename = strdup(PQgetvalue(res, i, i_usename));
}
@@ -2066,7 +2065,7 @@ getOpclasses(int *numOpclasses)
AssignDumpId(&opcinfo[i].dobj);
opcinfo[i].dobj.name = strdup(PQgetvalue(res, i, i_opcname));
opcinfo[i].dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_opcnamespace)),
- opcinfo[i].dobj.catId.oid);
+ opcinfo[i].dobj.catId.oid);
opcinfo[i].usename = strdup(PQgetvalue(res, i, i_usename));
if (g_fout->remoteVersion >= 70300)
@@ -2173,16 +2172,17 @@ getAggregates(int *numAggs)
AssignDumpId(&agginfo[i].aggfn.dobj);
agginfo[i].aggfn.dobj.name = strdup(PQgetvalue(res, i, i_aggname));
agginfo[i].aggfn.dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_aggnamespace)),
- agginfo[i].aggfn.dobj.catId.oid);
+ agginfo[i].aggfn.dobj.catId.oid);
agginfo[i].aggfn.usename = strdup(PQgetvalue(res, i, i_usename));
if (strlen(agginfo[i].aggfn.usename) == 0)
write_msg(NULL, "WARNING: owner of aggregate function \"%s\" appears to be invalid\n",
agginfo[i].aggfn.dobj.name);
- agginfo[i].aggfn.lang = InvalidOid; /* not currently interesting */
+ agginfo[i].aggfn.lang = InvalidOid; /* not currently
+ * interesting */
agginfo[i].aggfn.nargs = 1;
agginfo[i].aggfn.argtypes = (Oid *) malloc(sizeof(Oid));
agginfo[i].aggfn.argtypes[0] = atooid(PQgetvalue(res, i, i_aggbasetype));
- agginfo[i].aggfn.prorettype = InvalidOid; /* not saved */
+ agginfo[i].aggfn.prorettype = InvalidOid; /* not saved */
agginfo[i].aggfn.proacl = strdup(PQgetvalue(res, i, i_aggacl));
agginfo[i].anybasetype = false; /* computed when it's dumped */
agginfo[i].fmtbasetype = NULL; /* computed when it's dumped */
@@ -2293,7 +2293,7 @@ getFuncs(int *numFuncs)
AssignDumpId(&finfo[i].dobj);
finfo[i].dobj.name = strdup(PQgetvalue(res, i, i_proname));
finfo[i].dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_pronamespace)),
- finfo[i].dobj.catId.oid);
+ finfo[i].dobj.catId.oid);
finfo[i].usename = strdup(PQgetvalue(res, i, i_usename));
finfo[i].lang = atooid(PQgetvalue(res, i, i_prolang));
finfo[i].prorettype = atooid(PQgetvalue(res, i, i_prorettype));
@@ -2427,7 +2427,7 @@ getTables(int *numTables)
else if (g_fout->remoteVersion >= 70200)
{
appendPQExpBuffer(query,
- "SELECT tableoid, oid, relname, relacl, relkind, "
+ "SELECT tableoid, oid, relname, relacl, relkind, "
"0::oid as relnamespace, "
"(select usename from pg_user where relowner = usesysid) as usename, "
"relchecks, reltriggers, "
@@ -2444,7 +2444,7 @@ getTables(int *numTables)
{
/* all tables have oids in 7.1 */
appendPQExpBuffer(query,
- "SELECT tableoid, oid, relname, relacl, relkind, "
+ "SELECT tableoid, oid, relname, relacl, relkind, "
"0::oid as relnamespace, "
"(select usename from pg_user where relowner = usesysid) as usename, "
"relchecks, reltriggers, "
@@ -2530,7 +2530,7 @@ getTables(int *numTables)
AssignDumpId(&tblinfo[i].dobj);
tblinfo[i].dobj.name = strdup(PQgetvalue(res, i, i_relname));
tblinfo[i].dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_relnamespace)),
- tblinfo[i].dobj.catId.oid);
+ tblinfo[i].dobj.catId.oid);
tblinfo[i].usename = strdup(PQgetvalue(res, i, i_usename));
tblinfo[i].relacl = strdup(PQgetvalue(res, i, i_relacl));
tblinfo[i].relkind = *(PQgetvalue(res, i, i_relkind));
@@ -2580,8 +2580,8 @@ getTables(int *numTables)
resetPQExpBuffer(lockquery);
appendPQExpBuffer(lockquery,
"LOCK TABLE %s IN ACCESS SHARE MODE",
- fmtQualifiedId(tblinfo[i].dobj.namespace->dobj.name,
- tblinfo[i].dobj.name));
+ fmtQualifiedId(tblinfo[i].dobj.namespace->dobj.name,
+ tblinfo[i].dobj.name));
do_sql_command(g_conn, lockquery->data);
}
@@ -2593,8 +2593,9 @@ getTables(int *numTables)
/*
* If the user is attempting to dump a specific table, check to ensure
- * that the specified table actually exists. (This is a bit simplistic
- * since we don't fully check the combination of -n and -t switches.)
+ * that the specified table actually exists. (This is a bit
+ * simplistic since we don't fully check the combination of -n and -t
+ * switches.)
*/
if (selectTableName)
{
@@ -2721,9 +2722,9 @@ getIndexes(TableInfo tblinfo[], int numTables)
/*
* The point of the messy-looking outer join is to find a
* constraint that is related by an internal dependency link to
- * the index. If we find one, create a CONSTRAINT entry linked
- * to the INDEX entry. We assume an index won't have more than
- * one internal dependency.
+ * the index. If we find one, create a CONSTRAINT entry linked to
+ * the INDEX entry. We assume an index won't have more than one
+ * internal dependency.
*/
resetPQExpBuffer(query);
if (g_fout->remoteVersion >= 80000)
@@ -2737,7 +2738,7 @@ getIndexes(TableInfo tblinfo[], int numTables)
"c.contype, c.conname, "
"c.tableoid as contableoid, "
"c.oid as conoid, "
- "(SELECT spcname FROM pg_catalog.pg_tablespace s WHERE s.oid = t.reltablespace) as tablespace "
+ "(SELECT spcname FROM pg_catalog.pg_tablespace s WHERE s.oid = t.reltablespace) as tablespace "
"FROM pg_catalog.pg_index i "
"JOIN pg_catalog.pg_class t ON (t.oid = i.indexrelid) "
"LEFT JOIN pg_catalog.pg_depend d "
@@ -2781,7 +2782,7 @@ getIndexes(TableInfo tblinfo[], int numTables)
appendPQExpBuffer(query,
"SELECT t.tableoid, t.oid, "
"t.relname as indexname, "
- "pg_get_indexdef(i.indexrelid) as indexdef, "
+ "pg_get_indexdef(i.indexrelid) as indexdef, "
"t.relnatts as indnkeys, "
"i.indkey, false as indisclustered, "
"CASE WHEN i.indisprimary THEN 'p'::char "
@@ -2803,7 +2804,7 @@ getIndexes(TableInfo tblinfo[], int numTables)
"(SELECT oid FROM pg_class WHERE relname = 'pg_class') AS tableoid, "
"t.oid, "
"t.relname as indexname, "
- "pg_get_indexdef(i.indexrelid) as indexdef, "
+ "pg_get_indexdef(i.indexrelid) as indexdef, "
"t.relnatts as indnkeys, "
"i.indkey, false as indisclustered, "
"CASE WHEN i.indisprimary THEN 'p'::char "
@@ -2858,11 +2859,11 @@ getIndexes(TableInfo tblinfo[], int numTables)
/*
* In pre-7.4 releases, indkeys may contain more entries than
* indnkeys says (since indnkeys will be 1 for a functional
- * index). We don't actually care about this case since we don't
- * examine indkeys except for indexes associated with PRIMARY
- * and UNIQUE constraints, which are never functional indexes.
- * But we have to allocate enough space to keep parseOidArray
- * from complaining.
+ * index). We don't actually care about this case since we
+ * don't examine indkeys except for indexes associated with
+ * PRIMARY and UNIQUE constraints, which are never functional
+ * indexes. But we have to allocate enough space to keep
+ * parseOidArray from complaining.
*/
indxinfo[j].indkeys = (Oid *) malloc(INDEX_MAX_KEYS * sizeof(Oid));
parseOidArray(PQgetvalue(res, j, i_indkey),
@@ -2961,7 +2962,7 @@ getConstraints(TableInfo tblinfo[], int numTables)
resetPQExpBuffer(query);
appendPQExpBuffer(query,
"SELECT tableoid, oid, conname, "
- "pg_catalog.pg_get_constraintdef(oid) as condef "
+ "pg_catalog.pg_get_constraintdef(oid) as condef "
"FROM pg_catalog.pg_constraint "
"WHERE conrelid = '%u'::pg_catalog.oid "
"AND contype = 'f'",
@@ -3024,8 +3025,8 @@ getDomainConstraints(TypeInfo *tinfo)
return;
/*
- * select appropriate schema to ensure names in constraint are properly
- * qualified
+ * select appropriate schema to ensure names in constraint are
+ * properly qualified
*/
selectSourceSchema(tinfo->dobj.namespace->dobj.name);
@@ -3033,7 +3034,7 @@ getDomainConstraints(TypeInfo *tinfo)
if (g_fout->remoteVersion >= 70400)
appendPQExpBuffer(query, "SELECT tableoid, oid, conname, "
- "pg_catalog.pg_get_constraintdef(oid) AS consrc "
+ "pg_catalog.pg_get_constraintdef(oid) AS consrc "
"FROM pg_catalog.pg_constraint "
"WHERE contypid = '%u'::pg_catalog.oid "
"ORDER BY conname",
@@ -3076,9 +3077,10 @@ getDomainConstraints(TypeInfo *tinfo)
constrinfo[i].conindex = 0;
constrinfo[i].coninherited = false;
constrinfo[i].separate = false;
+
/*
- * Make the domain depend on the constraint, ensuring it won't
- * be output till any constraint dependencies are OK.
+ * Make the domain depend on the constraint, ensuring it won't be
+ * output till any constraint dependencies are OK.
*/
addObjectDependency(&tinfo->dobj,
constrinfo[i].dobj.dumpId);
@@ -3149,7 +3151,7 @@ getRules(int *numRules)
for (i = 0; i < ntups; i++)
{
- Oid ruletableoid;
+ Oid ruletableoid;
ruleinfo[i].dobj.objType = DO_RULE;
ruleinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid));
@@ -3164,10 +3166,10 @@ getRules(int *numRules)
if (ruleinfo[i].ruletable)
{
/*
- * If the table is a view, force its ON SELECT rule to be sorted
- * before the view itself --- this ensures that any dependencies
- * for the rule affect the table's positioning. Other rules
- * are forced to appear after their table.
+ * If the table is a view, force its ON SELECT rule to be
+ * sorted before the view itself --- this ensures that any
+ * dependencies for the rule affect the table's positioning.
+ * Other rules are forced to appear after their table.
*/
if (ruleinfo[i].ruletable->relkind == RELKIND_VIEW &&
ruleinfo[i].ev_type == '1' && ruleinfo[i].is_instead)
@@ -3245,7 +3247,7 @@ getTriggers(TableInfo tblinfo[], int numTables)
"tgfoid::pg_catalog.regproc as tgfname, "
"tgtype, tgnargs, tgargs, "
"tgisconstraint, tgconstrname, tgdeferrable, "
- "tgconstrrelid, tginitdeferred, tableoid, oid, "
+ "tgconstrrelid, tginitdeferred, tableoid, oid, "
"tgconstrrelid::pg_catalog.regclass as tgconstrrelname "
"from pg_catalog.pg_trigger t "
"where tgrelid = '%u'::pg_catalog.oid "
@@ -3262,7 +3264,7 @@ getTriggers(TableInfo tblinfo[], int numTables)
"SELECT tgname, tgfoid::regproc as tgfname, "
"tgtype, tgnargs, tgargs, "
"tgisconstraint, tgconstrname, tgdeferrable, "
- "tgconstrrelid, tginitdeferred, tableoid, oid, "
+ "tgconstrrelid, tginitdeferred, tableoid, oid, "
"(select relname from pg_class where oid = tgconstrrelid) "
" as tgconstrrelname "
"from pg_trigger "
@@ -3449,9 +3451,10 @@ getProcLangs(int *numProcLangs)
planginfo[i].lanvalidator = InvalidOid;
planginfo[i].lanacl = strdup("{=U}");
+
/*
- * We need to make a dependency to ensure the function will
- * be dumped first. (In 7.3 and later the regular dependency
+ * We need to make a dependency to ensure the function will be
+ * dumped first. (In 7.3 and later the regular dependency
* mechanism will handle this for us.)
*/
funcInfo = findFuncByOid(planginfo[i].lanplcallfoid);
@@ -3506,7 +3509,7 @@ getCasts(int *numCasts)
"FROM pg_type t1, pg_type t2, pg_proc p "
"WHERE p.pronargs = 1 AND "
"p.proargtypes[0] = t1.oid AND "
- "p.prorettype = t2.oid AND p.proname = t2.typname "
+ "p.prorettype = t2.oid AND p.proname = t2.typname "
"ORDER BY 3,4");
}
@@ -3528,7 +3531,7 @@ getCasts(int *numCasts)
for (i = 0; i < ntups; i++)
{
- PQExpBufferData namebuf;
+ PQExpBufferData namebuf;
TypeInfo *sTypeInfo;
TypeInfo *tTypeInfo;
@@ -3557,8 +3560,8 @@ getCasts(int *numCasts)
if (OidIsValid(castinfo[i].castfunc))
{
/*
- * We need to make a dependency to ensure the function will
- * be dumped first. (In 7.3 and later the regular dependency
+ * We need to make a dependency to ensure the function will be
+ * dumped first. (In 7.3 and later the regular dependency
* mechanism will handle this for us.)
*/
FuncInfo *funcInfo;
@@ -3741,7 +3744,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
tbinfo->attislocal[j] = (PQgetvalue(res, j, i_attislocal)[0] == 't');
tbinfo->attisserial[j] = false; /* fix below */
tbinfo->notnull[j] = (PQgetvalue(res, j, i_attnotnull)[0] == 't');
- tbinfo->attrdefs[j] = NULL; /* fix below */
+ tbinfo->attrdefs[j] = NULL; /* fix below */
if (PQgetvalue(res, j, i_atthasdef)[0] == 't')
hasdefaults = true;
/* these flags will be set in flagInhAttrs() */
@@ -3808,7 +3811,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
for (j = 0; j < numDefaults; j++)
{
- int adnum;
+ int adnum;
attrdefs[j].dobj.objType = DO_ATTRDEF;
attrdefs[j].dobj.catId.tableoid = atooid(PQgetvalue(res, j, 0));
@@ -3824,9 +3827,9 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
/*
* Defaults on a VIEW must always be dumped as separate
* ALTER TABLE commands. Defaults on regular tables are
- * dumped as part of the CREATE TABLE if possible. To check
- * if it's safe, we mark the default as needing to appear
- * before the CREATE.
+ * dumped as part of the CREATE TABLE if possible. To
+ * check if it's safe, we mark the default as needing to
+ * appear before the CREATE.
*/
if (tbinfo->relkind == RELKIND_VIEW)
{
@@ -3869,7 +3872,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
if (g_fout->remoteVersion >= 70400)
{
appendPQExpBuffer(q, "SELECT tableoid, oid, conname, "
- "pg_catalog.pg_get_constraintdef(oid) AS consrc "
+ "pg_catalog.pg_get_constraintdef(oid) AS consrc "
"FROM pg_catalog.pg_constraint "
"WHERE conrelid = '%u'::pg_catalog.oid "
" AND contype = 'c' "
@@ -3952,6 +3955,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
constrs[j].separate = false;
addObjectDependency(&tbinfo->dobj,
constrs[j].dobj.dumpId);
+
/*
* If the constraint is inherited, this will be detected
* later. We also detect later if the constraint must be
@@ -4110,7 +4114,7 @@ dumpTableComment(Archive *fout, TableInfo *tbinfo,
ArchiveEntry(fout, nilCatalogId, createDumpId(),
target->data,
- tbinfo->dobj.namespace->dobj.name, tbinfo->usename,
+ tbinfo->dobj.namespace->dobj.name, tbinfo->usename,
false, "COMMENT", query->data, "", NULL,
&(tbinfo->dobj.dumpId), 1,
NULL, NULL);
@@ -4130,7 +4134,7 @@ dumpTableComment(Archive *fout, TableInfo *tbinfo,
ArchiveEntry(fout, nilCatalogId, createDumpId(),
target->data,
- tbinfo->dobj.namespace->dobj.name, tbinfo->usename,
+ tbinfo->dobj.namespace->dobj.name, tbinfo->usename,
false, "COMMENT", query->data, "", NULL,
&(tbinfo->dobj.dumpId), 1,
NULL, NULL);
@@ -4169,9 +4173,9 @@ findComments(Archive *fout, Oid classoid, Oid objoid,
ncomments = collectComments(fout, &comments);
/*
- * Pre-7.2, pg_description does not contain classoid, so collectComments
- * just stores a zero. If there's a collision on object OID, well, you
- * get duplicate comments.
+ * Pre-7.2, pg_description does not contain classoid, so
+ * collectComments just stores a zero. If there's a collision on
+ * object OID, well, you get duplicate comments.
*/
if (fout->remoteVersion < 70200)
classoid = 0;
@@ -4180,7 +4184,7 @@ findComments(Archive *fout, Oid classoid, Oid objoid,
* Do binary search to find some item matching the object.
*/
low = &comments[0];
- high = &comments[ncomments-1];
+ high = &comments[ncomments - 1];
while (low <= high)
{
middle = low + (high - low) / 2;
@@ -4412,12 +4416,12 @@ dumpNamespace(Archive *fout, NamespaceInfo *nspinfo)
qnspname = strdup(fmtId(nspinfo->dobj.name));
/*
- * Note that ownership is shown in the AUTHORIZATION clause,
- * while the archive entry is listed with empty owner (causing
- * it to be emitted with SET SESSION AUTHORIZATION DEFAULT).
- * This seems the best way of dealing with schemas owned by
- * users without CREATE SCHEMA privilege. Further hacking has
- * to be applied for --no-owner mode, though!
+ * Note that ownership is shown in the AUTHORIZATION clause, while the
+ * archive entry is listed with empty owner (causing it to be emitted
+ * with SET SESSION AUTHORIZATION DEFAULT). This seems the best way of
+ * dealing with schemas owned by users without CREATE SCHEMA
+ * privilege. Further hacking has to be applied for --no-owner mode,
+ * though!
*/
appendPQExpBuffer(delq, "DROP SCHEMA %s;\n", qnspname);
@@ -4813,7 +4817,7 @@ dumpDomain(Archive *fout, TypeInfo *tinfo)
if (!domcheck->separate)
appendPQExpBuffer(q, "\n\tCONSTRAINT %s %s",
- fmtId(domcheck->dobj.name), domcheck->condef);
+ fmtId(domcheck->dobj.name), domcheck->condef);
}
appendPQExpBuffer(q, ";\n");
@@ -4961,17 +4965,16 @@ dumpProcLang(Archive *fout, ProcLangInfo *plang)
return;
/*
- * Current theory is to dump PLs iff their underlying functions
- * will be dumped (are in a dumpable namespace, or have a
- * non-system OID in pre-7.3 databases). Actually, we treat the
- * PL itself as being in the underlying function's namespace,
- * though it isn't really. This avoids searchpath problems for
- * the HANDLER clause.
+ * Current theory is to dump PLs iff their underlying functions will
+ * be dumped (are in a dumpable namespace, or have a non-system OID in
+ * pre-7.3 databases). Actually, we treat the PL itself as being in
+ * the underlying function's namespace, though it isn't really. This
+ * avoids searchpath problems for the HANDLER clause.
*
- * If the underlying function is in the pg_catalog namespace,
- * we won't have loaded it into finfo[] at all; therefore,
- * treat failure to find it in finfo[] as indicating we shouldn't
- * dump it, not as an error condition. Ditto for the validator.
+ * If the underlying function is in the pg_catalog namespace, we won't
+ * have loaded it into finfo[] at all; therefore, treat failure to
+ * find it in finfo[] as indicating we shouldn't dump it, not as an
+ * error condition. Ditto for the validator.
*/
funcInfo = findFuncByOid(plang->lanplcallfoid);
@@ -5007,7 +5010,7 @@ dumpProcLang(Archive *fout, ProcLangInfo *plang)
/* Cope with possibility that validator is in different schema */
if (validatorInfo->dobj.namespace != funcInfo->dobj.namespace)
appendPQExpBuffer(defqry, "%s.",
- fmtId(validatorInfo->dobj.namespace->dobj.name));
+ fmtId(validatorInfo->dobj.namespace->dobj.name));
appendPQExpBuffer(defqry, "%s",
fmtId(validatorInfo->dobj.name));
}
@@ -5204,6 +5207,7 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
if (strcmp(prosrc, "-") != 0)
{
appendPQExpBuffer(asPart, ", ");
+
/*
* where we have bin, use dollar quoting if allowed and src
* contains quote or backslash; else use regular quoting.
@@ -5229,7 +5233,7 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
if (proargnames && *proargnames)
{
- int nitems = 0;
+ int nitems = 0;
if (!parsePGArray(proargnames, &argnamearray, &nitems) ||
nitems != finfo->nargs)
@@ -5345,8 +5349,8 @@ dumpCast(Archive *fout, CastInfo *cast)
* As per discussion we dump casts if one or more of the underlying
* objects (the conversion function and the two data types) are not
* builtin AND if all of the non-builtin objects namespaces are
- * included in the dump. Builtin meaning, the namespace name does
- * not start with "pg_".
+ * included in the dump. Builtin meaning, the namespace name does not
+ * start with "pg_".
*/
sourceInfo = findTypeByOid(cast->castsource);
targetInfo = findTypeByOid(cast->casttarget);
@@ -5364,8 +5368,8 @@ dumpCast(Archive *fout, CastInfo *cast)
return;
/*
- * Skip cast if function isn't from pg_ and that namespace is
- * not dumped.
+ * Skip cast if function isn't from pg_ and that namespace is not
+ * dumped.
*/
if (funcInfo &&
strncmp(funcInfo->dobj.namespace->dobj.name, "pg_", 3) != 0 &&
@@ -5406,13 +5410,13 @@ dumpCast(Archive *fout, CastInfo *cast)
else
{
/*
- * Always qualify the function name, in case it is not in pg_catalog
- * schema (format_function_signature won't qualify it).
+ * Always qualify the function name, in case it is not in
+ * pg_catalog schema (format_function_signature won't qualify it).
*/
appendPQExpBuffer(defqry, "WITH FUNCTION %s.",
fmtId(funcInfo->dobj.namespace->dobj.name));
appendPQExpBuffer(defqry, "%s",
- format_function_signature(funcInfo, NULL, true));
+ format_function_signature(funcInfo, NULL, true));
}
if (cast->castcontext == 'a')
@@ -5754,7 +5758,7 @@ convertRegProcReference(const char *proc)
static const char *
convertOperatorReference(const char *opr)
{
- OprInfo *oprInfo;
+ OprInfo *oprInfo;
/* In all cases "0" means a null reference */
if (strcmp(opr, "0") == 0)
@@ -6046,8 +6050,8 @@ dumpConversion(Archive *fout, ConvInfo *convinfo)
/* Get conversion-specific details */
appendPQExpBuffer(query, "SELECT conname, "
- "pg_catalog.pg_encoding_to_char(conforencoding) AS conforencoding, "
- "pg_catalog.pg_encoding_to_char(contoencoding) AS contoencoding, "
+ "pg_catalog.pg_encoding_to_char(conforencoding) AS conforencoding, "
+ "pg_catalog.pg_encoding_to_char(contoencoding) AS contoencoding, "
"conproc, condefault "
"FROM pg_catalog.pg_conversion c "
"WHERE c.oid = '%u'::pg_catalog.oid",
@@ -6087,8 +6091,8 @@ dumpConversion(Archive *fout, ConvInfo *convinfo)
fmtId(convinfo->dobj.name));
appendPQExpBuffer(q, "CREATE %sCONVERSION %s FOR ",
- (condefault) ? "DEFAULT " : "",
- fmtId(convinfo->dobj.name));
+ (condefault) ? "DEFAULT " : "",
+ fmtId(convinfo->dobj.name));
appendStringLiteral(q, conforencoding, true);
appendPQExpBuffer(q, " TO ");
appendStringLiteral(q, contoencoding, true);
@@ -6332,22 +6336,22 @@ dumpAgg(Archive *fout, AggInfo *agginfo)
ArchiveEntry(fout, agginfo->aggfn.dobj.catId, agginfo->aggfn.dobj.dumpId,
aggsig_tag,
- agginfo->aggfn.dobj.namespace->dobj.name, agginfo->aggfn.usename,
+ agginfo->aggfn.dobj.namespace->dobj.name, agginfo->aggfn.usename,
false, "AGGREGATE", q->data, delq->data, NULL,
- agginfo->aggfn.dobj.dependencies, agginfo->aggfn.dobj.nDeps,
+ agginfo->aggfn.dobj.dependencies, agginfo->aggfn.dobj.nDeps,
NULL, NULL);
/* Dump Aggregate Comments */
resetPQExpBuffer(q);
appendPQExpBuffer(q, "AGGREGATE %s", aggsig);
dumpComment(fout, q->data,
- agginfo->aggfn.dobj.namespace->dobj.name, agginfo->aggfn.usename,
+ agginfo->aggfn.dobj.namespace->dobj.name, agginfo->aggfn.usename,
agginfo->aggfn.dobj.catId, 0, agginfo->aggfn.dobj.dumpId);
/*
* Since there is no GRANT ON AGGREGATE syntax, we have to make the
- * ACL command look like a function's GRANT; in particular this affects
- * the syntax for aggregates on ANY.
+ * ACL command look like a function's GRANT; in particular this
+ * affects the syntax for aggregates on ANY.
*/
free(aggsig);
free(aggsig_tag);
@@ -6582,8 +6586,8 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
}
/*
- * Default value --- suppress if inherited, serial,
- * or to be printed separately.
+ * Default value --- suppress if inherited, serial, or to
+ * be printed separately.
*/
if (tbinfo->attrdefs[j] != NULL &&
!tbinfo->inhAttrDef[j] &&
@@ -6641,7 +6645,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
appendPQExpBuffer(q, ", ");
if (parentRel->dobj.namespace != tbinfo->dobj.namespace)
appendPQExpBuffer(q, "%s.",
- fmtId(parentRel->dobj.namespace->dobj.name));
+ fmtId(parentRel->dobj.namespace->dobj.name));
appendPQExpBuffer(q, "%s",
fmtId(parentRel->dobj.name));
}
@@ -6723,7 +6727,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
ArchiveEntry(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId,
tbinfo->dobj.name,
tbinfo->dobj.namespace->dobj.name, tbinfo->usename,
- (strcmp(reltypename, "TABLE") == 0) ? tbinfo->hasoids : false,
+ (strcmp(reltypename, "TABLE") == 0) ? tbinfo->hasoids : false,
reltypename, q->data, delq->data, NULL,
tbinfo->dobj.dependencies, tbinfo->dobj.nDeps,
NULL, NULL);
@@ -6752,7 +6756,7 @@ dumpAttrDef(Archive *fout, AttrDefInfo *adinfo)
return;
/* Don't print inherited or serial defaults, either */
- if (tbinfo->inhAttrDef[adnum-1] || tbinfo->attisserial[adnum-1])
+ if (tbinfo->inhAttrDef[adnum - 1] || tbinfo->attisserial[adnum - 1])
return;
q = createPQExpBuffer();
@@ -6765,8 +6769,8 @@ dumpAttrDef(Archive *fout, AttrDefInfo *adinfo)
adinfo->adef_expr);
/*
- * DROP must be fully qualified in case same name appears
- * in pg_catalog
+ * DROP must be fully qualified in case same name appears in
+ * pg_catalog
*/
appendPQExpBuffer(delq, "ALTER TABLE %s.",
fmtId(tbinfo->dobj.namespace->dobj.name));
@@ -6857,8 +6861,8 @@ dumpIndex(Archive *fout, IndxInfo *indxinfo)
}
/*
- * DROP must be fully qualified in case same name appears
- * in pg_catalog
+ * DROP must be fully qualified in case same name appears in
+ * pg_catalog
*/
appendPQExpBuffer(delq, "DROP INDEX %s.",
fmtId(tbinfo->dobj.namespace->dobj.name));
@@ -6925,7 +6929,7 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
fmtId(tbinfo->dobj.name));
appendPQExpBuffer(q, " ADD CONSTRAINT %s %s (",
fmtId(coninfo->dobj.name),
- coninfo->contype == 'p' ? "PRIMARY KEY" : "UNIQUE");
+ coninfo->contype == 'p' ? "PRIMARY KEY" : "UNIQUE");
for (k = 0; k < indxinfo->indnkeys; k++)
{
@@ -6964,8 +6968,8 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
}
/*
- * DROP must be fully qualified in case same name appears
- * in pg_catalog
+ * DROP must be fully qualified in case same name appears in
+ * pg_catalog
*/
appendPQExpBuffer(delq, "ALTER TABLE ONLY %s.",
fmtId(tbinfo->dobj.namespace->dobj.name));
@@ -7191,7 +7195,7 @@ findLastBuiltinOid_V71(const char *dbname)
* find the last built in oid
*
* For 7.0, we do this by assuming that the last thing that initdb does is to
- * create the pg_indexes view. This sucks in general, but seeing that 7.0.x
+ * create the pg_indexes view. This sucks in general, but seeing that 7.0.x
* initdb won't be changing anymore, it'll do.
*/
static Oid
@@ -7204,7 +7208,7 @@ findLastBuiltinOid_V70(void)
res = PQexec(g_conn,
"SELECT oid FROM pg_class WHERE relname = 'pg_indexes'");
check_sql_result(res, g_conn,
- "SELECT oid FROM pg_class WHERE relname = 'pg_indexes'",
+ "SELECT oid FROM pg_class WHERE relname = 'pg_indexes'",
PGRES_TUPLES_OK);
ntups = PQntuples(res);
if (ntups < 1)
@@ -7348,15 +7352,17 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
if (!schemaOnly)
{
- TableInfo *owning_tab;
+ TableInfo *owning_tab;
resetPQExpBuffer(query);
appendPQExpBuffer(query, "SELECT pg_catalog.setval(");
+
/*
- * If this is a SERIAL sequence, then use the pg_get_serial_sequence
- * function to avoid hard-coding the sequence name. Note that this
- * implicitly assumes that the sequence and its owning table are in
- * the same schema, because we don't schema-qualify the reference.
+ * If this is a SERIAL sequence, then use the
+ * pg_get_serial_sequence function to avoid hard-coding the
+ * sequence name. Note that this implicitly assumes that the
+ * sequence and its owning table are in the same schema, because
+ * we don't schema-qualify the reference.
*/
if (OidIsValid(tbinfo->owning_tab) &&
(owning_tab = findTableByOid(tbinfo->owning_tab)) != NULL)
@@ -7364,7 +7370,7 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
appendPQExpBuffer(query, "pg_catalog.pg_get_serial_sequence(");
appendStringLiteral(query, fmtId(owning_tab->dobj.name), true);
appendPQExpBuffer(query, ", ");
- appendStringLiteral(query, owning_tab->attnames[tbinfo->owning_col-1], true);
+ appendStringLiteral(query, owning_tab->attnames[tbinfo->owning_col - 1], true);
appendPQExpBuffer(query, ")");
}
else
@@ -7579,8 +7585,8 @@ dumpRule(Archive *fout, RuleInfo *rinfo)
return;
/*
- * If it is an ON SELECT rule, we do not need to dump it because
- * it will be handled via CREATE VIEW for the table.
+ * If it is an ON SELECT rule, we do not need to dump it because it
+ * will be handled via CREATE VIEW for the table.
*/
if (rinfo->ev_type == '1' && rinfo->is_instead)
return;
@@ -7729,8 +7735,9 @@ getDependencies(void)
dobj = findObjectByCatalogId(objId);
/*
- * Failure to find objects mentioned in pg_depend is not unexpected,
- * since for example we don't collect info about TOAST tables.
+ * Failure to find objects mentioned in pg_depend is not
+ * unexpected, since for example we don't collect info about TOAST
+ * tables.
*/
if (dobj == NULL)
{
@@ -7885,7 +7892,7 @@ static char *
myFormatType(const char *typname, int32 typmod)
{
char *result;
- bool isarray = false;
+ bool isarray = false;
PQExpBuffer buf = createPQExpBuffer();
/* Handle array types */
diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h
index 37cd7613e26..6c3c02707af 100644
--- a/src/bin/pg_dump/pg_dump.h
+++ b/src/bin/pg_dump/pg_dump.h
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.h,v 1.111 2004/08/29 04:13:01 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.h,v 1.112 2004/08/29 05:06:53 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -39,7 +39,7 @@ typedef struct
Oid oid;
} CatalogId;
-typedef int DumpId;
+typedef int DumpId;
/*
@@ -105,6 +105,7 @@ typedef struct _namespaceInfo
typedef struct _typeInfo
{
DumpableObject dobj;
+
/*
* Note: dobj.name is the pg_type.typname entry. format_type() might
* produce something different than typname
@@ -199,22 +200,22 @@ typedef struct _tableInfo
bool *attisserial; /* true if attr is serial or bigserial */
/*
- * Note: we need to store per-attribute notnull, default, and constraint
- * stuff for all interesting tables so that we can tell which constraints
- * were inherited.
+ * Note: we need to store per-attribute notnull, default, and
+ * constraint stuff for all interesting tables so that we can tell
+ * which constraints were inherited.
*/
bool *notnull; /* Not null constraints on attributes */
- struct _attrDefInfo **attrdefs; /* DEFAULT expressions */
+ struct _attrDefInfo **attrdefs; /* DEFAULT expressions */
bool *inhAttrs; /* true if each attribute is inherited */
bool *inhAttrDef; /* true if attr's default is inherited */
bool *inhNotNull; /* true if NOT NULL is inherited */
- struct _constraintInfo *checkexprs; /* CHECK constraints */
+ struct _constraintInfo *checkexprs; /* CHECK constraints */
/*
* Stuff computed only for dumpable tables.
*/
int numParents; /* number of (immediate) parent tables */
- struct _tableInfo **parents; /* TableInfos of immediate parents */
+ struct _tableInfo **parents; /* TableInfos of immediate parents */
} TableInfo;
typedef struct _attrDefInfo
@@ -271,7 +272,7 @@ typedef struct _triggerInfo
} TriggerInfo;
/*
- * struct ConstraintInfo is used for all constraint types. However we
+ * struct ConstraintInfo is used for all constraint types. However we
* use a different objType for foreign key constraints, to make it easier
* to sort them the way we want.
*/
@@ -328,8 +329,8 @@ extern char g_opaque_type[10]; /* name for the opaque type */
*/
extern TableInfo *getSchemaData(int *numTablesPtr,
- const bool schemaOnly,
- const bool dataOnly);
+ const bool schemaOnly,
+ const bool dataOnly);
typedef enum _OidOptions
{
diff --git a/src/bin/pg_dump/pg_dump_sort.c b/src/bin/pg_dump/pg_dump_sort.c
index b74d442d89f..79696f452f7 100644
--- a/src/bin/pg_dump/pg_dump_sort.c
+++ b/src/bin/pg_dump/pg_dump_sort.c
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump_sort.c,v 1.5 2004/08/29 04:13:01 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump_sort.c,v 1.6 2004/08/29 05:06:53 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -22,30 +22,30 @@ static char *modulename = gettext_noop("sorter");
/*
* Sort priority for object types when dumping a pre-7.3 database.
* Objects are sorted by priority levels, and within an equal priority level
- * by OID. (This is a relatively crude hack to provide semi-reasonable
+ * by OID. (This is a relatively crude hack to provide semi-reasonable
* behavior for old databases without full dependency info.)
*/
static const int oldObjectTypePriority[] =
{
- 1, /* DO_NAMESPACE */
- 2, /* DO_TYPE */
- 2, /* DO_FUNC */
- 2, /* DO_AGG */
- 3, /* DO_OPERATOR */
- 4, /* DO_OPCLASS */
- 5, /* DO_CONVERSION */
- 6, /* DO_TABLE */
- 8, /* DO_ATTRDEF */
- 12, /* DO_INDEX */
- 13, /* DO_RULE */
- 14, /* DO_TRIGGER */
- 11, /* DO_CONSTRAINT */
- 15, /* DO_FK_CONSTRAINT */
- 2, /* DO_PROCLANG */
- 2, /* DO_CAST */
- 9, /* DO_TABLE_DATA */
- 7, /* DO_TABLE_TYPE */
- 10 /* DO_BLOBS */
+ 1, /* DO_NAMESPACE */
+ 2, /* DO_TYPE */
+ 2, /* DO_FUNC */
+ 2, /* DO_AGG */
+ 3, /* DO_OPERATOR */
+ 4, /* DO_OPCLASS */
+ 5, /* DO_CONVERSION */
+ 6, /* DO_TABLE */
+ 8, /* DO_ATTRDEF */
+ 12, /* DO_INDEX */
+ 13, /* DO_RULE */
+ 14, /* DO_TRIGGER */
+ 11, /* DO_CONSTRAINT */
+ 15, /* DO_FK_CONSTRAINT */
+ 2, /* DO_PROCLANG */
+ 2, /* DO_CAST */
+ 9, /* DO_TABLE_DATA */
+ 7, /* DO_TABLE_TYPE */
+ 10 /* DO_BLOBS */
};
/*
@@ -54,46 +54,46 @@ static const int oldObjectTypePriority[] =
*/
static const int newObjectTypePriority[] =
{
- 1, /* DO_NAMESPACE */
- 3, /* DO_TYPE */
- 4, /* DO_FUNC */
- 5, /* DO_AGG */
- 6, /* DO_OPERATOR */
- 7, /* DO_OPCLASS */
- 9, /* DO_CONVERSION */
- 10, /* DO_TABLE */
- 12, /* DO_ATTRDEF */
- 16, /* DO_INDEX */
- 17, /* DO_RULE */
- 18, /* DO_TRIGGER */
- 15, /* DO_CONSTRAINT */
- 19, /* DO_FK_CONSTRAINT */
- 2, /* DO_PROCLANG */
- 8, /* DO_CAST */
- 13, /* DO_TABLE_DATA */
- 11, /* DO_TABLE_TYPE */
- 14 /* DO_BLOBS */
+ 1, /* DO_NAMESPACE */
+ 3, /* DO_TYPE */
+ 4, /* DO_FUNC */
+ 5, /* DO_AGG */
+ 6, /* DO_OPERATOR */
+ 7, /* DO_OPCLASS */
+ 9, /* DO_CONVERSION */
+ 10, /* DO_TABLE */
+ 12, /* DO_ATTRDEF */
+ 16, /* DO_INDEX */
+ 17, /* DO_RULE */
+ 18, /* DO_TRIGGER */
+ 15, /* DO_CONSTRAINT */
+ 19, /* DO_FK_CONSTRAINT */
+ 2, /* DO_PROCLANG */
+ 8, /* DO_CAST */
+ 13, /* DO_TABLE_DATA */
+ 11, /* DO_TABLE_TYPE */
+ 14 /* DO_BLOBS */
};
static int DOTypeNameCompare(const void *p1, const void *p2);
static int DOTypeOidCompare(const void *p1, const void *p2);
static bool TopoSort(DumpableObject **objs,
- int numObjs,
- DumpableObject **ordering,
- int *nOrdering);
+ int numObjs,
+ DumpableObject **ordering,
+ int *nOrdering);
static void addHeapElement(int val, int *heap, int heapLength);
static int removeHeapElement(int *heap, int heapLength);
static void findDependencyLoops(DumpableObject **objs, int nObjs, int totObjs);
static bool findLoop(DumpableObject *obj,
- DumpId startPoint,
- DumpableObject **workspace,
- int depth,
- int *newDepth);
+ DumpId startPoint,
+ DumpableObject **workspace,
+ int depth,
+ int *newDepth);
static void repairDependencyLoop(DumpableObject **loop,
- int nLoop);
+ int nLoop);
static void describeDumpableObject(DumpableObject *obj,
- char *buf, int bufsize);
+ char *buf, int bufsize);
/*
@@ -185,7 +185,7 @@ DOTypeOidCompare(const void *p1, const void *p2)
void
sortDumpableObjects(DumpableObject **objs, int numObjs)
{
- DumpableObject **ordering;
+ DumpableObject **ordering;
int nOrdering;
if (numObjs <= 0)
@@ -207,11 +207,11 @@ sortDumpableObjects(DumpableObject **objs, int numObjs)
* TopoSort -- topological sort of a dump list
*
* Generate a re-ordering of the dump list that satisfies all the dependency
- * constraints shown in the dump list. (Each such constraint is a fact of a
+ * constraints shown in the dump list. (Each such constraint is a fact of a
* partial ordering.) Minimize rearrangement of the list not needed to
* achieve the partial ordering.
*
- * The input is the list of numObjs objects in objs[]. This list is not
+ * The input is the list of numObjs objects in objs[]. This list is not
* modified.
*
* Returns TRUE if able to build an ordering that satisfies all the
@@ -233,32 +233,33 @@ static bool
TopoSort(DumpableObject **objs,
int numObjs,
DumpableObject **ordering, /* output argument */
- int *nOrdering) /* output argument */
+ int *nOrdering) /* output argument */
{
DumpId maxDumpId = getMaxDumpId();
int *pendingHeap;
int *beforeConstraints;
int *idMap;
- DumpableObject *obj;
+ DumpableObject *obj;
int heapLength;
int i,
j,
k;
/*
- * This is basically the same algorithm shown for topological sorting in
- * Knuth's Volume 1. However, we would like to minimize unnecessary
- * rearrangement of the input ordering; that is, when we have a choice
- * of which item to output next, we always want to take the one highest
- * in the original list. Therefore, instead of maintaining an unordered
- * linked list of items-ready-to-output as Knuth does, we maintain a heap
- * of their item numbers, which we can use as a priority queue. This
- * turns the algorithm from O(N) to O(N log N) because each insertion or
- * removal of a heap item takes O(log N) time. However, that's still
- * plenty fast enough for this application.
+ * This is basically the same algorithm shown for topological sorting
+ * in Knuth's Volume 1. However, we would like to minimize
+ * unnecessary rearrangement of the input ordering; that is, when we
+ * have a choice of which item to output next, we always want to take
+ * the one highest in the original list. Therefore, instead of
+ * maintaining an unordered linked list of items-ready-to-output as
+ * Knuth does, we maintain a heap of their item numbers, which we can
+ * use as a priority queue. This turns the algorithm from O(N) to O(N
+ * log N) because each insertion or removal of a heap item takes O(log
+ * N) time. However, that's still plenty fast enough for this
+ * application.
*/
- *nOrdering = numObjs; /* for success return */
+ *nOrdering = numObjs; /* for success return */
/* Eliminate the null case */
if (numObjs <= 0)
@@ -272,9 +273,9 @@ TopoSort(DumpableObject **objs,
/*
* Scan the constraints, and for each item in the input, generate a
* count of the number of constraints that say it must be before
- * something else. The count for the item with dumpId j is
- * stored in beforeConstraints[j]. We also make a map showing the
- * input-order index of the item with dumpId j.
+ * something else. The count for the item with dumpId j is stored in
+ * beforeConstraints[j]. We also make a map showing the input-order
+ * index of the item with dumpId j.
*/
beforeConstraints = (int *) malloc((maxDumpId + 1) * sizeof(int));
if (beforeConstraints == NULL)
@@ -304,23 +305,24 @@ TopoSort(DumpableObject **objs,
* the indexes of items that already have beforeConstraints[id] == 0.
*
* The essential property of a heap is heap[(j-1)/2] >= heap[j] for each
- * j in the range 1..heapLength-1 (note we are using 0-based subscripts
- * here, while the discussion in Knuth assumes 1-based subscripts).
- * So, if we simply enter the indexes into pendingHeap[] in decreasing
- * order, we a-fortiori have the heap invariant satisfied at completion
- * of this loop, and don't need to do any sift-up comparisons.
+ * j in the range 1..heapLength-1 (note we are using 0-based
+ * subscripts here, while the discussion in Knuth assumes 1-based
+ * subscripts). So, if we simply enter the indexes into pendingHeap[]
+ * in decreasing order, we a-fortiori have the heap invariant
+ * satisfied at completion of this loop, and don't need to do any
+ * sift-up comparisons.
*/
heapLength = 0;
- for (i = numObjs; --i >= 0; )
+ for (i = numObjs; --i >= 0;)
{
if (beforeConstraints[objs[i]->dumpId] == 0)
pendingHeap[heapLength++] = i;
}
/*--------------------
- * Now emit objects, working backwards in the output list. At each step,
+ * Now emit objects, working backwards in the output list. At each step,
* we use the priority heap to select the last item that has no remaining
- * before-constraints. We remove that item from the heap, output it to
+ * before-constraints. We remove that item from the heap, output it to
* ordering[], and decrease the beforeConstraints count of each of the
* items it was constrained against. Whenever an item's beforeConstraints
* count is thereby decreased to zero, we insert it into the priority heap
@@ -343,7 +345,7 @@ TopoSort(DumpableObject **objs,
/* Update beforeConstraints counts of its predecessors */
for (k = 0; k < obj->nDeps; k++)
{
- int id = obj->dependencies[k];
+ int id = obj->dependencies[k];
if ((--beforeConstraints[id]) == 0)
addHeapElement(idMap[id], pendingHeap, heapLength++);
@@ -448,7 +450,7 @@ removeHeapElement(int *heap, int heapLength)
* before trying TopoSort again. We can safely repair loops that are
* disjoint (have no members in common); if we find overlapping loops
* then we repair only the first one found, because the action taken to
- * repair the first might have repaired the other as well. (If not,
+ * repair the first might have repaired the other as well. (If not,
* we'll fix it on the next go-round.)
*
* objs[] lists the objects TopoSort couldn't sort
@@ -459,25 +461,25 @@ static void
findDependencyLoops(DumpableObject **objs, int nObjs, int totObjs)
{
/*
- * We use a workspace array, the initial part of which stores
- * objects already processed, and the rest of which is used as
- * temporary space to try to build a loop in. This is convenient
- * because we do not care about loops involving already-processed
- * objects (see notes above); we can easily reject such loops in
- * findLoop() because of this representation. After we identify
- * and process a loop, we can add it to the initial part of the
- * workspace just by moving the boundary pointer.
+ * We use a workspace array, the initial part of which stores objects
+ * already processed, and the rest of which is used as temporary space
+ * to try to build a loop in. This is convenient because we do not
+ * care about loops involving already-processed objects (see notes
+ * above); we can easily reject such loops in findLoop() because of
+ * this representation. After we identify and process a loop, we can
+ * add it to the initial part of the workspace just by moving the
+ * boundary pointer.
*
- * When we determine that an object is not part of any interesting
- * loop, we also add it to the initial part of the workspace. This
- * is not necessary for correctness, but saves later invocations of
+ * When we determine that an object is not part of any interesting loop,
+ * we also add it to the initial part of the workspace. This is not
+ * necessary for correctness, but saves later invocations of
* findLoop() from uselessly chasing references to such an object.
*
- * We make the workspace large enough to hold all objects in the
- * original universe. This is probably overkill, but it's provably
- * enough space...
+ * We make the workspace large enough to hold all objects in the original
+ * universe. This is probably overkill, but it's provably enough
+ * space...
*/
- DumpableObject **workspace;
+ DumpableObject **workspace;
int initiallen;
bool fixedloop;
int i;
@@ -491,9 +493,9 @@ findDependencyLoops(DumpableObject **objs, int nObjs, int totObjs)
for (i = 0; i < nObjs; i++)
{
DumpableObject *obj = objs[i];
- int newlen;
+ int newlen;
- workspace[initiallen] = NULL; /* see test below */
+ workspace[initiallen] = NULL; /* see test below */
if (findLoop(obj, obj->dumpId, workspace, initiallen, &newlen))
{
@@ -506,10 +508,10 @@ findDependencyLoops(DumpableObject **objs, int nObjs, int totObjs)
else
{
/*
- * Didn't find a loop, but add this object to workspace anyway,
- * unless it's already present. We piggyback on the test that
- * findLoop() already did: it won't have tentatively added obj
- * to workspace if it's already present.
+ * Didn't find a loop, but add this object to workspace
+ * anyway, unless it's already present. We piggyback on the
+ * test that findLoop() already did: it won't have tentatively
+ * added obj to workspace if it's already present.
*/
if (workspace[initiallen] == obj)
initiallen++;
@@ -561,12 +563,15 @@ findLoop(DumpableObject *obj,
if (workspace[i] == obj)
return false;
}
+
/*
* Okay, tentatively add obj to workspace
*/
workspace[depth++] = obj;
+
/*
- * See if we've found a loop back to the desired startPoint; if so, done
+ * See if we've found a loop back to the desired startPoint; if so,
+ * done
*/
for (i = 0; i < obj->nDeps; i++)
{
@@ -576,6 +581,7 @@ findLoop(DumpableObject *obj,
return true;
}
}
+
/*
* Recurse down each outgoing branch
*/
@@ -620,6 +626,7 @@ repairTypeFuncLoop(DumpableObject *typeobj, DumpableObject *funcobj)
if (inputFuncInfo == NULL)
return;
addObjectDependency(funcobj, inputFuncInfo->dobj.dumpId);
+
/*
* Make sure the input function's dependency on type gets removed too;
* if it hasn't been done yet, we'd end up with loops involving the
@@ -900,7 +907,7 @@ repairDependencyLoop(DumpableObject **loop,
write_msg(modulename, "WARNING: could not resolve dependency loop among these items:\n");
for (i = 0; i < nLoop; i++)
{
- char buf[1024];
+ char buf[1024];
describeDumpableObject(loop[i], buf, sizeof(buf));
write_msg(modulename, " %s\n", buf);
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index dec81f58390..1a9e4cdf16a 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
*
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.50 2004/08/29 04:13:01 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.51 2004/08/29 05:06:53 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -59,7 +59,7 @@ static PGconn *connectDatabase(const char *dbname, const char *pghost, const cha
const char *pguser, bool require_password);
static PGresult *executeQuery(PGconn *conn, const char *query);
-char pg_dump_bin[MAXPGPATH];
+char pg_dump_bin[MAXPGPATH];
PQExpBuffer pgdumpopts;
bool output_clean = false;
bool skip_acls = false;
@@ -67,9 +67,9 @@ bool verbose = false;
int server_version;
/* flags for -X long options */
-int disable_dollar_quoting = 0;
-int disable_triggers = 0;
-int use_setsessauth = 0;
+int disable_dollar_quoting = 0;
+int disable_triggers = 0;
+int use_setsessauth = 0;
int
main(int argc, char *argv[])
@@ -82,7 +82,8 @@ main(int argc, char *argv[])
bool globals_only = false;
bool schema_only = false;
PGconn *conn;
- int c, ret;
+ int c,
+ ret;
static struct option long_options[] = {
{"data-only", no_argument, NULL, 'a'},
@@ -140,16 +141,16 @@ main(int argc, char *argv[])
{
if (ret == -1)
fprintf(stderr,
- _("The program \"pg_dump\" is needed by %s "
- "but was not found in the same directory as \"%s\".\n"
- "Check your installation.\n"),
- progname, progname);
+ _("The program \"pg_dump\" is needed by %s "
+ "but was not found in the same directory as \"%s\".\n"
+ "Check your installation.\n"),
+ progname, progname);
else
fprintf(stderr,
- _("The program \"pg_dump\" was found by %s "
- "but was not the same version as \"%s\".\n"
- "Check your installation.\n"),
- progname, progname);
+ _("The program \"pg_dump\" was found by %s "
+ "but was not the same version as \"%s\".\n"
+ "Check your installation.\n"),
+ progname, progname);
exit(1);
}
@@ -231,7 +232,7 @@ main(int argc, char *argv[])
else if (strcmp(optarg, "disable-triggers") == 0)
appendPQExpBuffer(pgdumpopts, " -X disable-triggers");
else if (strcmp(optarg, "use-set-session-authorization") == 0)
- /* no-op, still allowed for compatibility */ ;
+ /* no-op, still allowed for compatibility */ ;
else
{
fprintf(stderr,
@@ -251,14 +252,14 @@ main(int argc, char *argv[])
}
}
- /* Add long options to the pg_dump argument list */
+ /* Add long options to the pg_dump argument list */
if (disable_dollar_quoting)
appendPQExpBuffer(pgdumpopts, " -X disable-dollar-quoting");
if (disable_triggers)
appendPQExpBuffer(pgdumpopts, " -X disable-triggers");
if (use_setsessauth)
appendPQExpBuffer(pgdumpopts, " -X use-set-session-authorization");
-
+
if (optind < argc)
{
fprintf(stderr, _("%s: too many command-line arguments (first is \"%s\")\n"),
@@ -273,7 +274,7 @@ main(int argc, char *argv[])
printf("--\n-- PostgreSQL database cluster dump\n--\n\n");
if (verbose)
- dumpTimestamp("Started on");
+ dumpTimestamp("Started on");
printf("\\connect \"template1\"\n\n");
@@ -330,7 +331,7 @@ help(void)
printf(_(" -X disable-dollar-quoting, --disable-dollar-quoting\n"
" disable dollar quoting, use SQL standard quoting\n"));
printf(_(" -X disable-triggers, --disable-triggers\n"
- " disable triggers during data-only restore\n"));
+ " disable triggers during data-only restore\n"));
printf(_(" -X use-set-session-authorization, --use-set-session-authorization\n"
" use SESSION AUTHORIZATION commands instead of\n"
" OWNER TO commands\n"));
@@ -378,15 +379,20 @@ dumpUsers(PGconn *conn, bool initdbonly)
for (i = 0; i < PQntuples(res); i++)
{
const char *username;
- bool clusterowner;
+ bool clusterowner;
PQExpBuffer buf = createPQExpBuffer();
+
username = PQgetvalue(res, i, 0);
clusterowner = (strcmp(PQgetvalue(res, i, 6), "t") == 0);
/* Check which pass we're on */
- if ((initdbonly && !clusterowner) || (!initdbonly && clusterowner)) continue;
+ if ((initdbonly && !clusterowner) || (!initdbonly && clusterowner))
+ continue;
- /* Dump ALTER USER for the cluster owner and CREATE USER for all other users */
+ /*
+ * Dump ALTER USER for the cluster owner and CREATE USER for all
+ * other users
+ */
if (!clusterowner)
appendPQExpBuffer(buf, "CREATE USER %s WITH SYSID %s",
fmtId(username),
@@ -502,22 +508,22 @@ dumpTablespaces(PGconn *conn)
* pg_xxx)
*/
res = executeQuery(conn, "SELECT spcname, "
- "pg_catalog.pg_get_userbyid(spcowner) AS spcowner, "
+ "pg_catalog.pg_get_userbyid(spcowner) AS spcowner, "
"spclocation, spcacl "
"FROM pg_catalog.pg_tablespace "
"WHERE spcname NOT LIKE 'pg\\_%'");
-
+
if (PQntuples(res) > 0)
printf("--\n-- Tablespaces\n--\n\n");
for (i = 0; i < PQntuples(res); i++)
{
PQExpBuffer buf = createPQExpBuffer();
- char *spcname = PQgetvalue(res, i, 0);
- char *spcowner = PQgetvalue(res, i, 1);
- char *spclocation = PQgetvalue(res, i, 2);
- char *spcacl = PQgetvalue(res, i, 3);
- char *fspcname;
+ char *spcname = PQgetvalue(res, i, 0);
+ char *spcowner = PQgetvalue(res, i, 1);
+ char *spclocation = PQgetvalue(res, i, 2);
+ char *spcacl = PQgetvalue(res, i, 3);
+ char *fspcname;
/* needed for buildACLCommands() */
fspcname = strdup(fmtId(spcname));
@@ -778,11 +784,15 @@ makeAlterConfigCommand(const char *arrayitem, const char *type, const char *name
*pos = 0;
appendPQExpBuffer(buf, "ALTER %s %s ", type, fmtId(name));
appendPQExpBuffer(buf, "SET %s TO ", fmtId(mine));
- /* Some GUC variable names are 'LIST' type and hence must not be quoted. */
+
+ /*
+ * Some GUC variable names are 'LIST' type and hence must not be
+ * quoted.
+ */
if (strcasecmp(mine, "DateStyle") == 0
- || strcasecmp(mine, "search_path") == 0)
+ || strcasecmp(mine, "search_path") == 0)
appendPQExpBuffer(buf, "%s", pos + 1);
- else
+ else
appendStringLiteral(buf, pos + 1, false);
appendPQExpBuffer(buf, ";\n");
@@ -841,10 +851,10 @@ runPgDump(const char *dbname)
int ret;
/*
- * Win32 has to use double-quotes for args, rather than single quotes.
- * Strangely enough, this is the only place we pass a database name
- * on the command line, except template1 that doesn't need quoting.
- */
+ * Win32 has to use double-quotes for args, rather than single quotes.
+ * Strangely enough, this is the only place we pass a database name on
+ * the command line, except template1 that doesn't need quoting.
+ */
#ifndef WIN32
appendPQExpBuffer(cmd, "%s\"%s\" %s -Fp '", SYSTEMQUOTE, pg_dump_bin,
#else
@@ -871,7 +881,7 @@ runPgDump(const char *dbname)
#else
appendPQExpBufferChar(cmd, '"');
#endif
-
+
appendPQExpBuffer(cmd, "%s", SYSTEMQUOTE);
if (verbose)
@@ -994,8 +1004,8 @@ executeQuery(PGconn *conn, const char *query)
static void
dumpTimestamp(char *msg)
{
- char buf[256];
- time_t now = time(NULL);
+ char buf[256];
+ time_t now = time(NULL);
if (strftime(buf, 256, "%Y-%m-%d %H:%M:%S %Z", localtime(&now)) != 0)
printf("-- %s %s\n\n", msg, buf);
diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c
index 918a93a6568..90628da0674 100644
--- a/src/bin/pg_dump/pg_restore.c
+++ b/src/bin/pg_dump/pg_restore.c
@@ -34,7 +34,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_restore.c,v 1.60 2004/08/20 04:20:23 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_restore.c,v 1.61 2004/08/29 05:06:53 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -326,7 +326,8 @@ main(int argc, char **argv)
AH->verbose = opts->verbose;
/*
- * Whether to keep submitting sql commands as "pg_restore ... | psql ... "
+ * Whether to keep submitting sql commands as "pg_restore ... | psql
+ * ... "
*/
AH->exit_on_error = opts->exit_on_error;
@@ -340,11 +341,11 @@ main(int argc, char **argv)
/* done, print a summary of ignored errors */
if (AH->n_errors)
- fprintf(stderr, _("WARNING, errors ignored on restore: %d\n"),
+ fprintf(stderr, _("WARNING, errors ignored on restore: %d\n"),
AH->n_errors);
/* AH may be freed in CloseArchive? */
- exit_code = AH->n_errors? 1: 0;
+ exit_code = AH->n_errors ? 1 : 0;
CloseArchive(AH);