* by PostgreSQL
*
* 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 $
*
*-------------------------------------------------------------------------
*/
if (!schemaOnly)
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.
*/
/*
* 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);
- sortDumpableObjectsByType(dobjs, numObjs);
+ if (g_fout->remoteVersion >= 70300)
+ sortDumpableObjectsByTypeName(dobjs, numObjs);
+ else
+ sortDumpableObjectsByTypeOid(dobjs, numObjs);
+
sortDumpableObjects(dobjs, numObjs);
/*
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.
*/
nsinfo->dump = false;
else if (selectSchemaName != NULL)
{
- if (strcmp(nsinfo->nspname, selectSchemaName) == 0)
+ if (strcmp(nsinfo->dobj.name, selectSchemaName) == 0)
nsinfo->dump = true;
else
nsinfo->dump = false;
}
- else if (strncmp(nsinfo->nspname, "pg_", 3) == 0 ||
- strcmp(nsinfo->nspname, "information_schema") == 0)
+ else if (strncmp(nsinfo->dobj.name, "pg_", 3) == 0 ||
+ strcmp(nsinfo->dobj.name, "information_schema") == 0)
nsinfo->dump = false;
else
nsinfo->dump = true;
* not dump.
*/
tbinfo->dump = false;
- if (tbinfo->relnamespace->dump)
+ if (tbinfo->dobj.namespace->dump)
tbinfo->dump = true;
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 (selectSchemaName == NULL)
tbinfo->dump = true;
- else if (strcmp(tbinfo->relnamespace->nspname, selectSchemaName) == 0)
+ else if (strcmp(tbinfo->dobj.namespace->dobj.name, selectSchemaName) == 0)
tbinfo->dump = true;
}
}
{
TableDataInfo *tdinfo = (TableDataInfo *) dcontext;
TableInfo *tbinfo = tdinfo->tdtable;
- const char *classname = tbinfo->relname;
+ const char *classname = tbinfo->dobj.name;
const bool hasoids = tbinfo->hasoids;
const bool oids = tdinfo->oids;
PQExpBuffer q = createPQExpBuffer();
* but this ensures reproducible results in case the table contains
* 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 (oids && hasoids)
{
appendPQExpBuffer(q, "COPY %s %s WITH OIDS TO stdout;",
- fmtQualifiedId(tbinfo->relnamespace->nspname,
+ fmtQualifiedId(tbinfo->dobj.namespace->dobj.name,
classname),
column_list);
}
else
{
appendPQExpBuffer(q, "COPY %s %s TO stdout;",
- fmtQualifiedId(tbinfo->relnamespace->nspname,
+ fmtQualifiedId(tbinfo->dobj.namespace->dobj.name,
classname),
column_list);
}
{
TableDataInfo *tdinfo = (TableDataInfo *) dcontext;
TableInfo *tbinfo = tdinfo->tdtable;
- const char *classname = tbinfo->relname;
+ const char *classname = tbinfo->dobj.name;
PQExpBuffer q = createPQExpBuffer();
PGresult *res;
int tuple;
* but this ensures reproducible results in case the table contains
* regproc, regclass, etc columns.
*/
- selectSourceSchema(tbinfo->relnamespace->nspname);
+ selectSourceSchema(tbinfo->dobj.namespace->dobj.name);
if (fout->remoteVersion >= 70100)
{
appendPQExpBuffer(q, "DECLARE _pg_dump_cursor CURSOR FOR "
"SELECT * FROM ONLY %s",
- fmtQualifiedId(tbinfo->relnamespace->nspname,
+ fmtQualifiedId(tbinfo->dobj.namespace->dobj.name,
classname));
}
else
{
appendPQExpBuffer(q, "DECLARE _pg_dump_cursor CURSOR FOR "
"SELECT * FROM %s",
- fmtQualifiedId(tbinfo->relnamespace->nspname,
+ fmtQualifiedId(tbinfo->dobj.namespace->dobj.name,
classname));
}
dumpFn = dumpTableData_copy;
/* must use 2 steps here 'cause fmtId is nonreentrant */
appendPQExpBuffer(copyBuf, "COPY %s ",
- fmtId(tbinfo->relname));
+ fmtId(tbinfo->dobj.name));
appendPQExpBuffer(copyBuf, "%s %sFROM stdin;\n",
fmtCopyColumnList(tbinfo),
(tdinfo->oids && tbinfo->hasoids) ? "WITH OIDS " : "");
}
ArchiveEntry(fout, tdinfo->dobj.catId, tdinfo->dobj.dumpId,
- tbinfo->relname,
- tbinfo->relnamespace->nspname,
+ tbinfo->dobj.name,
+ tbinfo->dobj.namespace->dobj.name,
tbinfo->usename,
"TABLE DATA", "", "", copyStmt,
tdinfo->dobj.dependencies, tdinfo->dobj.nDeps,
tdinfo->dobj.catId.tableoid = 0;
tdinfo->dobj.catId.oid = tblinfo[i].dobj.catId.oid;
AssignDumpId(&tdinfo->dobj);
+ tdinfo->dobj.name = tblinfo[i].dobj.name;
+ tdinfo->dobj.namespace = tblinfo[i].dobj.namespace;
tdinfo->tdtable = &(tblinfo[i]);
tdinfo->oids = oids;
addObjectDependency(&tdinfo->dobj, tblinfo[i].dobj.dumpId);
nsinfo[0].dobj.catId.tableoid = 0;
nsinfo[0].dobj.catId.oid = 0;
AssignDumpId(&nsinfo[0].dobj);
- nsinfo[0].nspname = strdup("");
+ nsinfo[0].dobj.name = strdup("");
nsinfo[0].usename = strdup("");
nsinfo[0].nspacl = strdup("");
nsinfo[1].dobj.catId.tableoid = 0;
nsinfo[1].dobj.catId.oid = 1;
AssignDumpId(&nsinfo[1].dobj);
- nsinfo[1].nspname = strdup("pg_catalog");
+ nsinfo[1].dobj.name = strdup("pg_catalog");
nsinfo[1].usename = strdup("");
nsinfo[1].nspacl = strdup("");
nsinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid));
nsinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid));
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].nspacl = strdup(PQgetvalue(res, i, i_nspacl));
if (strlen(nsinfo[i].usename) == 0)
write_msg(NULL, "WARNING: owner of schema \"%s\" appears to be invalid\n",
- nsinfo[i].nspname);
+ nsinfo[i].dobj.name);
}
/*
if (selectSchemaName)
{
for (i = 0; i < ntups; i++)
- if (strcmp(nsinfo[i].nspname, selectSchemaName) == 0)
+ if (strcmp(nsinfo[i].dobj.name, selectSchemaName) == 0)
break;
/* Didn't find a match */
tinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid));
tinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid));
AssignDumpId(&tinfo[i].dobj);
- tinfo[i].typname = strdup(PQgetvalue(res, i, i_typname));
- tinfo[i].typnamespace = findNamespace(atooid(PQgetvalue(res, i, i_typnamespace)),
+ tinfo[i].dobj.name = strdup(PQgetvalue(res, i, i_typname));
+ tinfo[i].dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_typnamespace)),
tinfo[i].dobj.catId.oid);
tinfo[i].usename = strdup(PQgetvalue(res, i, i_usename));
tinfo[i].typinput = atooid(PQgetvalue(res, i, i_typinput));
tinfo[i].typrelkind = *PQgetvalue(res, i, i_typrelkind);
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
*/
if (OidIsValid(tinfo[i].typelem) &&
- tinfo[i].typname[0] != '_')
+ tinfo[i].dobj.name[0] != '_')
tinfo[i].isArray = true;
else
tinfo[i].isArray = false;
if (strlen(tinfo[i].usename) == 0 && tinfo[i].isDefined)
write_msg(NULL, "WARNING: owner of data type \"%s\" appears to be invalid\n",
- tinfo[i].typname);
+ tinfo[i].dobj.name);
}
*numTypes = ntups;
oprinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid));
oprinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid));
AssignDumpId(&oprinfo[i].dobj);
- oprinfo[i].oprname = strdup(PQgetvalue(res, i, i_oprname));
- oprinfo[i].oprnamespace = findNamespace(atooid(PQgetvalue(res, i, i_oprnamespace)),
+ oprinfo[i].dobj.name = strdup(PQgetvalue(res, i, i_oprname));
+ oprinfo[i].dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_oprnamespace)),
oprinfo[i].dobj.catId.oid);
oprinfo[i].usename = strdup(PQgetvalue(res, i, i_usename));
oprinfo[i].oprcode = atooid(PQgetvalue(res, i, i_oprcode));
if (strlen(oprinfo[i].usename) == 0)
write_msg(NULL, "WARNING: owner of operator \"%s\" appears to be invalid\n",
- oprinfo[i].oprname);
+ oprinfo[i].dobj.name);
}
PQclear(res);
convinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid));
convinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid));
AssignDumpId(&convinfo[i].dobj);
- convinfo[i].conname = strdup(PQgetvalue(res, i, i_conname));
- convinfo[i].connamespace = findNamespace(atooid(PQgetvalue(res, i, i_connamespace)),
+ convinfo[i].dobj.name = strdup(PQgetvalue(res, i, i_conname));
+ convinfo[i].dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_connamespace)),
convinfo[i].dobj.catId.oid);
convinfo[i].usename = strdup(PQgetvalue(res, i, i_usename));
}
opcinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid));
opcinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid));
AssignDumpId(&opcinfo[i].dobj);
- opcinfo[i].opcname = strdup(PQgetvalue(res, i, i_opcname));
- opcinfo[i].opcnamespace = findNamespace(atooid(PQgetvalue(res, i, i_opcnamespace)),
+ opcinfo[i].dobj.name = strdup(PQgetvalue(res, i, i_opcname));
+ opcinfo[i].dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_opcnamespace)),
opcinfo[i].dobj.catId.oid);
opcinfo[i].usename = strdup(PQgetvalue(res, i, i_usename));
{
if (strlen(opcinfo[i].usename) == 0)
write_msg(NULL, "WARNING: owner of operator class \"%s\" appears to be invalid\n",
- opcinfo[i].opcname);
+ opcinfo[i].dobj.name);
}
}
agginfo[i].aggfn.dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid));
agginfo[i].aggfn.dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid));
AssignDumpId(&agginfo[i].aggfn.dobj);
- agginfo[i].aggfn.proname = strdup(PQgetvalue(res, i, i_aggname));
- agginfo[i].aggfn.pronamespace = findNamespace(atooid(PQgetvalue(res, i, i_aggnamespace)),
+ agginfo[i].aggfn.dobj.name = strdup(PQgetvalue(res, i, i_aggname));
+ agginfo[i].aggfn.dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_aggnamespace)),
agginfo[i].aggfn.dobj.catId.oid);
agginfo[i].aggfn.usename = strdup(PQgetvalue(res, i, i_usename));
if (strlen(agginfo[i].aggfn.usename) == 0)
write_msg(NULL, "WARNING: owner of aggregate function \"%s\" appears to be invalid\n",
- agginfo[i].aggfn.proname);
+ agginfo[i].aggfn.dobj.name);
agginfo[i].aggfn.lang = InvalidOid; /* not currently interesting */
agginfo[i].aggfn.nargs = 1;
agginfo[i].aggfn.argtypes = (Oid *) malloc(sizeof(Oid));
finfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid));
finfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid));
AssignDumpId(&finfo[i].dobj);
- finfo[i].proname = strdup(PQgetvalue(res, i, i_proname));
- finfo[i].pronamespace = findNamespace(atooid(PQgetvalue(res, i, i_pronamespace)),
+ finfo[i].dobj.name = strdup(PQgetvalue(res, i, i_proname));
+ finfo[i].dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_pronamespace)),
finfo[i].dobj.catId.oid);
finfo[i].usename = strdup(PQgetvalue(res, i, i_usename));
finfo[i].lang = atooid(PQgetvalue(res, i, i_prolang));
if (strlen(finfo[i].usename) == 0)
write_msg(NULL, "WARNING: owner of function \"%s\" appears to be invalid\n",
- finfo[i].proname);
+ finfo[i].dobj.name);
}
PQclear(res);
tblinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_reltableoid));
tblinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_reloid));
AssignDumpId(&tblinfo[i].dobj);
- tblinfo[i].relname = strdup(PQgetvalue(res, i, i_relname));
- tblinfo[i].relnamespace = findNamespace(atooid(PQgetvalue(res, i, i_relnamespace)),
+ tblinfo[i].dobj.name = strdup(PQgetvalue(res, i, i_relname));
+ tblinfo[i].dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_relnamespace)),
tblinfo[i].dobj.catId.oid);
tblinfo[i].usename = strdup(PQgetvalue(res, i, i_usename));
tblinfo[i].relacl = strdup(PQgetvalue(res, i, i_relacl));
resetPQExpBuffer(lockquery);
appendPQExpBuffer(lockquery,
"LOCK TABLE %s IN ACCESS SHARE MODE",
- fmtQualifiedId(tblinfo[i].relnamespace->nspname,
- tblinfo[i].relname));
+ fmtQualifiedId(tblinfo[i].dobj.namespace->dobj.name,
+ tblinfo[i].dobj.name));
do_sql_command(g_conn, lockquery->data);
}
/* Emit notice if join for owner failed */
if (strlen(tblinfo[i].usename) == 0)
write_msg(NULL, "WARNING: owner of table \"%s\" appears to be invalid\n",
- tblinfo[i].relname);
+ tblinfo[i].dobj.name);
}
/*
if (selectTableName)
{
for (i = 0; i < ntups; i++)
- if (strcmp(tblinfo[i].relname, selectTableName) == 0)
+ if (strcmp(tblinfo[i].dobj.name, selectTableName) == 0)
break;
/* Didn't find a match */
if (g_verbose)
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 */
- selectSourceSchema(tbinfo->relnamespace->nspname);
+ selectSourceSchema(tbinfo->dobj.namespace->dobj.name);
/*
* The point of the messy-looking outer join is to find a
indxinfo[j].dobj.catId.tableoid = atooid(PQgetvalue(res, j, i_tableoid));
indxinfo[j].dobj.catId.oid = atooid(PQgetvalue(res, j, i_oid));
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].indexdef = strdup(PQgetvalue(res, j, i_indexdef));
indxinfo[j].indnkeys = atoi(PQgetvalue(res, j, i_indnkeys));
constrinfo[j].dobj.catId.tableoid = atooid(PQgetvalue(res, j, i_contableoid));
constrinfo[j].dobj.catId.oid = atooid(PQgetvalue(res, j, i_conoid));
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].condomain = NULL;
constrinfo[j].contype = contype;
if (g_verbose)
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
* needed
*/
- selectSourceSchema(tbinfo->relnamespace->nspname);
+ selectSourceSchema(tbinfo->dobj.namespace->dobj.name);
resetPQExpBuffer(query);
appendPQExpBuffer(query,
constrinfo[j].dobj.catId.tableoid = atooid(PQgetvalue(res, j, i_contableoid));
constrinfo[j].dobj.catId.oid = atooid(PQgetvalue(res, j, i_conoid));
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].condomain = NULL;
constrinfo[j].contype = 'f';
* select appropriate schema to ensure names in constraint are properly
* qualified
*/
- selectSourceSchema(tinfo->typnamespace->nspname);
+ selectSourceSchema(tinfo->dobj.namespace->dobj.name);
query = createPQExpBuffer();
constrinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid));
constrinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid));
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].condomain = tinfo;
constrinfo[i].contype = 'c';
ruleinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid));
ruleinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid));
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));
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].is_instead = *(PQgetvalue(res, i, i_is_instead)) == 't';
if (ruleinfo[i].ruletable)
if (g_verbose)
write_msg(NULL, "reading triggers for table \"%s\"\n",
- tbinfo->relname);
+ tbinfo->dobj.name);
/*
* select table schema to ensure regproc name is qualified if
* needed
*/
- selectSourceSchema(tbinfo->relnamespace->nspname);
+ selectSourceSchema(tbinfo->dobj.namespace->dobj.name);
resetPQExpBuffer(query);
if (g_fout->remoteVersion >= 70300)
if (ntups > tbinfo->ntrig)
{
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();
}
i_tableoid = PQfnumber(res, "tableoid");
tginfo[j].dobj.catId.tableoid = atooid(PQgetvalue(res, j, i_tableoid));
tginfo[j].dobj.catId.oid = atooid(PQgetvalue(res, j, i_oid));
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].tgname = strdup(PQgetvalue(res, j, i_tgname));
tginfo[j].tgfname = strdup(PQgetvalue(res, j, i_tgfname));
tginfo[j].tgtype = atoi(PQgetvalue(res, j, i_tgtype));
tginfo[j].tgnargs = atoi(PQgetvalue(res, j, i_tgnargs));
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",
- tginfo[j].tgname, tbinfo->relname,
+ tginfo[j].dobj.name, tbinfo->dobj.name,
tginfo[j].tgconstrrelid);
exit_nicely();
}
planginfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid));
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].lanplcallfoid = atooid(PQgetvalue(res, i, i_lanplcallfoid));
if (g_fout->remoteVersion >= 70300)
for (i = 0; i < ntups; i++)
{
+ PQExpBufferData namebuf;
+ TypeInfo *sTypeInfo;
+ TypeInfo *tTypeInfo;
+
castinfo[i].dobj.objType = DO_CAST;
castinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid));
castinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid));
castinfo[i].castfunc = atooid(PQgetvalue(res, i, i_castfunc));
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))
{
/*
* Make sure we are in proper schema for this table; this allows
* 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 */
*/
if (g_verbose)
write_msg(NULL, "finding the columns and types of table \"%s\"\n",
- tbinfo->relname);
+ tbinfo->dobj.name);
resetPQExpBuffer(q);
if (j + 1 != atoi(PQgetvalue(res, j, i_attnum)))
{
write_msg(NULL, "invalid column numbering in table \"%s\"\n",
- tbinfo->relname);
+ tbinfo->dobj.name);
exit_nicely();
}
tbinfo->attnames[j] = strdup(PQgetvalue(res, j, i_attname));
if (g_verbose)
write_msg(NULL, "finding default expressions of table \"%s\"\n",
- tbinfo->relname);
+ tbinfo->dobj.name);
resetPQExpBuffer(q);
if (g_fout->remoteVersion >= 70300)
attrdefs[j].adnum = adnum = atoi(PQgetvalue(res, j, 2));
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
* ALTER TABLE commands. Defaults on regular tables are
if (adnum <= 0 || adnum > ntups)
{
write_msg(NULL, "invalid adnum value %d for table \"%s\"\n",
- adnum, tbinfo->relname);
+ adnum, tbinfo->dobj.name);
exit_nicely();
}
tbinfo->attrdefs[adnum - 1] = &attrdefs[j];
if (g_verbose)
write_msg(NULL, "finding check constraints for table \"%s\"\n",
- tbinfo->relname);
+ tbinfo->dobj.name);
resetPQExpBuffer(q);
if (g_fout->remoteVersion >= 70400)
if (numConstrs != tbinfo->ncheck)
{
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");
exit_nicely();
}
constrs[j].dobj.catId.tableoid = atooid(PQgetvalue(res, j, 0));
constrs[j].dobj.catId.oid = atooid(PQgetvalue(res, j, 1));
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].condomain = NULL;
constrs[j].contype = 'c';
- constrs[j].conname = strdup(PQgetvalue(res, j, 2));
constrs[j].condef = strdup(PQgetvalue(res, j, 3));
constrs[j].conindex = 0;
constrs[j].coninherited = false;
{
resetPQExpBuffer(target);
appendPQExpBuffer(target, "%s %s", reltypename,
- fmtId(tbinfo->relname));
+ fmtId(tbinfo->dobj.name));
resetPQExpBuffer(query);
appendPQExpBuffer(query, "COMMENT ON %s IS ", target->data);
ArchiveEntry(fout, nilCatalogId, createDumpId(),
target->data,
- tbinfo->relnamespace->nspname, tbinfo->usename,
+ tbinfo->dobj.namespace->dobj.name, tbinfo->usename,
"COMMENT", query->data, "", NULL,
&(tbinfo->dobj.dumpId), 1,
NULL, NULL);
{
resetPQExpBuffer(target);
appendPQExpBuffer(target, "COLUMN %s.",
- fmtId(tbinfo->relname));
+ fmtId(tbinfo->dobj.name));
appendPQExpBuffer(target, "%s",
fmtId(tbinfo->attnames[objsubid - 1]));
ArchiveEntry(fout, nilCatalogId, createDumpId(),
target->data,
- tbinfo->relnamespace->nspname, tbinfo->usename,
+ tbinfo->dobj.namespace->dobj.name, tbinfo->usename,
"COMMENT", query->data, "", NULL,
&(tbinfo->dobj.dumpId), 1,
NULL, NULL);
case DO_TABLE_DATA:
dumpTableData(fout, (TableDataInfo *) dobj);
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;
}
}
return;
/* don't dump dummy namespace from pre-7.3 source */
- if (strlen(nspinfo->nspname) == 0)
+ if (strlen(nspinfo->dobj.name) == 0)
return;
q = 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
* users without CREATE SCHEMA privilege. Further hacking has
* 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);
qnspname, fmtId(nspinfo->usename));
ArchiveEntry(fout, nspinfo->dobj.catId, nspinfo->dobj.dumpId,
- nspinfo->nspname,
+ nspinfo->dobj.name,
NULL, "",
"SCHEMA", q->data, delq->data, NULL,
nspinfo->dobj.dependencies, nspinfo->dobj.nDeps,
nspinfo->dobj.catId, 0, nspinfo->dobj.dumpId);
dumpACL(fout, nspinfo->dobj.catId, nspinfo->dobj.dumpId, "SCHEMA",
- qnspname, nspinfo->nspname, NULL,
+ qnspname, nspinfo->dobj.name, NULL,
nspinfo->usename, nspinfo->nspacl);
free(qnspname);
dumpType(Archive *fout, TypeInfo *tinfo)
{
/* Dump only types in dumpable namespaces */
- if (!tinfo->typnamespace->dump || dataOnly)
+ if (!tinfo->dobj.namespace->dump || dataOnly)
return;
/* skip complex types, except for standalone composite types */
+ /* (note: this test should now be unnecessary) */
if (OidIsValid(tinfo->typrelid) && tinfo->typrelkind != 'c')
return;
return;
/* skip all array types that start w/ underscore */
- if ((tinfo->typname[0] == '_') &&
+ if ((tinfo->dobj.name[0] == '_') &&
OidIsValid(tinfo->typelem))
return;
char *typstorage;
/* Set proper schema search path so regproc references list correctly */
- selectSourceSchema(tinfo->typnamespace->nspname);
+ selectSourceSchema(tinfo->dobj.namespace->dobj.name);
/* Fetch type-specific details */
if (fout->remoteVersion >= 70500)
* pg_catalog
*/
appendPQExpBuffer(delq, "DROP TYPE %s.",
- fmtId(tinfo->typnamespace->nspname));
+ fmtId(tinfo->dobj.namespace->dobj.name));
appendPQExpBuffer(delq, "%s CASCADE;\n",
- fmtId(tinfo->typname));
+ fmtId(tinfo->dobj.name));
appendPQExpBuffer(q,
"CREATE TYPE %s (\n"
" INTERNALLENGTH = %s",
- fmtId(tinfo->typname),
+ fmtId(tinfo->dobj.name),
(strcmp(typlen, "-1") == 0) ? "variable" : typlen);
if (fout->remoteVersion >= 70300)
char *elemType;
/* reselect schema in case changed by function dump */
- selectSourceSchema(tinfo->typnamespace->nspname);
+ selectSourceSchema(tinfo->dobj.namespace->dobj.name);
elemType = getFormattedTypeName(tinfo->typelem, zeroAsOpaque);
appendPQExpBuffer(q, ",\n ELEMENT = %s", elemType);
free(elemType);
appendPQExpBuffer(q, "\n);\n");
ArchiveEntry(fout, tinfo->dobj.catId, tinfo->dobj.dumpId,
- tinfo->typname,
- tinfo->typnamespace->nspname,
+ tinfo->dobj.name,
+ tinfo->dobj.namespace->dobj.name,
tinfo->usename,
"TYPE", q->data, delq->data, NULL,
tinfo->dobj.dependencies, tinfo->dobj.nDeps,
/* Dump Type Comments */
resetPQExpBuffer(q);
- appendPQExpBuffer(q, "TYPE %s", fmtId(tinfo->typname));
+ appendPQExpBuffer(q, "TYPE %s", fmtId(tinfo->dobj.name));
dumpComment(fout, q->data,
- tinfo->typnamespace->nspname, tinfo->usename,
+ tinfo->dobj.namespace->dobj.name, tinfo->usename,
tinfo->dobj.catId, 0, tinfo->dobj.dumpId);
PQclear(res);
char *typdefault;
/* Set proper schema search path so type references list correctly */
- selectSourceSchema(tinfo->typnamespace->nspname);
+ selectSourceSchema(tinfo->dobj.namespace->dobj.name);
/* Fetch domain specific details */
/* We assume here that remoteVersion must be at least 70300 */
appendPQExpBuffer(q,
"CREATE DOMAIN %s AS %s",
- fmtId(tinfo->typname),
+ fmtId(tinfo->dobj.name),
typdefn);
if (typnotnull[0] == 't')
if (!domcheck->separate)
appendPQExpBuffer(q, "\n\tCONSTRAINT %s %s",
- fmtId(domcheck->conname), domcheck->condef);
+ fmtId(domcheck->dobj.name), domcheck->condef);
}
appendPQExpBuffer(q, ";\n");
* pg_catalog
*/
appendPQExpBuffer(delq, "DROP DOMAIN %s.",
- fmtId(tinfo->typnamespace->nspname));
+ fmtId(tinfo->dobj.namespace->dobj.name));
appendPQExpBuffer(delq, "%s;\n",
- fmtId(tinfo->typname));
+ fmtId(tinfo->dobj.name));
ArchiveEntry(fout, tinfo->dobj.catId, tinfo->dobj.dumpId,
- tinfo->typname,
- tinfo->typnamespace->nspname,
+ tinfo->dobj.name,
+ tinfo->dobj.namespace->dobj.name,
tinfo->usename,
"DOMAIN", q->data, delq->data, NULL,
tinfo->dobj.dependencies, tinfo->dobj.nDeps,
/* Dump Domain Comments */
resetPQExpBuffer(q);
- appendPQExpBuffer(q, "DOMAIN %s", fmtId(tinfo->typname));
+ appendPQExpBuffer(q, "DOMAIN %s", fmtId(tinfo->dobj.name));
dumpComment(fout, q->data,
- tinfo->typnamespace->nspname, tinfo->usename,
+ tinfo->dobj.namespace->dobj.name, tinfo->usename,
tinfo->dobj.catId, 0, tinfo->dobj.dumpId);
destroyPQExpBuffer(q);
int i;
/* Set proper schema search path so type references list correctly */
- selectSourceSchema(tinfo->typnamespace->nspname);
+ selectSourceSchema(tinfo->dobj.namespace->dobj.name);
/* Fetch type specific details */
/* We assume here that remoteVersion must be at least 70300 */
i_atttypdefn = PQfnumber(res, "atttypdefn");
appendPQExpBuffer(q, "CREATE TYPE %s AS (",
- fmtId(tinfo->typname));
+ fmtId(tinfo->dobj.name));
for (i = 0; i < ntups; i++)
{
* pg_catalog
*/
appendPQExpBuffer(delq, "DROP TYPE %s.",
- fmtId(tinfo->typnamespace->nspname));
+ fmtId(tinfo->dobj.namespace->dobj.name));
appendPQExpBuffer(delq, "%s;\n",
- fmtId(tinfo->typname));
+ fmtId(tinfo->dobj.name));
ArchiveEntry(fout, tinfo->dobj.catId, tinfo->dobj.dumpId,
- tinfo->typname,
- tinfo->typnamespace->nspname,
+ tinfo->dobj.name,
+ tinfo->dobj.namespace->dobj.name,
tinfo->usename,
"TYPE", q->data, delq->data, NULL,
tinfo->dobj.dependencies, tinfo->dobj.nDeps,
/* Dump Type Comments */
resetPQExpBuffer(q);
- appendPQExpBuffer(q, "TYPE %s", fmtId(tinfo->typname));
+ appendPQExpBuffer(q, "TYPE %s", fmtId(tinfo->dobj.name));
dumpComment(fout, q->data,
- tinfo->typnamespace->nspname, tinfo->usename,
+ tinfo->dobj.namespace->dobj.name, tinfo->usename,
tinfo->dobj.catId, 0, tinfo->dobj.dumpId);
PQclear(res);
if (funcInfo == NULL)
return;
- if (!funcInfo->pronamespace->dump)
+ if (!funcInfo->dobj.namespace->dump)
return;
if (OidIsValid(plang->lanvalidator))
defqry = createPQExpBuffer();
delqry = createPQExpBuffer();
- qlanname = strdup(fmtId(plang->lanname));
+ qlanname = strdup(fmtId(plang->dobj.name));
appendPQExpBuffer(delqry, "DROP PROCEDURAL LANGUAGE %s;\n",
qlanname);
plang->lanpltrusted ? "TRUSTED " : "",
qlanname);
appendPQExpBuffer(defqry, " HANDLER %s",
- fmtId(funcInfo->proname));
+ fmtId(funcInfo->dobj.name));
if (OidIsValid(plang->lanvalidator))
{
appendPQExpBuffer(defqry, " VALIDATOR ");
/* Cope with possibility that validator is in different schema */
- if (validatorInfo->pronamespace != funcInfo->pronamespace)
+ if (validatorInfo->dobj.namespace != funcInfo->dobj.namespace)
appendPQExpBuffer(defqry, "%s.",
- fmtId(validatorInfo->pronamespace->nspname));
+ fmtId(validatorInfo->dobj.namespace->dobj.name));
appendPQExpBuffer(defqry, "%s",
- fmtId(validatorInfo->proname));
+ fmtId(validatorInfo->dobj.name));
}
appendPQExpBuffer(defqry, ";\n");
ArchiveEntry(fout, plang->dobj.catId, plang->dobj.dumpId,
- plang->lanname,
- funcInfo->pronamespace->nspname, "",
+ plang->dobj.name,
+ funcInfo->dobj.namespace->dobj.name, "",
"PROCEDURAL LANGUAGE",
defqry->data, delqry->data, NULL,
plang->dobj.dependencies, plang->dobj.nDeps,
if (plang->lanpltrusted)
dumpACL(fout, plang->dobj.catId, plang->dobj.dumpId, "LANGUAGE",
- qlanname, plang->lanname,
- funcInfo->pronamespace->nspname,
+ qlanname, plang->dobj.name,
+ funcInfo->dobj.namespace->dobj.name,
NULL, plang->lanacl);
free(qlanname);
initPQExpBuffer(&fn);
if (honor_quotes)
- appendPQExpBuffer(&fn, "%s(", fmtId(finfo->proname));
+ appendPQExpBuffer(&fn, "%s(", fmtId(finfo->dobj.name));
else
- appendPQExpBuffer(&fn, "%s(", finfo->proname);
+ appendPQExpBuffer(&fn, "%s(", finfo->dobj.name);
for (j = 0; j < finfo->nargs; j++)
{
char *typname;
char **argnamearray = NULL;
/* Dump only funcs in dumpable namespaces */
- if (!finfo->pronamespace->dump || dataOnly)
+ if (!finfo->dobj.namespace->dump || dataOnly)
return;
query = createPQExpBuffer();
asPart = createPQExpBuffer();
/* Set proper schema search path so type references list correctly */
- selectSourceSchema(finfo->pronamespace->nspname);
+ selectSourceSchema(finfo->dobj.namespace->dobj.name);
/* Fetch function-specific details */
if (g_fout->remoteVersion >= 70500)
* pg_catalog
*/
appendPQExpBuffer(delqry, "DROP FUNCTION %s.%s;\n",
- fmtId(finfo->pronamespace->nspname),
+ fmtId(finfo->dobj.namespace->dobj.name),
funcsig);
rettypename = getFormattedTypeName(finfo->prorettype, zeroAsOpaque);
else if (provolatile[0] != PROVOLATILE_VOLATILE)
{
write_msg(NULL, "unrecognized provolatile value for function \"%s\"\n",
- finfo->proname);
+ finfo->dobj.name);
exit_nicely();
}
}
ArchiveEntry(fout, finfo->dobj.catId, finfo->dobj.dumpId,
funcsig_tag,
- finfo->pronamespace->nspname,
+ finfo->dobj.namespace->dobj.name,
finfo->usename,
"FUNCTION", q->data, delqry->data, NULL,
finfo->dobj.dependencies, finfo->dobj.nDeps,
resetPQExpBuffer(q);
appendPQExpBuffer(q, "FUNCTION %s", funcsig);
dumpComment(fout, q->data,
- finfo->pronamespace->nspname, finfo->usename,
+ finfo->dobj.namespace->dobj.name, finfo->usename,
finfo->dobj.catId, 0, finfo->dobj.dumpId);
dumpACL(fout, finfo->dobj.catId, finfo->dobj.dumpId, "FUNCTION",
funcsig, funcsig_tag,
- finfo->pronamespace->nspname,
+ finfo->dobj.namespace->dobj.name,
finfo->usename, finfo->proacl);
PQclear(res);
/*
* Skip this cast if all objects are from pg_
*/
- if ((funcInfo == NULL || strncmp(funcInfo->pronamespace->nspname, "pg_", 3) == 0) &&
- strncmp(sourceInfo->typnamespace->nspname, "pg_", 3) == 0 &&
- strncmp(targetInfo->typnamespace->nspname, "pg_", 3) == 0)
+ if ((funcInfo == NULL ||
+ strncmp(funcInfo->dobj.namespace->dobj.name, "pg_", 3) == 0) &&
+ strncmp(sourceInfo->dobj.namespace->dobj.name, "pg_", 3) == 0 &&
+ strncmp(targetInfo->dobj.namespace->dobj.name, "pg_", 3) == 0)
return;
/*
* not dumped.
*/
if (funcInfo &&
- strncmp(funcInfo->pronamespace->nspname, "pg_", 3) != 0 &&
- !funcInfo->pronamespace->dump)
+ strncmp(funcInfo->dobj.namespace->dobj.name, "pg_", 3) != 0 &&
+ !funcInfo->dobj.namespace->dump)
return;
/*
* Same for the Source type
*/
- if (strncmp(sourceInfo->typnamespace->nspname, "pg_", 3) != 0 &&
- !sourceInfo->typnamespace->dump)
+ if (strncmp(sourceInfo->dobj.namespace->dobj.name, "pg_", 3) != 0 &&
+ !sourceInfo->dobj.namespace->dump)
return;
/*
* and the target type.
*/
- if (strncmp(targetInfo->typnamespace->nspname, "pg_", 3) != 0 &&
- !targetInfo->typnamespace->dump)
+ if (strncmp(targetInfo->dobj.namespace->dobj.name, "pg_", 3) != 0 &&
+ !targetInfo->dobj.namespace->dump)
return;
/* Make sure we are in proper schema (needed for getFormattedTypeName) */
* schema (format_function_signature won't qualify it).
*/
appendPQExpBuffer(defqry, "WITH FUNCTION %s.",
- fmtId(funcInfo->pronamespace->nspname));
+ fmtId(funcInfo->dobj.namespace->dobj.name));
appendPQExpBuffer(defqry, "%s",
format_function_signature(funcInfo, NULL, true));
}
ArchiveEntry(fout, cast->dobj.catId, cast->dobj.dumpId,
castsig->data,
- sourceInfo->typnamespace->nspname, "",
+ "pg_catalog", "",
"CAST", defqry->data, delqry->data, NULL,
cast->dobj.dependencies, cast->dobj.nDeps,
NULL, NULL);
char *oprgtcmpop;
/* Dump only operators in dumpable namespaces */
- if (!oprinfo->oprnamespace->dump || dataOnly)
+ if (!oprinfo->dobj.namespace->dump || dataOnly)
return;
/*
details = createPQExpBuffer();
/* 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)
{
convertRegProcReference(oprcode));
appendPQExpBuffer(oprid, "%s (",
- oprinfo->oprname);
+ oprinfo->dobj.name);
/*
* right unary means there's a left arg and left unary means there's a
* pg_catalog
*/
appendPQExpBuffer(delq, "DROP OPERATOR %s.%s;\n",
- fmtId(oprinfo->oprnamespace->nspname),
+ fmtId(oprinfo->dobj.namespace->dobj.name),
oprid->data);
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,
- oprinfo->oprname,
- oprinfo->oprnamespace->nspname, oprinfo->usename,
+ oprinfo->dobj.name,
+ oprinfo->dobj.namespace->dobj.name, oprinfo->usename,
"OPERATOR", q->data, delq->data, NULL,
oprinfo->dobj.dependencies, oprinfo->dobj.nDeps,
NULL, NULL);
resetPQExpBuffer(q);
appendPQExpBuffer(q, "OPERATOR %s", oprid->data);
dumpComment(fout, q->data,
- oprinfo->oprnamespace->nspname, oprinfo->usename,
+ oprinfo->dobj.namespace->dobj.name, oprinfo->usename,
oprinfo->dobj.catId, 0, oprinfo->dobj.dumpId);
PQclear(res);
opr);
return NULL;
}
- return oprInfo->oprname;
+ return oprInfo->dobj.name;
}
/*
int i;
/* Dump only opclasses in dumpable namespaces */
- if (!opcinfo->opcnamespace->dump || dataOnly)
+ if (!opcinfo->dobj.namespace->dump || dataOnly)
return;
/*
delq = createPQExpBuffer();
/* 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 */
appendPQExpBuffer(query, "SELECT opcintype::pg_catalog.regtype, "
* pg_catalog
*/
appendPQExpBuffer(delq, "DROP OPERATOR CLASS %s",
- fmtId(opcinfo->opcnamespace->nspname));
+ fmtId(opcinfo->dobj.namespace->dobj.name));
appendPQExpBuffer(delq, ".%s",
- fmtId(opcinfo->opcname));
+ fmtId(opcinfo->dobj.name));
appendPQExpBuffer(delq, " USING %s;\n",
fmtId(amname));
/* Build the fixed portion of the CREATE command */
appendPQExpBuffer(q, "CREATE OPERATOR CLASS %s\n ",
- fmtId(opcinfo->opcname));
+ fmtId(opcinfo->dobj.name));
if (strcmp(opcdefault, "t") == 0)
appendPQExpBuffer(q, "DEFAULT ");
appendPQExpBuffer(q, "FOR TYPE %s USING %s AS\n ",
appendPQExpBuffer(q, ";\n");
ArchiveEntry(fout, opcinfo->dobj.catId, opcinfo->dobj.dumpId,
- opcinfo->opcname,
- opcinfo->opcnamespace->nspname, opcinfo->usename,
+ opcinfo->dobj.name,
+ opcinfo->dobj.namespace->dobj.name, opcinfo->usename,
"OPERATOR CLASS", q->data, delq->data, NULL,
opcinfo->dobj.dependencies, opcinfo->dobj.nDeps,
NULL, NULL);
/* Dump Operator Class Comments */
resetPQExpBuffer(q);
appendPQExpBuffer(q, "OPERATOR CLASS %s",
- fmtId(opcinfo->opcname));
+ fmtId(opcinfo->dobj.name));
appendPQExpBuffer(q, " USING %s",
fmtId(amname));
dumpComment(fout, q->data,
bool condefault;
/* Dump only conversions in dumpable namespaces */
- if (!convinfo->connamespace->dump || dataOnly)
+ if (!convinfo->dobj.namespace->dump || dataOnly)
return;
query = createPQExpBuffer();
details = createPQExpBuffer();
/* Make sure we are in proper schema */
- selectSourceSchema(convinfo->connamespace->nspname);
+ selectSourceSchema(convinfo->dobj.namespace->dobj.name);
/* Get conversion-specific details */
appendPQExpBuffer(query, "SELECT conname, "
* pg_catalog
*/
appendPQExpBuffer(delq, "DROP CONVERSION %s",
- fmtId(convinfo->connamespace->nspname));
+ fmtId(convinfo->dobj.namespace->dobj.name));
appendPQExpBuffer(delq, ".%s;\n",
- fmtId(convinfo->conname));
+ fmtId(convinfo->dobj.name));
appendPQExpBuffer(q, "CREATE %sCONVERSION %s FOR ",
(condefault) ? "DEFAULT " : "",
- fmtId(convinfo->conname));
+ fmtId(convinfo->dobj.name));
appendStringLiteral(q, conforencoding, true);
appendPQExpBuffer(q, " TO ");
appendStringLiteral(q, contoencoding, true);
appendPQExpBuffer(q, " FROM %s;\n", conproc);
ArchiveEntry(fout, convinfo->dobj.catId, convinfo->dobj.dumpId,
- convinfo->conname,
- convinfo->connamespace->nspname, convinfo->usename,
+ convinfo->dobj.name,
+ convinfo->dobj.namespace->dobj.name, convinfo->usename,
"CONVERSION", q->data, delq->data, NULL,
convinfo->dobj.dependencies, convinfo->dobj.nDeps,
NULL, NULL);
/* Dump Conversion Comments */
resetPQExpBuffer(q);
- appendPQExpBuffer(q, "CONVERSION %s", fmtId(convinfo->conname));
+ appendPQExpBuffer(q, "CONVERSION %s", fmtId(convinfo->dobj.name));
dumpComment(fout, q->data,
- convinfo->connamespace->nspname, convinfo->usename,
+ convinfo->dobj.namespace->dobj.name, convinfo->usename,
convinfo->dobj.catId, 0, convinfo->dobj.dumpId);
PQclear(res);
initPQExpBuffer(&buf);
if (honor_quotes)
appendPQExpBuffer(&buf, "%s",
- fmtId(agginfo->aggfn.proname));
+ fmtId(agginfo->aggfn.dobj.name));
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 (fout->remoteVersion >= 70100)
bool convertok;
/* Dump only aggs in dumpable namespaces */
- if (!agginfo->aggfn.pronamespace->dump || dataOnly)
+ if (!agginfo->aggfn.dobj.namespace->dump || dataOnly)
return;
query = createPQExpBuffer();
details = createPQExpBuffer();
/* Make sure we are in proper schema */
- selectSourceSchema(agginfo->aggfn.pronamespace->nspname);
+ selectSourceSchema(agginfo->aggfn.dobj.namespace->dobj.name);
/* Get aggregate-specific details */
if (g_fout->remoteVersion >= 70300)
* pg_catalog
*/
appendPQExpBuffer(delq, "DROP AGGREGATE %s.%s;\n",
- fmtId(agginfo->aggfn.pronamespace->nspname),
+ fmtId(agginfo->aggfn.dobj.namespace->dobj.name),
aggsig);
appendPQExpBuffer(q, "CREATE AGGREGATE %s (\n%s\n);\n",
- fmtId(agginfo->aggfn.proname),
+ fmtId(agginfo->aggfn.dobj.name),
details->data);
ArchiveEntry(fout, agginfo->aggfn.dobj.catId, agginfo->aggfn.dobj.dumpId,
aggsig_tag,
- agginfo->aggfn.pronamespace->nspname, agginfo->aggfn.usename,
+ agginfo->aggfn.dobj.namespace->dobj.name, agginfo->aggfn.usename,
"AGGREGATE", q->data, delq->data, NULL,
agginfo->aggfn.dobj.dependencies, agginfo->aggfn.dobj.nDeps,
NULL, NULL);
resetPQExpBuffer(q);
appendPQExpBuffer(q, "AGGREGATE %s", aggsig);
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);
/*
dumpACL(fout, agginfo->aggfn.dobj.catId, agginfo->aggfn.dobj.dumpId,
"FUNCTION",
aggsig, aggsig_tag,
- agginfo->aggfn.pronamespace->nspname,
+ agginfo->aggfn.dobj.namespace->dobj.name,
agginfo->aggfn.usename, agginfo->aggfn.proacl);
free(aggsig);
dumpTableSchema(fout, tbinfo);
/* Handle the ACL here */
- namecopy = strdup(fmtId(tbinfo->relname));
+ namecopy = strdup(fmtId(tbinfo->dobj.name));
dumpACL(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId, "TABLE",
- namecopy, tbinfo->relname,
- tbinfo->relnamespace->nspname, tbinfo->usename,
+ namecopy, tbinfo->dobj.name,
+ tbinfo->dobj.namespace->dobj.name, tbinfo->usename,
tbinfo->relacl);
free(namecopy);
}
k;
/* Make sure we are in proper schema */
- selectSourceSchema(tbinfo->relnamespace->nspname);
+ selectSourceSchema(tbinfo->dobj.namespace->dobj.name);
/* Is it a table or a view? */
if (tbinfo->relkind == RELKIND_VIEW)
{
appendPQExpBuffer(query, "SELECT definition as viewdef "
" from pg_views where viewname = ");
- appendStringLiteral(query, tbinfo->relname, true);
+ appendStringLiteral(query, tbinfo->dobj.name, true);
appendPQExpBuffer(query, ";");
}
{
if (PQntuples(res) < 1)
write_msg(NULL, "query to obtain definition of view \"%s\" returned no data\n",
- tbinfo->relname);
+ tbinfo->dobj.name);
else
write_msg(NULL, "query to obtain definition of view \"%s\" returned more than one definition\n",
- tbinfo->relname);
+ tbinfo->dobj.name);
exit_nicely();
}
if (strlen(viewdef) == 0)
{
write_msg(NULL, "definition of view \"%s\" appears to be empty (length zero)\n",
- tbinfo->relname);
+ tbinfo->dobj.name);
exit_nicely();
}
* pg_catalog
*/
appendPQExpBuffer(delq, "DROP VIEW %s.",
- fmtId(tbinfo->relnamespace->nspname));
+ fmtId(tbinfo->dobj.namespace->dobj.name));
appendPQExpBuffer(delq, "%s;\n",
- fmtId(tbinfo->relname));
+ fmtId(tbinfo->dobj.name));
appendPQExpBuffer(q, "CREATE VIEW %s AS\n %s\n",
- fmtId(tbinfo->relname), viewdef);
+ fmtId(tbinfo->dobj.name), viewdef);
PQclear(res);
}
* pg_catalog
*/
appendPQExpBuffer(delq, "DROP TABLE %s.",
- fmtId(tbinfo->relnamespace->nspname));
+ fmtId(tbinfo->dobj.namespace->dobj.name));
appendPQExpBuffer(delq, "%s;\n",
- fmtId(tbinfo->relname));
+ fmtId(tbinfo->dobj.name));
appendPQExpBuffer(q, "CREATE TABLE %s (",
- fmtId(tbinfo->relname));
+ fmtId(tbinfo->dobj.name));
actual_atts = 0;
for (j = 0; j < tbinfo->numatts; j++)
{
appendPQExpBuffer(q, ",\n ");
appendPQExpBuffer(q, "CONSTRAINT %s ",
- fmtId(constr->conname));
+ fmtId(constr->dobj.name));
appendPQExpBuffer(q, "%s", constr->condef);
actual_atts++;
if (k > 0)
appendPQExpBuffer(q, ", ");
- if (parentRel->relnamespace != tbinfo->relnamespace)
+ if (parentRel->dobj.namespace != tbinfo->dobj.namespace)
appendPQExpBuffer(q, "%s.",
- fmtId(parentRel->relnamespace->nspname));
+ fmtId(parentRel->dobj.namespace->dobj.name));
appendPQExpBuffer(q, "%s",
- fmtId(parentRel->relname));
+ fmtId(parentRel->dobj.name));
}
appendPQExpBuffer(q, ")");
}
!tbinfo->attisdropped[j])
{
appendPQExpBuffer(q, "ALTER TABLE ONLY %s ",
- fmtId(tbinfo->relname));
+ fmtId(tbinfo->dobj.name));
appendPQExpBuffer(q, "ALTER COLUMN %s ",
fmtId(tbinfo->attnames[j]));
appendPQExpBuffer(q, "SET STATISTICS %d;\n",
if (storage != NULL)
{
appendPQExpBuffer(q, "ALTER TABLE ONLY %s ",
- fmtId(tbinfo->relname));
+ fmtId(tbinfo->dobj.name));
appendPQExpBuffer(q, "ALTER COLUMN %s ",
fmtId(tbinfo->attnames[j]));
appendPQExpBuffer(q, "SET STORAGE %s;\n",
}
ArchiveEntry(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId,
- tbinfo->relname,
- tbinfo->relnamespace->nspname, tbinfo->usename,
+ tbinfo->dobj.name,
+ tbinfo->dobj.namespace->dobj.name, tbinfo->usename,
reltypename, q->data, delq->data, NULL,
tbinfo->dobj.dependencies, tbinfo->dobj.nDeps,
NULL, NULL);
delq = createPQExpBuffer();
appendPQExpBuffer(q, "ALTER TABLE %s ",
- fmtId(tbinfo->relname));
+ fmtId(tbinfo->dobj.name));
appendPQExpBuffer(q, "ALTER COLUMN %s SET DEFAULT %s;\n",
fmtId(tbinfo->attnames[adnum - 1]),
adinfo->adef_expr);
* in pg_catalog
*/
appendPQExpBuffer(delq, "ALTER TABLE %s.",
- fmtId(tbinfo->relnamespace->nspname));
+ fmtId(tbinfo->dobj.namespace->dobj.name));
appendPQExpBuffer(delq, "%s ",
- fmtId(tbinfo->relname));
+ fmtId(tbinfo->dobj.name));
appendPQExpBuffer(delq, "ALTER COLUMN %s DROP DEFAULT;\n",
fmtId(tbinfo->attnames[adnum - 1]));
ArchiveEntry(fout, adinfo->dobj.catId, adinfo->dobj.dumpId,
tbinfo->attnames[adnum - 1],
- tbinfo->relnamespace->nspname, tbinfo->usename,
+ tbinfo->dobj.namespace->dobj.name, tbinfo->usename,
"DEFAULT", q->data, delq->data, NULL,
adinfo->dobj.dependencies, adinfo->dobj.nDeps,
NULL, NULL);
return "tableoid";
}
write_msg(NULL, "invalid column number %d for table \"%s\"\n",
- attrnum, tblInfo->relname);
+ attrnum, tblInfo->dobj.name);
exit_nicely();
return NULL; /* keep compiler quiet */
}
if (indxinfo->indisclustered)
{
appendPQExpBuffer(q, "\nALTER TABLE %s CLUSTER",
- fmtId(tbinfo->relname));
+ fmtId(tbinfo->dobj.name));
appendPQExpBuffer(q, " ON %s;\n",
- fmtId(indxinfo->indexname));
+ fmtId(indxinfo->dobj.name));
}
/*
* in pg_catalog
*/
appendPQExpBuffer(delq, "DROP INDEX %s.",
- fmtId(tbinfo->relnamespace->nspname));
+ fmtId(tbinfo->dobj.namespace->dobj.name));
appendPQExpBuffer(delq, "%s;\n",
- fmtId(indxinfo->indexname));
+ fmtId(indxinfo->dobj.name));
ArchiveEntry(fout, indxinfo->dobj.catId, indxinfo->dobj.dumpId,
- indxinfo->indexname,
- tbinfo->relnamespace->nspname,
+ indxinfo->dobj.name,
+ tbinfo->dobj.namespace->dobj.name,
tbinfo->usename,
"INDEX", q->data, delq->data, NULL,
indxinfo->dobj.dependencies, indxinfo->dobj.nDeps,
/* Dump Index Comments */
resetPQExpBuffer(q);
appendPQExpBuffer(q, "INDEX %s",
- fmtId(indxinfo->indexname));
+ fmtId(indxinfo->dobj.name));
dumpComment(fout, q->data,
- tbinfo->relnamespace->nspname,
+ tbinfo->dobj.namespace->dobj.name,
tbinfo->usename,
indxinfo->dobj.catId, 0, indxinfo->dobj.dumpId);
if (indxinfo == NULL)
{
write_msg(NULL, "missing index for constraint %s\n",
- coninfo->conname);
+ coninfo->dobj.name);
exit_nicely();
}
appendPQExpBuffer(q, "ALTER TABLE ONLY %s\n",
- fmtId(tbinfo->relname));
+ fmtId(tbinfo->dobj.name));
appendPQExpBuffer(q, " ADD CONSTRAINT %s %s (",
- fmtId(coninfo->conname),
+ fmtId(coninfo->dobj.name),
coninfo->contype == 'p' ? "PRIMARY KEY" : "UNIQUE");
for (k = 0; k < indxinfo->indnkeys; k++)
if (indxinfo->indisclustered)
{
appendPQExpBuffer(q, "\nALTER TABLE %s CLUSTER",
- fmtId(tbinfo->relname));
+ fmtId(tbinfo->dobj.name));
appendPQExpBuffer(q, " ON %s;\n",
- fmtId(indxinfo->indexname));
+ fmtId(indxinfo->dobj.name));
}
/*
* in pg_catalog
*/
appendPQExpBuffer(delq, "ALTER TABLE ONLY %s.",
- fmtId(tbinfo->relnamespace->nspname));
+ fmtId(tbinfo->dobj.namespace->dobj.name));
appendPQExpBuffer(delq, "%s ",
- fmtId(tbinfo->relname));
+ fmtId(tbinfo->dobj.name));
appendPQExpBuffer(delq, "DROP CONSTRAINT %s;\n",
- fmtId(coninfo->conname));
+ fmtId(coninfo->dobj.name));
ArchiveEntry(fout, coninfo->dobj.catId, coninfo->dobj.dumpId,
- coninfo->conname,
- tbinfo->relnamespace->nspname,
+ coninfo->dobj.name,
+ tbinfo->dobj.namespace->dobj.name,
tbinfo->usename,
"CONSTRAINT", q->data, delq->data, NULL,
coninfo->dobj.dependencies, coninfo->dobj.nDeps,
* the current table data is not processed
*/
appendPQExpBuffer(q, "ALTER TABLE ONLY %s\n",
- fmtId(tbinfo->relname));
+ fmtId(tbinfo->dobj.name));
appendPQExpBuffer(q, " ADD CONSTRAINT %s %s;\n",
- fmtId(coninfo->conname),
+ fmtId(coninfo->dobj.name),
coninfo->condef);
/*
* pg_catalog
*/
appendPQExpBuffer(delq, "ALTER TABLE ONLY %s.",
- fmtId(tbinfo->relnamespace->nspname));
+ fmtId(tbinfo->dobj.namespace->dobj.name));
appendPQExpBuffer(delq, "%s ",
- fmtId(tbinfo->relname));
+ fmtId(tbinfo->dobj.name));
appendPQExpBuffer(delq, "DROP CONSTRAINT %s;\n",
- fmtId(coninfo->conname));
+ fmtId(coninfo->dobj.name));
ArchiveEntry(fout, coninfo->dobj.catId, coninfo->dobj.dumpId,
- coninfo->conname,
- tbinfo->relnamespace->nspname,
+ coninfo->dobj.name,
+ tbinfo->dobj.namespace->dobj.name,
tbinfo->usename,
"FK CONSTRAINT", q->data, delq->data, NULL,
coninfo->dobj.dependencies, coninfo->dobj.nDeps,
{
/* not ONLY since we want it to propagate to children */
appendPQExpBuffer(q, "ALTER TABLE %s\n",
- fmtId(tbinfo->relname));
+ fmtId(tbinfo->dobj.name));
appendPQExpBuffer(q, " ADD CONSTRAINT %s %s;\n",
- fmtId(coninfo->conname),
+ fmtId(coninfo->dobj.name),
coninfo->condef);
/*
* pg_catalog
*/
appendPQExpBuffer(delq, "ALTER TABLE %s.",
- fmtId(tbinfo->relnamespace->nspname));
+ fmtId(tbinfo->dobj.namespace->dobj.name));
appendPQExpBuffer(delq, "%s ",
- fmtId(tbinfo->relname));
+ fmtId(tbinfo->dobj.name));
appendPQExpBuffer(delq, "DROP CONSTRAINT %s;\n",
- fmtId(coninfo->conname));
+ fmtId(coninfo->dobj.name));
ArchiveEntry(fout, coninfo->dobj.catId, coninfo->dobj.dumpId,
- coninfo->conname,
- tbinfo->relnamespace->nspname,
+ coninfo->dobj.name,
+ tbinfo->dobj.namespace->dobj.name,
tbinfo->usename,
"CHECK CONSTRAINT", q->data, delq->data, NULL,
coninfo->dobj.dependencies, coninfo->dobj.nDeps,
TypeInfo *tinfo = coninfo->condomain;
/* 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",
- fmtId(tinfo->typname));
+ fmtId(tinfo->dobj.name));
appendPQExpBuffer(q, " ADD CONSTRAINT %s %s;\n",
- fmtId(coninfo->conname),
+ fmtId(coninfo->dobj.name),
coninfo->condef);
/*
* pg_catalog
*/
appendPQExpBuffer(delq, "ALTER DOMAIN %s.",
- fmtId(tinfo->typnamespace->nspname));
+ fmtId(tinfo->dobj.namespace->dobj.name));
appendPQExpBuffer(delq, "%s ",
- fmtId(tinfo->typname));
+ fmtId(tinfo->dobj.name));
appendPQExpBuffer(delq, "DROP CONSTRAINT %s;\n",
- fmtId(coninfo->conname));
+ fmtId(coninfo->dobj.name));
ArchiveEntry(fout, coninfo->dobj.catId, coninfo->dobj.dumpId,
- coninfo->conname,
- tinfo->typnamespace->nspname,
+ coninfo->dobj.name,
+ tinfo->dobj.namespace->dobj.name,
tinfo->usename,
"CHECK CONSTRAINT", q->data, delq->data, NULL,
coninfo->dobj.dependencies, coninfo->dobj.nDeps,
{
resetPQExpBuffer(q);
appendPQExpBuffer(q, "CONSTRAINT %s ",
- fmtId(coninfo->conname));
+ fmtId(coninfo->dobj.name));
appendPQExpBuffer(q, "ON %s",
- fmtId(tbinfo->relname));
+ fmtId(tbinfo->dobj.name));
dumpComment(fout, q->data,
- tbinfo->relnamespace->nspname,
+ tbinfo->dobj.namespace->dobj.name,
tbinfo->usename,
coninfo->dobj.catId, 0, coninfo->dobj.dumpId);
}
PQExpBuffer delqry = createPQExpBuffer();
/* 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(bufx, sizeof(bufx), INT64_FORMAT, SEQ_MAXVALUE);
"END AS min_value, "
"cache_value, is_cycled, is_called from %s",
bufx, bufm,
- fmtId(tbinfo->relname));
+ fmtId(tbinfo->dobj.name));
res = PQexec(g_conn, query->data);
check_sql_result(res, g_conn, query->data, PGRES_TUPLES_OK);
if (PQntuples(res) != 1)
{
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();
}
/* Disable this check: it fails if sequence has been renamed */
#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",
- tbinfo->relname, PQgetvalue(res, 0, 0));
+ tbinfo->dobj.name, PQgetvalue(res, 0, 0));
exit_nicely();
}
#endif
* pg_catalog
*/
appendPQExpBuffer(delqry, "DROP SEQUENCE %s.",
- fmtId(tbinfo->relnamespace->nspname));
+ fmtId(tbinfo->dobj.namespace->dobj.name));
appendPQExpBuffer(delqry, "%s;\n",
- fmtId(tbinfo->relname));
+ fmtId(tbinfo->dobj.name));
resetPQExpBuffer(query);
appendPQExpBuffer(query,
"CREATE SEQUENCE %s\n",
- fmtId(tbinfo->relname));
+ fmtId(tbinfo->dobj.name));
if (!called)
appendPQExpBuffer(query, " START WITH %s\n", last);
cache, (cycled ? "\n CYCLE" : ""));
ArchiveEntry(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId,
- tbinfo->relname,
- tbinfo->relnamespace->nspname, tbinfo->usename,
+ tbinfo->dobj.name,
+ tbinfo->dobj.namespace->dobj.name, tbinfo->usename,
"SEQUENCE", query->data, delqry->data, NULL,
tbinfo->dobj.dependencies, tbinfo->dobj.nDeps,
NULL, NULL);
{
resetPQExpBuffer(query);
appendPQExpBuffer(query, "SELECT pg_catalog.setval(");
- appendStringLiteral(query, fmtId(tbinfo->relname), true);
+ appendStringLiteral(query, fmtId(tbinfo->dobj.name), true);
appendPQExpBuffer(query, ", %s, %s);\n",
last, (called ? "true" : "false"));
ArchiveEntry(fout, nilCatalogId, createDumpId(),
- tbinfo->relname,
- tbinfo->relnamespace->nspname, tbinfo->usename,
+ tbinfo->dobj.name,
+ tbinfo->dobj.namespace->dobj.name, tbinfo->usename,
"SEQUENCE SET", query->data, "", NULL,
&(tbinfo->dobj.dumpId), 1,
NULL, NULL);
{
/* Dump Sequence Comments */
resetPQExpBuffer(query);
- appendPQExpBuffer(query, "SEQUENCE %s", fmtId(tbinfo->relname));
+ appendPQExpBuffer(query, "SEQUENCE %s", fmtId(tbinfo->dobj.name));
dumpComment(fout, query->data,
- tbinfo->relnamespace->nspname, tbinfo->usename,
+ tbinfo->dobj.namespace->dobj.name, tbinfo->usename,
tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId);
}
* pg_catalog
*/
appendPQExpBuffer(delqry, "DROP TRIGGER %s ",
- fmtId(tginfo->tgname));
+ fmtId(tginfo->dobj.name));
appendPQExpBuffer(delqry, "ON %s.",
- fmtId(tbinfo->relnamespace->nspname));
+ fmtId(tbinfo->dobj.namespace->dobj.name));
appendPQExpBuffer(delqry, "%s;\n",
- fmtId(tbinfo->relname));
+ fmtId(tbinfo->dobj.name));
if (tginfo->tgisconstraint)
{
else
{
appendPQExpBuffer(query, "CREATE TRIGGER ");
- appendPQExpBuffer(query, fmtId(tginfo->tgname));
+ appendPQExpBuffer(query, fmtId(tginfo->dobj.name));
}
appendPQExpBuffer(query, "\n ");
appendPQExpBuffer(query, " UPDATE");
}
appendPQExpBuffer(query, " ON %s\n",
- fmtId(tbinfo->relname));
+ fmtId(tbinfo->dobj.name));
if (tginfo->tgisconstraint)
{
{
write_msg(NULL, "invalid argument string (%s) for trigger \"%s\" on table \"%s\"\n",
tginfo->tgargs,
- tginfo->tgname,
- tbinfo->relname);
+ tginfo->dobj.name,
+ tbinfo->dobj.name);
exit_nicely();
}
p++;
appendPQExpBuffer(query, ");\n");
ArchiveEntry(fout, tginfo->dobj.catId, tginfo->dobj.dumpId,
- tginfo->tgname,
- tbinfo->relnamespace->nspname,
+ tginfo->dobj.name,
+ tbinfo->dobj.namespace->dobj.name,
tbinfo->usename,
"TRIGGER", query->data, delqry->data, NULL,
tginfo->dobj.dependencies, tginfo->dobj.nDeps,
resetPQExpBuffer(query);
appendPQExpBuffer(query, "TRIGGER %s ",
- fmtId(tginfo->tgname));
+ fmtId(tginfo->dobj.name));
appendPQExpBuffer(query, "ON %s",
- fmtId(tbinfo->relname));
+ fmtId(tbinfo->dobj.name));
dumpComment(fout, query->data,
- tbinfo->relnamespace->nspname, tbinfo->usename,
+ tbinfo->dobj.namespace->dobj.name, tbinfo->usename,
tginfo->dobj.catId, 0, tginfo->dobj.dumpId);
destroyPQExpBuffer(query);
/*
* Make sure we are in proper schema.
*/
- selectSourceSchema(tbinfo->relnamespace->nspname);
+ selectSourceSchema(tbinfo->dobj.namespace->dobj.name);
query = createPQExpBuffer();
cmd = createPQExpBuffer();
/* Rule name was unique before 7.3 ... */
appendPQExpBuffer(query,
"SELECT pg_get_ruledef('%s') AS definition",
- rinfo->rulename);
+ rinfo->dobj.name);
}
res = PQexec(g_conn, query->data);
if (PQntuples(res) != 1)
{
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();
}
* pg_catalog
*/
appendPQExpBuffer(delcmd, "DROP RULE %s ",
- fmtId(rinfo->rulename));
+ fmtId(rinfo->dobj.name));
appendPQExpBuffer(delcmd, "ON %s.",
- fmtId(tbinfo->relnamespace->nspname));
+ fmtId(tbinfo->dobj.namespace->dobj.name));
appendPQExpBuffer(delcmd, "%s;\n",
- fmtId(tbinfo->relname));
+ fmtId(tbinfo->dobj.name));
ArchiveEntry(fout, rinfo->dobj.catId, rinfo->dobj.dumpId,
- rinfo->rulename,
- tbinfo->relnamespace->nspname,
+ rinfo->dobj.name,
+ tbinfo->dobj.namespace->dobj.name,
tbinfo->usename,
"RULE", cmd->data, delcmd->data, NULL,
rinfo->dobj.dependencies, rinfo->dobj.nDeps,
/* Dump rule comments */
resetPQExpBuffer(query);
appendPQExpBuffer(query, "RULE %s",
- fmtId(rinfo->rulename));
+ fmtId(rinfo->dobj.name));
appendPQExpBuffer(query, " ON %s",
- fmtId(tbinfo->relname));
+ fmtId(tbinfo->dobj.name));
dumpComment(fout, query->data,
- tbinfo->relnamespace->nspname,
+ tbinfo->dobj.namespace->dobj.name,
tbinfo->usename,
rinfo->dobj.catId, 0, rinfo->dobj.dumpId);