From: Tom Lane <tgl@sss.pgh.pa.us>
To: Christophe Pettus <xof@thebuild.com>
Cc: Bryn Llewellyn <bryn@yugabyte.com>
Cc: pgsql-general list <pgsql-general@lists.postgresql.org>
Subject: Re: Re: « The PL/pgSQL interpreter parses the function's source text and produces an internal binary instruction tree... »
Date: Thu, 28 Jul 2022 22:04:02 -0400
Message-ID: <3603324.1659060242@sss.pgh.pa.us> (raw)
In-Reply-To: <14BAC5B9-225E-49A8-A225-60C2F179E334@thebuild.com>
References: <DD03DCB0-1946-4CEB-8D72-D94EE7A85A7A@yugabyte.com>
<14BAC5B9-225E-49A8-A225-60C2F179E334@thebuild.com>
Christophe Pettus <xof@thebuild.com> writes:
>> On Jul 28, 2022, at 18:04, Bryn Llewellyn <bryn@yugabyte.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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, xof@thebuild.com, bryn@yugabyte.com
Subject: Re: « The PL/pgSQL interpreter parses the function's source text and produces an internal binary instruction tree... »
In-Reply-To: <3603324.1659060242@sss.pgh.pa.us>
References: <DD03DCB0-1946-4CEB-8D72-D94EE7A85A7A@yugabyte.com> <14BAC5B9-225E-49A8-A225-60C2F179E334@thebuild.com> <3603324.1659060242@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox