From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | bugatti2(dot)5sp(at)gmail(dot)com, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org> |
Subject: | Re: BUG #16712: Wrong Sub-Query Record Filtering |
Date: | 2020-11-12 14:53:43 |
Message-ID: | CAKFQuwZXqzhmf5vp1w7eu0MnCP6=y=b5sb8e6nmkgVViF2Rpdg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On Thu, Nov 12, 2020 at 7:34 AM PG Bug reporting form <
noreply(at)postgresql(dot)org> wrote:
> The following bug has been logged on the website:
>
> Bug reference: 16712
> Logged by: SP
> Email address: bugatti2(dot)5sp(at)gmail(dot)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!
>
>
It does - right there in the "FROM data_cte" clause. The planner has
chosen to optimize this query by taking the two parts and making them one,
reducing a level of execution indirection. If you don't wish for this to
happen you need to add MATERIALIZED to the WITH clause element. This is
one of the more impactful changes with v13, in prior versions materialized
was the default (and optimization was not possible).
David J.
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2020-11-12 15:32:13 | Re: Problem with extract function ? |
Previous Message | PG Bug reporting form | 2020-11-12 14:26:58 | BUG #16712: Wrong Sub-Query Record Filtering |