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

Commit015cda4

Browse files
committed
Fix pg_dump to dump casts between auto-generated types.
The heuristic for when to dump a cast failed for a cast between tablerowtypes, as reported by Frédéric Rejol. Fix it by settingthe "dump" flag for such a type the same way as the flag is set for theunderlying table or base type. This won't result in the auto-generatedtype appearing in the output, since setting its objType to DO_DUMMY_TYPEunconditionally suppresses that. But it will result in dumpCast doing whatwas intended.Back-patch to 8.3. The 8.2 code is rather different in this area, and itdoesn't seem worth any risk to fix a corner case that nobody has stumbledon before.
1 parent9ca46f5 commit015cda4

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

‎src/bin/pg_dump/common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ getSchemaData(int *numTablesPtr)
131131
funinfo=getFuncs(&numFuncs);
132132
funinfoindex=buildIndexArray(funinfo,numFuncs,sizeof(FuncInfo));
133133

134-
/* this must be after getFuncs */
134+
/* this must be aftergetTables andgetFuncs */
135135
if (g_verbose)
136136
write_msg(NULL,"reading user-defined types\n");
137137
typinfo=getTypes(&numTypes);

‎src/bin/pg_dump/pg_dump.c

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,8 +1021,11 @@ selectDumpableTable(TableInfo *tbinfo)
10211021
* If it's a table's rowtype or an autogenerated array type, we also apply a
10221022
* special type code to facilitate sorting into the desired order.(We don't
10231023
* want to consider those to be ordinary types because that would bring tables
1024-
* up into the datatype part of the dump order.) Those tests should be made
1025-
* first to ensure the objType change is applied regardless of namespace etc.
1024+
* up into the datatype part of the dump order.) We still set the object's
1025+
* dump flag; that's not going to cause the dummy type to be dumped, but we
1026+
* need it so that casts involving such types will be dumped correctly -- see
1027+
* dumpCast. This means the flag should be set the same as for the underlying
1028+
* object (the table or base type).
10261029
*/
10271030
staticvoid
10281031
selectDumpableType(TypeInfo*tyinfo)
@@ -1031,19 +1034,30 @@ selectDumpableType(TypeInfo *tyinfo)
10311034
if (OidIsValid(tyinfo->typrelid)&&
10321035
tyinfo->typrelkind!=RELKIND_COMPOSITE_TYPE)
10331036
{
1034-
tyinfo->dobj.dump= false;
1037+
TableInfo*tytable=findTableByOid(tyinfo->typrelid);
1038+
10351039
tyinfo->dobj.objType=DO_DUMMY_TYPE;
1040+
if (tytable!=NULL)
1041+
tyinfo->dobj.dump=tytable->dobj.dump;
1042+
else
1043+
tyinfo->dobj.dump= false;
1044+
return;
10361045
}
10371046

10381047
/* skip auto-generated array types */
1039-
elseif (tyinfo->isArray)
1048+
if (tyinfo->isArray)
10401049
{
1041-
tyinfo->dobj.dump= false;
10421050
tyinfo->dobj.objType=DO_DUMMY_TYPE;
1051+
/*
1052+
* Fall through to set the dump flag; we assume that the subsequent
1053+
* rules will do the same thing as they would for the array's base
1054+
* type. (We cannot reliably look up the base type here, since
1055+
* getTypes may not have processed it yet.)
1056+
*/
10431057
}
10441058

10451059
/* dump only types in dumpable namespaces */
1046-
elseif (!tyinfo->dobj.namespace->dobj.dump)
1060+
if (!tyinfo->dobj.namespace->dobj.dump)
10471061
tyinfo->dobj.dump= false;
10481062

10491063
/* skip undefined placeholder types */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp