fix core when commit prepared xact
This commit is contained in:
@ -2079,6 +2079,14 @@ void FinishPreparedTransaction(const char* gid, bool isCommit)
|
||||
* callbacks will release the locks the transaction held.
|
||||
*/
|
||||
if (isCommit) {
|
||||
CommitSeqNo csn = SetXact2CommitInProgress(xid, 0);
|
||||
if (XLogStandbyInfoActive()) {
|
||||
XLogBeginInsert();
|
||||
XLogRegisterData((char*)(&xid), sizeof(TransactionId));
|
||||
XLogRegisterData((char*)(&csn), sizeof(CommitSeqNo));
|
||||
XLogInsert(RM_STANDBY_ID, XLOG_STANDBY_CSN_COMMITTING);
|
||||
}
|
||||
setCommitCsn(getNextCSN());
|
||||
pgxact->needToSyncXid = true;
|
||||
RecordTransactionCommitPrepared(xid,
|
||||
hdr->nsubxacts,
|
||||
|
@ -614,6 +614,58 @@ fetch from foo;
|
||||
(1 row)
|
||||
|
||||
abort;
|
||||
-- Test for prepared xacts
|
||||
create table prepared_xact_test(a int);
|
||||
start transaction;
|
||||
insert into prepared_xact_test values (1);
|
||||
prepare transaction 'pxact1';
|
||||
commit;
|
||||
WARNING: there is no transaction in progress
|
||||
select * from prepared_xact_test;
|
||||
a
|
||||
---
|
||||
(0 rows)
|
||||
|
||||
select gid from pg_prepared_xacts;
|
||||
gid
|
||||
--------
|
||||
pxact1
|
||||
(1 row)
|
||||
|
||||
commit prepared 'pxact1';
|
||||
select * from prepared_xact_test;
|
||||
a
|
||||
---
|
||||
1
|
||||
(1 row)
|
||||
|
||||
select * from pg_prepared_xacts;
|
||||
transaction | gid | prepared | owner | database
|
||||
-------------+-----+----------+-------+----------
|
||||
(0 rows)
|
||||
|
||||
begin;
|
||||
insert into prepared_xact_test values (2);
|
||||
prepare transaction 'pxact2';
|
||||
select gid from pg_prepared_xacts;
|
||||
gid
|
||||
--------
|
||||
pxact2
|
||||
(1 row)
|
||||
|
||||
rollback prepared 'pxact2';
|
||||
select * from prepared_xact_test;
|
||||
a
|
||||
---
|
||||
1
|
||||
(1 row)
|
||||
|
||||
select * from pg_prepared_xacts;
|
||||
transaction | gid | prepared | owner | database
|
||||
-------------+-----+----------+-------+----------
|
||||
(0 rows)
|
||||
|
||||
drop table prepared_xact_test;
|
||||
-- Test for proper cleanup after a failure in a cursor portal
|
||||
-- that was created in an outer subtransaction
|
||||
CREATE FUNCTION invert(x float8) RETURNS float8 LANGUAGE plpgsql AS
|
||||
|
@ -368,6 +368,28 @@ fetch from foo;
|
||||
|
||||
abort;
|
||||
|
||||
-- Test for prepared xacts
|
||||
create table prepared_xact_test(a int);
|
||||
start transaction;
|
||||
insert into prepared_xact_test values (1);
|
||||
prepare transaction 'pxact1';
|
||||
commit;
|
||||
select * from prepared_xact_test;
|
||||
select gid from pg_prepared_xacts;
|
||||
commit prepared 'pxact1';
|
||||
select * from prepared_xact_test;
|
||||
select * from pg_prepared_xacts;
|
||||
|
||||
begin;
|
||||
insert into prepared_xact_test values (2);
|
||||
prepare transaction 'pxact2';
|
||||
select gid from pg_prepared_xacts;
|
||||
rollback prepared 'pxact2';
|
||||
select * from prepared_xact_test;
|
||||
select * from pg_prepared_xacts;
|
||||
|
||||
drop table prepared_xact_test;
|
||||
|
||||
-- Test for proper cleanup after a failure in a cursor portal
|
||||
-- that was created in an outer subtransaction
|
||||
CREATE FUNCTION invert(x float8) RETURNS float8 LANGUAGE plpgsql AS
|
||||
|
Reference in New Issue
Block a user