Tom Lane wrote:
> Actually, I'd say the dubious behavior here is that
>
> SAVEPOINT foo;
> SAVEPOINT foo;
> SAVEPOINT foo;
>
> creates three nested savepoints ... it might be better if it
> automatically released any existing savepoint of the same name.
> I notice that the SAVEPOINT reference page says the latter is
> the behavior required by the SQL spec. Did we explicitly decide
> to do this differently from spec, and if so why?
Yeah, we did. I think the rationale was what happens when you have
another savepoint in the middle, say
SAVEPOINT foo;
SAVEPOINT bar;
SAVEPOINT foo;
The fact that the third sentence would implicitely release the "bar"
savepoint bothered us. IIRC Oracle gets away with this because their
savepoints are not actually nested, but sequential (i.e. you can release
"foo" without forgetting about "bar"). I'm not really sure about this.
Maybe we could change the behavior so that establishing a savepoint
releases a savepoint of the same name if it's the direct parent, but
that doesn't follow the KISS principle.
--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.