Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9de0ff9

Browse files
committed
Fix failure with SQL-procedure polymorphic output arguments in v12.
Before the v13-era commit913bbd8, check_sql_fn_retval fails toresolve polymorphic output types and then just throws up its hands andassumes the check will be made at runtime. I think that's true forordinary functions returning RECORD, but it doesn't happen in CALL,potentially resulting in crashes if the actual output of the SQLprocedure's SELECT doesn't match the type inferred from polymorphism.With a little bit of rearrangement, we can use get_call_result_typeinstead of get_func_result_type and thereby infer the correct types.I'm still unwilling to back-patch all of913bbd8, so if the typesdon't match you'll get an error rather than perhaps silently insertinga cast as v13 and later can. That's consistent with prior behaviorthough, so it seems fine.Prior to70ffb27, you'd typically get other errors due to othershortcomings of CALL's management of polymorphism. Nonetheless,this is an independent bug.Although there is no bug in v13 and up, it seems prudent to addthe test case for this to the newer branches too. It's clearlyan under-tested area.Per report from Andrew Bille.Discussion:https://postgr.es/m/CAJnzarw9EeWHAQRm76dXd=7j+rgw6ERqC=nCay8jeFqTwKwhqQ@mail.gmail.com
1 parent771b1b0 commit9de0ff9

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

‎src/test/regress/expected/create_procedure.out

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,23 @@ CALL ptest6b(1.1, null, null);
185185
1.1 | {1.1}
186186
(1 row)
187187

188+
CREATE PROCEDURE ptest6c(inout a anyelement, inout b anyelement)
189+
LANGUAGE SQL
190+
AS $$
191+
SELECT $1, 1;
192+
$$;
193+
CALL ptest6c(1, null);
194+
a | b
195+
---+---
196+
1 | 1
197+
(1 row)
198+
199+
CALL ptest6c(1.1, null); -- fails before v13
200+
a | b
201+
-----+---
202+
1.1 | 1
203+
(1 row)
204+
188205
-- collation assignment
189206
CREATE PROCEDURE ptest7(a text, b text)
190207
LANGUAGE SQL

‎src/test/regress/sql/create_procedure.sql

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,15 @@ $$;
127127
CALL ptest6b(1,null,null);
128128
CALL ptest6b(1.1,null,null);
129129

130+
CREATE PROCEDURE ptest6c(inout a anyelement, inout b anyelement)
131+
LANGUAGE SQL
132+
AS $$
133+
SELECT $1,1;
134+
$$;
135+
136+
CALL ptest6c(1,null);
137+
CALL ptest6c(1.1,null);-- fails before v13
138+
130139

131140
-- collation assignment
132141

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp