@@ -4481,19 +4481,22 @@ getFuncs(Archive *fout, int *numFuncs)
44814481selectSourceSchema (fout ,"pg_catalog" );
44824482
44834483/*
4484- * Find all user-defined functions. Normally we can exclude functions in
4485- * pg_catalog, which is worth doing since there are several thousand of
4486- * 'em. However, there are some extensions that create functions in
4487- * pg_catalog. In normal dumps we can still ignore those --- but in
4488- * binary-upgrade mode, we must dump the member objects of the extension,
4489- * so be sure to fetch any such functions.
4484+ * Find all interesting functions. This is a bit complicated:
44904485 *
4491- * Also, in 9.2 and up, exclude functions that are internally dependent on
4492- * something else, since presumably those will be created as a result of
4493- * creating the something else. This currently only acts to suppress
4494- * constructor functions for range types. Note that this is OK only
4495- * because the constructors don't have any dependencies the range type
4496- * doesn't have; otherwise we might not get creation ordering correct.
4486+ * 1. Always exclude aggregates; those are handled elsewhere.
4487+ *
4488+ * 2. Always exclude functions that are internally dependent on something
4489+ * else, since presumably those will be created as a result of creating
4490+ * the something else. This currently acts only to suppress constructor
4491+ * functions for range types (so we only need it in 9.2 and up). Note
4492+ * this is OK only because the constructors don't have any dependencies
4493+ * the range type doesn't have; otherwise we might not get creation
4494+ * ordering correct.
4495+ *
4496+ * 3. Otherwise, we normally exclude functions in pg_catalog. However, if
4497+ * they're members of extensions and we are in binary-upgrade mode then
4498+ * include them, since we want to dump extension members individually in
4499+ * that mode.
44974500 */
44984501
44994502if (fout -> remoteVersion >=70300 )
@@ -4504,16 +4507,18 @@ getFuncs(Archive *fout, int *numFuncs)
45044507"pronamespace, "
45054508"(%s proowner) AS rolname "
45064509"FROM pg_proc p "
4507- "WHERE NOT proisagg AND ("
4508- "pronamespace != "
4509- "(SELECT oid FROM pg_namespace "
4510- "WHERE nspname = 'pg_catalog')" ,
4510+ "WHERE NOT proisagg" ,
45114511username_subquery );
45124512if (fout -> remoteVersion >=90200 )
45134513appendPQExpBufferStr (query ,
45144514"\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
45154515"WHERE classid = 'pg_proc'::regclass AND "
45164516"objid = p.oid AND deptype = 'i')" );
4517+ appendPQExpBufferStr (query ,
4518+ "\n AND ("
4519+ "\n pronamespace != "
4520+ "(SELECT oid FROM pg_namespace "
4521+ "WHERE nspname = 'pg_catalog')" );
45174522if (dopt -> binary_upgrade && fout -> remoteVersion >=90100 )
45184523appendPQExpBufferStr (query ,
45194524"\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "