BUG #14414: SPI_ERROR_CONNECT on stable plpgsql function used for domain check

Started by Marcos Castedoover 9 years ago2 messagesbugs
Jump to latest
#1Marcos Castedo
marcos.castedo@anachronics.com

The following bug has been logged on the website:

Bug reference: 14414
Logged by: Marcos Castedo
Email address: marcos.castedo@anachronics.com
PostgreSQL version: 9.6.1
Operating system: Debian stretch
Description:

I'm trying to do a domain using stable plpgsql function for value check.
This isn't working on 9.6.x on plpgsql using assignment from base data type,
but it works fine on 9.2.x.

Test case:

BEGIN;

--Only fails on stable function, immutable works fine
CREATE OR REPLACE FUNCTION x_domain_test_check()
RETURNS boolean AS $$
BEGIN
RETURN true;
END;
$$ LANGUAGE plpgsql STABLE;

CREATE DOMAIN x_domain_test AS integer CHECK(x_domain_test_check());

DO $$
DECLARE
v_test x_domain_test;
BEGIN
v_test := 1;
END;
$$;

ROLLBACK;

Output on PostgreSQL 9.2.17 (expected)
DO
ROLLBACK

Output on PostgreSQL 9.6.1 (error)

ERROR: SPI_connect failed: SPI_ERROR_CONNECT
CONTEXT: PL/pgSQL function inline_code_block line 5 at assignment
ROLLBACK

--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Marcos Castedo (#1)
Re: BUG #14414: SPI_ERROR_CONNECT on stable plpgsql function used for domain check

marcos.castedo@anachronics.com writes:

I'm trying to do a domain using stable plpgsql function for value check.
This isn't working on 9.6.x on plpgsql using assignment from base data type,
but it works fine on 9.2.x.

Seems to be broken in 9.5 too :-(. I pushed a fix, thanks for the report!

--Only fails on stable function, immutable works fine

FWIW, both cases fail for me. There may be some other effect in whatever
your original case was, but in this specific example an immutable function
fails too.

regards, tom lane

--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs