Re: BUG #3494: may be Query Error: subplan does not executed

From: Heikki Linnakangas <heikki(at)enterprisedb(dot)com>
To: Sergey Burladyan <eshkinkot(at)gmail(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #3494: may be Query Error: subplan does not executed
Date: 2007-07-27 13:58:20
Message-ID: 46A9F9FC.6090603@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Sergey Burladyan wrote:
> i have query with join of two table and 'where' filter it result by subplan
> which have references to join result, but this subplan not executed and
> result is incorrect. This subplan also not exist in explain analyze output.

I can reproduce this on 8.1 and 8.2 branch heads, but not on 8.3 HEAD.
I've simplified test case down to this:

CREATE TABLE test1 (id int);
CREATE TABLE test2 (id int);

INSERT INTO test1 VALUES (1);
INSERT INTO test2 VALUES (1);

INSERT INTO test2 VALUES (1);

SELECT * FROM test1, test2
WHERE test1.id = test2.id
AND test1.id = (SELECT 123 WHERE test1.id = 100 AND test2.id = 100);

The query incorrectly returns one row, instead of none, with this plan:

QUERY PLAN
-----------------------------------------------------------
Nested Loop (cost=0.00..2.03 rows=1 width=8)
Join Filter: (test1.id = test2.id)
-> Seq Scan on test1 (cost=0.00..1.01 rows=1 width=4)
-> Seq Scan on test2 (cost=0.00..1.01 rows=1 width=4)
(4 rows)

I don't have the time to dig deeper right now, but I hope this helps
someone else to get started...

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Douglas Toltzman 2007-07-27 14:10:50 Re: BUG #3493: Cannot find data with = operator
Previous Message Tom Lane 2007-07-27 13:07:07 Re: BUG #3493: Cannot find data with = operator