From: Mark Murawski <markm-lists@intellasoft.net>
To: pgsql-bugs@postgresql.org
Subject: Subquery with toplevel reference used to work in pg 8.4
Date: Sat, 24 Mar 2012 00:04:56 -0400
Message-ID: <4F6D47E8.2040209@intellasoft.net> (raw)
I agree the query is a little odd, but I like backwards compatibility!
Postgres 8.4.1
----------------------
CREATE VIEW v_members AS
SELECT
1 as member_id,
100 as tenant_id,
3732 as conference_id,
200 as uid
FROM
(select 1 as uid_user, 2 as uid_contact) as m;
SELECT
u.tenant_id,
u.uid
FROM
(select 100 as tenant_id, 200 as uid) u
LEFT JOIN v_members m ON (m.uid = u.uid AND m.conference_id = 3732)
WHERE
(
SELECT 1
FROM (select 3732 as conference_id) c
WHERE (c.conference_id = 3732) AND (m.uid IS NOT NULL)
) = 1;
tenant_id | uid
-----------+-----
100 | 200
(1 row)
postgres 9.1.3
--------------------------
CREATE VIEW v_members AS
SELECT
1 as member_id,
100 as tenant_id,
3732 as conference_id,
200 as uid
FROM
(select 1 as uid_user, 2 as uid_contact) as m;
SELECT
u.tenant_id,
u.uid
FROM
(select 100 as tenant_id, 200 as uid) u
LEFT JOIN v_members m ON (m.uid = u.uid AND m.conference_id = 3732)
WHERE
(
SELECT 1
FROM (select 3732 as conference_id) c
WHERE (c.conference_id = 3732) AND (m.uid IS NOT NULL)
) = 1;
ERROR: Upper-level PlaceHolderVar found where not expected
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: markm-lists@intellasoft.net
Subject: Re: Subquery with toplevel reference used to work in pg 8.4
In-Reply-To: <4F6D47E8.2040209@intellasoft.net>
References: <4F6D47E8.2040209@intellasoft.net>
* 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