refactor compress
This commit is contained in:
parent
92a7801d09
commit
f3feb9dabe
|
@ -89,7 +89,7 @@ bool checkColumnLevelOrSetDefault(uint8_t type, char level[TSDB_CL_COMPRESS_OPTI
|
|||
void setColEncode(uint32_t* compress, uint8_t encode);
|
||||
void setColCompress(uint32_t* compress, uint16_t compressType);
|
||||
void setColLevel(uint32_t* compress, uint8_t level);
|
||||
int8_t setColCompressByOption(uint8_t type, uint8_t encode, uint16_t compressType, uint8_t level, bool check,
|
||||
int32_t setColCompressByOption(uint8_t type, uint8_t encode, uint16_t compressType, uint8_t level, bool check,
|
||||
uint32_t* compress);
|
||||
|
||||
int8_t validColCompressLevel(uint8_t type, uint8_t level);
|
||||
|
|
|
@ -182,6 +182,8 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_TSC_STMT_CACHE_ERROR TAOS_DEF_ERROR_CODE(0, 0X0230)
|
||||
#define TSDB_CODE_TSC_ENCODE_PARAM_ERROR TAOS_DEF_ERROR_CODE(0, 0X0231)
|
||||
#define TSDB_CODE_TSC_ENCODE_PARAM_NULL TAOS_DEF_ERROR_CODE(0, 0X0232)
|
||||
#define TSDB_CODE_TSC_COMPRESS_PARAM_ERROR TAOS_DEF_ERROR_CODE(0, 0X0233)
|
||||
#define TSDB_CODE_TSC_COMPRESS_LEVEL_ERROR TAOS_DEF_ERROR_CODE(0, 0X0234)
|
||||
#define TSDB_CODE_TSC_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0X02FF)
|
||||
|
||||
// mnode-common
|
||||
|
|
|
@ -306,22 +306,22 @@ void setColLevel(uint32_t* compress, uint8_t level) {
|
|||
return;
|
||||
}
|
||||
|
||||
int8_t setColCompressByOption(uint8_t type, uint8_t encode, uint16_t compressType, uint8_t level, bool check,
|
||||
int32_t setColCompressByOption(uint8_t type, uint8_t encode, uint16_t compressType, uint8_t level, bool check,
|
||||
uint32_t* compress) {
|
||||
if (check && !validColEncode(type, encode)) return 0;
|
||||
if (check && !validColEncode(type, encode)) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
||||
setColEncode(compress, encode);
|
||||
|
||||
if (compressType == TSDB_COLVAL_COMPRESS_DISABLED) {
|
||||
setColCompress(compress, compressType);
|
||||
setColLevel(compress, TSDB_COLVAL_LEVEL_DISABLED);
|
||||
} else {
|
||||
if (check && !validColCompress(type, compressType)) return 0;
|
||||
if (check && !validColCompress(type, compressType)) return TSDB_CODE_TSC_COMPRESS_PARAM_ERROR;
|
||||
setColCompress(compress, compressType);
|
||||
|
||||
if (check && !validColCompressLevel(type, level)) return 0;
|
||||
if (check && !validColCompressLevel(type, level)) return TSDB_CODE_TSC_COMPRESS_LEVEL_ERROR;
|
||||
setColLevel(compress, level);
|
||||
}
|
||||
return 1;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
bool useCompress(uint8_t tableType) { return TSDB_SUPER_TABLE == tableType || TSDB_NORMAL_TABLE == tableType; }
|
||||
|
|
|
@ -18,10 +18,10 @@
|
|||
#include "commandInt.h"
|
||||
#include "scheduler.h"
|
||||
#include "systable.h"
|
||||
#include "taosdef.h"
|
||||
#include "tdatablock.h"
|
||||
#include "tglobal.h"
|
||||
#include "tgrant.h"
|
||||
#include "taosdef.h"
|
||||
|
||||
extern SConfig* tsCfg;
|
||||
|
||||
|
@ -126,6 +126,7 @@ static int32_t setDescResultIntoDataBlock(bool sysInfoUser, SSDataBlock* pBlock,
|
|||
pCol7 = taosArrayGet(pBlock->pDataBlock, 6);
|
||||
}
|
||||
|
||||
int32_t fillTagCol = 0;
|
||||
char buf[DESCRIBE_RESULT_FIELD_LEN] = {0};
|
||||
for (int32_t i = 0; i < numOfRows; ++i) {
|
||||
if (invisibleColumn(sysInfoUser, pMeta->tableType, pMeta->schema[i].flags)) {
|
||||
|
@ -140,6 +141,7 @@ static int32_t setDescResultIntoDataBlock(bool sysInfoUser, SSDataBlock* pBlock,
|
|||
if (TSDB_VIEW_TABLE != pMeta->tableType) {
|
||||
if (i >= pMeta->tableInfo.numOfColumns) {
|
||||
STR_TO_VARSTR(buf, "TAG");
|
||||
fillTagCol = 1;
|
||||
} else if (i == 1 && pMeta->schema[i].flags & COL_IS_KEY) {
|
||||
STR_TO_VARSTR(buf, "PRIMARY KEY")
|
||||
} else {
|
||||
|
@ -158,15 +160,17 @@ static int32_t setDescResultIntoDataBlock(bool sysInfoUser, SSDataBlock* pBlock,
|
|||
STR_TO_VARSTR(buf, columnLevelStr(COMPRESS_L2_TYPE_LEVEL_U32(pMeta->schemaExt[i].compress)));
|
||||
colDataSetVal(pCol7, pBlock->info.rows, buf, false);
|
||||
} else {
|
||||
STR_TO_VARSTR(buf, "");
|
||||
STR_TO_VARSTR(buf, fillTagCol == 0 ? "" : "disabled");
|
||||
colDataSetVal(pCol5, pBlock->info.rows, buf, false);
|
||||
STR_TO_VARSTR(buf, "");
|
||||
STR_TO_VARSTR(buf, fillTagCol == 0 ? "" : "disabled");
|
||||
colDataSetVal(pCol6, pBlock->info.rows, buf, false);
|
||||
STR_TO_VARSTR(buf, "");
|
||||
STR_TO_VARSTR(buf, fillTagCol == 0 ? "" : "disabled");
|
||||
colDataSetVal(pCol7, pBlock->info.rows, buf, false);
|
||||
}
|
||||
}
|
||||
|
||||
fillTagCol = 0;
|
||||
|
||||
++(pBlock->info.rows);
|
||||
}
|
||||
if (pMeta->tableType == TSDB_SUPER_TABLE && biMode != 0) {
|
||||
|
@ -367,17 +371,20 @@ static void setCreateDBResultIntoDataBlock(SSDataBlock* pBlock, char* dbName, ch
|
|||
if (IS_SYS_DBNAME(dbName)) {
|
||||
len += sprintf(buf2 + VARSTR_HEADER_SIZE, "CREATE DATABASE `%s`", dbName);
|
||||
} else {
|
||||
len += sprintf(
|
||||
buf2 + VARSTR_HEADER_SIZE,
|
||||
len += sprintf(buf2 + VARSTR_HEADER_SIZE,
|
||||
"CREATE DATABASE `%s` BUFFER %d CACHESIZE %d CACHEMODEL '%s' COMP %d DURATION %dm "
|
||||
"WAL_FSYNC_PERIOD %d MAXROWS %d MINROWS %d STT_TRIGGER %d KEEP %dm,%dm,%dm PAGES %d PAGESIZE %d PRECISION '%s' REPLICA %d "
|
||||
"WAL_FSYNC_PERIOD %d MAXROWS %d MINROWS %d STT_TRIGGER %d KEEP %dm,%dm,%dm PAGES %d PAGESIZE %d "
|
||||
"PRECISION '%s' REPLICA %d "
|
||||
"WAL_LEVEL %d VGROUPS %d SINGLE_STABLE %d TABLE_PREFIX %d TABLE_SUFFIX %d TSDB_PAGESIZE %d "
|
||||
"WAL_RETENTION_PERIOD %d WAL_RETENTION_SIZE %" PRId64 " KEEP_TIME_OFFSET %d ENCRYPT_ALGORITHM '%s' S3_CHUNKSIZE %d S3_KEEPLOCAL %dm S3_COMPACT %d",
|
||||
dbName, pCfg->buffer, pCfg->cacheSize, cacheModelStr(pCfg->cacheLast), pCfg->compression, pCfg->daysPerFile,
|
||||
pCfg->walFsyncPeriod, pCfg->maxRows, pCfg->minRows, pCfg->sstTrigger, pCfg->daysToKeep0, pCfg->daysToKeep1, pCfg->daysToKeep2,
|
||||
pCfg->pages, pCfg->pageSize, prec, pCfg->replications, pCfg->walLevel, pCfg->numOfVgroups,
|
||||
1 == pCfg->numOfStables, hashPrefix, pCfg->hashSuffix, pCfg->tsdbPageSize, pCfg->walRetentionPeriod, pCfg->walRetentionSize,
|
||||
pCfg->keepTimeOffset, encryptAlgorithmStr(pCfg->encryptAlgorithm), pCfg->s3ChunkSize, pCfg->s3KeepLocal, pCfg->s3Compact);
|
||||
"WAL_RETENTION_PERIOD %d WAL_RETENTION_SIZE %" PRId64
|
||||
" KEEP_TIME_OFFSET %d ENCRYPT_ALGORITHM '%s' S3_CHUNKSIZE %d S3_KEEPLOCAL %dm S3_COMPACT %d",
|
||||
dbName, pCfg->buffer, pCfg->cacheSize, cacheModelStr(pCfg->cacheLast), pCfg->compression,
|
||||
pCfg->daysPerFile, pCfg->walFsyncPeriod, pCfg->maxRows, pCfg->minRows, pCfg->sstTrigger,
|
||||
pCfg->daysToKeep0, pCfg->daysToKeep1, pCfg->daysToKeep2, pCfg->pages, pCfg->pageSize, prec,
|
||||
pCfg->replications, pCfg->walLevel, pCfg->numOfVgroups, 1 == pCfg->numOfStables, hashPrefix,
|
||||
pCfg->hashSuffix, pCfg->tsdbPageSize, pCfg->walRetentionPeriod, pCfg->walRetentionSize,
|
||||
pCfg->keepTimeOffset, encryptAlgorithmStr(pCfg->encryptAlgorithm), pCfg->s3ChunkSize,
|
||||
pCfg->s3KeepLocal, pCfg->s3Compact);
|
||||
|
||||
if (retentions) {
|
||||
len += sprintf(buf2 + VARSTR_HEADER_SIZE + len, " RETENTIONS %s", retentions);
|
||||
|
@ -391,7 +398,9 @@ static void setCreateDBResultIntoDataBlock(SSDataBlock* pBlock, char* dbName, ch
|
|||
colDataSetVal(pCol2, 0, buf2, false);
|
||||
}
|
||||
|
||||
#define CHECK_LEADER(n) (row[n] && (fields[n].type == TSDB_DATA_TYPE_VARCHAR && strncasecmp(row[n], "leader", varDataLen((char *)row[n] - VARSTR_HEADER_SIZE)) == 0))
|
||||
#define CHECK_LEADER(n) \
|
||||
(row[n] && (fields[n].type == TSDB_DATA_TYPE_VARCHAR && \
|
||||
strncasecmp(row[n], "leader", varDataLen((char*)row[n] - VARSTR_HEADER_SIZE)) == 0))
|
||||
// on this row, if have leader return true else return false
|
||||
bool existLeaderRole(TAOS_ROW row, TAOS_FIELD* fields, int nFields) {
|
||||
// vgroup_id | db_name | tables | v1_dnode | v1_status | v2_dnode | v2_status | v3_dnode | v3_status | v4_dnode |
|
||||
|
@ -548,23 +557,25 @@ static int32_t buildCreateViewResultDataBlock(SSDataBlock** pOutput) {
|
|||
return code;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void appendColumnFields(char* buf, int32_t* len, STableCfg* pCfg) {
|
||||
for (int32_t i = 0; i < pCfg->numOfColumns; ++i) {
|
||||
SSchema* pSchema = pCfg->pSchemas + i;
|
||||
char type[32 + 60]; // 60 byte for compress info
|
||||
sprintf(type, "%s", tDataTypes[pSchema->type].name);
|
||||
if (TSDB_DATA_TYPE_VARCHAR == pSchema->type || TSDB_DATA_TYPE_VARBINARY == pSchema->type || TSDB_DATA_TYPE_GEOMETRY == pSchema->type) {
|
||||
if (TSDB_DATA_TYPE_VARCHAR == pSchema->type || TSDB_DATA_TYPE_VARBINARY == pSchema->type ||
|
||||
TSDB_DATA_TYPE_GEOMETRY == pSchema->type) {
|
||||
sprintf(type + strlen(type), "(%d)", (int32_t)(pSchema->bytes - VARSTR_HEADER_SIZE));
|
||||
} else if (TSDB_DATA_TYPE_NCHAR == pSchema->type) {
|
||||
sprintf(type + strlen(type), "(%d)", (int32_t)((pSchema->bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE));
|
||||
}
|
||||
|
||||
if (useCompress(pCfg->tableType)) {
|
||||
sprintf(type + strlen(type), " ENCODE \'%s\'", columnEncodeStr(COMPRESS_L1_TYPE_U32(pCfg->pSchemaExt[i].compress)));
|
||||
sprintf(type + strlen(type), " COMPRESS \'%s\'", columnCompressStr(COMPRESS_L2_TYPE_U32(pCfg->pSchemaExt[i].compress)));
|
||||
sprintf(type + strlen(type), " LEVEL \'%s\'", columnLevelStr(COMPRESS_L2_TYPE_LEVEL_U32(pCfg->pSchemaExt[i].compress)));
|
||||
sprintf(type + strlen(type), " ENCODE \'%s\'",
|
||||
columnEncodeStr(COMPRESS_L1_TYPE_U32(pCfg->pSchemaExt[i].compress)));
|
||||
sprintf(type + strlen(type), " COMPRESS \'%s\'",
|
||||
columnCompressStr(COMPRESS_L2_TYPE_U32(pCfg->pSchemaExt[i].compress)));
|
||||
sprintf(type + strlen(type), " LEVEL \'%s\'",
|
||||
columnLevelStr(COMPRESS_L2_TYPE_LEVEL_U32(pCfg->pSchemaExt[i].compress)));
|
||||
}
|
||||
if (!(pSchema->flags & COL_IS_KEY)) {
|
||||
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "%s`%s` %s", ((i > 0) ? ", " : ""), pSchema->name, type);
|
||||
|
@ -580,7 +591,8 @@ void appendTagFields(char* buf, int32_t* len, STableCfg* pCfg) {
|
|||
SSchema* pSchema = pCfg->pSchemas + pCfg->numOfColumns + i;
|
||||
char type[32];
|
||||
sprintf(type, "%s", tDataTypes[pSchema->type].name);
|
||||
if (TSDB_DATA_TYPE_VARCHAR == pSchema->type || TSDB_DATA_TYPE_VARBINARY == pSchema->type || TSDB_DATA_TYPE_GEOMETRY == pSchema->type) {
|
||||
if (TSDB_DATA_TYPE_VARCHAR == pSchema->type || TSDB_DATA_TYPE_VARBINARY == pSchema->type ||
|
||||
TSDB_DATA_TYPE_GEOMETRY == pSchema->type) {
|
||||
sprintf(type + strlen(type), "(%d)", (int32_t)(pSchema->bytes - VARSTR_HEADER_SIZE));
|
||||
} else if (TSDB_DATA_TYPE_NCHAR == pSchema->type) {
|
||||
sprintf(type + strlen(type), "(%d)", (int32_t)((pSchema->bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE));
|
||||
|
@ -823,7 +835,8 @@ static int32_t setCreateViewResultIntoDataBlock(SSDataBlock* pBlock, SShowCreate
|
|||
|
||||
SViewMeta* pMeta = pStmt->pViewMeta;
|
||||
ASSERT(pMeta);
|
||||
snprintf(varDataVal(buf2), SHOW_CREATE_VIEW_RESULT_FIELD2_LEN - VARSTR_HEADER_SIZE, "CREATE VIEW `%s`.`%s` AS %s", pStmt->dbName, pStmt->viewName, pMeta->querySql);
|
||||
snprintf(varDataVal(buf2), SHOW_CREATE_VIEW_RESULT_FIELD2_LEN - VARSTR_HEADER_SIZE, "CREATE VIEW `%s`.`%s` AS %s",
|
||||
pStmt->dbName, pStmt->viewName, pMeta->querySql);
|
||||
int32_t len = strlen(varDataVal(buf2));
|
||||
varDataLen(buf2) = (len > 65535) ? 65535 : len;
|
||||
colDataSetVal(pCol2, 0, buf2, false);
|
||||
|
@ -833,7 +846,6 @@ static int32_t setCreateViewResultIntoDataBlock(SSDataBlock* pBlock, SShowCreate
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static int32_t execShowCreateTable(SShowCreateTableStmt* pStmt, SRetrieveTableRsp** pRsp) {
|
||||
SSDataBlock* pBlock = NULL;
|
||||
int32_t code = buildCreateTbResultDataBlock(&pBlock);
|
||||
|
|
|
@ -745,7 +745,6 @@ SNode* createTimeOffsetValueNode(SAstCreateContext* pCxt, const SToken* pLiteral
|
|||
return (SNode*)val;
|
||||
}
|
||||
|
||||
|
||||
SNode* createDefaultDatabaseCondValue(SAstCreateContext* pCxt) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
if (NULL == pCxt->pQueryCxt->db) {
|
||||
|
@ -965,7 +964,8 @@ SNode* createTempTableNode(SAstCreateContext* pCxt, SNode* pSubquery, const STok
|
|||
return (SNode*)tempTable;
|
||||
}
|
||||
|
||||
SNode* createJoinTableNode(SAstCreateContext* pCxt, EJoinType type, EJoinSubType stype, SNode* pLeft, SNode* pRight, SNode* pJoinCond) {
|
||||
SNode* createJoinTableNode(SAstCreateContext* pCxt, EJoinType type, EJoinSubType stype, SNode* pLeft, SNode* pRight,
|
||||
SNode* pJoinCond) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
SJoinTableNode* joinTable = (SJoinTableNode*)nodesMakeNode(QUERY_NODE_JOIN_TABLE);
|
||||
CHECK_OUT_OF_MEM(joinTable);
|
||||
|
@ -1264,7 +1264,6 @@ SNode* addFillClause(SAstCreateContext* pCxt, SNode* pStmt, SNode* pFill) {
|
|||
return pStmt;
|
||||
}
|
||||
|
||||
|
||||
SNode* addJLimitClause(SAstCreateContext* pCxt, SNode* pJoin, SNode* pJLimit) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
if (NULL == pJLimit) {
|
||||
|
@ -1276,7 +1275,6 @@ SNode* addJLimitClause(SAstCreateContext* pCxt, SNode* pJoin, SNode* pJLimit) {
|
|||
return pJoin;
|
||||
}
|
||||
|
||||
|
||||
SNode* addWindowOffsetClause(SAstCreateContext* pCxt, SNode* pJoin, SNode* pWinOffset) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
if (NULL == pWinOffset) {
|
||||
|
@ -1288,7 +1286,6 @@ SNode* addWindowOffsetClause(SAstCreateContext* pCxt, SNode* pJoin, SNode* pWinO
|
|||
return pJoin;
|
||||
}
|
||||
|
||||
|
||||
SNode* createSelectStmt(SAstCreateContext* pCxt, bool isDistinct, SNodeList* pProjectionList, SNode* pTable,
|
||||
SNodeList* pHint) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
|
@ -1744,14 +1741,14 @@ SNode* setColumnOptions(SAstCreateContext* pCxt, SNode* pOptions, EColumnOptionT
|
|||
memset(((SColumnOptions*)pOptions)->compress, 0, TSDB_CL_COMPRESS_OPTION_LEN);
|
||||
COPY_STRING_FORM_STR_TOKEN(((SColumnOptions*)pOptions)->compress, (SToken*)pVal);
|
||||
if (0 == strlen(((SColumnOptions*)pOptions)->compress)) {
|
||||
pCxt->errCode = TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
||||
pCxt->errCode = TSDB_CODE_TSC_COMPRESS_PARAM_ERROR;
|
||||
}
|
||||
break;
|
||||
case COLUMN_OPTION_LEVEL:
|
||||
memset(((SColumnOptions*)pOptions)->compressLevel, 0, TSDB_CL_COMPRESS_OPTION_LEN);
|
||||
COPY_STRING_FORM_STR_TOKEN(((SColumnOptions*)pOptions)->compressLevel, (SToken*)pVal);
|
||||
if (0 == strlen(((SColumnOptions*)pOptions)->compressLevel)) {
|
||||
pCxt->errCode = TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
||||
pCxt->errCode = TSDB_CODE_TSC_COMPRESS_LEVEL_ERROR;
|
||||
}
|
||||
break;
|
||||
case COLUMN_OPTION_PRIMARYKEY:
|
||||
|
@ -1789,7 +1786,7 @@ SDataType createDataType(uint8_t type) {
|
|||
SDataType createVarLenDataType(uint8_t type, const SToken* pLen) {
|
||||
int32_t len = TSDB_MAX_BINARY_LEN - VARSTR_HEADER_SIZE;
|
||||
if (type == TSDB_DATA_TYPE_NCHAR) len /= TSDB_NCHAR_SIZE;
|
||||
if(pLen) len = taosStr2Int32(pLen->z, NULL, 10);
|
||||
if (pLen) len = taosStr2Int32(pLen->z, NULL, 10);
|
||||
SDataType dt = {.type = type, .precision = 0, .scale = 0, .bytes = len};
|
||||
return dt;
|
||||
}
|
||||
|
@ -1895,8 +1892,8 @@ SNode* createAlterTableAddModifyCol(SAstCreateContext* pCxt, SNode* pRealTable,
|
|||
return createAlterTableStmtFinalize(pRealTable, pStmt);
|
||||
}
|
||||
|
||||
SNode* createAlterTableAddModifyColOptions(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType, SToken* pColName,
|
||||
SNode* pOptions) {
|
||||
SNode* createAlterTableAddModifyColOptions(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType,
|
||||
SToken* pColName, SNode* pOptions) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
if (!checkColumnName(pCxt, pColName)) {
|
||||
return NULL;
|
||||
|
@ -2965,7 +2962,7 @@ SNode* createTSMAOptions(SAstCreateContext* pCxt, SNodeList* pFuncs) {
|
|||
CHECK_PARSER_STATUS(pCxt);
|
||||
STSMAOptions* pOptions = (STSMAOptions*)nodesMakeNode(QUERY_NODE_TSMA_OPTIONS);
|
||||
if (!pOptions) {
|
||||
//nodesDestroyList(pTSMAFuncs);
|
||||
// nodesDestroyList(pTSMAFuncs);
|
||||
pCxt->errCode = TSDB_CODE_OUT_OF_MEMORY;
|
||||
snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen, "Out of memory");
|
||||
return NULL;
|
||||
|
|
|
@ -5714,7 +5714,7 @@ static int32_t setEqualTbnameTableVgroups(STranslateContext* pCxt, SSelectStmt*
|
|||
|
||||
for (int32_t i = 0; i < pInfo->pRealTable->pTsmas->size; ++i) {
|
||||
STableTSMAInfo* pTsma = taosArrayGetP(pInfo->pRealTable->pTsmas, i);
|
||||
SArray *pTbNames = taosArrayInit(pInfo->aTbnames->size, POINTER_BYTES);
|
||||
SArray* pTbNames = taosArrayInit(pInfo->aTbnames->size, POINTER_BYTES);
|
||||
if (!pTbNames) return TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
||||
for (int32_t k = 0; k < pInfo->aTbnames->size; ++k) {
|
||||
|
@ -7225,9 +7225,9 @@ static int32_t checkColumnOptions(SNodeList* pList) {
|
|||
if (!checkColumnEncodeOrSetDefault(pCol->dataType.type, ((SColumnOptions*)pCol->pOptions)->encode))
|
||||
return TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
||||
if (!checkColumnCompressOrSetDefault(pCol->dataType.type, ((SColumnOptions*)pCol->pOptions)->compress))
|
||||
return TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
||||
return TSDB_CODE_TSC_COMPRESS_PARAM_ERROR;
|
||||
if (!checkColumnLevelOrSetDefault(pCol->dataType.type, ((SColumnOptions*)pCol->pOptions)->compressLevel))
|
||||
return TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
||||
return TSDB_CODE_TSC_COMPRESS_LEVEL_ERROR;
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -7742,7 +7742,7 @@ static int32_t addWdurationToSampleProjects(SNodeList* pProjectionList) {
|
|||
return nodesListAppend(pProjectionList, (SNode*)pFunc);
|
||||
}
|
||||
|
||||
static int32_t buildProjectsForSampleAst(SSampleAstInfo* pInfo, SNodeList** pList, int32_t *pProjectionTotalLen) {
|
||||
static int32_t buildProjectsForSampleAst(SSampleAstInfo* pInfo, SNodeList** pList, int32_t* pProjectionTotalLen) {
|
||||
SNodeList* pProjectionList = pInfo->pFuncs;
|
||||
pInfo->pFuncs = NULL;
|
||||
|
||||
|
@ -8118,13 +8118,15 @@ static int32_t buildAlterSuperTableReq(STranslateContext* pCxt, SAlterTableStmt*
|
|||
TAOS_FIELD field = {0};
|
||||
strcpy(field.name, pStmt->colName);
|
||||
if (!checkColumnEncode(pStmt->pColOptions->encode)) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
||||
if (!checkColumnCompress(pStmt->pColOptions->compress)) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
||||
if (!checkColumnLevel(pStmt->pColOptions->compressLevel)) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
||||
int8_t valid =
|
||||
if (!checkColumnCompress(pStmt->pColOptions->compress)) return TSDB_CODE_TSC_COMPRESS_PARAM_ERROR;
|
||||
if (!checkColumnLevel(pStmt->pColOptions->compressLevel)) return TSDB_CODE_TSC_COMPRESS_LEVEL_ERROR;
|
||||
int32_t code =
|
||||
setColCompressByOption(pStmt->dataType.type, columnEncodeVal(pStmt->pColOptions->encode),
|
||||
columnCompressVal(pStmt->pColOptions->compress),
|
||||
columnLevelVal(pStmt->pColOptions->compressLevel), false, (uint32_t*)&field.bytes);
|
||||
if (!valid) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
taosArrayPush(pAlterReq->pFields, &field);
|
||||
break;
|
||||
}
|
||||
|
@ -10726,7 +10728,8 @@ static int32_t deduplicateTsmaFuncs(SNodeList* pFuncs) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t buildTSMAAstStreamSubTable(SCreateTSMAStmt* pStmt, SMCreateSmaReq* pReq, const SNode* pTbname, SNode** pSubTable) {
|
||||
static int32_t buildTSMAAstStreamSubTable(SCreateTSMAStmt* pStmt, SMCreateSmaReq* pReq, const SNode* pTbname,
|
||||
SNode** pSubTable) {
|
||||
int32_t code = 0;
|
||||
SFunctionNode* pMd5Func = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||
SFunctionNode* pConcatFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||
|
@ -10768,8 +10771,8 @@ _end:
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t buildTSMAAst(STranslateContext* pCxt, SCreateTSMAStmt* pStmt, SMCreateSmaReq* pReq,
|
||||
const char* tbName, int32_t numOfTags, const SSchema* pTags) {
|
||||
static int32_t buildTSMAAst(STranslateContext* pCxt, SCreateTSMAStmt* pStmt, SMCreateSmaReq* pReq, const char* tbName,
|
||||
int32_t numOfTags, const SSchema* pTags) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
SSampleAstInfo info = {0};
|
||||
info.createSmaIndex = true;
|
||||
|
@ -10813,16 +10816,17 @@ static int32_t buildTSMAAst(STranslateContext* pCxt, SCreateTSMAStmt* pStmt, SMC
|
|||
if (!pTagCol) code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
if (code == TSDB_CODE_SUCCESS) {
|
||||
code = buildTSMAAstStreamSubTable(pStmt, pReq, pStmt->pOptions->recursiveTsma ? pTagCol : (SNode*)pTbnameFunc, (SNode**)&pSubTable);
|
||||
code = buildTSMAAstStreamSubTable(pStmt, pReq, pStmt->pOptions->recursiveTsma ? pTagCol : (SNode*)pTbnameFunc,
|
||||
(SNode**)&pSubTable);
|
||||
info.pSubTable = (SNode*)pSubTable;
|
||||
}
|
||||
if (code == TSDB_CODE_SUCCESS)
|
||||
code = nodesListMakeStrictAppend(&info.pTags, pStmt->pOptions->recursiveTsma ? pTagCol : nodesCloneNode((SNode*)pTbnameFunc));
|
||||
code = nodesListMakeStrictAppend(
|
||||
&info.pTags, pStmt->pOptions->recursiveTsma ? pTagCol : nodesCloneNode((SNode*)pTbnameFunc));
|
||||
}
|
||||
}
|
||||
|
||||
if (code == TSDB_CODE_SUCCESS && !pStmt->pOptions->recursiveTsma)
|
||||
code = fmCreateStateFuncs(info.pFuncs);
|
||||
if (code == TSDB_CODE_SUCCESS && !pStmt->pOptions->recursiveTsma) code = fmCreateStateFuncs(info.pFuncs);
|
||||
|
||||
if (code == TSDB_CODE_SUCCESS) {
|
||||
int32_t pProjectionTotalLen = 0;
|
||||
|
@ -10914,7 +10918,8 @@ static int32_t rewriteTSMAFuncs(STranslateContext* pCxt, SCreateTSMAStmt* pStmt,
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t buildCreateTSMAReq(STranslateContext* pCxt, SCreateTSMAStmt* pStmt, SMCreateSmaReq* pReq, SName* useTbName) {
|
||||
static int32_t buildCreateTSMAReq(STranslateContext* pCxt, SCreateTSMAStmt* pStmt, SMCreateSmaReq* pReq,
|
||||
SName* useTbName) {
|
||||
SName name;
|
||||
tNameExtractFullName(toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tsmaName, &name), pReq->name);
|
||||
memset(&name, 0, sizeof(SName));
|
||||
|
@ -11022,7 +11027,7 @@ static int32_t translateCreateTSMA(STranslateContext* pCxt, SCreateTSMAStmt* pSt
|
|||
if (code == TSDB_CODE_SUCCESS) {
|
||||
code = buildCreateTSMAReq(pCxt, pStmt, pStmt->pReq, &useTbName);
|
||||
}
|
||||
if ( TSDB_CODE_SUCCESS == code) {
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = collectUseTable(&useTbName, pCxt->pTargetTables);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
|
@ -11063,7 +11068,8 @@ int32_t translatePostCreateTSMA(SParseContext* pParseCxt, SQuery* pQuery, SSData
|
|||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
if (interval.interval > 0) {
|
||||
pStmt->pReq->lastTs = taosTimeAdd(taosTimeTruncate(lastTs, &interval), interval.interval, interval.intervalUnit, interval.precision);
|
||||
pStmt->pReq->lastTs = taosTimeAdd(taosTimeTruncate(lastTs, &interval), interval.interval, interval.intervalUnit,
|
||||
interval.precision);
|
||||
} else {
|
||||
pStmt->pReq->lastTs = lastTs + 1; // start key of the next time window
|
||||
}
|
||||
|
@ -11074,7 +11080,7 @@ int32_t translatePostCreateTSMA(SParseContext* pParseCxt, SQuery* pQuery, SSData
|
|||
code = setQuery(&cxt, pQuery);
|
||||
}
|
||||
|
||||
if ( TSDB_CODE_SUCCESS == code) {
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
SName name = {0};
|
||||
toName(pParseCxt->acctId, pStmt->dbName, pStmt->originalTbName, &name);
|
||||
code = collectUseTable(&name, cxt.pTargetTables);
|
||||
|
@ -12033,13 +12039,13 @@ static int32_t buildNormalTableBatchReq(int32_t acctId, const SCreateTableStmt*
|
|||
toSchema(pColDef, index + 1, pScheam);
|
||||
if (pColDef->pOptions) {
|
||||
req.colCmpr.pColCmpr[index].id = index + 1;
|
||||
int8_t valid = setColCompressByOption(
|
||||
int32_t code = setColCompressByOption(
|
||||
pScheam->type, columnEncodeVal(((SColumnOptions*)pColDef->pOptions)->encode),
|
||||
columnCompressVal(((SColumnOptions*)pColDef->pOptions)->compress),
|
||||
columnLevelVal(((SColumnOptions*)pColDef->pOptions)->compressLevel), true, &req.colCmpr.pColCmpr[index].alg);
|
||||
if (!valid) {
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
tdDestroySVCreateTbReq(&req);
|
||||
return TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
||||
return code;
|
||||
}
|
||||
}
|
||||
++index;
|
||||
|
@ -12499,7 +12505,6 @@ static int32_t buildDropTableVgroupHashmap(STranslateContext* pCxt, SDropTableCl
|
|||
goto over;
|
||||
}
|
||||
|
||||
|
||||
SVgroupInfo info = {0};
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = getTableHashVgroup(pCxt, pClause->dbName, pClause->tableName, &info);
|
||||
|
@ -12879,14 +12884,12 @@ static int buildAlterTableColumnCompress(STranslateContext* pCxt, SAlterTableStm
|
|||
}
|
||||
|
||||
if (!checkColumnEncode(pStmt->pColOptions->encode)) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
||||
if (!checkColumnCompress(pStmt->pColOptions->compress)) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
||||
if (!checkColumnLevel(pStmt->pColOptions->compressLevel)) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
||||
int8_t valid = setColCompressByOption(pSchema->type, columnEncodeVal(pStmt->pColOptions->encode),
|
||||
if (!checkColumnCompress(pStmt->pColOptions->compress)) return TSDB_CODE_TSC_COMPRESS_PARAM_ERROR;
|
||||
if (!checkColumnLevel(pStmt->pColOptions->compressLevel)) return TSDB_CODE_TSC_COMPRESS_LEVEL_ERROR;
|
||||
int8_t code = setColCompressByOption(pSchema->type, columnEncodeVal(pStmt->pColOptions->encode),
|
||||
columnCompressVal(pStmt->pColOptions->compress),
|
||||
columnLevelVal(pStmt->pColOptions->compressLevel), true, &pReq->compress);
|
||||
if (!valid) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t buildAlterTbReq(STranslateContext* pCxt, SAlterTableStmt* pStmt, STableMeta* pTableMeta,
|
||||
|
|
|
@ -151,8 +151,12 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TSC_QUERY_KILLED, "Query killed")
|
|||
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_NO_EXEC_NODE, "No available execution node in current query policy configuration")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_NOT_STABLE_ERROR, "Table is not a super table")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_STMT_CACHE_ERROR, "Stmt cache error")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_ENCODE_PARAM_ERROR, "Invalid compress param")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_ENCODE_PARAM_ERROR, "Invalid encode param")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_ENCODE_PARAM_NULL, "Not found compress param")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_COMPRESS_PARAM_ERROR, "Invalid compress param")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_COMPRESS_LEVEL_ERROR, "Invalid compress level param")
|
||||
|
||||
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INTERNAL_ERROR, "Internal error")
|
||||
|
||||
// mnode-common
|
||||
|
|
Loading…
Reference in New Issue