Re: savepoint improvements

Поиск
Список
Период
Сортировка
От Dennis Bjorklund
Тема Re: savepoint improvements
Дата
Msg-id 45B1A809.2070003@zigo.dhs.org
обсуждение исходный текст
Ответ на savepoint improvements  ("Merlin Moncure" <mmoncure@gmail.com>)
Список pgsql-hackers
Merlin Moncure skrev:

> The missing piece of the puzzle is the ability to recover a failed
> transaction without issuing a full commit/rollback.  This could be a
> new flavor of the savepoint command, commit command, or a new command.
> As a bonus, upon recovering the transaction you could snap an sql
> statement...this would be great for scripting:
> 
> BEGIN;
> SAVEPOINT X;
> COMMIT ON ERRORS SELECT FOO();
> 
> --or--
> 
> BEGIN;
> SAVEPOINT x;
> SAVEPOINT y ON ERRORS SELECT FOO; -- (or ROLLBACK TO SAVEPOINT x);
> COMMIT;
> 
> comments? fast track to todo list? :-)

Isn't the problem that you try to use psql for scripting and it doesn't 
have usual scripting power like branching (if) or looping (while,for) 
that most scripting languages have. If there was say an \if command in 
psql you could do things like this:

BEGIN;

INSERT INTO foo VALUES (42);

SAVEPOINT X;
INSERT INTO foo VALUES (NULL);

\if errorcode > 0  ROLLBACK TO SAVEPOINT X;
  INSERT INTO foo VALUES (666);
\endif

COMMIT;

I'm not sure you want to extend psql to be a full scripting engine, but 
maybe. It would be useful to me if it had an \if command like above. An 
other alternative is to use some other language to write scripts in that 
already have branching, looping, expression evaluation and what else.

/Dennis


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

Предыдущее
От: Gavin Sherry
Дата:
Сообщение: Re: Planning aggregates which require sorted or distinct
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Planning aggregates which require sorted or distinct