BUG #12146: Crash when using UNION ALL - Mailing list pgsql-bugs

From me@jandrabek.cz
Subject BUG #12146: Crash when using UNION ALL
Date
Msg-id 20141204160338.2565.93893@wrigleys.postgresql.org
Whole thread Raw
Responses Re: BUG #12146: Crash when using UNION ALL
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      12146
Logged by:          Jan Drabek
Email address:      me@jandrabek.cz
PostgreSQL version: 9.3.5
Operating system:   OS X 10.10 (via Macports)
Description:

Since 9.3.5 my PostgreSQL crashes when certain pattern in queries appears.
(Version 9.3.4 is not affected.)

After cutting all dependencies and columns from table foo it is only having
one column with BIGINT type.

The query is:
SELECT *
FROM (
       SELECT id
       FROM (
              SELECT id FROM foo
              UNION ALL
              SELECT id FROM foo

            ) t
       UNION ALL

       SELECT id FROM foo
     ) AS eop
  JOIN foo p ON p.id = eop.id

After execution of this query I get this in PostgreSQL log:
LOG:  server process (PID 11935) was terminated by signal 11: Segmentation
fault

However it is reproducible only on my machine (dumping database is of no
good).

Interesting observations:
 - After executing ANALYZE foo; problems disappear (corrupted statistics?)
 - Using UNION instead of UNION ALL makes it work.
 - Duplicating database on my machine (via pgadmin dump and load) doesn't
change this behaviour (i.e. it still crashes even on the newly loaded
database).

However I wasn't able to reproduce problem on different machine.
Any ideas what to do next in order to find the cause? (I tried to use
DEBUG5, but there were nothing interesting in the log).

Thanks
jan Drábek

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #12137: ORDER BY with expresion changes the output if added
Next
From: Tom Lane
Date:
Subject: Re: BUG #12146: Crash when using UNION ALL