I have a setup program that requires plpgsql to install stored procedures in a PostgreSQL 8.4 database. I need to make sure the language is installed or the app will fail. I don't want to drop the language and re-add it, as that could screw some other things up.
Is there a way to install the language "gently"?
CREATE LANGUAGE IF NOT EXISTS
does not appear to be valid.
Best Answer
In PostgreSQL 9.0 and later, PL/pgSQL is pre-installed by default.
Version 9.0 also introduced
CREATE OR REPLACE LANGUAGE
:To avoid raising an exception on older versions you can check the catalog table
pg_language
. I quote the manual once more:Or use the client application
createlang
, which has an option to check for existing languages: