|
25 | 25 | *
|
26 | 26 | *
|
27 | 27 | * IDENTIFICATION
|
28 |
| - * $PostgreSQL: pgsql/src/backend/optimizer/prep/prepqual.c,v 1.49 2005/03/28 00:58:23 tgl Exp $ |
| 28 | + * $PostgreSQL: pgsql/src/backend/optimizer/prep/prepqual.c,v 1.50 2005/07/29 21:40:02 tgl Exp $ |
29 | 29 | *
|
30 | 30 | *-------------------------------------------------------------------------
|
31 | 31 | */
|
@@ -167,9 +167,6 @@ pull_ors(List *orlist)
|
167 | 167 | static Expr *
|
168 | 168 | find_nots(Expr *qual)
|
169 | 169 | {
|
170 |
| - if (qual == NULL) |
171 |
| - return NULL; |
172 |
| - |
173 | 170 | if (and_clause((Node *) qual))
|
174 | 171 | {
|
175 | 172 | List *t_list = NIL;
|
@@ -204,17 +201,13 @@ find_nots(Expr *qual)
|
204 | 201 | static Expr *
|
205 | 202 | push_nots(Expr *qual)
|
206 | 203 | {
|
207 |
| - if (qual == NULL) |
208 |
| - return make_notclause(qual); /* XXX is this right? Or |
209 |
| - * possible? */ |
210 |
| - |
211 |
| - /* |
212 |
| - * Negate an operator clause if possible: (NOT (< A B)) => (>= A B) |
213 |
| - * Otherwise, retain the clause as it is (the NOT can't be pushed down |
214 |
| - * any farther). |
215 |
| - */ |
216 | 204 | if (is_opclause(qual))
|
217 | 205 | {
|
| 206 | + /* |
| 207 | + * Negate an operator clause if possible: (NOT (< A B)) => (>= A B) |
| 208 | + * Otherwise, retain the clause as it is (the NOT can't be pushed down |
| 209 | + * any farther). |
| 210 | + */ |
218 | 211 | OpExpr *opexpr = (OpExpr *) qual;
|
219 | 212 | Oid negator = get_negator(opexpr->opno);
|
220 | 213 |
|
@@ -256,15 +249,16 @@ push_nots(Expr *qual)
|
256 | 249 | {
|
257 | 250 | /*
|
258 | 251 | * Another NOT cancels this NOT, so eliminate the NOT and stop
|
259 |
| - * negating this branch. |
| 252 | + * negating this branch. But search the subexpression for more |
| 253 | + * NOTs to simplify. |
260 | 254 | */
|
261 |
| - return get_notclausearg(qual); |
| 255 | + return find_nots(get_notclausearg(qual)); |
262 | 256 | }
|
263 | 257 | else
|
264 | 258 | {
|
265 | 259 | /*
|
266 | 260 | * We don't know how to negate anything else, place a NOT at this
|
267 |
| - * level. |
| 261 | + * level. No point in recursing deeper, either. |
268 | 262 | */
|
269 | 263 | return make_notclause(qual);
|
270 | 264 | }
|
@@ -303,9 +297,6 @@ push_nots(Expr *qual)
|
303 | 297 | static Expr *
|
304 | 298 | find_duplicate_ors(Expr *qual)
|
305 | 299 | {
|
306 |
| - if (qual == NULL) |
307 |
| - return NULL; |
308 |
| - |
309 | 300 | if (or_clause((Node *) qual))
|
310 | 301 | {
|
311 | 302 | List *orlist = NIL;
|
|
0 commit comments