Re: Detecting if current transaction is modifying the database

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Detecting if current transaction is modifying the database
Дата
Msg-id 24224.1470428680@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Detecting if current transaction is modifying the database  (Christian Ohler <ohler@shift.com>)
Ответы Re: Detecting if current transaction is modifying the database  (Christian Ohler <ohler@shift.com>)
Список pgsql-general
Christian Ohler <ohler@shift.com> writes:
> Thanks, fair point.  I should have mentioned that I know about triggers but
> was hoping to find a less invasive mechanism (IIUC, I'd have to install a
> trigger on every table) – it seems to me that Postgres should just be able
> to tell me whether COMMIT will do anything, it obviously has to track that
> somehow (or some approximation of it).

You could check to see if the current transaction has had an XID assigned,
or if it's emitted any WAL records.  There are already tests for those
sorts of conditions in various places, though I do not think they're
exposed at the SQL level.

> Another thing I should have mentioned is that I don't consider incrementing
> a sequence to be a modification.

Things might not work the way you want on that...

            regards, tom lane


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

Предыдущее
От: Christian Ohler
Дата:
Сообщение: Re: Detecting if current transaction is modifying the database
Следующее
От: Rob Sargent
Дата:
Сообщение: Re: Detecting if current transaction is modifying the database