Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdd03129

Browse files
committed
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.
1 parentd72eb7c commitdd03129

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

‎src/backend/parser/analyze.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
*$Id: analyze.c,v 1.163 2000/11/0500:15:54 tgl Exp $
9+
*$Id: analyze.c,v 1.164 2000/11/0501:42:07 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -1786,6 +1786,7 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt)
17861786
{
17871787
Query*qry=makeNode(Query);
17881788
SelectStmt*leftmostSelect;
1789+
intleftmostRTI;
17891790
Query*leftmostQuery;
17901791
SetOperationStmt*sostmt;
17911792
char*into;
@@ -1856,8 +1857,8 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt)
18561857
while (node&&IsA(node,SetOperationStmt))
18571858
node= ((SetOperationStmt*)node)->larg;
18581859
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;
18611862
Assert(leftmostQuery!=NULL);
18621863
/*
18631864
* Generate dummy targetlist for outer query using column names of
@@ -1868,7 +1869,8 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt)
18681869
foreach(dtlist,sostmt->colTypes)
18691870
{
18701871
OidcolType= (Oid)lfirsti(dtlist);
1871-
char*colName= ((TargetEntry*)lfirst(lefttl))->resdom->resname;
1872+
Resdom*leftResdom= ((TargetEntry*)lfirst(lefttl))->resdom;
1873+
char*colName=leftResdom->resname;
18721874
Resdom*resdom;
18731875
Node*expr;
18741876

@@ -1877,8 +1879,8 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt)
18771879
-1,
18781880
pstrdup(colName),
18791881
false);
1880-
expr= (Node*)makeVar(1,
1881-
resdom->resno,
1882+
expr= (Node*)makeVar(leftmostRTI,
1883+
leftResdom->resno,
18821884
colType,
18831885
-1,
18841886
0);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp