* 3. Otherwise, we normally exclude functions in pg_catalog. However, if
* they're members of extensions and we are in binary-upgrade mode then
* include them, since we want to dump extension members individually in
- * that mode.
+ * that mode. Also, if they are used by casts or transforms then we need
+ * to gather the information about them, though they won't be dumped if
+ * they are built-in.
*/
if (fout->remoteVersion >= 70300)
"\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
"WHERE classid = 'pg_proc'::regclass AND "
"objid = p.oid AND deptype = 'i')");
- appendPQExpBufferStr(query,
+ appendPQExpBuffer(query,
"\n AND ("
"\n pronamespace != "
"(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 (fout->remoteVersion >= 90500)
+ appendPQExpBuffer(query,
+ "\n OR EXISTS (SELECT 1 FROM pg_transform"
+ "\n WHERE pg_transform.oid > %u::oid"
+ "\n AND (p.oid = pg_transform.trffromsql"
+ "\n OR p.oid = pg_transform.trftosql))",
+ g_last_builtin_oid);
+
if (dopt->binary_upgrade && fout->remoteVersion >= 90100)
appendPQExpBufferStr(query,
"\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
{
funcInfo = findFuncByOid(cast->castfunc);
if (funcInfo == NULL)
- return;
+ exit_horribly(NULL, "unable to find function definition for OID %u",
+ cast->castfunc);
}
/*
{
fromsqlFuncInfo = findFuncByOid(transform->trffromsql);
if (fromsqlFuncInfo == NULL)
- return;
+ exit_horribly(NULL, "unable to find function definition for OID %u",
+ transform->trffromsql);
}
if (OidIsValid(transform->trftosql))
{
tosqlFuncInfo = findFuncByOid(transform->trftosql);
if (tosqlFuncInfo == NULL)
- return;
+ exit_horribly(NULL, "unable to find function definition for OID %u",
+ transform->trftosql);
}
/* Make sure we are in proper schema (needed for getFormattedTypeName) */