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

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Re: « The PL/pgSQL interpreter parses the function's source text and produces an internal binary instruction tree... »
Дата
Msg-id 3603324.1659060242@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: « The PL/pgSQL interpreter parses the function's source text and produces an internal binary instruction tree... »  (Christophe Pettus <xof@thebuild.com>)
Ответы Re: « The PL/pgSQL interpreter parses the function's source text and produces an internal binary instruction tree... »  (Bryn Llewellyn <bryn@yugabyte.com>)
Список pgsql-general
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



В списке pgsql-general по дате отправления:

Предыдущее
От: Bryn Llewellyn
Дата:
Сообщение: Re: « The PL/pgSQL interpreter parses the function's source text and produces an internal binary instruction tree... »
Следующее
От: Christophe Pettus
Дата:
Сообщение: Re: « The PL/pgSQL interpreter parses the function's source text and produces an internal binary instruction tree... »