From 7e57f1ff6f1e5d69509cc42a237dd80638c2807e Mon Sep 17 00:00:00 2001 From: cc_db_dev Date: Tue, 21 Mar 2023 19:15:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E5=87=BD=E6=95=B0=E8=A1=A8=E8=BE=BE?= =?UTF-8?q?=E5=BC=8F=E8=AE=A1=E7=AE=97=E9=98=B6=E6=AE=B5=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E5=8C=85=E5=90=AB=E6=B8=B8=E6=A0=87=EF=BC=88?= =?UTF-8?q?refcursor=EF=BC=89=E7=9A=84=E9=80=BB=E8=BE=91=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E5=89=AA=E6=9E=9D=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/backend/catalog/builtin_funcs.ini | 4 ++-- src/common/backend/catalog/namespace.cpp | 5 +++++ src/gausskernel/runtime/executor/execQual.cpp | 9 +++++++-- src/gausskernel/runtime/executor/execUtils.cpp | 3 +++ src/include/catalog/pg_proc.h | 2 ++ .../regress/expected/single_node_type_sanity.out | 13 +++++++++++++ src/test/regress/sql/single_node_type_sanity.sql | 8 ++++++++ 7 files changed, 40 insertions(+), 4 deletions(-) diff --git a/src/common/backend/catalog/builtin_funcs.ini b/src/common/backend/catalog/builtin_funcs.ini index 24c70d2cf..2ebc52cac 100755 --- a/src/common/backend/catalog/builtin_funcs.ini +++ b/src/common/backend/catalog/builtin_funcs.ini @@ -2114,11 +2114,11 @@ ), AddFuncGroup( "cursor_to_xml", 1, - AddBuiltinFunc(_0(2925), _1("cursor_to_xml"), _2(5), _3(false), _4(false), _5(cursor_to_xml), _6(142), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(100), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('s'), _19(0), _20(5, 1790, 23, 16, 16, 25), _21(NULL), _22(NULL), _23(5, "cursor", "count", "nulls", "tableforest", "targetns"), _24(NULL), _25("cursor_to_xml"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33("map rows from cursor to XML"), _34('f'), _35(NULL), _36(0), _37(false), _38(NULL), _39(NULL), _40(0)) + AddBuiltinFunc(_0(CURSORTOXMLOID), _1("cursor_to_xml"), _2(5), _3(false), _4(false), _5(cursor_to_xml), _6(142), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(100), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('s'), _19(0), _20(5, 1790, 23, 16, 16, 25), _21(NULL), _22(NULL), _23(5, "cursor", "count", "nulls", "tableforest", "targetns"), _24(NULL), _25("cursor_to_xml"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33("map rows from cursor to XML"), _34('f'), _35(NULL), _36(0), _37(false), _38(NULL), _39(NULL), _40(0)) ), AddFuncGroup( "cursor_to_xmlschema", 1, - AddBuiltinFunc(_0(2928), _1("cursor_to_xmlschema"), _2(4), _3(false), _4(false), _5(cursor_to_xmlschema), _6(142), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(100), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('s'), _19(0), _20(4, 1790, 16, 16, 25), _21(NULL), _22(NULL), _23(4, "cursor", "nulls", "tableforest", "targetns"), _24(NULL), _25("cursor_to_xmlschema"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33("map cursor structure to XML Schema"), _34('f'), _35(NULL), _36(0), _37(false), _38(NULL), _39(NULL), _40(0)) + AddBuiltinFunc(_0(CURSORTOXMLSCHEMAOID), _1("cursor_to_xmlschema"), _2(4), _3(false), _4(false), _5(cursor_to_xmlschema), _6(142), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(100), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('s'), _19(0), _20(4, 1790, 16, 16, 25), _21(NULL), _22(NULL), _23(4, "cursor", "nulls", "tableforest", "targetns"), _24(NULL), _25("cursor_to_xmlschema"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33("map cursor structure to XML Schema"), _34('f'), _35(NULL), _36(0), _37(false), _38(NULL), _39(NULL), _40(0)) ), AddFuncGroup( "database_to_xml", 1, diff --git a/src/common/backend/catalog/namespace.cpp b/src/common/backend/catalog/namespace.cpp index 28d6d5cd3..3310ebca6 100644 --- a/src/common/backend/catalog/namespace.cpp +++ b/src/common/backend/catalog/namespace.cpp @@ -1059,6 +1059,11 @@ bool IsPlpgsqlLanguageOid(Oid langoid) bool isNull = true; char* langName = NULL; + if (langoid == INTERNALlanguageId || langoid == ClanguageId + || langoid == SQLlanguageId || langoid == JavalanguageId) { + return false; + } + Relation relation = heap_open(LanguageRelationId, NoLock); tp = SearchSysCache1(LANGOID, ObjectIdGetDatum(langoid)); if (!HeapTupleIsValid(tp)) { diff --git a/src/gausskernel/runtime/executor/execQual.cpp b/src/gausskernel/runtime/executor/execQual.cpp index caf9ef734..0278ae66b 100644 --- a/src/gausskernel/runtime/executor/execQual.cpp +++ b/src/gausskernel/runtime/executor/execQual.cpp @@ -2745,6 +2745,13 @@ extern bool func_has_refcursor_args(Oid Funcid, FunctionCallInfoData* fcinfo) bool return_refcursor = false; int out_count = 0; /* out arg count */ + fcinfo->refcursor_data.return_number = 0; + fcinfo->refcursor_data.returnCursor = NULL; + + if (IsSystemObjOid(Funcid) && Funcid != CURSORTOXMLOID && Funcid != CURSORTOXMLSCHEMAOID) { + return false; + } + proctup = SearchSysCache(PROCOID, ObjectIdGetDatum(Funcid), 0, 0, 0); /* @@ -2758,8 +2765,6 @@ extern bool func_has_refcursor_args(Oid Funcid, FunctionCallInfoData* fcinfo) allarg = get_func_arg_info(proctup, &p_argtypes, &p_argnames, &p_argmodes); procStruct = (Form_pg_proc)GETSTRUCT(proctup); - fcinfo->refcursor_data.return_number = 0; - fcinfo->refcursor_data.returnCursor = NULL; for (int i = 0; i < allarg; i++) { if (p_argmodes != NULL && (p_argmodes[i] == 'o' || p_argmodes[i] == 'b')) { out_count++; diff --git a/src/gausskernel/runtime/executor/execUtils.cpp b/src/gausskernel/runtime/executor/execUtils.cpp index 3a87a22fc..66387d0a6 100644 --- a/src/gausskernel/runtime/executor/execUtils.cpp +++ b/src/gausskernel/runtime/executor/execUtils.cpp @@ -2910,6 +2910,9 @@ bool expr_func_has_refcursor_args(Oid Funcid) char* p_argmodes = NULL; bool use_cursor = false; + if (IsSystemObjOid(Funcid) && Funcid != CURSORTOXMLOID && Funcid != CURSORTOXMLSCHEMAOID) { + return false; + } proctup = SearchSysCache(PROCOID, ObjectIdGetDatum(Funcid), 0, 0, 0); /* diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h index 215c1b3d4..2f90776ee 100644 --- a/src/include/catalog/pg_proc.h +++ b/src/include/catalog/pg_proc.h @@ -427,6 +427,8 @@ typedef FormData_pg_proc *Form_pg_proc; #define JSONAGGFUNCOID 3124 #define JSONOBJECTAGGFUNCOID 3403 #define GROUPCONCATFUNCOID 4097 +#define CURSORTOXMLOID 2925 +#define CURSORTOXMLSCHEMAOID 2928 /* * Symbolic values for prokind column diff --git a/src/test/regress/expected/single_node_type_sanity.out b/src/test/regress/expected/single_node_type_sanity.out index 9c61b7f07..56f0c3ef7 100644 --- a/src/test/regress/expected/single_node_type_sanity.out +++ b/src/test/regress/expected/single_node_type_sanity.out @@ -543,3 +543,16 @@ WHERE pronargs != 2 ----------+------------+--------- (0 rows) +-- pg_proc check-- +-- if the ouput here change, should fix the code expr_func_has_refcursor_args +-- and func_has_refcursor_args. +-- you should fix the code like 2925、2928 +select distinct(oid) from +(select prorettype as rettype, unnest(proargtypes) as argtype, oid from pg_proc) as qq +where qq.rettype=1790 or qq.argtype=1790 order by oid; + oid +------ + 2925 + 2928 +(2 rows) + diff --git a/src/test/regress/sql/single_node_type_sanity.sql b/src/test/regress/sql/single_node_type_sanity.sql index f9a63e036..5d1bcba05 100644 --- a/src/test/regress/sql/single_node_type_sanity.sql +++ b/src/test/regress/sql/single_node_type_sanity.sql @@ -386,3 +386,11 @@ FROM pg_range p1 JOIN pg_proc p ON p.oid = p1.rngsubdiff WHERE pronargs != 2 OR proargtypes[0] != rngsubtype OR proargtypes[1] != rngsubtype OR prorettype != 'pg_catalog.float8'::regtype; + +-- pg_proc check-- +-- if the ouput here change, should fix the code expr_func_has_refcursor_args +-- and func_has_refcursor_args. +-- you should fix the code like 2925、2928 +select distinct(oid) from +(select prorettype as rettype, unnest(proargtypes) as argtype, oid from pg_proc) as qq +where qq.rettype=1790 or qq.argtype=1790 order by oid; \ No newline at end of file