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 00a05d4c326eec02190bfda6f85a7e58734d4279
Author: Kevin Yeap <[email protected]>
AuthorDate: Fri Dec 15 14:47:23 2023 -0800

    pg_dump: fix --function-oid when --relation-oid is also used
    
    pg_dump does not correctly dump functions when both greenplum specific
    internal flags `--function-oid` and `--relation-oid` are used at the
    same time. This is because functions are being marked dumpable or not
    twice. The first time is by selectDumpableFunction and then again by
    selectDumpableObject. When `--relation-oid` is used, all namespaces are
    marked not dumpable which is why selectDumpableObject will mark the
    function to not be dumped.
    
    This must be a regression. The original commit that introduces greenplum
    specific selectDumpableFunction removes the usage of the more generic
    selectDumpableObject.
    
    selectDumpableFunction reference commit:
    
https://github.com/greenplum-db/gpdb/commit/318b86afc3eb5745f07ddfb390970b1769c63a1b
---
 gpMgmt/test/behave/mgmt_utils/environment.py    |  1 +
 gpMgmt/test/behave/mgmt_utils/minirepro.feature | 12 ++++++++++++
 src/bin/pg_dump/pg_dump.c                       |  1 -
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/gpMgmt/test/behave/mgmt_utils/environment.py 
b/gpMgmt/test/behave/mgmt_utils/environment.py
index d79f9c18acc..217583c9c4c 100644
--- a/gpMgmt/test/behave/mgmt_utils/environment.py
+++ b/gpMgmt/test/behave/mgmt_utils/environment.py
@@ -68,6 +68,7 @@ def before_feature(context, feature):
         dbconn.execSQL(context.conn, 'insert into t1 values(1, 2)')
         dbconn.execSQL(context.conn, 'insert into t2 values(1, 3)')
         dbconn.execSQL(context.conn, 'insert into t3 values(1, 4)')
+        dbconn.execSQL(context.conn, 'create or replace function select_one() 
returns integer as $$ select 1 $$ language sql')
         context.conn.commit()
 
     if 'gppkg' in feature.tags:
diff --git a/gpMgmt/test/behave/mgmt_utils/minirepro.feature 
b/gpMgmt/test/behave/mgmt_utils/minirepro.feature
index 15e9c666a51..03f098821ba 100644
--- a/gpMgmt/test/behave/mgmt_utils/minirepro.feature
+++ b/gpMgmt/test/behave/mgmt_utils/minirepro.feature
@@ -263,3 +263,15 @@ Feature: Dump minimum database objects that is related to 
the query
       And the output file "/tmp/out.sql" should contain "Table: t3, Attribute: 
f"
       And the output file "/tmp/out.sql" should be loaded to database 
"minidb_tmp" without error
       And the file "/tmp/in.sql" should be executed in database "minidb_tmp" 
without error
+
+    @minirepro_core
+    Scenario: Dump database objects of only functions
+      Given the file "/tmp/in.sql" exists and contains "SELECT select_one()"
+      And the file "/tmp/out.sql" does not exist
+      When the user runs "minirepro minireprodb -q /tmp/in.sql -f /tmp/out.sql"
+      Then the output file "/tmp/out.sql" should exist
+      And the output file "/tmp/out.sql" should contain "CREATE FUNCTION 
public.select_one() RETURNS integer"
+      And the output file "/tmp/out.sql" should contain "LANGUAGE sql"
+      And the output file "/tmp/out.sql" should contain "AS $$ select 1 $$;"
+      And the output file "/tmp/out.sql" should be loaded to database 
"minidb_tmp" without error
+      And the file "/tmp/in.sql" should be executed in database "minidb_tmp" 
without error
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index d09cd899445..d623077ccb0 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -6997,7 +6997,6 @@ getFuncs(Archive *fout, int *numFuncs)
 
                /* Decide whether we want to dump it */
                selectDumpableFunction(&finfo[i]);
-               selectDumpableObject(&(finfo[i].dobj), 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]

Reply via email to