Summary: PostgreSQL is amazing, but we face many problems at work because it defers many PL / pgSQL code checks to runtime. Is there a way to make it more like Oracle PL / SQL in this regard?
For instance...
Try this in any Oracle DB:
create function foo return number as begin select a from dual; return a; end;
Oracle immediately (i.e. at compile time!) Responds:
[Error] ORA-00904: invalid identifier
Now try the semantically equivalent thing in PostgreSQL:
CREATE OR REPLACE FUNCTION public.foo () RETURNS integer AS $body$ BEGIN select a; return a; END; $body$ LANGUAGE plpgsql;
You will see this - unfortunately! - execute a fine ... Error not reported.
But when you try to call this function (i.e. at runtime), you will get:
ERROR: column "a" does not exist LINE 1: select a
Is there a way to get PostgreSQL to parse and check at function definition time - not at run time? We have a lot of obsolete PL / SQL codes in the workplace that we port to PostgreSQL, but the lack of checks during compilation is very painful, forcing us to do manual work - that is, write code to check all the code paths in all functions / procedures that otherwise were automated by Oracle.
source share