diff --git a/src/client/inc/tsclient.h b/src/client/inc/tsclient.h index d60c6756d68ad2bc5d6cba0a0ea3e97beb5cdd25..6b6b8a23c60539d52985b1f4a58a9267036d6335 100644 --- a/src/client/inc/tsclient.h +++ b/src/client/inc/tsclient.h @@ -184,6 +184,7 @@ typedef struct { uint32_t allocSize; char * payload; int32_t payloadLen; + void * pBuf; // table meta buffer SHashObj *pTableMetaMap; // local buffer to keep the queried table meta, before validating the AST SQueryInfo *pQueryInfo; @@ -273,7 +274,6 @@ typedef struct SSqlObj { void * pStream; void * pSubscription; char * sqlstr; - void * pBuf; // tableMeta buffer char parseRetry; char retry; char maxRetry; diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 13fd9a8092642a2b727f61e56e35572ee3ebdb0e..18d17e9016555970eec8aa2091f10e97069d8fa8 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -7697,8 +7697,8 @@ int32_t loadAllTableMeta(SSqlObj* pSql, struct SSqlInfo* pInfo) { char name[TSDB_TABLE_FNAME_LEN] = {0}; assert(maxSize < 80 * TSDB_MAX_COLUMNS); - if (!pSql->pBuf) { - if (NULL == (pSql->pBuf = tcalloc(1, 80 * TSDB_MAX_COLUMNS))) { + if (!pSql->cmd.pBuf) { + if (NULL == (pSql->cmd.pBuf = tcalloc(1, 80 * TSDB_MAX_COLUMNS))) { return TSDB_CODE_TSC_OUT_OF_MEMORY; } } @@ -7718,7 +7718,7 @@ int32_t loadAllTableMeta(SSqlObj* pSql, struct SSqlInfo* pInfo) { if (pTableMeta->id.uid > 0) { if (pTableMeta->tableType == TSDB_CHILD_TABLE) { - code = tscCreateTableMetaFromSTableMeta(pTableMeta, name, pSql->pBuf); + code = tscCreateTableMetaFromSTableMeta(pTableMeta, name, pSql->cmd.pBuf); // create the child table meta from super table failed, try load it from mnode if (code != TSDB_CODE_SUCCESS) { diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 223c03b108ae26491e92184cb644f8e8466d2f0f..2f469a382853e4415222fdf7533a70e68d157e72 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -2596,8 +2596,8 @@ int32_t tscGetTableMetaImpl(SSqlObj* pSql, STableMetaInfo *pTableMetaInfo, bool // TODO resize the tableMeta assert(size < 80 * TSDB_MAX_COLUMNS); - if (!pSql->pBuf) { - if (NULL == (pSql->pBuf = tcalloc(1, 80 * TSDB_MAX_COLUMNS))) { + if (!pSql->cmd.pBuf) { + if (NULL == (pSql->cmd.pBuf = tcalloc(1, 80 * TSDB_MAX_COLUMNS))) { return TSDB_CODE_TSC_OUT_OF_MEMORY; } } @@ -2606,7 +2606,7 @@ int32_t tscGetTableMetaImpl(SSqlObj* pSql, STableMetaInfo *pTableMetaInfo, bool if (pMeta->id.uid > 0) { // in case of child table, here only get the if (pMeta->tableType == TSDB_CHILD_TABLE) { - int32_t code = tscCreateTableMetaFromSTableMeta(pTableMetaInfo->pTableMeta, name, pSql->pBuf); + int32_t code = tscCreateTableMetaFromSTableMeta(pTableMetaInfo->pTableMeta, name, pSql->cmd.pBuf); if (code != TSDB_CODE_SUCCESS) { return getTableMetaFromMnode(pSql, pTableMetaInfo, autocreate); } diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 2e0d5c7d8a7bda6e3dc79441a99ddac64bb5a1f3..bf997f3cbb7df27265fe741f5c957301bf644f11 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -1450,7 +1450,6 @@ void tscFreeSqlObj(SSqlObj* pSql) { pSql->signature = NULL; pSql->fp = NULL; tfree(pSql->sqlstr); - tfree(pSql->pBuf); tfree(pSql->pSubs); pSql->subState.numOfSub = 0; @@ -1461,8 +1460,9 @@ void tscFreeSqlObj(SSqlObj* pSql) { memset(pCmd->payload, 0, (size_t)pCmd->allocSize); tfree(pCmd->payload); + tfree(pCmd->pBuf); pCmd->allocSize = 0; - + tsem_destroy(&pSql->rspSem); memset(pSql, 0, sizeof(*pSql)); free(pSql); diff --git a/src/common/src/ttypes.c b/src/common/src/ttypes.c index 34dda32401b604450b3179cf0f344f53b6e2cb51..24789d01ad79e4ea448616f51edc748b1ac03975 100644 --- a/src/common/src/ttypes.c +++ b/src/common/src/ttypes.c @@ -515,7 +515,7 @@ static void *nullValues[] = { &nullTinyIntu, &nullSmallIntu, &nullIntu, &nullBigIntu, }; -void *getNullValue(int32_t type) { +const void *getNullValue(int32_t type) { assert(type >= TSDB_DATA_TYPE_BOOL && type <= TSDB_DATA_TYPE_UBIGINT); return nullValues[type - 1]; } diff --git a/src/cq/src/cqMain.c b/src/cq/src/cqMain.c index cd762f311075e7d315cf3ad9811056a909be50dc..b45234901b3f6d9c012ecb053e828df0cfb8a0eb 100644 --- a/src/cq/src/cqMain.c +++ b/src/cq/src/cqMain.c @@ -492,7 +492,7 @@ static void cqProcessStreamRes(void *param, TAOS_RES *tres, TAOS_ROW row) { STColumn *c = pSchema->columns + i; void* val = row[i]; if (val == NULL) { - val = getNullValue(c->type); + val = (void *)getNullValue(c->type); } else if (c->type == TSDB_DATA_TYPE_BINARY) { val = ((char*)val) - sizeof(VarDataLenT); } else if (c->type == TSDB_DATA_TYPE_NCHAR) { diff --git a/src/inc/taosdef.h b/src/inc/taosdef.h index f5be879878f5384dc6805fa4c2be6de77f243a90..0caf204baf37431809f3752143cbd5afdb189376 100644 --- a/src/inc/taosdef.h +++ b/src/inc/taosdef.h @@ -329,8 +329,9 @@ do { \ #define TSDB_MAX_JOIN_TABLE_NUM 10 #define TSDB_MAX_UNION_CLAUSE 5 -#define TSDB_MAX_BINARY_LEN (16384-TSDB_KEYSIZE) // keep 16384 -#define TSDB_MAX_NCHAR_LEN (16384-TSDB_KEYSIZE) // keep 16384 +#define TSDB_MAX_FIELD_LEN 16384 +#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 #define TSDB_MAX_RPC_THREADS 5 diff --git a/src/inc/ttype.h b/src/inc/ttype.h index 2581589563fc9e7ec6a6aaea222ad9971535eeab..d0266d6a5c4cd11bb3f53bf5df4557e2125e21b3 100644 --- a/src/inc/ttype.h +++ b/src/inc/ttype.h @@ -178,7 +178,7 @@ bool isValidDataType(int32_t type); void setVardataNull(char* val, int32_t type); void setNull(char *val, int32_t type, int32_t bytes); void setNullN(char *val, int32_t type, int32_t bytes, int32_t numOfElems); -void *getNullValue(int32_t type); +const void *getNullValue(int32_t type); void assignVal(char *val, const char *src, int32_t len, int32_t type); void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size, void* buf); diff --git a/src/tsdb/src/tsdbMeta.c b/src/tsdb/src/tsdbMeta.c index 621be04e216683681f276ff6181a34ffc3613ba4..b599e38e3af18e6448599c1b7424508cd51cec4b 100644 --- a/src/tsdb/src/tsdbMeta.c +++ b/src/tsdb/src/tsdbMeta.c @@ -787,7 +787,7 @@ static char *getTagIndexKey(const void *pData) { void * res = tdGetKVRowValOfCol(pTable->tagVal, pCol->colId); if (res == NULL) { // treat the column as NULL if we cannot find it - res = getNullValue(pCol->type); + res = (void *)getNullValue(pCol->type); } return res; }