mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-03 22:07:52 +02:00
Fix bug in COMMIT AND CHAIN command.
This commit fixes COMMIT AND CHAIN command so that it starts new transaction
immediately even if savepoints are defined within the transaction to commit.
Previously COMMIT AND CHAIN command did not in that case because
commit 280a408b48
forgot to make CommitTransactionCommand() handle
a transaction chaining when the transaction state was TBLOCK_SUBCOMMIT.
Also this commit adds the regression test for COMMIT AND CHAIN command
when savepoints are defined.
Back-patch to v12 where transaction chaining was added.
Reported-by: Arthur Nascimento
Author: Fujii Masao
Reviewed-by: Arthur Nascimento, Vik Fearing
Discussion: https://postgr.es/m/16867-3475744069228158@postgresql.org
This commit is contained in:
parent
bf9d3a5f84
commit
422012c98f
@ -3084,6 +3084,13 @@ CommitTransactionCommand(void)
|
|||||||
Assert(s->parent == NULL);
|
Assert(s->parent == NULL);
|
||||||
CommitTransaction();
|
CommitTransaction();
|
||||||
s->blockState = TBLOCK_DEFAULT;
|
s->blockState = TBLOCK_DEFAULT;
|
||||||
|
if (s->chain)
|
||||||
|
{
|
||||||
|
StartTransaction();
|
||||||
|
s->blockState = TBLOCK_INPROGRESS;
|
||||||
|
s->chain = false;
|
||||||
|
RestoreTransactionCharacteristics();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (s->blockState == TBLOCK_PREPARE)
|
else if (s->blockState == TBLOCK_PREPARE)
|
||||||
{
|
{
|
||||||
|
@ -774,6 +774,46 @@ SHOW transaction_deferrable;
|
|||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
INSERT INTO abc VALUES (5);
|
INSERT INTO abc VALUES (5);
|
||||||
|
COMMIT;
|
||||||
|
START TRANSACTION ISOLATION LEVEL REPEATABLE READ, READ WRITE, DEFERRABLE;
|
||||||
|
SHOW transaction_isolation;
|
||||||
|
transaction_isolation
|
||||||
|
-----------------------
|
||||||
|
repeatable read
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SHOW transaction_read_only;
|
||||||
|
transaction_read_only
|
||||||
|
-----------------------
|
||||||
|
off
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SHOW transaction_deferrable;
|
||||||
|
transaction_deferrable
|
||||||
|
------------------------
|
||||||
|
on
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SAVEPOINT x;
|
||||||
|
COMMIT AND CHAIN; -- TBLOCK_SUBCOMMIT
|
||||||
|
SHOW transaction_isolation;
|
||||||
|
transaction_isolation
|
||||||
|
-----------------------
|
||||||
|
repeatable read
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SHOW transaction_read_only;
|
||||||
|
transaction_read_only
|
||||||
|
-----------------------
|
||||||
|
off
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SHOW transaction_deferrable;
|
||||||
|
transaction_deferrable
|
||||||
|
------------------------
|
||||||
|
on
|
||||||
|
(1 row)
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
-- different mix of options just for fun
|
-- different mix of options just for fun
|
||||||
START TRANSACTION ISOLATION LEVEL SERIALIZABLE, READ WRITE, NOT DEFERRABLE;
|
START TRANSACTION ISOLATION LEVEL SERIALIZABLE, READ WRITE, NOT DEFERRABLE;
|
||||||
|
@ -458,6 +458,17 @@ SHOW transaction_deferrable;
|
|||||||
INSERT INTO abc VALUES (5);
|
INSERT INTO abc VALUES (5);
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
|
START TRANSACTION ISOLATION LEVEL REPEATABLE READ, READ WRITE, DEFERRABLE;
|
||||||
|
SHOW transaction_isolation;
|
||||||
|
SHOW transaction_read_only;
|
||||||
|
SHOW transaction_deferrable;
|
||||||
|
SAVEPOINT x;
|
||||||
|
COMMIT AND CHAIN; -- TBLOCK_SUBCOMMIT
|
||||||
|
SHOW transaction_isolation;
|
||||||
|
SHOW transaction_read_only;
|
||||||
|
SHOW transaction_deferrable;
|
||||||
|
COMMIT;
|
||||||
|
|
||||||
-- different mix of options just for fun
|
-- different mix of options just for fun
|
||||||
START TRANSACTION ISOLATION LEVEL SERIALIZABLE, READ WRITE, NOT DEFERRABLE;
|
START TRANSACTION ISOLATION LEVEL SERIALIZABLE, READ WRITE, NOT DEFERRABLE;
|
||||||
SHOW transaction_isolation;
|
SHOW transaction_isolation;
|
||||||
|
Loading…
Reference in New Issue
Block a user