Re: savepoints with the same name

Поиск
Список
Период
Сортировка
От Greg Sabino Mullane
Тема Re: savepoints with the same name
Дата
Msg-id 76452bddd8edd81e1aec6dd0fdcaad42@biglumber.com
обсуждение исходный текст
Ответ на savepoints with the same name  (hernan gonzalez <hgonzalez@gmail.com>)
Список pgsql-general
-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160


> I was thinking thinking about the issue asked here, about an error in
> a query causing the whole transaction to abort,
...
> I wonder if the suggestion I ("leonbloy") gave, of adding a SAVEPOINT
> after each insert  (when doing interactive work)
> is reasonable.

Not only reasonable, but already implemented inside of psql. Just type:

\set ON_ERROR_ROLLBACK on

inside your psql session, and it will automatically create a savepoint
before each command, and thus allow your transaction to continue
even if you encounter errors.

> "If you savepoint every single insert, you'll wind up begin much
> much slower..."
>
> Does that also apply when I issue a SAVEPOINT with the same name? Does
> the new savepoint release the previous and create a new
> one, or does it "move" the previous? Or it's just that a new one is
> created and the name "shadows" the previous, so that there are still N
> active savepoints in the transaction, taking up memory/resources ?

Yes, savepoints will slow things down, but probably not as much as you
are fearing. Savepoints will nest (or shadow). The ON_ERROR_ROLLBACK
feature creates the savepoint before the query, then either does a
ROLLBACK TO or a RELEASE depending on the success of the query, so there
is no build up of savepoints.

- --
Greg Sabino Mullane greg@turnstep.com
End Point Corporation http://www.endpoint.com/
PGP Key: 0x14964AC8 201004301245
http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
-----BEGIN PGP SIGNATURE-----

iEYEAREDAAYFAkvbCVIACgkQvJuQZxSWSsi4nwCdH8xwQ3RpVlD65I239hs/eAbW
V3oAniaEv2VWFkrrhqDU9HDlCRMv1ROx
=i0P6
-----END PGP SIGNATURE-----



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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Function to Table reference
Следующее
От: Glyn Astill
Дата:
Сообщение: Re: pg_restore: [custom archiver] dumping a specific TOC data block out of order is not supported without ID on this input stream (fseek required)