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: 200106121845.f5CIjoV43191@hub.org (view raw or flat)
Thread:
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 '
declare
	v_id		integer;
begin
	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();

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

CREATE
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

server.log:
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


Responses

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-2014 The PostgreSQL Global Development Group