*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/prep/prepjointree.c,v 1.71 2010/02/26 02:00:46 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/prep/prepjointree.c,v 1.72 2010/06/21 00:14:48 tgl Exp $
*
*-------------------------------------------------------------------------
*/
List *colnames;
List *fields;
bool save_need_phvs = rcon->need_phvs;
+ int save_sublevelsup = context->sublevels_up;
/*
* If generating an expansion for a var of a named rowtype (ie, this
&colnames, &fields);
/* Adjust the generated per-field Vars, but don't insert PHVs */
rcon->need_phvs = false;
+ context->sublevels_up = 0; /* to match the expandRTE output */
fields = (List *) replace_rte_variables_mutator((Node *) fields,
context);
rcon->need_phvs = save_need_phvs;
+ context->sublevels_up = save_sublevelsup;
+
rowexpr = makeNode(RowExpr);
rowexpr->args = fields;
rowexpr->row_typeid = var->vartype;
----+----+----
(0 rows)
+--
+-- Test case for bug #5514 (mishandling of whole-row Vars in subselects)
+--
+create temp table table_a(id integer);
+insert into table_a values (42);
+create temp view view_a as select * from table_a;
+select view_a from view_a;
+ view_a
+--------
+ (42)
+(1 row)
+
+select (select view_a) from view_a;
+ ?column?
+----------
+ (42)
+(1 row)
+
+select (select (select view_a)) from view_a;
+ ?column?
+----------
+ (42)
+(1 row)
+
+select (select (a.*)::text) from view_a a;
+ ?column?
+----------
+ (42)
+(1 row)
+
(select distinct f1, f2, (select f2 from t1 x where x.f1 = up.f1) as fs
from t1 up) ss
group by f1,f2,fs;
+
+--
+-- Test case for bug #5514 (mishandling of whole-row Vars in subselects)
+--
+
+create temp table table_a(id integer);
+insert into table_a values (42);
+
+create temp view view_a as select * from table_a;
+
+select view_a from view_a;
+select (select view_a) from view_a;
+select (select (select view_a)) from view_a;
+select (select (a.*)::text) from view_a a;