diff --git a/src/common/backend/catalog/builtin_funcs.ini b/src/common/backend/catalog/builtin_funcs.ini index d7a3bfe29..295e032c6 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 9e39c192c..4efe98b5e 100644 --- a/src/gausskernel/runtime/executor/execQual.cpp +++ b/src/gausskernel/runtime/executor/execQual.cpp @@ -2905,6 +2905,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); /* @@ -2918,8 +2925,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 77989d9d3..2e59283f8 100644 --- a/src/gausskernel/runtime/executor/execUtils.cpp +++ b/src/gausskernel/runtime/executor/execUtils.cpp @@ -2923,6 +2923,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