mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
Fix a pg_dump output ordering problem introduced in 8.3 by the addition of
array types for composite types. Although pg_dump understood it wasn't supposed to dump these array types as separate objects, it must include them in the dependency ordering analysis, and it was improperly assigning them the same relatively-high sort priority as regular types. This resulted in effectively moving composite types and tables up to that same high priority, which broke any ordering requirements that weren't explicitly enforced by dependencies. In particular user-defined operator classes, which should come out before tables, failed to do so. Per report from Brendan Jurd. In passing, also fix an ill-considered decision to give text search objects the same sort priority as functions and operators --- the sort result looks a lot nicer if different object types are kept separate. The recent foreign-data patch had copied that decision, making the sort ordering even messier :-(
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
* by PostgreSQL
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.513 2009/01/06 18:01:57 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.514 2009/01/18 20:44:45 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -1008,28 +1008,39 @@ selectDumpableTable(TableInfo *tbinfo)
|
||||
/*
|
||||
* selectDumpableType: policy-setting subroutine
|
||||
* Mark a type as to be dumped or not
|
||||
*
|
||||
* If it's a table's rowtype or an autogenerated array type, we also apply a
|
||||
* special type code to facilitate sorting into the desired order. (We don't
|
||||
* want to consider those to be ordinary types because that would bring tables
|
||||
* up into the datatype part of the dump order.) Those tests should be made
|
||||
* first to ensure the objType change is applied regardless of namespace etc.
|
||||
*/
|
||||
static void
|
||||
selectDumpableType(TypeInfo *tinfo)
|
||||
{
|
||||
/* Dump only types in dumpable namespaces */
|
||||
if (!tinfo->dobj.namespace->dobj.dump)
|
||||
tinfo->dobj.dump = false;
|
||||
|
||||
/* skip complex types, except for standalone composite types */
|
||||
/* (note: this test should now be unnecessary) */
|
||||
else if (OidIsValid(tinfo->typrelid) &&
|
||||
tinfo->typrelkind != RELKIND_COMPOSITE_TYPE)
|
||||
if (OidIsValid(tinfo->typrelid) &&
|
||||
tinfo->typrelkind != RELKIND_COMPOSITE_TYPE)
|
||||
{
|
||||
tinfo->dobj.dump = false;
|
||||
tinfo->dobj.objType = DO_DUMMY_TYPE;
|
||||
}
|
||||
|
||||
/* skip auto-generated array types */
|
||||
else if (tinfo->isArray)
|
||||
{
|
||||
tinfo->dobj.dump = false;
|
||||
tinfo->dobj.objType = DO_DUMMY_TYPE;
|
||||
}
|
||||
|
||||
/* dump only types in dumpable namespaces */
|
||||
else if (!tinfo->dobj.namespace->dobj.dump)
|
||||
tinfo->dobj.dump = false;
|
||||
|
||||
/* skip undefined placeholder types */
|
||||
else if (!tinfo->isDefined)
|
||||
tinfo->dobj.dump = false;
|
||||
|
||||
/* skip auto-generated array types */
|
||||
else if (tinfo->isArray)
|
||||
tinfo->dobj.dump = false;
|
||||
|
||||
else
|
||||
tinfo->dobj.dump = true;
|
||||
}
|
||||
@@ -2310,16 +2321,6 @@ getTypes(int *numTypes)
|
||||
tinfo[i].typtype = *PQgetvalue(res, i, i_typtype);
|
||||
tinfo[i].shellType = NULL;
|
||||
|
||||
/*
|
||||
* If it's a table's rowtype, use special type code to facilitate
|
||||
* sorting into the desired order. (We don't want to consider it an
|
||||
* ordinary type because that would bring the table up into the
|
||||
* datatype part of the dump order.)
|
||||
*/
|
||||
if (OidIsValid(tinfo[i].typrelid) &&
|
||||
tinfo[i].typrelkind != RELKIND_COMPOSITE_TYPE)
|
||||
tinfo[i].dobj.objType = DO_TABLE_TYPE;
|
||||
|
||||
if (strcmp(PQgetvalue(res, i, i_typisdefined), "t") == 0)
|
||||
tinfo[i].isDefined = true;
|
||||
else
|
||||
@@ -5836,8 +5837,8 @@ dumpDumpableObject(Archive *fout, DumpableObject *dobj)
|
||||
case DO_TABLE_DATA:
|
||||
dumpTableData(fout, (TableDataInfo *) dobj);
|
||||
break;
|
||||
case DO_TABLE_TYPE:
|
||||
/* table rowtypes are never dumped separately */
|
||||
case DO_DUMMY_TYPE:
|
||||
/* table rowtypes and array types are never dumped separately */
|
||||
break;
|
||||
case DO_TSPARSER:
|
||||
dumpTSParser(fout, (TSParserInfo *) dobj);
|
||||
|
Reference in New Issue
Block a user