Re: Testing plperl<->plperlu interaction - Mailing list pgsql-hackers
From | Andrew Dunstan |
---|---|
Subject | Re: Testing plperl<->plperlu interaction |
Date | |
Msg-id | 4B47C6A3.20702@dunslane.net Whole thread Raw |
In response to | Re: Testing plperl<->plperlu interaction (Tim Bunce <Tim.Bunce@pobox.com>) |
Responses |
Re: Testing plperl<->plperlu interaction
|
List | pgsql-hackers |
Tim Bunce wrote: > > Or perhaps put the tests that require multiplicity into a plperl_multi.sql > file and add logic to the GNUmakefile to add that file to REGRESS > if "perl -V:usemultiplicity" returns "usemultiplicity='define';" > > > OK, here is a patch that provides for running regression tests for plperlu alone and plperl/plperlu interaction, skipping the latter if it's not supported on the platform, using the test Tim has suggested. cheers andrew Index: GNUmakefile =================================================================== RCS file: /cvsroot/pgsql/src/pl/plperl/GNUmakefile,v retrieving revision 1.37 diff -c -r1.37 GNUmakefile *** GNUmakefile 5 Jun 2009 18:29:56 -0000 1.37 --- GNUmakefile 8 Jan 2010 23:52:30 -0000 *************** *** 38,45 **** SHLIB_LINK = $(perl_embed_ldflags) ! REGRESS_OPTS = --dbname=$(PL_TESTDB) --load-language=plperl ! REGRESS = plperl plperl_trigger plperl_shared plperl_elog # where to find psql for running the tests PSQLDIR = $(bindir) --- 38,48 ---- SHLIB_LINK = $(perl_embed_ldflags) ! REGRESS_OPTS = --dbname=$(PL_TESTDB) --load-language=plperl --load-language=plperlu ! REGRESS = plperl plperl_trigger plperl_shared plperl_elog plperlu ! ifeq ($(shell $(PERL) -V:usemultiplicity), usemultiplicity='define';) ! REGRESS += plperl_plperlu ! endif # where to find psql for running the tests PSQLDIR = $(bindir) Index: expected/plperl_plperlu.out =================================================================== RCS file: expected/plperl_plperlu.out diff -N expected/plperl_plperlu.out *** /dev/null 1 Jan 1970 00:00:00 -0000 --- expected/plperl_plperlu.out 8 Jan 2010 23:52:31 -0000 *************** *** 0 **** --- 1,18 ---- + -- test plperl/plperlu interaction + CREATE OR REPLACE FUNCTION bar() RETURNS integer AS $$ + #die 'BANG!'; # causes server process to exit(2) + # alternative - causes server process to exit(255) + spi_exec_query("invalid sql statement"); + $$ language plperl; -- plperl or plperlu + + CREATE OR REPLACE FUNCTION foo() RETURNS integer AS $$ + spi_exec_query("SELECT * FROM bar()"); + return 1; + $$ LANGUAGE plperlu; -- must be opposite to language of bar + + SELECT * FROM bar(); -- throws exception normally + ERROR: syntax error at or near "invalid" at line 4. + CONTEXT: PL/Perl function "bar" + SELECT * FROM foo(); -- used to cause backend crash + ERROR: syntax error at or near "invalid" at line 4. at line 2. + CONTEXT: PL/Perl function "foo" Index: expected/plperlu.out =================================================================== RCS file: expected/plperlu.out diff -N expected/plperlu.out *** /dev/null 1 Jan 1970 00:00:00 -0000 --- expected/plperlu.out 8 Jan 2010 23:52:31 -0000 *************** *** 0 **** --- 1,9 ---- + -- Use ONLY plperlu tests here. For plperl/plerlu combined tests + -- see plperl_plperlu.sql + -- + -- Test compilation of unicode regex - regardless of locale. + -- This code fails in plain plperl in a non-UTF8 database. + -- + CREATE OR REPLACE FUNCTION perl_unicode_regex(text) RETURNS INTEGER AS $$ + return ($_[0] =~ /\x{263A}|happy/i) ? 1 : 0; # unicode smiley + $$ LANGUAGE plperlu; Index: sql/plperl_plperlu.sql =================================================================== RCS file: sql/plperl_plperlu.sql diff -N sql/plperl_plperlu.sql *** /dev/null 1 Jan 1970 00:00:00 -0000 --- sql/plperl_plperlu.sql 8 Jan 2010 23:52:31 -0000 *************** *** 0 **** --- 1,17 ---- + -- test plperl/plperlu interaction + + CREATE OR REPLACE FUNCTION bar() RETURNS integer AS $$ + #die 'BANG!'; # causes server process to exit(2) + # alternative - causes server process to exit(255) + spi_exec_query("invalid sql statement"); + $$ language plperl; -- plperl or plperlu + + CREATE OR REPLACE FUNCTION foo() RETURNS integer AS $$ + spi_exec_query("SELECT * FROM bar()"); + return 1; + $$ LANGUAGE plperlu; -- must be opposite to language of bar + + SELECT * FROM bar(); -- throws exception normally + SELECT * FROM foo(); -- used to cause backend crash + + Index: sql/plperlu.sql =================================================================== RCS file: sql/plperlu.sql diff -N sql/plperlu.sql *** /dev/null 1 Jan 1970 00:00:00 -0000 --- sql/plperlu.sql 8 Jan 2010 23:52:31 -0000 *************** *** 0 **** --- 1,10 ---- + -- Use ONLY plperlu tests here. For plperl/plerlu combined tests + -- see plperl_plperlu.sql + + -- + -- Test compilation of unicode regex - regardless of locale. + -- This code fails in plain plperl in a non-UTF8 database. + -- + CREATE OR REPLACE FUNCTION perl_unicode_regex(text) RETURNS INTEGER AS $$ + return ($_[0] =~ /\x{263A}|happy/i) ? 1 : 0; # unicode smiley + $$ LANGUAGE plperlu;
pgsql-hackers by date: