pqReadData() -- backend closed the channel unexpectedly. - Mailing list pgsql-bugs

From pgsql-bugs@postgresql.org
Subject pqReadData() -- backend closed the channel unexpectedly.
Date
Msg-id 200105171745.f4HHjWg08478@hub.org
Whole thread Raw
Responses Re: pqReadData() -- backend closed the channel unexpectedly.  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
Kristis Makris (kristis.makris@datasoft.com) reports a bug with a severity of 2
The lower the number the more severe it is.

Short Description
pqReadData() -- backend closed the channel unexpectedly.

Long Description
Here are the facts:

I have a plpgsql function that should return a value out of a query. The function works when the select xxx into yyyy
statementin it enters data in a yyyy variable declared as "RECORD". IF delcared as BOOL, TEXT or INT4, I get the
pqReadDataerror. 

Here's a snippet of code that exhibits that.

Sample Code
Here's the function declaration when does not work while it should:


CREATE FUNCTION GetCheckNumber(INT4) RETURNS TEXT AS '
DECLARE
    lDepositID ALIAS FOR $1;
    lTemp       TEXT;
BEGIN
    SELECT mc.checknumber
    INTO   lTemp
    FROM   Deposit d,
           MoneyCheck mc
    WHERE  mc.type_id = d.id;

    IF NOT FOUND THEN
       RETURN ''N/A'';
    ELSE
       RETURN lTemp;
    END IF;

END;
'    LANGUAGE 'plpgsql';


And here's a working version of the function using the RECORD type:

CREATE FUNCTION GetCheckNumber(INT4) RETURNS TEXT AS '
DECLARE
    lDepositID ALIAS FOR $1;
    lTemp       RECORD;
BEGIN
    SELECT mc.checknumber
    INTO   lTemp
    FROM   Deposit d,
           MoneyCheck mc
    WHERE  mc.type_id = d.id;

    IF NOT FOUND THEN
       RETURN ''N/A'';
    ELSE
       RETURN lTemp.checknumber;
    END IF;

END;
'    LANGUAGE 'plpgsql';


No file was uploaded with this report

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: Unusual slowdown using subselects
Next
From: Tom Lane
Date:
Subject: Re: pqReadData() -- backend closed the channel unexpectedly.