Alvaro Herrera wrote:

>Michael Paesold wrote:
Alvaro suggested to implement such a function. It is not there yet. I think
you would have to access the sub xact stack, but I have not looked into
that code for quite some time.

The only problem with this idea is that the function cannot be run when the transaction is in aborted state. Not sure if that is a problem or not. What happens if the user does

I don't think there is a problem. If the transaction is in aborted state, we only care if the last statement has aborted the transaction. Otherwise we would not issue our savepoint at all. In that case, i.e. if the last statement aborted the transaction, we can roll it back anyway, can't we? There can't be a savepoint on top of us, because that would have failed right now.
Is my logic wrong?


all in one command in psql?

I know psql sends that as three commands, so maybe it's not an issue.

As far as I remember psql splits the three commands, so there would be an implicit savepoint for each individual statement:

* SAVEPOINT pg_psql_savepoint; -- [1]
* SAVEPOINT pg_psql_savepoint; -- [2]
* ROLLBACK TO pg_psql_savepoint; -- [2]
* SAVEPOINT pg_psql_savepoint; -- [3]
* RELEASE pg_psql_savepoint; -- [3]
* RELEASE pg_psql_savepoint; -- [1], because pg_psql_savepoint is on top of the stack now again

I hope you get the point. ;-)

Do you think it's better to create a server-side function or handle that in the client? How hard would it be to implement such a function? And what should it return? Only the name of the current top savepoint?

Best Regards,
Michael Paesold

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Reply via email to