{{ message }}

# CASE expressions with constants are not evaluated correctly #3932

Closed
opened this issue Nov 30, 2020 · 0 comments
Closed

# CASE expressions with constants are not evaluated correctly#3932

opened this issue Nov 30, 2020 · 0 comments
Labels

### monetdb-team commented Nov 30, 2020

Date: 2016-02-25 09:56:44 +0100
From: Arno Mittelbach <<arno.mittelbach>>
To: SQL devs <>
Version: 11.21.13 (Jul2015-SP2)

Last updated: 2016-03-25 09:59:18 +0100

## Comment 21821

Date: 2016-02-25 09:56:44 +0100
From: Arno Mittelbach <<arno.mittelbach>>

User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36
Build Identifier:

For preparation consider the following simple table with one entry.

Create table a (a varchar(5), b varchar(10));
insert into a values ('12345','1234567890');

Now, the following statement outputs, as expected, 1234567890:

SELECT CASE WHEN 1=2 THEN a ELSE b END from a;

Result: 1234567890

However, when putting in a constant value then MonetDb returns an odd result:

SELECT CASE WHEN 1=2 THEN a ELSE 'lala' END from a;

Result: Px?~

The result is even varying if you run the query multiple times.

Reproducible: Always

### Steps to Reproduce:

1. Create table a (a varchar(5), b varchar(10));
2. insert into a values ('12345','1234567890');
3. SELECT CASE WHEN 1=2 THEN a ELSE 'lala' END from a;

Px?~

### Expected Results:

'lala'

As CASE expressions are quite standard and this may lead to wrong results I've set the Severity to critical.

## Comment 21831

Date: 2016-02-26 15:47:19 +0100
From: MonetDB Mercurial Repository <>

Changeset 200c19adf549 made by Sjoerd Mullender sjoerd@acm.org in the MonetDB repo, refers to this bug.

Changeset description:

``````Use VALptr instead of getArgReference to get correct indirection.
This fixes bug #3932.
``````

## Comment 21832

Date: 2016-02-26 15:47:37 +0100
From: @sjoerdmullender

Fixed.

## Comment 21959

Date: 2016-03-25 09:59:18 +0100
From: @sjoerdmullender

Jul2015-SP3 has been released.