From cd5afd8175e256fa401cf440d06304df746abe62 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Tue, 5 Feb 2019 15:08:53 +0100 Subject: [PATCH] Add collation assignment to CALL statement Otherwise functions that require collation information will not have it if they are called in arguments to a CALL statement. Reported-by: Jean-Marc Voillequin Reviewed-by: Tom Lane Discussion: https://www.postgresql.org/message-id/flat/1EC8157EB499BF459A516ADCF135ADCE39FFAC54%40LON-WGMSX712.ad.moodys.net --- src/backend/parser/analyze.c | 2 ++ src/test/regress/expected/create_procedure.out | 7 +++++++ src/test/regress/sql/create_procedure.sql | 11 +++++++++++ 3 files changed, 20 insertions(+) diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c index 7f5773582b..e3544efb6f 100644 --- a/src/backend/parser/analyze.c +++ b/src/backend/parser/analyze.c @@ -2636,6 +2636,8 @@ transformCallStmt(ParseState *pstate, CallStmt *stmt) true, stmt->funccall->location); + assign_expr_collations(pstate, node); + stmt->funcexpr = castNode(FuncExpr, node); result = makeNode(Query); diff --git a/src/test/regress/expected/create_procedure.out b/src/test/regress/expected/create_procedure.out index 5b9b83839c..211a42cefa 100644 --- a/src/test/regress/expected/create_procedure.out +++ b/src/test/regress/expected/create_procedure.out @@ -139,6 +139,13 @@ AS $$ SELECT NULL::int; $$; CALL ptest6(1, 2); +-- collation assignment +CREATE PROCEDURE ptest7(a text, b text) +LANGUAGE SQL +AS $$ +SELECT a = b; +$$; +CALL ptest7(least('a', 'b'), 'a'); -- 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 b64293ed66..89b96d580f 100644 --- a/src/test/regress/sql/create_procedure.sql +++ b/src/test/regress/sql/create_procedure.sql @@ -101,6 +101,17 @@ $$; CALL ptest6(1, 2); +-- collation assignment + +CREATE PROCEDURE ptest7(a text, b text) +LANGUAGE SQL +AS $$ +SELECT a = b; +$$; + +CALL ptest7(least('a', 'b'), 'a'); + + -- various error cases CALL version(); -- error: not a procedure -- 2.40.0