mirror of
https://github.com/postgres/postgres.git
synced 2025-06-04 12:42:24 +03:00
Fix dumping of casts and transforms using built-in functions
In pg_dump.c dumpCast() and dumpTransform(), we would happily ignore the cast or transform if it happened to use a built-in function because we weren't including the information about built-in functions when querying pg_proc from getFuncs(). Modify the query in getFuncs() to also gather information about functions which are used by user-defined casts and transforms (where "user-defined" means "has an OID >= FirstNormalObjectId"). This also adds to the TAP regression tests for 9.6 and master to cover these types of objects. Back-patch all the way for casts, back to 9.5 for transforms. Discussion: https://www.postgresql.org/message-id/flat/20160504183952.GE10850%40tamriel.snowman.net
This commit is contained in:
parent
fc03f7dd19
commit
1f2cfd26f5
@ -4204,7 +4204,9 @@ getFuncs(Archive *fout, int *numFuncs)
|
|||||||
* 3. Otherwise, we normally exclude functions in pg_catalog. However, if
|
* 3. Otherwise, we normally exclude functions in pg_catalog. However, if
|
||||||
* they're members of extensions and we are in binary-upgrade mode then
|
* they're members of extensions and we are in binary-upgrade mode then
|
||||||
* include them, since we want to dump extension members individually in
|
* include them, since we want to dump extension members individually in
|
||||||
* that mode.
|
* that mode. Also, if they are used by casts then we need to gather the
|
||||||
|
* information about them, though they won't be dumped if they are
|
||||||
|
* built-in.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (fout->remoteVersion >= 70300)
|
if (fout->remoteVersion >= 70300)
|
||||||
@ -4226,7 +4228,11 @@ getFuncs(Archive *fout, int *numFuncs)
|
|||||||
"\n AND ("
|
"\n AND ("
|
||||||
"\n pronamespace != "
|
"\n pronamespace != "
|
||||||
"(SELECT oid FROM pg_namespace "
|
"(SELECT oid FROM pg_namespace "
|
||||||
"WHERE nspname = 'pg_catalog')");
|
"WHERE nspname = 'pg_catalog')"
|
||||||
|
"\n OR EXISTS (SELECT 1 FROM pg_cast"
|
||||||
|
"\n WHERE pg_cast.oid > '%u'::oid"
|
||||||
|
"\n AND p.oid = pg_cast.castfunc)",
|
||||||
|
g_last_builtin_oid);
|
||||||
if (binary_upgrade && fout->remoteVersion >= 90100)
|
if (binary_upgrade && fout->remoteVersion >= 90100)
|
||||||
appendPQExpBuffer(query,
|
appendPQExpBuffer(query,
|
||||||
"\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
|
"\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
|
||||||
@ -10170,7 +10176,8 @@ dumpCast(Archive *fout, CastInfo *cast)
|
|||||||
{
|
{
|
||||||
funcInfo = findFuncByOid(cast->castfunc);
|
funcInfo = findFuncByOid(cast->castfunc);
|
||||||
if (funcInfo == NULL)
|
if (funcInfo == NULL)
|
||||||
return;
|
exit_horribly(NULL, "unable to find function definition for OID %u",
|
||||||
|
cast->castfunc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user