Add collation assignment to CALL statement
authorPeter Eisentraut <peter@eisentraut.org>
Tue, 5 Feb 2019 14:08:53 +0000 (15:08 +0100)
committerPeter Eisentraut <peter@eisentraut.org>
Thu, 7 Feb 2019 07:25:47 +0000 (08:25 +0100)
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 <Jean-Marc.Voillequin@moodys.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/1EC8157EB499BF459A516ADCF135ADCE39FFAC54%40LON-WGMSX712.ad.moodys.net

src/backend/parser/analyze.c
src/test/regress/expected/create_procedure.out
src/test/regress/sql/create_procedure.sql

index 7f5773582b073b2a1ee8884b006c981e5de2f142..e3544efb6fe574747ad76d55fe68518eaeb8ef29 100644 (file)
@@ -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);
index 5b9b83839cfb4510135dfe7e821dac41b8cd3d1f..211a42cefa039e70fc3e63289f724505081f7758 100644 (file)
@@ -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
index b64293ed669416acab761ee90cdd3b25fff80e7d..89b96d580ffa472b3dfc705e36c100c16eb08429 100644 (file)
@@ -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