feat: alter database stt_trigger/minrows
This commit is contained in:
parent
afd01bb9b6
commit
e5de317f44
|
@ -845,6 +845,7 @@ typedef struct {
|
|||
int8_t cacheLast;
|
||||
int8_t replications;
|
||||
int32_t sstTrigger;
|
||||
int32_t minRows;
|
||||
} SAlterDbReq;
|
||||
|
||||
int32_t tSerializeSAlterDbReq(void* buf, int32_t bufLen, SAlterDbReq* pReq);
|
||||
|
|
|
@ -2219,6 +2219,7 @@ int32_t tSerializeSAlterDbReq(void *buf, int32_t bufLen, SAlterDbReq *pReq) {
|
|||
if (tEncodeI8(&encoder, pReq->cacheLast) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->replications) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->sstTrigger) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->minRows) < 0) return -1;
|
||||
tEndEncode(&encoder);
|
||||
|
||||
int32_t tlen = encoder.pos;
|
||||
|
@ -2246,6 +2247,9 @@ int32_t tDeserializeSAlterDbReq(void *buf, int32_t bufLen, SAlterDbReq *pReq) {
|
|||
if (tDecodeI8(&decoder, &pReq->cacheLast) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->replications) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->sstTrigger) < 0) return -1;
|
||||
if (!tDecodeIsEnd(&decoder)) {
|
||||
if (tDecodeI32(&decoder, &pReq->minRows) < 0) return -1;
|
||||
}
|
||||
tEndDecode(&decoder);
|
||||
|
||||
tDecoderClear(&decoder);
|
||||
|
|
|
@ -725,6 +725,18 @@ static int32_t mndSetDbCfgFromAlterDbReq(SDbObj *pDb, SAlterDbReq *pAlter) {
|
|||
terrno = 0;
|
||||
}
|
||||
|
||||
if (pAlter->sstTrigger > 0 && pAlter->sstTrigger != pDb->cfg.sstTrigger) {
|
||||
pDb->cfg.sstTrigger = pAlter->sstTrigger;
|
||||
pDb->vgVersion++;
|
||||
terrno = 0;
|
||||
}
|
||||
|
||||
if (pAlter->minRows > 0 && pAlter->minRows != pDb->cfg.minRows) {
|
||||
pDb->cfg.minRows = pAlter->minRows;
|
||||
pDb->vgVersion++;
|
||||
terrno = 0;
|
||||
}
|
||||
|
||||
return terrno;
|
||||
}
|
||||
|
||||
|
|
|
@ -236,6 +236,7 @@ alter_db_option(A) ::= REPLICA NK_INTEGER(B).
|
|||
//alter_db_option(A) ::= STRICT NK_STRING(B). { A.type = DB_OPTION_STRICT; A.val = B; }
|
||||
alter_db_option(A) ::= WAL_LEVEL NK_INTEGER(B). { A.type = DB_OPTION_WAL; A.val = B; }
|
||||
alter_db_option(A) ::= STT_TRIGGER NK_INTEGER(B). { A.type = DB_OPTION_STT_TRIGGER; A.val = B; }
|
||||
alter_db_option(A) ::= MINROWS NK_INTEGER(B). { A.type = DB_OPTION_MINROWS; A.val = B; }
|
||||
|
||||
%type integer_list { SNodeList* }
|
||||
%destructor integer_list { nodesDestroyList($$); }
|
||||
|
|
|
@ -2501,8 +2501,7 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) {
|
|||
code = translateSubquery(pCxt, pTempTable->pSubquery);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
if (QUERY_NODE_SELECT_STMT == nodeType(pTempTable->pSubquery) &&
|
||||
((SSelectStmt*)pTempTable->pSubquery)->isEmptyResult &&
|
||||
isSelectStmt(pCxt->pCurrStmt)) {
|
||||
((SSelectStmt*)pTempTable->pSubquery)->isEmptyResult && isSelectStmt(pCxt->pCurrStmt)) {
|
||||
((SSelectStmt*)pCxt->pCurrStmt)->isEmptyResult = true;
|
||||
}
|
||||
|
||||
|
@ -4254,6 +4253,7 @@ static void buildAlterDbReq(STranslateContext* pCxt, SAlterDatabaseStmt* pStmt,
|
|||
pReq->cacheLastSize = pStmt->pOptions->cacheLastSize;
|
||||
pReq->replications = pStmt->pOptions->replica;
|
||||
pReq->sstTrigger = pStmt->pOptions->sstTrigger;
|
||||
pReq->minRows = pStmt->pOptions->minRowsPerBlock;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -108,6 +108,7 @@ TEST_F(ParserInitialATest, alterDnode) {
|
|||
* | REPLICA int_value -- todo: enum 1, 3, default 1, unit replica
|
||||
* | WAL_LEVEL int_value -- enum 1, 2, default 1
|
||||
* | STT_TRIGGER int_value -- rang [1, 16], default 8
|
||||
* | MINROWS int_value -- rang [10, 1000], default 100
|
||||
* }
|
||||
*/
|
||||
TEST_F(ParserInitialATest, alterDatabase) {
|
||||
|
@ -133,6 +134,7 @@ TEST_F(ParserInitialATest, alterDatabase) {
|
|||
expect.cacheLastSize = -1;
|
||||
expect.replications = -1;
|
||||
expect.sstTrigger = -1;
|
||||
expect.minRows = -1;
|
||||
};
|
||||
auto setAlterDbBuffer = [&](int32_t buffer) { expect.buffer = buffer; };
|
||||
auto setAlterDbPageSize = [&](int32_t pageSize) { expect.pageSize = pageSize; };
|
||||
|
@ -150,6 +152,7 @@ TEST_F(ParserInitialATest, alterDatabase) {
|
|||
auto setAlterDbCacheModel = [&](int8_t cacheModel) { expect.cacheLast = cacheModel; };
|
||||
auto setAlterDbReplica = [&](int8_t replications) { expect.replications = replications; };
|
||||
auto setAlterDbSttTrigger = [&](int8_t sstTrigger) { expect.sstTrigger = sstTrigger; };
|
||||
auto setAlterDbMinRows = [&](int32_t minRows) { expect.minRows = minRows; };
|
||||
|
||||
setCheckDdlFunc([&](const SQuery* pQuery, ParserStage stage) {
|
||||
ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_ALTER_DATABASE_STMT);
|
||||
|
@ -170,6 +173,7 @@ TEST_F(ParserInitialATest, alterDatabase) {
|
|||
ASSERT_EQ(req.cacheLast, expect.cacheLast);
|
||||
ASSERT_EQ(req.replications, expect.replications);
|
||||
ASSERT_EQ(req.sstTrigger, expect.sstTrigger);
|
||||
ASSERT_EQ(req.minRows, expect.minRows);
|
||||
});
|
||||
|
||||
const int32_t MINUTE_PER_DAY = MILLISECOND_PER_DAY / MILLISECOND_PER_MINUTE;
|
||||
|
@ -277,6 +281,15 @@ TEST_F(ParserInitialATest, alterDatabase) {
|
|||
setAlterDbSttTrigger(16);
|
||||
run("ALTER DATABASE test STT_TRIGGER 16");
|
||||
clearAlterDbReq();
|
||||
|
||||
initAlterDb("test");
|
||||
setAlterDbMinRows(10);
|
||||
run("ALTER DATABASE test MINROWS 10");
|
||||
setAlterDbMinRows(50);
|
||||
run("ALTER DATABASE test MINROWS 50");
|
||||
setAlterDbMinRows(1000);
|
||||
run("ALTER DATABASE test MINROWS 1000");
|
||||
clearAlterDbReq();
|
||||
}
|
||||
|
||||
TEST_F(ParserInitialATest, alterDatabaseSemanticCheck) {
|
||||
|
|
Loading…
Reference in New Issue