From edca83956c65b060437cab55b50dcfe76414065b Mon Sep 17 00:00:00 2001 From: Andy Fan Date: Fri, 18 Aug 2023 15:38:50 +0800 Subject: [PATCH] convert anyelement to internal. --- src/backend/utils/adt/jsonb.c | 9 +++++---- src/backend/utils/adt/jsonfuncs.c | 2 +- src/include/catalog/pg_proc.dat | 12 ++++++------ 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/backend/utils/adt/jsonb.c b/src/backend/utils/adt/jsonb.c index 148c1e2e195..7c1faa3d7f7 100644 --- a/src/backend/utils/adt/jsonb.c +++ b/src/backend/utils/adt/jsonb.c @@ -2091,10 +2091,11 @@ jsonb_cast_support(PG_FUNCTION_ARGS) if (OidIsValid(new_func_id)) { - Const *target = makeDummyConst(fexpr->funcresulttype, 0, InvalidOid); + // Const *target = makeDummyConst(fexpr->funcresulttype, 0, InvalidOid); + int64 target_typ = fexpr->funcresulttype; fexpr->funcid = new_func_id; fexpr->args = opexpr->args; - fexpr->args = list_insert_nth(fexpr->args, 0, target); + fexpr->args = list_insert_nth(fexpr->args, 0, (void *) target_typ); } PG_RETURN_POINTER(fexpr); @@ -2164,7 +2165,7 @@ cast_jsonbvalue_to_type(JsonbValue *v, Oid targetOid) Datum jsonb_object_field_type(PG_FUNCTION_ARGS) { - Oid targetOid = get_fn_expr_argtype(fcinfo->flinfo, 0); + Oid targetOid = DatumGetObjectId(0); Jsonb *jb = PG_GETARG_JSONB_P(1); text *key = PG_GETARG_TEXT_PP(2); @@ -2188,7 +2189,7 @@ jsonb_object_field_type(PG_FUNCTION_ARGS) Datum jsonb_array_element_type(PG_FUNCTION_ARGS) { - Oid targetOid = get_fn_expr_argtype(fcinfo->flinfo, 0); + Oid targetOid = DatumGetObjectId(0); Jsonb *jb = PG_GETARG_JSONB_P(1); int element = PG_GETARG_INT32(2); diff --git a/src/backend/utils/adt/jsonfuncs.c b/src/backend/utils/adt/jsonfuncs.c index bb4ca807d74..54138258bfc 100644 --- a/src/backend/utils/adt/jsonfuncs.c +++ b/src/backend/utils/adt/jsonfuncs.c @@ -1477,7 +1477,7 @@ get_scalar(void *state, char *token, JsonTokenType tokentype) Datum jsonb_extract_path_type(PG_FUNCTION_ARGS) { - Oid targetOid = get_fn_expr_argtype(fcinfo->flinfo, 0); + Oid targetOid = DatumGetObjectId(0); Jsonb *jb = PG_GETARG_JSONB_P(1); ArrayType *path = PG_GETARG_ARRAYTYPE_P(2); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index b6844537529..66d1af71586 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -9930,8 +9930,8 @@ proargtypes => 'jsonb text', proargnames => '{from_json, field_name}', prosrc => 'jsonb_object_field_text' }, { oid => '3813', descr => 'return a given type specified in desired_type from jsonb field', - proname => 'jsonb_object_field_type', prorettype => 'anyelement', - proargtypes => 'anyelement jsonb text', proargnames => '{target_type, from_json, field_name}', + proname => 'jsonb_object_field_type', prorettype => 'internal', + proargtypes => 'internal jsonb text', proargnames => '{target_type, from_json, field_name}', prosrc => 'jsonb_object_field_type'}, { oid => '3814', descr => 'planner support for numeric(jsonb)', proname => 'jsonb_cast_support', prorettype => 'internal', @@ -9945,8 +9945,8 @@ proargtypes => 'jsonb int4', proargnames => '{from_json, element_index}', prosrc => 'jsonb_array_element_text' }, { oid => '4549', descr => 'cast an array element to given type', - proname => 'jsonb_array_element_type', prorettype => 'anyelement', - proargtypes => 'anyelement jsonb int4', proargnames => '{target_type, from_json, element_index}', + proname => 'jsonb_array_element_type', prorettype => 'internal', + proargtypes => 'internal jsonb int4', proargnames => '{target_type, from_json, element_index}', prosrc => 'jsonb_array_element_type' }, { oid => '3217', descr => 'get value from jsonb with path elements', proname => 'jsonb_extract_path', provariadic => 'text', prorettype => 'jsonb', @@ -9961,8 +9961,8 @@ prosrc => 'jsonb_extract_path_text' }, { oid => '4551', descr => 'cast value from jsonb as text with path elements to given type', proname => 'jsonb_extract_path_type', provariadic => 'text', - prorettype => 'anyelement', proargtypes => 'anyelement jsonb _text', - proallargtypes => '{anyelement,jsonb,_text}', proargmodes => '{i,i,v}', + prorettype => 'internal', proargtypes => 'internal jsonb _text', + proallargtypes => '{internal,jsonb,_text}', proargmodes => '{i,i,v}', proargnames => '{target_type,from_json,path_elems}', prosrc => 'jsonb_extract_path_type' }, { oid => '3219', descr => 'elements of a jsonb array', -- 2.21.0