Return-Path: X-Original-To: apmail-db-derby-dev-archive@www.apache.org Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E77251099C for ; Wed, 2 Oct 2013 10:36:28 +0000 (UTC) Received: (qmail 96072 invoked by uid 500); 2 Oct 2013 10:36:28 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 95201 invoked by uid 500); 2 Oct 2013 10:36:27 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 95149 invoked by uid 99); 2 Oct 2013 10:36:26 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Oct 2013 10:36:26 +0000 Date: Wed, 2 Oct 2013 10:36:26 +0000 (UTC) From: =?utf-8?Q?Grzegorz_=C5=BBur_=28JIRA=29?= To: derby-dev@db.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Created] (DERBY-6365) Incorrect evaluation of logical expressions in CASE MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 Grzegorz =C5=BBur created DERBY-6365: ----------------------------------- Summary: Incorrect evaluation of logical expressions in CASE Key: DERBY-6365 URL: https://issues.apache.org/jira/browse/DERBY-6365 Project: Derby Issue Type: Bug Components: SQL Affects Versions: 10.10.1.1, 10.8.3.0, 10.4.1.3 Reporter: Grzegorz =C5=BBur Logical expressions with AND and OR operators inside WHEN inside CASE expre= ssion nested in SELECT part of statement are wrongly evaluated. Evaluation results depends on position of OR subexpression. If OR is placed= on left side of AND it is evaluated incorrectly. Following code shows the error. create table t ( a int, b char ); insert into t values (1, 'a'); insert into t values (2, 'b'); insert into t values (3, 'a'); insert into t values (4, 'b'); insert into t values (5, 'a'); insert into t values (6, 'b'); select a, b, case when (( b =3D 'a' or b =3D 'b' ) and a < 4) then 'x' else '-' end, case when (a < 4 and ( b =3D 'a' or b =3D 'b' )) then 'y' else '-' end from t; Actual result: 1 a x y 2 b - y 3 a x y 4 b - - 5 a - - 6 b - - Expected result 1 a x y 2 b x y 3 a x y 4 b - - 5 a - - 6 b - - -- This message was sent by Atlassian JIRA (v6.1#6144)