From: Peter Eisentraut Date: Fri, 6 Jul 2018 20:27:42 +0000 (+0200) Subject: Allow CALL with polymorphic type arguments X-Git-Tag: REL_11_BETA3~105 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6f50b1c70fe04dc0b08f58e87dd982d50e0edd22;p=postgresql Allow CALL with polymorphic type arguments In order to be able to resolve polymorphic types, we need to set fn_expr before invoking the procedure. --- diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c index 8864d9ae44..acc08b1990 100644 --- a/src/backend/commands/functioncmds.c +++ b/src/backend/commands/functioncmds.c @@ -2264,6 +2264,7 @@ ExecuteCallStmt(CallStmt *stmt, ParamListInfo params, bool atomic, DestReceiver /* Initialize function call structure */ InvokeFunctionExecuteHook(fexpr->funcid); fmgr_info(fexpr->funcid, &flinfo); + fmgr_info_set_expr((Node *) fexpr, &flinfo); InitFunctionCallInfoData(fcinfo, &flinfo, nargs, fexpr->inputcollid, (Node *) callcontext, NULL); /* diff --git a/src/test/regress/expected/create_procedure.out b/src/test/regress/expected/create_procedure.out index 30495971bc..0acea7bd8c 100644 --- a/src/test/regress/expected/create_procedure.out +++ b/src/test/regress/expected/create_procedure.out @@ -116,6 +116,13 @@ SELECT * FROM cp_test; 100 | Hello (8 rows) +-- polymorphic types +CREATE PROCEDURE ptest6(a int, b anyelement) +LANGUAGE SQL +AS $$ +SELECT NULL::int; +$$; +CALL ptest6(1, 2); -- various error cases CALL version(); -- error: not a procedure ERROR: version() is not a procedure diff --git a/src/test/regress/sql/create_procedure.sql b/src/test/regress/sql/create_procedure.sql index 22cc497ebe..0a9af8c906 100644 --- a/src/test/regress/sql/create_procedure.sql +++ b/src/test/regress/sql/create_procedure.sql @@ -84,6 +84,17 @@ CALL ptest5(b => 'Hello', a => 10); SELECT * FROM cp_test; +-- polymorphic types + +CREATE PROCEDURE ptest6(a int, b anyelement) +LANGUAGE SQL +AS $$ +SELECT NULL::int; +$$; + +CALL ptest6(1, 2); + + -- various error cases CALL version(); -- error: not a procedure