Skip to content

pg_dump: stop overriding --function-oids with the namespace policy - #2175

Open
MisterRaindrop wants to merge 1 commit into
apache:mainfrom
MisterRaindrop:fix/pg-dump-function-oids
Open

MisterRaindrop wants to merge 1 commit into
apache:mainfrom
MisterRaindrop:fix/pg-dump-function-oids

Conversation

@MisterRaindrop

Copy link
Copy Markdown
Contributor

What does this PR do?

pg_dump --function-oids has not selected anything. getFuncs() called selectDumpableFunction() and then selectDumpableObject() on the same object, and the second call overwrote the decision with the parent namespace's dump_contains. Two consequences:

  • With --relation-oids (or -t) as well, every namespace is DUMP_COMPONENT_NONE (selectDumpableNamespace()), so the requested functions were dropped. That is how minirepro calls pg_dump (pg_dump -sxO db --relation-oids ... --function-oids ...), so minirepro never emitted a CREATE FUNCTION.
  • On its own, --function-oids dumped every function in a dumpable namespace, so the list had no effect.

The second call is gone and selectDumpableFunction() decides alone, as in Greenplum. It now checks extension membership first, as selectDumpableObject() did, and assigns DumpComponents rather than a bool. With no --function-oids, the outcome is the same as before: the namespace's dump_contains, with extension members left to their extension.

Split out of #1639 (originally ac20f61, by @tuhaihe).

Test Plan

Demo cluster (Rocky 8 build image), a database with tables t, u, functions f1, f2, select_one in public, s2.g, and a view; pg_dump from main and from this branch against the same database:

main this PR
--relation-oids t --function-oids f1 t only t, f1
--function-oids f1 f1, f2, s2.g (+ tables) f1 (+ tables)
--relation-oids 0 --function-oids f1 (minirepro's form) no function f1
minirepro -q "SELECT select_one()" no CREATE FUNCTION public.select_one() present
pg_dump -s and pg_dumpall -s, no selection options identical to main, apart from the random \restrict key

Behave's "Dump database objects of only functions" (minirepro.feature) covers this once the suite (#2170) is in.

Type of Change

  • Bug fix (non-breaking change)

Checklist

  • This PR contains AI-assisted code generation

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 apache#1639 (originally ac20f61).

@leborchuk leborchuk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

MisterRaindrop added a commit to MisterRaindrop/cloudberry that referenced this pull request Oct 23, 2026
The suite comes from apache#1639, where it ran with that PR's fixes. Here it
runs without them, and these scenarios fail until they land.  Tag them
@needs_fix and skip that tag in every job; each fix removes the tag from
the scenarios it makes pass, which is also how it shows they do.  A
comment beside each tag names the fix.

  analyzedb      1  0977ac5 (identifiers and pg.escape_string)
  gpactivatestandby
                 1  apache#1889 (forced activation after a clean shutdown)
  gpaddmirrors   2  mirror postgresql.conf check; not pinned down yet,
                    among b971d48, a3bfe47 and 8377856
  gpcheckcat    11  0bfc1d7
  gpinitstandby  2  apache#2172 (pg_basebackup EXCLUDE); without it the new
                    standby promotes itself
  gpinitsystem  19  b971d48
  gpmovemirrors  4  a3bfe47, 51955ac, 7056e02 (one of them a
                    Scenario Outline with four examples)
  gpstop         2  45a1155, 51955ac (the gpstop lock)
  minirepro      3  3fccb75 (tables a view reads), 51955ac,
                    apache#2175 (pg_dump --function-oids)

The commit hashes are those in apache#1639.  gprecoverseg is tagged as a
whole: without its fixes a scenario hangs and the job reaches its
120 minute timeout, so the scenarios that do fail cannot be told apart
from the ones never reached.  It comes back as the gprecoverseg fixes
land.
@Alena0704
Alena0704 self-requested a review October 24, 2026 17:52
@MisterRaindrop MisterRaindrop mentioned this pull request Oct 24, 2026
2 of 6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants