fix translater rules for replica & wal level
This commit is contained in:
parent
4311309d51
commit
c13ba895ee
|
@ -6898,19 +6898,6 @@ static int32_t checkDbTbPrefixSuffixOptions(STranslateContext* pCxt, int32_t tbP
|
|||
}
|
||||
|
||||
static int32_t checkOptionsDependency(STranslateContext* pCxt, const char* pDbName, SDatabaseOptions* pOptions) {
|
||||
if (pOptions->replica > 1) {
|
||||
SDbCfgInfo dbCfg = {0};
|
||||
int32_t code = getDBCfg(pCxt, pDbName, &dbCfg);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
|
||||
if (pOptions->walLevel == 0 || dbCfg.walLevel == 0) {
|
||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_DB_OPTION,
|
||||
"Invalid option, wal_level 0 should be used with replica 1");
|
||||
}
|
||||
}
|
||||
|
||||
int32_t daysPerFile = pOptions->daysPerFile;
|
||||
int32_t s3KeepLocal = pOptions->s3KeepLocal;
|
||||
int64_t daysToKeep0 = pOptions->keep[0];
|
||||
|
@ -6939,6 +6926,11 @@ static int32_t checkOptionsDependency(STranslateContext* pCxt, const char* pDbNa
|
|||
"Invalid option, with_arbitrator should be used with replica 2");
|
||||
}
|
||||
|
||||
if (pOptions->replica > 1 && pOptions->walLevel == 0) {
|
||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_DB_OPTION,
|
||||
"Invalid option, wal_level 0 should be used with replica 1");
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -7284,6 +7276,15 @@ static int32_t translateAlterDatabase(STranslateContext* pCxt, SAlterDatabaseStm
|
|||
}
|
||||
}
|
||||
|
||||
if (pStmt->pOptions->replica > 1) {
|
||||
SDbCfgInfo dbCfg = {0};
|
||||
int32_t code = getDBCfg(pCxt, pStmt->dbName, &dbCfg);
|
||||
if (TSDB_CODE_SUCCESS == code && dbCfg.walLevel == 0) {
|
||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_DB_OPTION,
|
||||
"Invalid option, wal_level 0 should be used with replica 1");
|
||||
}
|
||||
}
|
||||
|
||||
int32_t code = checkDatabaseOptions(pCxt, pStmt->dbName, pStmt->pOptions);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
|
|
Loading…
Reference in New Issue