Re: Re: « The PL/pgSQL interpreter parses the function's source text and produces an internal binary instruction tree... »

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Christophe Pettus <xof(at)thebuild(dot)com>
Cc: Bryn Llewellyn <bryn(at)yugabyte(dot)com>, pgsql-general list <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Re: « The PL/pgSQL interpreter parses the function's source text and produces an internal binary instruction tree... »
Date: 2022-07-29 02:04:02
Message-ID: 3603324.1659060242@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Christophe Pettus <xof(at)thebuild(dot)com> writes:
>> On Jul 28, 2022, at 18:04, Bryn Llewellyn <bryn(at)yugabyte(dot)com> wrote:
>> Is this expected?

> Yes. This isn't a bug.

It's actually a feature: there are cases where it's useful that we
don't do semantics checking on statements until they are reached.
A trivial example is

begin
create table foo(...);
insert into foo values(...);
end;

which would never work at all if we insisted on semantic validity
of the INSERT before the CREATE is executed.

Having said that, there are certainly aspects of what happens when
in plpgsql that don't have a lot of justification other than being
implementation artifacts. For instance, things that are certainly
plpgsql variable names (e.g. the lefthand side of an assignment)
are checked sooner than things that might not be (e.g. the righthand
side). That's defensible on a couple of grounds but it undoubtedly
leads to surprising results if you expect error conditions to be
recognized left-to-right or anything like that.

Of course, SQL commands themselves have to be analyzed in not
particularly left-to-right order, and we don't get that many
complaints about that.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Christophe Pettus 2022-07-29 02:09:36 Re: « The PL/pgSQL interpreter parses the function's source text and produces an internal binary instruction tree... »
Previous Message Bryn Llewellyn 2022-07-29 01:49:32 Re: « The PL/pgSQL interpreter parses the function's source text and produces an internal binary instruction tree... »