| От | Tom Lane |
|---|---|
| Тема | Re: delete inside for plpgsql loop on same relation? |
| Дата | |
| Msg-id | 17007.1560882011@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | delete inside for plpgsql loop on same relation? (Rob Nikander <rob.nikander@gmail.com>) |
| Список | pgsql-general |
Rob Nikander <rob.nikander@gmail.com> writes:
> Are there guarantees about how this plpgsql behaves? It’s deleting from a table while it loops over it. So far it
seemslike the delete is logically after the select, as I hoped, and doesn’t interfere.
> for row in select * from some_stuff loop
> delete from some_stuff where …
> ...
> end loop;
Sure. A query will not see the effects of queries that start after it.
This isn't particularly plpgsql-specific.
Some qualifications are needed if you have triggers or volatile functions
in the first query (those *can* see later effects); but this usage seems
safe enough.
regards, tom lane
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера