From 0d723fd216d8ce61eeecc1b25650dad5b31cc7bd Mon Sep 17 00:00:00 2001 From: teooooozhang Date: Mon, 27 Mar 2023 15:15:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=98=E5=82=A8=E8=BF=87=E7=A8=8B=E5=AD=98?= =?UTF-8?q?=E5=9C=A8comment=E6=97=B6=EF=BC=8Cgs=5Fdump=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E8=AF=AD=E5=8F=A5=E9=94=99=E8=AF=AF=E5=AF=BC=E8=87=B4=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E5=AF=BC=E5=85=A5=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bin/pg_dump/pg_dump.cpp | 6 +++++- src/test/regress/input/gs_dump_tableof.source | 7 +++++++ src/test/regress/output/gs_dump_tableof.source | 10 ++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/bin/pg_dump/pg_dump.cpp b/src/bin/pg_dump/pg_dump.cpp index 864880ad9b..c434ba20be 100644 --- a/src/bin/pg_dump/pg_dump.cpp +++ b/src/bin/pg_dump/pg_dump.cpp @@ -13444,7 +13444,11 @@ static void dumpFunc(Archive* fout, FuncInfo* finfo) } } - appendPQExpBuffer(labelq, "%s %s\n", funcKind, funcsig); + /* + * since COMMENT ON PROCEDURE and ALTER EXTENSION ADD PROCEDURE are not valid in grammar + * COMMENT ON/ALTER EXTENSION ADD, we should use FUNCTION instead. + */ + appendPQExpBuffer(labelq, "%s %s\n", "FUNCTION", funcsig); if (binary_upgrade) binary_upgrade_extension_member(q, &finfo->dobj, labelq->data); diff --git a/src/test/regress/input/gs_dump_tableof.source b/src/test/regress/input/gs_dump_tableof.source index 66f5675a55..e016aeb61a 100644 --- a/src/test/regress/input/gs_dump_tableof.source +++ b/src/test/regress/input/gs_dump_tableof.source @@ -13,6 +13,10 @@ create type s_type_1 is ( ); create type dams_arrytype1 is table of s_type_1; +create procedure comment_test_procedure(int,int) as begin select $1 + $2;end; +/ +comment on function comment_test_procedure(int,int) is 'test_comment_on'; + \! @abs_bindir@/gs_dump dump_type_db -p @portstring@ -f @abs_bindir@/dump_type.tar -F t >/dev/null 2>&1; echo $? drop database if exists restore_type_db; @@ -20,6 +24,9 @@ create database restore_type_db; \! @abs_bindir@/gs_restore -d restore_type_db -p @portstring@ @abs_bindir@/dump_type.tar >/dev/null 2>&1; echo $? +\c restore_type_db +select proname, obj_description(oid, 'pg_proc') AS comment from pg_proc where proname = 'comment_test_procedure'; + drop database if exists dump_mysql; create database dump_mysql dbcompatibility 'B'; \c dump_mysql diff --git a/src/test/regress/output/gs_dump_tableof.source b/src/test/regress/output/gs_dump_tableof.source index eaac822962..6abd32cb32 100644 --- a/src/test/regress/output/gs_dump_tableof.source +++ b/src/test/regress/output/gs_dump_tableof.source @@ -13,6 +13,9 @@ create type s_type_1 is ( addr text ); create type dams_arrytype1 is table of s_type_1; +create procedure comment_test_procedure(int,int) as begin select $1 + $2;end; +/ +comment on function comment_test_procedure(int,int) is 'test_comment_on'; \! @abs_bindir@/gs_dump dump_type_db -p @portstring@ -f @abs_bindir@/dump_type.tar -F t >/dev/null 2>&1; echo $? 0 drop database if exists restore_type_db; @@ -20,6 +23,13 @@ NOTICE: database "restore_type_db" does not exist, skipping create database restore_type_db; \! @abs_bindir@/gs_restore -d restore_type_db -p @portstring@ @abs_bindir@/dump_type.tar >/dev/null 2>&1; echo $? 0 +\c restore_type_db +select proname, obj_description(oid, 'pg_proc') AS comment from pg_proc where proname = 'comment_test_procedure'; + proname | comment +------------------------+----------------- + comment_test_procedure | test_comment_on +(1 row) + drop database if exists dump_mysql; NOTICE: database "dump_mysql" does not exist, skipping create database dump_mysql dbcompatibility 'B'; -- Gitee