BUG #14385: Operator IS changed priority in 9.5

From: strahinjak(at)nordeus(dot)com
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #14385: Operator IS changed priority in 9.5
Date: 2016-10-20 08:50:35
Message-ID: 20161020085035.1413.58037@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 14385
Logged by: Strahinja Kustudic
Email address: strahinjak(at)nordeus(dot)com
PostgreSQL version: 9.5.4
Operating system: CentOS 6
Description:

If we create a test table like this:

test-# create table test (i integer, b boolean);

And insert the following data:

test-# insert into test (i) values (5), (null);
test-# update test set b = i is not null;

When we run the following select on Postgres 9.1-9.4:
test-# select
test-# 'aaa' || i is not null || 'bbb' as v1,
test-# 'aaa' || b || 'bbb' as v2,
test-# 'aaa' || i is not null || 'bbb' = 'aaa' || b || 'bbb' as v1_eq_v2
test-# from test;
v1 | v2 | v1_eq_v2
-------------+-------------+----------
aaatruebbb | aaatruebbb | t
aaafalsebbb | aaafalsebbb | t
(2 rows)

but if we run the same query on 9.5 we get a different output:

test-# select
test-# 'aaa' || i is not null || 'bbb' as v1,
test-# 'aaa' || b || 'bbb' as v2,
test-# 'aaa' || i is not null || 'bbb' = 'aaa' || b || 'bbb' as v1_eq_v2
test-# from test;
v1 | v2 | v1_eq_v2
----------+-------------+----------
truebbb | aaatruebbb | f
falsebbb | aaafalsebbb | f
(2 rows)

As you can see 9.5 removes the first 'aaa' string from concatenation. We
guess it's because of the operator IS priority has changed in 9.5, because
if we put 'i is not null' between parenthesis, it works like before 9.5:

test-# select
test-# 'aaa' || (i is not null) || 'bbb' as v1,
test-# 'aaa' || b || 'bbb' as v2,
test-# 'aaa' || (i is not null) || 'bbb' = 'aaa' || b || 'bbb' as
v1_eq_v2
test-# from test;
v1 | v2 | v1_eq_v2
-------------+-------------+----------
aaatruebbb | aaatruebbb | t
aaafalsebbb | aaafalsebbb | t
(2 rows)

We couldn't find any documentation changes about this, so is this a bug, or
was it intentional?

Browse pgsql-bugs by date

  From Date Subject
Next Message Strahinja Kustudić 2016-10-20 09:12:48 Re: BUG #14385: Operator IS changed priority in 9.5
Previous Message boleslaw.ziobrowski 2016-10-20 07:56:49 BUG #14384: pg_dump uses excessive amounts of memory for LOBs