Re: any way to check if a transaction is active?

Поиск
Список
Период
Сортировка
От Richard Huxton
Тема Re: any way to check if a transaction is active?
Дата
Msg-id 200208081522.53644.dev@archonet.com
обсуждение исходный текст
Ответ на any way to check if a transaction is active?  (Mario Weilguni <mweilguni@sime.com>)
Список pgsql-general
On Thursday 08 Aug 2002 7:57 am, Mario Weilguni wrote:
> I'm trying to find some method to detect wether a real transaction is in
> progress. With "real" I mean a transaction explicitly started with "begin",
> not the auto-transactions postgres puts around single statements. Is there
> a function that can be used for this? It's ok for me to write a extension
> function in C if this is necessary, but I've no clue where to start?

Can't think of a good way to do this - you can query the states of the
backends using "ps" since Postgresql modifies the command-line displayed. If
you want to write some C I'd start looking at the code that does that.

Also, check the statistics analyser, although I can't think of anything that
says whether you're in a transaction.

> The reason why I need this is this one:
> * I use a database wrapper in PHP to stay compatible with Oracle
> * whenever I issue a rollback without any prior transaction, the apache
> error log will have a line NOTICE:  ROLLBACK: no transaction in progress
> ROLLBACK

Is there not some way to flag whether you issue a BEGIN? If you don't know
whether you are in a transaction, how do you know what you are rolling back?

Another option would be to always issue a BEGIN at script startup and a COMMIT
or ROLLBACK at script end.

> This makes the error log unreadable, so I'm trying to get rid of this. Any
> idea how?

Or - just post-process the apache log with sed/awk/perl.

HTH

- Richard Huxton

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

Предыдущее
От: Richard Huxton
Дата:
Сообщение: Re: looking to speed up SELECT ... LEFT JOIN query
Следующее
От: Robert Treat
Дата:
Сообщение: Re: Does COPY need a manual Commit?