Friday, 13 September 2013

how to make erroneous PostgreSQL functions (plpgsql) fail on creation rather than on calling them

how to make erroneous PostgreSQL functions (plpgsql) fail on creation
rather than on calling them

At the psql prompt (or in a script file), I am doing a (this is just for
illustration purposes):
CREATE OR REPLACE FUNCTION FOO() RETURNS VOID AS 'BEGIN SELECT 1 FROM
doesntexist; END;' LANGUAGE plpgsql;
... where the table doesntexist doesn't exist. The function is created
without a complain issued and only fails upon calling it:
test=> select foo() ;
ERROR: relation "doesntexist" does not exist
...
How can I change that behavior so that I can be confident that once my
script is executed there are no errors of that type lurking?

No comments:

Post a Comment