Hi !
When I let the PostGre script running, I got strange error messages on the production server.
Finding the real error wasn't all that easy, but in the end, it all boils down to
Quote:
ERROR: language "plpgsql" does not exist
When you run
Code:
SELECT lanname, lanowner, lanispl, lanpltrusted, lanplcallfoid, lanvalidator,
lanacl
FROM pg_language;
on older servers (where the database has not been created using template0/1), such as stable production servers, you will see that no such language is included.
So, add the below part as the very top of the script.
(Taken from
http://timmurphy.org/201...nt-exist-in-postgresql/ )
Code:
CREATE OR REPLACE FUNCTION create_language_plpgsql()
RETURNS BOOLEAN AS $$
CREATE LANGUAGE plpgsql;
SELECT TRUE;
$$ LANGUAGE SQL;
SELECT CASE WHEN NOT
(
SELECT TRUE AS exists
FROM pg_language
WHERE lanname = 'plpgsql'
UNION
SELECT FALSE AS exists
ORDER BY exists DESC
LIMIT 1
)
THEN
create_language_plpgsql()
ELSE
FALSE
END AS plpgsql_created;
DROP FUNCTION create_language_plpgsql();