From: julius.tuskenis@gmail.com
To: pgsql-bugs@postgresql.org
Subject: BUG #14665: Wrong IS NULL result for composite type that has composite element
Date: Tue, 23 May 2017 13:53:27 +0000
Message-ID: <20170523135327.29942.17412@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: 14665
Logged by: Julius Tuskenis
Email address: julius.tuskenis@gmail.com
PostgreSQL version: 9.6.3
Operating system: Windows 10
Description:
According to the documentation
(https://www.postgresql.org/docs/9.4/static/functions-comparison.html) "If
the expression is row-valued, then IS NULL is true when the row expression
itself is null or when all the row's fields are null"
The problem is with the composite types that have composite types in them.
In cases then a subtype has all NULL fields the type is still evaluated NOT
NULL.
The code to reproduce the problem:
CREATE TYPE public.my_point AS
(x integer,
y integer);
ALTER TYPE public.my_point
OWNER TO postgres;
/*A pixel has a colored point */
CREATE TYPE public.my_pixel AS
(p public.my_point,
color integer);
ALTER TYPE public.my_pixel
OWNER TO postgres;
SELECT
(a).p IS NULL AS point_is_null
, (a).color IS NULL AS color_is_null
, (a) IS NULL as my_pixel_is_null
FROM (
VALUES
((ROW(1,2), 1)::my_pixel)
, ((ROW(1,2), NULL)::my_pixel)
, ((ROW(NULL,NULL), NULL)::my_pixel)
, ((NULL, NULL)::my_pixel)
) AS tbl(a);
RESULT:
f;f;f
f;t;f
t;t;f <-- components are NULL, but the result is not...
t;t;t
--
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: julius.tuskenis@gmail.com
Subject: Re: BUG #14665: Wrong IS NULL result for composite type that has composite element
In-Reply-To: <20170523135327.29942.17412@wrigleys.postgresql.org>
References: <20170523135327.29942.17412@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