aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2004-08-04 17:13:03 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2004-08-04 17:13:03 +0000
commit576856b698c2c5b920592c1663b148a38ce09361 (patch)
tree1ac840412e7a01b51fb1f77337501300bb70a62c
parent6568d643503fd5ca9ca447a9f93c01b05bf9cf1e (diff)
downloadpostgresql-576856b698c2c5b920592c1663b148a38ce09361.tar.gz
postgresql-576856b698c2c5b920592c1663b148a38ce09361.zip
Dump comments on columns of composite types.
Instead of putting all the OWNER TO commands at the end, it dumps then after each object. This is WAY more readable and nice. ACLs are still at the end. Christopher Kings-Lynne
-rw-r--r--src/bin/pg_dump/pg_backup_archiver.c56
-rw-r--r--src/bin/pg_dump/pg_dump.c22
2 files changed, 42 insertions, 36 deletions
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index 939baf86ec9..d234d2aedf2 100644
--- a/src/bin/pg_dump/pg_backup_archiver.c
+++ b/src/bin/pg_dump/pg_backup_archiver.c
@@ -15,7 +15,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.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 $
*
*-------------------------------------------------------------------------
*/
@@ -49,7 +49,7 @@ static ArchiveHandle *_allocAH(const char *FileSpec, const ArchiveFormat fmt,
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,
@@ -62,7 +62,7 @@ static void _becomeUser(ArchiveHandle *AH, const char *user);
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);
@@ -1913,7 +1913,7 @@ ReadToc(ArchiveHandle *AH)
}
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 */
@@ -1922,7 +1922,7 @@ _tocEntryRequired(TocEntry *te, RestoreOptions *ropt, bool ownerAndACL)
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)
@@ -2338,39 +2338,20 @@ _printTocHeader(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDa
}
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);
@@ -2388,6 +2369,25 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat
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);
+ }
}
}
}
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 8ffc1522beb..7d736a4c434 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -12,7 +12,7 @@
* by PostgreSQL
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.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 $
*
*-------------------------------------------------------------------------
*/
@@ -2393,10 +2393,10 @@ getTables(int *numTables)
"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)
{
@@ -2419,10 +2419,10 @@ getTables(int *numTables)
"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)
{
@@ -4063,7 +4063,7 @@ dumpComment(Archive *fout, const char *target,
/*
* 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
@@ -4864,6 +4864,7 @@ dumpCompositeType(Archive *fout, TypeInfo *tinfo)
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);
@@ -4928,7 +4929,6 @@ dumpCompositeType(Archive *fout, TypeInfo *tinfo)
tinfo->dobj.dependencies, tinfo->dobj.nDeps,
NULL, NULL);
-
/* Dump Type Comments */
resetPQExpBuffer(q);
@@ -4937,7 +4937,13 @@ dumpCompositeType(Archive *fout, TypeInfo *tinfo)
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);
@@ -6432,7 +6438,7 @@ dumpTable(Archive *fout, TableInfo *tbinfo)
{
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 */