This is an automated email from the ASF dual-hosted git repository. tuhaihe pushed a commit to branch REL_2_STABLE in repository https://gitbox.apache.org/repos/asf/cloudberry.git
commit 39cb75073d2cc7b0e6f82e770a9cbb3906b922a5 Author: Brent Doil <[email protected]> AuthorDate: Fri Jan 5 19:55:41 2024 -0500 Fix dumping funcs/aggs with --function-oids flag. Commit 992b4dd fixes a pg_dump regression when using --function-oid where functions were incorrectly being marked to not dump. However, this fix revealed a second pg_dump regression with selectDumpableFunction which was being masked by the first regression. selectDumpableFunction now needed updating to work with the new method of dumping that uses bit masking that was backported in github.com/greenplum-db/gpdb/commits/07a3ffef6422275f76818d9c445c31495460889a. It also needed updating to work with function dumping when extensions are involved. selectDumpableAggregate was created so aggregate dumping works as intended when using --function-oid on an aggregate function. This is necessary because pg_dump treats aggregates separately from functions. See the comment in getFuncs for details. --- src/bin/pg_dump/pg_dump.c | 43 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index d623077ccb0..96026aa8ab4 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -2153,20 +2153,49 @@ 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; * else, always dump the function. */ - if (function_include_oids.head != NULL) - finfo->dobj.dump = simple_oid_list_member(&function_include_oids, - finfo->dobj.catId.oid); + if (function_include_oids.head != NULL && + simple_oid_list_member(&function_include_oids, finfo->dobj.catId.oid)) + finfo->dobj.dump = DUMP_COMPONENT_ALL; else if (finfo->dobj.namespace) finfo->dobj.dump = finfo->dobj.namespace->dobj.dump; else - finfo->dobj.dump = true; + finfo->dobj.dump = DUMP_COMPONENT_ALL; +} + +/* + * selectDumpableAggregate: policy-setting subroutine + * Mark a function as to be dumped or not + */ +static void +selectDumpableAggregate(AggInfo *agginfo, Archive *fout) +{ + + if (checkExtensionMembership(&agginfo->aggfn.dobj, fout)) + return; /* extension membership overrides all else */ + + /* + * If specific aggregates are being dumped, dump just those aggregates; else, dump + * according to the parent namespace's dump flag if parent namespace is not null; + * else, always dump the function. + */ + if (function_include_oids.head != NULL && + simple_oid_list_member(&function_include_oids, agginfo->aggfn.dobj.catId.oid)) + agginfo->aggfn.dobj.dump = DUMP_COMPONENT_ALL; + else if (agginfo->aggfn.dobj.namespace) + agginfo->aggfn.dobj.dump = agginfo->aggfn.dobj.namespace->dobj.dump; + else + agginfo->aggfn.dobj.dump = DUMP_COMPONENT_ALL; } /* @@ -6663,7 +6692,7 @@ getAggregates(Archive *fout, int *numAggs) } /* Decide whether we want to dump it */ - selectDumpableObject(&(agginfo[i].aggfn.dobj), fout); + selectDumpableAggregate(&(agginfo[i]), fout); /* Mark whether aggregate has an ACL */ if (!PQgetisnull(res, i, i_aggacl)) @@ -6996,7 +7025,7 @@ getFuncs(Archive *fout, int *numFuncs) } /* Decide whether we want to dump it */ - selectDumpableFunction(&finfo[i]); + selectDumpableFunction(&finfo[i], fout); /* Mark whether function has an ACL */ if (!PQgetisnull(res, i, i_proacl)) --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
