CREATE OR REPLACE FUNCTION make_plpgsql()Oh, and it's idempotent too. No need to worry whether it's been done before
RETURNS VOID
LANGUAGE SQL
AS $$
CREATE LANGUAGE plpgsql;
$$;
SELECT
CASE
WHEN EXISTS(
SELECT 1
FROM pg_catalog.pg_language
WHERE lanname='plpgsql'
)
THEN NULL
ELSE make_plpgsql() END;
To clean up, you can do:
DROP FUNCTION make_plpgsql();
I'm glad you found it useful, and have added the cleanup you suggested
http://andreas.scherbaum.la/blog/archives/346-create-language-if-not-exist.html