aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2003-02-11 04:13:06 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2003-02-11 04:13:06 +0000
commit9069a5fc337bf63edf36f40d0e49164c46993482 (patch)
treeb750268e0f3edb574ff129e6f605246288cb1d85
parent8a4fdce9f277fe1f02654091e89e96180af9c4cb (diff)
downloadpostgresql-9069a5fc337bf63edf36f40d0e49164c46993482.tar.gz
postgresql-9069a5fc337bf63edf36f40d0e49164c46993482.zip
Use a varno not chosen at random for dummy variables in the top-level
targetlist of a set-operation tree. I'm not sure that this solution will really stand the test of time --- perhaps we need to make a special RTE for such vars to refer to. But this quick hack fixes Brandon Craig Rhodes' complaint of 10-Feb-02 about EXCEPT in CREATE RULE, while not changing any behavior in the better-tested cases where leftmostRTI is one anyway.
-rw-r--r--src/backend/parser/analyze.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c
index fb3415ba03c..f198ceb813f 100644
--- a/src/backend/parser/analyze.c
+++ b/src/backend/parser/analyze.c
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.261 2003/02/09 06:56:28 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.262 2003/02/11 04:13:06 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1786,6 +1786,11 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt)
* leftmost select and common datatypes of topmost set operation. Also
* make lists of the dummy vars and their names for use in parsing
* ORDER BY.
+ *
+ * Note: we use leftmostRTI as the varno of the dummy variables.
+ * It shouldn't matter too much which RT index they have, as long
+ * as they have one that corresponds to a real RT entry; else funny
+ * things may happen when the tree is mashed by rule rewriting.
*/
qry->targetList = NIL;
targetvars = NIL;
@@ -1804,7 +1809,7 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt)
-1,
colName,
false);
- expr = (Expr *) makeVar(1,
+ expr = (Expr *) makeVar(leftmostRTI,
leftResdom->resno,
colType,
-1,
@@ -1871,7 +1876,7 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt)
NULL,
true);
jrtr = makeNode(RangeTblRef);
- jrtr->rtindex = 1;
+ jrtr->rtindex = 1; /* only entry in dummy rtable */
sv_rtable = pstate->p_rtable;
pstate->p_rtable = makeList1(jrte);