Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit576856b

Browse files
committed
Dump comments on columns of composite types.
Instead of putting all the OWNER TO commands at the end, it dumps thenafter each object. This is WAY more readable and nice. ACLs are stillat the end.Christopher Kings-Lynne
1 parent6568d64 commit576856b

File tree

2 files changed

+42
-36
lines changed

2 files changed

+42
-36
lines changed

‎src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*
1717
* IDENTIFICATION
18-
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.90 2004/07/19 21:39:47 momjian Exp $
18+
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.91 2004/08/04 17:13:03 tgl Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -49,7 +49,7 @@ static ArchiveHandle *_allocAH(const char *FileSpec, const ArchiveFormat fmt,
4949
constintcompression,ArchiveModemode);
5050
staticchar*_getObjectFromDropStmt(constchar*dropStmt,constchar*type);
5151
staticvoid_printTocHeader(ArchiveHandle*AH,TocEntry*te,RestoreOptions*ropt,boolisData);
52-
staticint_printTocEntry(ArchiveHandle*AH,TocEntry*te,RestoreOptions*ropt,boolisData,boolownerAndACL);
52+
staticint_printTocEntry(ArchiveHandle*AH,TocEntry*te,RestoreOptions*ropt,boolisData,boolacl_pass);
5353

5454

5555
staticvoidfixPriorBlobRefs(ArchiveHandle*AH,TocEntry*blobte,
@@ -62,7 +62,7 @@ static void _becomeUser(ArchiveHandle *AH, const char *user);
6262
staticvoid_becomeOwner(ArchiveHandle*AH,TocEntry*te);
6363
staticvoid_selectOutputSchema(ArchiveHandle*AH,constchar*schemaName);
6464

65-
staticteReqs_tocEntryRequired(TocEntry*te,RestoreOptions*ropt,boolownerAndACL);
65+
staticteReqs_tocEntryRequired(TocEntry*te,RestoreOptions*ropt,boolacl_pass);
6666
staticvoid_disableTriggersIfNecessary(ArchiveHandle*AH,TocEntry*te,RestoreOptions*ropt);
6767
staticvoid_enableTriggersIfNecessary(ArchiveHandle*AH,TocEntry*te,RestoreOptions*ropt);
6868
staticTocEntry*getTocEntryByDumpId(ArchiveHandle*AH,DumpIdid);
@@ -1913,7 +1913,7 @@ ReadToc(ArchiveHandle *AH)
19131913
}
19141914

