From 3a4b2a633a7a911e0b6dac2abcc5a3b2170d9d01 Mon Sep 17 00:00:00 2001 From: Dianjin Wang Date: Sat, 12 Sep 2026 00:42:31 +0800 Subject: [PATCH] pg_dump: stop overriding --function-oids with the namespace policy getFuncs() called selectDumpableFunction() and then immediately called selectDumpableObject() on the same object, which overwrites dobj->dump with the parent namespace's dump_contains. --relation-oids sets every namespace to DUMP_COMPONENT_NONE (see selectDumpableNamespace), so a function named by --function-oids was dropped from the dump whenever --relation-oids was also given -- which is how minirepro always calls pg_dump: pg_dump -sxO db --relation-oids 0 --function-oids 17021 emitted no CREATE FUNCTION at all. Drop the second call and let selectDumpableFunction() decide, as Greenplum does. It now takes the archive so it can still give extension membership the last word, and assigns DumpComponents bitmasks rather than a bool. Exercised by minirepro.feature:282. Split out of #1639 (originally ac20f618cca). --- src/bin/pg_dump/pg_dump.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index b024acaf768..127ae5574a0 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -2191,8 +2191,11 @@ selectDumpableType(TypeInfo *tyinfo, Archive *fout) * Mark a function as to be dumped or not */ static void -selectDumpableFunction(FuncInfo *finfo) +selectDumpableFunction(FuncInfo *finfo, Archive *fout) { + if (checkExtensionMembership(&finfo->dobj, fout)) + return; /* extension membership overrides all else */ + /* * If specific functions are being dumped, dump just those functions; else, dump * according to the parent namespace's dump flag if parent namespace is not null; @@ -2200,11 +2203,12 @@ selectDumpableFunction(FuncInfo *finfo) */ if (function_include_oids.head != NULL) finfo->dobj.dump = simple_oid_list_member(&function_include_oids, - finfo->dobj.catId.oid); + finfo->dobj.catId.oid) ? + DUMP_COMPONENT_ALL : DUMP_COMPONENT_NONE; else if (finfo->dobj.namespace) - finfo->dobj.dump = finfo->dobj.namespace->dobj.dump; + finfo->dobj.dump = finfo->dobj.namespace->dobj.dump_contains; else - finfo->dobj.dump = true; + finfo->dobj.dump = DUMP_COMPONENT_ALL; } /* @@ -7299,8 +7303,7 @@ getFuncs(Archive *fout, int *numFuncs) finfo[i].postponed_def = false; /* might get set during sort */ /* Decide whether we want to dump it */ - selectDumpableFunction(&finfo[i]); - selectDumpableObject(&(finfo[i].dobj), fout); + selectDumpableFunction(&finfo[i], fout); /* Mark whether function has an ACL */ if (!PQgetisnull(res, i, i_proacl))