Re: Removing unneeded self joins

From: Alexander Lakhin <exclusion(at)gmail(dot)com>
To: Andrei Lepikhov <a(dot)lepikhov(at)postgrespro(dot)ru>, Alexander Korotkov <aekorotkov(at)gmail(dot)com>
Cc: "Gregory Stark (as CFM)" <stark(dot)cfm(at)gmail(dot)com>, Michał Kłeczek <michal(at)kleczek(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Richard Guo <guofenglinux(at)gmail(dot)com>
Subject: Re: Removing unneeded self joins
Date: 2024-01-08 20:00:01
Message-ID: 4788f781-31bd-9796-d7d6-588a751c8787@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello Andrei and Alexander,

Please look at the following query which produces an incorrect result since
d3d55ce57:
CREATE TABLE t(a int PRIMARY KEY, b int);
INSERT INTO t VALUES  (1, 1), (2, 1);
SELECT * FROM t WHERE EXISTS (SELECT * FROM t t2 WHERE t2.a = t.b AND t2.b > 0);

 a | b
---+---
 1 | 1
(1 row)

I think that the expected result is:
 a | b
---+---
 1 | 1
 2 | 1
(2 rows)

Best regards,
Alexander

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Rafsun Masud 2024-01-08 20:06:22 Re: printing raw parse tree
Previous Message Robert Haas 2024-01-08 19:57:34 Re: the s_lock_stuck on perform_spin_delay