Commit 9e733eab authored by Tom Lane's avatar Tom Lane

Modify pg_dump so that the preferred dump order is by name within

object types, rather than by OID.  This should help ensure consistent
dump output from databases that are logically the same but have different
histories, per recent discussion about 'diffing' databases.  The patch
is bulky because of renaming of fields, but not very complicated.
Also, do some tweaking to cause BLOB restoration to be done in a better
order, and clean up pg_restore's textual output to exactly match pg_dump.
parent 6819787c
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/bin/pg_dump/common.c,v 1.80 2003/12/08 16:39:05 tgl Exp $ * $PostgreSQL: pgsql/src/bin/pg_dump/common.c,v 1.81 2004/03/03 21:28:54 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -368,9 +368,9 @@ flagInhAttrs(TableInfo *tblinfo, int numTables, ...@@ -368,9 +368,9 @@ flagInhAttrs(TableInfo *tblinfo, int numTables,
pconstr = &(parent->checkexprs[l]); pconstr = &(parent->checkexprs[l]);
if (strcmp(pconstr->condef, constr->condef) != 0) if (strcmp(pconstr->condef, constr->condef) != 0)
continue; continue;
if (strcmp(pconstr->conname, constr->conname) == 0 || if (strcmp(pconstr->dobj.name, constr->dobj.name) == 0 ||
(pconstr->conname[0] == '$' && (pconstr->dobj.name[0] == '$' &&
constr->conname[0] == '$')) constr->dobj.name[0] == '$'))
{ {
constr->coninherited = true; constr->coninherited = true;
break; break;
...@@ -395,6 +395,8 @@ void ...@@ -395,6 +395,8 @@ void
AssignDumpId(DumpableObject *dobj) AssignDumpId(DumpableObject *dobj)
{ {
dobj->dumpId = ++lastDumpId; dobj->dumpId = ++lastDumpId;
dobj->name = NULL; /* must be set later */
dobj->namespace = NULL; /* may be set later */
dobj->dependencies = NULL; dobj->dependencies = NULL;
dobj->nDeps = 0; dobj->nDeps = 0;
dobj->allocDeps = 0; dobj->allocDeps = 0;
...@@ -725,7 +727,7 @@ findParentsByOid(TableInfo *self, ...@@ -725,7 +727,7 @@ findParentsByOid(TableInfo *self,
{ {
write_msg(NULL, "failed sanity check, parent OID %u of table \"%s\" (OID %u) not found\n", write_msg(NULL, "failed sanity check, parent OID %u of table \"%s\" (OID %u) not found\n",
inhinfo[i].inhparent, inhinfo[i].inhparent,
self->relname, self->dobj.name,
oid); oid);
exit_nicely(); exit_nicely();
} }
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.83 2004/02/24 03:35:19 tgl Exp $ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.84 2004/03/03 21:28:54 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -49,6 +49,8 @@ static ArchiveHandle *_allocAH(const char *FileSpec, const ArchiveFormat fmt, ...@@ -49,6 +49,8 @@ static ArchiveHandle *_allocAH(const char *FileSpec, const ArchiveFormat fmt,
const int compression, ArchiveMode mode); const int compression, ArchiveMode mode);
static int _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isData); static int _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isData);
static void fixPriorBlobRefs(ArchiveHandle *AH, TocEntry *blobte,
RestoreOptions *ropt);
static void _doSetFixedOutputState(ArchiveHandle *AH); static void _doSetFixedOutputState(ArchiveHandle *AH);
static void _doSetSessionAuth(ArchiveHandle *AH, const char *user); static void _doSetSessionAuth(ArchiveHandle *AH, const char *user);
static void _reconnectToDB(ArchiveHandle *AH, const char *dbname, const char *user); static void _reconnectToDB(ArchiveHandle *AH, const char *dbname, const char *user);
...@@ -279,7 +281,7 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt) ...@@ -279,7 +281,7 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
/* /*
* If we can output the data, then restore it. * 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 #ifndef HAVE_LIBZ
if (AH->compression != 0) if (AH->compression != 0)
...@@ -331,6 +333,24 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt) ...@@ -331,6 +333,24 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
(*AH->PrintTocDataPtr) (AH, te, ropt); (*AH->PrintTocDataPtr) (AH, te, 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.
*/
if (strcmp(te->desc, "BLOBS") == 0)
fixPriorBlobRefs(AH, te, ropt);
else if (AH->createdBlobXref &&
strcmp(te->desc, "TABLE DATA") == 0)
{
ahlog(AH, 1, "fixing up large-object cross-reference for \"%s\"\n", te->tag);
FixupBlobRefs(AH, te);
}
_enableTriggersIfNecessary(AH, te, ropt); _enableTriggersIfNecessary(AH, te, ropt);
} }
} }
...@@ -346,22 +366,44 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt) ...@@ -346,22 +366,44 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
} /* end loop over TOC entries */ } /* end loop over TOC entries */
/* /*
* Now use blobs_xref (if used) to fixup any refs for tables that we * Clean up & we're done.
* loaded
*/ */
if (_canRestoreBlobs(AH) && AH->createdBlobXref) if (ropt->filename || ropt->compression)
ResetOutput(AH, sav);
if (ropt->useDB)
{
PQfinish(AH->connection);
AH->connection = NULL;
if (AH->blobConnection)
{
PQfinish(AH->blobConnection);
AH->blobConnection = NULL;
}
}
}
/*
* After restoring BLOBS, fix all blob references in previously-restored
* tables. (Normally, the BLOBS entry should appear after all TABLE DATA
* entries, so this will in fact handle all blob references.)
*/
static void
fixPriorBlobRefs(ArchiveHandle *AH, TocEntry *blobte, RestoreOptions *ropt)
{
TocEntry *te;
teReqs reqs;
if (AH->createdBlobXref)
{ {
/* NULL parameter means disable ALL user triggers */ /* NULL parameter means disable ALL user triggers */
_disableTriggersIfNecessary(AH, NULL, ropt); _disableTriggersIfNecessary(AH, NULL, ropt);
te = AH->toc->next; for (te = AH->toc->next; te != blobte; te = te->next)
while (te != AH->toc)
{ {
/* Is it table data? */
if (strcmp(te->desc, "TABLE DATA") == 0) if (strcmp(te->desc, "TABLE DATA") == 0)
{ {
ahlog(AH, 2, "checking whether we loaded \"%s\"\n", te->tag);
reqs = _tocEntryRequired(te, ropt); reqs = _tocEntryRequired(te, ropt);
if ((reqs & REQ_DATA) != 0) /* We loaded the data */ if ((reqs & REQ_DATA) != 0) /* We loaded the data */
...@@ -370,33 +412,11 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt) ...@@ -370,33 +412,11 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
FixupBlobRefs(AH, te); FixupBlobRefs(AH, te);
} }
} }
else
ahlog(AH, 2, "ignoring large-object cross-references for %s %s\n", te->desc, te->tag);
te = te->next;
} }
/* NULL parameter means enable ALL user triggers */ /* NULL parameter means enable ALL user triggers */
_enableTriggersIfNecessary(AH, NULL, ropt); _enableTriggersIfNecessary(AH, NULL, ropt);
} }
/*
* Clean up & we're done.
*/
if (ropt->filename || ropt->compression)
ResetOutput(AH, sav);
if (ropt->useDB)
{
PQfinish(AH->connection);
AH->connection = NULL;
if (AH->blobConnection)
{
PQfinish(AH->blobConnection);
AH->blobConnection = NULL;
}
}
} }
/* /*
...@@ -703,6 +723,9 @@ EndRestoreBlobs(ArchiveHandle *AH) ...@@ -703,6 +723,9 @@ EndRestoreBlobs(ArchiveHandle *AH)
if (AH->blobTxActive) if (AH->blobTxActive)
CommitTransactionXref(AH); CommitTransactionXref(AH);
if (AH->createdBlobXref)
CreateBlobXrefIndex(AH);
ahlog(AH, 1, "restored %d large objects\n", AH->blobCount); ahlog(AH, 1, "restored %d large objects\n", AH->blobCount);
} }
...@@ -2148,7 +2171,7 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat ...@@ -2148,7 +2171,7 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat
pfx, te->tag, te->desc, pfx, te->tag, te->desc,
te->namespace ? te->namespace : "-", te->namespace ? te->namespace : "-",
te->owner); te->owner);
if (AH->PrintExtraTocPtr !=NULL) if (AH->PrintExtraTocPtr != NULL)
(*AH->PrintExtraTocPtr) (AH, te); (*AH->PrintExtraTocPtr) (AH, te);
ahprintf(AH, "--\n\n"); ahprintf(AH, "--\n\n");
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.28 2003/12/06 03:00:11 tgl Exp $ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.29 2004/03/03 21:28:54 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -279,8 +279,9 @@ _PrintExtraToc(ArchiveHandle *AH, TocEntry *te) ...@@ -279,8 +279,9 @@ _PrintExtraToc(ArchiveHandle *AH, TocEntry *te)
{ {
lclTocEntry *ctx = (lclTocEntry *) te->formatData; lclTocEntry *ctx = (lclTocEntry *) te->formatData;
ahprintf(AH, "-- Data Pos: " INT64_FORMAT "\n", if (AH->public.verbose)
(int64) ctx->dataPos); ahprintf(AH, "-- Data Pos: " INT64_FORMAT "\n",
(int64) ctx->dataPos);
} }
/* /*
...@@ -417,8 +418,8 @@ _EndBlobs(ArchiveHandle *AH, TocEntry *te) ...@@ -417,8 +418,8 @@ _EndBlobs(ArchiveHandle *AH, TocEntry *te)
} }
/* /*
* Print data for a gievn TOC entry * Print data for a given TOC entry
*/ */
static void static void
_PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt) _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt)
{ {
...@@ -497,8 +498,6 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt) ...@@ -497,8 +498,6 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt)
blkType); blkType);
break; break;
} }
ahprintf(AH, "\n\n");
} }
/* /*
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* Implements the basic DB functions used by the archiver. * Implements the basic DB functions used by the archiver.
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.51 2003/11/29 19:52:05 pgsql Exp $ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.52 2004/03/03 21:28:54 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -674,13 +674,21 @@ CreateBlobXrefTable(ArchiveHandle *AH) ...@@ -674,13 +674,21 @@ CreateBlobXrefTable(ArchiveHandle *AH)
ahlog(AH, 1, "creating table for large object cross-references\n"); ahlog(AH, 1, "creating table for large object cross-references\n");
appendPQExpBuffer(qry, "Create Temporary Table %s(oldOid pg_catalog.oid, newOid pg_catalog.oid);", BLOB_XREF_TABLE); appendPQExpBuffer(qry, "CREATE TEMPORARY TABLE %s(oldOid pg_catalog.oid, newOid pg_catalog.oid) WITHOUT OIDS", BLOB_XREF_TABLE);
ExecuteSqlCommand(AH, qry, "could not create large object cross-reference table", true); ExecuteSqlCommand(AH, qry, "could not create large object cross-reference table", true);
resetPQExpBuffer(qry); destroyPQExpBuffer(qry);
}
appendPQExpBuffer(qry, "Create Unique Index %s_ix on %s(oldOid)", BLOB_XREF_TABLE, BLOB_XREF_TABLE); void
CreateBlobXrefIndex(ArchiveHandle *AH)
{
PQExpBuffer qry = createPQExpBuffer();
ahlog(AH, 1, "creating index for large object cross-references\n");
appendPQExpBuffer(qry, "CREATE UNIQUE INDEX %s_ix ON %s(oldOid)",
BLOB_XREF_TABLE, BLOB_XREF_TABLE);
ExecuteSqlCommand(AH, qry, "could not create index on large object cross-reference table", true); ExecuteSqlCommand(AH, qry, "could not create index on large object cross-reference table", true);
destroyPQExpBuffer(qry); destroyPQExpBuffer(qry);
...@@ -692,9 +700,8 @@ InsertBlobXref(ArchiveHandle *AH, Oid old, Oid new) ...@@ -692,9 +700,8 @@ InsertBlobXref(ArchiveHandle *AH, Oid old, Oid new)
PQExpBuffer qry = createPQExpBuffer(); PQExpBuffer qry = createPQExpBuffer();
appendPQExpBuffer(qry, appendPQExpBuffer(qry,
"Insert Into %s(oldOid, newOid) Values ('%u', '%u');", "INSERT INTO %s(oldOid, newOid) VALUES ('%u', '%u')",
BLOB_XREF_TABLE, old, new); BLOB_XREF_TABLE, old, new);
ExecuteSqlCommand(AH, qry, "could not create large object cross-reference entry", true); ExecuteSqlCommand(AH, qry, "could not create large object cross-reference entry", true);
destroyPQExpBuffer(qry); destroyPQExpBuffer(qry);
...@@ -705,7 +712,7 @@ StartTransaction(ArchiveHandle *AH) ...@@ -705,7 +712,7 @@ StartTransaction(ArchiveHandle *AH)
{ {
PQExpBuffer qry = createPQExpBuffer(); PQExpBuffer qry = createPQExpBuffer();
appendPQExpBuffer(qry, "Begin;"); appendPQExpBuffer(qry, "BEGIN");
ExecuteSqlCommand(AH, qry, "could not start database transaction", false); ExecuteSqlCommand(AH, qry, "could not start database transaction", false);
AH->txActive = true; AH->txActive = true;
...@@ -718,7 +725,7 @@ StartTransactionXref(ArchiveHandle *AH) ...@@ -718,7 +725,7 @@ StartTransactionXref(ArchiveHandle *AH)
{ {
PQExpBuffer qry = createPQExpBuffer(); PQExpBuffer qry = createPQExpBuffer();
appendPQExpBuffer(qry, "Begin;"); appendPQExpBuffer(qry, "BEGIN");
ExecuteSqlCommand(AH, qry, ExecuteSqlCommand(AH, qry,
"could not start transaction for large object cross-references", true); "could not start transaction for large object cross-references", true);
...@@ -732,7 +739,7 @@ CommitTransaction(ArchiveHandle *AH) ...@@ -732,7 +739,7 @@ CommitTransaction(ArchiveHandle *AH)
{ {
PQExpBuffer qry = createPQExpBuffer(); PQExpBuffer qry = createPQExpBuffer();
appendPQExpBuffer(qry, "Commit;"); appendPQExpBuffer(qry, "COMMIT");
ExecuteSqlCommand(AH, qry, "could not commit database transaction", false); ExecuteSqlCommand(AH, qry, "could not commit database transaction", false);
AH->txActive = false; AH->txActive = false;
...@@ -745,7 +752,7 @@ CommitTransactionXref(ArchiveHandle *AH) ...@@ -745,7 +752,7 @@ CommitTransactionXref(ArchiveHandle *AH)
{ {
PQExpBuffer qry = createPQExpBuffer(); PQExpBuffer qry = createPQExpBuffer();
appendPQExpBuffer(qry, "Commit;"); appendPQExpBuffer(qry, "COMMIT");
ExecuteSqlCommand(AH, qry, "could not commit transaction for large object cross-references", true); ExecuteSqlCommand(AH, qry, "could not commit transaction for large object cross-references", true);
AH->blobTxActive = false; AH->blobTxActive = false;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Definitions for pg_backup_db.c * Definitions for pg_backup_db.c
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_db.h,v 1.9 2003/11/29 19:52:05 pgsql Exp $ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_db.h,v 1.10 2004/03/03 21:28:54 tgl Exp $
*/ */
#define BLOB_XREF_TABLE "pg_dump_blob_xref" /* MUST be lower case */ #define BLOB_XREF_TABLE "pg_dump_blob_xref" /* MUST be lower case */
...@@ -12,6 +12,7 @@ extern int ExecuteSqlCommand(ArchiveHandle *AH, PQExpBuffer qry, char *desc, boo ...@@ -12,6 +12,7 @@ extern int ExecuteSqlCommand(ArchiveHandle *AH, PQExpBuffer qry, char *desc, boo
extern int ExecuteSqlCommandBuf(ArchiveHandle *AH, void *qry, size_t bufLen); extern int ExecuteSqlCommandBuf(ArchiveHandle *AH, void *qry, size_t bufLen);
extern void CreateBlobXrefTable(ArchiveHandle *AH); extern void CreateBlobXrefTable(ArchiveHandle *AH);
extern void CreateBlobXrefIndex(ArchiveHandle *AH);
extern void InsertBlobXref(ArchiveHandle *AH, Oid old, Oid new); extern void InsertBlobXref(ArchiveHandle *AH, Oid old, Oid new);
extern void StartTransaction(ArchiveHandle *AH); extern void StartTransaction(ArchiveHandle *AH);
extern void StartTransactionXref(ArchiveHandle *AH); extern void StartTransactionXref(ArchiveHandle *AH);
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.24 2003/12/06 03:00:11 tgl Exp $ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.25 2004/03/03 21:28:54 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -224,7 +224,8 @@ _PrintExtraToc(ArchiveHandle *AH, TocEntry *te) ...@@ -224,7 +224,8 @@ _PrintExtraToc(ArchiveHandle *AH, TocEntry *te)
{ {
lclTocEntry *ctx = (lclTocEntry *) te->formatData; lclTocEntry *ctx = (lclTocEntry *) te->formatData;
ahprintf(AH, "-- File: %s\n", ctx->filename); if (AH->public.verbose)
ahprintf(AH, "-- File: %s\n", ctx->filename);
} }
static void static void
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.41 2003/12/08 16:39:05 tgl Exp $ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.42 2004/03/03 21:28:54 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -309,7 +309,7 @@ _PrintExtraToc(ArchiveHandle *AH, TocEntry *te) ...@@ -309,7 +309,7 @@ _PrintExtraToc(ArchiveHandle *AH, TocEntry *te)
{ {
lclTocEntry *ctx = (lclTocEntry *) te->formatData; lclTocEntry *ctx = (lclTocEntry *) te->formatData;
if (ctx->filename != NULL) if (AH->public.verbose && ctx->filename != NULL)
ahprintf(AH, "-- File: %s\n", ctx->filename); ahprintf(AH, "-- File: %s\n", ctx->filename);
} }
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* by PostgreSQL * by PostgreSQL
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.366 2004/03/02 21:14:44 tgl Exp $ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.367 2004/03/03 21:28:54 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -544,6 +544,18 @@ main(int argc, char **argv) ...@@ -544,6 +544,18 @@ main(int argc, char **argv)
if (!schemaOnly) if (!schemaOnly)
getTableData(tblinfo, numTables, oids); getTableData(tblinfo, numTables, oids);
if (outputBlobs)
{
/* This is just a placeholder to allow correct sorting of blobs */
DumpableObject *blobobj;
blobobj = (DumpableObject *) malloc(sizeof(DumpableObject));
blobobj->objType = DO_BLOBS;
blobobj->catId = nilCatalogId;
AssignDumpId(blobobj);
blobobj->name = strdup("BLOBS");
}
/* /*
* Collect dependency data to assist in ordering the objects. * Collect dependency data to assist in ordering the objects.
*/ */
...@@ -551,10 +563,20 @@ main(int argc, char **argv) ...@@ -551,10 +563,20 @@ main(int argc, char **argv)
/* /*
* Sort the objects into a safe dump order (no forward references). * Sort the objects into a safe dump order (no forward references).
*
* 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.
*/ */
getDumpableObjects(&dobjs, &numObjs); getDumpableObjects(&dobjs, &numObjs);
sortDumpableObjectsByType(dobjs, numObjs); if (g_fout->remoteVersion >= 70300)
sortDumpableObjectsByTypeName(dobjs, numObjs);
else
sortDumpableObjectsByTypeOid(dobjs, numObjs);
sortDumpableObjects(dobjs, numObjs); sortDumpableObjects(dobjs, numObjs);
/* /*
...@@ -579,14 +601,6 @@ main(int argc, char **argv) ...@@ -579,14 +601,6 @@ main(int argc, char **argv)
dumpDumpableObject(g_fout, dobjs[i]); dumpDumpableObject(g_fout, dobjs[i]);
} }
/* BLOBs are always last (XXX is this right?) */
if (outputBlobs)
ArchiveEntry(g_fout, nilCatalogId, createDumpId(),
"BLOBS", NULL, "",
"BLOBS", "", "", NULL,
NULL, 0,
dumpBlobs, NULL);
/* /*
* And finally we can do the actual output. * And finally we can do the actual output.
*/ */
...@@ -692,13 +706,13 @@ selectDumpableNamespace(NamespaceInfo *nsinfo) ...@@ -692,13 +706,13 @@ selectDumpableNamespace(NamespaceInfo *nsinfo)
nsinfo->dump = false; nsinfo->dump = false;
else if (selectSchemaName != NULL) else if (selectSchemaName != NULL)
{ {
if (strcmp(nsinfo->nspname, selectSchemaName) == 0) if (strcmp(nsinfo->dobj.name, selectSchemaName) == 0)
nsinfo->dump = true; nsinfo->dump = true;
else else
nsinfo->dump = false; nsinfo->dump = false;
} }
else if (strncmp(nsinfo->nspname, "pg_", 3) == 0 || else if (strncmp(nsinfo->dobj.name, "pg_", 3) == 0 ||
strcmp(nsinfo->nspname, "information_schema") == 0) strcmp(nsinfo->dobj.name, "information_schema") == 0)
nsinfo->dump = false; nsinfo->dump = false;
else else
nsinfo->dump = true; nsinfo->dump = true;
...@@ -717,15 +731,15 @@ selectDumpableTable(TableInfo *tbinfo) ...@@ -717,15 +731,15 @@ selectDumpableTable(TableInfo *tbinfo)
* not dump. * not dump.
*/ */
tbinfo->dump = false; tbinfo->dump = false;
if (tbinfo->relnamespace->dump) if (tbinfo->dobj.namespace->dump)
tbinfo->dump = true; tbinfo->dump = true;
else if (selectTableName != NULL && else if (selectTableName != NULL &&
strcmp(tbinfo->relname, selectTableName) == 0) strcmp(tbinfo->dobj.name, selectTableName) == 0)
{ {
/* If both -s and -t specified, must match both to dump */ /* If both -s and -t specified, must match both to dump */
if (selectSchemaName == NULL) if (selectSchemaName == NULL)
tbinfo->dump = true; tbinfo->dump = true;
else if (strcmp(tbinfo->relnamespace->nspname, selectSchemaName) == 0) else if (strcmp(tbinfo->dobj.namespace->dobj.name, selectSchemaName) == 0)
tbinfo->dump = true; tbinfo->dump = true;
} }
} }
...@@ -743,7 +757,7 @@ dumpTableData_copy(Archive *fout, void *dcontext) ...@@ -743,7 +757,7 @@ dumpTableData_copy(Archive *fout, void *dcontext)
{ {
TableDataInfo *tdinfo = (TableDataInfo *) dcontext; TableDataInfo *tdinfo = (TableDataInfo *) dcontext;
TableInfo *tbinfo = tdinfo->tdtable; TableInfo *tbinfo = tdinfo->tdtable;
const char *classname = tbinfo->relname; const char *classname = tbinfo->dobj.name;
const bool hasoids = tbinfo->hasoids; const bool hasoids = tbinfo->hasoids;
const bool oids = tdinfo->oids; const bool oids = tdinfo->oids;
PQExpBuffer q = createPQExpBuffer(); PQExpBuffer q = createPQExpBuffer();
...@@ -762,7 +776,7 @@ dumpTableData_copy(Archive *fout, void *dcontext) ...@@ -762,7 +776,7 @@ dumpTableData_copy(Archive *fout, void *dcontext)
* but this ensures reproducible results in case the table contains * but this ensures reproducible results in case the table contains
* regproc, regclass, etc columns. * regproc, regclass, etc columns.
*/ */
selectSourceSchema(tbinfo->relnamespace->nspname); selectSourceSchema(tbinfo->dobj.namespace->dobj.name);
/* /*
* If possible, specify the column list explicitly so that we have no * If possible, specify the column list explicitly so that we have no
...@@ -778,14 +792,14 @@ dumpTableData_copy(Archive *fout, void *dcontext) ...@@ -778,14 +792,14 @@ dumpTableData_copy(Archive *fout, void *dcontext)
if (oids && hasoids) if (oids && hasoids)
{ {
appendPQExpBuffer(q, "COPY %s %s WITH OIDS TO stdout;", appendPQExpBuffer(q, "COPY %s %s WITH OIDS TO stdout;",
fmtQualifiedId(tbinfo->relnamespace->nspname, fmtQualifiedId(tbinfo->dobj.namespace->dobj.name,
classname), classname),
column_list); column_list);
} }
else else
{ {
appendPQExpBuffer(q, "COPY %s %s TO stdout;", appendPQExpBuffer(q, "COPY %s %s TO stdout;",
fmtQualifiedId(tbinfo->relnamespace->nspname, fmtQualifiedId(tbinfo->dobj.namespace->dobj.name,
classname), classname),
column_list); column_list);
} }
...@@ -882,7 +896,7 @@ dumpTableData_insert(Archive *fout, void *dcontext) ...@@ -882,7 +896,7 @@ dumpTableData_insert(Archive *fout, void *dcontext)
{ {
TableDataInfo *tdinfo = (TableDataInfo *) dcontext; TableDataInfo *tdinfo = (TableDataInfo *) dcontext;
TableInfo *tbinfo = tdinfo->tdtable; TableInfo *tbinfo = tdinfo->tdtable;
const char *classname = tbinfo->relname; const char *classname = tbinfo->dobj.name;
PQExpBuffer q = createPQExpBuffer(); PQExpBuffer q = createPQExpBuffer();
PGresult *res; PGresult *res;
int tuple; int tuple;
...@@ -895,20 +909,20 @@ dumpTableData_insert(Archive *fout, void *dcontext) ...@@ -895,20 +909,20 @@ dumpTableData_insert(Archive *fout, void *dcontext)
* but this ensures reproducible results in case the table contains * but this ensures reproducible results in case the table contains
* regproc, regclass, etc columns. * regproc, regclass, etc columns.
*/ */
selectSourceSchema(tbinfo->relnamespace->nspname); selectSourceSchema(tbinfo->dobj.namespace->dobj.name);
if (fout->remoteVersion >= 70100) if (fout->remoteVersion >= 70100)
{ {
appendPQExpBuffer(q, "DECLARE _pg_dump_cursor CURSOR FOR " appendPQExpBuffer(q, "DECLARE _pg_dump_cursor CURSOR FOR "
"SELECT * FROM ONLY %s", "SELECT * FROM ONLY %s",
fmtQualifiedId(tbinfo->relnamespace->nspname, fmtQualifiedId(tbinfo->dobj.namespace->dobj.name,
classname)); classname));
} }
else else
{ {
appendPQExpBuffer(q, "DECLARE _pg_dump_cursor CURSOR FOR " appendPQExpBuffer(q, "DECLARE _pg_dump_cursor CURSOR FOR "
"SELECT * FROM %s", "SELECT * FROM %s",
fmtQualifiedId(tbinfo->relnamespace->nspname, fmtQualifiedId(tbinfo->dobj.namespace->dobj.name,
classname)); classname));
} }
...@@ -1044,7 +1058,7 @@ dumpTableData(Archive *fout, TableDataInfo *tdinfo) ...@@ -1044,7 +1058,7 @@ dumpTableData(Archive *fout, TableDataInfo *tdinfo)
dumpFn = dumpTableData_copy; dumpFn = dumpTableData_copy;
/* must use 2 steps here 'cause fmtId is nonreentrant */ /* must use 2 steps here 'cause fmtId is nonreentrant */
appendPQExpBuffer(copyBuf, "COPY %s ", appendPQExpBuffer(copyBuf, "COPY %s ",
fmtId(tbinfo->relname)); fmtId(tbinfo->dobj.name));
appendPQExpBuffer(copyBuf, "%s %sFROM stdin;\n", appendPQExpBuffer(copyBuf, "%s %sFROM stdin;\n",
fmtCopyColumnList(tbinfo), fmtCopyColumnList(tbinfo),
(tdinfo->oids && tbinfo->hasoids) ? "WITH OIDS " : ""); (tdinfo->oids && tbinfo->hasoids) ? "WITH OIDS " : "");
...@@ -1058,8 +1072,8 @@ dumpTableData(Archive *fout, TableDataInfo *tdinfo) ...@@ -1058,8 +1072,8 @@ dumpTableData(Archive *fout, TableDataInfo *tdinfo)
} }
ArchiveEntry(fout, tdinfo->dobj.catId, tdinfo->dobj.dumpId, ArchiveEntry(fout, tdinfo->dobj.catId, tdinfo->dobj.dumpId,
tbinfo->relname, tbinfo->dobj.name,
tbinfo->relnamespace->nspname, tbinfo->dobj.namespace->dobj.name,
tbinfo->usename, tbinfo->usename,
"TABLE DATA", "", "", copyStmt, "TABLE DATA", "", "", copyStmt,
tdinfo->dobj.dependencies, tdinfo->dobj.nDeps, tdinfo->dobj.dependencies, tdinfo->dobj.nDeps,
...@@ -1100,6 +1114,8 @@ getTableData(TableInfo *tblinfo, int numTables, bool oids) ...@@ -1100,6 +1114,8 @@ getTableData(TableInfo *tblinfo, int numTables, bool oids)
tdinfo->dobj.catId.tableoid = 0; tdinfo->dobj.catId.tableoid = 0;
tdinfo->dobj.catId.oid = tblinfo[i].dobj.catId.oid; tdinfo->dobj.catId.oid = tblinfo[i].dobj.catId.oid;
AssignDumpId(&tdinfo->dobj); AssignDumpId(&tdinfo->dobj);
tdinfo->dobj.name = tblinfo[i].dobj.name;
tdinfo->dobj.namespace = tblinfo[i].dobj.namespace;
tdinfo->tdtable = &(tblinfo[i]); tdinfo->tdtable = &(tblinfo[i]);
tdinfo->oids = oids; tdinfo->oids = oids;
addObjectDependency(&tdinfo->dobj, tblinfo[i].dobj.dumpId); addObjectDependency(&tdinfo->dobj, tblinfo[i].dobj.dumpId);
...@@ -1415,7 +1431,7 @@ getNamespaces(int *numNamespaces) ...@@ -1415,7 +1431,7 @@ getNamespaces(int *numNamespaces)
nsinfo[0].dobj.catId.tableoid = 0; nsinfo[0].dobj.catId.tableoid = 0;
nsinfo[0].dobj.catId.oid = 0; nsinfo[0].dobj.catId.oid = 0;
AssignDumpId(&nsinfo[0].dobj); AssignDumpId(&nsinfo[0].dobj);
nsinfo[0].nspname = strdup(""); nsinfo[0].dobj.name = strdup("");
nsinfo[0].usename = strdup(""); nsinfo[0].usename = strdup("");
nsinfo[0].nspacl = strdup(""); nsinfo[0].nspacl = strdup("");
...@@ -1425,7 +1441,7 @@ getNamespaces(int *numNamespaces) ...@@ -1425,7 +1441,7 @@ getNamespaces(int *numNamespaces)
nsinfo[1].dobj.catId.tableoid = 0; nsinfo[1].dobj.catId.tableoid = 0;
nsinfo[1].dobj.catId.oid = 1; nsinfo[1].dobj.catId.oid = 1;
AssignDumpId(&nsinfo[1].dobj); AssignDumpId(&nsinfo[1].dobj);
nsinfo[1].nspname = strdup("pg_catalog"); nsinfo[1].dobj.name = strdup("pg_catalog");
nsinfo[1].usename = strdup(""); nsinfo[1].usename = strdup("");
nsinfo[1].nspacl = strdup(""); nsinfo[1].nspacl = strdup("");
...@@ -1470,7 +1486,7 @@ getNamespaces(int *numNamespaces) ...@@ -1470,7 +1486,7 @@ getNamespaces(int *numNamespaces)
nsinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid)); nsinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid));
nsinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid)); nsinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid));
AssignDumpId(&nsinfo[i].dobj); AssignDumpId(&nsinfo[i].dobj);
nsinfo[i].nspname = strdup(PQgetvalue(res, i, i_nspname)); nsinfo[i].dobj.name = strdup(PQgetvalue(res, i, i_nspname));
nsinfo[i].usename = strdup(PQgetvalue(res, i, i_usename)); nsinfo[i].usename = strdup(PQgetvalue(res, i, i_usename));
nsinfo[i].nspacl = strdup(PQgetvalue(res, i, i_nspacl)); nsinfo[i].nspacl = strdup(PQgetvalue(res, i, i_nspacl));
...@@ -1479,7 +1495,7 @@ getNamespaces(int *numNamespaces) ...@@ -1479,7 +1495,7 @@ getNamespaces(int *numNamespaces)
if (strlen(nsinfo[i].usename) == 0) if (strlen(nsinfo[i].usename) == 0)
write_msg(NULL, "WARNING: owner of schema \"%s\" appears to be invalid\n", write_msg(NULL, "WARNING: owner of schema \"%s\" appears to be invalid\n",
nsinfo[i].nspname); nsinfo[i].dobj.name);
} }
/* /*
...@@ -1489,7 +1505,7 @@ getNamespaces(int *numNamespaces) ...@@ -1489,7 +1505,7 @@ getNamespaces(int *numNamespaces)
if (selectSchemaName) if (selectSchemaName)
{ {
for (i = 0; i < ntups; i++) for (i = 0; i < ntups; i++)
if (strcmp(nsinfo[i].nspname, selectSchemaName) == 0) if (strcmp(nsinfo[i].dobj.name, selectSchemaName) == 0)
break; break;
/* Didn't find a match */ /* Didn't find a match */
...@@ -1659,8 +1675,8 @@ getTypes(int *numTypes) ...@@ -1659,8 +1675,8 @@ getTypes(int *numTypes)
tinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid)); tinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid));
tinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid)); tinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid));
AssignDumpId(&tinfo[i].dobj); AssignDumpId(&tinfo[i].dobj);
tinfo[i].typname = strdup(PQgetvalue(res, i, i_typname)); tinfo[i].dobj.name = strdup(PQgetvalue(res, i, i_typname));
tinfo[i].typnamespace = findNamespace(atooid(PQgetvalue(res, i, i_typnamespace)), 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].usename = strdup(PQgetvalue(res, i, i_usename));
tinfo[i].typinput = atooid(PQgetvalue(res, i, i_typinput)); tinfo[i].typinput = atooid(PQgetvalue(res, i, i_typinput));
...@@ -1670,11 +1686,20 @@ getTypes(int *numTypes) ...@@ -1670,11 +1686,20 @@ getTypes(int *numTypes)
tinfo[i].typrelkind = *PQgetvalue(res, i, i_typrelkind); tinfo[i].typrelkind = *PQgetvalue(res, i, i_typrelkind);
tinfo[i].typtype = *PQgetvalue(res, i, i_typtype); tinfo[i].typtype = *PQgetvalue(res, i, i_typtype);
/*
* 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
* an ordinary type because that would bring the table up into the
* datatype part of the dump order.)
*/
if (OidIsValid(tinfo[i].typrelid) && tinfo[i].typrelkind != 'c')
tinfo[i].dobj.objType = DO_TABLE_TYPE;
/* /*
* check for user-defined array types, omit system generated ones * check for user-defined array types, omit system generated ones
*/ */
if (OidIsValid(tinfo[i].typelem) && if (OidIsValid(tinfo[i].typelem) &&
tinfo[i].typname[0] != '_') tinfo[i].dobj.name[0] != '_')
tinfo[i].isArray = true; tinfo[i].isArray = true;
else else
tinfo[i].isArray = false; tinfo[i].isArray = false;
...@@ -1709,7 +1734,7 @@ getTypes(int *numTypes) ...@@ -1709,7 +1734,7 @@ getTypes(int *numTypes)
if (strlen(tinfo[i].usename) == 0 && tinfo[i].isDefined) if (strlen(tinfo[i].usename) == 0 && tinfo[i].isDefined)
write_msg(NULL, "WARNING: owner of data type \"%s\" appears to be invalid\n", write_msg(NULL, "WARNING: owner of data type \"%s\" appears to be invalid\n",
tinfo[i].typname); tinfo[i].dobj.name);
} }
*numTypes = ntups; *numTypes = ntups;
...@@ -1799,15 +1824,15 @@ getOperators(int *numOprs) ...@@ -1799,15 +1824,15 @@ getOperators(int *numOprs)
oprinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid)); oprinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid));
oprinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid)); oprinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid));
AssignDumpId(&oprinfo[i].dobj); AssignDumpId(&oprinfo[i].dobj);
oprinfo[i].oprname = strdup(PQgetvalue(res, i, i_oprname)); oprinfo[i].dobj.name = strdup(PQgetvalue(res, i, i_oprname));
oprinfo[i].oprnamespace = findNamespace(atooid(PQgetvalue(res, i, i_oprnamespace)), 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].usename = strdup(PQgetvalue(res, i, i_usename));
oprinfo[i].oprcode = atooid(PQgetvalue(res, i, i_oprcode)); oprinfo[i].oprcode = atooid(PQgetvalue(res, i, i_oprcode));
if (strlen(oprinfo[i].usename) == 0) if (strlen(oprinfo[i].usename) == 0)
write_msg(NULL, "WARNING: owner of operator \"%s\" appears to be invalid\n", write_msg(NULL, "WARNING: owner of operator \"%s\" appears to be invalid\n",
oprinfo[i].oprname); oprinfo[i].dobj.name);
} }
PQclear(res); PQclear(res);
...@@ -1877,8 +1902,8 @@ getConversions(int *numConversions) ...@@ -1877,8 +1902,8 @@ getConversions(int *numConversions)
convinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid)); convinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid));
convinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid)); convinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid));
AssignDumpId(&convinfo[i].dobj); AssignDumpId(&convinfo[i].dobj);
convinfo[i].conname = strdup(PQgetvalue(res, i, i_conname)); convinfo[i].dobj.name = strdup(PQgetvalue(res, i, i_conname));
convinfo[i].connamespace = findNamespace(atooid(PQgetvalue(res, i, i_connamespace)), 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)); convinfo[i].usename = strdup(PQgetvalue(res, i, i_usename));
} }
...@@ -1963,8 +1988,8 @@ getOpclasses(int *numOpclasses) ...@@ -1963,8 +1988,8 @@ getOpclasses(int *numOpclasses)
opcinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid)); opcinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid));
opcinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid)); opcinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid));
AssignDumpId(&opcinfo[i].dobj); AssignDumpId(&opcinfo[i].dobj);
opcinfo[i].opcname = strdup(PQgetvalue(res, i, i_opcname)); opcinfo[i].dobj.name = strdup(PQgetvalue(res, i, i_opcname));
opcinfo[i].opcnamespace = findNamespace(atooid(PQgetvalue(res, i, i_opcnamespace)), 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)); opcinfo[i].usename = strdup(PQgetvalue(res, i, i_usename));
...@@ -1972,7 +1997,7 @@ getOpclasses(int *numOpclasses) ...@@ -1972,7 +1997,7 @@ getOpclasses(int *numOpclasses)
{ {
if (strlen(opcinfo[i].usename) == 0) if (strlen(opcinfo[i].usename) == 0)
write_msg(NULL, "WARNING: owner of operator class \"%s\" appears to be invalid\n", write_msg(NULL, "WARNING: owner of operator class \"%s\" appears to be invalid\n",
opcinfo[i].opcname); opcinfo[i].dobj.name);
} }
} }
...@@ -2070,13 +2095,13 @@ getAggregates(int *numAggs) ...@@ -2070,13 +2095,13 @@ getAggregates(int *numAggs)
agginfo[i].aggfn.dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid)); agginfo[i].aggfn.dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid));
agginfo[i].aggfn.dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid)); agginfo[i].aggfn.dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid));
AssignDumpId(&agginfo[i].aggfn.dobj); AssignDumpId(&agginfo[i].aggfn.dobj);
agginfo[i].aggfn.proname = strdup(PQgetvalue(res, i, i_aggname)); agginfo[i].aggfn.dobj.name = strdup(PQgetvalue(res, i, i_aggname));
agginfo[i].aggfn.pronamespace = findNamespace(atooid(PQgetvalue(res, i, i_aggnamespace)), 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)); agginfo[i].aggfn.usename = strdup(PQgetvalue(res, i, i_usename));
if (strlen(agginfo[i].aggfn.usename) == 0) if (strlen(agginfo[i].aggfn.usename) == 0)
write_msg(NULL, "WARNING: owner of aggregate function \"%s\" appears to be invalid\n", write_msg(NULL, "WARNING: owner of aggregate function \"%s\" appears to be invalid\n",
agginfo[i].aggfn.proname); 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.nargs = 1;
agginfo[i].aggfn.argtypes = (Oid *) malloc(sizeof(Oid)); agginfo[i].aggfn.argtypes = (Oid *) malloc(sizeof(Oid));
...@@ -2190,8 +2215,8 @@ getFuncs(int *numFuncs) ...@@ -2190,8 +2215,8 @@ getFuncs(int *numFuncs)
finfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid)); finfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid));
finfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid)); finfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid));
AssignDumpId(&finfo[i].dobj); AssignDumpId(&finfo[i].dobj);
finfo[i].proname = strdup(PQgetvalue(res, i, i_proname)); finfo[i].dobj.name = strdup(PQgetvalue(res, i, i_proname));
finfo[i].pronamespace = findNamespace(atooid(PQgetvalue(res, i, i_pronamespace)), 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].usename = strdup(PQgetvalue(res, i, i_usename));
finfo[i].lang = atooid(PQgetvalue(res, i, i_prolang)); finfo[i].lang = atooid(PQgetvalue(res, i, i_prolang));
...@@ -2209,7 +2234,7 @@ getFuncs(int *numFuncs) ...@@ -2209,7 +2234,7 @@ getFuncs(int *numFuncs)
if (strlen(finfo[i].usename) == 0) if (strlen(finfo[i].usename) == 0)
write_msg(NULL, "WARNING: owner of function \"%s\" appears to be invalid\n", write_msg(NULL, "WARNING: owner of function \"%s\" appears to be invalid\n",
finfo[i].proname); finfo[i].dobj.name);
} }
PQclear(res); PQclear(res);
...@@ -2395,8 +2420,8 @@ getTables(int *numTables) ...@@ -2395,8 +2420,8 @@ getTables(int *numTables)
tblinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_reltableoid)); tblinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_reltableoid));
tblinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_reloid)); tblinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_reloid));
AssignDumpId(&tblinfo[i].dobj); AssignDumpId(&tblinfo[i].dobj);
tblinfo[i].relname = strdup(PQgetvalue(res, i, i_relname)); tblinfo[i].dobj.name = strdup(PQgetvalue(res, i, i_relname));
tblinfo[i].relnamespace = findNamespace(atooid(PQgetvalue(res, i, i_relnamespace)), 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].usename = strdup(PQgetvalue(res, i, i_usename));
tblinfo[i].relacl = strdup(PQgetvalue(res, i, i_relacl)); tblinfo[i].relacl = strdup(PQgetvalue(res, i, i_relacl));
...@@ -2446,15 +2471,15 @@ getTables(int *numTables) ...@@ -2446,15 +2471,15 @@ getTables(int *numTables)
resetPQExpBuffer(lockquery); resetPQExpBuffer(lockquery);
appendPQExpBuffer(lockquery, appendPQExpBuffer(lockquery,
"LOCK TABLE %s IN ACCESS SHARE MODE", "LOCK TABLE %s IN ACCESS SHARE MODE",
fmtQualifiedId(tblinfo[i].relnamespace->nspname, fmtQualifiedId(tblinfo[i].dobj.namespace->dobj.name,
tblinfo[i].relname)); tblinfo[i].dobj.name));
do_sql_command(g_conn, lockquery->data); do_sql_command(g_conn, lockquery->data);
} }
/* Emit notice if join for owner failed */ /* Emit notice if join for owner failed */
if (strlen(tblinfo[i].usename) == 0) if (strlen(tblinfo[i].usename) == 0)
write_msg(NULL, "WARNING: owner of table \"%s\" appears to be invalid\n", write_msg(NULL, "WARNING: owner of table \"%s\" appears to be invalid\n",
tblinfo[i].relname); tblinfo[i].dobj.name);
} }
/* /*
...@@ -2465,7 +2490,7 @@ getTables(int *numTables) ...@@ -2465,7 +2490,7 @@ getTables(int *numTables)
if (selectTableName) if (selectTableName)
{ {
for (i = 0; i < ntups; i++) for (i = 0; i < ntups; i++)
if (strcmp(tblinfo[i].relname, selectTableName) == 0) if (strcmp(tblinfo[i].dobj.name, selectTableName) == 0)
break; break;
/* Didn't find a match */ /* Didn't find a match */
...@@ -2578,10 +2603,10 @@ getIndexes(TableInfo tblinfo[], int numTables) ...@@ -2578,10 +2603,10 @@ getIndexes(TableInfo tblinfo[], int numTables)
if (g_verbose) if (g_verbose)
write_msg(NULL, "reading indexes for table \"%s\"\n", write_msg(NULL, "reading indexes for table \"%s\"\n",
tbinfo->relname); tbinfo->dobj.name);
/* Make sure we are in proper schema so indexdef is right */ /* Make sure we are in proper schema so indexdef is right */
selectSourceSchema(tbinfo->relnamespace->nspname); selectSourceSchema(tbinfo->dobj.namespace->dobj.name);
/* /*
* The point of the messy-looking outer join is to find a * The point of the messy-looking outer join is to find a
...@@ -2684,7 +2709,8 @@ getIndexes(TableInfo tblinfo[], int numTables) ...@@ -2684,7 +2709,8 @@ getIndexes(TableInfo tblinfo[], int numTables)
indxinfo[j].dobj.catId.tableoid = atooid(PQgetvalue(res, j, i_tableoid)); indxinfo[j].dobj.catId.tableoid = atooid(PQgetvalue(res, j, i_tableoid));
indxinfo[j].dobj.catId.oid = atooid(PQgetvalue(res, j, i_oid)); indxinfo[j].dobj.catId.oid = atooid(PQgetvalue(res, j, i_oid));
AssignDumpId(&indxinfo[j].dobj); AssignDumpId(&indxinfo[j].dobj);
indxinfo[j].indexname = strdup(PQgetvalue(res, j, i_indexname)); indxinfo[j].dobj.name = strdup(PQgetvalue(res, j, i_indexname));
indxinfo[j].dobj.namespace = tbinfo->dobj.namespace;
indxinfo[j].indextable = tbinfo; indxinfo[j].indextable = tbinfo;
indxinfo[j].indexdef = strdup(PQgetvalue(res, j, i_indexdef)); indxinfo[j].indexdef = strdup(PQgetvalue(res, j, i_indexdef));
indxinfo[j].indnkeys = atoi(PQgetvalue(res, j, i_indnkeys)); indxinfo[j].indnkeys = atoi(PQgetvalue(res, j, i_indnkeys));
...@@ -2716,8 +2742,8 @@ getIndexes(TableInfo tblinfo[], int numTables) ...@@ -2716,8 +2742,8 @@ getIndexes(TableInfo tblinfo[], int numTables)
constrinfo[j].dobj.catId.tableoid = atooid(PQgetvalue(res, j, i_contableoid)); constrinfo[j].dobj.catId.tableoid = atooid(PQgetvalue(res, j, i_contableoid));
constrinfo[j].dobj.catId.oid = atooid(PQgetvalue(res, j, i_conoid)); constrinfo[j].dobj.catId.oid = atooid(PQgetvalue(res, j, i_conoid));
AssignDumpId(&constrinfo[j].dobj); AssignDumpId(&constrinfo[j].dobj);
constrinfo[j].dobj.name = strdup(PQgetvalue(res, j, i_conname));
constrinfo[j].conname = strdup(PQgetvalue(res, j, i_conname)); constrinfo[j].dobj.namespace = tbinfo->dobj.namespace;
constrinfo[j].contable = tbinfo; constrinfo[j].contable = tbinfo;
constrinfo[j].condomain = NULL; constrinfo[j].condomain = NULL;
constrinfo[j].contype = contype; constrinfo[j].contype = contype;
...@@ -2783,13 +2809,13 @@ getConstraints(TableInfo tblinfo[], int numTables) ...@@ -2783,13 +2809,13 @@ getConstraints(TableInfo tblinfo[], int numTables)
if (g_verbose) if (g_verbose)
write_msg(NULL, "reading foreign key constraints for table \"%s\"\n", write_msg(NULL, "reading foreign key constraints for table \"%s\"\n",
tbinfo->relname); tbinfo->dobj.name);
/* /*
* select table schema to ensure constraint expr is qualified if * select table schema to ensure constraint expr is qualified if
* needed * needed
*/ */
selectSourceSchema(tbinfo->relnamespace->nspname); selectSourceSchema(tbinfo->dobj.namespace->dobj.name);
resetPQExpBuffer(query); resetPQExpBuffer(query);
appendPQExpBuffer(query, appendPQExpBuffer(query,
...@@ -2817,7 +2843,8 @@ getConstraints(TableInfo tblinfo[], int numTables) ...@@ -2817,7 +2843,8 @@ getConstraints(TableInfo tblinfo[], int numTables)
constrinfo[j].dobj.catId.tableoid = atooid(PQgetvalue(res, j, i_contableoid)); constrinfo[j].dobj.catId.tableoid = atooid(PQgetvalue(res, j, i_contableoid));
constrinfo[j].dobj.catId.oid = atooid(PQgetvalue(res, j, i_conoid)); constrinfo[j].dobj.catId.oid = atooid(PQgetvalue(res, j, i_conoid));
AssignDumpId(&constrinfo[j].dobj); AssignDumpId(&constrinfo[j].dobj);
constrinfo[j].conname = strdup(PQgetvalue(res, j, i_conname)); constrinfo[j].dobj.name = strdup(PQgetvalue(res, j, i_conname));
constrinfo[j].dobj.namespace = tbinfo->dobj.namespace;
constrinfo[j].contable = tbinfo; constrinfo[j].contable = tbinfo;
constrinfo[j].condomain = NULL; constrinfo[j].condomain = NULL;
constrinfo[j].contype = 'f'; constrinfo[j].contype = 'f';
...@@ -2859,7 +2886,7 @@ getDomainConstraints(TypeInfo *tinfo) ...@@ -2859,7 +2886,7 @@ getDomainConstraints(TypeInfo *tinfo)
* select appropriate schema to ensure names in constraint are properly * select appropriate schema to ensure names in constraint are properly
* qualified * qualified
*/ */
selectSourceSchema(tinfo->typnamespace->nspname); selectSourceSchema(tinfo->dobj.namespace->dobj.name);
query = createPQExpBuffer(); query = createPQExpBuffer();
...@@ -2899,7 +2926,8 @@ getDomainConstraints(TypeInfo *tinfo) ...@@ -2899,7 +2926,8 @@ getDomainConstraints(TypeInfo *tinfo)
constrinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid)); constrinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid));
constrinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid)); constrinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid));
AssignDumpId(&constrinfo[i].dobj); AssignDumpId(&constrinfo[i].dobj);
constrinfo[i].conname = strdup(PQgetvalue(res, i, i_conname)); constrinfo[i].dobj.name = strdup(PQgetvalue(res, i, i_conname));
constrinfo[i].dobj.namespace = tinfo->dobj.namespace;
constrinfo[i].contable = NULL; constrinfo[i].contable = NULL;
constrinfo[i].condomain = tinfo; constrinfo[i].condomain = tinfo;
constrinfo[i].contype = 'c'; constrinfo[i].contype = 'c';
...@@ -2986,9 +3014,10 @@ getRules(int *numRules) ...@@ -2986,9 +3014,10 @@ getRules(int *numRules)
ruleinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid)); ruleinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid));
ruleinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid)); ruleinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid));
AssignDumpId(&ruleinfo[i].dobj); AssignDumpId(&ruleinfo[i].dobj);
ruleinfo[i].rulename = strdup(PQgetvalue(res, i, i_rulename)); ruleinfo[i].dobj.name = strdup(PQgetvalue(res, i, i_rulename));
ruletableoid = atooid(PQgetvalue(res, i, i_ruletable)); ruletableoid = atooid(PQgetvalue(res, i, i_ruletable));
ruleinfo[i].ruletable = findTableByOid(ruletableoid); ruleinfo[i].ruletable = findTableByOid(ruletableoid);
ruleinfo[i].dobj.namespace = ruleinfo[i].ruletable->dobj.namespace;
ruleinfo[i].ev_type = *(PQgetvalue(res, i, i_ev_type)); ruleinfo[i].ev_type = *(PQgetvalue(res, i, i_ev_type));
ruleinfo[i].is_instead = *(PQgetvalue(res, i, i_is_instead)) == 't'; ruleinfo[i].is_instead = *(PQgetvalue(res, i, i_is_instead)) == 't';
if (ruleinfo[i].ruletable) if (ruleinfo[i].ruletable)
...@@ -3055,13 +3084,13 @@ getTriggers(TableInfo tblinfo[], int numTables) ...@@ -3055,13 +3084,13 @@ getTriggers(TableInfo tblinfo[], int numTables)
if (g_verbose) if (g_verbose)
write_msg(NULL, "reading triggers for table \"%s\"\n", write_msg(NULL, "reading triggers for table \"%s\"\n",
tbinfo->relname); tbinfo->dobj.name);
/* /*
* select table schema to ensure regproc name is qualified if * select table schema to ensure regproc name is qualified if
* needed * needed
*/ */
selectSourceSchema(tbinfo->relnamespace->nspname); selectSourceSchema(tbinfo->dobj.namespace->dobj.name);
resetPQExpBuffer(query); resetPQExpBuffer(query);
if (g_fout->remoteVersion >= 70300) if (g_fout->remoteVersion >= 70300)
...@@ -3127,7 +3156,7 @@ getTriggers(TableInfo tblinfo[], int numTables) ...@@ -3127,7 +3156,7 @@ getTriggers(TableInfo tblinfo[], int numTables)
if (ntups > tbinfo->ntrig) if (ntups > tbinfo->ntrig)
{ {
write_msg(NULL, "expected %d triggers on table \"%s\" but found %d\n", write_msg(NULL, "expected %d triggers on table \"%s\" but found %d\n",
tbinfo->ntrig, tbinfo->relname, ntups); tbinfo->ntrig, tbinfo->dobj.name, ntups);
exit_nicely(); exit_nicely();
} }
i_tableoid = PQfnumber(res, "tableoid"); i_tableoid = PQfnumber(res, "tableoid");
...@@ -3152,8 +3181,9 @@ getTriggers(TableInfo tblinfo[], int numTables) ...@@ -3152,8 +3181,9 @@ getTriggers(TableInfo tblinfo[], int numTables)
tginfo[j].dobj.catId.tableoid = atooid(PQgetvalue(res, j, i_tableoid)); tginfo[j].dobj.catId.tableoid = atooid(PQgetvalue(res, j, i_tableoid));
tginfo[j].dobj.catId.oid = atooid(PQgetvalue(res, j, i_oid)); tginfo[j].dobj.catId.oid = atooid(PQgetvalue(res, j, i_oid));
AssignDumpId(&tginfo[j].dobj); AssignDumpId(&tginfo[j].dobj);
tginfo[j].dobj.name = strdup(PQgetvalue(res, j, i_tgname));
tginfo[j].dobj.namespace = tbinfo->dobj.namespace;
tginfo[j].tgtable = tbinfo; tginfo[j].tgtable = tbinfo;
tginfo[j].tgname = strdup(PQgetvalue(res, j, i_tgname));
tginfo[j].tgfname = strdup(PQgetvalue(res, j, i_tgfname)); tginfo[j].tgfname = strdup(PQgetvalue(res, j, i_tgfname));
tginfo[j].tgtype = atoi(PQgetvalue(res, j, i_tgtype)); tginfo[j].tgtype = atoi(PQgetvalue(res, j, i_tgtype));
tginfo[j].tgnargs = atoi(PQgetvalue(res, j, i_tgnargs)); tginfo[j].tgnargs = atoi(PQgetvalue(res, j, i_tgnargs));
...@@ -3171,7 +3201,7 @@ getTriggers(TableInfo tblinfo[], int numTables) ...@@ -3171,7 +3201,7 @@ getTriggers(TableInfo tblinfo[], int numTables)
if (PQgetisnull(res, j, i_tgconstrrelname)) if (PQgetisnull(res, j, i_tgconstrrelname))
{ {
write_msg(NULL, "query produced null referenced table name for foreign key trigger \"%s\" on table \"%s\" (OID of table: %u)\n", write_msg(NULL, "query produced null referenced table name for foreign key trigger \"%s\" on table \"%s\" (OID of table: %u)\n",
tginfo[j].tgname, tbinfo->relname, tginfo[j].dobj.name, tbinfo->dobj.name,
tginfo[j].tgconstrrelid); tginfo[j].tgconstrrelid);
exit_nicely(); exit_nicely();
} }
...@@ -3264,7 +3294,7 @@ getProcLangs(int *numProcLangs) ...@@ -3264,7 +3294,7 @@ getProcLangs(int *numProcLangs)
planginfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid)); planginfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid));
AssignDumpId(&planginfo[i].dobj); AssignDumpId(&planginfo[i].dobj);
planginfo[i].lanname = strdup(PQgetvalue(res, i, i_lanname)); planginfo[i].dobj.name = strdup(PQgetvalue(res, i, i_lanname));
planginfo[i].lanpltrusted = *(PQgetvalue(res, i, i_lanpltrusted)) == 't'; planginfo[i].lanpltrusted = *(PQgetvalue(res, i, i_lanpltrusted)) == 't';
planginfo[i].lanplcallfoid = atooid(PQgetvalue(res, i, i_lanplcallfoid)); planginfo[i].lanplcallfoid = atooid(PQgetvalue(res, i, i_lanplcallfoid));
if (g_fout->remoteVersion >= 70300) if (g_fout->remoteVersion >= 70300)
...@@ -3357,6 +3387,10 @@ getCasts(int *numCasts) ...@@ -3357,6 +3387,10 @@ getCasts(int *numCasts)
for (i = 0; i < ntups; i++) for (i = 0; i < ntups; i++)
{ {
PQExpBufferData namebuf;
TypeInfo *sTypeInfo;
TypeInfo *tTypeInfo;
castinfo[i].dobj.objType = DO_CAST; castinfo[i].dobj.objType = DO_CAST;
castinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid)); castinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid));
castinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid)); castinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid));
...@@ -3366,6 +3400,19 @@ getCasts(int *numCasts) ...@@ -3366,6 +3400,19 @@ getCasts(int *numCasts)
castinfo[i].castfunc = atooid(PQgetvalue(res, i, i_castfunc)); castinfo[i].castfunc = atooid(PQgetvalue(res, i, i_castfunc));
castinfo[i].castcontext = *(PQgetvalue(res, i, i_castcontext)); castinfo[i].castcontext = *(PQgetvalue(res, i, i_castcontext));
/*
* Try to name cast as concatenation of typnames. This is only
* used for purposes of sorting. If we fail to find either type,
* the name will be an empty string.
*/
initPQExpBuffer(&namebuf);
sTypeInfo = findTypeByOid(castinfo[i].castsource);
tTypeInfo = findTypeByOid(castinfo[i].casttarget);
if (sTypeInfo && tTypeInfo)
appendPQExpBuffer(&namebuf, "%s %s",
sTypeInfo->dobj.name, tTypeInfo->dobj.name);
castinfo[i].dobj.name = namebuf.data;
if (OidIsValid(castinfo[i].castfunc)) if (OidIsValid(castinfo[i].castfunc))
{ {
/* /*
...@@ -3440,7 +3487,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables) ...@@ -3440,7 +3487,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
* Make sure we are in proper schema for this table; this allows * Make sure we are in proper schema for this table; this allows
* correct retrieval of formatted type names and default exprs * correct retrieval of formatted type names and default exprs
*/ */
selectSourceSchema(tbinfo->relnamespace->nspname); selectSourceSchema(tbinfo->dobj.namespace->dobj.name);
/* find all the user attributes and their types */ /* find all the user attributes and their types */
...@@ -3454,7 +3501,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables) ...@@ -3454,7 +3501,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
*/ */
if (g_verbose) if (g_verbose)
write_msg(NULL, "finding the columns and types of table \"%s\"\n", write_msg(NULL, "finding the columns and types of table \"%s\"\n",
tbinfo->relname); tbinfo->dobj.name);
resetPQExpBuffer(q); resetPQExpBuffer(q);
...@@ -3540,7 +3587,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables) ...@@ -3540,7 +3587,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
if (j + 1 != atoi(PQgetvalue(res, j, i_attnum))) if (j + 1 != atoi(PQgetvalue(res, j, i_attnum)))
{ {
write_msg(NULL, "invalid column numbering in table \"%s\"\n", write_msg(NULL, "invalid column numbering in table \"%s\"\n",
tbinfo->relname); tbinfo->dobj.name);
exit_nicely(); exit_nicely();
} }
tbinfo->attnames[j] = strdup(PQgetvalue(res, j, i_attname)); tbinfo->attnames[j] = strdup(PQgetvalue(res, j, i_attname));
...@@ -3574,7 +3621,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables) ...@@ -3574,7 +3621,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
if (g_verbose) if (g_verbose)
write_msg(NULL, "finding default expressions of table \"%s\"\n", write_msg(NULL, "finding default expressions of table \"%s\"\n",
tbinfo->relname); tbinfo->dobj.name);
resetPQExpBuffer(q); resetPQExpBuffer(q);
if (g_fout->remoteVersion >= 70300) if (g_fout->remoteVersion >= 70300)
...@@ -3630,6 +3677,9 @@ getTableAttrs(TableInfo *tblinfo, int numTables) ...@@ -3630,6 +3677,9 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
attrdefs[j].adnum = adnum = atoi(PQgetvalue(res, j, 2)); attrdefs[j].adnum = adnum = atoi(PQgetvalue(res, j, 2));
attrdefs[j].adef_expr = strdup(PQgetvalue(res, j, 3)); attrdefs[j].adef_expr = strdup(PQgetvalue(res, j, 3));
attrdefs[j].dobj.name = strdup(tbinfo->dobj.name);
attrdefs[j].dobj.namespace = tbinfo->dobj.namespace;
/* /*
* Defaults on a VIEW must always be dumped as separate * Defaults on a VIEW must always be dumped as separate
* ALTER TABLE commands. Defaults on regular tables are * ALTER TABLE commands. Defaults on regular tables are
...@@ -3654,7 +3704,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables) ...@@ -3654,7 +3704,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
if (adnum <= 0 || adnum > ntups) if (adnum <= 0 || adnum > ntups)
{ {
write_msg(NULL, "invalid adnum value %d for table \"%s\"\n", write_msg(NULL, "invalid adnum value %d for table \"%s\"\n",
adnum, tbinfo->relname); adnum, tbinfo->dobj.name);
exit_nicely(); exit_nicely();
} }
tbinfo->attrdefs[adnum - 1] = &attrdefs[j]; tbinfo->attrdefs[adnum - 1] = &attrdefs[j];
...@@ -3672,7 +3722,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables) ...@@ -3672,7 +3722,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
if (g_verbose) if (g_verbose)
write_msg(NULL, "finding check constraints for table \"%s\"\n", write_msg(NULL, "finding check constraints for table \"%s\"\n",
tbinfo->relname); tbinfo->dobj.name);
resetPQExpBuffer(q); resetPQExpBuffer(q);
if (g_fout->remoteVersion >= 70400) if (g_fout->remoteVersion >= 70400)
...@@ -3736,7 +3786,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables) ...@@ -3736,7 +3786,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
if (numConstrs != tbinfo->ncheck) if (numConstrs != tbinfo->ncheck)
{ {
write_msg(NULL, "expected %d check constraints on table \"%s\" but found %d\n", write_msg(NULL, "expected %d check constraints on table \"%s\" but found %d\n",
tbinfo->ncheck, tbinfo->relname, numConstrs); tbinfo->ncheck, tbinfo->dobj.name, numConstrs);
write_msg(NULL, "(The system catalogs might be corrupted.)\n"); write_msg(NULL, "(The system catalogs might be corrupted.)\n");
exit_nicely(); exit_nicely();
} }
...@@ -3750,10 +3800,11 @@ getTableAttrs(TableInfo *tblinfo, int numTables) ...@@ -3750,10 +3800,11 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
constrs[j].dobj.catId.tableoid = atooid(PQgetvalue(res, j, 0)); constrs[j].dobj.catId.tableoid = atooid(PQgetvalue(res, j, 0));
constrs[j].dobj.catId.oid = atooid(PQgetvalue(res, j, 1)); constrs[j].dobj.catId.oid = atooid(PQgetvalue(res, j, 1));
AssignDumpId(&constrs[j].dobj); AssignDumpId(&constrs[j].dobj);
constrs[j].dobj.name = strdup(PQgetvalue(res, j, 2));
constrs[j].dobj.namespace = tbinfo->dobj.namespace;
constrs[j].contable = tbinfo; constrs[j].contable = tbinfo;
constrs[j].condomain = NULL; constrs[j].condomain = NULL;
constrs[j].contype = 'c'; constrs[j].contype = 'c';
constrs[j].conname = strdup(PQgetvalue(res, j, 2));
constrs[j].condef = strdup(PQgetvalue(res, j, 3)); constrs[j].condef = strdup(PQgetvalue(res, j, 3));
constrs[j].conindex = 0; constrs[j].conindex = 0;
constrs[j].coninherited = false; constrs[j].coninherited = false;
...@@ -3969,7 +4020,7 @@ dumpTableComment(Archive *fout, TableInfo *tbinfo, ...@@ -3969,7 +4020,7 @@ dumpTableComment(Archive *fout, TableInfo *tbinfo,
{ {
resetPQExpBuffer(target); resetPQExpBuffer(target);
appendPQExpBuffer(target, "%s %s", reltypename, appendPQExpBuffer(target, "%s %s", reltypename,
fmtId(tbinfo->relname)); fmtId(tbinfo->dobj.name));
resetPQExpBuffer(query); resetPQExpBuffer(query);
appendPQExpBuffer(query, "COMMENT ON %s IS ", target->data); appendPQExpBuffer(query, "COMMENT ON %s IS ", target->data);
...@@ -3978,7 +4029,7 @@ dumpTableComment(Archive *fout, TableInfo *tbinfo, ...@@ -3978,7 +4029,7 @@ dumpTableComment(Archive *fout, TableInfo *tbinfo,
ArchiveEntry(fout, nilCatalogId, createDumpId(), ArchiveEntry(fout, nilCatalogId, createDumpId(),
target->data, target->data,
tbinfo->relnamespace->nspname, tbinfo->usename, tbinfo->dobj.namespace->dobj.name, tbinfo->usename,
"COMMENT", query->data, "", NULL, "COMMENT", query->data, "", NULL,
&(tbinfo->dobj.dumpId), 1, &(tbinfo->dobj.dumpId), 1,
NULL, NULL); NULL, NULL);
...@@ -3987,7 +4038,7 @@ dumpTableComment(Archive *fout, TableInfo *tbinfo, ...@@ -3987,7 +4038,7 @@ dumpTableComment(Archive *fout, TableInfo *tbinfo,
{ {
resetPQExpBuffer(target); resetPQExpBuffer(target);
appendPQExpBuffer(target, "COLUMN %s.", appendPQExpBuffer(target, "COLUMN %s.",
fmtId(tbinfo->relname)); fmtId(tbinfo->dobj.name));
appendPQExpBuffer(target, "%s", appendPQExpBuffer(target, "%s",
fmtId(tbinfo->attnames[objsubid - 1])); fmtId(tbinfo->attnames[objsubid - 1]));
...@@ -3998,7 +4049,7 @@ dumpTableComment(Archive *fout, TableInfo *tbinfo, ...@@ -3998,7 +4049,7 @@ dumpTableComment(Archive *fout, TableInfo *tbinfo,
ArchiveEntry(fout, nilCatalogId, createDumpId(), ArchiveEntry(fout, nilCatalogId, createDumpId(),
target->data, target->data,
tbinfo->relnamespace->nspname, tbinfo->usename, tbinfo->dobj.namespace->dobj.name, tbinfo->usename,
"COMMENT", query->data, "", NULL, "COMMENT", query->data, "", NULL,
&(tbinfo->dobj.dumpId), 1, &(tbinfo->dobj.dumpId), 1,
NULL, NULL); NULL, NULL);
...@@ -4072,6 +4123,16 @@ dumpDumpableObject(Archive *fout, DumpableObject *dobj) ...@@ -4072,6 +4123,16 @@ dumpDumpableObject(Archive *fout, DumpableObject *dobj)
case DO_TABLE_DATA: case DO_TABLE_DATA:
dumpTableData(fout, (TableDataInfo *) dobj); dumpTableData(fout, (TableDataInfo *) dobj);
break; break;
case DO_TABLE_TYPE:
/* table rowtypes are never dumped separately */
break;
case DO_BLOBS:
ArchiveEntry(fout, dobj->catId, dobj->dumpId,
dobj->name, NULL, "",
"BLOBS", "", "", NULL,
NULL, 0,
dumpBlobs, NULL);
break;
} }
} }
...@@ -4091,13 +4152,13 @@ dumpNamespace(Archive *fout, NamespaceInfo *nspinfo) ...@@ -4091,13 +4152,13 @@ dumpNamespace(Archive *fout, NamespaceInfo *nspinfo)
return; return;
/* don't dump dummy namespace from pre-7.3 source */ /* don't dump dummy namespace from pre-7.3 source */
if (strlen(nspinfo->nspname) == 0) if (strlen(nspinfo->dobj.name) == 0)
return; return;
q = createPQExpBuffer(); q = createPQExpBuffer();
delq = createPQExpBuffer(); delq = createPQExpBuffer();
qnspname = strdup(fmtId(nspinfo->nspname)); qnspname = strdup(fmtId(nspinfo->dobj.name));
/* /*
* If it's the PUBLIC namespace, suppress the CREATE SCHEMA record * If it's the PUBLIC namespace, suppress the CREATE SCHEMA record
...@@ -4112,7 +4173,7 @@ dumpNamespace(Archive *fout, NamespaceInfo *nspinfo) ...@@ -4112,7 +4173,7 @@ dumpNamespace(Archive *fout, NamespaceInfo *nspinfo)
* users without CREATE SCHEMA privilege. Further hacking has * users without CREATE SCHEMA privilege. Further hacking has
* to be applied for --no-owner mode, though! * to be applied for --no-owner mode, though!
*/ */
if (strcmp(nspinfo->nspname, "public") != 0) if (strcmp(nspinfo->dobj.name, "public") != 0)
{ {
appendPQExpBuffer(delq, "DROP SCHEMA %s;\n", qnspname); appendPQExpBuffer(delq, "DROP SCHEMA %s;\n", qnspname);
...@@ -4120,7 +4181,7 @@ dumpNamespace(Archive *fout, NamespaceInfo *nspinfo) ...@@ -4120,7 +4181,7 @@ dumpNamespace(Archive *fout, NamespaceInfo *nspinfo)
qnspname, fmtId(nspinfo->usename)); qnspname, fmtId(nspinfo->usename));
ArchiveEntry(fout, nspinfo->dobj.catId, nspinfo->dobj.dumpId, ArchiveEntry(fout, nspinfo->dobj.catId, nspinfo->dobj.dumpId,
nspinfo->nspname, nspinfo->dobj.name,
NULL, "", NULL, "",
"SCHEMA", q->data, delq->data, NULL, "SCHEMA", q->data, delq->data, NULL,
nspinfo->dobj.dependencies, nspinfo->dobj.nDeps, nspinfo->dobj.dependencies, nspinfo->dobj.nDeps,
...@@ -4135,7 +4196,7 @@ dumpNamespace(Archive *fout, NamespaceInfo *nspinfo) ...@@ -4135,7 +4196,7 @@ dumpNamespace(Archive *fout, NamespaceInfo *nspinfo)
nspinfo->dobj.catId, 0, nspinfo->dobj.dumpId); nspinfo->dobj.catId, 0, nspinfo->dobj.dumpId);
dumpACL(fout, nspinfo->dobj.catId, nspinfo->dobj.dumpId, "SCHEMA", dumpACL(fout, nspinfo->dobj.catId, nspinfo->dobj.dumpId, "SCHEMA",
qnspname, nspinfo->nspname, NULL, qnspname, nspinfo->dobj.name, NULL,
nspinfo->usename, nspinfo->nspacl); nspinfo->usename, nspinfo->nspacl);
free(qnspname); free(qnspname);
...@@ -4152,10 +4213,11 @@ static void ...@@ -4152,10 +4213,11 @@ static void
dumpType(Archive *fout, TypeInfo *tinfo) dumpType(Archive *fout, TypeInfo *tinfo)
{ {
/* Dump only types in dumpable namespaces */ /* Dump only types in dumpable namespaces */
if (!tinfo->typnamespace->dump || dataOnly) if (!tinfo->dobj.namespace->dump || dataOnly)
return; return;
/* skip complex types, except for standalone composite types */ /* skip complex types, except for standalone composite types */
/* (note: this test should now be unnecessary) */
if (OidIsValid(tinfo->typrelid) && tinfo->typrelkind != 'c') if (OidIsValid(tinfo->typrelid) && tinfo->typrelkind != 'c')
return; return;
...@@ -4164,7 +4226,7 @@ dumpType(Archive *fout, TypeInfo *tinfo) ...@@ -4164,7 +4226,7 @@ dumpType(Archive *fout, TypeInfo *tinfo)
return; return;
/* skip all array types that start w/ underscore */ /* skip all array types that start w/ underscore */
if ((tinfo->typname[0] == '_') && if ((tinfo->dobj.name[0] == '_') &&
OidIsValid(tinfo->typelem)) OidIsValid(tinfo->typelem))
return; return;
...@@ -4207,7 +4269,7 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo) ...@@ -4207,7 +4269,7 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo)
char *typstorage; char *typstorage;
/* Set proper schema search path so regproc references list correctly */ /* Set proper schema search path so regproc references list correctly */
selectSourceSchema(tinfo->typnamespace->nspname); selectSourceSchema(tinfo->dobj.namespace->dobj.name);
/* Fetch type-specific details */ /* Fetch type-specific details */
if (fout->remoteVersion >= 70500) if (fout->remoteVersion >= 70500)
...@@ -4332,14 +4394,14 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo) ...@@ -4332,14 +4394,14 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo)
* pg_catalog * pg_catalog
*/ */
appendPQExpBuffer(delq, "DROP TYPE %s.", appendPQExpBuffer(delq, "DROP TYPE %s.",
fmtId(tinfo->typnamespace->nspname)); fmtId(tinfo->dobj.namespace->dobj.name));
appendPQExpBuffer(delq, "%s CASCADE;\n", appendPQExpBuffer(delq, "%s CASCADE;\n",
fmtId(tinfo->typname)); fmtId(tinfo->dobj.name));
appendPQExpBuffer(q, appendPQExpBuffer(q,
"CREATE TYPE %s (\n" "CREATE TYPE %s (\n"
" INTERNALLENGTH = %s", " INTERNALLENGTH = %s",
fmtId(tinfo->typname), fmtId(tinfo->dobj.name),
(strcmp(typlen, "-1") == 0) ? "variable" : typlen); (strcmp(typlen, "-1") == 0) ? "variable" : typlen);
if (fout->remoteVersion >= 70300) if (fout->remoteVersion >= 70300)
...@@ -4374,7 +4436,7 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo) ...@@ -4374,7 +4436,7 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo)
char *elemType; char *elemType;
/* reselect schema in case changed by function dump */ /* reselect schema in case changed by function dump */
selectSourceSchema(tinfo->typnamespace->nspname); selectSourceSchema(tinfo->dobj.namespace->dobj.name);
elemType = getFormattedTypeName(tinfo->typelem, zeroAsOpaque); elemType = getFormattedTypeName(tinfo->typelem, zeroAsOpaque);
appendPQExpBuffer(q, ",\n ELEMENT = %s", elemType); appendPQExpBuffer(q, ",\n ELEMENT = %s", elemType);
free(elemType); free(elemType);
...@@ -4410,8 +4472,8 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo) ...@@ -4410,8 +4472,8 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo)
appendPQExpBuffer(q, "\n);\n"); appendPQExpBuffer(q, "\n);\n");
ArchiveEntry(fout, tinfo->dobj.catId, tinfo->dobj.dumpId, ArchiveEntry(fout, tinfo->dobj.catId, tinfo->dobj.dumpId,
tinfo->typname, tinfo->dobj.name,
tinfo->typnamespace->nspname, tinfo->dobj.namespace->dobj.name,
tinfo->usename, tinfo->usename,
"TYPE", q->data, delq->data, NULL, "TYPE", q->data, delq->data, NULL,
tinfo->dobj.dependencies, tinfo->dobj.nDeps, tinfo->dobj.dependencies, tinfo->dobj.nDeps,
...@@ -4420,9 +4482,9 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo) ...@@ -4420,9 +4482,9 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo)
/* Dump Type Comments */ /* Dump Type Comments */
resetPQExpBuffer(q); resetPQExpBuffer(q);
appendPQExpBuffer(q, "TYPE %s", fmtId(tinfo->typname)); appendPQExpBuffer(q, "TYPE %s", fmtId(tinfo->dobj.name));
dumpComment(fout, q->data, dumpComment(fout, q->data,
tinfo->typnamespace->nspname, tinfo->usename, tinfo->dobj.namespace->dobj.name, tinfo->usename,
tinfo->dobj.catId, 0, tinfo->dobj.dumpId); tinfo->dobj.catId, 0, tinfo->dobj.dumpId);
PQclear(res); PQclear(res);
...@@ -4449,7 +4511,7 @@ dumpDomain(Archive *fout, TypeInfo *tinfo) ...@@ -4449,7 +4511,7 @@ dumpDomain(Archive *fout, TypeInfo *tinfo)
char *typdefault; char *typdefault;
/* Set proper schema search path so type references list correctly */ /* Set proper schema search path so type references list correctly */
selectSourceSchema(tinfo->typnamespace->nspname); selectSourceSchema(tinfo->dobj.namespace->dobj.name);
/* Fetch domain specific details */ /* Fetch domain specific details */
/* We assume here that remoteVersion must be at least 70300 */ /* We assume here that remoteVersion must be at least 70300 */
...@@ -4481,7 +4543,7 @@ dumpDomain(Archive *fout, TypeInfo *tinfo) ...@@ -4481,7 +4543,7 @@ dumpDomain(Archive *fout, TypeInfo *tinfo)
appendPQExpBuffer(q, appendPQExpBuffer(q,
"CREATE DOMAIN %s AS %s", "CREATE DOMAIN %s AS %s",
fmtId(tinfo->typname), fmtId(tinfo->dobj.name),
typdefn); typdefn);
if (typnotnull[0] == 't') if (typnotnull[0] == 't')
...@@ -4501,7 +4563,7 @@ dumpDomain(Archive *fout, TypeInfo *tinfo) ...@@ -4501,7 +4563,7 @@ dumpDomain(Archive *fout, TypeInfo *tinfo)
if (!domcheck->separate) if (!domcheck->separate)
appendPQExpBuffer(q, "\n\tCONSTRAINT %s %s", appendPQExpBuffer(q, "\n\tCONSTRAINT %s %s",
fmtId(domcheck->conname), domcheck->condef); fmtId(domcheck->dobj.name), domcheck->condef);
} }
appendPQExpBuffer(q, ";\n"); appendPQExpBuffer(q, ";\n");
...@@ -4511,13 +4573,13 @@ dumpDomain(Archive *fout, TypeInfo *tinfo) ...@@ -4511,13 +4573,13 @@ dumpDomain(Archive *fout, TypeInfo *tinfo)
* pg_catalog * pg_catalog
*/ */
appendPQExpBuffer(delq, "DROP DOMAIN %s.", appendPQExpBuffer(delq, "DROP DOMAIN %s.",
fmtId(tinfo->typnamespace->nspname)); fmtId(tinfo->dobj.namespace->dobj.name));
appendPQExpBuffer(delq, "%s;\n", appendPQExpBuffer(delq, "%s;\n",
fmtId(tinfo->typname)); fmtId(tinfo->dobj.name));
ArchiveEntry(fout, tinfo->dobj.catId, tinfo->dobj.dumpId, ArchiveEntry(fout, tinfo->dobj.catId, tinfo->dobj.dumpId,
tinfo->typname, tinfo->dobj.name,
tinfo->typnamespace->nspname, tinfo->dobj.namespace->dobj.name,
tinfo->usename, tinfo->usename,
"DOMAIN", q->data, delq->data, NULL, "DOMAIN", q->data, delq->data, NULL,
tinfo->dobj.dependencies, tinfo->dobj.nDeps, tinfo->dobj.dependencies, tinfo->dobj.nDeps,
...@@ -4526,9 +4588,9 @@ dumpDomain(Archive *fout, TypeInfo *tinfo) ...@@ -4526,9 +4588,9 @@ dumpDomain(Archive *fout, TypeInfo *tinfo)
/* Dump Domain Comments */ /* Dump Domain Comments */
resetPQExpBuffer(q); resetPQExpBuffer(q);
appendPQExpBuffer(q, "DOMAIN %s", fmtId(tinfo->typname)); appendPQExpBuffer(q, "DOMAIN %s", fmtId(tinfo->dobj.name));
dumpComment(fout, q->data, dumpComment(fout, q->data,
tinfo->typnamespace->nspname, tinfo->usename, tinfo->dobj.namespace->dobj.name, tinfo->usename,
tinfo->dobj.catId, 0, tinfo->dobj.dumpId); tinfo->dobj.catId, 0, tinfo->dobj.dumpId);
destroyPQExpBuffer(q); destroyPQExpBuffer(q);
...@@ -4554,7 +4616,7 @@ dumpCompositeType(Archive *fout, TypeInfo *tinfo) ...@@ -4554,7 +4616,7 @@ dumpCompositeType(Archive *fout, TypeInfo *tinfo)
int i; int i;
/* Set proper schema search path so type references list correctly */ /* Set proper schema search path so type references list correctly */
selectSourceSchema(tinfo->typnamespace->nspname); selectSourceSchema(tinfo->dobj.namespace->dobj.name);
/* Fetch type specific details */ /* Fetch type specific details */
/* We assume here that remoteVersion must be at least 70300 */ /* We assume here that remoteVersion must be at least 70300 */
...@@ -4583,7 +4645,7 @@ dumpCompositeType(Archive *fout, TypeInfo *tinfo) ...@@ -4583,7 +4645,7 @@ dumpCompositeType(Archive *fout, TypeInfo *tinfo)
i_atttypdefn = PQfnumber(res, "atttypdefn"); i_atttypdefn = PQfnumber(res, "atttypdefn");
appendPQExpBuffer(q, "CREATE TYPE %s AS (", appendPQExpBuffer(q, "CREATE TYPE %s AS (",
fmtId(tinfo->typname)); fmtId(tinfo->dobj.name));
for (i = 0; i < ntups; i++) for (i = 0; i < ntups; i++)
{ {
...@@ -4604,13 +4666,13 @@ dumpCompositeType(Archive *fout, TypeInfo *tinfo) ...@@ -4604,13 +4666,13 @@ dumpCompositeType(Archive *fout, TypeInfo *tinfo)
* pg_catalog * pg_catalog
*/ */
appendPQExpBuffer(delq, "DROP TYPE %s.", appendPQExpBuffer(delq, "DROP TYPE %s.",
fmtId(tinfo->typnamespace->nspname)); fmtId(tinfo->dobj.namespace->dobj.name));
appendPQExpBuffer(delq, "%s;\n", appendPQExpBuffer(delq, "%s;\n",
fmtId(tinfo->typname)); fmtId(tinfo->dobj.name));
ArchiveEntry(fout, tinfo->dobj.catId, tinfo->dobj.dumpId, ArchiveEntry(fout, tinfo->dobj.catId, tinfo->dobj.dumpId,
tinfo->typname, tinfo->dobj.name,
tinfo->typnamespace->nspname, tinfo->dobj.namespace->dobj.name,
tinfo->usename, tinfo->usename,
"TYPE", q->data, delq->data, NULL, "TYPE", q->data, delq->data, NULL,
tinfo->dobj.dependencies, tinfo->dobj.nDeps, tinfo->dobj.dependencies, tinfo->dobj.nDeps,
...@@ -4620,9 +4682,9 @@ dumpCompositeType(Archive *fout, TypeInfo *tinfo) ...@@ -4620,9 +4682,9 @@ dumpCompositeType(Archive *fout, TypeInfo *tinfo)
/* Dump Type Comments */ /* Dump Type Comments */
resetPQExpBuffer(q); resetPQExpBuffer(q);
appendPQExpBuffer(q, "TYPE %s", fmtId(tinfo->typname)); appendPQExpBuffer(q, "TYPE %s", fmtId(tinfo->dobj.name));
dumpComment(fout, q->data, dumpComment(fout, q->data,
tinfo->typnamespace->nspname, tinfo->usename, tinfo->dobj.namespace->dobj.name, tinfo->usename,
tinfo->dobj.catId, 0, tinfo->dobj.dumpId); tinfo->dobj.catId, 0, tinfo->dobj.dumpId);
PQclear(res); PQclear(res);
...@@ -4666,7 +4728,7 @@ dumpProcLang(Archive *fout, ProcLangInfo *plang) ...@@ -4666,7 +4728,7 @@ dumpProcLang(Archive *fout, ProcLangInfo *plang)
if (funcInfo == NULL) if (funcInfo == NULL)
return; return;
if (!funcInfo->pronamespace->dump) if (!funcInfo->dobj.namespace->dump)
return; return;
if (OidIsValid(plang->lanvalidator)) if (OidIsValid(plang->lanvalidator))
...@@ -4679,7 +4741,7 @@ dumpProcLang(Archive *fout, ProcLangInfo *plang) ...@@ -4679,7 +4741,7 @@ dumpProcLang(Archive *fout, ProcLangInfo *plang)
defqry = createPQExpBuffer(); defqry = createPQExpBuffer();
delqry = createPQExpBuffer(); delqry = createPQExpBuffer();
qlanname = strdup(fmtId(plang->lanname)); qlanname = strdup(fmtId(plang->dobj.name));
appendPQExpBuffer(delqry, "DROP PROCEDURAL LANGUAGE %s;\n", appendPQExpBuffer(delqry, "DROP PROCEDURAL LANGUAGE %s;\n",
qlanname); qlanname);
...@@ -4688,22 +4750,22 @@ dumpProcLang(Archive *fout, ProcLangInfo *plang) ...@@ -4688,22 +4750,22 @@ dumpProcLang(Archive *fout, ProcLangInfo *plang)
plang->lanpltrusted ? "TRUSTED " : "", plang->lanpltrusted ? "TRUSTED " : "",
qlanname); qlanname);
appendPQExpBuffer(defqry, " HANDLER %s", appendPQExpBuffer(defqry, " HANDLER %s",
fmtId(funcInfo->proname)); fmtId(funcInfo->dobj.name));
if (OidIsValid(plang->lanvalidator)) if (OidIsValid(plang->lanvalidator))
{ {
appendPQExpBuffer(defqry, " VALIDATOR "); appendPQExpBuffer(defqry, " VALIDATOR ");
/* Cope with possibility that validator is in different schema */ /* Cope with possibility that validator is in different schema */
if (validatorInfo->pronamespace != funcInfo->pronamespace) if (validatorInfo->dobj.namespace != funcInfo->dobj.namespace)
appendPQExpBuffer(defqry, "%s.", appendPQExpBuffer(defqry, "%s.",
fmtId(validatorInfo->pronamespace->nspname)); fmtId(validatorInfo->dobj.namespace->dobj.name));
appendPQExpBuffer(defqry, "%s", appendPQExpBuffer(defqry, "%s",
fmtId(validatorInfo->proname)); fmtId(validatorInfo->dobj.name));
} }
appendPQExpBuffer(defqry, ";\n"); appendPQExpBuffer(defqry, ";\n");
ArchiveEntry(fout, plang->dobj.catId, plang->dobj.dumpId, ArchiveEntry(fout, plang->dobj.catId, plang->dobj.dumpId,
plang->lanname, plang->dobj.name,
funcInfo->pronamespace->nspname, "", funcInfo->dobj.namespace->dobj.name, "",
"PROCEDURAL LANGUAGE", "PROCEDURAL LANGUAGE",
defqry->data, delqry->data, NULL, defqry->data, delqry->data, NULL,
plang->dobj.dependencies, plang->dobj.nDeps, plang->dobj.dependencies, plang->dobj.nDeps,
...@@ -4719,8 +4781,8 @@ dumpProcLang(Archive *fout, ProcLangInfo *plang) ...@@ -4719,8 +4781,8 @@ dumpProcLang(Archive *fout, ProcLangInfo *plang)
if (plang->lanpltrusted) if (plang->lanpltrusted)
dumpACL(fout, plang->dobj.catId, plang->dobj.dumpId, "LANGUAGE", dumpACL(fout, plang->dobj.catId, plang->dobj.dumpId, "LANGUAGE",
qlanname, plang->lanname, qlanname, plang->dobj.name,
funcInfo->pronamespace->nspname, funcInfo->dobj.namespace->dobj.name,
NULL, plang->lanacl); NULL, plang->lanacl);
free(qlanname); free(qlanname);
...@@ -4746,9 +4808,9 @@ format_function_signature(FuncInfo *finfo, char **argnames, ...@@ -4746,9 +4808,9 @@ format_function_signature(FuncInfo *finfo, char **argnames,
initPQExpBuffer(&fn); initPQExpBuffer(&fn);
if (honor_quotes) if (honor_quotes)
appendPQExpBuffer(&fn, "%s(", fmtId(finfo->proname)); appendPQExpBuffer(&fn, "%s(", fmtId(finfo->dobj.name));
else else
appendPQExpBuffer(&fn, "%s(", finfo->proname); appendPQExpBuffer(&fn, "%s(", finfo->dobj.name);
for (j = 0; j < finfo->nargs; j++) for (j = 0; j < finfo->nargs; j++)
{ {
char *typname; char *typname;
...@@ -4799,7 +4861,7 @@ dumpFunc(Archive *fout, FuncInfo *finfo) ...@@ -4799,7 +4861,7 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
char **argnamearray = NULL; char **argnamearray = NULL;
/* Dump only funcs in dumpable namespaces */ /* Dump only funcs in dumpable namespaces */
if (!finfo->pronamespace->dump || dataOnly) if (!finfo->dobj.namespace->dump || dataOnly)
return; return;
query = createPQExpBuffer(); query = createPQExpBuffer();
...@@ -4808,7 +4870,7 @@ dumpFunc(Archive *fout, FuncInfo *finfo) ...@@ -4808,7 +4870,7 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
asPart = createPQExpBuffer(); asPart = createPQExpBuffer();
/* Set proper schema search path so type references list correctly */ /* Set proper schema search path so type references list correctly */
selectSourceSchema(finfo->pronamespace->nspname); selectSourceSchema(finfo->dobj.namespace->dobj.name);
/* Fetch function-specific details */ /* Fetch function-specific details */
if (g_fout->remoteVersion >= 70500) if (g_fout->remoteVersion >= 70500)
...@@ -4926,7 +4988,7 @@ dumpFunc(Archive *fout, FuncInfo *finfo) ...@@ -4926,7 +4988,7 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
* pg_catalog * pg_catalog
*/ */
appendPQExpBuffer(delqry, "DROP FUNCTION %s.%s;\n", appendPQExpBuffer(delqry, "DROP FUNCTION %s.%s;\n",
fmtId(finfo->pronamespace->nspname), fmtId(finfo->dobj.namespace->dobj.name),
funcsig); funcsig);
rettypename = getFormattedTypeName(finfo->prorettype, zeroAsOpaque); rettypename = getFormattedTypeName(finfo->prorettype, zeroAsOpaque);
...@@ -4949,7 +5011,7 @@ dumpFunc(Archive *fout, FuncInfo *finfo) ...@@ -4949,7 +5011,7 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
else if (provolatile[0] != PROVOLATILE_VOLATILE) else if (provolatile[0] != PROVOLATILE_VOLATILE)
{ {
write_msg(NULL, "unrecognized provolatile value for function \"%s\"\n", write_msg(NULL, "unrecognized provolatile value for function \"%s\"\n",
finfo->proname); finfo->dobj.name);
exit_nicely(); exit_nicely();
} }
} }
...@@ -4964,7 +5026,7 @@ dumpFunc(Archive *fout, FuncInfo *finfo) ...@@ -4964,7 +5026,7 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
ArchiveEntry(fout, finfo->dobj.catId, finfo->dobj.dumpId, ArchiveEntry(fout, finfo->dobj.catId, finfo->dobj.dumpId,
funcsig_tag, funcsig_tag,
finfo->pronamespace->nspname, finfo->dobj.namespace->dobj.name,
finfo->usename, finfo->usename,
"FUNCTION", q->data, delqry->data, NULL, "FUNCTION", q->data, delqry->data, NULL,
finfo->dobj.dependencies, finfo->dobj.nDeps, finfo->dobj.dependencies, finfo->dobj.nDeps,
...@@ -4974,12 +5036,12 @@ dumpFunc(Archive *fout, FuncInfo *finfo) ...@@ -4974,12 +5036,12 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
resetPQExpBuffer(q); resetPQExpBuffer(q);
appendPQExpBuffer(q, "FUNCTION %s", funcsig); appendPQExpBuffer(q, "FUNCTION %s", funcsig);
dumpComment(fout, q->data, dumpComment(fout, q->data,
finfo->pronamespace->nspname, finfo->usename, finfo->dobj.namespace->dobj.name, finfo->usename,
finfo->dobj.catId, 0, finfo->dobj.dumpId); finfo->dobj.catId, 0, finfo->dobj.dumpId);
dumpACL(fout, finfo->dobj.catId, finfo->dobj.dumpId, "FUNCTION", dumpACL(fout, finfo->dobj.catId, finfo->dobj.dumpId, "FUNCTION",
funcsig, funcsig_tag, funcsig, funcsig_tag,
finfo->pronamespace->nspname, finfo->dobj.namespace->dobj.name,
finfo->usename, finfo->proacl); finfo->usename, finfo->proacl);
PQclear(res); PQclear(res);
...@@ -5034,9 +5096,10 @@ dumpCast(Archive *fout, CastInfo *cast) ...@@ -5034,9 +5096,10 @@ dumpCast(Archive *fout, CastInfo *cast)
/* /*
* Skip this cast if all objects are from pg_ * Skip this cast if all objects are from pg_
*/ */
if ((funcInfo == NULL || strncmp(funcInfo->pronamespace->nspname, "pg_", 3) == 0) && if ((funcInfo == NULL ||
strncmp(sourceInfo->typnamespace->nspname, "pg_", 3) == 0 && strncmp(funcInfo->dobj.namespace->dobj.name, "pg_", 3) == 0) &&
strncmp(targetInfo->typnamespace->nspname, "pg_", 3) == 0) strncmp(sourceInfo->dobj.namespace->dobj.name, "pg_", 3) == 0 &&
strncmp(targetInfo->dobj.namespace->dobj.name, "pg_", 3) == 0)
return; return;
/* /*
...@@ -5044,22 +5107,22 @@ dumpCast(Archive *fout, CastInfo *cast) ...@@ -5044,22 +5107,22 @@ dumpCast(Archive *fout, CastInfo *cast)
* not dumped. * not dumped.
*/ */
if (funcInfo && if (funcInfo &&
strncmp(funcInfo->pronamespace->nspname, "pg_", 3) != 0 && strncmp(funcInfo->dobj.namespace->dobj.name, "pg_", 3) != 0 &&
!funcInfo->pronamespace->dump) !funcInfo->dobj.namespace->dump)
return; return;
/* /*
* Same for the Source type * Same for the Source type
*/ */
if (strncmp(sourceInfo->typnamespace->nspname, "pg_", 3) != 0 && if (strncmp(sourceInfo->dobj.namespace->dobj.name, "pg_", 3) != 0 &&
!sourceInfo->typnamespace->dump) !sourceInfo->dobj.namespace->dump)
return; return;
/* /*
* and the target type. * and the target type.
*/ */
if (strncmp(targetInfo->typnamespace->nspname, "pg_", 3) != 0 && if (strncmp(targetInfo->dobj.namespace->dobj.name, "pg_", 3) != 0 &&
!targetInfo->typnamespace->dump) !targetInfo->dobj.namespace->dump)
return; return;
/* Make sure we are in proper schema (needed for getFormattedTypeName) */ /* Make sure we are in proper schema (needed for getFormattedTypeName) */
...@@ -5086,7 +5149,7 @@ dumpCast(Archive *fout, CastInfo *cast) ...@@ -5086,7 +5149,7 @@ dumpCast(Archive *fout, CastInfo *cast)
* schema (format_function_signature won't qualify it). * schema (format_function_signature won't qualify it).
*/ */
appendPQExpBuffer(defqry, "WITH FUNCTION %s.", appendPQExpBuffer(defqry, "WITH FUNCTION %s.",
fmtId(funcInfo->pronamespace->nspname)); fmtId(funcInfo->dobj.namespace->dobj.name));
appendPQExpBuffer(defqry, "%s", appendPQExpBuffer(defqry, "%s",
format_function_signature(funcInfo, NULL, true)); format_function_signature(funcInfo, NULL, true));
} }
...@@ -5103,7 +5166,7 @@ dumpCast(Archive *fout, CastInfo *cast) ...@@ -5103,7 +5166,7 @@ dumpCast(Archive *fout, CastInfo *cast)
ArchiveEntry(fout, cast->dobj.catId, cast->dobj.dumpId, ArchiveEntry(fout, cast->dobj.catId, cast->dobj.dumpId,
castsig->data, castsig->data,
sourceInfo->typnamespace->nspname, "", "pg_catalog", "",
"CAST", defqry->data, delqry->data, NULL, "CAST", defqry->data, delqry->data, NULL,
cast->dobj.dependencies, cast->dobj.nDeps, cast->dobj.dependencies, cast->dobj.nDeps,
NULL, NULL); NULL, NULL);
...@@ -5165,7 +5228,7 @@ dumpOpr(Archive *fout, OprInfo *oprinfo) ...@@ -5165,7 +5228,7 @@ dumpOpr(Archive *fout, OprInfo *oprinfo)
char *oprgtcmpop; char *oprgtcmpop;
/* Dump only operators in dumpable namespaces */ /* Dump only operators in dumpable namespaces */
if (!oprinfo->oprnamespace->dump || dataOnly) if (!oprinfo->dobj.namespace->dump || dataOnly)
return; return;
/* /*
...@@ -5182,7 +5245,7 @@ dumpOpr(Archive *fout, OprInfo *oprinfo) ...@@ -5182,7 +5245,7 @@ dumpOpr(Archive *fout, OprInfo *oprinfo)
details = createPQExpBuffer(); details = createPQExpBuffer();
/* Make sure we are in proper schema so regoperator works correctly */ /* Make sure we are in proper schema so regoperator works correctly */
selectSourceSchema(oprinfo->oprnamespace->nspname); selectSourceSchema(oprinfo->dobj.namespace->dobj.name);
if (g_fout->remoteVersion >= 70300) if (g_fout->remoteVersion >= 70300)
{ {
...@@ -5276,7 +5339,7 @@ dumpOpr(Archive *fout, OprInfo *oprinfo) ...@@ -5276,7 +5339,7 @@ dumpOpr(Archive *fout, OprInfo *oprinfo)
convertRegProcReference(oprcode)); convertRegProcReference(oprcode));
appendPQExpBuffer(oprid, "%s (", appendPQExpBuffer(oprid, "%s (",
oprinfo->oprname); oprinfo->dobj.name);
/* /*
* right unary means there's a left arg and left unary means there's a * right unary means there's a left arg and left unary means there's a
...@@ -5348,15 +5411,15 @@ dumpOpr(Archive *fout, OprInfo *oprinfo) ...@@ -5348,15 +5411,15 @@ dumpOpr(Archive *fout, OprInfo *oprinfo)
* pg_catalog * pg_catalog
*/ */
appendPQExpBuffer(delq, "DROP OPERATOR %s.%s;\n", appendPQExpBuffer(delq, "DROP OPERATOR %s.%s;\n",
fmtId(oprinfo->oprnamespace->nspname), fmtId(oprinfo->dobj.namespace->dobj.name),
oprid->data); oprid->data);
appendPQExpBuffer(q, "CREATE OPERATOR %s (\n%s\n);\n", appendPQExpBuffer(q, "CREATE OPERATOR %s (\n%s\n);\n",
oprinfo->oprname, details->data); oprinfo->dobj.name, details->data);
ArchiveEntry(fout, oprinfo->dobj.catId, oprinfo->dobj.dumpId, ArchiveEntry(fout, oprinfo->dobj.catId, oprinfo->dobj.dumpId,
oprinfo->oprname, oprinfo->dobj.name,
oprinfo->oprnamespace->nspname, oprinfo->usename, oprinfo->dobj.namespace->dobj.name, oprinfo->usename,
"OPERATOR", q->data, delq->data, NULL, "OPERATOR", q->data, delq->data, NULL,
oprinfo->dobj.dependencies, oprinfo->dobj.nDeps, oprinfo->dobj.dependencies, oprinfo->dobj.nDeps,
NULL, NULL); NULL, NULL);
...@@ -5365,7 +5428,7 @@ dumpOpr(Archive *fout, OprInfo *oprinfo) ...@@ -5365,7 +5428,7 @@ dumpOpr(Archive *fout, OprInfo *oprinfo)
resetPQExpBuffer(q); resetPQExpBuffer(q);
appendPQExpBuffer(q, "OPERATOR %s", oprid->data); appendPQExpBuffer(q, "OPERATOR %s", oprid->data);
dumpComment(fout, q->data, dumpComment(fout, q->data,
oprinfo->oprnamespace->nspname, oprinfo->usename, oprinfo->dobj.namespace->dobj.name, oprinfo->usename,
oprinfo->dobj.catId, 0, oprinfo->dobj.dumpId); oprinfo->dobj.catId, 0, oprinfo->dobj.dumpId);
PQclear(res); PQclear(res);
...@@ -5465,7 +5528,7 @@ convertOperatorReference(const char *opr) ...@@ -5465,7 +5528,7 @@ convertOperatorReference(const char *opr)
opr); opr);
return NULL; return NULL;
} }
return oprInfo->oprname; return oprInfo->dobj.name;
} }
/* /*
...@@ -5502,7 +5565,7 @@ dumpOpclass(Archive *fout, OpclassInfo *opcinfo) ...@@ -5502,7 +5565,7 @@ dumpOpclass(Archive *fout, OpclassInfo *opcinfo)
int i; int i;
/* Dump only opclasses in dumpable namespaces */ /* Dump only opclasses in dumpable namespaces */
if (!opcinfo->opcnamespace->dump || dataOnly) if (!opcinfo->dobj.namespace->dump || dataOnly)
return; return;
/* /*
...@@ -5518,7 +5581,7 @@ dumpOpclass(Archive *fout, OpclassInfo *opcinfo) ...@@ -5518,7 +5581,7 @@ dumpOpclass(Archive *fout, OpclassInfo *opcinfo)
delq = createPQExpBuffer(); delq = createPQExpBuffer();
/* Make sure we are in proper schema so regoperator works correctly */ /* Make sure we are in proper schema so regoperator works correctly */
selectSourceSchema(opcinfo->opcnamespace->nspname); selectSourceSchema(opcinfo->dobj.namespace->dobj.name);
/* Get additional fields from the pg_opclass row */ /* Get additional fields from the pg_opclass row */
appendPQExpBuffer(query, "SELECT opcintype::pg_catalog.regtype, " appendPQExpBuffer(query, "SELECT opcintype::pg_catalog.regtype, "
...@@ -5557,15 +5620,15 @@ dumpOpclass(Archive *fout, OpclassInfo *opcinfo) ...@@ -5557,15 +5620,15 @@ dumpOpclass(Archive *fout, OpclassInfo *opcinfo)
* pg_catalog * pg_catalog
*/ */
appendPQExpBuffer(delq, "DROP OPERATOR CLASS %s", appendPQExpBuffer(delq, "DROP OPERATOR CLASS %s",
fmtId(opcinfo->opcnamespace->nspname)); fmtId(opcinfo->dobj.namespace->dobj.name));
appendPQExpBuffer(delq, ".%s", appendPQExpBuffer(delq, ".%s",
fmtId(opcinfo->opcname)); fmtId(opcinfo->dobj.name));
appendPQExpBuffer(delq, " USING %s;\n", appendPQExpBuffer(delq, " USING %s;\n",
fmtId(amname)); fmtId(amname));
/* Build the fixed portion of the CREATE command */ /* Build the fixed portion of the CREATE command */
appendPQExpBuffer(q, "CREATE OPERATOR CLASS %s\n ", appendPQExpBuffer(q, "CREATE OPERATOR CLASS %s\n ",
fmtId(opcinfo->opcname)); fmtId(opcinfo->dobj.name));
if (strcmp(opcdefault, "t") == 0) if (strcmp(opcdefault, "t") == 0)
appendPQExpBuffer(q, "DEFAULT "); appendPQExpBuffer(q, "DEFAULT ");
appendPQExpBuffer(q, "FOR TYPE %s USING %s AS\n ", appendPQExpBuffer(q, "FOR TYPE %s USING %s AS\n ",
...@@ -5662,8 +5725,8 @@ dumpOpclass(Archive *fout, OpclassInfo *opcinfo) ...@@ -5662,8 +5725,8 @@ dumpOpclass(Archive *fout, OpclassInfo *opcinfo)
appendPQExpBuffer(q, ";\n"); appendPQExpBuffer(q, ";\n");
ArchiveEntry(fout, opcinfo->dobj.catId, opcinfo->dobj.dumpId, ArchiveEntry(fout, opcinfo->dobj.catId, opcinfo->dobj.dumpId,
opcinfo->opcname, opcinfo->dobj.name,
opcinfo->opcnamespace->nspname, opcinfo->usename, opcinfo->dobj.namespace->dobj.name, opcinfo->usename,
"OPERATOR CLASS", q->data, delq->data, NULL, "OPERATOR CLASS", q->data, delq->data, NULL,
opcinfo->dobj.dependencies, opcinfo->dobj.nDeps, opcinfo->dobj.dependencies, opcinfo->dobj.nDeps,
NULL, NULL); NULL, NULL);
...@@ -5671,7 +5734,7 @@ dumpOpclass(Archive *fout, OpclassInfo *opcinfo) ...@@ -5671,7 +5734,7 @@ dumpOpclass(Archive *fout, OpclassInfo *opcinfo)
/* Dump Operator Class Comments */ /* Dump Operator Class Comments */
resetPQExpBuffer(q); resetPQExpBuffer(q);
appendPQExpBuffer(q, "OPERATOR CLASS %s", appendPQExpBuffer(q, "OPERATOR CLASS %s",
fmtId(opcinfo->opcname)); fmtId(opcinfo->dobj.name));
appendPQExpBuffer(q, " USING %s", appendPQExpBuffer(q, " USING %s",
fmtId(amname)); fmtId(amname));
dumpComment(fout, q->data, dumpComment(fout, q->data,
...@@ -5709,7 +5772,7 @@ dumpConversion(Archive *fout, ConvInfo *convinfo) ...@@ -5709,7 +5772,7 @@ dumpConversion(Archive *fout, ConvInfo *convinfo)
bool condefault; bool condefault;
/* Dump only conversions in dumpable namespaces */ /* Dump only conversions in dumpable namespaces */
if (!convinfo->connamespace->dump || dataOnly) if (!convinfo->dobj.namespace->dump || dataOnly)
return; return;
query = createPQExpBuffer(); query = createPQExpBuffer();
...@@ -5718,7 +5781,7 @@ dumpConversion(Archive *fout, ConvInfo *convinfo) ...@@ -5718,7 +5781,7 @@ dumpConversion(Archive *fout, ConvInfo *convinfo)
details = createPQExpBuffer(); details = createPQExpBuffer();
/* Make sure we are in proper schema */ /* Make sure we are in proper schema */
selectSourceSchema(convinfo->connamespace->nspname); selectSourceSchema(convinfo->dobj.namespace->dobj.name);
/* Get conversion-specific details */ /* Get conversion-specific details */
appendPQExpBuffer(query, "SELECT conname, " appendPQExpBuffer(query, "SELECT conname, "
...@@ -5758,13 +5821,13 @@ dumpConversion(Archive *fout, ConvInfo *convinfo) ...@@ -5758,13 +5821,13 @@ dumpConversion(Archive *fout, ConvInfo *convinfo)
* pg_catalog * pg_catalog
*/ */
appendPQExpBuffer(delq, "DROP CONVERSION %s", appendPQExpBuffer(delq, "DROP CONVERSION %s",
fmtId(convinfo->connamespace->nspname)); fmtId(convinfo->dobj.namespace->dobj.name));
appendPQExpBuffer(delq, ".%s;\n", appendPQExpBuffer(delq, ".%s;\n",
fmtId(convinfo->conname)); fmtId(convinfo->dobj.name));
appendPQExpBuffer(q, "CREATE %sCONVERSION %s FOR ", appendPQExpBuffer(q, "CREATE %sCONVERSION %s FOR ",
(condefault) ? "DEFAULT " : "", (condefault) ? "DEFAULT " : "",
fmtId(convinfo->conname)); fmtId(convinfo->dobj.name));
appendStringLiteral(q, conforencoding, true); appendStringLiteral(q, conforencoding, true);
appendPQExpBuffer(q, " TO "); appendPQExpBuffer(q, " TO ");
appendStringLiteral(q, contoencoding, true); appendStringLiteral(q, contoencoding, true);
...@@ -5772,17 +5835,17 @@ dumpConversion(Archive *fout, ConvInfo *convinfo) ...@@ -5772,17 +5835,17 @@ dumpConversion(Archive *fout, ConvInfo *convinfo)
appendPQExpBuffer(q, " FROM %s;\n", conproc); appendPQExpBuffer(q, " FROM %s;\n", conproc);
ArchiveEntry(fout, convinfo->dobj.catId, convinfo->dobj.dumpId, ArchiveEntry(fout, convinfo->dobj.catId, convinfo->dobj.dumpId,
convinfo->conname, convinfo->dobj.name,
convinfo->connamespace->nspname, convinfo->usename, convinfo->dobj.namespace->dobj.name, convinfo->usename,
"CONVERSION", q->data, delq->data, NULL, "CONVERSION", q->data, delq->data, NULL,
convinfo->dobj.dependencies, convinfo->dobj.nDeps, convinfo->dobj.dependencies, convinfo->dobj.nDeps,
NULL, NULL); NULL, NULL);
/* Dump Conversion Comments */ /* Dump Conversion Comments */
resetPQExpBuffer(q); resetPQExpBuffer(q);
appendPQExpBuffer(q, "CONVERSION %s", fmtId(convinfo->conname)); appendPQExpBuffer(q, "CONVERSION %s", fmtId(convinfo->dobj.name));
dumpComment(fout, q->data, dumpComment(fout, q->data,
convinfo->connamespace->nspname, convinfo->usename, convinfo->dobj.namespace->dobj.name, convinfo->usename,
convinfo->dobj.catId, 0, convinfo->dobj.dumpId); convinfo->dobj.catId, 0, convinfo->dobj.dumpId);
PQclear(res); PQclear(res);
...@@ -5807,9 +5870,9 @@ format_aggregate_signature(AggInfo *agginfo, Archive *fout, bool honor_quotes) ...@@ -5807,9 +5870,9 @@ format_aggregate_signature(AggInfo *agginfo, Archive *fout, bool honor_quotes)
initPQExpBuffer(&buf); initPQExpBuffer(&buf);
if (honor_quotes) if (honor_quotes)
appendPQExpBuffer(&buf, "%s", appendPQExpBuffer(&buf, "%s",
fmtId(agginfo->aggfn.proname)); fmtId(agginfo->aggfn.dobj.name));
else else
appendPQExpBuffer(&buf, "%s", agginfo->aggfn.proname); appendPQExpBuffer(&buf, "%s", agginfo->aggfn.dobj.name);
/* If using regtype or format_type, fmtbasetype is already quoted */ /* If using regtype or format_type, fmtbasetype is already quoted */
if (fout->remoteVersion >= 70100) if (fout->remoteVersion >= 70100)
...@@ -5860,7 +5923,7 @@ dumpAgg(Archive *fout, AggInfo *agginfo) ...@@ -5860,7 +5923,7 @@ dumpAgg(Archive *fout, AggInfo *agginfo)
bool convertok; bool convertok;
/* Dump only aggs in dumpable namespaces */ /* Dump only aggs in dumpable namespaces */
if (!agginfo->aggfn.pronamespace->dump || dataOnly) if (!agginfo->aggfn.dobj.namespace->dump || dataOnly)
return; return;
query = createPQExpBuffer(); query = createPQExpBuffer();
...@@ -5869,7 +5932,7 @@ dumpAgg(Archive *fout, AggInfo *agginfo) ...@@ -5869,7 +5932,7 @@ dumpAgg(Archive *fout, AggInfo *agginfo)
details = createPQExpBuffer(); details = createPQExpBuffer();
/* Make sure we are in proper schema */ /* Make sure we are in proper schema */
selectSourceSchema(agginfo->aggfn.pronamespace->nspname); selectSourceSchema(agginfo->aggfn.dobj.namespace->dobj.name);
/* Get aggregate-specific details */ /* Get aggregate-specific details */
if (g_fout->remoteVersion >= 70300) if (g_fout->remoteVersion >= 70300)
...@@ -5999,16 +6062,16 @@ dumpAgg(Archive *fout, AggInfo *agginfo) ...@@ -5999,16 +6062,16 @@ dumpAgg(Archive *fout, AggInfo *agginfo)
* pg_catalog * pg_catalog
*/ */
appendPQExpBuffer(delq, "DROP AGGREGATE %s.%s;\n", appendPQExpBuffer(delq, "DROP AGGREGATE %s.%s;\n",
fmtId(agginfo->aggfn.pronamespace->nspname), fmtId(agginfo->aggfn.dobj.namespace->dobj.name),
aggsig); aggsig);
appendPQExpBuffer(q, "CREATE AGGREGATE %s (\n%s\n);\n", appendPQExpBuffer(q, "CREATE AGGREGATE %s (\n%s\n);\n",
fmtId(agginfo->aggfn.proname), fmtId(agginfo->aggfn.dobj.name),
details->data); details->data);
ArchiveEntry(fout, agginfo->aggfn.dobj.catId, agginfo->aggfn.dobj.dumpId, ArchiveEntry(fout, agginfo->aggfn.dobj.catId, agginfo->aggfn.dobj.dumpId,
aggsig_tag, aggsig_tag,
agginfo->aggfn.pronamespace->nspname, agginfo->aggfn.usename, agginfo->aggfn.dobj.namespace->dobj.name, agginfo->aggfn.usename,
"AGGREGATE", q->data, delq->data, NULL, "AGGREGATE", q->data, delq->data, NULL,
agginfo->aggfn.dobj.dependencies, agginfo->aggfn.dobj.nDeps, agginfo->aggfn.dobj.dependencies, agginfo->aggfn.dobj.nDeps,
NULL, NULL); NULL, NULL);
...@@ -6017,7 +6080,7 @@ dumpAgg(Archive *fout, AggInfo *agginfo) ...@@ -6017,7 +6080,7 @@ dumpAgg(Archive *fout, AggInfo *agginfo)
resetPQExpBuffer(q); resetPQExpBuffer(q);
appendPQExpBuffer(q, "AGGREGATE %s", aggsig); appendPQExpBuffer(q, "AGGREGATE %s", aggsig);
dumpComment(fout, q->data, dumpComment(fout, q->data,
agginfo->aggfn.pronamespace->nspname, agginfo->aggfn.usename, agginfo->aggfn.dobj.namespace->dobj.name, agginfo->aggfn.usename,
agginfo->aggfn.dobj.catId, 0, agginfo->aggfn.dobj.dumpId); agginfo->aggfn.dobj.catId, 0, agginfo->aggfn.dobj.dumpId);
/* /*
...@@ -6034,7 +6097,7 @@ dumpAgg(Archive *fout, AggInfo *agginfo) ...@@ -6034,7 +6097,7 @@ dumpAgg(Archive *fout, AggInfo *agginfo)
dumpACL(fout, agginfo->aggfn.dobj.catId, agginfo->aggfn.dobj.dumpId, dumpACL(fout, agginfo->aggfn.dobj.catId, agginfo->aggfn.dobj.dumpId,
"FUNCTION", "FUNCTION",
aggsig, aggsig_tag, aggsig, aggsig_tag,
agginfo->aggfn.pronamespace->nspname, agginfo->aggfn.dobj.namespace->dobj.name,
agginfo->aggfn.usename, agginfo->aggfn.proacl); agginfo->aggfn.usename, agginfo->aggfn.proacl);
free(aggsig); free(aggsig);
...@@ -6112,10 +6175,10 @@ dumpTable(Archive *fout, TableInfo *tbinfo) ...@@ -6112,10 +6175,10 @@ dumpTable(Archive *fout, TableInfo *tbinfo)
dumpTableSchema(fout, tbinfo); dumpTableSchema(fout, tbinfo);
/* Handle the ACL here */ /* Handle the ACL here */
namecopy = strdup(fmtId(tbinfo->relname)); namecopy = strdup(fmtId(tbinfo->dobj.name));
dumpACL(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId, "TABLE", dumpACL(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId, "TABLE",
namecopy, tbinfo->relname, namecopy, tbinfo->dobj.name,
tbinfo->relnamespace->nspname, tbinfo->usename, tbinfo->dobj.namespace->dobj.name, tbinfo->usename,
tbinfo->relacl); tbinfo->relacl);
free(namecopy); free(namecopy);
} }
...@@ -6141,7 +6204,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) ...@@ -6141,7 +6204,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
k; k;
/* Make sure we are in proper schema */ /* Make sure we are in proper schema */
selectSourceSchema(tbinfo->relnamespace->nspname); selectSourceSchema(tbinfo->dobj.namespace->dobj.name);
/* Is it a table or a view? */ /* Is it a table or a view? */
if (tbinfo->relkind == RELKIND_VIEW) if (tbinfo->relkind == RELKIND_VIEW)
...@@ -6162,7 +6225,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) ...@@ -6162,7 +6225,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
{ {
appendPQExpBuffer(query, "SELECT definition as viewdef " appendPQExpBuffer(query, "SELECT definition as viewdef "
" from pg_views where viewname = "); " from pg_views where viewname = ");
appendStringLiteral(query, tbinfo->relname, true); appendStringLiteral(query, tbinfo->dobj.name, true);
appendPQExpBuffer(query, ";"); appendPQExpBuffer(query, ";");
} }
...@@ -6173,10 +6236,10 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) ...@@ -6173,10 +6236,10 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
{ {
if (PQntuples(res) < 1) if (PQntuples(res) < 1)
write_msg(NULL, "query to obtain definition of view \"%s\" returned no data\n", write_msg(NULL, "query to obtain definition of view \"%s\" returned no data\n",
tbinfo->relname); tbinfo->dobj.name);
else else
write_msg(NULL, "query to obtain definition of view \"%s\" returned more than one definition\n", write_msg(NULL, "query to obtain definition of view \"%s\" returned more than one definition\n",
tbinfo->relname); tbinfo->dobj.name);
exit_nicely(); exit_nicely();
} }
...@@ -6185,7 +6248,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) ...@@ -6185,7 +6248,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
if (strlen(viewdef) == 0) if (strlen(viewdef) == 0)
{ {
write_msg(NULL, "definition of view \"%s\" appears to be empty (length zero)\n", write_msg(NULL, "definition of view \"%s\" appears to be empty (length zero)\n",
tbinfo->relname); tbinfo->dobj.name);
exit_nicely(); exit_nicely();
} }
...@@ -6194,12 +6257,12 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) ...@@ -6194,12 +6257,12 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
* pg_catalog * pg_catalog
*/ */
appendPQExpBuffer(delq, "DROP VIEW %s.", appendPQExpBuffer(delq, "DROP VIEW %s.",
fmtId(tbinfo->relnamespace->nspname)); fmtId(tbinfo->dobj.namespace->dobj.name));
appendPQExpBuffer(delq, "%s;\n", appendPQExpBuffer(delq, "%s;\n",
fmtId(tbinfo->relname)); fmtId(tbinfo->dobj.name));
appendPQExpBuffer(q, "CREATE VIEW %s AS\n %s\n", appendPQExpBuffer(q, "CREATE VIEW %s AS\n %s\n",
fmtId(tbinfo->relname), viewdef); fmtId(tbinfo->dobj.name), viewdef);
PQclear(res); PQclear(res);
} }
...@@ -6214,12 +6277,12 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) ...@@ -6214,12 +6277,12 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
* pg_catalog * pg_catalog
*/ */
appendPQExpBuffer(delq, "DROP TABLE %s.", appendPQExpBuffer(delq, "DROP TABLE %s.",
fmtId(tbinfo->relnamespace->nspname)); fmtId(tbinfo->dobj.namespace->dobj.name));
appendPQExpBuffer(delq, "%s;\n", appendPQExpBuffer(delq, "%s;\n",
fmtId(tbinfo->relname)); fmtId(tbinfo->dobj.name));
appendPQExpBuffer(q, "CREATE TABLE %s (", appendPQExpBuffer(q, "CREATE TABLE %s (",
fmtId(tbinfo->relname)); fmtId(tbinfo->dobj.name));
actual_atts = 0; actual_atts = 0;
for (j = 0; j < tbinfo->numatts; j++) for (j = 0; j < tbinfo->numatts; j++)
{ {
...@@ -6298,7 +6361,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) ...@@ -6298,7 +6361,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
appendPQExpBuffer(q, ",\n "); appendPQExpBuffer(q, ",\n ");
appendPQExpBuffer(q, "CONSTRAINT %s ", appendPQExpBuffer(q, "CONSTRAINT %s ",
fmtId(constr->conname)); fmtId(constr->dobj.name));
appendPQExpBuffer(q, "%s", constr->condef); appendPQExpBuffer(q, "%s", constr->condef);
actual_atts++; actual_atts++;
...@@ -6315,11 +6378,11 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) ...@@ -6315,11 +6378,11 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
if (k > 0) if (k > 0)
appendPQExpBuffer(q, ", "); appendPQExpBuffer(q, ", ");
if (parentRel->relnamespace != tbinfo->relnamespace) if (parentRel->dobj.namespace != tbinfo->dobj.namespace)
appendPQExpBuffer(q, "%s.", appendPQExpBuffer(q, "%s.",
fmtId(parentRel->relnamespace->nspname)); fmtId(parentRel->dobj.namespace->dobj.name));
appendPQExpBuffer(q, "%s", appendPQExpBuffer(q, "%s",
fmtId(parentRel->relname)); fmtId(parentRel->dobj.name));
} }
appendPQExpBuffer(q, ")"); appendPQExpBuffer(q, ")");
} }
...@@ -6340,7 +6403,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) ...@@ -6340,7 +6403,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
!tbinfo->attisdropped[j]) !tbinfo->attisdropped[j])
{ {
appendPQExpBuffer(q, "ALTER TABLE ONLY %s ", appendPQExpBuffer(q, "ALTER TABLE ONLY %s ",
fmtId(tbinfo->relname)); fmtId(tbinfo->dobj.name));
appendPQExpBuffer(q, "ALTER COLUMN %s ", appendPQExpBuffer(q, "ALTER COLUMN %s ",
fmtId(tbinfo->attnames[j])); fmtId(tbinfo->attnames[j]));
appendPQExpBuffer(q, "SET STATISTICS %d;\n", appendPQExpBuffer(q, "SET STATISTICS %d;\n",
...@@ -6379,7 +6442,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) ...@@ -6379,7 +6442,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
if (storage != NULL) if (storage != NULL)
{ {
appendPQExpBuffer(q, "ALTER TABLE ONLY %s ", appendPQExpBuffer(q, "ALTER TABLE ONLY %s ",
fmtId(tbinfo->relname)); fmtId(tbinfo->dobj.name));
appendPQExpBuffer(q, "ALTER COLUMN %s ", appendPQExpBuffer(q, "ALTER COLUMN %s ",
fmtId(tbinfo->attnames[j])); fmtId(tbinfo->attnames[j]));
appendPQExpBuffer(q, "SET STORAGE %s;\n", appendPQExpBuffer(q, "SET STORAGE %s;\n",
...@@ -6390,8 +6453,8 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) ...@@ -6390,8 +6453,8 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
} }
ArchiveEntry(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId, ArchiveEntry(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId,
tbinfo->relname, tbinfo->dobj.name,
tbinfo->relnamespace->nspname, tbinfo->usename, tbinfo->dobj.namespace->dobj.name, tbinfo->usename,
reltypename, q->data, delq->data, NULL, reltypename, q->data, delq->data, NULL,
tbinfo->dobj.dependencies, tbinfo->dobj.nDeps, tbinfo->dobj.dependencies, tbinfo->dobj.nDeps,
NULL, NULL); NULL, NULL);
...@@ -6427,7 +6490,7 @@ dumpAttrDef(Archive *fout, AttrDefInfo *adinfo) ...@@ -6427,7 +6490,7 @@ dumpAttrDef(Archive *fout, AttrDefInfo *adinfo)
delq = createPQExpBuffer(); delq = createPQExpBuffer();
appendPQExpBuffer(q, "ALTER TABLE %s ", appendPQExpBuffer(q, "ALTER TABLE %s ",
fmtId(tbinfo->relname)); fmtId(tbinfo->dobj.name));
appendPQExpBuffer(q, "ALTER COLUMN %s SET DEFAULT %s;\n", appendPQExpBuffer(q, "ALTER COLUMN %s SET DEFAULT %s;\n",
fmtId(tbinfo->attnames[adnum - 1]), fmtId(tbinfo->attnames[adnum - 1]),
adinfo->adef_expr); adinfo->adef_expr);
...@@ -6437,15 +6500,15 @@ dumpAttrDef(Archive *fout, AttrDefInfo *adinfo) ...@@ -6437,15 +6500,15 @@ dumpAttrDef(Archive *fout, AttrDefInfo *adinfo)
* in pg_catalog * in pg_catalog
*/ */
appendPQExpBuffer(delq, "ALTER TABLE %s.", appendPQExpBuffer(delq, "ALTER TABLE %s.",
fmtId(tbinfo->relnamespace->nspname)); fmtId(tbinfo->dobj.namespace->dobj.name));
appendPQExpBuffer(delq, "%s ", appendPQExpBuffer(delq, "%s ",
fmtId(tbinfo->relname)); fmtId(tbinfo->dobj.name));
appendPQExpBuffer(delq, "ALTER COLUMN %s DROP DEFAULT;\n", appendPQExpBuffer(delq, "ALTER COLUMN %s DROP DEFAULT;\n",
fmtId(tbinfo->attnames[adnum - 1])); fmtId(tbinfo->attnames[adnum - 1]));
ArchiveEntry(fout, adinfo->dobj.catId, adinfo->dobj.dumpId, ArchiveEntry(fout, adinfo->dobj.catId, adinfo->dobj.dumpId,
tbinfo->attnames[adnum - 1], tbinfo->attnames[adnum - 1],
tbinfo->relnamespace->nspname, tbinfo->usename, tbinfo->dobj.namespace->dobj.name, tbinfo->usename,
"DEFAULT", q->data, delq->data, NULL, "DEFAULT", q->data, delq->data, NULL,
adinfo->dobj.dependencies, adinfo->dobj.nDeps, adinfo->dobj.dependencies, adinfo->dobj.nDeps,
NULL, NULL); NULL, NULL);
...@@ -6484,7 +6547,7 @@ getAttrName(int attrnum, TableInfo *tblInfo) ...@@ -6484,7 +6547,7 @@ getAttrName(int attrnum, TableInfo *tblInfo)
return "tableoid"; return "tableoid";
} }
write_msg(NULL, "invalid column number %d for table \"%s\"\n", write_msg(NULL, "invalid column number %d for table \"%s\"\n",
attrnum, tblInfo->relname); attrnum, tblInfo->dobj.name);
exit_nicely(); exit_nicely();
return NULL; /* keep compiler quiet */ return NULL; /* keep compiler quiet */
} }
...@@ -6519,9 +6582,9 @@ dumpIndex(Archive *fout, IndxInfo *indxinfo) ...@@ -6519,9 +6582,9 @@ dumpIndex(Archive *fout, IndxInfo *indxinfo)
if (indxinfo->indisclustered) if (indxinfo->indisclustered)
{ {
appendPQExpBuffer(q, "\nALTER TABLE %s CLUSTER", appendPQExpBuffer(q, "\nALTER TABLE %s CLUSTER",
fmtId(tbinfo->relname)); fmtId(tbinfo->dobj.name));
appendPQExpBuffer(q, " ON %s;\n", appendPQExpBuffer(q, " ON %s;\n",
fmtId(indxinfo->indexname)); fmtId(indxinfo->dobj.name));
} }
/* /*
...@@ -6529,13 +6592,13 @@ dumpIndex(Archive *fout, IndxInfo *indxinfo) ...@@ -6529,13 +6592,13 @@ dumpIndex(Archive *fout, IndxInfo *indxinfo)
* in pg_catalog * in pg_catalog
*/ */
appendPQExpBuffer(delq, "DROP INDEX %s.", appendPQExpBuffer(delq, "DROP INDEX %s.",
fmtId(tbinfo->relnamespace->nspname)); fmtId(tbinfo->dobj.namespace->dobj.name));
appendPQExpBuffer(delq, "%s;\n", appendPQExpBuffer(delq, "%s;\n",
fmtId(indxinfo->indexname)); fmtId(indxinfo->dobj.name));
ArchiveEntry(fout, indxinfo->dobj.catId, indxinfo->dobj.dumpId, ArchiveEntry(fout, indxinfo->dobj.catId, indxinfo->dobj.dumpId,
indxinfo->indexname, indxinfo->dobj.name,
tbinfo->relnamespace->nspname, tbinfo->dobj.namespace->dobj.name,
tbinfo->usename, tbinfo->usename,
"INDEX", q->data, delq->data, NULL, "INDEX", q->data, delq->data, NULL,
indxinfo->dobj.dependencies, indxinfo->dobj.nDeps, indxinfo->dobj.dependencies, indxinfo->dobj.nDeps,
...@@ -6545,9 +6608,9 @@ dumpIndex(Archive *fout, IndxInfo *indxinfo) ...@@ -6545,9 +6608,9 @@ dumpIndex(Archive *fout, IndxInfo *indxinfo)
/* Dump Index Comments */ /* Dump Index Comments */
resetPQExpBuffer(q); resetPQExpBuffer(q);
appendPQExpBuffer(q, "INDEX %s", appendPQExpBuffer(q, "INDEX %s",
fmtId(indxinfo->indexname)); fmtId(indxinfo->dobj.name));
dumpComment(fout, q->data, dumpComment(fout, q->data,
tbinfo->relnamespace->nspname, tbinfo->dobj.namespace->dobj.name,
tbinfo->usename, tbinfo->usename,
indxinfo->dobj.catId, 0, indxinfo->dobj.dumpId); indxinfo->dobj.catId, 0, indxinfo->dobj.dumpId);
...@@ -6585,14 +6648,14 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo) ...@@ -6585,14 +6648,14 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
if (indxinfo == NULL) if (indxinfo == NULL)
{ {
write_msg(NULL, "missing index for constraint %s\n", write_msg(NULL, "missing index for constraint %s\n",
coninfo->conname); coninfo->dobj.name);
exit_nicely(); exit_nicely();
} }
appendPQExpBuffer(q, "ALTER TABLE ONLY %s\n", appendPQExpBuffer(q, "ALTER TABLE ONLY %s\n",
fmtId(tbinfo->relname)); fmtId(tbinfo->dobj.name));
appendPQExpBuffer(q, " ADD CONSTRAINT %s %s (", appendPQExpBuffer(q, " ADD CONSTRAINT %s %s (",
fmtId(coninfo->conname), fmtId(coninfo->dobj.name),
coninfo->contype == 'p' ? "PRIMARY KEY" : "UNIQUE"); coninfo->contype == 'p' ? "PRIMARY KEY" : "UNIQUE");
for (k = 0; k < indxinfo->indnkeys; k++) for (k = 0; k < indxinfo->indnkeys; k++)
...@@ -6615,9 +6678,9 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo) ...@@ -6615,9 +6678,9 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
if (indxinfo->indisclustered) if (indxinfo->indisclustered)
{ {
appendPQExpBuffer(q, "\nALTER TABLE %s CLUSTER", appendPQExpBuffer(q, "\nALTER TABLE %s CLUSTER",
fmtId(tbinfo->relname)); fmtId(tbinfo->dobj.name));
appendPQExpBuffer(q, " ON %s;\n", appendPQExpBuffer(q, " ON %s;\n",
fmtId(indxinfo->indexname)); fmtId(indxinfo->dobj.name));
} }
/* /*
...@@ -6625,15 +6688,15 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo) ...@@ -6625,15 +6688,15 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
* in pg_catalog * in pg_catalog
*/ */
appendPQExpBuffer(delq, "ALTER TABLE ONLY %s.", appendPQExpBuffer(delq, "ALTER TABLE ONLY %s.",
fmtId(tbinfo->relnamespace->nspname)); fmtId(tbinfo->dobj.namespace->dobj.name));
appendPQExpBuffer(delq, "%s ", appendPQExpBuffer(delq, "%s ",
fmtId(tbinfo->relname)); fmtId(tbinfo->dobj.name));
appendPQExpBuffer(delq, "DROP CONSTRAINT %s;\n", appendPQExpBuffer(delq, "DROP CONSTRAINT %s;\n",
fmtId(coninfo->conname)); fmtId(coninfo->dobj.name));
ArchiveEntry(fout, coninfo->dobj.catId, coninfo->dobj.dumpId, ArchiveEntry(fout, coninfo->dobj.catId, coninfo->dobj.dumpId,
coninfo->conname, coninfo->dobj.name,
tbinfo->relnamespace->nspname, tbinfo->dobj.namespace->dobj.name,
tbinfo->usename, tbinfo->usename,
"CONSTRAINT", q->data, delq->data, NULL, "CONSTRAINT", q->data, delq->data, NULL,
coninfo->dobj.dependencies, coninfo->dobj.nDeps, coninfo->dobj.dependencies, coninfo->dobj.nDeps,
...@@ -6646,9 +6709,9 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo) ...@@ -6646,9 +6709,9 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
* the current table data is not processed * the current table data is not processed
*/ */
appendPQExpBuffer(q, "ALTER TABLE ONLY %s\n", appendPQExpBuffer(q, "ALTER TABLE ONLY %s\n",
fmtId(tbinfo->relname)); fmtId(tbinfo->dobj.name));
appendPQExpBuffer(q, " ADD CONSTRAINT %s %s;\n", appendPQExpBuffer(q, " ADD CONSTRAINT %s %s;\n",
fmtId(coninfo->conname), fmtId(coninfo->dobj.name),
coninfo->condef); coninfo->condef);
/* /*
...@@ -6656,15 +6719,15 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo) ...@@ -6656,15 +6719,15 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
* pg_catalog * pg_catalog
*/ */
appendPQExpBuffer(delq, "ALTER TABLE ONLY %s.", appendPQExpBuffer(delq, "ALTER TABLE ONLY %s.",
fmtId(tbinfo->relnamespace->nspname)); fmtId(tbinfo->dobj.namespace->dobj.name));
appendPQExpBuffer(delq, "%s ", appendPQExpBuffer(delq, "%s ",
fmtId(tbinfo->relname)); fmtId(tbinfo->dobj.name));
appendPQExpBuffer(delq, "DROP CONSTRAINT %s;\n", appendPQExpBuffer(delq, "DROP CONSTRAINT %s;\n",
fmtId(coninfo->conname)); fmtId(coninfo->dobj.name));
ArchiveEntry(fout, coninfo->dobj.catId, coninfo->dobj.dumpId, ArchiveEntry(fout, coninfo->dobj.catId, coninfo->dobj.dumpId,
coninfo->conname, coninfo->dobj.name,
tbinfo->relnamespace->nspname, tbinfo->dobj.namespace->dobj.name,
tbinfo->usename, tbinfo->usename,
"FK CONSTRAINT", q->data, delq->data, NULL, "FK CONSTRAINT", q->data, delq->data, NULL,
coninfo->dobj.dependencies, coninfo->dobj.nDeps, coninfo->dobj.dependencies, coninfo->dobj.nDeps,
...@@ -6679,9 +6742,9 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo) ...@@ -6679,9 +6742,9 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
{ {
/* not ONLY since we want it to propagate to children */ /* not ONLY since we want it to propagate to children */
appendPQExpBuffer(q, "ALTER TABLE %s\n", appendPQExpBuffer(q, "ALTER TABLE %s\n",
fmtId(tbinfo->relname)); fmtId(tbinfo->dobj.name));
appendPQExpBuffer(q, " ADD CONSTRAINT %s %s;\n", appendPQExpBuffer(q, " ADD CONSTRAINT %s %s;\n",
fmtId(coninfo->conname), fmtId(coninfo->dobj.name),
coninfo->condef); coninfo->condef);
/* /*
...@@ -6689,15 +6752,15 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo) ...@@ -6689,15 +6752,15 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
* pg_catalog * pg_catalog
*/ */
appendPQExpBuffer(delq, "ALTER TABLE %s.", appendPQExpBuffer(delq, "ALTER TABLE %s.",
fmtId(tbinfo->relnamespace->nspname)); fmtId(tbinfo->dobj.namespace->dobj.name));
appendPQExpBuffer(delq, "%s ", appendPQExpBuffer(delq, "%s ",
fmtId(tbinfo->relname)); fmtId(tbinfo->dobj.name));
appendPQExpBuffer(delq, "DROP CONSTRAINT %s;\n", appendPQExpBuffer(delq, "DROP CONSTRAINT %s;\n",
fmtId(coninfo->conname)); fmtId(coninfo->dobj.name));
ArchiveEntry(fout, coninfo->dobj.catId, coninfo->dobj.dumpId, ArchiveEntry(fout, coninfo->dobj.catId, coninfo->dobj.dumpId,
coninfo->conname, coninfo->dobj.name,
tbinfo->relnamespace->nspname, tbinfo->dobj.namespace->dobj.name,
tbinfo->usename, tbinfo->usename,
"CHECK CONSTRAINT", q->data, delq->data, NULL, "CHECK CONSTRAINT", q->data, delq->data, NULL,
coninfo->dobj.dependencies, coninfo->dobj.nDeps, coninfo->dobj.dependencies, coninfo->dobj.nDeps,
...@@ -6710,12 +6773,12 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo) ...@@ -6710,12 +6773,12 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
TypeInfo *tinfo = coninfo->condomain; TypeInfo *tinfo = coninfo->condomain;
/* Ignore if not to be dumped separately, or if not dumping domain */ /* Ignore if not to be dumped separately, or if not dumping domain */
if (coninfo->separate && tinfo->typnamespace->dump) if (coninfo->separate && tinfo->dobj.namespace->dump)
{ {
appendPQExpBuffer(q, "ALTER DOMAIN %s\n", appendPQExpBuffer(q, "ALTER DOMAIN %s\n",
fmtId(tinfo->typname)); fmtId(tinfo->dobj.name));
appendPQExpBuffer(q, " ADD CONSTRAINT %s %s;\n", appendPQExpBuffer(q, " ADD CONSTRAINT %s %s;\n",
fmtId(coninfo->conname), fmtId(coninfo->dobj.name),
coninfo->condef); coninfo->condef);
/* /*
...@@ -6723,15 +6786,15 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo) ...@@ -6723,15 +6786,15 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
* pg_catalog * pg_catalog
*/ */
appendPQExpBuffer(delq, "ALTER DOMAIN %s.", appendPQExpBuffer(delq, "ALTER DOMAIN %s.",
fmtId(tinfo->typnamespace->nspname)); fmtId(tinfo->dobj.namespace->dobj.name));
appendPQExpBuffer(delq, "%s ", appendPQExpBuffer(delq, "%s ",
fmtId(tinfo->typname)); fmtId(tinfo->dobj.name));
appendPQExpBuffer(delq, "DROP CONSTRAINT %s;\n", appendPQExpBuffer(delq, "DROP CONSTRAINT %s;\n",
fmtId(coninfo->conname)); fmtId(coninfo->dobj.name));
ArchiveEntry(fout, coninfo->dobj.catId, coninfo->dobj.dumpId, ArchiveEntry(fout, coninfo->dobj.catId, coninfo->dobj.dumpId,
coninfo->conname, coninfo->dobj.name,
tinfo->typnamespace->nspname, tinfo->dobj.namespace->dobj.name,
tinfo->usename, tinfo->usename,
"CHECK CONSTRAINT", q->data, delq->data, NULL, "CHECK CONSTRAINT", q->data, delq->data, NULL,
coninfo->dobj.dependencies, coninfo->dobj.nDeps, coninfo->dobj.dependencies, coninfo->dobj.nDeps,
...@@ -6749,11 +6812,11 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo) ...@@ -6749,11 +6812,11 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
{ {
resetPQExpBuffer(q); resetPQExpBuffer(q);
appendPQExpBuffer(q, "CONSTRAINT %s ", appendPQExpBuffer(q, "CONSTRAINT %s ",
fmtId(coninfo->conname)); fmtId(coninfo->dobj.name));
appendPQExpBuffer(q, "ON %s", appendPQExpBuffer(q, "ON %s",
fmtId(tbinfo->relname)); fmtId(tbinfo->dobj.name));
dumpComment(fout, q->data, dumpComment(fout, q->data,
tbinfo->relnamespace->nspname, tbinfo->dobj.namespace->dobj.name,
tbinfo->usename, tbinfo->usename,
coninfo->dobj.catId, 0, coninfo->dobj.dumpId); coninfo->dobj.catId, 0, coninfo->dobj.dumpId);
} }
...@@ -6896,7 +6959,7 @@ dumpSequence(Archive *fout, TableInfo *tbinfo) ...@@ -6896,7 +6959,7 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
PQExpBuffer delqry = createPQExpBuffer(); PQExpBuffer delqry = createPQExpBuffer();
/* Make sure we are in proper schema */ /* Make sure we are in proper schema */
selectSourceSchema(tbinfo->relnamespace->nspname); selectSourceSchema(tbinfo->dobj.namespace->dobj.name);
snprintf(bufm, sizeof(bufm), INT64_FORMAT, SEQ_MINVALUE); snprintf(bufm, sizeof(bufm), INT64_FORMAT, SEQ_MINVALUE);
snprintf(bufx, sizeof(bufx), INT64_FORMAT, SEQ_MAXVALUE); snprintf(bufx, sizeof(bufx), INT64_FORMAT, SEQ_MAXVALUE);
...@@ -6913,7 +6976,7 @@ dumpSequence(Archive *fout, TableInfo *tbinfo) ...@@ -6913,7 +6976,7 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
"END AS min_value, " "END AS min_value, "
"cache_value, is_cycled, is_called from %s", "cache_value, is_cycled, is_called from %s",
bufx, bufm, bufx, bufm,
fmtId(tbinfo->relname)); fmtId(tbinfo->dobj.name));
res = PQexec(g_conn, query->data); res = PQexec(g_conn, query->data);
check_sql_result(res, g_conn, query->data, PGRES_TUPLES_OK); check_sql_result(res, g_conn, query->data, PGRES_TUPLES_OK);
...@@ -6921,16 +6984,16 @@ dumpSequence(Archive *fout, TableInfo *tbinfo) ...@@ -6921,16 +6984,16 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
if (PQntuples(res) != 1) if (PQntuples(res) != 1)
{ {
write_msg(NULL, "query to get data of sequence \"%s\" returned %d rows (expected 1)\n", write_msg(NULL, "query to get data of sequence \"%s\" returned %d rows (expected 1)\n",
tbinfo->relname, PQntuples(res)); tbinfo->dobj.name, PQntuples(res));
exit_nicely(); exit_nicely();
} }
/* Disable this check: it fails if sequence has been renamed */ /* Disable this check: it fails if sequence has been renamed */
#ifdef NOT_USED #ifdef NOT_USED
if (strcmp(PQgetvalue(res, 0, 0), tbinfo->relname) != 0) if (strcmp(PQgetvalue(res, 0, 0), tbinfo->dobj.name) != 0)
{ {
write_msg(NULL, "query to get data of sequence \"%s\" returned name \"%s\"\n", write_msg(NULL, "query to get data of sequence \"%s\" returned name \"%s\"\n",
tbinfo->relname, PQgetvalue(res, 0, 0)); tbinfo->dobj.name, PQgetvalue(res, 0, 0));
exit_nicely(); exit_nicely();
} }
#endif #endif
...@@ -6965,14 +7028,14 @@ dumpSequence(Archive *fout, TableInfo *tbinfo) ...@@ -6965,14 +7028,14 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
* pg_catalog * pg_catalog
*/ */
appendPQExpBuffer(delqry, "DROP SEQUENCE %s.", appendPQExpBuffer(delqry, "DROP SEQUENCE %s.",
fmtId(tbinfo->relnamespace->nspname)); fmtId(tbinfo->dobj.namespace->dobj.name));
appendPQExpBuffer(delqry, "%s;\n", appendPQExpBuffer(delqry, "%s;\n",
fmtId(tbinfo->relname)); fmtId(tbinfo->dobj.name));
resetPQExpBuffer(query); resetPQExpBuffer(query);
appendPQExpBuffer(query, appendPQExpBuffer(query,
"CREATE SEQUENCE %s\n", "CREATE SEQUENCE %s\n",
fmtId(tbinfo->relname)); fmtId(tbinfo->dobj.name));
if (!called) if (!called)
appendPQExpBuffer(query, " START WITH %s\n", last); appendPQExpBuffer(query, " START WITH %s\n", last);
...@@ -6994,8 +7057,8 @@ dumpSequence(Archive *fout, TableInfo *tbinfo) ...@@ -6994,8 +7057,8 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
cache, (cycled ? "\n CYCLE" : "")); cache, (cycled ? "\n CYCLE" : ""));
ArchiveEntry(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId, ArchiveEntry(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId,
tbinfo->relname, tbinfo->dobj.name,
tbinfo->relnamespace->nspname, tbinfo->usename, tbinfo->dobj.namespace->dobj.name, tbinfo->usename,
"SEQUENCE", query->data, delqry->data, NULL, "SEQUENCE", query->data, delqry->data, NULL,
tbinfo->dobj.dependencies, tbinfo->dobj.nDeps, tbinfo->dobj.dependencies, tbinfo->dobj.nDeps,
NULL, NULL); NULL, NULL);
...@@ -7005,13 +7068,13 @@ dumpSequence(Archive *fout, TableInfo *tbinfo) ...@@ -7005,13 +7068,13 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
{ {
resetPQExpBuffer(query); resetPQExpBuffer(query);
appendPQExpBuffer(query, "SELECT pg_catalog.setval("); appendPQExpBuffer(query, "SELECT pg_catalog.setval(");
appendStringLiteral(query, fmtId(tbinfo->relname), true); appendStringLiteral(query, fmtId(tbinfo->dobj.name), true);
appendPQExpBuffer(query, ", %s, %s);\n", appendPQExpBuffer(query, ", %s, %s);\n",
last, (called ? "true" : "false")); last, (called ? "true" : "false"));
ArchiveEntry(fout, nilCatalogId, createDumpId(), ArchiveEntry(fout, nilCatalogId, createDumpId(),
tbinfo->relname, tbinfo->dobj.name,
tbinfo->relnamespace->nspname, tbinfo->usename, tbinfo->dobj.namespace->dobj.name, tbinfo->usename,
"SEQUENCE SET", query->data, "", NULL, "SEQUENCE SET", query->data, "", NULL,
&(tbinfo->dobj.dumpId), 1, &(tbinfo->dobj.dumpId), 1,
NULL, NULL); NULL, NULL);
...@@ -7021,9 +7084,9 @@ dumpSequence(Archive *fout, TableInfo *tbinfo) ...@@ -7021,9 +7084,9 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
{ {
/* Dump Sequence Comments */ /* Dump Sequence Comments */
resetPQExpBuffer(query); resetPQExpBuffer(query);
appendPQExpBuffer(query, "SEQUENCE %s", fmtId(tbinfo->relname)); appendPQExpBuffer(query, "SEQUENCE %s", fmtId(tbinfo->dobj.name));
dumpComment(fout, query->data, dumpComment(fout, query->data,
tbinfo->relnamespace->nspname, tbinfo->usename, tbinfo->dobj.namespace->dobj.name, tbinfo->usename,
tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId); tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId);
} }
...@@ -7053,11 +7116,11 @@ dumpTrigger(Archive *fout, TriggerInfo *tginfo) ...@@ -7053,11 +7116,11 @@ dumpTrigger(Archive *fout, TriggerInfo *tginfo)
* pg_catalog * pg_catalog
*/ */
appendPQExpBuffer(delqry, "DROP TRIGGER %s ", appendPQExpBuffer(delqry, "DROP TRIGGER %s ",
fmtId(tginfo->tgname)); fmtId(tginfo->dobj.name));
appendPQExpBuffer(delqry, "ON %s.", appendPQExpBuffer(delqry, "ON %s.",
fmtId(tbinfo->relnamespace->nspname)); fmtId(tbinfo->dobj.namespace->dobj.name));
appendPQExpBuffer(delqry, "%s;\n", appendPQExpBuffer(delqry, "%s;\n",
fmtId(tbinfo->relname)); fmtId(tbinfo->dobj.name));
if (tginfo->tgisconstraint) if (tginfo->tgisconstraint)
{ {
...@@ -7067,7 +7130,7 @@ dumpTrigger(Archive *fout, TriggerInfo *tginfo) ...@@ -7067,7 +7130,7 @@ dumpTrigger(Archive *fout, TriggerInfo *tginfo)
else else
{ {
appendPQExpBuffer(query, "CREATE TRIGGER "); appendPQExpBuffer(query, "CREATE TRIGGER ");
appendPQExpBuffer(query, fmtId(tginfo->tgname)); appendPQExpBuffer(query, fmtId(tginfo->dobj.name));
} }
appendPQExpBuffer(query, "\n "); appendPQExpBuffer(query, "\n ");
...@@ -7098,7 +7161,7 @@ dumpTrigger(Archive *fout, TriggerInfo *tginfo) ...@@ -7098,7 +7161,7 @@ dumpTrigger(Archive *fout, TriggerInfo *tginfo)
appendPQExpBuffer(query, " UPDATE"); appendPQExpBuffer(query, " UPDATE");
} }
appendPQExpBuffer(query, " ON %s\n", appendPQExpBuffer(query, " ON %s\n",
fmtId(tbinfo->relname)); fmtId(tbinfo->dobj.name));
if (tginfo->tgisconstraint) if (tginfo->tgisconstraint)
{ {
...@@ -7146,8 +7209,8 @@ dumpTrigger(Archive *fout, TriggerInfo *tginfo) ...@@ -7146,8 +7209,8 @@ dumpTrigger(Archive *fout, TriggerInfo *tginfo)
{ {
write_msg(NULL, "invalid argument string (%s) for trigger \"%s\" on table \"%s\"\n", write_msg(NULL, "invalid argument string (%s) for trigger \"%s\" on table \"%s\"\n",
tginfo->tgargs, tginfo->tgargs,
tginfo->tgname, tginfo->dobj.name,
tbinfo->relname); tbinfo->dobj.name);
exit_nicely(); exit_nicely();
} }
p++; p++;
...@@ -7175,8 +7238,8 @@ dumpTrigger(Archive *fout, TriggerInfo *tginfo) ...@@ -7175,8 +7238,8 @@ dumpTrigger(Archive *fout, TriggerInfo *tginfo)
appendPQExpBuffer(query, ");\n"); appendPQExpBuffer(query, ");\n");
ArchiveEntry(fout, tginfo->dobj.catId, tginfo->dobj.dumpId, ArchiveEntry(fout, tginfo->dobj.catId, tginfo->dobj.dumpId,
tginfo->tgname, tginfo->dobj.name,
tbinfo->relnamespace->nspname, tbinfo->dobj.namespace->dobj.name,
tbinfo->usename, tbinfo->usename,
"TRIGGER", query->data, delqry->data, NULL, "TRIGGER", query->data, delqry->data, NULL,
tginfo->dobj.dependencies, tginfo->dobj.nDeps, tginfo->dobj.dependencies, tginfo->dobj.nDeps,
...@@ -7184,12 +7247,12 @@ dumpTrigger(Archive *fout, TriggerInfo *tginfo) ...@@ -7184,12 +7247,12 @@ dumpTrigger(Archive *fout, TriggerInfo *tginfo)
resetPQExpBuffer(query); resetPQExpBuffer(query);
appendPQExpBuffer(query, "TRIGGER %s ", appendPQExpBuffer(query, "TRIGGER %s ",
fmtId(tginfo->tgname)); fmtId(tginfo->dobj.name));
appendPQExpBuffer(query, "ON %s", appendPQExpBuffer(query, "ON %s",
fmtId(tbinfo->relname)); fmtId(tbinfo->dobj.name));
dumpComment(fout, query->data, dumpComment(fout, query->data,
tbinfo->relnamespace->nspname, tbinfo->usename, tbinfo->dobj.namespace->dobj.name, tbinfo->usename,
tginfo->dobj.catId, 0, tginfo->dobj.dumpId); tginfo->dobj.catId, 0, tginfo->dobj.dumpId);
destroyPQExpBuffer(query); destroyPQExpBuffer(query);
...@@ -7225,7 +7288,7 @@ dumpRule(Archive *fout, RuleInfo *rinfo) ...@@ -7225,7 +7288,7 @@ dumpRule(Archive *fout, RuleInfo *rinfo)
/* /*
* Make sure we are in proper schema. * Make sure we are in proper schema.
*/ */
selectSourceSchema(tbinfo->relnamespace->nspname); selectSourceSchema(tbinfo->dobj.namespace->dobj.name);
query = createPQExpBuffer(); query = createPQExpBuffer();
cmd = createPQExpBuffer(); cmd = createPQExpBuffer();
...@@ -7242,7 +7305,7 @@ dumpRule(Archive *fout, RuleInfo *rinfo) ...@@ -7242,7 +7305,7 @@ dumpRule(Archive *fout, RuleInfo *rinfo)
/* Rule name was unique before 7.3 ... */ /* Rule name was unique before 7.3 ... */
appendPQExpBuffer(query, appendPQExpBuffer(query,
"SELECT pg_get_ruledef('%s') AS definition", "SELECT pg_get_ruledef('%s') AS definition",
rinfo->rulename); rinfo->dobj.name);
} }
res = PQexec(g_conn, query->data); res = PQexec(g_conn, query->data);
...@@ -7251,7 +7314,7 @@ dumpRule(Archive *fout, RuleInfo *rinfo) ...@@ -7251,7 +7314,7 @@ dumpRule(Archive *fout, RuleInfo *rinfo)
if (PQntuples(res) != 1) if (PQntuples(res) != 1)
{ {
write_msg(NULL, "query to get rule \"%s\" for table \"%s\" failed: wrong number of rows returned", write_msg(NULL, "query to get rule \"%s\" for table \"%s\" failed: wrong number of rows returned",
rinfo->rulename, tbinfo->relname); rinfo->dobj.name, tbinfo->dobj.name);
exit_nicely(); exit_nicely();
} }
...@@ -7262,15 +7325,15 @@ dumpRule(Archive *fout, RuleInfo *rinfo) ...@@ -7262,15 +7325,15 @@ dumpRule(Archive *fout, RuleInfo *rinfo)
* pg_catalog * pg_catalog
*/ */
appendPQExpBuffer(delcmd, "DROP RULE %s ", appendPQExpBuffer(delcmd, "DROP RULE %s ",
fmtId(rinfo->rulename)); fmtId(rinfo->dobj.name));
appendPQExpBuffer(delcmd, "ON %s.", appendPQExpBuffer(delcmd, "ON %s.",
fmtId(tbinfo->relnamespace->nspname)); fmtId(tbinfo->dobj.namespace->dobj.name));
appendPQExpBuffer(delcmd, "%s;\n", appendPQExpBuffer(delcmd, "%s;\n",
fmtId(tbinfo->relname)); fmtId(tbinfo->dobj.name));
ArchiveEntry(fout, rinfo->dobj.catId, rinfo->dobj.dumpId, ArchiveEntry(fout, rinfo->dobj.catId, rinfo->dobj.dumpId,
rinfo->rulename, rinfo->dobj.name,
tbinfo->relnamespace->nspname, tbinfo->dobj.namespace->dobj.name,
tbinfo->usename, tbinfo->usename,
"RULE", cmd->data, delcmd->data, NULL, "RULE", cmd->data, delcmd->data, NULL,
rinfo->dobj.dependencies, rinfo->dobj.nDeps, rinfo->dobj.dependencies, rinfo->dobj.nDeps,
...@@ -7279,11 +7342,11 @@ dumpRule(Archive *fout, RuleInfo *rinfo) ...@@ -7279,11 +7342,11 @@ dumpRule(Archive *fout, RuleInfo *rinfo)
/* Dump rule comments */ /* Dump rule comments */
resetPQExpBuffer(query); resetPQExpBuffer(query);
appendPQExpBuffer(query, "RULE %s", appendPQExpBuffer(query, "RULE %s",
fmtId(rinfo->rulename)); fmtId(rinfo->dobj.name));
appendPQExpBuffer(query, " ON %s", appendPQExpBuffer(query, " ON %s",
fmtId(tbinfo->relname)); fmtId(tbinfo->dobj.name));
dumpComment(fout, query->data, dumpComment(fout, query->data,
tbinfo->relnamespace->nspname, tbinfo->dobj.namespace->dobj.name,
tbinfo->usename, tbinfo->usename,
rinfo->dobj.catId, 0, rinfo->dobj.dumpId); rinfo->dobj.catId, 0, rinfo->dobj.dumpId);
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.h,v 1.107 2003/12/06 03:00:16 tgl Exp $ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.h,v 1.108 2004/03/03 21:28:55 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -59,7 +59,7 @@ typedef int DumpId; ...@@ -59,7 +59,7 @@ typedef int DumpId;
typedef enum typedef enum
{ {
/* When modifying this enum, update priority table in pg_dump_sort.c! */ /* When modifying this enum, update priority tables in pg_dump_sort.c! */
DO_NAMESPACE, DO_NAMESPACE,
DO_TYPE, DO_TYPE,
DO_FUNC, DO_FUNC,
...@@ -76,7 +76,9 @@ typedef enum ...@@ -76,7 +76,9 @@ typedef enum
DO_FK_CONSTRAINT, /* see note for ConstraintInfo */ DO_FK_CONSTRAINT, /* see note for ConstraintInfo */
DO_PROCLANG, DO_PROCLANG,
DO_CAST, DO_CAST,
DO_TABLE_DATA DO_TABLE_DATA,
DO_TABLE_TYPE,
DO_BLOBS
} DumpableObjectType; } DumpableObjectType;
typedef struct _dumpableObject typedef struct _dumpableObject
...@@ -84,6 +86,8 @@ typedef struct _dumpableObject ...@@ -84,6 +86,8 @@ typedef struct _dumpableObject
DumpableObjectType objType; DumpableObjectType objType;
CatalogId catId; /* zero if not a cataloged object */ CatalogId catId; /* zero if not a cataloged object */
DumpId dumpId; /* assigned by AssignDumpId() */ DumpId dumpId; /* assigned by AssignDumpId() */
char *name; /* object name (should never be NULL) */
struct _namespaceInfo *namespace; /* containing namespace, or NULL */
DumpId *dependencies; /* dumpIds of objects this one depends on */ DumpId *dependencies; /* dumpIds of objects this one depends on */
int nDeps; /* number of valid dependencies */ int nDeps; /* number of valid dependencies */
int allocDeps; /* allocated size of dependencies[] */ int allocDeps; /* allocated size of dependencies[] */
...@@ -92,7 +96,6 @@ typedef struct _dumpableObject ...@@ -92,7 +96,6 @@ typedef struct _dumpableObject
typedef struct _namespaceInfo typedef struct _namespaceInfo
{ {
DumpableObject dobj; DumpableObject dobj;
char *nspname;
char *usename; /* name of owner, or empty string */ char *usename; /* name of owner, or empty string */
char *nspacl; char *nspacl;
bool dump; /* true if need to dump definition */ bool dump; /* true if need to dump definition */
...@@ -101,9 +104,10 @@ typedef struct _namespaceInfo ...@@ -101,9 +104,10 @@ typedef struct _namespaceInfo
typedef struct _typeInfo typedef struct _typeInfo
{ {
DumpableObject dobj; DumpableObject dobj;
char *typname; /* name as seen in catalog */ /*
/* Note: format_type might produce something different than typname */ * Note: dobj.name is the pg_type.typname entry. format_type() might
NamespaceInfo *typnamespace; /* link to containing namespace */ * produce something different than typname
*/
char *usename; /* name of owner, or empty string */ char *usename; /* name of owner, or empty string */
Oid typinput; Oid typinput;
Oid typelem; Oid typelem;
...@@ -120,8 +124,6 @@ typedef struct _typeInfo ...@@ -120,8 +124,6 @@ typedef struct _typeInfo
typedef struct _funcInfo typedef struct _funcInfo
{ {
DumpableObject dobj; DumpableObject dobj;
char *proname;
NamespaceInfo *pronamespace; /* link to containing namespace */
char *usename; /* name of owner, or empty string */ char *usename; /* name of owner, or empty string */
Oid lang; Oid lang;
int nargs; int nargs;
...@@ -141,8 +143,6 @@ typedef struct _aggInfo ...@@ -141,8 +143,6 @@ typedef struct _aggInfo
typedef struct _oprInfo typedef struct _oprInfo
{ {
DumpableObject dobj; DumpableObject dobj;
char *oprname;
NamespaceInfo *oprnamespace; /* link to containing namespace */
char *usename; char *usename;
Oid oprcode; Oid oprcode;
} OprInfo; } OprInfo;
...@@ -150,16 +150,12 @@ typedef struct _oprInfo ...@@ -150,16 +150,12 @@ typedef struct _oprInfo
typedef struct _opclassInfo typedef struct _opclassInfo
{ {
DumpableObject dobj; DumpableObject dobj;
char *opcname;
NamespaceInfo *opcnamespace; /* link to containing namespace */
char *usename; char *usename;
} OpclassInfo; } OpclassInfo;
typedef struct _convInfo typedef struct _convInfo
{ {
DumpableObject dobj; DumpableObject dobj;
char *conname;
NamespaceInfo *connamespace; /* link to containing namespace */
char *usename; char *usename;
} ConvInfo; } ConvInfo;
...@@ -169,8 +165,6 @@ typedef struct _tableInfo ...@@ -169,8 +165,6 @@ typedef struct _tableInfo
* These fields are collected for every table in the database. * These fields are collected for every table in the database.
*/ */
DumpableObject dobj; DumpableObject dobj;
char *relname;
NamespaceInfo *relnamespace; /* link to containing namespace */
char *usename; /* name of owner, or empty string */ char *usename; /* name of owner, or empty string */
char *relacl; char *relacl;
char relkind; char relkind;
...@@ -240,7 +234,6 @@ typedef struct _tableDataInfo ...@@ -240,7 +234,6 @@ typedef struct _tableDataInfo
typedef struct _indxInfo typedef struct _indxInfo
{ {
DumpableObject dobj; DumpableObject dobj;
char *indexname;
TableInfo *indextable; /* link to table the index is for */ TableInfo *indextable; /* link to table the index is for */
char *indexdef; char *indexdef;
int indnkeys; int indnkeys;
...@@ -253,7 +246,6 @@ typedef struct _indxInfo ...@@ -253,7 +246,6 @@ typedef struct _indxInfo
typedef struct _ruleInfo typedef struct _ruleInfo
{ {
DumpableObject dobj; DumpableObject dobj;
char *rulename;
TableInfo *ruletable; /* link to table the rule is for */ TableInfo *ruletable; /* link to table the rule is for */
char ev_type; char ev_type;
bool is_instead; bool is_instead;
...@@ -263,7 +255,6 @@ typedef struct _triggerInfo ...@@ -263,7 +255,6 @@ typedef struct _triggerInfo
{ {
DumpableObject dobj; DumpableObject dobj;
TableInfo *tgtable; /* link to table the trigger is for */ TableInfo *tgtable; /* link to table the trigger is for */
char *tgname;
char *tgfname; char *tgfname;
int tgtype; int tgtype;
int tgnargs; int tgnargs;
...@@ -284,7 +275,6 @@ typedef struct _triggerInfo ...@@ -284,7 +275,6 @@ typedef struct _triggerInfo
typedef struct _constraintInfo typedef struct _constraintInfo
{ {
DumpableObject dobj; DumpableObject dobj;
char *conname;
TableInfo *contable; /* NULL if domain constraint */ TableInfo *contable; /* NULL if domain constraint */
TypeInfo *condomain; /* NULL if table constraint */ TypeInfo *condomain; /* NULL if table constraint */
char contype; char contype;
...@@ -297,7 +287,6 @@ typedef struct _constraintInfo ...@@ -297,7 +287,6 @@ typedef struct _constraintInfo
typedef struct _procLangInfo typedef struct _procLangInfo
{ {
DumpableObject dobj; DumpableObject dobj;
char *lanname;
bool lanpltrusted; bool lanpltrusted;
Oid lanplcallfoid; Oid lanplcallfoid;
Oid lanvalidator; Oid lanvalidator;
...@@ -368,7 +357,8 @@ extern void exit_nicely(void); ...@@ -368,7 +357,8 @@ extern void exit_nicely(void);
extern void parseOidArray(const char *str, Oid *array, int arraysize); extern void parseOidArray(const char *str, Oid *array, int arraysize);
extern void sortDumpableObjects(DumpableObject **objs, int numObjs); extern void sortDumpableObjects(DumpableObject **objs, int numObjs);
extern void sortDumpableObjectsByType(DumpableObject **objs, int numObjs); extern void sortDumpableObjectsByTypeName(DumpableObject **objs, int numObjs);
extern void sortDumpableObjectsByTypeOid(DumpableObject **objs, int numObjs);
/* /*
* version specific routines * version specific routines
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump_sort.c,v 1.3 2003/12/07 05:44:50 tgl Exp $ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump_sort.c,v 1.4 2004/03/03 21:28:55 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -20,12 +20,12 @@ ...@@ -20,12 +20,12 @@
static char *modulename = gettext_noop("sorter"); static char *modulename = gettext_noop("sorter");
/* /*
* Sort priority for object types. Objects are sorted by priority, * Sort priority for object types when dumping a pre-7.3 database.
* and within an equal priority level by OID. (This is a relatively * Objects are sorted by priority levels, and within an equal priority level
* crude hack to provide semi-reasonable behavior for old databases * by OID. (This is a relatively crude hack to provide semi-reasonable
* without full dependency info.) * behavior for old databases without full dependency info.)
*/ */
static const int objectTypePriority[] = static const int oldObjectTypePriority[] =
{ {
1, /* DO_NAMESPACE */ 1, /* DO_NAMESPACE */
2, /* DO_TYPE */ 2, /* DO_TYPE */
...@@ -35,19 +35,49 @@ static const int objectTypePriority[] = ...@@ -35,19 +35,49 @@ static const int objectTypePriority[] =
4, /* DO_OPCLASS */ 4, /* DO_OPCLASS */
5, /* DO_CONVERSION */ 5, /* DO_CONVERSION */
6, /* DO_TABLE */ 6, /* DO_TABLE */
7, /* DO_ATTRDEF */ 8, /* DO_ATTRDEF */
10, /* DO_INDEX */ 12, /* DO_INDEX */
11, /* DO_RULE */ 13, /* DO_RULE */
12, /* DO_TRIGGER */ 14, /* DO_TRIGGER */
9, /* DO_CONSTRAINT */ 11, /* DO_CONSTRAINT */
13, /* DO_FK_CONSTRAINT */ 15, /* DO_FK_CONSTRAINT */
2, /* DO_PROCLANG */ 2, /* DO_PROCLANG */
2, /* DO_CAST */ 2, /* DO_CAST */
8 /* DO_TABLE_DATA */ 9, /* DO_TABLE_DATA */
7, /* DO_TABLE_TYPE */
10 /* DO_BLOBS */
}; };
/*
* Sort priority for object types when dumping newer databases.
* Objects are sorted by type, and within a type by name.
*/
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 */
};
static int DOTypeCompare(const void *p1, const void *p2);
static int DOTypeNameCompare(const void *p1, const void *p2);
static int DOTypeOidCompare(const void *p1, const void *p2);
static bool TopoSort(DumpableObject **objs, static bool TopoSort(DumpableObject **objs,
int numObjs, int numObjs,
DumpableObject **ordering, DumpableObject **ordering,
...@@ -67,27 +97,79 @@ static void describeDumpableObject(DumpableObject *obj, ...@@ -67,27 +97,79 @@ static void describeDumpableObject(DumpableObject *obj,
/* /*
* Sort the given objects into a type/OID-based ordering * Sort the given objects into a type/name-based ordering
* *
* Normally this is just the starting point for the dependency-based * Normally this is just the starting point for the dependency-based
* ordering. * ordering.
*/ */
void void
sortDumpableObjectsByType(DumpableObject **objs, int numObjs) sortDumpableObjectsByTypeName(DumpableObject **objs, int numObjs)
{
if (numObjs > 1)
qsort((void *) objs, numObjs, sizeof(DumpableObject *),
DOTypeNameCompare);
}
static int
DOTypeNameCompare(const void *p1, const void *p2)
{
DumpableObject *obj1 = *(DumpableObject **) p1;
DumpableObject *obj2 = *(DumpableObject **) p2;
int cmpval;
/* Sort by type */
cmpval = newObjectTypePriority[obj1->objType] -
newObjectTypePriority[obj2->objType];
if (cmpval != 0)
return cmpval;
/*
* Sort by namespace. Note that all objects of the same type should
* either have or not have a namespace link, so we needn't be fancy
* about cases where one link is null and the other not.
*/
if (obj1->namespace && obj2->namespace)
{
cmpval = strcmp(obj1->namespace->dobj.name,
obj2->namespace->dobj.name);
if (cmpval != 0)
return cmpval;
}
/* Sort by name */
cmpval = strcmp(obj1->name, obj2->name);
if (cmpval != 0)
return cmpval;
/* Probably shouldn't get here, but if we do, sort by OID */
return oidcmp(obj1->catId.oid, obj2->catId.oid);
}
/*
* Sort the given objects into a type/OID-based ordering
*
* This is used with pre-7.3 source databases as a crude substitute for the
* lack of dependency information.
*/
void
sortDumpableObjectsByTypeOid(DumpableObject **objs, int numObjs)
{ {
if (numObjs > 1) if (numObjs > 1)
qsort((void *) objs, numObjs, sizeof(DumpableObject *), DOTypeCompare); qsort((void *) objs, numObjs, sizeof(DumpableObject *),
DOTypeOidCompare);
} }
static int static int
DOTypeCompare(const void *p1, const void *p2) DOTypeOidCompare(const void *p1, const void *p2)
{ {
DumpableObject *obj1 = *(DumpableObject **) p1; DumpableObject *obj1 = *(DumpableObject **) p1;
DumpableObject *obj2 = *(DumpableObject **) p2; DumpableObject *obj2 = *(DumpableObject **) p2;
int cmpval; int cmpval;
cmpval = objectTypePriority[obj1->objType] - cmpval = oldObjectTypePriority[obj1->objType] -
objectTypePriority[obj2->objType]; oldObjectTypePriority[obj2->objType];
if (cmpval != 0) if (cmpval != 0)
return cmpval; return cmpval;
...@@ -839,93 +921,79 @@ describeDumpableObject(DumpableObject *obj, char *buf, int bufsize) ...@@ -839,93 +921,79 @@ describeDumpableObject(DumpableObject *obj, char *buf, int bufsize)
case DO_NAMESPACE: case DO_NAMESPACE:
snprintf(buf, bufsize, snprintf(buf, bufsize,
"SCHEMA %s (ID %d OID %u)", "SCHEMA %s (ID %d OID %u)",
((NamespaceInfo *) obj)->nspname, obj->name, obj->dumpId, obj->catId.oid);
obj->dumpId, obj->catId.oid);
return; return;
case DO_TYPE: case DO_TYPE:
snprintf(buf, bufsize, snprintf(buf, bufsize,
"TYPE %s (ID %d OID %u)", "TYPE %s (ID %d OID %u)",
((TypeInfo *) obj)->typname, obj->name, obj->dumpId, obj->catId.oid);
obj->dumpId, obj->catId.oid);
return; return;
case DO_FUNC: case DO_FUNC:
snprintf(buf, bufsize, snprintf(buf, bufsize,
"FUNCTION %s (ID %d OID %u)", "FUNCTION %s (ID %d OID %u)",
((FuncInfo *) obj)->proname, obj->name, obj->dumpId, obj->catId.oid);
obj->dumpId, obj->catId.oid);
return; return;
case DO_AGG: case DO_AGG:
snprintf(buf, bufsize, snprintf(buf, bufsize,
"AGGREGATE %s (ID %d OID %u)", "AGGREGATE %s (ID %d OID %u)",
((AggInfo *) obj)->aggfn.proname, obj->name, obj->dumpId, obj->catId.oid);
obj->dumpId, obj->catId.oid);
return; return;
case DO_OPERATOR: case DO_OPERATOR:
snprintf(buf, bufsize, snprintf(buf, bufsize,
"OPERATOR %s (ID %d OID %u)", "OPERATOR %s (ID %d OID %u)",
((OprInfo *) obj)->oprname, obj->name, obj->dumpId, obj->catId.oid);
obj->dumpId, obj->catId.oid);
return; return;
case DO_OPCLASS: case DO_OPCLASS:
snprintf(buf, bufsize, snprintf(buf, bufsize,
"OPERATOR CLASS %s (ID %d OID %u)", "OPERATOR CLASS %s (ID %d OID %u)",
((OpclassInfo *) obj)->opcname, obj->name, obj->dumpId, obj->catId.oid);
obj->dumpId, obj->catId.oid);
return; return;
case DO_CONVERSION: case DO_CONVERSION:
snprintf(buf, bufsize, snprintf(buf, bufsize,
"CONVERSION %s (ID %d OID %u)", "CONVERSION %s (ID %d OID %u)",
((ConvInfo *) obj)->conname, obj->name, obj->dumpId, obj->catId.oid);
obj->dumpId, obj->catId.oid);
return; return;
case DO_TABLE: case DO_TABLE:
snprintf(buf, bufsize, snprintf(buf, bufsize,
"TABLE %s (ID %d OID %u)", "TABLE %s (ID %d OID %u)",
((TableInfo *) obj)->relname, obj->name, obj->dumpId, obj->catId.oid);
obj->dumpId, obj->catId.oid);
return; return;
case DO_ATTRDEF: case DO_ATTRDEF:
snprintf(buf, bufsize, snprintf(buf, bufsize,
"ATTRDEF %s.%s (ID %d OID %u)", "ATTRDEF %s.%s (ID %d OID %u)",
((AttrDefInfo *) obj)->adtable->relname, ((AttrDefInfo *) obj)->adtable->dobj.name,
((AttrDefInfo *) obj)->adtable->attnames[((AttrDefInfo *) obj)->adnum - 1], ((AttrDefInfo *) obj)->adtable->attnames[((AttrDefInfo *) obj)->adnum - 1],
obj->dumpId, obj->catId.oid); obj->dumpId, obj->catId.oid);
return; return;
case DO_INDEX: case DO_INDEX:
snprintf(buf, bufsize, snprintf(buf, bufsize,
"INDEX %s (ID %d OID %u)", "INDEX %s (ID %d OID %u)",
((IndxInfo *) obj)->indexname, obj->name, obj->dumpId, obj->catId.oid);
obj->dumpId, obj->catId.oid);
return; return;
case DO_RULE: case DO_RULE:
snprintf(buf, bufsize, snprintf(buf, bufsize,
"RULE %s (ID %d OID %u)", "RULE %s (ID %d OID %u)",
((RuleInfo *) obj)->rulename, obj->name, obj->dumpId, obj->catId.oid);
obj->dumpId, obj->catId.oid);
return; return;
case DO_TRIGGER: case DO_TRIGGER:
snprintf(buf, bufsize, snprintf(buf, bufsize,
"TRIGGER %s (ID %d OID %u)", "TRIGGER %s (ID %d OID %u)",
((TriggerInfo *) obj)->tgname, obj->name, obj->dumpId, obj->catId.oid);
obj->dumpId, obj->catId.oid);
return; return;
case DO_CONSTRAINT: case DO_CONSTRAINT:
snprintf(buf, bufsize, snprintf(buf, bufsize,
"CONSTRAINT %s (ID %d OID %u)", "CONSTRAINT %s (ID %d OID %u)",
((ConstraintInfo *) obj)->conname, obj->name, obj->dumpId, obj->catId.oid);
obj->dumpId, obj->catId.oid);
return; return;
case DO_FK_CONSTRAINT: case DO_FK_CONSTRAINT:
snprintf(buf, bufsize, snprintf(buf, bufsize,
"FK CONSTRAINT %s (ID %d OID %u)", "FK CONSTRAINT %s (ID %d OID %u)",
((ConstraintInfo *) obj)->conname, obj->name, obj->dumpId, obj->catId.oid);
obj->dumpId, obj->catId.oid);
return; return;
case DO_PROCLANG: case DO_PROCLANG:
snprintf(buf, bufsize, snprintf(buf, bufsize,
"PROCEDURAL LANGUAGE %s (ID %d OID %u)", "PROCEDURAL LANGUAGE %s (ID %d OID %u)",
((ProcLangInfo *) obj)->lanname, obj->name, obj->dumpId, obj->catId.oid);
obj->dumpId, obj->catId.oid);
return; return;
case DO_CAST: case DO_CAST:
snprintf(buf, bufsize, snprintf(buf, bufsize,
...@@ -937,8 +1005,17 @@ describeDumpableObject(DumpableObject *obj, char *buf, int bufsize) ...@@ -937,8 +1005,17 @@ describeDumpableObject(DumpableObject *obj, char *buf, int bufsize)
case DO_TABLE_DATA: case DO_TABLE_DATA:
snprintf(buf, bufsize, snprintf(buf, bufsize,
"TABLE DATA %s (ID %d OID %u)", "TABLE DATA %s (ID %d OID %u)",
((TableDataInfo *) obj)->tdtable->relname, obj->name, obj->dumpId, obj->catId.oid);
obj->dumpId, obj->catId.oid); return;
case DO_TABLE_TYPE:
snprintf(buf, bufsize,
"TABLE TYPE %s (ID %d OID %u)",
obj->name, obj->dumpId, obj->catId.oid);
return;
case DO_BLOBS:
snprintf(buf, bufsize,
"BLOBS (ID %d)",
obj->dumpId);
return; return;
} }
/* shouldn't get here */ /* shouldn't get here */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment