UNION select in a CREATE RULE caused a weird error, because transformRuleStmt
got confused by 'dummy' targetlist built for the UNION's toplevel query. Fix by making dummy targetlist a little less cheesy.
This commit is contained in:
parent
d72eb7cbbd
commit
dd03129b9f
@ -6,7 +6,7 @@
|
|||||||
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $Id: analyze.c,v 1.163 2000/11/05 00:15:54 tgl Exp $
|
* $Id: analyze.c,v 1.164 2000/11/05 01:42:07 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -1786,6 +1786,7 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt)
|
|||||||
{
|
{
|
||||||
Query *qry = makeNode(Query);
|
Query *qry = makeNode(Query);
|
||||||
SelectStmt *leftmostSelect;
|
SelectStmt *leftmostSelect;
|
||||||
|
int leftmostRTI;
|
||||||
Query *leftmostQuery;
|
Query *leftmostQuery;
|
||||||
SetOperationStmt *sostmt;
|
SetOperationStmt *sostmt;
|
||||||
char *into;
|
char *into;
|
||||||
@ -1856,8 +1857,8 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt)
|
|||||||
while (node && IsA(node, SetOperationStmt))
|
while (node && IsA(node, SetOperationStmt))
|
||||||
node = ((SetOperationStmt *) node)->larg;
|
node = ((SetOperationStmt *) node)->larg;
|
||||||
Assert(node && IsA(node, RangeTblRef));
|
Assert(node && IsA(node, RangeTblRef));
|
||||||
leftmostQuery = rt_fetch(((RangeTblRef *) node)->rtindex,
|
leftmostRTI = ((RangeTblRef *) node)->rtindex;
|
||||||
pstate->p_rtable)->subquery;
|
leftmostQuery = rt_fetch(leftmostRTI, pstate->p_rtable)->subquery;
|
||||||
Assert(leftmostQuery != NULL);
|
Assert(leftmostQuery != NULL);
|
||||||
/*
|
/*
|
||||||
* Generate dummy targetlist for outer query using column names of
|
* Generate dummy targetlist for outer query using column names of
|
||||||
@ -1868,7 +1869,8 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt)
|
|||||||
foreach(dtlist, sostmt->colTypes)
|
foreach(dtlist, sostmt->colTypes)
|
||||||
{
|
{
|
||||||
Oid colType = (Oid) lfirsti(dtlist);
|
Oid colType = (Oid) lfirsti(dtlist);
|
||||||
char *colName = ((TargetEntry *) lfirst(lefttl))->resdom->resname;
|
Resdom *leftResdom = ((TargetEntry *) lfirst(lefttl))->resdom;
|
||||||
|
char *colName = leftResdom->resname;
|
||||||
Resdom *resdom;
|
Resdom *resdom;
|
||||||
Node *expr;
|
Node *expr;
|
||||||
|
|
||||||
@ -1877,8 +1879,8 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt)
|
|||||||
-1,
|
-1,
|
||||||
pstrdup(colName),
|
pstrdup(colName),
|
||||||
false);
|
false);
|
||||||
expr = (Node *) makeVar(1,
|
expr = (Node *) makeVar(leftmostRTI,
|
||||||
resdom->resno,
|
leftResdom->resno,
|
||||||
colType,
|
colType,
|
||||||
-1,
|
-1,
|
||||||
0);
|
0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user