Re: plpgsql.consistent_into

Поиск
Список
Период
Сортировка
От Marko Tiikkaja
Тема Re: plpgsql.consistent_into
Дата
Msg-id 52D47C52.2070405@joh.to
обсуждение исходный текст
Ответ на Re: plpgsql.consistent_into  (Florian Pflug <fgp@phlo.org>)
Ответы Re: plpgsql.consistent_into  (Florian Pflug <fgp@phlo.org>)
Список pgsql-hackers
On 1/14/14, 12:41 AM, Florian Pflug wrote:
> In fact, after reading the documentation on SELECT ... INTO, I'm convinced the
> the whole consistent_into thing is a bad idea. The documentation states clearly
> that
>
>    For INSERT/UPDATE/DELETE with RETURNING, PL/pgSQL reports an error for more than
>    one returned row, even when STRICT is not specified. This is because there is no
>    option such as ORDER BY with which to determine which affected row should be
>    returned.
>
> It therefor isn't an oversight that SELECT ... INTO allows multiple result rows
> but INSERT/UPDATE/DELETE forbids them, it's been done that way on purpose and
> for a reason.

Yeah, it does state that.  But it's a BS reason.  In addition to ORDER 
BY, SELECT also has a LIMIT which you can use to get the "first row" 
behaviour.  There's no way to go to the more sane behaviour from what we 
have right now.

When I've worked with PL/PgSQL, this has been a source of a few bugs 
that would have been noticed during testing if the behaviour of INTO 
wasn't as dangerous as it is right now.  Yes, it breaks backwards 
compatibility, but that's why there's a nice GUC.  If we're not going to 
scrap PL/PgSQL and start over again, we are going to have to do changes 
like this to make the language better.  Also I think that out of all the 
things we could do to break backwards compatibility, this is closer to 
"harmless" than "a pain in the butt".


Regards,
Marko Tiikkaja



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

Предыдущее
От: Florian Pflug
Дата:
Сообщение: Re: plpgsql.consistent_into
Следующее
От: Josh Berkus
Дата:
Сообщение: Re: plpgsql.consistent_into