summaryrefslogtreecommitdiff
path: root/src/backend/parser/parse_expr.c
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2011-10-08 11:17:40 +0300
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2011-10-08 11:21:14 +0300
commit3a2f6b570fbc6f71447c013e866d554fc515de0e (patch)
tree1dd275ba4f28bfd420d071f27e11f5967d995e17 /src/backend/parser/parse_expr.c
parentb0d5469a04aac226d140edc3dfedd8aac87310d6 (diff)
Don't let transform_null_equals=on affect CASE foo WHEN NULL ... constructs.
transform_null_equals is only supposed to affect "foo = NULL" expressions given directly by the user, not the internal "foo = NULL" expression generated from CASE-WHEN. This fixes bug #6242, reported by Sergey. Backpatch to all supported branches.
Diffstat (limited to 'src/backend/parser/parse_expr.c')
-rw-r--r--src/backend/parser/parse_expr.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/backend/parser/parse_expr.c b/src/backend/parser/parse_expr.c
index 78dca832a94..98b85724648 100644
--- a/src/backend/parser/parse_expr.c
+++ b/src/backend/parser/parse_expr.c
@@ -632,12 +632,15 @@ transformAExprOp(ParseState *pstate, A_Expr *a)
/*
* Special-case "foo = NULL" and "NULL = foo" for compatibility with
* standards-broken products (like Microsoft's). Turn these into IS NULL
- * exprs.
+ * exprs. (If either side is a CaseTestExpr, then the expression was
+ * generated internally from a CASE-WHEN expression, and
+ * transform_null_equals does not apply.)
*/
if (Transform_null_equals &&
list_length(a->name) == 1 &&
strcmp(strVal(linitial(a->name)), "=") == 0 &&
- (exprIsNullConstant(lexpr) || exprIsNullConstant(rexpr)))
+ (exprIsNullConstant(lexpr) || exprIsNullConstant(rexpr)) &&
+ (!IsA(lexpr, CaseTestExpr) && !IsA(rexpr, CaseTestExpr)))
{
NullTest *n = makeNode(NullTest);