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
---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings