Backend crash on query with UNION subselect

Started by PostgreSQL Bugs Listover 25 years ago2 messagesbugs
Jump to latest
#1PostgreSQL Bugs List
pgsql-bugs@postgresql.org

Vladimir Zamiussky (ltd@ippe.obninsk.ru) reports a bug with a severity of 1
The lower the number the more severe it is.

Short Description
Backend crash on query with UNION subselect

Long Description
There are two nearly identical tables, differ from each other by the length of corresponding fields of type CHARACTER (one has CHARACTER(20) field, other has CHARACTER(30) field).
when i do "select * from table1 union select * from table2" backend crashes with message:
FATAL 1: Memory exhausted in AllocSetAlloc()
pqReadData() -- backend closed channel unexpectadly.
This probably means the backend terminated abnormally before or while processing the request.

When char fileds have the same size, crash does not occur.

This bug takes place on 7.0.2 and 7.0.3 versions

Sample Code
create table pipe_alarms(
dtime timestamp default now(),
pipe_name char(30),
alarm_name char(30) );

create table gauge_alarms(
dtime timestamp default now(),
gauge_name char(20),
alarm_name char(30) );

insert into pipe_alarms(pipe_name,alarm_name) values('Pipe 1','LEAK');
insert into pipe_alarms(pipe_name,alarm_name) values('Pipe 2','No leaks');
insert into gauge_alarms(gauge_name,alarm_name) values('sensor_1','OverLimit');
insert into gauge_alarms(gauge_name,alarm_name) values('sensor_2','OverLimit');
insert into gauge_alarms(gauge_name,alarm_name) values('sensor_3','OverLimit');

select * from gauge_alarms union all select * from pipe_alarms

No file was uploaded with this report

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: PostgreSQL Bugs List (#1)
Re: Backend crash on query with UNION subselect

pgsql-bugs@postgresql.org writes:

There are two nearly identical tables, differ from each other by the
length of corresponding fields of type CHARACTER (one has
CHARACTER(20) field, other has CHARACTER(30) field).
when i do "select * from table1 union select * from table2" backend
crashes with message:
FATAL 1: Memory exhausted in AllocSetAlloc()
When char fileds have the same size, crash does not occur.
This bug takes place on 7.0.2 and 7.0.3 versions

This is fixed for 7.1. Older versions have quite a few problems with
cross-datatype UNIONs :-(

regards, tom lane