From: | Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr> |
---|---|
To: | Michael Paquier <michael(at)paquier(dot)xyz>, Andres Freund <andres(at)anarazel(dot)de> |
Cc: | Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, fn ln <emuser20140816(at)gmail(dot)com>, PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: BUG #15977: Inconsistent behavior in chained transactions |
Date: | 2019-09-07 06:54:42 |
Message-ID: | alpine.DEB.2.21.1909070833570.15836@lancre |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs pgsql-hackers |
Hello,
>> I do think the fact that COMMIT in multi-statement implicit transaction
>> has some usecase, is an argument for just implementing it properly...
>
> Like Peter, I would also keep an ERROR for now, as we could always
> relax that later on.
I can agree with both warning and error, but for me the choice should be
consistent with the current behavior of COMMIT and ROLLBACK in the same
context.
pg> CREATE OR REPLACE PROCEDURE warn(msg TEXT) LANGUAGE plpgsql AS
$$ BEGIN RAISE WARNING 'warning: %', msg ; END ; $$;
Then an out-of-transaction multi-statement commit:
pg> CALL warn('1') \; COMMIT \; CALL warn('2') ;
WARNING: warning: 1
WARNING: there is no transaction in progress
WARNING: warning: 2
CALL
But v4 creates an non uniform behavior that I find surprising and
unwelcome:
pg> CALL warn('1') \; COMMIT AND CHAIN \; CALL warn('2') ;
WARNING: warning: 1
ERROR: COMMIT AND CHAIN can only be used in transaction blocks
Why "commit" & "commit and chain" should behave differently in the same
context? For me they can error or warn, but consistency implies that they
should do the exact same thing.
From a user perspective, I really want to know if a commit did not do what
I thought, and I'm certainly NOT expecting the stuff I sent to go on as if
nothing happened. Basically I agree with everybody that raising an error
is the right behavior in this case, which suggest that out-of-transaction
commit and rollback should error.
So my opinion is that commit & rollback issued out-of-transaction should
also generate an error.
If it is too much a change and potential regression, then I think that the
"and chain" variants should be consistent and just raise warnings.
--
Fabien.
From | Date | Subject | |
---|---|---|---|
Next Message | fn ln | 2019-09-07 09:58:20 | Re: BUG #15977: Inconsistent behavior in chained transactions |
Previous Message | Tom Lane | 2019-09-07 00:00:51 | Re: BUG #15994: can't run psql |
From | Date | Subject | |
---|---|---|---|
Next Message | fn ln | 2019-09-07 09:58:20 | Re: BUG #15977: Inconsistent behavior in chained transactions |
Previous Message | Swen Kooij | 2019-09-07 06:48:25 | Re: Patch to add hook to copydir() |