@@ -179,8 +179,7 @@ static TransactionManager MtmTM = {
179
179
MtmGetTransactionStateSize ,
180
180
MtmSerializeTransactionState ,
181
181
MtmDeserializeTransactionState ,
182
- // MtmInitializeSequence
183
- PgInitializeSequence
182
+ MtmInitializeSequence
184
183
};
185
184
186
185
char const * const MtmNodeStatusMnem [] =
@@ -197,7 +196,6 @@ char const* const MtmNodeStatusMnem[] =
197
196
bool MtmDoReplication ;
198
197
char * MtmDatabaseName ;
199
198
char * MtmDatabaseUser ;
200
- char * MtmUtilityStmt = NULL ;
201
199
202
200
int MtmNodes ;
203
201
int MtmNodeId ;
@@ -213,6 +211,7 @@ int MtmHeartbeatSendTimeout;
213
211
int MtmHeartbeatRecvTimeout ;
214
212
bool MtmUseRaftable ;
215
213
bool MtmUseDtm ;
214
+ bool MtmVolksWagenMode ;
216
215
217
216
static char * MtmConnStrs ;
218
217
static int MtmQueueSize ;
@@ -235,9 +234,6 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
235
234
ProcessUtilityContext context , ParamListInfo params ,
236
235
DestReceiver * dest , char * completionTag );
237
236
238
- // static StringInfo MtmGUCBuffer;
239
- // static bool MtmGUCBufferAllocated = false;
240
-
241
237
/*
242
238
* -------------------------------------------
243
239
* Synchronize access to MTM structures.
@@ -370,8 +366,16 @@ MtmDeserializeTransactionState(void* ctx)
370
366
static void
371
367
MtmInitializeSequence (int64 * start , int64 * step )
372
368
{
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
+ }
375
379
}
376
380
377
381
@@ -704,10 +708,6 @@ static const char* const isoLevelStr[] =
704
708
static void
705
709
MtmBeginTransaction (MtmCurrentTrans * x )
706
710
{
707
- if (MtmUtilityStmt )
708
- pfree (MtmUtilityStmt );
709
- MtmUtilityStmt = NULL ;
710
-
711
711
if (x -> snapshot == INVALID_CSN ) {
712
712
TransactionId xmin = (Mtm -> gcCount >= MtmGcPeriod ) ? PgGetOldestXmin (NULL , false) : InvalidTransactionId ; /* Get oldest xmin outside critical section */
713
713
@@ -2218,6 +2218,19 @@ _PG_init(void)
2218
2218
NULL
2219
2219
);
2220
2220
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
+
2221
2234
DefineCustomIntVariable (
2222
2235
"multimaster.workers" ,
2223
2236
"Number of multimaster executor workers per node" ,
@@ -3128,13 +3141,6 @@ static void MtmBroadcastUtilityStmt(char const* sql, bool ignoreError)
3128
3141
{
3129
3142
if (conns [i ])
3130
3143
{
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
- // }
3138
3144
if (!MtmRunUtilityStmt (conns [i ], "BEGIN TRANSACTION" , & utility_errmsg ) && !ignoreError )
3139
3145
{
3140
3146
errorMsg = "Failed to start transaction at node %d" ;
@@ -3188,38 +3194,6 @@ static void MtmBroadcastUtilityStmt(char const* sql, bool ignoreError)
3188
3194
}
3189
3195
}
3190
3196
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
-
3223
3197
/*
3224
3198
* Genenerate global transaction identifier for two-pahse commit.
3225
3199
* It should be unique for all nodes
@@ -3237,11 +3211,12 @@ static bool MtmTwoPhaseCommit(MtmCurrentTrans* x)
3237
3211
{
3238
3212
/*
3239
3213
* 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.
3242
3216
*/
3243
3217
x -> isDistributed = false;
3244
- x -> csn = NULL ;
3218
+ if (!MtmVolksWagenMode )
3219
+ elog (NOTICE , "MTM: Transaction was not replicated as it accesed temporary relation" );
3245
3220
return false;
3246
3221
}
3247
3222
@@ -3438,8 +3413,6 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
3438
3413
{
3439
3414
bool skipCommand = false;
3440
3415
3441
- // skipCommand = MyXactAccessedTempRel;
3442
-
3443
3416
MTM_LOG3 ("%d: Process utility statement %s" , MyProcPid , queryString );
3444
3417
switch (nodeTag (parsetree ))
3445
3418
{
@@ -3492,19 +3465,10 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
3492
3465
skipCommand = true;
3493
3466
break ;
3494
3467
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
-
3503
3468
/* Save GUC context for consequent DDL execution */
3504
3469
case T_DiscardStmt :
3505
3470
{
3506
3471
DiscardStmt * stmt = (DiscardStmt * ) parsetree ;
3507
- skipCommand = stmt -> target == DISCARD_TEMP ; // XXX
3508
3472
3509
3473
if (!IsTransactionBlock ())
3510
3474
{
0 commit comments