aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/ruleutils.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2003-01-09 20:50:53 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2003-01-09 20:50:53 +0000
commit6bc61fc046961cfc2b3901ab38ac74b45f8c6cd3 (patch)
treea29a0825d52ba55e9971b8df6c4a530cc90a5bff /src/backend/utils/adt/ruleutils.c
parent59779c81ba9e6ea29cec1a59d0cfdbe76fa016ff (diff)
downloadpostgresql-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/backend/utils/adt/ruleutils.c')
-rw-r--r--src/backend/utils/adt/ruleutils.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 0275d8424ac..a8679463670 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -3,7 +3,7 @@
* back to source text
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.130 2003/01/08 22:54:06 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.131 2003/01/09 20:50:52 tgl Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
@@ -2660,8 +2660,16 @@ get_sublink_expr(SubLink *sublink, deparse_context *context)
break;
case ANY_SUBLINK:
- oper = (OpExpr *) lfirst(sublink->oper);
- appendStringInfo(buf, "%s ANY ", get_opname(oper->opno));
+ if (sublink->operIsEquals)
+ {
+ /* Represent it as IN */
+ appendStringInfo(buf, "IN ");
+ }
+ else
+ {
+ oper = (OpExpr *) lfirst(sublink->oper);
+ appendStringInfo(buf, "%s ANY ", get_opname(oper->opno));
+ }
break;
case ALL_SUBLINK: