@@ -290,7 +290,7 @@ static ExecutorStart_hook_type PreviousExecutorStartHook;
290
290
static ExecutorFinish_hook_type PreviousExecutorFinishHook ;
291
291
static ProcessUtility_hook_type PreviousProcessUtilityHook ;
292
292
static shmem_startup_hook_type PreviousShmemStartupHook ;
293
- // static seq_nextval_hook_t PreviousSeqNextvalHook;
293
+ static seq_nextval_hook_t PreviousSeqNextvalHook ;
294
294
295
295
static void MtmExecutorStart (QueryDesc * queryDesc , int eflags );
296
296
static void MtmExecutorFinish (QueryDesc * queryDesc );
@@ -3390,8 +3390,8 @@ _PG_init(void)
3390
3390
PreviousProcessUtilityHook = ProcessUtility_hook ;
3391
3391
ProcessUtility_hook = MtmProcessUtility ;
3392
3392
3393
- // PreviousSeqNextvalHook = SeqNextvalHook;
3394
- // SeqNextvalHook = MtmSeqNextvalHook;
3393
+ PreviousSeqNextvalHook = SeqNextvalHook ;
3394
+ SeqNextvalHook = MtmSeqNextvalHook ;
3395
3395
}
3396
3396
3397
3397
/*
@@ -3403,7 +3403,7 @@ _PG_fini(void)
3403
3403
shmem_startup_hook = PreviousShmemStartupHook ;
3404
3404
ExecutorFinish_hook = PreviousExecutorFinishHook ;
3405
3405
ProcessUtility_hook = PreviousProcessUtilityHook ;
3406
- // SeqNextvalHook = PreviousSeqNextvalHook;
3406
+ SeqNextvalHook = PreviousSeqNextvalHook ;
3407
3407
}
3408
3408
3409
3409
@@ -5089,7 +5089,33 @@ static bool MtmFunctionProfileDependsOnTempTable(CreateFunctionStmt* func)
5089
5089
return false;
5090
5090
}
5091
5091
5092
+ static void
5093
+ AdjustCreateSequence (List * options )
5094
+ {
5095
+ bool has_increment = false, has_start = false;
5096
+ ListCell * option ;
5097
+
5098
+ foreach (option , options )
5099
+ {
5100
+ DefElem * defel = (DefElem * ) lfirst (option );
5101
+ if (strcmp (defel -> defname , "increment" ) == 0 )
5102
+ has_increment = true;
5103
+ else if (strcmp (defel -> defname , "start" ) == 0 )
5104
+ has_start = true;
5105
+ }
5092
5106
5107
+ if (!has_increment )
5108
+ {
5109
+ DefElem * defel = makeDefElem ("increment" , (Node * ) makeInteger (MtmMaxNodes ), -1 );
5110
+ options = lappend (options , defel );
5111
+ }
5112
+
5113
+ if (!has_start )
5114
+ {
5115
+ DefElem * defel = makeDefElem ("start" , (Node * ) makeInteger (MtmNodeId ), -1 );
5116
+ options = lappend (options , defel );
5117
+ }
5118
+ }
5093
5119
5094
5120
static void MtmProcessUtility (PlannedStmt * pstmt ,
5095
5121
const char * queryString , ProcessUtilityContext context ,
@@ -5162,6 +5188,13 @@ static void MtmProcessUtility(PlannedStmt *pstmt,
5162
5188
elog (ERROR , "Multimaster doesn't support creating and dropping databases" );
5163
5189
break ;
5164
5190
5191
+ case T_CreateSeqStmt :
5192
+ {
5193
+ CreateSeqStmt * stmt = (CreateSeqStmt * ) parsetree ;
5194
+ AdjustCreateSequence (stmt -> options );
5195
+ }
5196
+ break ;
5197
+
5165
5198
case T_CreateTableSpaceStmt :
5166
5199
case T_DropTableSpaceStmt :
5167
5200
{
0 commit comments