commit errors

Поиск
Список
Период
Сортировка
От Ryan VanderBijl
Тема commit errors
Дата
Msg-id 20030203052100.GA2934@vanderbijlfamily.com
обсуждение исходный текст
Ответы Re: commit errors  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
Hello,

Within an application, if I receive an error executing 'BEGIN',
'ROLLBACK', or 'COMMIT', what should I do?

What is the "official" recommendation, if any?
What do you (anyone) do?

I'm especially interested in serializable transactions, if that
makes a difference.

Yes, the documentation says I should either get 'COMMIT' back,
or 'WARNING: COMMIT: no transaciton in progress'. However,
what if, for example, the tcp/ip connection drops at that
point?  What should my application do?

Currently my code looks something like:

bool function_to_do_whatever() {
    while(1) {
        if (!begin_serializable_transaction())  {
            log("aborting: begin transaction failure");
            return false;
        }

        if (!execute( ... )) {
            if (!rollback_transaction()) {
                log("aborting: error rollback transaction");
                return false;
            }
            log("retrying: error executing ...");
            continue;
        }

        if (!commit_transaction())  {
            log("aborting: commit transaction failure");
            return false;
        }
        break;
    }

    log("database transaction commited.");
    return true;
}


--
Ryan VanderBijl                              rvbijl@vanderbijlfamily.com

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

Предыдущее
От: Greg Stark
Дата:
Сообщение: Re: Query plan question, and a memory leak
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Query plan question, and a memory leak