12
12
* by PostgreSQL
13
13
*
14
14
* IDENTIFICATION
15
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.399 2005/01/11 05:14:13 tgl Exp $
15
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.400 2005/01/11 17:55:25 tgl Exp $
16
16
*
17
17
*-------------------------------------------------------------------------
18
18
*/
@@ -2349,8 +2349,13 @@ getTables(int *numTables)
2349
2349
* We include system catalogs, so that we can work if a user table is
2350
2350
* defined to inherit from a system catalog (pretty weird, but...)
2351
2351
*
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).
2354
2359
*
2355
2360
* Note: in this phase we should collect only a minimal amount of
2356
2361
* information about each table, basically just enough to decide if it
@@ -2380,10 +2385,11 @@ getTables(int *numTables)
2380
2385
"d.classid = c.tableoid and d.objid = c.oid and "
2381
2386
"d.objsubid = 0 and "
2382
2387
"d.refclassid = c.tableoid and d.deptype = 'i') "
2383
- "where relkind in ('%c', '%c', '%c') "
2388
+ "where relkind in ('%c', '%c', '%c', '%c' ) "
2384
2389
"order by c.oid" ,
2385
2390
RELKIND_SEQUENCE ,
2386
- RELKIND_RELATION , RELKIND_SEQUENCE , RELKIND_VIEW );
2391
+ RELKIND_RELATION , RELKIND_SEQUENCE ,
2392
+ RELKIND_VIEW , RELKIND_COMPOSITE_TYPE );
2387
2393
}
2388
2394
else if (g_fout -> remoteVersion >= 70300 )
2389
2395
{
@@ -2406,10 +2412,11 @@ getTables(int *numTables)
2406
2412
"d.classid = c.tableoid and d.objid = c.oid and "
2407
2413
"d.objsubid = 0 and "
2408
2414
"d.refclassid = c.tableoid and d.deptype = 'i') "
2409
- "where relkind in ('%c', '%c', '%c') "
2415
+ "where relkind in ('%c', '%c', '%c', '%c' ) "
2410
2416
"order by c.oid" ,
2411
2417
RELKIND_SEQUENCE ,
2412
- RELKIND_RELATION , RELKIND_SEQUENCE , RELKIND_VIEW );
2418
+ RELKIND_RELATION , RELKIND_SEQUENCE ,
2419
+ RELKIND_VIEW , RELKIND_COMPOSITE_TYPE );
2413
2420
}
2414
2421
else if (g_fout -> remoteVersion >= 70200 )
2415
2422
{
@@ -2545,7 +2552,9 @@ getTables(int *numTables)
2545
2552
* serial columns are never dumpable on their own; we will
2546
2553
* transpose their owning table's dump flag to them below.
2547
2554
*/
2548
- if (OidIsValid (tblinfo [i ].owning_tab ))
2555
+ if (tblinfo [i ].relkind == RELKIND_COMPOSITE_TYPE )
2556
+ tblinfo [i ].dump = false;
2557
+ else if (OidIsValid (tblinfo [i ].owning_tab ))
2549
2558
tblinfo [i ].dump = false;
2550
2559
else
2551
2560
selectDumpableTable (& tblinfo [i ]);
@@ -7796,7 +7805,19 @@ getDependencies(void)
7796
7805
continue ;
7797
7806
}
7798
7807
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 );
7800
7821
}
7801
7822
7802
7823
PQclear (res );
0 commit comments