diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2010-12-01 00:53:29 -0500 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2010-12-01 00:53:29 -0500 |
| commit | 6bd3753d4d66bd78ac6d3b694910914f81212d56 (patch) | |
| tree | 76213f535ebfc548c269dbeb467f597fc594035c /src/test | |
| parent | 61f86180169cda1168a2f4829f3289323d7ec7ae (diff) | |
Prevent inlining a SQL function with multiple OUT parameters.
There were corner cases in which the planner would attempt to inline such
a function, which would result in a failure at runtime due to loss of
information about exactly what the result record type is. Fix by disabling
inlining when the function's recorded result type is RECORD. There might
be some sub-cases where inlining could still be allowed, but this is a
simple and backpatchable fix, so leave refinements for another day.
Per bug #5777 from Nate Carson.
Back-patch to all supported branches. 8.1 happens to avoid a core-dump
here, but it still does the wrong thing.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/regress/expected/rangefuncs.out | 20 | ||||
| -rw-r--r-- | src/test/regress/sql/rangefuncs.sql | 19 |
2 files changed, 39 insertions, 0 deletions
diff --git a/src/test/regress/expected/rangefuncs.out b/src/test/regress/expected/rangefuncs.out index e8bdc42b9b6..0769fa66f9d 100644 --- a/src/test/regress/expected/rangefuncs.out +++ b/src/test/regress/expected/rangefuncs.out @@ -891,3 +891,23 @@ select * from foobar(); (2 rows) drop function foobar(); +-- check handling of a SQL function with multiple OUT params (bug #5777) +create or replace function foobar(out integer, out numeric) as +$$ select (1, 2.1) $$ language sql; +select * from foobar(); + column1 | column2 +---------+--------- + 1 | 2.1 +(1 row) + +create or replace function foobar(out integer, out numeric) as +$$ select (1, 2) $$ language sql; +select * from foobar(); -- fail +ERROR: function return row and query-specified return row do not match +DETAIL: Returned type integer at ordinal position 2, but query expects numeric. +create or replace function foobar(out integer, out numeric) as +$$ select (1, 2.1, 3) $$ language sql; +select * from foobar(); -- fail +ERROR: function return row and query-specified return row do not match +DETAIL: Returned row contains 3 attributes, but query expects 2. +drop function foobar(); diff --git a/src/test/regress/sql/rangefuncs.sql b/src/test/regress/sql/rangefuncs.sql index d780c6cd3eb..c813a306436 100644 --- a/src/test/regress/sql/rangefuncs.sql +++ b/src/test/regress/sql/rangefuncs.sql @@ -423,3 +423,22 @@ select foobar(); select * from foobar(); drop function foobar(); + +-- check handling of a SQL function with multiple OUT params (bug #5777) + +create or replace function foobar(out integer, out numeric) as +$$ select (1, 2.1) $$ language sql; + +select * from foobar(); + +create or replace function foobar(out integer, out numeric) as +$$ select (1, 2) $$ language sql; + +select * from foobar(); -- fail + +create or replace function foobar(out integer, out numeric) as +$$ select (1, 2.1, 3) $$ language sql; + +select * from foobar(); -- fail + +drop function foobar(); |
