Re: wCTE behaviour

Поиск
Список
Период
Сортировка
От Dimitri Fontaine
Тема Re: wCTE behaviour
Дата
Msg-id m2zkteti48.fsf@2ndQuadrant.fr
обсуждение исходный текст
Ответ на Re: wCTE behaviour  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: wCTE behaviour  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: wCTE behaviour  (Alvaro Herrera <alvherre@commandprompt.com>)
Список pgsql-hackers
Tom Lane <tgl@sss.pgh.pa.us> writes:
>     WITH t AS (DELETE FROM foo RETURNING *)
>     SELECT * FROM t LIMIT 1;
>
> How many rows does this delete?  I think we concluded that we should
> force the DELETE to be run to conclusion even if the outer query didn't
> read it all

The counter-example that jumps to mind is unix pipes. It's read-only at
the consumer level but as soon as you stop reading, the producer stops.
I guess that's only talking about the surprise factor, though.

I'm not sure how far we go with the SIGPIPE analogy, but I wanted to say
that maybe that would not feel so strange to some people if the DELETE
were not run to completion but only until the reader is done.

What about this one:
 WITH d AS (DELETE FROM foo RETURNING id),      q AS (INSERT INTO queue SELECT 'D', id FROM d) SELECT * FROM q ORDER BY
idLIMIT 10;
 

For next example, replace INSERT with a MERGE to remove a previously
existing 'I' or 'U' event in the queue when we add a 'D'. Bonus points
if wCTE allows to implement the query without resorting to MERGE at all,
which would be nice in my mind.

Regards,
-- 
Dimitri Fontaine
http://2ndQuadrant.fr     PostgreSQL : Expertise, Formation et Support


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

Предыдущее
От: Heikki Linnakangas
Дата:
Сообщение: Re: B-tree parent pointer and checkpoints
Следующее
От: Dimitri Fontaine
Дата:
Сообщение: Re: Refactoring the Type System