From af9fdcd29d51086823687771fd121d0c15b47197 Mon Sep 17 00:00:00 2001 From: factosea <285808407@qq.com> Date: Fri, 8 Mar 2024 11:23:11 +0800 Subject: [PATCH] create stable/table --- include/common/tcol.h | 1 + include/common/tmsg.h | 8 ++++++++ source/common/src/tcol.c | 15 +++++++++++---- source/common/src/tmsg.c | 3 +++ source/dnode/mnode/impl/src/mndStb.c | 4 ++++ source/libs/parser/src/parTranslater.c | 9 ++++++++- 6 files changed, 35 insertions(+), 5 deletions(-) diff --git a/include/common/tcol.h b/include/common/tcol.h index 5a5d9b09a6..4ca4629d8b 100644 --- a/include/common/tcol.h +++ b/include/common/tcol.h @@ -78,5 +78,6 @@ bool checkColumnLevel(uint8_t type, char level[TSDB_CL_COMPRESS_OPTION_LEN]); void setColEncode(uint32_t* compress, uint8_t encode); void setColCompress(uint32_t* compress, uint16_t compressType); void setColLevel(uint32_t* compress, uint8_t level); +void setColCompressByOption(uint32_t* compress, uint8_t encode, uint16_t compressType, uint8_t level); #endif /*_TD_TCOL_H_*/ diff --git a/include/common/tmsg.h b/include/common/tmsg.h index b1f2708fc2..cb91f0c991 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -675,8 +675,16 @@ static FORCE_INLINE SColCmprWrapper* tCloneSColCmprWrapper(const SColCmprWrapper return pDstWrapper; } +static FORCE_INLINE void tInitDefaultSColCmprWrapperByCols(SColCmprWrapper* pCmpr, int32_t nCols) { + assert(!pCmpr->pColCmpr); + pCmpr->pColCmpr = taosMemoryCalloc(nCols, sizeof(SColCmpr)); + pCmpr->nCols = nCols; +} + static FORCE_INLINE void tInitDefaultSColCmprWrapper(SColCmprWrapper* pCmpr, SSchemaWrapper* pSchema) { pCmpr->nCols = pSchema->nCols; + assert(!pCmpr->pColCmpr); + pCmpr->pColCmpr = taosMemoryCalloc(pCmpr->nCols, sizeof(SColCmpr)); for (int32_t i = 0; i < pCmpr->nCols; i++) { SColCmpr* pColCmpr = &pCmpr->pColCmpr[i]; SSchema* pColSchema = &pSchema->pSchema[i]; diff --git a/source/common/src/tcol.c b/source/common/src/tcol.c index 702c1a3efd..d34482c1c6 100644 --- a/source/common/src/tcol.c +++ b/source/common/src/tcol.c @@ -152,11 +152,11 @@ const char* columnCompressStr(uint16_t type) { uint8_t columnLevelVal(const char* level) { uint8_t l = TSDB_COLVAL_LEVEL_MEDIUM; - if (0 == strcmp(level, TSDB_COLUMN_LEVEL_HIGH)) { + if (0 == strcmp(level, "h") || 0 == strcmp(level, TSDB_COLUMN_LEVEL_HIGH)) { l = TSDB_COLVAL_LEVEL_HIGH; - } else if (0 == strcmp(level, TSDB_COLUMN_LEVEL_MEDIUM)) { + } else if (0 == strcmp(level, "m") || 0 == strcmp(level, TSDB_COLUMN_LEVEL_MEDIUM)) { l = TSDB_COLVAL_LEVEL_MEDIUM; - } else if (0 == strcmp(level, TSDB_COLUMN_LEVEL_LOW)) { + } else if (0 == strcmp(level, "l") || 0 == strcmp(level, TSDB_COLUMN_LEVEL_LOW)) { l = TSDB_COLVAL_LEVEL_LOW; } return l; @@ -228,7 +228,7 @@ bool checkColumnEncode(uint8_t type, char encode[TSDB_CL_COMPRESS_OPTION_LEN]) { } bool checkColumnCompress(uint8_t type, char compress[TSDB_CL_COMPRESS_OPTION_LEN]) { if (0 == strlen(compress)) { - strncpy(compress, getDefaultEncodeStr(type), TSDB_CL_COMPRESS_OPTION_LEN); + strncpy(compress, getDefaultCompressStr(type), TSDB_CL_COMPRESS_OPTION_LEN); return true; } strtolower(compress, compress); @@ -272,3 +272,10 @@ void setColLevel(uint32_t* compress, uint8_t level) { *compress |= level; return; } + +void setColCompressByOption(uint32_t* compress, uint8_t encode, uint16_t compressType, uint8_t level) { + setColEncode(compress, encode); + setColCompress(compress, compressType); + setColLevel(compress, level); + return; +} diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 31ddfe9539..22a54795ef 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -7722,6 +7722,9 @@ void tDestroySVCreateTbReq(SVCreateTbReq *pReq, int32_t flags) { } } + if (pReq->colCmpr.pColCmpr) taosMemoryFree(pReq->colCmpr.pColCmpr); + pReq->colCmpr.pColCmpr = NULL; + if (pReq->sql != NULL) { taosMemoryFree(pReq->sql); } diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index 2b68e9574d..ded759d9c3 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -1125,6 +1125,10 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) { goto _OVER; } + // todo xsdebug + terrno = TSDB_CODE_OPS_NOT_SUPPORT; + goto _OVER; + mInfo("stb:%s, start to create", createReq.name); if (mndCheckCreateStbReq(&createReq) != 0) { terrno = TSDB_CODE_INVALID_MSG; diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index f7bd643515..a5475f5d91 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -9870,8 +9870,15 @@ static int32_t buildNormalTableBatchReq(int32_t acctId, const SCreateTableStmt* } SNode* pCol; col_id_t index = 0; + tInitDefaultSColCmprWrapperByCols(&req.colCmpr, req.ntb.schemaRow.nCols); FOREACH(pCol, pStmt->pCols) { - toSchema((SColumnDefNode*)pCol, index + 1, req.ntb.schemaRow.pSchema + index); + SColumnDefNode* pColDef = (SColumnDefNode*)pCol; + toSchema(pColDef, index + 1, req.ntb.schemaRow.pSchema + index); + if (pColDef->pOptions) { + req.colCmpr.pColCmpr[index].id = index + 1; + setColCompressByOption(&req.colCmpr.pColCmpr[index].alg, columnEncodeVal(pColDef->pOptions->encode), + columnCompressVal(pColDef->pOptions->compress), columnLevelVal(pColDef->pOptions->compressLevel)); + } ++index; } pBatch->info = *pVgroupInfo;