From 7147e42132fefece4e7616c2c04e8742ed1b05e0 Mon Sep 17 00:00:00 2001 From: David Fetter Date: Wed, 27 Jan 2010 10:58:23 -0800 Subject: [PATCH] test.sql now doesn't depend on whether you've * Added a 'plparrot' row to pg_catalog.pg_pltemplate, or * Created the PL/Parrot language. --- t/test.sql | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/t/test.sql b/t/test.sql index db33086..d14165e 100644 --- a/t/test.sql +++ b/t/test.sql @@ -15,8 +15,11 @@ BEGIN; -- Plan the tests. SELECT plan(5); ---DROP FUNCTION plparrot_call_handler() CASCADE; -- TODO: Make this configurable +CREATE OR REPLACE FUNCTION setup_plparrot() +RETURNS BOOLEAN +LANGUAGE SQL +AS $$ INSERT INTO pg_catalog.pg_pltemplate( tmplname, tmpltrusted, @@ -31,10 +34,38 @@ VALUES ( 'plparrot_call_handler', '$libdir/plparrot' ); -CREATE LANGUAGE plparrot; +SELECT true; +$$; +CREATE OR REPLACE FUNCTION create_plparrot() +RETURNS BOOLEAN +LANGUAGE SQL +AS $$ +CREATE LANGUAGE plparrot; +SELECT true; +$$; -- These functions should be written in PIR +SELECT + CASE WHEN EXISTS( + SELECT 1 FROM pg_catalog.pg_pltemplate WHERE tmplname='plparrot' + ) + THEN + true + ELSE + setup_plparrot() + END; + +SELECT + CASE WHEN EXISTS( + SELECT 1 FROM pg_catalog.pg_language WHERE lanname='plparrot' + ) + THEN + true + ELSE + create_plparrot() + END; + CREATE FUNCTION test_void() RETURNS void AS $$ FAIL $$ LANGUAGE plparrot; CREATE FUNCTION test_int() RETURNS int AS $$ select 1 as result $$ LANGUAGE plparrot;