8
8
*
9
9
*
10
10
* 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 $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
25
25
static RestrictInfo * make_restrictinfo_internal (Expr * clause ,
26
26
Expr * orclause ,
27
27
bool is_pushed_down ,
28
+ bool outerjoin_delayed ,
28
29
Relids required_relids );
29
30
static Expr * make_sub_restrictinfos (Expr * clause ,
30
- bool is_pushed_down );
31
+ bool is_pushed_down ,
32
+ bool outerjoin_delayed );
31
33
static RestrictInfo * join_clause_is_redundant (PlannerInfo * root ,
32
34
RestrictInfo * rinfo ,
33
35
List * reference_list ,
@@ -39,28 +41,34 @@ static RestrictInfo *join_clause_is_redundant(PlannerInfo *root,
39
41
*
40
42
* Build a RestrictInfo node containing the given subexpression.
41
43
*
42
- * The is_pushed_down flag must be supplied by the caller.
43
- * required_relids can be NULL, in which case it defaults to the
44
+ * The is_pushed_down and outerjoin_delayed flags must be supplied by the
45
+ * caller. required_relids can be NULL, in which case it defaults to the
44
46
* actual clause contents (i.e., clause_relids).
45
47
*
46
48
* We initialize fields that depend only on the given subexpression, leaving
47
49
* others that depend on context (or may never be needed at all) to be filled
48
50
* later.
49
51
*/
50
52
RestrictInfo *
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 )
52
57
{
53
58
/*
54
59
* If it's an OR clause, build a modified copy with RestrictInfos inserted
55
60
* above each subclause of the top-level AND/OR structure.
56
61
*/
57
62
if (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 );
59
66
60
67
/* Shouldn't be an AND clause, else AND/OR flattening messed up */
61
68
Assert (!and_clause ((Node * ) clause ));
62
69
63
- return make_restrictinfo_internal (clause , NULL , is_pushed_down ,
70
+ return make_restrictinfo_internal (clause , NULL ,
71
+ is_pushed_down , outerjoin_delayed ,
64
72
required_relids );
65
73
}
66
74
@@ -74,6 +82,9 @@ make_restrictinfo(Expr *clause, bool is_pushed_down, Relids required_relids)
74
82
* The result is a List (effectively, implicit-AND representation) of
75
83
* RestrictInfos.
76
84
*
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
+ *
77
88
* If include_predicates is true, we add any partial index predicates to
78
89
* the explicit index quals. When this is not true, we return a condition
79
90
* that might be weaker than the actual scan represents.
@@ -169,6 +180,7 @@ make_restrictinfo_from_bitmapqual(Path *bitmapqual,
169
180
list_make1 (make_restrictinfo_internal (make_orclause (withoutris ),
170
181
make_orclause (withris ),
171
182
is_pushed_down ,
183
+ false,
172
184
NULL ));
173
185
}
174
186
}
@@ -193,6 +205,7 @@ make_restrictinfo_from_bitmapqual(Path *bitmapqual,
193
205
result = lappend (result ,
194
206
make_restrictinfo (pred ,
195
207
is_pushed_down ,
208
+ false,
196
209
NULL ));
197
210
}
198
211
}
@@ -213,13 +226,15 @@ make_restrictinfo_from_bitmapqual(Path *bitmapqual,
213
226
*/
214
227
static RestrictInfo *
215
228
make_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 )
217
231
{
218
232
RestrictInfo * restrictinfo = makeNode (RestrictInfo );
219
233
220
234
restrictinfo -> clause = clause ;
221
235
restrictinfo -> orclause = orclause ;
222
236
restrictinfo -> is_pushed_down = is_pushed_down ;
237
+ restrictinfo -> outerjoin_delayed = outerjoin_delayed ;
223
238
restrictinfo -> can_join = false; /* may get set below */
224
239
225
240
/*
@@ -299,7 +314,8 @@ make_restrictinfo_internal(Expr *clause, Expr *orclause,
299
314
* simple clauses are valid RestrictInfos.
300
315
*/
301
316
static 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 )
303
319
{
304
320
if (or_clause ((Node * ) clause ))
305
321
{
@@ -309,10 +325,12 @@ make_sub_restrictinfos(Expr *clause, bool is_pushed_down)
309
325
foreach (temp , ((BoolExpr * ) clause )-> args )
310
326
orlist = lappend (orlist ,
311
327
make_sub_restrictinfos (lfirst (temp ),
312
- is_pushed_down ));
328
+ is_pushed_down ,
329
+ outerjoin_delayed ));
313
330
return (Expr * ) make_restrictinfo_internal (clause ,
314
331
make_orclause (orlist ),
315
332
is_pushed_down ,
333
+ outerjoin_delayed ,
316
334
NULL );
317
335
}
318
336
else if (and_clause ((Node * ) clause ))
@@ -323,13 +341,15 @@ make_sub_restrictinfos(Expr *clause, bool is_pushed_down)
323
341
foreach (temp , ((BoolExpr * ) clause )-> args )
324
342
andlist = lappend (andlist ,
325
343
make_sub_restrictinfos (lfirst (temp ),
326
- is_pushed_down ));
344
+ is_pushed_down ,
345
+ outerjoin_delayed ));
327
346
return make_andclause (andlist );
328
347
}
329
348
else
330
349
return (Expr * ) make_restrictinfo_internal (clause ,
331
350
NULL ,
332
351
is_pushed_down ,
352
+ outerjoin_delayed ,
333
353
NULL );
334
354
}
335
355
0 commit comments