diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2003-01-09 20:50:53 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2003-01-09 20:50:53 +0000 |
commit | 6bc61fc046961cfc2b3901ab38ac74b45f8c6cd3 (patch) | |
tree | a29a0825d52ba55e9971b8df6c4a530cc90a5bff /src/include/nodes/primnodes.h | |
parent | 59779c81ba9e6ea29cec1a59d0cfdbe76fa016ff (diff) | |
download | postgresql-6bc61fc046961cfc2b3901ab38ac74b45f8c6cd3.tar.gz postgresql-6bc61fc046961cfc2b3901ab38ac74b45f8c6cd3.zip |
Adjust parser so that 'x NOT IN (subselect)' is converted to
'NOT (x IN (subselect))', that is 'NOT (x = ANY (subselect))',
rather than 'x <> ALL (subselect)' as we formerly did. This
opens the door to optimizing NOT IN the same way as IN, whereas
there's no hope of optimizing the expression using <>. Also,
convert 'x <> ALL (subselect)' to the NOT(IN) style, so that
the optimization will be available when processing rules dumped
by older Postgres versions.
initdb forced due to small change in SubLink node representation.
Diffstat (limited to 'src/include/nodes/primnodes.h')
-rw-r--r-- | src/include/nodes/primnodes.h | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/include/nodes/primnodes.h b/src/include/nodes/primnodes.h index 285a0008fdc..d9ea05994dd 100644 --- a/src/include/nodes/primnodes.h +++ b/src/include/nodes/primnodes.h @@ -10,7 +10,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: primnodes.h,v 1.75 2002/12/14 00:17:59 tgl Exp $ + * $Id: primnodes.h,v 1.76 2003/01/09 20:50:53 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -374,7 +374,7 @@ typedef struct BoolExpr * MULTIEXPR and EXPR require the subselect to deliver only one row. * ALL, ANY, and MULTIEXPR require the combining operators to deliver boolean * results. These are reduced to one result per row using OR or AND semantics - * depending on the "useor" flag. ALL and ANY combine the per-row results + * depending on the "useOr" flag. ALL and ANY combine the per-row results * using AND and OR semantics respectively. * * SubLink is classed as an Expr node, but it is not actually executable; @@ -395,7 +395,11 @@ typedef struct BoolExpr * rewriter. * * In EXISTS and EXPR SubLinks, both lefthand and oper are unused and are - * always NIL. useor is not significant either for these sublink types. + * always NIL. useOr is not significant either for these sublink types. + * + * The operIsEquals field is TRUE when the combining operator was written as + * "=" --- if the subLinkType is ANY_SUBLINK, this means the operation is + * equivalent to "IN". This case allows special optimizations to be used. * ---------------- */ typedef enum SubLinkType @@ -408,7 +412,8 @@ typedef struct SubLink { Expr xpr; SubLinkType subLinkType; /* EXISTS, ALL, ANY, MULTIEXPR, EXPR */ - bool useor; /* TRUE to combine column results with + bool operIsEquals; /* TRUE if combining operator is "=" */ + bool useOr; /* TRUE to combine column results with * "OR" not "AND" */ List *lefthand; /* list of outer-query expressions on the * left */ @@ -446,7 +451,7 @@ typedef struct SubPlan Expr xpr; /* Fields copied from original SubLink: */ SubLinkType subLinkType; /* EXISTS, ALL, ANY, MULTIEXPR, EXPR */ - bool useor; /* TRUE to combine column results with + bool useOr; /* TRUE to combine column results with * "OR" not "AND" */ List *oper; /* list of executable expressions for * combining operators (with arguments) */ |