6
6
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
7
7
* Portions Copyright (c) 1994, Regents of the University of California
8
8
*
9
- * $Id: analyze.c,v 1.163 2000/11/05 00:15:54 tgl Exp $
9
+ * $Id: analyze.c,v 1.164 2000/11/05 01:42:07 tgl Exp $
10
10
*
11
11
*-------------------------------------------------------------------------
12
12
*/
@@ -1786,6 +1786,7 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt)
1786
1786
{
1787
1787
Query * qry = makeNode (Query );
1788
1788
SelectStmt * leftmostSelect ;
1789
+ int leftmostRTI ;
1789
1790
Query * leftmostQuery ;
1790
1791
SetOperationStmt * sostmt ;
1791
1792
char * into ;
@@ -1856,8 +1857,8 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt)
1856
1857
while (node && IsA (node , SetOperationStmt ))
1857
1858
node = ((SetOperationStmt * ) node )-> larg ;
1858
1859
Assert (node && IsA (node , RangeTblRef ));
1859
- leftmostQuery = rt_fetch ((( RangeTblRef * ) node )-> rtindex ,
1860
- pstate -> p_rtable )-> subquery ;
1860
+ leftmostRTI = (( RangeTblRef * ) node )-> rtindex ;
1861
+ leftmostQuery = rt_fetch ( leftmostRTI , pstate -> p_rtable )-> subquery ;
1861
1862
Assert (leftmostQuery != NULL );
1862
1863
/*
1863
1864
* Generate dummy targetlist for outer query using column names of
@@ -1868,7 +1869,8 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt)
1868
1869
foreach (dtlist , sostmt -> colTypes )
1869
1870
{
1870
1871
Oid colType = (Oid ) lfirsti (dtlist );
1871
- char * colName = ((TargetEntry * ) lfirst (lefttl ))-> resdom -> resname ;
1872
+ Resdom * leftResdom = ((TargetEntry * ) lfirst (lefttl ))-> resdom ;
1873
+ char * colName = leftResdom -> resname ;
1872
1874
Resdom * resdom ;
1873
1875
Node * expr ;
1874
1876
@@ -1877,8 +1879,8 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt)
1877
1879
-1 ,
1878
1880
pstrdup (colName ),
1879
1881
false);
1880
- expr = (Node * ) makeVar (1 ,
1881
- resdom -> resno ,
1882
+ expr = (Node * ) makeVar (leftmostRTI ,
1883
+ leftResdom -> resno ,
1882
1884
colType ,
1883
1885
-1 ,
1884
1886
0 );
0 commit comments