From 405597e5fe0174e4f364f92c75b5f155c6a9614b Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Sun, 9 Oct 2022 19:24:02 +0800 Subject: [PATCH] feat: column support 63K and row support 64k --- src/client/inc/tscParseLine.h | 8 +++--- src/client/inc/tscUtil.h | 10 ++++---- src/client/inc/tsclient.h | 2 +- src/client/src/tscLocal.c | 37 ++++++++++++++------------- src/client/src/tscParseLineProtocol.c | 34 ++++++++++++------------ src/client/src/tscParseOpenTSDB.c | 28 ++++++++++---------- src/client/src/tscPrepare.c | 2 +- src/client/src/tscSQLParser.c | 14 +++++----- src/client/src/tscServer.c | 2 +- src/client/src/tscSubquery.c | 4 +-- src/client/src/tscUtil.c | 10 ++++---- src/inc/taos.h | 2 +- src/inc/taosdef.h | 19 +++++++++++++- src/inc/taosmsg.h | 24 ++++++++--------- src/inc/tsdb.h | 4 +-- src/inc/ttype.h | 2 +- src/mnode/inc/mnodeDef.h | 2 +- src/query/inc/qScript.h | 24 ++++++++--------- src/query/inc/qUdf.h | 29 ++++++++++----------- src/query/src/qExecutor.c | 11 ++++---- src/query/src/qScript.c | 2 +- src/tsdb/src/tsdbMeta.c | 2 +- src/tsdb/src/tsdbRead.c | 12 ++++----- tests/script/api/resultBlock.c | 6 ++--- 24 files changed, 154 insertions(+), 136 deletions(-) diff --git a/src/client/inc/tscParseLine.h b/src/client/inc/tscParseLine.h index 8e84d0831d..ab9a45b17a 100644 --- a/src/client/inc/tscParseLine.h +++ b/src/client/inc/tscParseLine.h @@ -26,10 +26,10 @@ extern "C" { typedef TSDB_SML_PROTOCOL_TYPE SMLProtocolType; typedef struct { - char* key; - uint8_t type; - int16_t length; - char* value; + char* key; + uint8_t type; + uint16_t length; + char* value; uint32_t fieldSchemaIdx; } TAOS_SML_KV; diff --git a/src/client/inc/tscUtil.h b/src/client/inc/tscUtil.h index 2699f4dbda..553dd3977d 100644 --- a/src/client/inc/tscUtil.h +++ b/src/client/inc/tscUtil.h @@ -141,7 +141,7 @@ int32_t tsSetBlockInfo(SSubmitBlk *pBlocks, const STableMeta *pTableMeta, int32_ void tscDestroyBoundColumnInfo(SParsedDataColInfo* pColInfo); void doRetrieveSubqueryData(SSchedMsg *pMsg); -SParamInfo* tscAddParamToDataBlock(STableDataBlocks* pDataBlock, char type, uint8_t timePrec, int16_t bytes, +SParamInfo* tscAddParamToDataBlock(STableDataBlocks* pDataBlock, char type, uint8_t timePrec, uint16_t bytes, uint32_t offset); void* tscDestroyBlockArrayList(SSqlObj* pSql, SArray* pDataBlockList); @@ -205,7 +205,7 @@ bool tscIsInsertData(char* sqlstr); int32_t tscAllocPayloadFast(SSqlCmd *pCmd, size_t size); int32_t tscAllocPayload(SSqlCmd* pCmd, int size); -TAOS_FIELD tscCreateField(int8_t type, const char* name, int16_t bytes); +TAOS_FIELD tscCreateField(int8_t type, const char* name, uint16_t bytes); SInternalField* tscFieldInfoAppend(SFieldInfo* pFieldInfo, TAOS_FIELD* pField); SInternalField* tscFieldInfoInsert(SFieldInfo* pFieldInfo, int32_t index, TAOS_FIELD* field); @@ -231,15 +231,15 @@ void addExprParams(SSqlExpr* pExpr, char* argument, int32_t type, int32_t bytes) int32_t tscGetResRowLength(SArray* pExprList); SExprInfo* tscExprInsert(SQueryInfo* pQueryInfo, int32_t index, int16_t functionId, SColumnIndex* pColIndex, int16_t type, - int16_t size, int16_t resColId, int32_t interSize, bool isTagCol); + uint16_t size, int16_t resColId, int32_t interSize, bool isTagCol); SExprInfo* tscExprCreate(STableMetaInfo* pTableMetaInfo, int16_t functionId, SColumnIndex* pColIndex, int16_t type, - int16_t size, int16_t resColId, int32_t interSize, int32_t colType); + uint16_t size, int16_t resColId, int32_t interSize, int32_t colType); void tscExprAddParams(SSqlExpr* pExpr, char* argument, int32_t type, int32_t bytes); SExprInfo* tscExprAppend(SQueryInfo* pQueryInfo, int16_t functionId, SColumnIndex* pColIndex, int16_t type, - int16_t size, int16_t resColId, int32_t interSize, bool isTagCol); + uint16_t size, int16_t resColId, int32_t interSize, bool isTagCol); SExprInfo* tscExprUpdate(SQueryInfo* pQueryInfo, int32_t index, int16_t functionId, int16_t srcColumnIndex, int16_t type, int32_t size); diff --git a/src/client/inc/tsclient.h b/src/client/inc/tsclient.h index 65854905bd..07b44d205e 100644 --- a/src/client/inc/tsclient.h +++ b/src/client/inc/tsclient.h @@ -86,7 +86,7 @@ typedef struct SParamInfo { int32_t idx; uint8_t type; uint8_t timePrec; - int16_t bytes; + uint16_t bytes; uint32_t offset; } SParamInfo; diff --git a/src/client/src/tscLocal.c b/src/client/src/tscLocal.c index 8e4bdc8b2b..d501927a34 100644 --- a/src/client/src/tscLocal.c +++ b/src/client/src/tscLocal.c @@ -168,12 +168,12 @@ static int32_t tscBuildTableSchemaResultFields(SSqlObj *pSql, int32_t numOfCols, rowLen += ((TSDB_COL_NAME_LEN - 1) + VARSTR_HEADER_SIZE); - f.bytes = (int16_t)(typeColLength + VARSTR_HEADER_SIZE); + f.bytes = (uint16_t)(typeColLength + VARSTR_HEADER_SIZE); f.type = TSDB_DATA_TYPE_BINARY; tstrncpy(f.name, "Type", sizeof(f.name)); pInfo = tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f); - pInfo->pExpr = tscExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &idx, TSDB_DATA_TYPE_BINARY, (int16_t)(typeColLength + VARSTR_HEADER_SIZE), + pInfo->pExpr = tscExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &idx, TSDB_DATA_TYPE_BINARY, (uint16_t)(typeColLength + VARSTR_HEADER_SIZE), -1000, typeColLength, false); rowLen += typeColLength + VARSTR_HEADER_SIZE; @@ -188,12 +188,12 @@ static int32_t tscBuildTableSchemaResultFields(SSqlObj *pSql, int32_t numOfCols, rowLen += sizeof(int32_t); - f.bytes = (int16_t)(noteColLength + VARSTR_HEADER_SIZE); + f.bytes = (uint16_t)(noteColLength + VARSTR_HEADER_SIZE); f.type = TSDB_DATA_TYPE_BINARY; tstrncpy(f.name, "Note", sizeof(f.name)); pInfo = tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f); - pInfo->pExpr = tscExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &idx, TSDB_DATA_TYPE_BINARY, (int16_t)(noteColLength + VARSTR_HEADER_SIZE), + pInfo->pExpr = tscExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &idx, TSDB_DATA_TYPE_BINARY, (uint16_t)(noteColLength + VARSTR_HEADER_SIZE), -1000, noteColLength, false); rowLen += noteColLength + VARSTR_HEADER_SIZE; @@ -414,31 +414,32 @@ static int32_t tscGetTableTagValue(SCreateBuilder *builder, char *result) { // build 'show create table/database' result fields static int32_t tscSCreateBuildResultFields(SSqlObj *pSql, BuildType type, const char *ddl) { - int32_t rowLen = 0; - int16_t ddlLen = (int16_t)strlen(ddl); + int32_t rowLen = 0; + uint16_t ddlLen = (uint16_t)strlen(ddl); SColumnIndex idx = {0}; pSql->cmd.numOfCols = 2; - SQueryInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd); + SQueryInfo *pQueryInfo = tscGetQueryInfo(&pSql->cmd); pQueryInfo->order.order = TSDB_ORDER_ASC; - TAOS_FIELD f; + TAOS_FIELD f; if (type == SCREATE_BUILD_TABLE) { - f.type = TSDB_DATA_TYPE_BINARY; + f.type = TSDB_DATA_TYPE_BINARY; f.bytes = (TSDB_TABLE_NAME_LEN - 1) + VARSTR_HEADER_SIZE; tstrncpy(f.name, "Table", sizeof(f.name)); } else { - f.type = TSDB_DATA_TYPE_BINARY; - f.bytes = (TSDB_DB_NAME_LEN - 1) + VARSTR_HEADER_SIZE; + f.type = TSDB_DATA_TYPE_BINARY; + f.bytes = (TSDB_DB_NAME_LEN - 1) + VARSTR_HEADER_SIZE; tstrncpy(f.name, "Database", sizeof(f.name)); - } + } - SInternalField* pInfo = tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f); - pInfo->pExpr = tscExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &idx, TSDB_DATA_TYPE_BINARY, f.bytes, -1000, f.bytes - VARSTR_HEADER_SIZE, false); + SInternalField *pInfo = tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f); + pInfo->pExpr = tscExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &idx, TSDB_DATA_TYPE_BINARY, f.bytes, -1000, + f.bytes - VARSTR_HEADER_SIZE, false); - rowLen += f.bytes; + rowLen += f.bytes; - f.bytes = (int16_t)(ddlLen + VARSTR_HEADER_SIZE); + f.bytes = (uint16_t)(ddlLen + VARSTR_HEADER_SIZE); f.type = TSDB_DATA_TYPE_BINARY; if (type == SCREATE_BUILD_TABLE) { tstrncpy(f.name, "Create Table", sizeof(f.name)); @@ -448,7 +449,7 @@ static int32_t tscSCreateBuildResultFields(SSqlObj *pSql, BuildType type, const pInfo = tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f); pInfo->pExpr = tscExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &idx, TSDB_DATA_TYPE_BINARY, - (int16_t)(ddlLen + VARSTR_HEADER_SIZE), -1000, ddlLen, false); + (uint16_t)(ddlLen + VARSTR_HEADER_SIZE), -1000, ddlLen, false); rowLen += ddlLen + VARSTR_HEADER_SIZE; @@ -943,7 +944,7 @@ void tscSetLocalQueryResult(SSqlObj *pSql, const char *val, const char *columnNa tscFieldInfoClear(&pQueryInfo->fieldsInfo); pQueryInfo->fieldsInfo.internalField = taosArrayInit(1, sizeof(SInternalField)); - TAOS_FIELD f = tscCreateField((int8_t)type, columnName, (int16_t)valueLength); + TAOS_FIELD f = tscCreateField((int8_t)type, columnName, (uint16_t)valueLength); tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f); pSql->res.pMerger = tscInitResObjForLocalQuery(1, (int32_t)valueLength, pSql->self); diff --git a/src/client/src/tscParseLineProtocol.c b/src/client/src/tscParseLineProtocol.c index f3bb479144..39514b0889 100644 --- a/src/client/src/tscParseLineProtocol.c +++ b/src/client/src/tscParseLineProtocol.c @@ -1643,8 +1643,8 @@ static int32_t isTimeStamp(char *pVal, uint16_t len, SMLTimeStampType *tsType, S static bool convertStrToNumber(TAOS_SML_KV *pVal, char *str, SSmlLinesInfo* info) { errno = 0; - uint8_t type = pVal->type; - int16_t length = pVal->length; + uint8_t type = pVal->type; + uint16_t length = pVal->length; int64_t val_s = 0; uint64_t val_u = 0; double val_d = 0.0; @@ -1761,7 +1761,7 @@ bool convertSmlValueType(TAOS_SML_KV *pVal, char *value, bool has_sign; if (isInteger(value, len, &has_sign)) { pVal->type = has_sign ? TSDB_DATA_TYPE_BIGINT : TSDB_DATA_TYPE_UBIGINT; - pVal->length = (int16_t)tDataTypes[pVal->type].bytes; + pVal->length = (uint16_t)tDataTypes[pVal->type].bytes; value[len - 1] = '\0'; if (!isValidInteger(value) || !convertStrToNumber(pVal, value, info)) { return false; @@ -1770,7 +1770,7 @@ bool convertSmlValueType(TAOS_SML_KV *pVal, char *value, } if (isTinyInt(value, len)) { pVal->type = TSDB_DATA_TYPE_TINYINT; - pVal->length = (int16_t)tDataTypes[pVal->type].bytes; + pVal->length = (uint16_t)tDataTypes[pVal->type].bytes; value[len - 2] = '\0'; if (!isValidInteger(value) || !convertStrToNumber(pVal, value, info)) { return false; @@ -1779,7 +1779,7 @@ bool convertSmlValueType(TAOS_SML_KV *pVal, char *value, } if (isTinyUint(value, len)) { pVal->type = TSDB_DATA_TYPE_UTINYINT; - pVal->length = (int16_t)tDataTypes[pVal->type].bytes; + pVal->length = (uint16_t)tDataTypes[pVal->type].bytes; value[len - 2] = '\0'; if (!isValidInteger(value) || !convertStrToNumber(pVal, value, info)) { return false; @@ -1788,7 +1788,7 @@ bool convertSmlValueType(TAOS_SML_KV *pVal, char *value, } if (isSmallInt(value, len)) { pVal->type = TSDB_DATA_TYPE_SMALLINT; - pVal->length = (int16_t)tDataTypes[pVal->type].bytes; + pVal->length = (uint16_t)tDataTypes[pVal->type].bytes; value[len - 3] = '\0'; if (!isValidInteger(value) || !convertStrToNumber(pVal, value, info)) { return false; @@ -1797,7 +1797,7 @@ bool convertSmlValueType(TAOS_SML_KV *pVal, char *value, } if (isSmallUint(value, len)) { pVal->type = TSDB_DATA_TYPE_USMALLINT; - pVal->length = (int16_t)tDataTypes[pVal->type].bytes; + pVal->length = (uint16_t)tDataTypes[pVal->type].bytes; value[len - 3] = '\0'; if (!isValidInteger(value) || !convertStrToNumber(pVal, value, info)) { return false; @@ -1806,7 +1806,7 @@ bool convertSmlValueType(TAOS_SML_KV *pVal, char *value, } if (isInt(value, len)) { pVal->type = TSDB_DATA_TYPE_INT; - pVal->length = (int16_t)tDataTypes[pVal->type].bytes; + pVal->length = (uint16_t)tDataTypes[pVal->type].bytes; value[len - 3] = '\0'; if (!isValidInteger(value) || !convertStrToNumber(pVal, value, info)) { return false; @@ -1815,7 +1815,7 @@ bool convertSmlValueType(TAOS_SML_KV *pVal, char *value, } if (isUint(value, len)) { pVal->type = TSDB_DATA_TYPE_UINT; - pVal->length = (int16_t)tDataTypes[pVal->type].bytes; + pVal->length = (uint16_t)tDataTypes[pVal->type].bytes; value[len - 3] = '\0'; if (!isValidInteger(value) || !convertStrToNumber(pVal, value, info)) { return false; @@ -1824,7 +1824,7 @@ bool convertSmlValueType(TAOS_SML_KV *pVal, char *value, } if (isBigInt(value, len)) { pVal->type = TSDB_DATA_TYPE_BIGINT; - pVal->length = (int16_t)tDataTypes[pVal->type].bytes; + pVal->length = (uint16_t)tDataTypes[pVal->type].bytes; value[len - 3] = '\0'; if (!isValidInteger(value) || !convertStrToNumber(pVal, value, info)) { return false; @@ -1833,7 +1833,7 @@ bool convertSmlValueType(TAOS_SML_KV *pVal, char *value, } if (isBigUint(value, len)) { pVal->type = TSDB_DATA_TYPE_UBIGINT; - pVal->length = (int16_t)tDataTypes[pVal->type].bytes; + pVal->length = (uint16_t)tDataTypes[pVal->type].bytes; value[len - 3] = '\0'; if (!isValidInteger(value) || !convertStrToNumber(pVal, value, info)) { return false; @@ -1843,7 +1843,7 @@ bool convertSmlValueType(TAOS_SML_KV *pVal, char *value, //floating number if (isFloat(value, len)) { pVal->type = TSDB_DATA_TYPE_FLOAT; - pVal->length = (int16_t)tDataTypes[pVal->type].bytes; + pVal->length = (uint16_t)tDataTypes[pVal->type].bytes; value[len - 3] = '\0'; if (!isValidFloat(value) || !convertStrToNumber(pVal, value, info)) { return false; @@ -1852,7 +1852,7 @@ bool convertSmlValueType(TAOS_SML_KV *pVal, char *value, } if (isDouble(value, len)) { pVal->type = TSDB_DATA_TYPE_DOUBLE; - pVal->length = (int16_t)tDataTypes[pVal->type].bytes; + pVal->length = (uint16_t)tDataTypes[pVal->type].bytes; value[len - 3] = '\0'; if (!isValidFloat(value) || !convertStrToNumber(pVal, value, info)) { return false; @@ -1881,7 +1881,7 @@ bool convertSmlValueType(TAOS_SML_KV *pVal, char *value, bool bVal; if (isBool(value, len, &bVal)) { pVal->type = TSDB_DATA_TYPE_BOOL; - pVal->length = (int16_t)tDataTypes[pVal->type].bytes; + pVal->length = (uint16_t)tDataTypes[pVal->type].bytes; pVal->value = calloc(pVal->length, 1); memcpy(pVal->value, &bVal, pVal->length); return true; @@ -1890,7 +1890,7 @@ bool convertSmlValueType(TAOS_SML_KV *pVal, char *value, //Handle default(no appendix) type as DOUBLE if (isValidInteger(value) || isValidFloat(value)) { pVal->type = TSDB_DATA_TYPE_DOUBLE; - pVal->length = (int16_t)tDataTypes[pVal->type].bytes; + pVal->length = (uint16_t)tDataTypes[pVal->type].bytes; if (!convertStrToNumber(pVal, value, info)) { return false; } @@ -1962,7 +1962,7 @@ int32_t convertSmlTimeStamp(TAOS_SML_KV *pVal, char *value, tscDebug("SML:0x%"PRIx64"Timestamp after conversion:%"PRId64, info->id, tsVal); pVal->type = TSDB_DATA_TYPE_TIMESTAMP; - pVal->length = (int16_t)tDataTypes[pVal->type].bytes; + pVal->length = (uint16_t)tDataTypes[pVal->type].bytes; pVal->value = calloc(pVal->length, 1); memcpy(pVal->value, &tsVal, pVal->length); return TSDB_CODE_SUCCESS; @@ -2056,7 +2056,7 @@ static int32_t parseSmlValue(TAOS_SML_KV *pKV, const char **idx, int32_t sqlLen, int32_t ret = TSDB_CODE_SUCCESS; char *value = NULL; int32_t bufSize = TSDB_FUNC_BUF_SIZE; - int16_t len = 0; + uint16_t len = 0; bool kv_done = false; bool back_slash = false; diff --git a/src/client/src/tscParseOpenTSDB.c b/src/client/src/tscParseOpenTSDB.c index f0c7b6e0c5..6b3fd5cb6a 100644 --- a/src/client/src/tscParseOpenTSDB.c +++ b/src/client/src/tscParseOpenTSDB.c @@ -657,7 +657,7 @@ static int32_t parseTimestampFromJSON(cJSON *root, TAOS_SML_KV **pTS, int *num_k memcpy((*pTS)->key, key, sizeof(key)); (*pTS)->type = TSDB_DATA_TYPE_TIMESTAMP; - (*pTS)->length = (int16_t)tDataTypes[(*pTS)->type].bytes; + (*pTS)->length = (uint16_t)tDataTypes[(*pTS)->type].bytes; (*pTS)->value = tcalloc((*pTS)->length, 1); memcpy((*pTS)->value, &tsVal, (*pTS)->length); @@ -672,7 +672,7 @@ static int32_t convertJSONBool(TAOS_SML_KV *pVal, char* typeStr, int64_t valueIn return TSDB_CODE_TSC_INVALID_JSON_TYPE; } pVal->type = TSDB_DATA_TYPE_BOOL; - pVal->length = (int16_t)tDataTypes[pVal->type].bytes; + pVal->length = (uint16_t)tDataTypes[pVal->type].bytes; pVal->value = tcalloc(pVal->length, 1); *(bool *)(pVal->value) = valueInt ? true : false; @@ -688,7 +688,7 @@ static int32_t convertJSONNumber(TAOS_SML_KV *pVal, char* typeStr, cJSON *value, return TSDB_CODE_TSC_VALUE_OUT_OF_RANGE; } pVal->type = TSDB_DATA_TYPE_TINYINT; - pVal->length = (int16_t)tDataTypes[pVal->type].bytes; + pVal->length = (uint16_t)tDataTypes[pVal->type].bytes; pVal->value = tcalloc(pVal->length, 1); *(int8_t *)(pVal->value) = (int8_t)(value->valueint); return TSDB_CODE_SUCCESS; @@ -701,7 +701,7 @@ static int32_t convertJSONNumber(TAOS_SML_KV *pVal, char* typeStr, cJSON *value, return TSDB_CODE_TSC_VALUE_OUT_OF_RANGE; } pVal->type = TSDB_DATA_TYPE_SMALLINT; - pVal->length = (int16_t)tDataTypes[pVal->type].bytes; + pVal->length = (uint16_t)tDataTypes[pVal->type].bytes; pVal->value = tcalloc(pVal->length, 1); *(int16_t *)(pVal->value) = (int16_t)(value->valueint); return TSDB_CODE_SUCCESS; @@ -714,7 +714,7 @@ static int32_t convertJSONNumber(TAOS_SML_KV *pVal, char* typeStr, cJSON *value, return TSDB_CODE_TSC_VALUE_OUT_OF_RANGE; } pVal->type = TSDB_DATA_TYPE_INT; - pVal->length = (int16_t)tDataTypes[pVal->type].bytes; + pVal->length = (uint16_t)tDataTypes[pVal->type].bytes; pVal->value = tcalloc(pVal->length, 1); *(int32_t *)(pVal->value) = (int32_t)(value->valueint); return TSDB_CODE_SUCCESS; @@ -723,7 +723,7 @@ static int32_t convertJSONNumber(TAOS_SML_KV *pVal, char* typeStr, cJSON *value, if (strcasecmp(typeStr, "i64") == 0 || strcasecmp(typeStr, "bigint") == 0) { pVal->type = TSDB_DATA_TYPE_BIGINT; - pVal->length = (int16_t)tDataTypes[pVal->type].bytes; + pVal->length = (uint16_t)tDataTypes[pVal->type].bytes; pVal->value = tcalloc(pVal->length, 1); /* cJSON conversion of legit BIGINT may overflow, * use original string to do the conversion. @@ -745,7 +745,7 @@ static int32_t convertJSONNumber(TAOS_SML_KV *pVal, char* typeStr, cJSON *value, return TSDB_CODE_TSC_VALUE_OUT_OF_RANGE; } pVal->type = TSDB_DATA_TYPE_FLOAT; - pVal->length = (int16_t)tDataTypes[pVal->type].bytes; + pVal->length = (uint16_t)tDataTypes[pVal->type].bytes; pVal->value = tcalloc(pVal->length, 1); *(float *)(pVal->value) = (float)(value->valuedouble); return TSDB_CODE_SUCCESS; @@ -758,7 +758,7 @@ static int32_t convertJSONNumber(TAOS_SML_KV *pVal, char* typeStr, cJSON *value, return TSDB_CODE_TSC_VALUE_OUT_OF_RANGE; } pVal->type = TSDB_DATA_TYPE_DOUBLE; - pVal->length = (int16_t)tDataTypes[pVal->type].bytes; + pVal->length = (uint16_t)tDataTypes[pVal->type].bytes; pVal->value = tcalloc(pVal->length, 1); *(double *)(pVal->value) = (double)(value->valuedouble); return TSDB_CODE_SUCCESS; @@ -778,7 +778,7 @@ static int32_t convertJSONString(TAOS_SML_KV *pVal, char* typeStr, cJSON *value, tscError("OTD:0x%"PRIx64" invalid type(%s) for JSON String", info->id, typeStr); return TSDB_CODE_TSC_INVALID_JSON_TYPE; } - pVal->length = (int16_t)strlen(value->valuestring); + pVal->length = (uint16_t)strlen(value->valuestring); pVal->value = tcalloc(pVal->length + 1, 1); memcpy(pVal->value, value->valuestring, pVal->length); return TSDB_CODE_SUCCESS; @@ -839,7 +839,7 @@ static int32_t parseValueFromJSON(cJSON *root, TAOS_SML_KV *pVal, SSmlLinesInfo* case cJSON_True: case cJSON_False: { pVal->type = TSDB_DATA_TYPE_BOOL; - pVal->length = (int16_t)tDataTypes[pVal->type].bytes; + pVal->length = (uint16_t)tDataTypes[pVal->type].bytes; pVal->value = tcalloc(pVal->length, 1); *(bool *)(pVal->value) = root->valueint ? true : false; break; @@ -848,7 +848,7 @@ static int32_t parseValueFromJSON(cJSON *root, TAOS_SML_KV *pVal, SSmlLinesInfo* //convert default JSON Number type to BIGINT/DOUBLE //if (isValidInteger(root->numberstring)) { // pVal->type = TSDB_DATA_TYPE_BIGINT; - // pVal->length = (int16_t)tDataTypes[pVal->type].bytes; + // pVal->length = (uint16_t)tDataTypes[pVal->type].bytes; // pVal->value = tcalloc(pVal->length, 1); // /* cJSON conversion of legit BIGINT may overflow, // * use original string to do the conversion. @@ -862,7 +862,7 @@ static int32_t parseValueFromJSON(cJSON *root, TAOS_SML_KV *pVal, SSmlLinesInfo* // *(int64_t *)(pVal->value) = val; //} else if (isValidFloat(root->numberstring)) { // pVal->type = TSDB_DATA_TYPE_DOUBLE; - // pVal->length = (int16_t)tDataTypes[pVal->type].bytes; + // pVal->length = (uint16_t)tDataTypes[pVal->type].bytes; // pVal->value = tcalloc(pVal->length, 1); // *(double *)(pVal->value) = (double)(root->valuedouble); //} else { @@ -870,7 +870,7 @@ static int32_t parseValueFromJSON(cJSON *root, TAOS_SML_KV *pVal, SSmlLinesInfo* //} if (isValidInteger(root->numberstring) || isValidFloat(root->numberstring)) { pVal->type = TSDB_DATA_TYPE_DOUBLE; - pVal->length = (int16_t)tDataTypes[pVal->type].bytes; + pVal->length = (uint16_t)tDataTypes[pVal->type].bytes; pVal->value = tcalloc(pVal->length, 1); *(double *)(pVal->value) = (double)(root->valuedouble); } @@ -890,7 +890,7 @@ static int32_t parseValueFromJSON(cJSON *root, TAOS_SML_KV *pVal, SSmlLinesInfo* return TSDB_CODE_TSC_INVALID_JSON_CONFIG; } //pVal->length = wcslen((wchar_t *)root->valuestring) * TSDB_NCHAR_SIZE; - pVal->length = (int16_t)strlen(root->valuestring); + pVal->length = (uint16_t)strlen(root->valuestring); pVal->value = tcalloc(pVal->length + 1, 1); memcpy(pVal->value, root->valuestring, pVal->length); break; diff --git a/src/client/src/tscPrepare.c b/src/client/src/tscPrepare.c index 3f94cdc64a..c2de205767 100644 --- a/src/client/src/tscPrepare.c +++ b/src/client/src/tscPrepare.c @@ -922,7 +922,7 @@ static int doBindBatchParam(STableDataBlocks* pBlock, SParamInfo* param, TAOS_MU tscError("binary length too long, ignore it, max:%d, actual:%d", param->bytes, (int32_t)pBind->length[i]); return TSDB_CODE_TSC_INVALID_VALUE; } - int16_t bsize = (short)pBind->length[i]; + uint16_t bsize = (uint16_t)pBind->length[i]; STR_WITH_SIZE_TO_VARSTR(data + param->offset, (char *)pBind->buffer + pBind->buffer_length * i, bsize); } else if (param->type == TSDB_DATA_TYPE_NCHAR) { if (pBind->length[i] > (uintptr_t)param->bytes) { diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 8eb7f15fde..8ba3f20f6e 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -81,7 +81,7 @@ static void getColumnName(tSqlExprItem* pItem, char* resultFieldName, char* rawN static int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t colIndex, tSqlExprItem* pItem, bool finalResult, SUdfInfo* pUdfInfo); -static int32_t insertResultField(SQueryInfo* pQueryInfo, int32_t outputIndex, SColumnList* pColList, int16_t bytes, +static int32_t insertResultField(SQueryInfo* pQueryInfo, int32_t outputIndex, SColumnList* pColList, uint16_t bytes, int8_t type, char* fieldName, SExprInfo* pSqlExpr); static uint8_t convertRelationalOperator(SStrToken *pToken); @@ -2368,7 +2368,7 @@ int32_t validateSelectNodeList(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SArray* pS return TSDB_CODE_SUCCESS; } -int32_t insertResultField(SQueryInfo* pQueryInfo, int32_t outputIndex, SColumnList* pColList, int16_t bytes, +int32_t insertResultField(SQueryInfo* pQueryInfo, int32_t outputIndex, SColumnList* pColList, uint16_t bytes, int8_t type, char* fieldName, SExprInfo* pSqlExpr) { for (int32_t i = 0; i < pColList->num; ++i) { int32_t tableIndex = pColList->ids[i].tableIndex; @@ -8276,9 +8276,9 @@ void addGroupInfoForSubquery(SSqlObj* pParentObj, SSqlObj* pSql, int32_t subClau int16_t colIndex = tscGetTagColIndexById(pTableMetaInfo->pTableMeta, colId); SColumnIndex idx = {.tableIndex = 0, .columnIndex = colIndex}; - char* name = pTagSchema->name; - int16_t type = pTagSchema->type; - int16_t bytes = pTagSchema->bytes; + char* name = pTagSchema->name; + int16_t type = pTagSchema->type; + uint16_t bytes = pTagSchema->bytes; pExpr = tscExprAppend(pQueryInfo, TSDB_FUNC_TAG, &idx, type, bytes, getNewResColId(&pSql->cmd), bytes, true); pExpr->base.colInfo.flag = TSDB_COL_TAG; @@ -9350,7 +9350,7 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) { // check again after the convert since it may be converted from binary to nchar. if (pSchema->type == TSDB_DATA_TYPE_BINARY || pSchema->type == TSDB_DATA_TYPE_NCHAR) { - int16_t len = varDataTLen(tagVal); + uint16_t len = varDataTLen(tagVal); if (len > pSchema->bytes) { tdDestroyKVRowBuilder(&kvRowBuilder); return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3); @@ -9404,7 +9404,7 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) { // check again after the convert since it may be converted from binary to nchar. if (pSchema->type == TSDB_DATA_TYPE_BINARY || pSchema->type == TSDB_DATA_TYPE_NCHAR) { - int16_t len = varDataTLen(tagVal); + uint16_t len = varDataTLen(tagVal); if (len > pSchema->bytes) { tdDestroyKVRowBuilder(&kvRowBuilder); return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3); diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 8cc28bb2ca..cc035677e7 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -1290,7 +1290,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) { *(int8_t*) pMsg = pUdfInfo->resType; pMsg += sizeof(pUdfInfo->resType); - *(int16_t*) pMsg = htons(pUdfInfo->resBytes); + *(uint16_t *)pMsg = htons(pUdfInfo->resBytes); pMsg += sizeof(pUdfInfo->resBytes); STR_TO_VARSTR(pMsg, pUdfInfo->name); diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index fc72943c6e..33883a1ab0 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -3747,7 +3747,7 @@ _error: return pRes->code; } -static char* getResultBlockPosition(SSqlCmd* pCmd, SSqlRes* pRes, int32_t columnIndex, int16_t* bytes) { +static char* getResultBlockPosition(SSqlCmd* pCmd, SSqlRes* pRes, int32_t columnIndex, uint16_t* bytes) { SQueryInfo* pQueryInfo = tscGetQueryInfo(pCmd); SInternalField* pInfo = (SInternalField*) TARRAY_GET_ELEM(pQueryInfo->fieldsInfo.internalField, columnIndex); @@ -3805,7 +3805,7 @@ static void doBuildResFromSubqueries(SSqlObj* pSql) { pRes->data = pFilePage->data; char* data = pRes->data; - int16_t bytes = 0; + uint16_t bytes = 0; tscRestoreFuncForSTableQuery(pQueryInfo); tscFieldInfoUpdateOffset(pQueryInfo); diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 0f293299d2..6eeb8aedc5 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -1865,7 +1865,7 @@ void tscDestroyDataBlock(SSqlObj *pSql, STableDataBlocks* pDataBlock, bool remov tfree(pDataBlock); } -SParamInfo* tscAddParamToDataBlock(STableDataBlocks* pDataBlock, char type, uint8_t timePrec, int16_t bytes, +SParamInfo* tscAddParamToDataBlock(STableDataBlocks* pDataBlock, char type, uint8_t timePrec, uint16_t bytes, uint32_t offset) { uint32_t needed = pDataBlock->numOfParams + 1; if (needed > pDataBlock->numOfAllocedParams) { @@ -2395,7 +2395,7 @@ int32_t tscAllocPayload(SSqlCmd* pCmd, int size) { return code; } -TAOS_FIELD tscCreateField(int8_t type, const char* name, int16_t bytes) { +TAOS_FIELD tscCreateField(int8_t type, const char* name, uint16_t bytes) { TAOS_FIELD f = { .type = type, .bytes = bytes, }; tstrncpy(f.name, name, sizeof(f.name)); return f; @@ -2623,7 +2623,7 @@ void tscFieldInfoCopy(SFieldInfo* pFieldInfo, const SFieldInfo* pSrc, const SArr SExprInfo* tscExprCreate(STableMetaInfo* pTableMetaInfo, int16_t functionId, SColumnIndex* pColIndex, int16_t type, - int16_t size, int16_t resColId, int32_t interSize, int32_t colType) { + uint16_t size, int16_t resColId, int32_t interSize, int32_t colType) { SExprInfo* pExpr = calloc(1, sizeof(SExprInfo)); if (pExpr == NULL) { return NULL; @@ -2685,7 +2685,7 @@ SExprInfo* tscExprCreate(STableMetaInfo* pTableMetaInfo, int16_t functionId, SCo } SExprInfo* tscExprInsert(SQueryInfo* pQueryInfo, int32_t idx, int16_t functionId, SColumnIndex* pColIndex, int16_t type, - int16_t size, int16_t resColId, int32_t interSize, bool isTagCol) { + uint16_t size, int16_t resColId, int32_t interSize, bool isTagCol) { int32_t num = (int32_t)taosArrayGetSize(pQueryInfo->exprList); if (idx == num) { return tscExprAppend(pQueryInfo, functionId, pColIndex, type, size, resColId, interSize, isTagCol); @@ -2698,7 +2698,7 @@ SExprInfo* tscExprInsert(SQueryInfo* pQueryInfo, int32_t idx, int16_t functionId } SExprInfo* tscExprAppend(SQueryInfo* pQueryInfo, int16_t functionId, SColumnIndex* pColIndex, int16_t type, - int16_t size, int16_t resColId, int32_t interSize, bool isTagCol) { + uint16_t size, int16_t resColId, int32_t interSize, bool isTagCol) { STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, pColIndex->tableIndex); SExprInfo* pExpr = tscExprCreate(pTableMetaInfo, functionId, pColIndex, type, size, resColId, interSize, isTagCol); taosArrayPush(pQueryInfo->exprList, &pExpr); diff --git a/src/inc/taos.h b/src/inc/taos.h index b2e2e9f3c6..60c81db5e6 100644 --- a/src/inc/taos.h +++ b/src/inc/taos.h @@ -66,7 +66,7 @@ typedef enum { typedef struct taosField { char name[65]; uint8_t type; - int16_t bytes; + uint16_t bytes; } TAOS_FIELD; typedef enum { diff --git a/src/inc/taosdef.h b/src/inc/taosdef.h index ade0c83ef7..a105cfcb9f 100644 --- a/src/inc/taosdef.h +++ b/src/inc/taosdef.h @@ -206,7 +206,14 @@ do { \ // this is the length of its string representation, including the terminator zero #define TSDB_ACCT_ID_LEN 11 +#define TSDB_MODE_RICH_COL_ + +#ifdef TSDB_MODE_RICH_COL #define TSDB_MAX_COLUMNS 4096 +#else +#define TSDB_MAX_COLUMNS 128 +#endif + #define TSDB_MIN_COLUMNS 2 //PRIMARY COLUMN(timestamp) + other columns #define TSDB_NODE_NAME_LEN 64 @@ -231,7 +238,12 @@ do { \ * - Secondly, if all cols are VarDataT type except primary key, we need 4 bits to store the offset, thus * the final value is 65531-(4096-1)*4 = 49151. */ -#define TSDB_MAX_BYTES_PER_ROW 49151 +#ifdef TSDB_MODE_RICH_COL +#define TSDB_MAX_BYTES_PER_ROW 49151 +#else +#define TSDB_MAX_BYTES_PER_ROW 65023 // 65531-(128-1)*4=65023 +#endif + #define TSDB_MAX_TAGS_LEN 16384 #define TSDB_MAX_JSON_TAGS_LEN (4096*TSDB_NCHAR_SIZE + 2 + 1) // 2->var_header_len 1->type #define TSDB_MAX_TAGS 128 @@ -371,7 +383,12 @@ do { \ #define TSDB_MAX_JOIN_TABLE_NUM 10 #define TSDB_MAX_UNION_CLAUSE 5 +#ifdef TSDB_MODE_RICH_COL #define TSDB_MAX_FIELD_LEN 16384 +#else +#define TSDB_MAX_FIELD_LEN 64512 +#endif + #define TSDB_MAX_BINARY_LEN (TSDB_MAX_FIELD_LEN-TSDB_KEYSIZE) // keep 16384 #define TSDB_MAX_NCHAR_LEN (TSDB_MAX_FIELD_LEN-TSDB_KEYSIZE) // keep 16384 #define PRIMARYKEY_TIMESTAMP_COL_INDEX 0 diff --git a/src/inc/taosmsg.h b/src/inc/taosmsg.h index f2aed524de..90fb1970b8 100644 --- a/src/inc/taosmsg.h +++ b/src/inc/taosmsg.h @@ -265,10 +265,10 @@ typedef struct { } SShellSubmitRspMsg; typedef struct SSchema { - uint8_t type; - char name[TSDB_COL_NAME_LEN]; - int16_t colId; - int16_t bytes; + uint8_t type; + char name[TSDB_COL_NAME_LEN]; + int16_t colId; + uint16_t bytes; } SSchema; typedef struct STimeWindow { @@ -643,14 +643,14 @@ typedef struct { } SRetrieveFuncMsg; typedef struct { - int8_t extend; - char name[TSDB_FUNC_NAME_LEN]; - int32_t funcType; - int8_t resType; - int16_t resBytes; - int32_t bufSize; - int32_t len; - char content[]; + int8_t extend; + char name[TSDB_FUNC_NAME_LEN]; + int32_t funcType; + int8_t resType; + uint16_t resBytes; + int32_t bufSize; + int32_t len; + char content[]; } SFunctionInfoMsg; typedef struct { diff --git a/src/inc/tsdb.h b/src/inc/tsdb.h index 73820ebef2..8fec9b7d8e 100644 --- a/src/inc/tsdb.h +++ b/src/inc/tsdb.h @@ -432,8 +432,8 @@ bool tsdbNoProblem(STsdbRepo* pRepo); int tsdbCheckWal(STsdbRepo *pRepo, uint32_t walSize); // for json tag -void* getJsonTagValueElment(void* data, char* key, int32_t keyLen, char* out, int16_t bytes); -void getJsonTagValueAll(void* data, void* dst, int16_t bytes); +void* getJsonTagValueElment(void* data, char* key, int32_t keyLen, char* out, uint16_t bytes); +void getJsonTagValueAll(void* data, void* dst, uint16_t bytes); char* parseTagDatatoJson(void *p); // diff --git a/src/inc/ttype.h b/src/inc/ttype.h index 3c645b8530..91fb0da3fb 100644 --- a/src/inc/ttype.h +++ b/src/inc/ttype.h @@ -11,7 +11,7 @@ extern "C" { // ----------------- For variable data types such as TSDB_DATA_TYPE_BINARY and TSDB_DATA_TYPE_NCHAR typedef int32_t VarDataOffsetT; -typedef int16_t VarDataLenT; // maxVarDataLen: 32767 +typedef uint16_t VarDataLenT; // maxVarDataLen: 65535 typedef uint16_t TDRowLenT; // not including overhead: 0 ~ 65535 typedef uint32_t TDRowTLenT; // total length, including overhead diff --git a/src/mnode/inc/mnodeDef.h b/src/mnode/inc/mnodeDef.h index 4bbbbb7d86..6aa60c3cfb 100644 --- a/src/mnode/inc/mnodeDef.h +++ b/src/mnode/inc/mnodeDef.h @@ -239,7 +239,7 @@ typedef struct SFuncObj { int32_t bufSize; int64_t createdTime; uint8_t resType; - int16_t resBytes; + uint16_t resBytes; int64_t sig; // partial md5 sign int16_t type; // [lua script|so|js] int8_t reserved[64]; diff --git a/src/query/inc/qScript.h b/src/query/inc/qScript.h index 0f370be4be..5855665857 100644 --- a/src/query/inc/qScript.h +++ b/src/query/inc/qScript.h @@ -42,23 +42,23 @@ enum ScriptState { typedef struct { SHashObj *funcId; //func already registed in lua_env, may be no use lua_State *lua_state; // lua env -} ScriptEnv; +} ScriptEnv; typedef struct ScriptCtx { // one-more-space-for-null-terminator to support function name // at most USER_FUNC_NAME_LIMIT bytes long actually - char funcName[USER_FUNC_NAME_LIMIT+1]; - int8_t state; - ScriptEnv *pEnv; - int8_t isAgg; // agg function or not - + char funcName[USER_FUNC_NAME_LIMIT + 1]; + int8_t state; + ScriptEnv *pEnv; + int8_t isAgg; // agg function or not + // init value of udf script - int8_t resType; - int16_t resBytes; + int8_t resType; + uint16_t resBytes; + + int32_t numOfOutput; + int32_t offset; - int32_t numOfOutput; - int32_t offset; - } ScriptCtx; int taosLoadScriptInit(void *pInit); @@ -75,7 +75,7 @@ typedef struct { pthread_mutex_t mutex; } ScriptEnvPool; -ScriptCtx* createScriptCtx(char *str, int8_t resType, int16_t resBytes); +ScriptCtx* createScriptCtx(char *str, int8_t resType, uint16_t resBytes); void destroyScriptCtx(void *pScriptCtx); int32_t scriptEnvPoolInit(); diff --git a/src/query/inc/qUdf.h b/src/query/inc/qUdf.h index 77da4b668a..136a136715 100644 --- a/src/query/inc/qUdf.h +++ b/src/query/inc/qUdf.h @@ -32,26 +32,25 @@ typedef struct SUdfInit{ void (*destroyCtxFunc)(void *script_ctx); } SUdfInit; - typedef struct SUdfInfo { - int32_t functionId; // system assigned function id - int32_t funcType; // scalar function or aggregate function - int8_t resType; // result type - int16_t resBytes; // result byte - int32_t contLen; // content length - int32_t bufSize; //interbuf size - char *name; // function name - void *handle; // handle loaded in mem - void *funcs[TSDB_UDF_FUNC_MAX_NUM]; // function ptr + int32_t functionId; // system assigned function id + int32_t funcType; // scalar function or aggregate function + int8_t resType; // result type + uint16_t resBytes; // result byte + int32_t contLen; // content length + int32_t bufSize; // interbuf size + char* name; // function name + void* handle; // handle loaded in mem + void* funcs[TSDB_UDF_FUNC_MAX_NUM]; // function ptr // for script like lua/javascript only - int isScript; - void *pScriptCtx; + int isScript; + void* pScriptCtx; SUdfInit init; - char *content; - char *path; - bool keep; + char* content; + char* path; + bool keep; } SUdfInfo; //script diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 707c123006..12026187aa 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -3446,7 +3446,7 @@ void filterColRowsInDataBlock(SQueryRuntimeEnv* pRuntimeEnv, SSDataBlock* pBlock static SColumnInfo* doGetTagColumnInfoById(SColumnInfo* pTagColList, int32_t numOfTags, int16_t colId); static void doSetTagValueInParam(void* pTable, char* param, int32_t paraLen, int32_t tagColId, tVariant* tag, - int16_t type, int16_t bytes); + int16_t type, uint16_t bytes); static uint32_t doFilterByBlockTimeWindow(STableScanInfo* pTableScanInfo, SSDataBlock* pBlock) { SQLFunctionCtx* pCtx = pTableScanInfo->pCtx; @@ -3732,7 +3732,7 @@ int32_t binarySearchForKey(char* pValue, int num, TSKEY key, int order) { * e.g.,tag information into input buffer */ static void doSetTagValueInParam(void* pTable, char* param, int32_t paramLen, int32_t tagColId, tVariant* tag, - int16_t type, int16_t bytes) { + int16_t type, uint16_t bytes) { tVariantDestroy(tag); char* val = NULL; @@ -8580,7 +8580,7 @@ static SSDataBlock* doTagScan(void* param, bool* newgroup) { count = 0; - int16_t bytes = pExprInfo->base.resBytes; + uint16_t bytes = pExprInfo->base.resBytes; int16_t type = pExprInfo->base.resType; for (int32_t i = 0; i < pQueryAttr->numOfTags; ++i) { @@ -8654,7 +8654,8 @@ static SSDataBlock* doTagScan(void* param, bool* newgroup) { STableQueryInfo* item = taosArrayGetP(pa, i); char * data = NULL, *dst = NULL; - int16_t type = 0, bytes = 0; + int16_t type = 0; + uint16_t bytes = 0; for (int32_t j = 0; j < pOperator->numOfOutput; ++j) { // not assign value in case of user defined constant output column if (TSDB_COL_IS_UD_COL(pExprInfo[j].base.colInfo.flag)) { @@ -9359,7 +9360,7 @@ int32_t convertQueryMsg(SQueryTableMsg* pQueryMsg, SQueryParam* param) { param->pUdfInfo->resType = *(int8_t*)pMsg; pMsg += sizeof(int8_t); - param->pUdfInfo->resBytes = htons(*(int16_t*)pMsg); + param->pUdfInfo->resBytes = htons(*(uint16_t*)pMsg); pMsg += sizeof(int16_t); tstr* name = (tstr*)(pMsg); diff --git a/src/query/src/qScript.c b/src/query/src/qScript.c index 2d968e2cdb..0a8450ce70 100644 --- a/src/query/src/qScript.c +++ b/src/query/src/qScript.c @@ -210,7 +210,7 @@ void taosLoadScriptDestroy(void *pInit) { destroyScriptCtx(pInit); } -ScriptCtx* createScriptCtx(char *script, int8_t resType, int16_t resBytes) { +ScriptCtx* createScriptCtx(char *script, int8_t resType, uint16_t resBytes) { ScriptCtx *pCtx = (ScriptCtx *)calloc(1, sizeof(ScriptCtx)); pCtx->state = SCRIPT_STATE_INIT; pCtx->pEnv = getScriptEnvFromPool(); // diff --git a/src/tsdb/src/tsdbMeta.c b/src/tsdb/src/tsdbMeta.c index a7aa310152..8c249d3483 100644 --- a/src/tsdb/src/tsdbMeta.c +++ b/src/tsdb/src/tsdbMeta.c @@ -1373,7 +1373,7 @@ static int tsdbEncodeTableName(void **buf, tstr *name) { } static void *tsdbDecodeTableName(void *buf, tstr **name) { - VarDataLenT len = 0; + int16_t len = 0; buf = taosDecodeFixedI16(buf, &len); *name = calloc(1, sizeof(tstr) + len + 1); diff --git a/src/tsdb/src/tsdbRead.c b/src/tsdb/src/tsdbRead.c index 2126597e42..9924706f36 100644 --- a/src/tsdb/src/tsdbRead.c +++ b/src/tsdb/src/tsdbRead.c @@ -1866,11 +1866,11 @@ static int32_t doCopyRowsFromFileBlock(STsdbQueryHandle* pQueryHandle, int32_t c static void mergeTwoRowFromMem(STsdbQueryHandle* pQueryHandle, int32_t capacity, int32_t numOfRows, SMemRow row1, SMemRow row2, int32_t numOfCols, STable* pTable, STSchema* pSchema1, STSchema* pSchema2, bool forceSetNull) { - char* pData = NULL; + char* pData = NULL; STSchema* pSchema; - SMemRow row; - int16_t colId; - int16_t offset; + SMemRow row; + int16_t colId; + uint16_t offset; bool isRow1DataRow = isDataRow(row1); bool isRow2DataRow = false; @@ -4593,7 +4593,7 @@ static int32_t tsdbQueryTableList(STable* pTable, SArray* pRes, void* filterInfo return TSDB_CODE_SUCCESS; } -void* getJsonTagValueElment(void* data, char* key, int32_t keyLen, char* dst, int16_t bytes){ +void* getJsonTagValueElment(void* data, char* key, int32_t keyLen, char* dst, uint16_t bytes){ char keyMd5[TSDB_MAX_JSON_KEY_MD5_LEN] = {0}; jsonKeyMd5(key, keyLen, keyMd5); @@ -4625,7 +4625,7 @@ void* getJsonTagValueElment(void* data, char* key, int32_t keyLen, char* dst, in return result; } -void getJsonTagValueAll(void* data, void* dst, int16_t bytes) { +void getJsonTagValueAll(void* data, void* dst, uint16_t bytes) { char* json = parseTagDatatoJson(data); char* tagData = POINTER_SHIFT(dst, CHAR_BYTES); *(char*)dst = TSDB_DATA_TYPE_JSON; diff --git a/tests/script/api/resultBlock.c b/tests/script/api/resultBlock.c index 4a55a9d4a5..c2b0273f0f 100644 --- a/tests/script/api/resultBlock.c +++ b/tests/script/api/resultBlock.c @@ -121,10 +121,10 @@ static int print_result(TAOS_RES* res, int32_t rows) { case TSDB_DATA_TYPE_BINARY: case TSDB_DATA_TYPE_NCHAR: { - int32_t charLen = *(int16_t *)col[i]; + int32_t charLen = *(uint16_t *)col[i]; int32_t charBytes = (fields[i].type == TSDB_DATA_TYPE_BINARY) ? sizeof(char) : sizeof(wchar_t); - int32_t offset = k * (sizeof(int16_t) + fields[i].bytes * charBytes); - memcpy(str + len, (char *)col[i] + sizeof(int16_t) + offset, charLen); + int32_t offset = k * (sizeof(uint16_t) + fields[i].bytes * charBytes); + memcpy(str + len, (char *)col[i] + sizeof(uint16_t) + offset, charLen); len += charLen; } break; -- GitLab