From: andrew@tao11.riddles.org.uk
To: pgsql-bugs@postgresql.org
Subject: BUG #14235: inconsistencies with IS NULL / IS NOT NULL
Date: Fri, 08 Jul 2016 02:47:46 +0000
Message-ID: <20160708024746.1410.57282@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
The following bug has been logged on the website:
Bug reference: 14235
Logged by: Andrew Gierth
Email address: andrew@tao11.riddles.org.uk
PostgreSQL version: 9.6beta2
Operating system: any
Description:
While discussing the issues resulting from the spec's definition of IS NULL
and IS NOT NULL on composite values, we discovered the following
inconsistent cases, all of which appear to be the fault of
eval_const_expressions.
In short, the transformations applied to NullTest nodes change the
semantics, which can then make the final result depend on, for example,
whether function calls were inlined or not.
create type ct1 as (a integer, b integer);
create type ct2 as (a integer, b ct1);
create type ct3 as (a integer, b ct2);
create function make_ct1(integer,integer) returns ct1
language sql immutable
as $f$ select row($1,$2*$2)::ct1; $f$;
create function make_ct2(integer,integer) returns ct2
language sql immutable
as $f$ select row($1,row($2,$2)::ct1)::ct2; $f$;
create function make_ct3(integer,integer) returns ct3
language sql immutable
as $f$ select row($1,row($2,row($2,$2)::ct1)::ct2)::ct3; $f$;
create function stable_null() returns integer
language plpgsql stable cost 1
as $f$ begin return null; end; $f$;
create function volatile_null() returns integer
language plpgsql volatile cost 1000
as $f$ begin return null; end; $f$;
select row(null,null)::ct1 is null as ct1,
row(null,row(null,null)::ct1)::ct2 is null as ct2,
row(null,row(null,row(null,null)::ct1)::ct2)::ct3 is null as ct3;
select row(1,null)::ct1 is not null as row_cons,
'(1,)'::ct1 is not null as row_literal,
make_ct1(1,null) is not null as inlined_const,
make_ct1(1,stable_null()) is not null as inlined_func,
make_ct1(1,volatile_null()) is not null as called_func;
select row(1,row(null,null)::ct1)::ct2 is not null as row_cons,
'(1,"(,)")'::ct2 is not null as row_literal,
make_ct2(1,null) is not null as inlined_const,
make_ct2(1,stable_null()) is not null as inlined_func,
make_ct2(1,volatile_null()) is not null as called_func;
select row(1,row(null,row(null,null)::ct1)::ct2)::ct3 is not null as
row_cons,
'(1,"(,""(,)"")")'::ct3 is not null as row_literal,
make_ct3(1,null) is not null as inlined_const,
make_ct3(1,stable_null()) is not null as inlined_func,
make_ct3(1,volatile_null()) is not null as called_func;
select row(null,null)::ct1 is null as row_cons,
'(,)'::ct1 is null as row_literal,
make_ct1(null,null) is null as inlined_const,
make_ct1(null,stable_null()) is null as inlined_func,
make_ct1(null,volatile_null()) is null as called_func;
select row(null,row(null,null)::ct1)::ct2 is null as row_cons,
'(,"(,)")'::ct2 is null as row_literal,
make_ct2(null,null) is null as inlined_const,
make_ct2(null,stable_null()) is null as inlined_func,
make_ct2(null,volatile_null()) is null as called_func;
select row(null,row(null,row(null,null)::ct1)::ct2)::ct3 is null as
row_cons,
'(,"(,""(,)"")")'::ct3 is null as row_literal,
make_ct3(null,null) is null as inlined_const,
make_ct3(null,stable_null()) is null as inlined_func,
make_ct3(null,volatile_null()) is null as called_func;
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: andrew@tao11.riddles.org.uk
Subject: Re: BUG #14235: inconsistencies with IS NULL / IS NOT NULL
In-Reply-To: <20160708024746.1410.57282@wrigleys.postgresql.org>
References: <20160708024746.1410.57282@wrigleys.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox