Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 4262926

Browse files
committed
Fix problem with whole-row Vars referencing sub-select outputs, per
example from Jim Dew. Add some simple regression tests, since this is an area we seem to break regularly :-(
1 parent f82e2ba commit 4262926

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

src/backend/executor/execQual.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.185 2005/11/22 18:17:10 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.186 2005/12/14 16:28:32 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -523,7 +523,7 @@ ExecEvalWholeRowVar(ExprState *exprstate, ExprContext *econtext,
523523
Assert(variable->varno != OUTER);
524524
slot = econtext->ecxt_scantuple;
525525

526-
tuple = slot->tts_tuple;
526+
tuple = ExecFetchSlotTuple(slot);
527527
tupleDesc = slot->tts_tupleDescriptor;
528528

529529
/*

src/test/regress/expected/select.out

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,3 +431,24 @@ SELECT p.name, p.age FROM person* p ORDER BY age using >, name;
431431
mary | 8
432432
(58 rows)
433433

434+
--
435+
-- Test some cases involving whole-row Var referencing a subquery
436+
--
437+
select foo from (select 1) as foo;
438+
foo
439+
-----
440+
(1)
441+
(1 row)
442+
443+
select foo from (select null) as foo;
444+
foo
445+
-----
446+
()
447+
(1 row)
448+
449+
select foo from (select 'xyzzy',1,null) as foo;
450+
foo
451+
------------
452+
(xyzzy,1,)
453+
(1 row)
454+

src/test/regress/sql/select.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,9 @@ SELECT p.name, p.age FROM person* p;
104104
--
105105
SELECT p.name, p.age FROM person* p ORDER BY age using >, name;
106106

107+
--
108+
-- Test some cases involving whole-row Var referencing a subquery
109+
--
110+
select foo from (select 1) as foo;
111+
select foo from (select null) as foo;
112+
select foo from (select 'xyzzy',1,null) as foo;

0 commit comments

Comments
 (0)