pg_upgrade is a little over-keen about checking for shared libraries
that back functions. In particular, it checks for libraries that support
functions created in pg_catalog, even if pg_dump doesn't export the
function.
The attached patch mimics the filter that pg_dump uses for functions so
that only the relevant libraries are checked.
This would remove the need for a particularly ugly hack in making the
9.1 backport of JSON binary upgradeable.
cheers
andrew
*** a/contrib/pg_upgrade/function.c
--- b/contrib/pg_upgrade/function.c
***************
*** 11,16 ****
--- 11,17 ----
#include "pg_upgrade.h"
+ #include "pqexpbuffer.h"
#include "access/transam.h"
#define PG_UPGRADE_SUPPORT "$libdir/pg_upgrade_support"
***************
*** 141,157 **** get_loadable_libraries(void)
{
DbInfo *active_db = &old_cluster.dbarr.dbs[dbnum];
PGconn *conn = connectToServer(&old_cluster, active_db->db_name);
! /* Fetch all libraries referenced in this DB */
! ress[dbnum] = executeQueryOrDie(conn,
! "SELECT DISTINCT probin "
! "FROM pg_catalog.pg_proc "
! "WHERE prolang = 13 /* C */ AND "
! "probin IS NOT NULL AND "
! "oid >= %u;",
! FirstNormalObjectId);
totaltups += PQntuples(ress[dbnum]);
PQfinish(conn);
}
--- 142,183 ----
{
DbInfo *active_db = &old_cluster.dbarr.dbs[dbnum];
PGconn *conn = connectToServer(&old_cluster, active_db->db_name);
+ PQExpBufferData query;
! initPQExpBuffer(&query);
!
! /*
! * pg_dump doesn't export functions in pg_catalog unless (and only in
! * 9.1 and later) they are part of an extension. We therefore make
! * the same exclusions when choosing which libraries to test for.
! */
!
! appendPQExpBufferStr(&query,
! "SELECT DISTINCT probin "
! "FROM pg_catalog.pg_proc p "
! "WHERE prolang = 13 /* C */ AND"
! "probin IS NOT NULL AND "
! "oid >= %u AND ("
! "pronamespace != "
! "(SELECT oid FROM pg_catalog.pg_namespace "
! "WHERE nspname = 'pg_catalog')");
!
! if (GET_MAJOR_VERSION(old_cluster.major_version) < 901)
! appendPQExpBufferStr(&query,
! "OR EXISTS(SELECT 1 FROM pg_catalog.pg_depend "
! "WHERE classid = 'pg_proc'::regclass AND "
! "objid = p.oid AND "
! "refclassid = 'pg_extension'::regclass AND "
! "deptype = 'e')");
!
! appendPQExpBufferStr(&query,")");
!
! /* Fetch all required libraries referenced in this DB */
! ress[dbnum] = executeQueryOrDie(conn, query.data, FirstNormalObjectId);
totaltups += PQntuples(ress[dbnum]);
+ termPQExpBuffer(&query);
+
PQfinish(conn);
}
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers