@@ -84,6 +84,9 @@ typedef struct
8484#define DTM_TRACE (x )
8585/* #define DTM_TRACE(x) fprintf x */
8686
87+ /* GUC enabling global snapshots */
88+ bool track_global_snapshots ;
89+
8790// static shmem_startup_hook_type prev_shmem_startup_hook;
8891static HTAB * xid2status ;
8992static HTAB * gtid2xid ;
@@ -1019,8 +1022,12 @@ Datum
10191022pg_global_snaphot_create (PG_FUNCTION_ARGS )
10201023{
10211024 GlobalTransactionId gtid = text_to_cstring (PG_GETARG_TEXT_PP (0 ));
1022- cid_t cid = DtmLocalExtend (& dtm_tx , gtid );
1025+ cid_t cid ;
1026+
1027+ if (!track_global_snapshots )
1028+ elog (ERROR , "Global snapshots are disabled" );
10231029
1030+ cid = DtmLocalExtend (& dtm_tx , gtid );
10241031 DTM_TRACE ((stderr , "Backend %d extends transaction %u(%s) to global with cid=%lu\n" , getpid (), dtm_tx .xid , gtid , cid ));
10251032 PG_RETURN_INT64 (cid );
10261033}
@@ -1031,6 +1038,9 @@ pg_global_snaphot_join(PG_FUNCTION_ARGS)
10311038 cid_t cid = PG_GETARG_INT64 (0 );
10321039 GlobalTransactionId gtid = text_to_cstring (PG_GETARG_TEXT_PP (1 ));
10331040
1041+ if (!track_global_snapshots )
1042+ elog (ERROR , "Global snapshots are disabled" );
1043+
10341044 DTM_TRACE ((stderr , "Backend %d joins transaction %u(%s) with cid=%lu\n" , getpid (), dtm_tx .xid , gtid , cid ));
10351045 cid = DtmLocalAccess (& dtm_tx , gtid , cid );
10361046 PG_RETURN_INT64 (cid );
@@ -1041,6 +1051,9 @@ pg_global_snaphot_begin_prepare(PG_FUNCTION_ARGS)
10411051{
10421052 GlobalTransactionId gtid = text_to_cstring (PG_GETARG_TEXT_PP (0 ));
10431053
1054+ if (!track_global_snapshots )
1055+ elog (ERROR , "Global snapshots are disabled" );
1056+
10441057 DtmLocalBeginPrepare (gtid );
10451058 DTM_TRACE ((stderr , "Backend %d begins prepare of transaction %s\n" , getpid (), gtid ));
10461059 PG_RETURN_VOID ();
@@ -1052,6 +1065,10 @@ pg_global_snaphot_prepare(PG_FUNCTION_ARGS)
10521065 GlobalTransactionId gtid = text_to_cstring (PG_GETARG_TEXT_PP (0 ));
10531066 cid_t cid = PG_GETARG_INT64 (1 );
10541067
1068+ if (!track_global_snapshots )
1069+ elog (ERROR , "Global snapshots are disabled" );
1070+
1071+
10551072 cid = DtmLocalPrepare (gtid , cid );
10561073 DTM_TRACE ((stderr , "Backend %d prepares transaction %s with cid=%lu\n" , getpid (), gtid , cid ));
10571074 PG_RETURN_INT64 (cid );
@@ -1063,6 +1080,9 @@ pg_global_snaphot_end_prepare(PG_FUNCTION_ARGS)
10631080 GlobalTransactionId gtid = text_to_cstring (PG_GETARG_TEXT_PP (0 ));
10641081 cid_t cid = PG_GETARG_INT64 (1 );
10651082
1083+ if (!track_global_snapshots )
1084+ elog (ERROR , "Global snapshots are disabled" );
1085+
10661086 DTM_TRACE ((stderr , "Backend %d ends prepare of transactions %s with cid=%lu\n" , getpid (), gtid , cid ));
10671087 DtmLocalEndPrepare (gtid , cid );
10681088 PG_RETURN_VOID ();
0 commit comments