From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: bugatti2.5sp@gmail.com
Subject: BUG #16712: Wrong Sub-Query Record Filtering
Date: Thu, 12 Nov 2020 14:26:58 +0000
Message-ID: <16712-4cf5381d0fe6790f@postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 16712
Logged by: SP
Email address: bugatti2.5sp@gmail.com
PostgreSQL version: 13.0
Operating system: seems any (tested on Ubuntu 18.04 and macOS 10.15)
Description:
An unexpected result returns when running this query:
WITH data_cte(str) AS (
SELECT *
FROM (VALUES ('a')) data_tmp(str)
WHERE FALSE
)
SELECT str::INTEGER
FROM data_cte;
While empty result is expected, we get this:
ERROR: invalid input syntax for type integer: "a"
Because of these type casting error, it seems that the outer query has
access to the data_cte record!
The strange thing is that if records of data_tmp (or data_cte, it doesn't
matter) be more than one, result will be true. So, for this query:
WITH data_cte(str) AS (
SELECT *
FROM (VALUES ('1a'), ('2b')) data_tmp(str)
WHERE FALSE
)
SELECT str::INTEGER
FROM data_cte;
we get this:
substring
-----------
(0 rows)
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 using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, bugatti2.5sp@gmail.com
Subject: Re: BUG #16712: Wrong Sub-Query Record Filtering
In-Reply-To: <16712-4cf5381d0fe6790f@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