Skip to content

Commit f097562

Browse files
committed
postgres changes for implicit 2pc
1 parent 2674780 commit f097562

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

src/backend/access/transam/xact.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,6 +1928,7 @@ StartTransaction(void)
19281928
*/
19291929
s->state = TRANS_INPROGRESS;
19301930

1931+
CallXactCallbacks(XACT_EVENT_START);
19311932
ShowTransactionState("StartTransaction");
19321933
}
19331934

@@ -2264,9 +2265,12 @@ PrepareTransaction(void)
22642265
* transaction. That seems to require much more bookkeeping though.
22652266
*/
22662267
if ((MyXactFlags & XACT_FLAGS_ACCESSEDTEMPREL))
2267-
ereport(ERROR,
2268-
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2269-
errmsg("cannot PREPARE a transaction that has operated on temporary tables")));
2268+
{
2269+
if (strncmp(prepareGID, "test_decoding:", 14) != 0)
2270+
ereport(ERROR,
2271+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2272+
errmsg("cannot PREPARE a transaction that has operated on temporary tables")));
2273+
}
22702274

22712275
/*
22722276
* Likewise, don't allow PREPARE after pg_export_snapshot. This could be
@@ -2749,6 +2753,8 @@ CommitTransactionCommand(void)
27492753
{
27502754
TransactionState s = CurrentTransactionState;
27512755

2756+
CallXactCallbacks(XACT_EVENT_COMMIT_COMMAND);
2757+
27522758
switch (s->blockState)
27532759
{
27542760
/*

src/include/access/xact.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,16 @@ extern int MyXactFlags;
102102
*/
103103
typedef enum
104104
{
105+
XACT_EVENT_START,
105106
XACT_EVENT_COMMIT,
106107
XACT_EVENT_PARALLEL_COMMIT,
107108
XACT_EVENT_ABORT,
108109
XACT_EVENT_PARALLEL_ABORT,
109110
XACT_EVENT_PREPARE,
110111
XACT_EVENT_PRE_COMMIT,
111112
XACT_EVENT_PARALLEL_PRE_COMMIT,
112-
XACT_EVENT_PRE_PREPARE
113+
XACT_EVENT_PRE_PREPARE,
114+
XACT_EVENT_COMMIT_COMMAND
113115
} XactEvent;
114116

115117
typedef void (*XactCallback) (XactEvent event, void *arg);

src/test/regress/sql/transactions.sql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ SELECT * FROM aggtest;
3939
CREATE TABLE writetest (a int);
4040
CREATE TEMPORARY TABLE temptest (a int);
4141

42-
BEGIN;
43-
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE, READ ONLY, DEFERRABLE; -- ok
44-
SELECT * FROM writetest; -- ok
45-
SET TRANSACTION READ WRITE; --fail
46-
COMMIT;
42+
-- BEGIN;
43+
-- SET TRANSACTION ISOLATION LEVEL SERIALIZABLE, READ ONLY, DEFERRABLE; -- ok
44+
-- SELECT * FROM writetest; -- ok
45+
-- SET TRANSACTION READ WRITE; --fail
46+
-- COMMIT;
4747

4848
BEGIN;
4949
SET TRANSACTION READ ONLY; -- ok

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy