SPI_ERROR_CONNECT in plperl function

Lists: pgsql-general
From: Christian Schröder <cs(at)deriva(dot)de>
To: PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: SPI_ERROR_CONNECT in plperl function
Date: 2009-01-04 20:18:27
Message-ID: 49611993.9050605@deriva.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Hi list,
I have found the following problem: I have declared a domain datatype
with a check constraint. The check constraint uses a plpgsql function:

CREATE FUNCTION domain_ok(value integer) RETURNS boolean AS $$
BEGIN
RETURN value > 0;
END;
$$ LANGUAGE plpgsql;

CREATE DOMAIN testdomain integer CHECK (domain_ok(value));

I then wrote a plperl function that returns a set of this domain type:

CREATE FUNCTION testfunc() RETURNS SETOF testdomain AS $$
return_next(42);
return undef;
$$ LANGUAGE plperl;

When I try to call the function I get the following error message:

test=# select * from testfunc();
ERROR: error from Perl function: SPI_connect failed: SPI_ERROR_CONNECT
at line 2.

The problem goes away if I declare the testfunc to return an integer.
Even a domain with a "normal" check constraint (i.e. without one that
calls another function) does not cause this error.

Is this a known bug? Or do I miss something?

Regards,
Christian

--
Deriva GmbH Tel.: +49 551 489500-42
Financial IT and Consulting Fax: +49 551 489500-91
Hans-Böckler-Straße 2 http://www.deriva.de
D-37079 Göttingen

Deriva CA Certificate: http://www.deriva.de/deriva-ca.cer


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Christian Schröder <cs(at)deriva(dot)de>
Cc: PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: Re: SPI_ERROR_CONNECT in plperl function
Date: 2009-01-04 23:28:14
Message-ID: 1168.1231111694@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

=?ISO-8859-1?Q?Christian_Schr=F6der?= <cs(at)deriva(dot)de> writes:
> When I try to call the function I get the following error message:

> test=# select * from testfunc();
> ERROR: error from Perl function: SPI_connect failed: SPI_ERROR_CONNECT
> at line 2.

Hmph ... looks like plperl is shy a few SPI_push/SPI_pop calls.
We fixed this issue in plpgsql awhile back, but nobody thought to
look at the other PLs :-(

regards, tom lane


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Christian Schröder <cs(at)deriva(dot)de>, PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: Re: SPI_ERROR_CONNECT in plperl function
Date: 2009-01-07 20:44:47
Message-ID: 4036.1231361087@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

I wrote:
> =?ISO-8859-1?Q?Christian_Schr=F6der?= <cs(at)deriva(dot)de> writes:
>> When I try to call the function I get the following error message:

>> test=# select * from testfunc();
>> ERROR: error from Perl function: SPI_connect failed: SPI_ERROR_CONNECT
>> at line 2.

> Hmph ... looks like plperl is shy a few SPI_push/SPI_pop calls.

I've applied a patch for this --- it'll be in the next set of update
releases.

regards, tom lane


From: Christian Schröder <cs(at)deriva(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: Re: SPI_ERROR_CONNECT in plperl function
Date: 2009-01-08 11:24:38
Message-ID: 4965E276.6080109@deriva.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Tom Lane wrote:
> Hmph ... looks like plperl is shy a few SPI_push/SPI_pop calls.
>
>
> I've applied a patch for this --- it'll be in the next set of update
> releases.
>
Great. Thanks a lot! The whole PostgreSQL stuff is really amazing! :-)

Regards,
Christian

--
Deriva GmbH Tel.: +49 551 489500-42
Financial IT and Consulting Fax: +49 551 489500-91
Hans-Böckler-Straße 2 http://www.deriva.de
D-37079 Göttingen

Deriva CA Certificate: http://www.deriva.de/deriva-ca.cer