19151915
staticteReqs
1916-
_tocEntryRequired(TocEntry*te,RestoreOptions*ropt,boolownerAndACL)
1916+
_tocEntryRequired(TocEntry*te,RestoreOptions*ropt,boolacl_pass)
19171917
{
19181918
teReqsres=3;/* Schema = 1, Data = 2, Both = 3 */
19191919

@@ -1922,7 +1922,7 @@ _tocEntryRequired(TocEntry *te, RestoreOptions *ropt, bool ownerAndACL)
19221922
return0;
19231923

19241924
/* If it's an ACL, maybe ignore it */
1925-
if ((!ownerAndACL||ropt->aclsSkip)&&strcmp(te->desc,"ACL")==0)
1925+
if ((!acl_pass||ropt->aclsSkip)&&strcmp(te->desc,"ACL")==0)
19261926
return0;
19271927

19281928
if (!ropt->create&&strcmp(te->desc,"DATABASE")==0)
@@ -2338,39 +2338,20 @@ _printTocHeader(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDa
23382338
}
23392339

23402340
staticint
2341-
_printTocEntry(ArchiveHandle*AH,TocEntry*te,RestoreOptions*ropt,boolisData,boolownerAndACL)
2341+
_printTocEntry(ArchiveHandle*AH,TocEntry*te,RestoreOptions*ropt,boolisData,boolacl_pass)
23422342
{
23432343
/* Select schema as necessary */
23442344
_becomeOwner(AH,te);
23452345
_selectOutputSchema(AH,te->namespace);
2346-
if (strcmp(te->desc,"TABLE")==0&& !ownerAndACL)
2346+
if (strcmp(te->desc,"TABLE")==0&& !acl_pass)
23472347
_setWithOids(AH,te);
23482348

2349-
if (!ropt->noOwner&& !ropt->use_setsessauth&&ownerAndACL&&strlen(te->owner)>0&&strlen(te->dropStmt)>0&& (
2350-
strcmp(te->desc,"AGGREGATE")==0||
2351-
strcmp(te->desc,"CONVERSION")==0||
2352-
strcmp(te->desc,"DOMAIN")==0||
2353-
strcmp(te->desc,"FUNCTION")==0||
2354-
strcmp(te->desc,"OPERATOR")==0||
2355-
strcmp(te->desc,"OPERATOR CLASS")==0||
2356-
strcmp(te->desc,"TABLE")==0||
2357-
strcmp(te->desc,"TYPE")==0||
2358-
strcmp(te->desc,"VIEW")==0||
2359-
strcmp(te->desc,"SEQUENCE")==0||
2360-
(strcmp(te->desc,"SCHEMA")==0&&strcmp(te->tag,"public")==0)/* Only public schema */
2361-
))
2362-
{
2363-
char*temp=_getObjectFromDropStmt(te->dropStmt,te->desc);
2364-
_printTocHeader(AH,te,ropt,isData);
2365-
ahprintf(AH,"ALTER %s OWNER TO %s;\n\n",temp,fmtId(te->owner));
2366-
free (temp);
2367-
}
2368-
elseif (ownerAndACL&&strcmp(te->desc,"ACL")==0)
2349+
if (acl_pass&&strcmp(te->desc,"ACL")==0)
23692350
{
23702351
_printTocHeader(AH,te,ropt,isData);
23712352
ahprintf(AH,"%s\n\n",te->defn);
23722353
}
2373-
elseif (!ownerAndACL&&strlen(te->defn)>0)
2354+
elseif (!acl_pass&&strlen(te->defn)>0)
23742355
{
23752356
_printTocHeader(AH,te,ropt,isData);
23762357

@@ -2388,6 +2369,25 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat
23882369
else
23892370
{
23902371
ahprintf(AH,"%s\n\n",te->defn);
2372+
2373+
if (!ropt->noOwner&& !ropt->use_setsessauth&&strlen(te->owner)>0&&strlen(te->dropStmt)>0&& (
2374+
strcmp(te->desc,"AGGREGATE")==0||
2375+
strcmp(te->desc,"CONVERSION")==0||
2376+
strcmp(te->desc,"DOMAIN")==0||
2377+
strcmp(te->desc,"FUNCTION")==0||
2378+
strcmp(te->desc,"OPERATOR")==0||
2379+
strcmp(te->desc,"OPERATOR CLASS")==0||
2380+
strcmp(te->desc,"TABLE")==0||
2381+
strcmp(te->desc,"TYPE")==0||
2382+
strcmp(te->desc,"VIEW")==0||
2383+
strcmp(te->desc,"SEQUENCE")==0||
2384+
(strcmp(te->desc,"SCHEMA")==0&&strcmp(te->tag,"public")==0)/* Only public schema */
2385+
))
2386+
{
2387+
char*temp=_getObjectFromDropStmt(te->dropStmt,te->desc);
2388+
ahprintf(AH,"ALTER %s OWNER TO %s;\n\n",temp,fmtId(te->owner));
2389+
free (temp);
2390+
}
23912391
}
23922392
}
23932393
}

‎src/bin/pg_dump/pg_dump.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*by PostgreSQL
1313
*
1414
* IDENTIFICATION
15-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.381 2004/08/02 04:28:03 tgl Exp $
15+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.382 2004/08/04 17:13:03 tgl Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -2393,10 +2393,10 @@ getTables(int *numTables)
23932393
"d.classid = c.tableoid and d.objid = c.oid and "
23942394
"d.objsubid = 0 and "
23952395
"d.refclassid = c.tableoid and d.deptype = 'i') "
2396-
"where relkind in ('%c', '%c', '%c') "
2396+
"where relkind in ('%c', '%c', '%c', '%c') "
23972397
"order by c.oid",
23982398
RELKIND_SEQUENCE,
2399-
RELKIND_RELATION,RELKIND_SEQUENCE,RELKIND_VIEW);
2399+
RELKIND_RELATION,RELKIND_SEQUENCE,RELKIND_VIEW,RELKIND_COMPOSITE_TYPE);
24002400
}
24012401
elseif (g_fout->remoteVersion >=70300)
24022402
{
@@ -2419,10 +2419,10 @@ getTables(int *numTables)
24192419
"d.classid = c.tableoid and d.objid = c.oid and "
24202420
"d.objsubid = 0 and "
24212421
"d.refclassid = c.tableoid and d.deptype = 'i') "
2422-
"where relkind in ('%c', '%c', '%c') "
2422+
"where relkind in ('%c', '%c', '%c', '%c') "
24232423
"order by c.oid",
24242424
RELKIND_SEQUENCE,
2425-
RELKIND_RELATION,RELKIND_SEQUENCE,RELKIND_VIEW);
2425+
RELKIND_RELATION,RELKIND_SEQUENCE,RELKIND_VIEW,RELKIND_COMPOSITE_TYPE);
24262426
}
24272427
elseif (g_fout->remoteVersion >=70200)
24282428
{
@@ -4063,7 +4063,7 @@ dumpComment(Archive *fout, const char *target,
40634063
/*
40644064
* dumpTableComment --
40654065
*
4066-
* As above, but dump comments for both the specified table (orview)
4066+
* As above, but dump comments for both the specified table, vieworcomposite type
40674067
* and its columns.
40684068
*/
40694069
staticvoid
@@ -4864,6 +4864,7 @@ dumpCompositeType(Archive *fout, TypeInfo *tinfo)
48644864
inti_attname;
48654865
inti_atttypdefn;
48664866
inti;
4867+
TableInfo*tableInfo;
48674868

48684869
/* Set proper schema search path so type references list correctly */
48694870
selectSourceSchema(tinfo->dobj.namespace->dobj.name);
@@ -4928,7 +4929,6 @@ dumpCompositeType(Archive *fout, TypeInfo *tinfo)
49284929
tinfo->dobj.dependencies,tinfo->dobj.nDeps,
49294930
NULL,NULL);
49304931

4931-
49324932
/* Dump Type Comments */
49334933
resetPQExpBuffer(q);
49344934

@@ -4937,7 +4937,13 @@ dumpCompositeType(Archive *fout, TypeInfo *tinfo)
49374937
tinfo->dobj.namespace->dobj.name,tinfo->usename,
49384938
tinfo->dobj.catId,0,tinfo->dobj.dumpId);
49394939

4940+
/* Dump column comments */
4941+
tableInfo=findTableByOid(tinfo->typrelid);
4942+
if (tableInfo)
4943+
dumpTableComment(fout,tableInfo,"TABLE");
4944+
49404945
PQclear(res);
4946+
49414947
destroyPQExpBuffer(q);
49424948
destroyPQExpBuffer(delq);
49434949
destroyPQExpBuffer(query);
@@ -6432,7 +6438,7 @@ dumpTable(Archive *fout, TableInfo *tbinfo)
64326438
{
64336439
if (tbinfo->relkind==RELKIND_SEQUENCE)
64346440
dumpSequence(fout,tbinfo);
6435-
elseif (!dataOnly)
6441+
elseif (!dataOnly&&tbinfo->relkind!=RELKIND_COMPOSITE_TYPE)
64366442
dumpTableSchema(fout,tbinfo);
64376443

64386444
/* Handle the ACL here */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp