mirror of
https://github.com/postgres/postgres.git
synced 2025-06-10 09:21:54 +03:00
Fix pg_dump to dump casts between auto-generated types.
The heuristic for when to dump a cast failed for a cast between table rowtypes, as reported by Frédéric Rejol. Fix it by setting the "dump" flag for such a type the same way as the flag is set for the underlying table or base type. This won't result in the auto-generated type appearing in the output, since setting its objType to DO_DUMMY_TYPE unconditionally suppresses that. But it will result in dumpCast doing what was intended. Back-patch to 8.3. The 8.2 code is rather different in this area, and it doesn't seem worth any risk to fix a corner case that nobody has stumbled on before.
This commit is contained in:
parent
8c1501b292
commit
35d6ce97e7
@ -125,7 +125,7 @@ getSchemaData(int *numTablesPtr)
|
|||||||
funinfo = getFuncs(&numFuncs);
|
funinfo = getFuncs(&numFuncs);
|
||||||
funinfoindex = buildIndexArray(funinfo, numFuncs, sizeof(FuncInfo));
|
funinfoindex = buildIndexArray(funinfo, numFuncs, sizeof(FuncInfo));
|
||||||
|
|
||||||
/* this must be after getFuncs */
|
/* this must be after getTables and getFuncs */
|
||||||
if (g_verbose)
|
if (g_verbose)
|
||||||
write_msg(NULL, "reading user-defined types\n");
|
write_msg(NULL, "reading user-defined types\n");
|
||||||
typinfo = getTypes(&numTypes);
|
typinfo = getTypes(&numTypes);
|
||||||
|
@ -1093,8 +1093,11 @@ selectDumpableTable(TableInfo *tbinfo)
|
|||||||
* If it's a table's rowtype or an autogenerated array type, we also apply a
|
* 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
|
* 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
|
* 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
|
* up into the datatype part of the dump order.) We still set the object's
|
||||||
* first to ensure the objType change is applied regardless of namespace etc.
|
* dump flag; that's not going to cause the dummy type to be dumped, but we
|
||||||
|
* need it so that casts involving such types will be dumped correctly -- see
|
||||||
|
* dumpCast. This means the flag should be set the same as for the underlying
|
||||||
|
* object (the table or base type).
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
selectDumpableType(TypeInfo *tyinfo)
|
selectDumpableType(TypeInfo *tyinfo)
|
||||||
@ -1103,19 +1106,30 @@ selectDumpableType(TypeInfo *tyinfo)
|
|||||||
if (OidIsValid(tyinfo->typrelid) &&
|
if (OidIsValid(tyinfo->typrelid) &&
|
||||||
tyinfo->typrelkind != RELKIND_COMPOSITE_TYPE)
|
tyinfo->typrelkind != RELKIND_COMPOSITE_TYPE)
|
||||||
{
|
{
|
||||||
tyinfo->dobj.dump = false;
|
TableInfo *tytable = findTableByOid(tyinfo->typrelid);
|
||||||
|
|
||||||
tyinfo->dobj.objType = DO_DUMMY_TYPE;
|
tyinfo->dobj.objType = DO_DUMMY_TYPE;
|
||||||
|
if (tytable != NULL)
|
||||||
|
tyinfo->dobj.dump = tytable->dobj.dump;
|
||||||
|
else
|
||||||
|
tyinfo->dobj.dump = false;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* skip auto-generated array types */
|
/* skip auto-generated array types */
|
||||||
else if (tyinfo->isArray)
|
if (tyinfo->isArray)
|
||||||
{
|
{
|
||||||
tyinfo->dobj.dump = false;
|
|
||||||
tyinfo->dobj.objType = DO_DUMMY_TYPE;
|
tyinfo->dobj.objType = DO_DUMMY_TYPE;
|
||||||
|
/*
|
||||||
|
* Fall through to set the dump flag; we assume that the subsequent
|
||||||
|
* rules will do the same thing as they would for the array's base
|
||||||
|
* type. (We cannot reliably look up the base type here, since
|
||||||
|
* getTypes may not have processed it yet.)
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/* dump only types in dumpable namespaces */
|
/* dump only types in dumpable namespaces */
|
||||||
else if (!tyinfo->dobj.namespace->dobj.dump)
|
if (!tyinfo->dobj.namespace->dobj.dump)
|
||||||
tyinfo->dobj.dump = false;
|
tyinfo->dobj.dump = false;
|
||||||
|
|
||||||
/* skip undefined placeholder types */
|
/* skip undefined placeholder types */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user