Re: Cleaning up aborted transactions

Поиск
Список
Период
Сортировка
От Michael Glaesemann
Тема Re: Cleaning up aborted transactions
Дата
Msg-id DB8E9D12-9B24-11D7-94FB-0005029FC1A7@myrealbox.com
обсуждение исходный текст
Ответ на Re: Cleaning up aborted transactions  ("Adrian Tineo" <adriantineo@softhome.net>)
Ответы Re: Cleaning up aborted transactions  (Rod Taylor <rbt@rbt.ca>)
Список pgsql-php
On Tuesday, Jun 10, 2003, at 17:05 Asia/Tokyo, Adrian Tineo wrote:
> pg_connect($connection);
> pg_query($connection,"BEGIN;");
> $insert="INSERT INTO table VALUES (2,7,5);
> $result=pg_query($connection,$insert);
> if(!$result){
>     pg_query($connection,"ROLLBACK");
>     //Something went wrong with the insert so we rollback and nothing
> changes in the db
> }else{
>     pg_query($connection,"COMMIT");
>     // If everything went all right, then we commit the changes
> }
> pg_close($connection);


Thanks, Adrian, for the illustration, especially the instance with
ROLLBACK. I've figured out this sequence now.

What I'm wondering about is what happens when this sequence isn't
properly followed and the script quits before issuing a ROLLBACK or a
COMMIT. Obviously it's not a good situation and one to be avoided.

But, if it does happen, what are the alternatives? How do I finish off
that transaction that hasn't been properly finished? I'm assuming
restarting postmaster will do it, but I'm wondering if there's any
other way.

I haven't been able to find anything about this after googling.
Obviously the vast majority of people have their ducks in a row. :)

Thanks again, Adrian. I appreciate the response.

Carefully closing my transactions,

Michael


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

Предыдущее
От: "Adrian Tineo"
Дата:
Сообщение: Re: Cleaning up aborted transactions
Следующее
От: Rod Taylor
Дата:
Сообщение: Re: Cleaning up aborted transactions