Skip to content

Commit

Permalink
test.sql now doesn't depend on whether you've
Browse files Browse the repository at this point in the history
* Added a 'plparrot' row to pg_catalog.pg_pltemplate, or
* Created the PL/Parrot language.
  • Loading branch information
David Fetter committed Jan 27, 2010
1 parent cb46c11 commit 7147e42
Showing 1 changed file with 33 additions and 2 deletions.
35 changes: 33 additions & 2 deletions t/test.sql
Expand Up @@ -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,
Expand All @@ -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;
Expand Down

0 comments on commit 7147e42

Please sign in to comment.