From: luis.roberto@siscobra.com.br
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-bugs <pgsql-bugs@lists.postgresql.org>
Cc: alan.formagi <alan.formagi@siscobra.com.br>
Subject: Re: segfault with incremental sort
Date: Tue, 3 Nov 2020 09:37:33 -0300 (BRT)
Message-ID: <1779929796.39206557.1604407053112.JavaMail.zimbra@siscobra.com.br> (raw)
In-Reply-To: <136656.1604092024@sss.pgh.pa.us>
References: <622580997.37108180.1604080457319.JavaMail.zimbra@siscobra.com.br>
<102089.1604082122@sss.pgh.pa.us>
<541187747.37582276.1604086719237.JavaMail.zimbra@siscobra.com.br>
<107029.1604087483@sss.pgh.pa.us>
<1673261949.37800156.1604090102715.JavaMail.zimbra@siscobra.com.br>
<1807748588.37862034.1604091799640.JavaMail.zimbra@siscobra.com.br>
<136656.1604092024@sss.pgh.pa.us>
Hm ... suggestive, but not really enough to debug it.
Can you build a self-contained test case?
regards, tom lane
Hi Tom!
It took me some time to make it the same... I managed to simplify the error. It appears to be something related to a subplan with a distinct clause and another subplan...
drop table main,secondary;
create table main (
id bigint generated by default as identity primary key,
id2 int not null,
type smallint default 0,
name text not null
);
insert into main (id2,name,type)
select (id%100)+1,md5(id::text),case when (id%100) > 0 then 0 else 1 end
from generate_series(1,3401305) a(id);
create index on main (id2);
create table secondary (
id bigint,
id2 smallint,
name text,
primary key (id,id2)
);
insert into secondary (id,id2,name)
select m.id,a.seq,md5(m.id::text)
from main m,
generate_series(1,16) a(seq);
analyze main,secondary;
explain analyze
select m.id2,
m.id,
s.description
FROM main m
LEFT JOIN ( SELECT DISTINCT
m.id,
CASE
WHEN m.id2 = 15 AND (SELECT name FROM secondary x WHERE x.id = s2.id AND x.id2 = 10) = md5(123::text) THEN 'description'
WHEN m.id2 = 15 THEN (SELECT name FROM secondary x WHERE x.id = s2.id AND x.id2 = 5)
END AS description
FROM main m
JOIN secondary s2 ON m.id = s2.id
WHERE m.id2 = 15
and type = 0) s ON s.id = m.id
WHERE m.id2 IN (15)
and type = 0
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 using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: luis.roberto@siscobra.com.br, tgl@sss.pgh.pa.us, pgsql-bugs@lists.postgresql.org, alan.formagi@siscobra.com.br
Subject: Re: segfault with incremental sort
In-Reply-To: <1779929796.39206557.1604407053112.JavaMail.zimbra@siscobra.com.br>
* 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