Thread: Error in calling a function with protocol 7.4

Error in calling a function with protocol 7.4

From
Haribabu Kommi
Date:
when function is called using the following way, it generates an error.

? = CALL procname ()

The error message with 09.03.0400 with protocol 7.4 is
-----------------------------------------------------
errstate -> 08P01
errcode -> 7
errmsg -> ERROR: invalid message format; Error while executing the query
-----------------------------------------------------

But it passes with protocol 6.4 in version 09.03.0400. The same test passes
with either protocol versions in version 09.03.0100.

Function:

CREATE OR REPLACE FUNCTION PROC1() RETURNS INTEGER
AS $$
  BEGIN
    RETURN 1234;
  END;
$$ LANGUAGE 'plpgsql';

Here I attached the sample test file to reproduce the problem. I want to know
whether is it a problem or normal behavior in this version?

Regards,
Hari Babu
Fujitsu Australia

Attachment

Re: Error in calling a function with protocol 7.4

From
Heikki Linnakangas
Date:
On 09/12/15 02:40, Haribabu Kommi wrote:
> when function is called using the following way, it generates an error.
>
> ? = CALL procname ()
>
> The error message with 09.03.0400 with protocol 7.4 is
> -----------------------------------------------------
> errstate -> 08P01
> errcode -> 7
> errmsg -> ERROR: invalid message format; Error while executing the query
> -----------------------------------------------------
>
> But it passes with protocol 6.4 in version 09.03.0400. The same test passes
> with either protocol versions in version 09.03.0100.
>
> Function:
>
> CREATE OR REPLACE FUNCTION PROC1() RETURNS INTEGER
> AS $$
>    BEGIN
>      RETURN 1234;
>    END;
> $$ LANGUAGE 'plpgsql';
>
> Here I attached the sample test file to reproduce the problem. I want to know
> whether is it a problem or normal behavior in this version?

It's a bug. I bisected it into commit e6d7ded, which was a bit
surprising because that commit didn't change the way the parameters are
handled, AFAICS. In any case, in 'master', the bug was quite clearly in
libpq_bind_and_exec(): with a not-already-prepared statement, it sent
the original number of parameters to the server, rather than the number
of parameters minus the OUT params.

Pushed a fix for this to master. Thanks for the test case!

- Heikki



Re: Error in calling a function with protocol 7.4

From
Haribabu Kommi
Date:
On Tue, Dec 22, 2015 at 1:41 AM, Heikki Linnakangas <hlinnaka@iki.fi> wrote:
> On 09/12/15 02:40, Haribabu Kommi wrote:
>>
>> when function is called using the following way, it generates an error.
>>
>> ? = CALL procname ()
>>
>> The error message with 09.03.0400 with protocol 7.4 is
>> -----------------------------------------------------
>> errstate -> 08P01
>> errcode -> 7
>> errmsg -> ERROR: invalid message format; Error while executing the query
>> -----------------------------------------------------
>>
>> But it passes with protocol 6.4 in version 09.03.0400. The same test
>> passes
>> with either protocol versions in version 09.03.0100.
>>
>> Function:
>>
>> CREATE OR REPLACE FUNCTION PROC1() RETURNS INTEGER
>> AS $$
>>    BEGIN
>>      RETURN 1234;
>>    END;
>> $$ LANGUAGE 'plpgsql';
>>
>> Here I attached the sample test file to reproduce the problem. I want to
>> know
>> whether is it a problem or normal behavior in this version?
>
>
> It's a bug. I bisected it into commit e6d7ded, which was a bit surprising
> because that commit didn't change the way the parameters are handled,
> AFAICS. In any case, in 'master', the bug was quite clearly in
> libpq_bind_and_exec(): with a not-already-prepared statement, it sent the
> original number of parameters to the server, rather than the number of
> parameters minus the OUT params.
>
> Pushed a fix for this to master. Thanks for the test case!

Thanks for the fix.

Regards,
Hari Babu
Fujitsu Australia