*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.90 2004/07/19 21:39:47 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.91 2004/08/04 17:13:03 tgl Exp $
*
*-------------------------------------------------------------------------
*/
const int compression, ArchiveMode mode);
static char *_getObjectFromDropStmt(const char *dropStmt, const char *type);
static void _printTocHeader(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isData);
-static int _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isData, bool ownerAndACL);
+static int _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isData, bool acl_pass);
static void fixPriorBlobRefs(ArchiveHandle *AH, TocEntry *blobte,
static void _becomeOwner(ArchiveHandle *AH, TocEntry *te);
static void _selectOutputSchema(ArchiveHandle *AH, const char *schemaName);
-static teReqs _tocEntryRequired(TocEntry *te, RestoreOptions *ropt, bool ownerAndACL);
+static teReqs _tocEntryRequired(TocEntry *te, RestoreOptions *ropt, bool acl_pass);
static void _disableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
static void _enableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
static TocEntry *getTocEntryByDumpId(ArchiveHandle *AH, DumpId id);
}
static teReqs
-_tocEntryRequired(TocEntry *te, RestoreOptions *ropt, bool ownerAndACL)
+_tocEntryRequired(TocEntry *te, RestoreOptions *ropt, bool acl_pass)
{
teReqs res = 3; /* Schema = 1, Data = 2, Both = 3 */
return 0;
/* If it's an ACL, maybe ignore it */
- if ((!ownerAndACL || ropt->aclsSkip) && strcmp(te->desc, "ACL") == 0)
+ if ((!acl_pass || ropt->aclsSkip) && strcmp(te->desc, "ACL") == 0)
return 0;
if (!ropt->create && strcmp(te->desc, "DATABASE") == 0)
}
static int
-_printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isData, bool ownerAndACL)
+_printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isData, bool acl_pass)
{
/* Select schema as necessary */
_becomeOwner(AH, te);
_selectOutputSchema(AH, te->namespace);
- if (strcmp(te->desc, "TABLE") == 0 && !ownerAndACL)
+ if (strcmp(te->desc, "TABLE") == 0 && !acl_pass)
_setWithOids(AH, te);
- if (!ropt->noOwner && !ropt->use_setsessauth && ownerAndACL && strlen(te->owner) > 0 && strlen(te->dropStmt) > 0 && (
- strcmp(te->desc, "AGGREGATE") == 0 ||
- strcmp(te->desc, "CONVERSION") == 0 ||
- strcmp(te->desc, "DOMAIN") == 0 ||
- strcmp(te->desc, "FUNCTION") == 0 ||
- strcmp(te->desc, "OPERATOR") == 0 ||
- strcmp(te->desc, "OPERATOR CLASS") == 0 ||
- strcmp(te->desc, "TABLE") == 0 ||
- strcmp(te->desc, "TYPE") == 0 ||
- strcmp(te->desc, "VIEW") == 0 ||
- strcmp(te->desc, "SEQUENCE") == 0 ||
- (strcmp(te->desc, "SCHEMA") == 0 && strcmp(te->tag, "public") == 0) /* Only public schema */
- ))
- {
- char *temp = _getObjectFromDropStmt(te->dropStmt, te->desc);
- _printTocHeader(AH, te, ropt, isData);
- ahprintf(AH, "ALTER %s OWNER TO %s;\n\n", temp, fmtId(te->owner));
- free (temp);
- }
- else if (ownerAndACL && strcmp(te->desc, "ACL") == 0)
+ if (acl_pass && strcmp(te->desc, "ACL") == 0)
{
_printTocHeader(AH, te, ropt, isData);
ahprintf(AH, "%s\n\n", te->defn);
}
- else if (!ownerAndACL && strlen(te->defn) > 0)
+ else if (!acl_pass && strlen(te->defn) > 0)
{
_printTocHeader(AH, te, ropt, isData);
else
{
ahprintf(AH, "%s\n\n", te->defn);
+
+ if (!ropt->noOwner && !ropt->use_setsessauth && strlen(te->owner) > 0 && strlen(te->dropStmt) > 0 && (
+ strcmp(te->desc, "AGGREGATE") == 0 ||
+ strcmp(te->desc, "CONVERSION") == 0 ||
+ strcmp(te->desc, "DOMAIN") == 0 ||
+ strcmp(te->desc, "FUNCTION") == 0 ||
+ strcmp(te->desc, "OPERATOR") == 0 ||
+ strcmp(te->desc, "OPERATOR CLASS") == 0 ||
+ strcmp(te->desc, "TABLE") == 0 ||
+ strcmp(te->desc, "TYPE") == 0 ||
+ strcmp(te->desc, "VIEW") == 0 ||
+ strcmp(te->desc, "SEQUENCE") == 0 ||
+ (strcmp(te->desc, "SCHEMA") == 0 && strcmp(te->tag, "public") == 0) /* Only public schema */
+ ))
+ {
+ char *temp = _getObjectFromDropStmt(te->dropStmt, te->desc);
+ ahprintf(AH, "ALTER %s OWNER TO %s;\n\n", temp, fmtId(te->owner));
+ free (temp);
+ }
}
}
}
* by PostgreSQL
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.381 2004/08/02 04:28:03 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.382 2004/08/04 17:13:03 tgl Exp $
*
*-------------------------------------------------------------------------
*/
"d.classid = c.tableoid and d.objid = c.oid and "
"d.objsubid = 0 and "
"d.refclassid = c.tableoid and d.deptype = 'i') "
- "where relkind in ('%c', '%c', '%c') "
+ "where relkind in ('%c', '%c', '%c', '%c') "
"order by c.oid",
RELKIND_SEQUENCE,
- RELKIND_RELATION, RELKIND_SEQUENCE, RELKIND_VIEW);
+ RELKIND_RELATION, RELKIND_SEQUENCE, RELKIND_VIEW, RELKIND_COMPOSITE_TYPE);
}
else if (g_fout->remoteVersion >= 70300)
{
"d.classid = c.tableoid and d.objid = c.oid and "
"d.objsubid = 0 and "
"d.refclassid = c.tableoid and d.deptype = 'i') "
- "where relkind in ('%c', '%c', '%c') "
+ "where relkind in ('%c', '%c', '%c', '%c') "
"order by c.oid",
RELKIND_SEQUENCE,
- RELKIND_RELATION, RELKIND_SEQUENCE, RELKIND_VIEW);
+ RELKIND_RELATION, RELKIND_SEQUENCE, RELKIND_VIEW, RELKIND_COMPOSITE_TYPE);
}
else if (g_fout->remoteVersion >= 70200)
{
/*
* dumpTableComment --
*
- * As above, but dump comments for both the specified table (or view)
+ * As above, but dump comments for both the specified table, view or composite type
* and its columns.
*/
static void
int i_attname;
int i_atttypdefn;
int i;
+ TableInfo *tableInfo;
/* Set proper schema search path so type references list correctly */
selectSourceSchema(tinfo->dobj.namespace->dobj.name);
tinfo->dobj.dependencies, tinfo->dobj.nDeps,
NULL, NULL);
-
/* Dump Type Comments */
resetPQExpBuffer(q);
tinfo->dobj.namespace->dobj.name, tinfo->usename,
tinfo->dobj.catId, 0, tinfo->dobj.dumpId);
+ /* Dump column comments */
+ tableInfo = findTableByOid(tinfo->typrelid);
+ if (tableInfo)
+ dumpTableComment(fout, tableInfo, "TABLE");
+
PQclear(res);
+
destroyPQExpBuffer(q);
destroyPQExpBuffer(delq);
destroyPQExpBuffer(query);
{
if (tbinfo->relkind == RELKIND_SEQUENCE)
dumpSequence(fout, tbinfo);
- else if (!dataOnly)
+ else if (!dataOnly && tbinfo->relkind != RELKIND_COMPOSITE_TYPE)
dumpTableSchema(fout, tbinfo);
/* Handle the ACL here */