aboutsummaryrefslogtreecommitdiff
path: root/src/backend/optimizer/prep/prepjointree.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2004-01-10 18:13:53 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2004-01-10 18:13:53 +0000
commita43f4307f78bd80e88cdfb5f36ad59819c4b552e (patch)
tree165a62f6d559cee487cc876dd51784ab4601652b /src/backend/optimizer/prep/prepjointree.c
parent47f8f3340950aeaf833338c75db2e64736bc3eca (diff)
downloadpostgresql-a43f4307f78bd80e88cdfb5f36ad59819c4b552e.tar.gz
postgresql-a43f4307f78bd80e88cdfb5f36ad59819c4b552e.zip
Improve has_nullable_targetlist() to allow strict functions of simple
variables, not just simple variables. This was foreseen in the original coding of this routine, but not implemented until now. Responds to performance gripe from Laurent Perez.
Diffstat (limited to 'src/backend/optimizer/prep/prepjointree.c')
-rw-r--r--src/backend/optimizer/prep/prepjointree.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/backend/optimizer/prep/prepjointree.c b/src/backend/optimizer/prep/prepjointree.c
index 90485171d97..033aaba494e 100644
--- a/src/backend/optimizer/prep/prepjointree.c
+++ b/src/backend/optimizer/prep/prepjointree.c
@@ -16,7 +16,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/prep/prepjointree.c,v 1.15 2004/01/10 00:30:21 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/prep/prepjointree.c,v 1.16 2004/01/10 18:13:53 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -439,11 +439,13 @@ is_simple_subquery(Query *subquery)
/*
* has_nullable_targetlist
* Check a subquery in the range table to see if all the non-junk
- * targetlist items are simple variables (and, hence, will correctly
- * go to NULL when examined above the point of an outer join).
+ * targetlist items are simple variables or strict functions of simple
+ * variables (and, hence, will correctly go to NULL when examined above
+ * the point of an outer join).
*
- * A possible future extension is to accept strict functions of simple
- * variables, eg, "x + 1".
+ * NOTE: it would be correct (and useful) to ignore output columns that aren't
+ * actually referenced by the enclosing query ... but we do not have that
+ * information available at this point.
*/
static bool
has_nullable_targetlist(Query *subquery)
@@ -458,11 +460,15 @@ has_nullable_targetlist(Query *subquery)
if (tle->resdom->resjunk)
continue;
- /* Okay if tlist item is a simple Var */
- if (tle->expr && IsA(tle->expr, Var))
- continue;
+ /* Must contain a Var of current level */
+ if (!contain_vars_of_level((Node *) tle->expr, 0))
+ return false;
- return false;
+ /* Must not contain any non-strict constructs */
+ if (contain_nonstrict_functions((Node *) tle->expr))
+ return false;
+
+ /* This one's OK, keep scanning */
}
return true;
}