Re: Unable to ALTER table after SELECT data from table

Поиск
Список
Период
Сортировка
От Scott Marlowe
Тема Re: Unable to ALTER table after SELECT data from table
Дата
Msg-id dcc563d10712101327we238a2ao27f3caaad4ece30d@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Unable to ALTER table after SELECT data from table  (Keary Suska <hierophant@pcisys.net>)
Ответы Re: Unable to ALTER table after SELECT data from table  (Keary Suska <hierophant@pcisys.net>)
Список pgsql-general
On Dec 10, 2007 2:48 PM, Keary Suska <hierophant@pcisys.net> wrote:
> on 12/10/07 12:15 PM, Thomas-Carsten.Franke@brunel.de purportedly said:
>
> > To work around this I add an dbCon.rollBack() after select statement
> > above in good and in bad times. After that ALTER works.
> > Can someone explain me why I need this rollback ?
>
> You only need the rollback when the SELECT statement fails. When an error
> occurs within a transaction, the transaction is aborted but not rolled back.
> There are likely reasons why the rollback isn't automatic, but I don't know
> them.

I think you confuse postgresql with some other database.  Without
setting a savepoint, any error during a transaction and roll it back
upon connection close | rollback | commit.

I.e. the rollback IS automatic.  Just not necessarily immediate.

> Your choice is either to run the commands in an "autocommit" mode or, as you
> are doing, rollback (or commit, if there was no error) after the SELECT.

You can commit with an error.  It'll do the same thing as a rollback;

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

Предыдущее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: Unable to ALTER table after SELECT data from table
Следующее
От: "hjenkins"
Дата:
Сообщение: comparing rows