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

Commit6c59886

Browse files
committed
Second try at fixing join alias variables. Instead of attaching miscellaneous
lists to join RTEs, attach a list of Vars and COALESCE expressions that willreplace the join's alias variables during planning. This simplifiesflatten_join_alias_vars while still making it easy to fix up varno referenceswhen transforming the query tree. Add regression test cases for interactionsof subqueries with outer joins.
1 parentc8996f9 commit6c59886

File tree

21 files changed

+622
-651
lines changed

21 files changed

+622
-651
lines changed

‎src/backend/nodes/copyfuncs.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* Portions Copyright (c) 1994, Regents of the University of California
1616
*
1717
* IDENTIFICATION
18-
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.181 2002/04/24 02:48:54 momjian Exp $
18+
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.182 2002/04/28 19:54:28 tgl Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -323,7 +323,6 @@ CopyJoinFields(Join *from, Join *newnode)
323323
{
324324
newnode->jointype=from->jointype;
325325
Node_Copy(from,newnode,joinqual);
326-
newnode->joinrti=from->joinrti;
327326
/* subPlan list must point to subplans in the new subtree, not the old */
328327
if (from->plan.subPlan!=NIL)
329328
newnode->plan.subPlan=nconc(newnode->plan.subPlan,
@@ -1475,10 +1474,7 @@ _copyRangeTblEntry(RangeTblEntry *from)
14751474
newnode->relid=from->relid;
14761475
Node_Copy(from,newnode,subquery);
14771476
newnode->jointype=from->jointype;
1478-
newnode->joincoltypes=listCopy(from->joincoltypes);
1479-
newnode->joincoltypmods=listCopy(from->joincoltypmods);
1480-
newnode->joinleftcols=listCopy(from->joinleftcols);
1481-
newnode->joinrightcols=listCopy(from->joinrightcols);
1477+
Node_Copy(from,newnode,joinaliasvars);
14821478
Node_Copy(from,newnode,alias);
14831479
Node_Copy(from,newnode,eref);
14841480
newnode->inh=from->inh;

‎src/backend/nodes/equalfuncs.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* Portions Copyright (c) 1994, Regents of the University of California
2121
*
2222
* IDENTIFICATION
23-
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.129 2002/04/24 02:48:54 momjian Exp $
23+
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.130 2002/04/28 19:54:28 tgl Exp $
2424
*
2525
*-------------------------------------------------------------------------
2626
*/
@@ -1680,13 +1680,7 @@ _equalRangeTblEntry(RangeTblEntry *a, RangeTblEntry *b)
16801680
return false;
16811681
if (a->jointype!=b->jointype)
16821682
return false;
1683-
if (!equali(a->joincoltypes,b->joincoltypes))
1684-
return false;
1685-
if (!equali(a->joincoltypmods,b->joincoltypmods))
1686-
return false;
1687-
if (!equali(a->joinleftcols,b->joinleftcols))
1688-
return false;
1689-
if (!equali(a->joinrightcols,b->joinrightcols))
1683+
if (!equal(a->joinaliasvars,b->joinaliasvars))
16901684
return false;
16911685
if (!equal(a->alias,b->alias))
16921686
return false;

‎src/backend/nodes/outfuncs.c

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
66
* Portions Copyright (c) 1994, Regents of the University of California
77
*
8-
*$Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.156 2002/04/17 20:57:56 tgl Exp $
8+
*$Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.157 2002/04/28 19:54:28 tgl Exp $
99
*
1010
* NOTES
1111
* Every (plan) node in POSTGRES has an associated "out" routine which
@@ -408,8 +408,6 @@ _outJoin(StringInfo str, Join *node)
408408
appendStringInfo(str," :jointype %d :joinqual ",
409409
(int)node->jointype);
410410
_outNode(str,node->joinqual);
411-
appendStringInfo(str," :joinrti %d ",
412-
node->joinrti);
413411
}
414412

415413
/*
@@ -423,8 +421,6 @@ _outNestLoop(StringInfo str, NestLoop *node)
423421
appendStringInfo(str," :jointype %d :joinqual ",
424422
(int)node->join.jointype);
425423
_outNode(str,node->join.joinqual);
426-
appendStringInfo(str," :joinrti %d ",
427-
node->join.joinrti);
428424
}
429425

430426
/*
@@ -438,8 +434,6 @@ _outMergeJoin(StringInfo str, MergeJoin *node)
438434
appendStringInfo(str," :jointype %d :joinqual ",
439435
(int)node->join.jointype);
440436
_outNode(str,node->join.joinqual);
441-
appendStringInfo(str," :joinrti %d ",
442-
node->join.joinrti);
443437

444438
appendStringInfo(str," :mergeclauses ");
445439
_outNode(str,node->mergeclauses);
@@ -456,8 +450,6 @@ _outHashJoin(StringInfo str, HashJoin *node)
456450
appendStringInfo(str," :jointype %d :joinqual ",
457451
(int)node->join.jointype);
458452
_outNode(str,node->join.joinqual);
459-
appendStringInfo(str," :joinrti %d ",
460-
node->join.joinrti);
461453

462454
appendStringInfo(str," :hashclauses ");
463455
_outNode(str,node->hashclauses);
@@ -982,22 +974,16 @@ _outRangeTblEntry(StringInfo str, RangeTblEntry *node)
982974
{
983975
caseRTE_RELATION:
984976
caseRTE_SPECIAL:
985-
appendStringInfo(str,":relid %u",node->relid);
977+
appendStringInfo(str,":relid %u",node->relid);
986978
break;
987979
caseRTE_SUBQUERY:
988980
appendStringInfo(str,":subquery ");
989981
_outNode(str,node->subquery);
990982
break;
991983
caseRTE_JOIN:
992-
appendStringInfo(str,":jointype %d :joincoltypes ",
984+
appendStringInfo(str,":jointype %d :joinaliasvars ",
993985
(int)node->jointype);
994-
_outOidList(str,node->joincoltypes);
995-
appendStringInfo(str," :joincoltypmods ");
996-
_outIntList(str,node->joincoltypmods);
997-
appendStringInfo(str," :joinleftcols ");
998-
_outIntList(str,node->joinleftcols);
999-
appendStringInfo(str," :joinrightcols ");
1000-
_outIntList(str,node->joinrightcols);
986+
_outNode(str,node->joinaliasvars);
1001987
break;
1002988
default:
1003989
elog(ERROR,"bogus rte kind %d", (int)node->rtekind);

‎src/backend/nodes/readfuncs.c

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.119 2002/04/11 20:00:00 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.120 2002/04/28 19:54:28 tgl Exp $
1212
*
1313
* NOTES
1414
* Most of the read functions for plan nodes are tested. (In fact, they
@@ -421,10 +421,6 @@ _getJoin(Join *node)
421421

422422
token=pg_strtok(&length);/* skip the :joinqual */
423423
node->joinqual=nodeRead(true);/* get the joinqual */
424-
425-
token=pg_strtok(&length);/* skip the :joinrti */
426-
token=pg_strtok(&length);/* get the joinrti */
427-
node->joinrti=atoi(token);
428424
}
429425

430426

@@ -1523,17 +1519,8 @@ _readRangeTblEntry(void)
15231519
token=pg_strtok(&length);/* get jointype */
15241520
local_node->jointype= (JoinType)atoi(token);
15251521

1526-
token=pg_strtok(&length);/* eat :joincoltypes */
1527-
local_node->joincoltypes=toOidList(nodeRead(true));
1528-
1529-
token=pg_strtok(&length);/* eat :joincoltypmods */
1530-
local_node->joincoltypmods=toIntList(nodeRead(true));
1531-
1532-
token=pg_strtok(&length);/* eat :joinleftcols */
1533-
local_node->joinleftcols=toIntList(nodeRead(true));
1534-
1535-
token=pg_strtok(&length);/* eat :joinrightcols */
1536-
local_node->joinrightcols=toIntList(nodeRead(true));
1522+
token=pg_strtok(&length);/* eat :joinaliasvars */
1523+
local_node->joinaliasvars=nodeRead(true);/* now read it */
15371524
break;
15381525

15391526
default:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp