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

Commit5f0a468

Browse files
committed
Fix tracking of dump-order dependencies for stand-alone composite types.
Per report from Robert Koepferl.
1 parent5b354d2 commit5f0a468

File tree

1 file changed

+30
-9
lines changed

1 file changed

+30
-9
lines changed

‎src/bin/pg_dump/pg_dump.c

Lines changed: 30 additions & 9 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.399 2005/01/1105:14:13 tgl Exp $
15+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.400 2005/01/1117:55:25 tgl Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -2349,8 +2349,13 @@ getTables(int *numTables)
23492349
* We include system catalogs, so that we can work if a user table is
23502350
* defined to inherit from a system catalog (pretty weird, but...)
23512351
*
2352-
* We ignore tables that are not type 'r' (ordinary relation) or 'S'
2353-
* (sequence) or 'v' (view).
2352+
* We ignore tables that are not type 'r' (ordinary relation), 'S'
2353+
* (sequence), 'v' (view), or 'c' (composite type).
2354+
*
2355+
* Composite-type table entries won't be dumped as such, but we have
2356+
* to make a DumpableObject for them so that we can track dependencies
2357+
* of the composite type (pg_depend entries for columns of the composite
2358+
* type link to the pg_class entry not the pg_type entry).
23542359
*
23552360
* Note: in this phase we should collect only a minimal amount of
23562361
* information about each table, basically just enough to decide if it
@@ -2380,10 +2385,11 @@ getTables(int *numTables)
23802385
"d.classid = c.tableoid and d.objid = c.oid and "
23812386
"d.objsubid = 0 and "
23822387
"d.refclassid = c.tableoid and d.deptype = 'i') "
2383-
"where relkind in ('%c', '%c', '%c') "
2388+
"where relkind in ('%c', '%c', '%c', '%c') "
23842389
"order by c.oid",
23852390
RELKIND_SEQUENCE,
2386-
RELKIND_RELATION,RELKIND_SEQUENCE,RELKIND_VIEW);
2391+
RELKIND_RELATION,RELKIND_SEQUENCE,
2392+
RELKIND_VIEW,RELKIND_COMPOSITE_TYPE);
23872393
}
23882394
elseif (g_fout->remoteVersion >=70300)
23892395
{
@@ -2406,10 +2412,11 @@ getTables(int *numTables)
24062412
"d.classid = c.tableoid and d.objid = c.oid and "
24072413
"d.objsubid = 0 and "
24082414
"d.refclassid = c.tableoid and d.deptype = 'i') "
2409-
"where relkind in ('%c', '%c', '%c') "
2415+
"where relkind in ('%c', '%c', '%c', '%c') "
24102416
"order by c.oid",
24112417
RELKIND_SEQUENCE,
2412-
RELKIND_RELATION,RELKIND_SEQUENCE,RELKIND_VIEW);
2418+
RELKIND_RELATION,RELKIND_SEQUENCE,
2419+
RELKIND_VIEW,RELKIND_COMPOSITE_TYPE);
24132420
}
24142421
elseif (g_fout->remoteVersion >=70200)
24152422
{
@@ -2545,7 +2552,9 @@ getTables(int *numTables)
25452552
* serial columns are never dumpable on their own; we will
25462553
* transpose their owning table's dump flag to them below.
25472554
*/
2548-
if (OidIsValid(tblinfo[i].owning_tab))
2555+
if (tblinfo[i].relkind==RELKIND_COMPOSITE_TYPE)
2556+
tblinfo[i].dump= false;
2557+
elseif (OidIsValid(tblinfo[i].owning_tab))
25492558
tblinfo[i].dump= false;
25502559
else
25512560
selectDumpableTable(&tblinfo[i]);
@@ -7796,7 +7805,19 @@ getDependencies(void)
77967805
continue;
77977806
}
77987807

7799-
addObjectDependency(dobj,refdobj->dumpId);
7808+
/*
7809+
* Ordinarily, table rowtypes have implicit dependencies on their
7810+
* tables. However, for a composite type the implicit dependency
7811+
* goes the other way in pg_depend; which is the right thing for
7812+
* DROP but it doesn't produce the dependency ordering we need.
7813+
* So in that one case, we reverse the direction of the dependency.
7814+
*/
7815+
if (deptype=='i'&&
7816+
dobj->objType==DO_TABLE&&
7817+
refdobj->objType==DO_TYPE)
7818+
addObjectDependency(refdobj,dobj->dumpId);
7819+
else/* normal case */
7820+
addObjectDependency(dobj,refdobj->dumpId);
78007821
}
78017822

78027823
PQclear(res);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp