title: PostgreSQL vs Oracle: "compile-time" checking of PL/pgSQL
body: <p><em>Executive summary:</em> PostgreSQL is amazing, but we are facing many issues at work due to the fact that it postpones many checks on PL/pgSQL code until runtime. <em>Is there a way to make it more like Oracle's PL/SQL in this respect</em>?</p>
  
  <p>For example...</p>
  
  <p>Try executing this in any Oracle DB:</p>
  
  <pre><code>create function foo return number as
  begin
    select a from dual;
    return a;
  end;
  </code></pre>
  
  <p>Oracle will immediately (i.e. at <em>compile-time</em>!) respond with:</p>
  
  <pre><code>[Error] ORA-00904: invalid identifier
  </code></pre>
  
  <p>Now try the semantically equivalent thing in PostgreSQL:</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION public.foo ()
      RETURNS integer AS
  $body$
      BEGIN
          select a;
          return a;
      END;
  $body$
  LANGUAGE plpgsql;
  </code></pre>
  
  <p>You will see it - unfortunately! - execute fine ... No error is reported.</p>
  
  <p>But when you then try to call this function (i.e. at <em>runtime</em>) you will get:</p>
  
  <pre><code>ERROR:  column "a" does not exist
  LINE 1: select a
  </code></pre>
  
  <p>Is there a way to force PostgreSQL to perform syntax analysis and checking at function definition time - not at run-time? We have tons of legacy PL/SQL code at work, which we are porting to PostgreSQL - but the lack of <em>compile-time</em> checks is very painful, forcing us to do manual work - i.e. writing code to test all code paths in all functions/procedures - that was otherwise automated in Oracle.</p>