Re: PLpgSQL: list of scalars as row for assign stmt, fore and fors stm

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: PLpgSQL: list of scalars as row for assign stmt, fore and fors stm
Дата
Msg-id 8581.1135137891@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: PLpgSQL: list of scalars as row for assign stmt, fore and fors stm  ("Pavel Stehule" <pavel.stehule@hotmail.com>)
Ответы Re: PLpgSQL: list of scalars as row for assign stmt, fore and fors stm  ("Pavel Stehule" <pavel.stehule@hotmail.com>)
Список pgsql-patches
"Pavel Stehule" <pavel.stehule@hotmail.com> writes:
>>>> x, y := r;
>
>>> That strikes me as a really bad idea.  It weakens both syntax and
>>> semantic error checking, to accomplish how much?
>>
>> Could use PHP-style thingy:
>> LIST(x, y) := r;

Actually, ROW(x, y) would be the right spelling per SQL convention.

> It's inconsystency :-(.
> EXECUTE INTO and SELECT INTO use scalar of vectors without anything.

But in both of those cases there are required leading keywords to give
you some clue what's supposed to come next.  Allowing bare x, y at the
start of a statement is just a recipe for misconstruing stuff that was
intended as something else and is one or two punctuation characters shy
of perfection.

There is also the problem of insufficient semantic cross-checking.  A
record variable doesn't have any very well-defined order of fields, so
who's to say which value goes to x and which to y?  For that matter,
if I just have
    x := y
and y is a single-field rowtype, it'd be entirely unclear whether x is
to receive the row value or the field value.

I don't think this buys anything that is worth the can of worms we'd
be opening up.  The extension for FOR might be worth doing, but not
the assignment change.

And, to reiterate Andrew's point, this entire discussion should have
been held before you wrote a line of code.  It is utterly wrong
to be doing it in pgsql-patches.

            regards, tom lane

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

Предыдущее
От: Christopher Kings-Lynne
Дата:
Сообщение: Re: PLpgSQL: list of scalars as row for assign stmt, fore
Следующее
От: "Serge A. Ribalchenko"
Дата:
Сообщение: new uk_UA i18n file