Skip site navigation (1) Skip section navigation (2)

coalesce in execute crashes backend

From: pgsql-bugs(at)postgresql(dot)org
To: pgsql-bugs(at)postgresql(dot)org
Subject: coalesce in execute crashes backend
Date: 2001-06-12 18:45:50
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-bugs
Vinod Kurup (vkurup(at)massmed(dot)org) reports a bug with a severity of 3
The lower the number the more severe it is.

Short Description
coalesce in execute crashes backend

Long Description
When I use a coalesce statement to calculate an expression that is part of a dynamic query, it crashes the backend. Interestingly, it works if I use constants as arguments to coalesce. 

Sample Code
select version();

create function vk_test()
returns integer as '
	v_id		integer;
	v_id := 2;
	raise notice ''try a constant.'';
	execute ''select '' || coalesce(2,0) || '';'';

	raise notice ''that worked'';

	raise notice ''now, try a var with the same value.'';
	execute ''select '' || coalesce(v_id,0) || '';'';

	raise notice ''we never get here'';
	return 0;
end;' language 'plpgsql';

select vk_test();

 PostgreSQL 7.1 on i586-pc-linux-gnu, compiled by GCC 2.95.3
(1 row)

psql:junk.sql:24: NOTICE:  try a constant.
psql:junk.sql:24: NOTICE:  that worked
psql:junk.sql:24: NOTICE:  now, try a var with the same value.
psql:junk.sql:24: pqReadData() -- backend closed the channel unexpectedly.
	This probably means the backend terminated abnormally
	before or while processing the request.
psql:junk.sql:24: connection to server was lost

NOTICE:  try a constant.
NOTICE:  that worked
NOTICE:  now, try a var with the same value.
Server process (pid 7516) exited with status 11 at Tue Jun 12 14:32:13 2001
Terminating any active server processes...
NOTICE:  Message from PostgreSQL backend:
	The Postmaster has informed me that some other backend	died abnormally and possibly corrupted shared memory.
	I have rolled back the current transaction and am	going to terminate your database system connection and exit.
	Please reconnect to the database system and repeat your query.

No file was uploaded with this report


pgsql-bugs by date

Next:From: Arcady GenkinDate: 2001-06-12 20:13:17
Subject: Re: REPOST: redefining location of the socket file /tmp/.s.PGSQL.5432
Previous:From: Cary O'BrienDate: 2001-06-12 14:28:11
Subject: Index files grow forever?

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group