Unix Technical Forum

plperl tests for currently untested features

This is a discussion on plperl tests for currently untested features within the Pgsql Patches forums, part of the PostgreSQL category; --> continuing my quest for better testing ... ;-) The current plperl regression tests do not test the trigger or ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql Patches

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-17-2008, 11:21 PM
Andrew Dunstan
 
Posts: n/a
Default plperl tests for currently untested features


continuing my quest for better testing ... ;-)

The current plperl regression tests do not test the trigger or shared
data features. The attached new files remedy that:

sql/plperl_trigger.sql
sql/plperl_shared.sql
expected/plperl_trigger.out
expected/plperl_shared.out

The corresponding patch for GNUmakefile is below

Is it worth supplying a more descriptive name to the current plperl.sql
test script?

cheers

andrew

Index: GNUmakefile
================================================== =================
RCS file: /projects/cvsroot/pgsql/src/pl/plperl/GNUmakefile,v
retrieving revision 1.20
diff -c -r1.20 GNUmakefile
*** GNUmakefile 17 May 2005 18:26:22 -0000 1.20
--- GNUmakefile 23 May 2005 22:08:07 -0000
***************
*** 37,43 ****
SHLIB_LINK = $(perl_embed_ldflags) $(BE_DLLLIBS)

REGRESS_OPTS = --dbname=$(PL_TESTDB) --load-language=plperl
! REGRESS = plperl

include $(top_srcdir)/src/Makefile.shlib

--- 37,43 ----
SHLIB_LINK = $(perl_embed_ldflags) $(BE_DLLLIBS)

REGRESS_OPTS = --dbname=$(PL_TESTDB) --load-language=plperl
! REGRESS = plperl plperl_trigger plperl_shared

include $(top_srcdir)/src/Makefile.shlib



-- test the shared hash
create function setme(key text, val text) returns void language plperl as $$

my $key = shift;
my $val = shift;
$_SHARED{$key}= $val;

$$;
create function getme(key text) returns text language plperl as $$

my $key = shift;
return $_SHARED{$key};

$$;
select setme('ourkey','ourval');
setme
-------

(1 row)

select getme('ourkey');
getme
--------
ourval
(1 row)


-- test plperl triggers
CREATE TABLE trigger_test (
i int,
v varchar
);
CREATE OR REPLACE FUNCTION valid_id() RETURNS trigger AS $$

if (($_TD->{new}{i}>=100) || ($_TD->{new}{i}<=0))
{
return "SKIP"; # Skip INSERT/UPDATE command
}
elsif ($_TD->{new}{v} ne "immortal")
{
$_TD->{new}{v} .= "(modified by trigger)";
return "MODIFY"; # Modify tuple and proceed INSERT/UPDATE command
}
else
{
return; # Proceed INSERT/UPDATE command
}
$$ LANGUAGE plperl;
CREATE TRIGGER "test_valid_id_trig" BEFORE INSERT OR UPDATE ON trigger_test
FOR EACH ROW EXECUTE PROCEDURE "valid_id"();
INSERT INTO trigger_test (i, v) VALUES (1,'first line');
INSERT INTO trigger_test (i, v) VALUES (2,'second line');
INSERT INTO trigger_test (i, v) VALUES (3,'third line');
INSERT INTO trigger_test (i, v) VALUES (4,'immortal');
INSERT INTO trigger_test (i, v) VALUES (101,'bad id');
SELECT * FROM trigger_test;
i | v
---+----------------------------------
1 | first line(modified by trigger)
2 | second line(modified by trigger)
3 | third line(modified by trigger)
4 | immortal
(4 rows)

UPDATE trigger_test SET i = 5 where i=3;
UPDATE trigger_test SET i = 100 where i=1;
SELECT * FROM trigger_test;
i | v
---+------------------------------------------------------
1 | first line(modified by trigger)
2 | second line(modified by trigger)
4 | immortal
5 | third line(modified by trigger)(modified by trigger)
(4 rows)

CREATE OR REPLACE FUNCTION immortal() RETURNS trigger AS $$
if ($_TD->{old}{v} eq $_TD->{args}[0])
{
return "SKIP"; # Skip DELETE command
}
else
{
return; # Proceed DELETE command
};
$$ LANGUAGE plperl;
CREATE TRIGGER "immortal_trig" BEFORE DELETE ON trigger_test
FOR EACH ROW EXECUTE PROCEDURE immortal('immortal');
DELETE FROM trigger_test;
SELECT * FROM trigger_test;
i | v
---+----------
4 | immortal
(1 row)



---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-17-2008, 11:21 PM
Neil Conway
 
Posts: n/a
Default Re: plperl tests for currently untested features

Andrew Dunstan wrote:
> The current plperl regression tests do not test the trigger or shared
> data features. The attached new files remedy that [...]


Barring any objections I'll apply this later today.

-Neil

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-17-2008, 11:21 PM
Neil Conway
 
Posts: n/a
Default Re: plperl tests for currently untested features

Andrew Dunstan wrote:
> The current plperl regression tests do not test the trigger or shared
> data features. The attached new files remedy that [...]


Applied to HEAD. Thanks for the patch.

BTW, I noticed that the PL/Perl regression tests are broken for out of
tree build (i.e. "vpath")...

-Neil

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-17-2008, 11:21 PM
Andrew Dunstan
 
Posts: n/a
Default Re: plperl tests for currently untested features



Neil Conway wrote:

> Andrew Dunstan wrote:
>
>> The current plperl regression tests do not test the trigger or shared
>> data features. The attached new files remedy that [...]

>
>
> Applied to HEAD. Thanks for the patch.
>
> BTW, I noticed that the PL/Perl regression tests are broken for out of
> tree build (i.e. "vpath")...
>
>


I see that in fact all the PL tests are broken for vpath builds.

Did they work before we moved them to the pg_regress mechanism?

I am not a vpath master, so if someone can suggest a neat fix I'd be
grateful.

cheers

andrew

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-17-2008, 11:21 PM
Tom Lane
 
Posts: n/a
Default Re: plperl tests for currently untested features

Andrew Dunstan <andrew@dunslane.net> writes:
> Neil Conway wrote:
>> BTW, I noticed that the PL/Perl regression tests are broken for out of
>> tree build (i.e. "vpath")...


> I see that in fact all the PL tests are broken for vpath builds.


Fixed (copy and paste from src/test/regress) --- I can't actually
test the plpython script right now, but it should work the same
as the other two.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-17-2008, 11:21 PM
Andrew Dunstan
 
Posts: n/a
Default Re: plperl tests for currently untested features



Tom Lane wrote:

>
>>I see that in fact all the PL tests are broken for vpath builds.
>>
>>

>
>Fixed (copy and paste from src/test/regress) --- I can't actually
>test the plpython script right now, but it should work the same
>as the other two.
>
>
>
>


Thanks. I have added support for vpath builds to the list of features
wanted on the buildfarm.

cheers

andrew

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 11:23 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com