From 6bc61fc046961cfc2b3901ab38ac74b45f8c6cd3 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 9 Jan 2003 20:50:53 +0000 Subject: 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. --- src/backend/utils/adt/ruleutils.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/backend/utils/adt/ruleutils.c') 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: -- cgit v1.2.3