mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-21 08:29:39 +08:00
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.
This commit is contained in:
parent
041dceb259
commit
1ef60dab70
@ -836,12 +836,15 @@ transformAExprOp(ParseState *pstate, A_Expr *a)
|
|||||||
/*
|
/*
|
||||||
* Special-case "foo = NULL" and "NULL = foo" for compatibility with
|
* Special-case "foo = NULL" and "NULL = foo" for compatibility with
|
||||||
* standards-broken products (like Microsoft's). Turn these into IS NULL
|
* 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 &&
|
if (Transform_null_equals &&
|
||||||
list_length(a->name) == 1 &&
|
list_length(a->name) == 1 &&
|
||||||
strcmp(strVal(linitial(a->name)), "=") == 0 &&
|
strcmp(strVal(linitial(a->name)), "=") == 0 &&
|
||||||
(exprIsNullConstant(lexpr) || exprIsNullConstant(rexpr)))
|
(exprIsNullConstant(lexpr) || exprIsNullConstant(rexpr)) &&
|
||||||
|
(!IsA(lexpr, CaseTestExpr) && !IsA(rexpr, CaseTestExpr)))
|
||||||
{
|
{
|
||||||
NullTest *n = makeNode(NullTest);
|
NullTest *n = makeNode(NullTest);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user