Lists: | pgsql-hackers |
---|
From: | Teodor Sigaev <teodor(at)sigaev(dot)ru> |
---|---|
To: | Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | coredump of 9.3.2 |
Date: | 2013-12-10 17:39:54 |
Message-ID: | 52A751EA.6000303@sigaev.ru |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hi!
Rather simple script (original query was a 500 lines of SQL with >100 Mb of
gzipped dump. Query is looked strange, but actually it was auto-generated):
CREATE TABLE t (a int, b int);
CREATE TABLE tt (c int);
INSERT INTO t VALUES (1,1), (2,2);
INSERT INTO tt VALUES (2);
SELECT
*
FROM
t
WHERE (
CASE
WHEN a%2 IN (SELECT c FROM tt) THEN a
END IN (SELECT c FROM tt)
);
I suppose, the problem is connected to hashed subplan, but I'm not very familiar
with executor. And this affects all supported versions of pgsql.
--
Teodor Sigaev E-mail: teodor(at)sigaev(dot)ru
WWW: http://www.sigaev.ru/
From: | Josh Berkus <josh(at)agliodbs(dot)com> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: coredump of 9.3.2 |
Date: | 2013-12-10 18:46:16 |
Message-ID: | 52A76178.8000906@agliodbs.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On 12/10/2013 09:39 AM, Teodor Sigaev wrote:
>
> SELECT
> *
> FROM
> t
> WHERE (
> CASE
> WHEN a%2 IN (SELECT c FROM tt) THEN a
> END IN (SELECT c FROM tt)
> );
Wow, it wouldn't have occured to me that that was even supported syntax.
I'm not suprised that it doesn't work ...
--
Josh Berkus
PostgreSQL Experts Inc.
http://pgexperts.com
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Teodor Sigaev <teodor(at)sigaev(dot)ru> |
Cc: | Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: coredump of 9.3.2 |
Date: | 2013-12-10 19:13:13 |
Message-ID: | 14219.1386702793@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Teodor Sigaev <teodor(at)sigaev(dot)ru> writes:
> SELECT
> *
> FROM
> t
> WHERE (
> CASE
> WHEN a%2 IN (SELECT c FROM tt) THEN a
> END IN (SELECT c FROM tt)
> );
> I suppose, the problem is connected to hashed subplan, but I'm not very familiar
> with executor. And this affects all supported versions of pgsql.
It seems to be a planner bug: it's doing the wrong thing with the
PARAM_SUBLINK Params for the nested IN SubLinks. (They don't look
to be nested textually, but they are, and convert_testexpr is
mistakenly replacing the inner one's Params when it should only
be replacing the outer one's Params.)
I think this has probably been broken since about 2005 :-(.
The comment on convert_testexpr claims it doesn't need to worry
about nested cases; which is true when it's called during
SS_process_sublinks, but not so much when it's called from
convert_ANY_sublink_to_join. Some digging in the git history
suggests that the latter call existed at the time, meaning the
comment was wrong even when written.
regards, tom lane