aboutsummaryrefslogtreecommitdiff
path: root/src/backend/optimizer/path/allpaths.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2004-05-10 22:44:49 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2004-05-10 22:44:49 +0000
commit2f63232d30ca64a8f2684af855230f23a701d371 (patch)
treeb7a7707d1ec9edf368780cd3f4a23755527c5884 /src/backend/optimizer/path/allpaths.c
parent9a939886ac782cfee3cd5fdd1c58689163ed84be (diff)
downloadpostgresql-2f63232d30ca64a8f2684af855230f23a701d371.tar.gz
postgresql-2f63232d30ca64a8f2684af855230f23a701d371.zip
Promote row expressions to full-fledged citizens of the expression syntax,
rather than allowing them only in a few special cases as before. In particular you can now pass a ROW() construct to a function that accepts a rowtype parameter. Internal generation of RowExprs fixes a number of corner cases that used to not work very well, such as referencing the whole-row result of a JOIN or subquery. This represents a further step in the work I started a month or so back to make rowtype values into first-class citizens.
Diffstat (limited to 'src/backend/optimizer/path/allpaths.c')
-rw-r--r--src/backend/optimizer/path/allpaths.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/backend/optimizer/path/allpaths.c b/src/backend/optimizer/path/allpaths.c
index 5d92fc4c5d1..217f06a6b2b 100644
--- a/src/backend/optimizer/path/allpaths.c
+++ b/src/backend/optimizer/path/allpaths.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/path/allpaths.c,v 1.113 2004/04/25 18:23:56 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/path/allpaths.c,v 1.114 2004/05/10 22:44:44 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -57,9 +57,10 @@ static void compare_tlist_datatypes(List *tlist, List *colTypes,
bool *differentTypes);
static bool qual_is_pushdown_safe(Query *subquery, Index rti, Node *qual,
bool *differentTypes);
-static void subquery_push_qual(Query *subquery, Index rti, Node *qual);
+static void subquery_push_qual(Query *subquery,
+ RangeTblEntry *rte, Index rti, Node *qual);
static void recurse_push_qual(Node *setOp, Query *topquery,
- Index rti, Node *qual);
+ RangeTblEntry *rte, Index rti, Node *qual);
/*
@@ -375,7 +376,7 @@ set_subquery_pathlist(Query *root, RelOptInfo *rel,
if (qual_is_pushdown_safe(subquery, rti, clause, differentTypes))
{
/* Push it down */
- subquery_push_qual(subquery, rti, clause);
+ subquery_push_qual(subquery, rte, rti, clause);
}
else
{
@@ -778,12 +779,12 @@ qual_is_pushdown_safe(Query *subquery, Index rti, Node *qual,
* subquery_push_qual - push down a qual that we have determined is safe
*/
static void
-subquery_push_qual(Query *subquery, Index rti, Node *qual)
+subquery_push_qual(Query *subquery, RangeTblEntry *rte, Index rti, Node *qual)
{
if (subquery->setOperations != NULL)
{
/* Recurse to push it separately to each component query */
- recurse_push_qual(subquery->setOperations, subquery, rti, qual);
+ recurse_push_qual(subquery->setOperations, subquery, rte, rti, qual);
}
else
{
@@ -797,7 +798,7 @@ subquery_push_qual(Query *subquery, Index rti, Node *qual)
* This step also ensures that when we are pushing into a setop tree,
* each component query gets its own copy of the qual.
*/
- qual = ResolveNew(qual, rti, 0,
+ qual = ResolveNew(qual, rti, 0, rte,
subquery->targetList,
CMD_SELECT, 0);
subquery->havingQual = make_and_qual(subquery->havingQual,
@@ -816,23 +817,23 @@ subquery_push_qual(Query *subquery, Index rti, Node *qual)
*/
static void
recurse_push_qual(Node *setOp, Query *topquery,
- Index rti, Node *qual)
+ RangeTblEntry *rte, Index rti, Node *qual)
{
if (IsA(setOp, RangeTblRef))
{
RangeTblRef *rtr = (RangeTblRef *) setOp;
- RangeTblEntry *rte = rt_fetch(rtr->rtindex, topquery->rtable);
- Query *subquery = rte->subquery;
+ RangeTblEntry *subrte = rt_fetch(rtr->rtindex, topquery->rtable);
+ Query *subquery = subrte->subquery;
Assert(subquery != NULL);
- subquery_push_qual(subquery, rti, qual);
+ subquery_push_qual(subquery, rte, rti, qual);
}
else if (IsA(setOp, SetOperationStmt))
{
SetOperationStmt *op = (SetOperationStmt *) setOp;
- recurse_push_qual(op->larg, topquery, rti, qual);
- recurse_push_qual(op->rarg, topquery, rti, qual);
+ recurse_push_qual(op->larg, topquery, rte, rti, qual);
+ recurse_push_qual(op->rarg, topquery, rte, rti, qual);
}
else
{