check serialize result

This commit is contained in:
xsren 2024-07-21 18:57:08 +08:00
parent 99dcaaff21
commit e86189d9ea
3 changed files with 88 additions and 36 deletions

View File

@ -512,6 +512,7 @@ void appendTagNameFields(char* buf, int32_t* len, STableCfg* pCfg) {
}
int32_t appendTagValues(char* buf, int32_t* len, STableCfg* pCfg) {
int32_t code = TSDB_CODE_SUCCESS;
SArray* pTagVals = NULL;
STag* pTag = (STag*)pCfg->pTags;
@ -530,7 +531,6 @@ int32_t appendTagValues(char* buf, int32_t* len, STableCfg* pCfg) {
}
QRY_ERR_RET(tTagToValArray((const STag*)pCfg->pTags, &pTagVals));
int16_t valueNum = taosArrayGetSize(pTagVals);
int32_t num = 0;
int32_t j = 0;
@ -548,15 +548,18 @@ int32_t appendTagValues(char* buf, int32_t* len, STableCfg* pCfg) {
STagVal* pTagVal = (STagVal*)taosArrayGet(pTagVals, j);
if (pSchema->colId > pTagVal->cid) {
qError("tag value and column mismatch, schemaId:%d, valId:%d", pSchema->colId, pTagVal->cid);
TAOS_CHECK_ERRNO(TSDB_CODE_APP_ERROR);
code = TSDB_CODE_APP_ERROR;
TAOS_CHECK_ERRNO(code);
} else if (pSchema->colId == pTagVal->cid) {
char type = pTagVal->type;
int32_t tlen = 0;
if (IS_VAR_DATA_TYPE(type)) {
TAOS_CHECK_ERRNO(dataConverToStr(buf + VARSTR_HEADER_SIZE + *len, type, pTagVal->pData, pTagVal->nData, &tlen));
code = dataConverToStr(buf + VARSTR_HEADER_SIZE + *len, type, pTagVal->pData, pTagVal->nData, &tlen);
TAOS_CHECK_ERRNO(code);
} else {
TAOS_CHECK_ERRNO(dataConverToStr(buf + VARSTR_HEADER_SIZE + *len, type, &pTagVal->i64, tDataTypes[type].bytes, &tlen));
code = dataConverToStr(buf + VARSTR_HEADER_SIZE + *len, type, &pTagVal->i64, tDataTypes[type].bytes, &tlen);
TAOS_CHECK_ERRNO(code);
}
*len += tlen;
j++;
@ -596,7 +599,7 @@ int32_t appendTagValues(char* buf, int32_t* len, STableCfg* pCfg) {
_exit:
taosArrayDestroy(pTagVals);
return terrno;
return code;
}
void appendTableOptions(char* buf, int32_t* len, SDbCfgInfo* pDbCfg, STableCfg* pCfg) {
@ -661,6 +664,7 @@ void appendTableOptions(char* buf, int32_t* len, SDbCfgInfo* pDbCfg, STableCfg*
}
static int32_t setCreateTBResultIntoDataBlock(SSDataBlock* pBlock, SDbCfgInfo* pDbCfg, char* tbName, STableCfg* pCfg) {
int32_t code = TSDB_CODE_SUCCESS;
QRY_ERR_RET(blockDataEnsureCapacity(pBlock, 1));
pBlock->info.rows = 1;
@ -688,7 +692,8 @@ static int32_t setCreateTBResultIntoDataBlock(SSDataBlock* pBlock, SDbCfgInfo* p
len += sprintf(buf2 + VARSTR_HEADER_SIZE, "CREATE TABLE `%s` USING `%s` (", tbName, pCfg->stbName);
appendTagNameFields(buf2, &len, pCfg);
len += sprintf(buf2 + VARSTR_HEADER_SIZE + len, ") TAGS (");
TAOS_CHECK_ERRNO(appendTagValues(buf2, &len, pCfg));
code = appendTagValues(buf2, &len, pCfg);
TAOS_CHECK_ERRNO(code);
len += sprintf(buf2 + VARSTR_HEADER_SIZE + len, ")");
appendTableOptions(buf2, &len, pDbCfg, pCfg);
} else {
@ -700,12 +705,13 @@ static int32_t setCreateTBResultIntoDataBlock(SSDataBlock* pBlock, SDbCfgInfo* p
varDataLen(buf2) = (len > 65535) ? 65535 : len;
TAOS_CHECK_ERRNO(colDataSetVal(pCol2, 0, buf2, false));
code = colDataSetVal(pCol2, 0, buf2, false);
TAOS_CHECK_ERRNO(code);
_exit:
taosMemoryFree(buf2);
return terrno;
return code;
}
static int32_t setCreateViewResultIntoDataBlock(SSDataBlock* pBlock, SShowCreateViewStmt* pStmt) {
@ -731,12 +737,10 @@ static int32_t setCreateViewResultIntoDataBlock(SSDataBlock* pBlock, SShowCreate
pStmt->dbName, pStmt->viewName, pMeta->querySql);
int32_t len = strlen(varDataVal(buf2));
varDataLen(buf2) = (len > 65535) ? 65535 : len;
TAOS_CHECK_ERRNO(colDataSetVal(pCol2, 0, buf2, false));
_exit:
code = colDataSetVal(pCol2, 0, buf2, false);
taosMemoryFree(buf2);
return terrno;
return code;
}
static int32_t execShowCreateTable(SShowCreateTableStmt* pStmt, SRetrieveTableRsp** pRsp) {

View File

@ -2100,26 +2100,30 @@ int32_t qExplainUpdateExecInfo(SExplainCtx *pCtx, SExplainRsp *pRspMsg, int32_t
group->nodeExecInfo = taosArrayInit(group->nodeNum, sizeof(SExplainRsp));
if (NULL == group->nodeExecInfo) {
qError("taosArrayInit %d explainExecInfo failed", group->nodeNum);
terrno = TSDB_CODE_OUT_OF_MEMORY;
goto _exit;
code = TSDB_CODE_OUT_OF_MEMORY;
TAOS_CHECK_ERRNO(code);
}
group->physiPlanExecNum = pRspMsg->numOfPlans;
} else if (taosArrayGetSize(group->nodeExecInfo) >= group->nodeNum) {
qError("group execInfo already full, size:%d, nodeNum:%d", (int32_t)taosArrayGetSize(group->nodeExecInfo),
group->nodeNum);
terrno = TSDB_CODE_APP_ERROR;
goto _exit;
code = TSDB_CODE_APP_ERROR;
TAOS_CHECK_ERRNO(code);
}
if (group->physiPlanExecNum != pRspMsg->numOfPlans) {
qError("physiPlanExecNum %d mismatch with others %d in group %d", pRspMsg->numOfPlans, group->physiPlanExecNum,
groupId);
terrno = TSDB_CODE_APP_ERROR;
goto _exit;
code = TSDB_CODE_APP_ERROR;
TAOS_CHECK_ERRNO(code);
}
if(taosArrayPush(group->nodeExecInfo, pRspMsg) == NULL) goto _exit;
if(taosArrayPush(group->nodeExecInfo, pRspMsg) == NULL)
{
code = TSDB_CODE_OUT_OF_MEMORY;
TAOS_CHECK_ERRNO(code);
}
groupDone = (taosArrayGetSize(group->nodeExecInfo) >= group->nodeNum);
@ -2139,7 +2143,7 @@ int32_t qExplainUpdateExecInfo(SExplainCtx *pCtx, SExplainRsp *pRspMsg, int32_t
_exit:
tFreeSExplainRsp(pRspMsg);
taosWUnLockLatch(&group->lock);
return terrno;
return code;
}
int32_t qExecStaticExplain(SQueryPlan *pDag, SRetrieveTableRsp **pRsp) {

View File

@ -85,7 +85,10 @@ int32_t queryBuildTableMetaReqMsg(void *input, char **msg, int32_t msgSize, int3
int32_t bufLen = tSerializeSTableInfoReq(NULL, 0, &infoReq);
void *pBuf = (*mallcFp)(bufLen);
(void)tSerializeSTableInfoReq(pBuf, bufLen, &infoReq);
if(tSerializeSTableInfoReq(pBuf, bufLen, &infoReq) < 0)
{
return TSDB_CODE_TSC_INVALID_INPUT;
}
*msg = pBuf;
*msgLen = bufLen;
@ -109,7 +112,10 @@ int32_t queryBuildUseDbMsg(void *input, char **msg, int32_t msgSize, int32_t *ms
int32_t bufLen = tSerializeSUseDbReq(NULL, 0, &usedbReq);
void *pBuf = (*mallcFp)(bufLen);
(void)tSerializeSUseDbReq(pBuf, bufLen, &usedbReq);
if(tSerializeSUseDbReq(pBuf, bufLen, &usedbReq) < 0)
{
return TSDB_CODE_TSC_INVALID_INPUT;
}
*msg = pBuf;
*msgLen = bufLen;
@ -127,7 +133,10 @@ int32_t queryBuildQnodeListMsg(void *input, char **msg, int32_t msgSize, int32_t
int32_t bufLen = tSerializeSQnodeListReq(NULL, 0, &qnodeListReq);
void *pBuf = (*mallcFp)(bufLen);
(void)tSerializeSQnodeListReq(pBuf, bufLen, &qnodeListReq);
if(tSerializeSQnodeListReq(pBuf, bufLen, &qnodeListReq) < 0)
{
return TSDB_CODE_TSC_INVALID_INPUT;
}
*msg = pBuf;
*msgLen = bufLen;
@ -145,7 +154,10 @@ int32_t queryBuildDnodeListMsg(void *input, char **msg, int32_t msgSize, int32_t
int32_t bufLen = tSerializeSDnodeListReq(NULL, 0, &dnodeListReq);
void *pBuf = (*mallcFp)(bufLen);
(void)tSerializeSDnodeListReq(pBuf, bufLen, &dnodeListReq);
if(tSerializeSDnodeListReq(pBuf, bufLen, &dnodeListReq) < 0)
{
return TSDB_CODE_TSC_INVALID_INPUT;
}
*msg = pBuf;
*msgLen = bufLen;
@ -162,7 +174,10 @@ int32_t queryBuildGetSerVerMsg(void *input, char **msg, int32_t msgSize, int32_t
int32_t bufLen = tSerializeSServerVerReq(NULL, 0, &req);
void *pBuf = (*mallcFp)(bufLen);
(void)tSerializeSServerVerReq(pBuf, bufLen, &req);
if(tSerializeSServerVerReq(pBuf, bufLen, &req) < 0)
{
return TSDB_CODE_TSC_INVALID_INPUT;
}
*msg = pBuf;
*msgLen = bufLen;
@ -180,7 +195,10 @@ int32_t queryBuildGetDBCfgMsg(void *input, char **msg, int32_t msgSize, int32_t
int32_t bufLen = tSerializeSDbCfgReq(NULL, 0, &dbCfgReq);
void *pBuf = (*mallcFp)(bufLen);
(void)tSerializeSDbCfgReq(pBuf, bufLen, &dbCfgReq);
if(tSerializeSDbCfgReq(pBuf, bufLen, &dbCfgReq) < 0)
{
return TSDB_CODE_TSC_INVALID_INPUT;
}
*msg = pBuf;
*msgLen = bufLen;
@ -198,7 +216,10 @@ int32_t queryBuildGetIndexMsg(void *input, char **msg, int32_t msgSize, int32_t
int32_t bufLen = tSerializeSUserIndexReq(NULL, 0, &indexReq);
void *pBuf = (*mallcFp)(bufLen);
(void)tSerializeSUserIndexReq(pBuf, bufLen, &indexReq);
if(tSerializeSUserIndexReq(pBuf, bufLen, &indexReq) < 0)
{
return TSDB_CODE_TSC_INVALID_INPUT;
}
*msg = pBuf;
*msgLen = bufLen;
@ -221,12 +242,15 @@ int32_t queryBuildRetrieveFuncMsg(void *input, char **msg, int32_t msgSize, int3
}
if (taosArrayPush(funcReq.pFuncNames, input) == NULL) {
taosArrayDestroy(funcReq.pFuncNames);
return terrno;
return TSDB_CODE_OUT_OF_MEMORY;
}
int32_t bufLen = tSerializeSRetrieveFuncReq(NULL, 0, &funcReq);
void *pBuf = (*mallcFp)(bufLen);
(void)tSerializeSRetrieveFuncReq(pBuf, bufLen, &funcReq);
if(tSerializeSRetrieveFuncReq(pBuf, bufLen, &funcReq) < 0)
{
return TSDB_CODE_TSC_INVALID_INPUT;
}
taosArrayDestroy(funcReq.pFuncNames);
@ -246,7 +270,9 @@ int32_t queryBuildGetUserAuthMsg(void *input, char **msg, int32_t msgSize, int32
int32_t bufLen = tSerializeSGetUserAuthReq(NULL, 0, &req);
void *pBuf = (*mallcFp)(bufLen);
(void)tSerializeSGetUserAuthReq(pBuf, bufLen, &req);
if (tSerializeSGetUserAuthReq(pBuf, bufLen, &req) < 0) {
return TSDB_CODE_TSC_INVALID_INPUT;
}
*msg = pBuf;
*msgLen = bufLen;
@ -264,7 +290,10 @@ int32_t queryBuildGetTbIndexMsg(void *input, char **msg, int32_t msgSize, int32_
int32_t bufLen = tSerializeSTableIndexReq(NULL, 0, &indexReq);
void *pBuf = (*mallcFp)(bufLen);
(void)tSerializeSTableIndexReq(pBuf, bufLen, &indexReq);
if(tSerializeSTableIndexReq(pBuf, bufLen, &indexReq) < 0)
{
return TSDB_CODE_TSC_INVALID_INPUT;
}
*msg = pBuf;
*msgLen = bufLen;
@ -285,7 +314,10 @@ int32_t queryBuildGetTbCfgMsg(void *input, char **msg, int32_t msgSize, int32_t
int32_t bufLen = tSerializeSTableCfgReq(NULL, 0, &cfgReq);
void *pBuf = (*mallcFp)(bufLen);
(void)tSerializeSTableCfgReq(pBuf, bufLen, &cfgReq);
if(tSerializeSTableCfgReq(pBuf, bufLen, &cfgReq) < 0)
{
return TSDB_CODE_TSC_INVALID_INPUT;
}
*msg = pBuf;
*msgLen = bufLen;
@ -303,7 +335,10 @@ int32_t queryBuildGetViewMetaMsg(void *input, char **msg, int32_t msgSize, int32
int32_t bufLen = tSerializeSViewMetaReq(NULL, 0, &req);
void *pBuf = (*mallcFp)(bufLen);
(void)tSerializeSViewMetaReq(pBuf, bufLen, &req);
if(tSerializeSViewMetaReq(pBuf, bufLen, &req) < 0)
{
return TSDB_CODE_TSC_INVALID_INPUT;
}
*msg = pBuf;
*msgLen = bufLen;
@ -322,7 +357,10 @@ int32_t queryBuildGetTableTSMAMsg(void *input, char **msg, int32_t msgSize, int3
int32_t bufLen = tSerializeTableTSMAInfoReq(NULL, 0, &req);
void * pBuf = (*mallcFp)(bufLen);
(void)tSerializeTableTSMAInfoReq(pBuf, bufLen, &req);
if(tSerializeTableTSMAInfoReq(pBuf, bufLen, &req) < 0)
{
return TSDB_CODE_TSC_INVALID_INPUT;
}
*msg = pBuf;
*msgLen = bufLen;
@ -341,7 +379,10 @@ int32_t queryBuildGetTSMAMsg(void *input, char **msg, int32_t msgSize, int32_t *
int32_t bufLen = tSerializeTableTSMAInfoReq(NULL, 0, &req);
void * pBuf = (*mallcFp)(bufLen);
(void)tSerializeTableTSMAInfoReq(pBuf, bufLen, &req);
if(tSerializeTableTSMAInfoReq(pBuf, bufLen, &req) < 0)
{
return TSDB_CODE_TSC_INVALID_INPUT;
}
*msg = pBuf;
*msgLen = bufLen;
@ -356,7 +397,10 @@ int32_t queryBuildGetStreamProgressMsg(void* input, char** msg, int32_t msgSize,
int32_t len = tSerializeStreamProgressReq(NULL, 0, input);
void* pBuf = (*mallcFp)(len);
(void)tSerializeStreamProgressReq(pBuf, len, input);
if(tSerializeStreamProgressReq(pBuf, len, input) < 0)
{
return TSDB_CODE_TSC_INVALID_INPUT;
}
*msg = pBuf;
*msgLen = len;