@@ -3462,7 +3462,10 @@ getAggregates(int *numAggs)
34623462 /* Make sure we are in proper schema */
34633463 selectSourceSchema ("pg_catalog" );
34643464
3465- /* find all user-defined aggregates */
3465+ /*
3466+ * Find all user-defined aggregates. See comment in getFuncs() for the
3467+ * rationale behind the filtering logic.
3468+ */
34663469
34673470 if (g_fout -> remoteVersion >= 80200 )
34683471 {
@@ -3471,11 +3474,20 @@ getAggregates(int *numAggs)
34713474 "pronargs, proargtypes, "
34723475 "(%s proowner) AS rolname, "
34733476 "proacl AS aggacl "
3474- "FROM pg_proc "
3475- "WHERE proisagg "
3476- "AND pronamespace != "
3477- "(SELECT oid FROM pg_namespace WHERE nspname = 'pg_catalog')" ,
3477+ "FROM pg_proc p "
3478+ "WHERE proisagg AND ("
3479+ "pronamespace != "
3480+ "(SELECT oid FROM pg_namespace "
3481+ "WHERE nspname = 'pg_catalog')" ,
34783482 username_subquery );
3483+ if (binary_upgrade && g_fout -> remoteVersion >= 90100 )
3484+ appendPQExpBuffer (query ,
3485+ " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
3486+ "classid = 'pg_proc'::regclass AND "
3487+ "objid = p.oid AND "
3488+ "refclassid = 'pg_extension'::regclass AND "
3489+ "deptype = 'e')" );
3490+ appendPQExpBuffer (query , ")" );
34793491 }
34803492 else if (g_fout -> remoteVersion >= 70300 )
34813493 {
@@ -3608,7 +3620,14 @@ getFuncs(int *numFuncs)
36083620 /* Make sure we are in proper schema */
36093621 selectSourceSchema ("pg_catalog" );
36103622
3611- /* find all user-defined funcs */
3623+ /*
3624+ * Find all user-defined functions. Normally we can exclude functions
3625+ * in pg_catalog, which is worth doing since there are several thousand
3626+ * of 'em. However, there are some extensions that create functions in
3627+ * pg_catalog. In normal dumps we can still ignore those --- but in
3628+ * binary-upgrade mode, we must dump the member objects of the extension,
3629+ * so be sure to fetch any such functions.
3630+ */
36123631
36133632 if (g_fout -> remoteVersion >= 70300 )
36143633 {
@@ -3617,12 +3636,20 @@ getFuncs(int *numFuncs)
36173636 "pronargs, proargtypes, prorettype, proacl, "
36183637 "pronamespace, "
36193638 "(%s proowner) AS rolname "
3620- "FROM pg_proc "
3621- "WHERE NOT proisagg "
3622- "AND pronamespace != "
3639+ "FROM pg_proc p "
3640+ "WHERE NOT proisagg AND ( "
3641+ "pronamespace != "
36233642 "(SELECT oid FROM pg_namespace "
36243643 "WHERE nspname = 'pg_catalog')" ,
36253644 username_subquery );
3645+ if (binary_upgrade && g_fout -> remoteVersion >= 90100 )
3646+ appendPQExpBuffer (query ,
3647+ " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
3648+ "classid = 'pg_proc'::regclass AND "
3649+ "objid = p.oid AND "
3650+ "refclassid = 'pg_extension'::regclass AND "
3651+ "deptype = 'e')" );
3652+ appendPQExpBuffer (query , ")" );
36263653 }
36273654 else if (g_fout -> remoteVersion >= 70100 )
36283655 {
@@ -13319,6 +13346,8 @@ getExtensionMembership(ExtensionInfo extinfo[], int numExtensions)
1331913346 */
1332013347 if (!binary_upgrade )
1332113348 dobj -> dump = false;
13349+ else
13350+ dobj -> dump = refdobj -> dump ;
1332213351 }
1332313352
1332413353 PQclear (res );
0 commit comments