more code
This commit is contained in:
parent
f85ddb6633
commit
d48547ed64
|
@ -1639,6 +1639,7 @@ typedef struct {
|
|||
int32_t sqlLen;
|
||||
char* sql;
|
||||
SArray* vgroupIds;
|
||||
int8_t metaOnly;
|
||||
} SCompactDbReq;
|
||||
|
||||
int32_t tSerializeSCompactDbReq(void* buf, int32_t bufLen, SCompactDbReq* pReq);
|
||||
|
@ -2083,6 +2084,7 @@ typedef struct {
|
|||
int64_t compactStartTime;
|
||||
STimeWindow tw;
|
||||
int32_t compactId;
|
||||
int8_t metaOnly;
|
||||
} SCompactVnodeReq;
|
||||
|
||||
int32_t tSerializeSCompactVnodeReq(void* buf, int32_t bufLen, SCompactVnodeReq* pReq);
|
||||
|
|
|
@ -169,6 +169,7 @@ typedef struct SCompactDatabaseStmt {
|
|||
char dbName[TSDB_DB_NAME_LEN];
|
||||
SNode* pStart;
|
||||
SNode* pEnd;
|
||||
bool metaOnly;
|
||||
} SCompactDatabaseStmt;
|
||||
|
||||
typedef struct SCompactVgroupsStmt {
|
||||
|
@ -177,6 +178,7 @@ typedef struct SCompactVgroupsStmt {
|
|||
SNodeList* vgidList;
|
||||
SNode* pStart;
|
||||
SNode* pEnd;
|
||||
bool metaOnly;
|
||||
} SCompactVgroupsStmt;
|
||||
|
||||
typedef struct STableOptions {
|
||||
|
|
|
@ -4686,6 +4686,8 @@ int32_t tSerializeSCompactDbReq(void *buf, int32_t bufLen, SCompactDbReq *pReq)
|
|||
}
|
||||
}
|
||||
|
||||
TAOS_CHECK_EXIT(tEncodeI8(&encoder, pReq->metaOnly));
|
||||
|
||||
tEndEncode(&encoder);
|
||||
|
||||
_exit:
|
||||
|
@ -4729,6 +4731,12 @@ int32_t tDeserializeSCompactDbReq(void *buf, int32_t bufLen, SCompactDbReq *pReq
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!tDecodeIsEnd(&decoder)) {
|
||||
TAOS_CHECK_EXIT(tDecodeI8(&decoder, &pReq->metaOnly));
|
||||
} else {
|
||||
pReq->metaOnly = false;
|
||||
}
|
||||
tEndDecode(&decoder);
|
||||
|
||||
_exit:
|
||||
|
@ -7156,6 +7164,7 @@ int32_t tSerializeSCompactVnodeReq(void *buf, int32_t bufLen, SCompactVnodeReq *
|
|||
TAOS_CHECK_EXIT(tEncodeI64(&encoder, pReq->tw.ekey));
|
||||
|
||||
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pReq->compactId));
|
||||
TAOS_CHECK_EXIT(tEncodeI8(&encoder, pReq->metaOnly));
|
||||
|
||||
tEndEncode(&encoder);
|
||||
|
||||
|
@ -7193,6 +7202,12 @@ int32_t tDeserializeSCompactVnodeReq(void *buf, int32_t bufLen, SCompactVnodeReq
|
|||
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pReq->compactId));
|
||||
}
|
||||
|
||||
if (!tDecodeIsEnd(&decoder)) {
|
||||
TAOS_CHECK_EXIT(tDecodeI8(&decoder, &pReq->metaOnly));
|
||||
} else {
|
||||
pReq->metaOnly = false;
|
||||
}
|
||||
|
||||
tEndDecode(&decoder);
|
||||
_exit:
|
||||
tDecoderClear(&decoder);
|
||||
|
|
|
@ -927,7 +927,8 @@ static int32_t mndCompactDispatchAudit(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pD
|
|||
return 0;
|
||||
}
|
||||
|
||||
extern int32_t mndCompactDb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, STimeWindow tw, SArray *vgroupIds);
|
||||
extern int32_t mndCompactDb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, STimeWindow tw, SArray *vgroupIds,
|
||||
bool metaOnly);
|
||||
static int32_t mndCompactDispatch(SRpcMsg *pReq) {
|
||||
int32_t code = 0;
|
||||
SMnode *pMnode = pReq->info.node;
|
||||
|
@ -982,7 +983,7 @@ static int32_t mndCompactDispatch(SRpcMsg *pReq) {
|
|||
.skey = convertTimePrecision(curMs + compactStartTime * 60000LL, TSDB_TIME_PRECISION_MILLI, pDb->cfg.precision),
|
||||
.ekey = convertTimePrecision(curMs + compactEndTime * 60000LL, TSDB_TIME_PRECISION_MILLI, pDb->cfg.precision)};
|
||||
|
||||
if ((code = mndCompactDb(pMnode, NULL, pDb, tw, NULL)) == 0) {
|
||||
if ((code = mndCompactDb(pMnode, NULL, pDb, tw, NULL, false)) == 0) {
|
||||
mInfo("db:%p,%s, succeed to dispatch compact with range:[%" PRIi64 ",%" PRIi64 "], interval:%dm, start:%" PRIi64
|
||||
"m, end:%" PRIi64 "m, offset:%" PRIi8 "h",
|
||||
pDb, pDb->name, tw.skey, tw.ekey, pDb->cfg.compactInterval, compactStartTime, compactEndTime,
|
||||
|
|
|
@ -202,9 +202,9 @@ SNode* createAlterDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName, SNode*
|
|||
SNode* createFlushDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName);
|
||||
SNode* createTrimDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName, int32_t maxSpeed);
|
||||
SNode* createS3MigrateDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName);
|
||||
SNode* createCompactStmt(SAstCreateContext* pCxt, SToken* pDbName, SNode* pStart, SNode* pEnd);
|
||||
SNode* createCompactStmt(SAstCreateContext* pCxt, SToken* pDbName, SNode* pStart, SNode* pEnd, bool metaOnly);
|
||||
SNode* createCompactVgroupsStmt(SAstCreateContext* pCxt, SNode* pDbName, SNodeList* vgidList, SNode* pStart,
|
||||
SNode* pEnd);
|
||||
SNode* pEnd, bool metaOnly);
|
||||
SNode* createDefaultTableOptions(SAstCreateContext* pCxt);
|
||||
SNode* createAlterTableOptions(SAstCreateContext* pCxt);
|
||||
SNode* setTableOption(SAstCreateContext* pCxt, SNode* pOptions, ETableOptionType type, void* pVal);
|
||||
|
|
|
@ -238,8 +238,13 @@ cmd ::= ALTER DATABASE db_name(A) alter_db_options(B).
|
|||
cmd ::= FLUSH DATABASE db_name(A). { pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &A); }
|
||||
cmd ::= TRIM DATABASE db_name(A) speed_opt(B). { pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &A, B); }
|
||||
cmd ::= S3MIGRATE DATABASE db_name(A). { pCxt->pRootNode = createS3MigrateDatabaseStmt(pCxt, &A); }
|
||||
cmd ::= COMPACT DATABASE db_name(A) start_opt(B) end_opt(C). { pCxt->pRootNode = createCompactStmt(pCxt, &A, B, C); }
|
||||
cmd ::= COMPACT db_name_cond_opt(A) VGROUPS IN NK_LP integer_list(B) NK_RP start_opt(C) end_opt(D). { pCxt->pRootNode = createCompactVgroupsStmt(pCxt, A, B, C, D); }
|
||||
cmd ::= COMPACT DATABASE db_name(A) start_opt(B) end_opt(C) meta_only(D). { pCxt->pRootNode = createCompactStmt(pCxt, &A, B, C, D); }
|
||||
cmd ::= COMPACT db_name_cond_opt(A) VGROUPS IN NK_LP integer_list(B) NK_RP start_opt(C) end_opt(D) meta_only(E). { pCxt->pRootNode = createCompactVgroupsStmt(pCxt, A, B, C, D, E); }
|
||||
|
||||
%type meta_only { bool }
|
||||
%destructor meta_only { }
|
||||
meta_only(A) ::= . { A = false; }
|
||||
exists_opt(A) ::= META_ONLY. { A = true; }
|
||||
|
||||
%type not_exists_opt { bool }
|
||||
%destructor not_exists_opt { }
|
||||
|
|
|
@ -2212,7 +2212,7 @@ _err:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
SNode* createCompactStmt(SAstCreateContext* pCxt, SToken* pDbName, SNode* pStart, SNode* pEnd) {
|
||||
SNode* createCompactStmt(SAstCreateContext* pCxt, SToken* pDbName, SNode* pStart, SNode* pEnd, bool metaOnly) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
CHECK_NAME(checkDbName(pCxt, pDbName, false));
|
||||
SCompactDatabaseStmt* pStmt = NULL;
|
||||
|
@ -2221,6 +2221,7 @@ SNode* createCompactStmt(SAstCreateContext* pCxt, SToken* pDbName, SNode* pStart
|
|||
COPY_STRING_FORM_ID_TOKEN(pStmt->dbName, pDbName);
|
||||
pStmt->pStart = pStart;
|
||||
pStmt->pEnd = pEnd;
|
||||
pStmt->metaOnly = metaOnly;
|
||||
return (SNode*)pStmt;
|
||||
_err:
|
||||
nodesDestroyNode(pStart);
|
||||
|
@ -2229,7 +2230,7 @@ _err:
|
|||
}
|
||||
|
||||
SNode* createCompactVgroupsStmt(SAstCreateContext* pCxt, SNode* pDbName, SNodeList* vgidList, SNode* pStart,
|
||||
SNode* pEnd) {
|
||||
SNode* pEnd, bool metaOnly) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
if (NULL == pDbName) {
|
||||
snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen, "database not specified");
|
||||
|
@ -2243,6 +2244,7 @@ SNode* createCompactVgroupsStmt(SAstCreateContext* pCxt, SNode* pDbName, SNodeLi
|
|||
pStmt->vgidList = vgidList;
|
||||
pStmt->pStart = pStart;
|
||||
pStmt->pEnd = pEnd;
|
||||
pStmt->metaOnly = metaOnly;
|
||||
return (SNode*)pStmt;
|
||||
_err:
|
||||
nodesDestroyNode(pDbName);
|
||||
|
|
|
@ -360,7 +360,8 @@ static SKeyword keywordTable[] = {
|
|||
{"ON_FAILURE", TK_ON_FAILURE},
|
||||
{"NOTIFY_HISTORY", TK_NOTIFY_HISTORY},
|
||||
{"REGEXP", TK_REGEXP},
|
||||
{"TRUE_FOR", TK_TRUE_FOR}
|
||||
{"TRUE_FOR", TK_TRUE_FOR},
|
||||
{"META_ONLY", TK_META_ONLY}
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
|
|
|
@ -11315,9 +11315,11 @@ static int32_t translateCompactRange(STranslateContext* pCxt, const char* dbName
|
|||
}
|
||||
|
||||
static int32_t translateCompactDb(STranslateContext* pCxt, SCompactDatabaseStmt* pStmt) {
|
||||
SCompactDbReq compactReq = {0};
|
||||
SName name;
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
SCompactDbReq compactReq = {
|
||||
.metaOnly = pStmt->metaOnly,
|
||||
};
|
||||
SName name;
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
code = tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName));
|
||||
if (TSDB_CODE_SUCCESS != code) return code;
|
||||
|
||||
|
@ -11384,7 +11386,9 @@ static int32_t translateVgroupList(STranslateContext* pCxt, SNodeList* vgroupLis
|
|||
static int32_t translateCompactVgroups(STranslateContext* pCxt, SCompactVgroupsStmt* pStmt) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
SName name;
|
||||
SCompactDbReq req = {0};
|
||||
SCompactDbReq req = {
|
||||
.metaOnly = pStmt->metaOnly,
|
||||
};
|
||||
|
||||
code = tNameSetDbName(&name, pCxt->pParseCxt->acctId, ((SValueNode*)pStmt->pDbName)->literal,
|
||||
strlen(((SValueNode*)pStmt->pDbName)->literal));
|
||||
|
|
Loading…
Reference in New Issue