@@ -179,8 +179,7 @@ static TransactionManager MtmTM = {
179179 MtmGetTransactionStateSize ,
180180 MtmSerializeTransactionState ,
181181 MtmDeserializeTransactionState ,
182- // MtmInitializeSequence
183- PgInitializeSequence
182+ MtmInitializeSequence
184183};
185184
186185char const * const MtmNodeStatusMnem [] =
@@ -197,7 +196,6 @@ char const* const MtmNodeStatusMnem[] =
197196bool MtmDoReplication ;
198197char * MtmDatabaseName ;
199198char * MtmDatabaseUser ;
200- char * MtmUtilityStmt = NULL ;
201199
202200int MtmNodes ;
203201int MtmNodeId ;
@@ -213,6 +211,7 @@ int MtmHeartbeatSendTimeout;
213211int MtmHeartbeatRecvTimeout ;
214212bool MtmUseRaftable ;
215213bool MtmUseDtm ;
214+ bool MtmVolksWagenMode ;
216215
217216static char * MtmConnStrs ;
218217static int MtmQueueSize ;
@@ -235,9 +234,6 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
235234 ProcessUtilityContext context , ParamListInfo params ,
236235 DestReceiver * dest , char * completionTag );
237236
238- // static StringInfo MtmGUCBuffer;
239- // static bool MtmGUCBufferAllocated = false;
240-
241237/*
242238 * -------------------------------------------
243239 * Synchronize access to MTM structures.
@@ -370,8 +366,16 @@ MtmDeserializeTransactionState(void* ctx)
370366static void
371367MtmInitializeSequence (int64 * start , int64 * step )
372368{
373- * start = MtmNodeId ;
374- * step = MtmMaxNodes ;
369+ if (MtmVolksWagenMode )
370+ {
371+ * start = 1 ;
372+ * step = 1 ;
373+ }
374+ else
375+ {
376+ * start = MtmNodeId ;
377+ * step = MtmMaxNodes ;
378+ }
375379}
376380
377381
@@ -704,10 +708,6 @@ static const char* const isoLevelStr[] =
704708static void
705709MtmBeginTransaction (MtmCurrentTrans * x )
706710{
707- if (MtmUtilityStmt )
708- pfree (MtmUtilityStmt );
709- MtmUtilityStmt = NULL ;
710-
711711 if (x -> snapshot == INVALID_CSN ) {
712712 TransactionId xmin = (Mtm -> gcCount >= MtmGcPeriod ) ? PgGetOldestXmin (NULL , false) : InvalidTransactionId ; /* Get oldest xmin outside critical section */
713713
@@ -2218,6 +2218,19 @@ _PG_init(void)
22182218 NULL
22192219 );
22202220
2221+ DefineCustomBoolVariable (
2222+ "multimaster.volkswagen_mode" ,
2223+ "Pretend to be normal postgres. This means skip some NOTICE's and use local sequences. Default false." ,
2224+ NULL ,
2225+ & MtmVolksWagenMode ,
2226+ false,
2227+ PGC_BACKEND ,
2228+ 0 ,
2229+ NULL ,
2230+ NULL ,
2231+ NULL
2232+ );
2233+
22212234 DefineCustomIntVariable (
22222235 "multimaster.workers" ,
22232236 "Number of multimaster executor workers per node" ,
@@ -3128,13 +3141,6 @@ static void MtmBroadcastUtilityStmt(char const* sql, bool ignoreError)
31283141 {
31293142 if (conns [i ])
31303143 {
3131- // if (MtmGUCBufferAllocated && !MtmRunUtilityStmt(conns[i], MtmGUCBuffer->data, &utility_errmsg) && !ignoreError)
3132- // {
3133- // errorMsg = "Failed to set GUC variables at node %d";
3134- // elog(WARNING, "%s", utility_errmsg);
3135- // failedNode = i;
3136- // break;
3137- // }
31383144 if (!MtmRunUtilityStmt (conns [i ], "BEGIN TRANSACTION" , & utility_errmsg ) && !ignoreError )
31393145 {
31403146 errorMsg = "Failed to start transaction at node %d" ;
@@ -3188,38 +3194,6 @@ static void MtmBroadcastUtilityStmt(char const* sql, bool ignoreError)
31883194 }
31893195}
31903196
3191- // static void MtmGUCBufferAppend(const char *gucQueryString){
3192-
3193- // if (!MtmGUCBufferAllocated)
3194- // {
3195- // MemoryContext oldcontext;
3196- // oldcontext = MemoryContextSwitchTo(TopMemoryContext);
3197- // MtmGUCBuffer = makeStringInfo();
3198- // MemoryContextSwitchTo(oldcontext);
3199- // MtmGUCBufferAllocated = true;
3200- // appendStringInfoString(MtmGUCBuffer, "RESET SESSION AUTHORIZATION; reset all;");
3201- // }
3202-
3203- // appendStringInfoString(MtmGUCBuffer, gucQueryString);
3204- // /* sometimes there is no ';' char at the end. */
3205- // // appendStringInfoString(MtmGUCBuffer, ";");
3206- // }
3207-
3208- // static char * MtmGUCBufferGet(void){
3209- // if (!MtmGUCBufferAllocated)
3210- // MtmGUCBufferAppend("");
3211- // return MtmGUCBuffer->data;
3212- // }
3213-
3214- // static void MtmGUCBufferClear(void)
3215- // {
3216- // if (MtmGUCBufferAllocated)
3217- // {
3218- // resetStringInfo(MtmGUCBuffer);
3219- // MtmGUCBufferAppend("");
3220- // }
3221- // }
3222-
32233197/*
32243198 * Genenerate global transaction identifier for two-pahse commit.
32253199 * It should be unique for all nodes
@@ -3237,11 +3211,12 @@ static bool MtmTwoPhaseCommit(MtmCurrentTrans* x)
32373211 {
32383212 /*
32393213 * XXX: this tx anyway goes to subscribers later, but without
3240- * surrounding begin/commit. Probably there is more clever way
3241- * to do that.
3214+ * surrounding begin/commit. Now it will be filtered out on receiver side.
3215+ * Probably there is more clever way to do that.
32423216 */
32433217 x -> isDistributed = false;
3244- x -> csn = NULL ;
3218+ if (!MtmVolksWagenMode )
3219+ elog (NOTICE , "MTM: Transaction was not replicated as it accesed temporary relation" );
32453220 return false;
32463221 }
32473222
@@ -3438,8 +3413,6 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
34383413{
34393414 bool skipCommand = false;
34403415
3441- // skipCommand = MyXactAccessedTempRel;
3442-
34433416 MTM_LOG3 ("%d: Process utility statement %s" , MyProcPid , queryString );
34443417 switch (nodeTag (parsetree ))
34453418 {
@@ -3492,19 +3465,10 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
34923465 skipCommand = true;
34933466 break ;
34943467
3495- // /* Do not skip following unless temp object was accessed */
3496- // case T_CreateTableAsStmt:
3497- // case T_CreateStmt:
3498- // case T_ViewStmt:
3499- // case T_IndexStmt:
3500- // case T_DropStmt:
3501- // break;
3502-
35033468 /* Save GUC context for consequent DDL execution */
35043469 case T_DiscardStmt :
35053470 {
35063471 DiscardStmt * stmt = (DiscardStmt * ) parsetree ;
3507- skipCommand = stmt -> target == DISCARD_TEMP ; // XXX
35083472
35093473 if (!IsTransactionBlock ())
35103474 {
0 commit comments