From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: luza.mbox@gmail.com
Subject: BUG #16212: subquery block allows to overwrite table alias defined earlier
Date: Thu, 16 Jan 2020 22:36:16 +0000
Message-ID: <16212-cc31996adcf45996@postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 16212
Logged by: Denis Girko
Email address: luza.mbox@gmail.com
PostgreSQL version: 9.6.16
Operating system: Linux
Description:
Short example to illustrate the issue:
SELECT
a,
b.p,
c.p
FROM
(VALUES (1)) a
JOIN LATERAL (
SELECT p FROM (VALUES (2)) p
) b ON TRUE
JOIN LATERAL (
SELECT p FROM (VALUES (3)) p
) c ON TRUE
;
Expected result ((1), (2), (3))
Actual result ((1), (2), (2)).
("p" introduced in second JOIN overwrites the one defined by first)
Regular JOIN (not LATERAL) is not the subject of such an issue.
Another example:
SELECT
a,
b.a
FROM
(VALUES (1)) a
JOIN (
SELECT a FROM (VALUES (2)) a
) b ON TRUE
;
Expected result ((1), (2))
Actual result ((2), (2)).
(JOIN overwrites the "a" defined before)
Both regular and lateral JOIN show the same behaviour.
Scalars also can cause the same result:
SELECT
a,
b.a
FROM
(VALUES (1)) a
JOIN (
SELECT 2 AS a
) b ON TRUE
;
Expected result ((1), 2)
Actual result (2, 2).
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: noreply@postgresql.org, luza.mbox@gmail.com
Subject: Re: BUG #16212: subquery block allows to overwrite table alias defined earlier
In-Reply-To: <16212-cc31996adcf45996@postgresql.org>
References: <16212-cc31996adcf45996@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