Re: Why does the PL/pgSQL compiler do this?

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Michael Moore <michaeljmoore(at)gmail(dot)com>
Cc: postgres list <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Why does the PL/pgSQL compiler do this?
Date: 2016-10-31 22:24:14
Message-ID: CAKFQuwYjBuTC59cnndRBb=42g0Y4DLQDx1Tm0JSROGTq0R0mFA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Mon, Oct 31, 2016 at 3:13 PM, Michael Moore <michaeljmoore(at)gmail(dot)com>
wrote:

> Here is the complete function, but all you need to look at is the
> exception block. (I didn't write this code) :-) I will ask the question
> after the code.
> ​[...]​
>
> RETURN TRUE;
>
> EXCEPTION WHEN OTHERS THEN
>
> RAISE EXCEPTION '% %', SQLERRM, SQLSTATE;
>
> ROLLBACK;
>
> RETURN FALSE;
>
> END;
>
> $BODY$
>
> LANGUAGE plpgsql VOLATILE
>
> COST 100;
>
>
> So, here is the question. Why does the compiler not catch:
>
> 1) ROLLBACK; is not a valid PL/pgSQL command
>

R
​eading section ​41.10.2 at the linked page should answer this part.

https://www.postgresql.org/docs/current/static/plpgsql-implementation.html

> 2) ROLLBACK; and RETURN FALSE; can never be reached
>
>
>
Similar to the above - though "static analysis" is yet a step beyond even
what the syntax checking skipping covered above would reveal.

​David J.​

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Michael Moore 2016-10-31 22:55:38 Re: Why does the PL/pgSQL compiler do this?
Previous Message Michael Moore 2016-10-31 22:13:58 Why does the PL/pgSQL compiler do this?