Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit338e9a9

Browse files
committed
evict GetLockedGlobalTransactionId()
1 parent91c69c2 commit338e9a9

File tree

4 files changed

+20
-34
lines changed

4 files changed

+20
-34
lines changed

‎contrib/pg_tsdtm/pg_tsdtm.c

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
#defineINVALID_CID 0
3737
#defineMIN_WAIT_TIMEOUT 1000
3838
#defineMAX_WAIT_TIMEOUT 100000
39-
#defineMAX_GTID_SIZE 16
4039
#defineHASH_PER_ELEM_OVERHEAD 64
4140

4241
#defineUSEC 1000000
@@ -297,12 +296,6 @@ dtm_shmem_startup(void)
297296
DtmInitialize();
298297
}
299298

300-
staticGlobalTransactionId
301-
dtm_get_global_trans_id()
302-
{
303-
returnGetLockedGlobalTransactionId();
304-
}
305-
306299
staticvoid
307300
dtm_xact_callback(XactEventevent,void*arg)
308301
{
@@ -324,15 +317,15 @@ dtm_xact_callback(XactEvent event, void *arg)
324317
break;
325318

326319
caseXACT_EVENT_ABORT_PREPARED:
327-
DtmLocalAbortPrepared(&dtm_tx,dtm_get_global_trans_id());
320+
DtmLocalAbortPrepared(&dtm_tx);
328321
break;
329322

330323
caseXACT_EVENT_COMMIT_PREPARED:
331-
DtmLocalCommitPrepared(&dtm_tx,dtm_get_global_trans_id());
324+
DtmLocalCommitPrepared(&dtm_tx);
332325
break;
333326

334327
caseXACT_EVENT_PREPARE:
335-
DtmLocalSavePreparedState(dtm_get_global_trans_id());
328+
DtmLocalSavePreparedState(&dtm_tx);
336329
DtmLocalEnd(&dtm_tx);
337330
break;
338331

@@ -679,6 +672,7 @@ DtmLocalExtend(DtmCurrentTrans * x, GlobalTransactionId gtid)
679672
id->nSubxids=0;
680673
id->subxids=0;
681674
}
675+
strncpy(x->gtid,gtid,MAX_GTID_SIZE);
682676
SpinLockRelease(&local->lock);
683677
}
684678
x->is_global= true;
@@ -708,6 +702,7 @@ DtmLocalAccess(DtmCurrentTrans * x, GlobalTransactionId gtid, cid_t global_cid)
708702
x->snapshot=global_cid;
709703
x->is_global= true;
710704
}
705+
strncpy(x->gtid,gtid,MAX_GTID_SIZE);
711706
SpinLockRelease(&local->lock);
712707
if (global_cid<local_cid-DtmVacuumDelay*USEC)
713708
{
@@ -813,13 +808,13 @@ DtmLocalEndPrepare(GlobalTransactionId gtid, cid_t cid)
813808
* Mark tranasction as prepared
814809
*/
815810
void
816-
DtmLocalCommitPrepared(DtmCurrentTrans*x,GlobalTransactionIdgtid)
811+
DtmLocalCommitPrepared(DtmCurrentTrans*x)
817812
{
818-
Assert(gtid!=NULL);
813+
Assert(x->gtid!=NULL);
819814

820815
SpinLockAcquire(&local->lock);
821816
{
822-
DtmTransId*id= (DtmTransId*)hash_search(gtid2xid,gtid,HASH_REMOVE,NULL);
817+
DtmTransId*id= (DtmTransId*)hash_search(gtid2xid,x->gtid,HASH_REMOVE,NULL);
823818

824819
Assert(id!=NULL);
825820

@@ -881,13 +876,13 @@ DtmLocalCommit(DtmCurrentTrans * x)
881876
* Mark tranasction as prepared
882877
*/
883878
void
884-
DtmLocalAbortPrepared(DtmCurrentTrans*x,GlobalTransactionIdgtid)
879+
DtmLocalAbortPrepared(DtmCurrentTrans*x)
885880
{
886-
Assert(gtid!=NULL);
881+
Assert(x->gtid!=NULL);
887882

888883
SpinLockAcquire(&local->lock);
889884
{
890-
DtmTransId*id= (DtmTransId*)hash_search(gtid2xid,gtid,HASH_REMOVE,NULL);
885+
DtmTransId*id= (DtmTransId*)hash_search(gtid2xid,x->gtid,HASH_REMOVE,NULL);
891886

892887
Assert(id!=NULL);
893888

@@ -998,13 +993,13 @@ DtmGetCsn(TransactionId xid)
998993
* Save state of parepared transaction
999994
*/
1000995
void
1001-
DtmLocalSavePreparedState(GlobalTransactionIdgtid)
996+
DtmLocalSavePreparedState(DtmCurrentTrans*x)
1002997
{
1003-
if (gtid!=NULL)
998+
if (x->gtid[0])
1004999
{
10051000
SpinLockAcquire(&local->lock);
10061001
{
1007-
DtmTransId*id= (DtmTransId*)hash_search(gtid2xid,gtid,HASH_FIND,NULL);
1002+
DtmTransId*id= (DtmTransId*)hash_search(gtid2xid,x->gtid,HASH_FIND,NULL);
10081003

10091004
if (id!=NULL)
10101005
{

‎contrib/pg_tsdtm/pg_tsdtm.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#ifndefDTM_BACKEND_H
22
#defineDTM_BACKEND_H
33

4+
#defineMAX_GTID_SIZE 16
5+
46
typedefintnodeid_t;
57
typedefuint64cid_t;
68

@@ -11,6 +13,7 @@ typedef struct
1113
boolis_prepared;
1214
cid_tcid;
1315
cid_tsnapshot;
16+
chargtid[MAX_GTID_SIZE];
1417
}DtmCurrentTrans;
1518

1619
typedefcharconst*GlobalTransactionId;
@@ -37,10 +40,10 @@ cid_tDtmLocalPrepare(GlobalTransactionId gtid, cid_t cid);
3740
voidDtmLocalEndPrepare(GlobalTransactionIdgtid,cid_tcid);
3841

3942
/* Do local commit of global transaction */
40-
voidDtmLocalCommitPrepared(DtmCurrentTrans*x,GlobalTransactionIdgtid);
43+
voidDtmLocalCommitPrepared(DtmCurrentTrans*x);
4144

4245
/* Do local abort of global transaction */
43-
voidDtmLocalAbortPrepared(DtmCurrentTrans*x,GlobalTransactionIdgtid);
46+
voidDtmLocalAbortPrepared(DtmCurrentTrans*x);
4447

4548
/* Do local commit of global transaction */
4649
voidDtmLocalCommit(DtmCurrentTrans*x);
@@ -52,6 +55,6 @@ voidDtmLocalAbort(DtmCurrentTrans * x);
5255
voidDtmLocalEnd(DtmCurrentTrans*x);
5356

5457
/* Save global preapred transactoin state */
55-
voidDtmLocalSavePreparedState(GlobalTransactionIdgtid);
58+
voidDtmLocalSavePreparedState(DtmCurrentTrans*x);
5659

5760
#endif

‎src/backend/access/transam/twophase.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2414,13 +2414,3 @@ PrepareRedoRemove(TransactionId xid, bool giveWarning)
24142414

24152415
return;
24162416
}
2417-
2418-
2419-
/*
2420-
* Return identified of current global transaction
2421-
*/
2422-
constchar*
2423-
GetLockedGlobalTransactionId(void)
2424-
{
2425-
returnMyLockedGxact ?MyLockedGxact->gid :NULL;
2426-
}

‎src/include/access/twophase.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,4 @@ extern void PrepareRedoAdd(char *buf, XLogRecPtr start_lsn,
5858
externvoidPrepareRedoRemove(TransactionIdxid,boolgiveWarning);
5959
externvoidrestoreTwoPhaseData(void);
6060

61-
externconstchar*GetLockedGlobalTransactionId(void);
62-
6361
#endif/* TWOPHASE_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp