88 *
99 *
1010 * IDENTIFICATION
11- * $PostgreSQL: pgsql/src/backend/optimizer/util/restrictinfo.c,v 1.41 2005/10/15 02:49:21 momjian Exp $
11+ * $PostgreSQL: pgsql/src/backend/optimizer/util/restrictinfo.c,v 1.42 2005/11/14 23:54:22 tgl Exp $
1212 *
1313 *-------------------------------------------------------------------------
1414 */
2525static RestrictInfo * make_restrictinfo_internal (Expr * clause ,
2626Expr * orclause ,
2727bool is_pushed_down ,
28+ bool outerjoin_delayed ,
2829Relids required_relids );
2930static Expr * make_sub_restrictinfos (Expr * clause ,
30- bool is_pushed_down );
31+ bool is_pushed_down ,
32+ bool outerjoin_delayed );
3133static RestrictInfo * join_clause_is_redundant (PlannerInfo * root ,
3234RestrictInfo * rinfo ,
3335List * reference_list ,
@@ -39,28 +41,34 @@ static RestrictInfo *join_clause_is_redundant(PlannerInfo *root,
3941 *
4042 * Build a RestrictInfo node containing the given subexpression.
4143 *
42- * The is_pushed_downflag must be supplied by the caller.
43- * required_relids can be NULL, in which case it defaults to the
44+ * The is_pushed_downand outerjoin_delayed flags must be supplied by the
45+ *caller. required_relids can be NULL, in which case it defaults to the
4446 * actual clause contents (i.e., clause_relids).
4547 *
4648 * We initialize fields that depend only on the given subexpression, leaving
4749 * others that depend on context (or may never be needed at all) to be filled
4850 * later.
4951 */
5052RestrictInfo *
51- make_restrictinfo (Expr * clause ,bool is_pushed_down ,Relids required_relids )
53+ make_restrictinfo (Expr * clause ,
54+ bool is_pushed_down ,
55+ bool outerjoin_delayed ,
56+ Relids required_relids )
5257{
5358/*
5459 * If it's an OR clause, build a modified copy with RestrictInfos inserted
5560 * above each subclause of the top-level AND/OR structure.
5661 */
5762if (or_clause ((Node * )clause ))
58- return (RestrictInfo * )make_sub_restrictinfos (clause ,is_pushed_down );
63+ return (RestrictInfo * )make_sub_restrictinfos (clause ,
64+ is_pushed_down ,
65+ outerjoin_delayed );
5966
6067/* Shouldn't be an AND clause, else AND/OR flattening messed up */
6168Assert (!and_clause ((Node * )clause ));
6269
63- return make_restrictinfo_internal (clause ,NULL ,is_pushed_down ,
70+ return make_restrictinfo_internal (clause ,NULL ,
71+ is_pushed_down ,outerjoin_delayed ,
6472required_relids );
6573}
6674
@@ -74,6 +82,9 @@ make_restrictinfo(Expr *clause, bool is_pushed_down, Relids required_relids)
7482 * The result is a List (effectively, implicit-AND representation) of
7583 * RestrictInfos.
7684 *
85+ * The caller must pass is_pushed_down, but we assume outerjoin_delayed
86+ * is false (no such qual should ever get into a bitmapqual).
87+ *
7788 * If include_predicates is true, we add any partial index predicates to
7889 * the explicit index quals. When this is not true, we return a condition
7990 * that might be weaker than the actual scan represents.
@@ -169,6 +180,7 @@ make_restrictinfo_from_bitmapqual(Path *bitmapqual,
169180list_make1 (make_restrictinfo_internal (make_orclause (withoutris ),
170181make_orclause (withris ),
171182is_pushed_down ,
183+ false,
172184NULL ));
173185}
174186}
@@ -193,6 +205,7 @@ make_restrictinfo_from_bitmapqual(Path *bitmapqual,
193205result = lappend (result ,
194206make_restrictinfo (pred ,
195207is_pushed_down ,
208+ false,
196209NULL ));
197210}
198211}
@@ -213,13 +226,15 @@ make_restrictinfo_from_bitmapqual(Path *bitmapqual,
213226 */
214227static RestrictInfo *
215228make_restrictinfo_internal (Expr * clause ,Expr * orclause ,
216- bool is_pushed_down ,Relids required_relids )
229+ bool is_pushed_down ,bool outerjoin_delayed ,
230+ Relids required_relids )
217231{
218232RestrictInfo * restrictinfo = makeNode (RestrictInfo );
219233
220234restrictinfo -> clause = clause ;
221235restrictinfo -> orclause = orclause ;
222236restrictinfo -> is_pushed_down = is_pushed_down ;
237+ restrictinfo -> outerjoin_delayed = outerjoin_delayed ;
223238restrictinfo -> can_join = false;/* may get set below */
224239
225240/*
@@ -299,7 +314,8 @@ make_restrictinfo_internal(Expr *clause, Expr *orclause,
299314 * simple clauses are valid RestrictInfos.
300315 */
301316static Expr *
302- make_sub_restrictinfos (Expr * clause ,bool is_pushed_down )
317+ make_sub_restrictinfos (Expr * clause ,
318+ bool is_pushed_down ,bool outerjoin_delayed )
303319{
304320if (or_clause ((Node * )clause ))
305321{
@@ -309,10 +325,12 @@ make_sub_restrictinfos(Expr *clause, bool is_pushed_down)
309325foreach (temp , ((BoolExpr * )clause )-> args )
310326orlist = lappend (orlist ,
311327make_sub_restrictinfos (lfirst (temp ),
312- is_pushed_down ));
328+ is_pushed_down ,
329+ outerjoin_delayed ));
313330return (Expr * )make_restrictinfo_internal (clause ,
314331make_orclause (orlist ),
315332is_pushed_down ,
333+ outerjoin_delayed ,
316334NULL );
317335}
318336else if (and_clause ((Node * )clause ))
@@ -323,13 +341,15 @@ make_sub_restrictinfos(Expr *clause, bool is_pushed_down)
323341foreach (temp , ((BoolExpr * )clause )-> args )
324342andlist = lappend (andlist ,
325343make_sub_restrictinfos (lfirst (temp ),
326- is_pushed_down ));
344+ is_pushed_down ,
345+ outerjoin_delayed ));
327346return make_andclause (andlist );
328347}
329348else
330349return (Expr * )make_restrictinfo_internal (clause ,
331350NULL ,
332351is_pushed_down ,
352+ outerjoin_delayed ,
333353NULL );
334354}
335355