Vinod Kurup ([EMAIL PROTECTED]) 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


---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Reply via email to