Merge pull request #12017 from taosdata/feature/qnode

fix: fix hb crash issue
This commit is contained in:
dapan1121 2022-04-29 16:38:48 +08:00 committed by GitHub
commit 190b702953
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 559 additions and 196 deletions

View File

@ -88,6 +88,7 @@ typedef struct SValueNode {
double d; double d;
char* p; char* p;
} datum; } datum;
int64_t typeData;
char unit; char unit;
} SValueNode; } SValueNode;
@ -313,6 +314,7 @@ bool nodesIsTimeorderQuery(const SNode* pQuery);
bool nodesIsTimelineQuery(const SNode* pQuery); bool nodesIsTimelineQuery(const SNode* pQuery);
void* nodesGetValueFromNode(SValueNode* pNode); void* nodesGetValueFromNode(SValueNode* pNode);
int32_t nodesSetValueNodeValue(SValueNode* pNode, void *value);
char* nodesGetStrValueFromNode(SValueNode* pNode); char* nodesGetStrValueFromNode(SValueNode* pNode);
char* getFillModeString(EFillMode mode); char* getFillModeString(EFillMode mode);
void valueNodeToVariant(const SValueNode* pNode, SVariant* pVal); void valueNodeToVariant(const SValueNode* pNode, SVariant* pVal);

View File

@ -46,11 +46,12 @@ typedef struct SStmtTableCache {
void* boundTags; void* boundTags;
} SStmtTableCache; } SStmtTableCache;
typedef struct SQueryFields { typedef struct SStmtQueryResInfo {
TAOS_FIELD* fields; TAOS_FIELD* fields;
TAOS_FIELD* userFields; TAOS_FIELD* userFields;
uint32_t numOfCols; uint32_t numOfCols;
} SQueryFields; int32_t precision;
} SStmtQueryResInfo;
typedef struct SStmtBindInfo { typedef struct SStmtBindInfo {
bool needParse; bool needParse;
@ -72,17 +73,17 @@ typedef struct SStmtExecInfo {
} SStmtExecInfo; } SStmtExecInfo;
typedef struct SStmtSQLInfo { typedef struct SStmtSQLInfo {
STMT_TYPE type; STMT_TYPE type;
STMT_STATUS status; STMT_STATUS status;
bool autoCreate; bool autoCreate;
uint64_t runTimes; uint64_t runTimes;
SHashObj* pTableCache; //SHash<SStmtTableCache> SHashObj* pTableCache; //SHash<SStmtTableCache>
SQuery* pQuery; SQuery* pQuery;
char* sqlStr; char* sqlStr;
int32_t sqlLen; int32_t sqlLen;
SArray* nodeList; SArray* nodeList;
SQueryPlan* pQueryPlan; SQueryPlan* pQueryPlan;
SQueryFields fields; SStmtQueryResInfo queryRes;
} SStmtSQLInfo; } SStmtSQLInfo;
typedef struct STscStmt { typedef struct STscStmt {

View File

@ -74,17 +74,44 @@ int32_t stmtGetTbName(TAOS_STMT *stmt, char **tbName) {
} }
int32_t stmtBackupQueryFields(STscStmt* pStmt) { int32_t stmtBackupQueryFields(STscStmt* pStmt) {
SQueryFields *pFields = &pStmt->sql.fields; SStmtQueryResInfo *pRes = &pStmt->sql.queryRes;
int32_t size = pFields->numOfCols * sizeof(TAOS_FIELD); pRes->numOfCols = pStmt->exec.pRequest->body.resInfo.numOfCols;
pRes->precision = pStmt->exec.pRequest->body.resInfo.precision;
pFields->numOfCols = pStmt->exec.pRequest->body.resInfo.numOfCols; int32_t size = pRes->numOfCols * sizeof(TAOS_FIELD);
pFields->fields = taosMemoryMalloc(size); pRes->fields = taosMemoryMalloc(size);
pFields->userFields = taosMemoryMalloc(size); pRes->userFields = taosMemoryMalloc(size);
if (NULL == pFields->fields || NULL == pFields->userFields) { if (NULL == pRes->fields || NULL == pRes->userFields) {
STMT_ERR_RET(TSDB_CODE_TSC_OUT_OF_MEMORY); STMT_ERR_RET(TSDB_CODE_TSC_OUT_OF_MEMORY);
} }
memcpy(pFields->fields, pStmt->exec.pRequest->body.resInfo.fields, size); memcpy(pRes->fields, pStmt->exec.pRequest->body.resInfo.fields, size);
memcpy(pFields->userFields, pStmt->exec.pRequest->body.resInfo.userFields, size); memcpy(pRes->userFields, pStmt->exec.pRequest->body.resInfo.userFields, size);
return TSDB_CODE_SUCCESS;
}
int32_t stmtRestoreQueryFields(STscStmt* pStmt) {
SStmtQueryResInfo *pRes = &pStmt->sql.queryRes;
int32_t size = pRes->numOfCols * sizeof(TAOS_FIELD);
pStmt->exec.pRequest->body.resInfo.numOfCols = pRes->numOfCols;
pStmt->exec.pRequest->body.resInfo.precision = pRes->precision;
if (NULL == pStmt->exec.pRequest->body.resInfo.fields) {
pStmt->exec.pRequest->body.resInfo.fields = taosMemoryMalloc(size);
if (NULL == pStmt->exec.pRequest->body.resInfo.fields) {
STMT_ERR_RET(TSDB_CODE_TSC_OUT_OF_MEMORY);
}
memcpy(pStmt->exec.pRequest->body.resInfo.fields, pRes->fields, size);
}
if (NULL == pStmt->exec.pRequest->body.resInfo.userFields) {
pStmt->exec.pRequest->body.resInfo.userFields = taosMemoryMalloc(size);
if (NULL == pStmt->exec.pRequest->body.resInfo.userFields) {
STMT_ERR_RET(TSDB_CODE_TSC_OUT_OF_MEMORY);
}
memcpy(pStmt->exec.pRequest->body.resInfo.userFields, pRes->userFields, size);
}
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
@ -235,6 +262,8 @@ int32_t stmtCleanExecInfo(STscStmt* pStmt, bool keepTable, bool freeRequest) {
} }
int32_t stmtCleanSQLInfo(STscStmt* pStmt) { int32_t stmtCleanSQLInfo(STscStmt* pStmt) {
taosMemoryFree(pStmt->sql.queryRes.fields);
taosMemoryFree(pStmt->sql.queryRes.userFields);
taosMemoryFree(pStmt->sql.sqlStr); taosMemoryFree(pStmt->sql.sqlStr);
qDestroyQuery(pStmt->sql.pQuery); qDestroyQuery(pStmt->sql.pQuery);
qDestroyQueryPlan(pStmt->sql.pQueryPlan); qDestroyQueryPlan(pStmt->sql.pQueryPlan);
@ -497,6 +526,8 @@ int stmtBindBatch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind, int32_t colIdx) {
pStmt->sql.pQueryPlan = pStmt->exec.pRequest->body.pDag; pStmt->sql.pQueryPlan = pStmt->exec.pRequest->body.pDag;
pStmt->exec.pRequest->body.pDag = NULL; pStmt->exec.pRequest->body.pDag = NULL;
STMT_ERR_RET(stmtBackupQueryFields(pStmt)); STMT_ERR_RET(stmtBackupQueryFields(pStmt));
} else {
STMT_ERR_RET(stmtRestoreQueryFields(pStmt));
} }
STMT_RET(qStmtBindParam(pStmt->sql.pQueryPlan, bind, colIdx, pStmt->exec.pRequest->requestId)); STMT_RET(qStmtBindParam(pStmt->sql.pQueryPlan, bind, colIdx, pStmt->exec.pRequest->requestId));
@ -509,7 +540,11 @@ int stmtBindBatch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind, int32_t colIdx) {
} }
if (colIdx < 0) { if (colIdx < 0) {
qBindStmtColsValue(*pDataBlock, bind, pStmt->exec.pRequest->msgBuf, pStmt->exec.pRequest->msgBufLen); int32_t code = qBindStmtColsValue(*pDataBlock, bind, pStmt->exec.pRequest->msgBuf, pStmt->exec.pRequest->msgBufLen);
if (code) {
tscError("qBindStmtColsValue failed, error:%s", tstrerror(code));
STMT_ERR_RET(code);
}
} else { } else {
if (colIdx != (pStmt->bInfo.sBindLastIdx + 1) && colIdx != 0) { if (colIdx != (pStmt->bInfo.sBindLastIdx + 1) && colIdx != 0) {
tscError("bind column index not in sequence"); tscError("bind column index not in sequence");

View File

@ -47,7 +47,7 @@ typedef int32_t (*MndInitFp)(SMnode *pMnode);
typedef void (*MndCleanupFp)(SMnode *pMnode); typedef void (*MndCleanupFp)(SMnode *pMnode);
typedef int32_t (*ShowRetrieveFp)(SNodeMsg *pMsg, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows); typedef int32_t (*ShowRetrieveFp)(SNodeMsg *pMsg, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
typedef void (*ShowFreeIterFp)(SMnode *pMnode, void *pIter); typedef void (*ShowFreeIterFp)(SMnode *pMnode, void *pIter);
typedef struct SQWorkerMgmt SQHandle; typedef struct SQWorker SQHandle;
typedef struct { typedef struct {
const char *name; const char *name;

View File

@ -29,7 +29,7 @@
extern "C" { extern "C" {
#endif #endif
typedef struct SQWorkerMgmt SQHandle; typedef struct SQWorker SQHandle;
typedef struct SQnode { typedef struct SQnode {
int32_t qndId; int32_t qndId;

View File

@ -52,7 +52,7 @@ typedef struct STsdb STsdb;
typedef struct STQ STQ; typedef struct STQ STQ;
typedef struct SVState SVState; typedef struct SVState SVState;
typedef struct SVBufPool SVBufPool; typedef struct SVBufPool SVBufPool;
typedef struct SQWorkerMgmt SQHandle; typedef struct SQWorker SQHandle;
#define VNODE_META_DIR "meta" #define VNODE_META_DIR "meta"
#define VNODE_TSDB_DIR "tsdb" #define VNODE_TSDB_DIR "tsdb"

View File

@ -1911,23 +1911,51 @@ static int32_t jsonToDatum(const SJson* pJson, void* pObj) {
break; break;
case TSDB_DATA_TYPE_BOOL: case TSDB_DATA_TYPE_BOOL:
code = tjsonGetBoolValue(pJson, jkValueDatum, &pNode->datum.b); code = tjsonGetBoolValue(pJson, jkValueDatum, &pNode->datum.b);
*(bool*)&pNode->typeData = pNode->datum.b;
break; break;
case TSDB_DATA_TYPE_TINYINT: case TSDB_DATA_TYPE_TINYINT:
code = tjsonGetBigIntValue(pJson, jkValueDatum, &pNode->datum.i);
*(int8_t*)&pNode->typeData = pNode->datum.i;
break;
case TSDB_DATA_TYPE_SMALLINT: case TSDB_DATA_TYPE_SMALLINT:
code = tjsonGetBigIntValue(pJson, jkValueDatum, &pNode->datum.i);
*(int16_t*)&pNode->typeData = pNode->datum.i;
break;
case TSDB_DATA_TYPE_INT: case TSDB_DATA_TYPE_INT:
code = tjsonGetBigIntValue(pJson, jkValueDatum, &pNode->datum.i);
*(int32_t*)&pNode->typeData = pNode->datum.i;
break;
case TSDB_DATA_TYPE_BIGINT: case TSDB_DATA_TYPE_BIGINT:
code = tjsonGetBigIntValue(pJson, jkValueDatum, &pNode->datum.i);
*(int64_t*)&pNode->typeData = pNode->datum.i;
break;
case TSDB_DATA_TYPE_TIMESTAMP: case TSDB_DATA_TYPE_TIMESTAMP:
code = tjsonGetBigIntValue(pJson, jkValueDatum, &pNode->datum.i); code = tjsonGetBigIntValue(pJson, jkValueDatum, &pNode->datum.i);
*(int64_t*)&pNode->typeData = pNode->datum.i;
break; break;
case TSDB_DATA_TYPE_UTINYINT: case TSDB_DATA_TYPE_UTINYINT:
code = tjsonGetUBigIntValue(pJson, jkValueDatum, &pNode->datum.u);
*(uint8_t*)&pNode->typeData = pNode->datum.u;
break;
case TSDB_DATA_TYPE_USMALLINT: case TSDB_DATA_TYPE_USMALLINT:
code = tjsonGetUBigIntValue(pJson, jkValueDatum, &pNode->datum.u);
*(uint16_t*)&pNode->typeData = pNode->datum.u;
break;
case TSDB_DATA_TYPE_UINT: case TSDB_DATA_TYPE_UINT:
code = tjsonGetUBigIntValue(pJson, jkValueDatum, &pNode->datum.u);
*(uint32_t*)&pNode->typeData = pNode->datum.u;
break;
case TSDB_DATA_TYPE_UBIGINT: case TSDB_DATA_TYPE_UBIGINT:
code = tjsonGetUBigIntValue(pJson, jkValueDatum, &pNode->datum.u); code = tjsonGetUBigIntValue(pJson, jkValueDatum, &pNode->datum.u);
*(uint64_t*)&pNode->typeData = pNode->datum.u;
break; break;
case TSDB_DATA_TYPE_FLOAT: case TSDB_DATA_TYPE_FLOAT:
code = tjsonGetDoubleValue(pJson, jkValueDatum, &pNode->datum.d);
*(float*)&pNode->typeData = pNode->datum.d;
break;
case TSDB_DATA_TYPE_DOUBLE: case TSDB_DATA_TYPE_DOUBLE:
code = tjsonGetDoubleValue(pJson, jkValueDatum, &pNode->datum.d); code = tjsonGetDoubleValue(pJson, jkValueDatum, &pNode->datum.d);
*(double*)&pNode->typeData = pNode->datum.d;
break; break;
case TSDB_DATA_TYPE_NCHAR: case TSDB_DATA_TYPE_NCHAR:
case TSDB_DATA_TYPE_VARCHAR: case TSDB_DATA_TYPE_VARCHAR:

View File

@ -871,21 +871,18 @@ void nodesClearList(SNodeList* pList) {
void* nodesGetValueFromNode(SValueNode* pNode) { void* nodesGetValueFromNode(SValueNode* pNode) {
switch (pNode->node.resType.type) { switch (pNode->node.resType.type) {
case TSDB_DATA_TYPE_BOOL: case TSDB_DATA_TYPE_BOOL:
return (void*)&pNode->datum.b;
case TSDB_DATA_TYPE_TINYINT: case TSDB_DATA_TYPE_TINYINT:
case TSDB_DATA_TYPE_SMALLINT: case TSDB_DATA_TYPE_SMALLINT:
case TSDB_DATA_TYPE_INT: case TSDB_DATA_TYPE_INT:
case TSDB_DATA_TYPE_BIGINT: case TSDB_DATA_TYPE_BIGINT:
case TSDB_DATA_TYPE_TIMESTAMP: case TSDB_DATA_TYPE_TIMESTAMP:
return (void*)&pNode->datum.i;
case TSDB_DATA_TYPE_UTINYINT: case TSDB_DATA_TYPE_UTINYINT:
case TSDB_DATA_TYPE_USMALLINT: case TSDB_DATA_TYPE_USMALLINT:
case TSDB_DATA_TYPE_UINT: case TSDB_DATA_TYPE_UINT:
case TSDB_DATA_TYPE_UBIGINT: case TSDB_DATA_TYPE_UBIGINT:
return (void*)&pNode->datum.u;
case TSDB_DATA_TYPE_FLOAT: case TSDB_DATA_TYPE_FLOAT:
case TSDB_DATA_TYPE_DOUBLE: case TSDB_DATA_TYPE_DOUBLE:
return (void*)&pNode->datum.d; return (void*)&pNode->typeData;
case TSDB_DATA_TYPE_NCHAR: case TSDB_DATA_TYPE_NCHAR:
case TSDB_DATA_TYPE_VARCHAR: case TSDB_DATA_TYPE_VARCHAR:
case TSDB_DATA_TYPE_VARBINARY: case TSDB_DATA_TYPE_VARBINARY:
@ -897,6 +894,68 @@ void* nodesGetValueFromNode(SValueNode* pNode) {
return NULL; return NULL;
} }
int32_t nodesSetValueNodeValue(SValueNode* pNode, void *value) {
switch (pNode->node.resType.type) {
case TSDB_DATA_TYPE_BOOL:
pNode->datum.b = *(bool*)value;
*(bool*)&pNode->typeData = pNode->datum.b;
break;
case TSDB_DATA_TYPE_TINYINT:
pNode->datum.i = *(int8_t*)value;
*(int8_t*)&pNode->typeData = pNode->datum.i;
break;
case TSDB_DATA_TYPE_SMALLINT:
pNode->datum.i = *(int16_t*)value;
*(int16_t*)&pNode->typeData = pNode->datum.i;
break;
case TSDB_DATA_TYPE_INT:
pNode->datum.i = *(int32_t*)value;
*(int32_t*)&pNode->typeData = pNode->datum.i;
break;
case TSDB_DATA_TYPE_BIGINT:
pNode->datum.i = *(int64_t*)value;
*(int64_t*)&pNode->typeData = pNode->datum.i;
break;
case TSDB_DATA_TYPE_TIMESTAMP:
pNode->datum.i = *(int64_t*)value;
*(int64_t*)&pNode->typeData = pNode->datum.i;
break;
case TSDB_DATA_TYPE_UTINYINT:
pNode->datum.u = *(int8_t*)value;
*(int8_t*)&pNode->typeData = pNode->datum.u;
break;
case TSDB_DATA_TYPE_USMALLINT:
pNode->datum.u = *(int16_t*)value;
*(int16_t*)&pNode->typeData = pNode->datum.u;
break;
case TSDB_DATA_TYPE_UINT:
pNode->datum.u = *(int32_t*)value;
*(int32_t*)&pNode->typeData = pNode->datum.u;
break;
case TSDB_DATA_TYPE_UBIGINT:
pNode->datum.u = *(uint64_t*)value;
*(uint64_t*)&pNode->typeData = pNode->datum.u;
break;
case TSDB_DATA_TYPE_FLOAT:
pNode->datum.d = *(float*)value;
*(float*)&pNode->typeData = pNode->datum.d;
break;
case TSDB_DATA_TYPE_DOUBLE:
pNode->datum.d = *(double*)value;
*(double*)&pNode->typeData = pNode->datum.d;
break;
case TSDB_DATA_TYPE_NCHAR:
case TSDB_DATA_TYPE_VARCHAR:
case TSDB_DATA_TYPE_VARBINARY:
pNode->datum.p = (char*)value;
break;
default:
return TSDB_CODE_QRY_APP_ERROR;
}
return TSDB_CODE_SUCCESS;
}
char* nodesGetStrValueFromNode(SValueNode* pNode) { char* nodesGetStrValueFromNode(SValueNode* pNode) {
switch (pNode->node.resType.type) { switch (pNode->node.resType.type) {
case TSDB_DATA_TYPE_BOOL: { case TSDB_DATA_TYPE_BOOL: {

View File

@ -466,27 +466,66 @@ static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) {
break; break;
case TSDB_DATA_TYPE_BOOL: case TSDB_DATA_TYPE_BOOL:
pVal->datum.b = (0 == strcasecmp(pVal->literal, "true")); pVal->datum.b = (0 == strcasecmp(pVal->literal, "true"));
*(bool*)&pVal->typeData = pVal->datum.b;
break; break;
case TSDB_DATA_TYPE_TINYINT: case TSDB_DATA_TYPE_TINYINT:{
case TSDB_DATA_TYPE_SMALLINT: char* endPtr = NULL;
case TSDB_DATA_TYPE_INT: pVal->datum.i = strtoll(pVal->literal, &endPtr, 10);
*(int8_t*)&pVal->typeData = pVal->datum.i;
break;
}
case TSDB_DATA_TYPE_SMALLINT:{
char* endPtr = NULL;
pVal->datum.i = strtoll(pVal->literal, &endPtr, 10);
*(int16_t*)&pVal->typeData = pVal->datum.i;
break;
}
case TSDB_DATA_TYPE_INT:{
char* endPtr = NULL;
pVal->datum.i = strtoll(pVal->literal, &endPtr, 10);
*(int32_t*)&pVal->typeData = pVal->datum.i;
break;
}
case TSDB_DATA_TYPE_BIGINT: { case TSDB_DATA_TYPE_BIGINT: {
char* endPtr = NULL; char* endPtr = NULL;
pVal->datum.i = strtoll(pVal->literal, &endPtr, 10); pVal->datum.i = strtoll(pVal->literal, &endPtr, 10);
*(int64_t*)&pVal->typeData = pVal->datum.i;
break;
}
case TSDB_DATA_TYPE_UTINYINT:{
char* endPtr = NULL;
pVal->datum.u = strtoull(pVal->literal, &endPtr, 10);
*(uint8_t*)&pVal->typeData = pVal->datum.u;
break;
}
case TSDB_DATA_TYPE_USMALLINT:{
char* endPtr = NULL;
pVal->datum.u = strtoull(pVal->literal, &endPtr, 10);
*(uint16_t*)&pVal->typeData = pVal->datum.u;
break;
}
case TSDB_DATA_TYPE_UINT:{
char* endPtr = NULL;
pVal->datum.u = strtoull(pVal->literal, &endPtr, 10);
*(uint32_t*)&pVal->typeData = pVal->datum.u;
break; break;
} }
case TSDB_DATA_TYPE_UTINYINT:
case TSDB_DATA_TYPE_USMALLINT:
case TSDB_DATA_TYPE_UINT:
case TSDB_DATA_TYPE_UBIGINT: { case TSDB_DATA_TYPE_UBIGINT: {
char* endPtr = NULL; char* endPtr = NULL;
pVal->datum.u = strtoull(pVal->literal, &endPtr, 10); pVal->datum.u = strtoull(pVal->literal, &endPtr, 10);
*(uint64_t*)&pVal->typeData = pVal->datum.u;
break;
}
case TSDB_DATA_TYPE_FLOAT:{
char* endPtr = NULL;
pVal->datum.d = strtold(pVal->literal, &endPtr);
*(float*)&pVal->typeData = pVal->datum.d;
break; break;
} }
case TSDB_DATA_TYPE_FLOAT:
case TSDB_DATA_TYPE_DOUBLE: { case TSDB_DATA_TYPE_DOUBLE: {
char* endPtr = NULL; char* endPtr = NULL;
pVal->datum.d = strtold(pVal->literal, &endPtr); pVal->datum.d = strtold(pVal->literal, &endPtr);
*(double*)&pVal->typeData = pVal->datum.d;
break; break;
} }
case TSDB_DATA_TYPE_VARCHAR: case TSDB_DATA_TYPE_VARCHAR:
@ -504,6 +543,7 @@ static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) {
TSDB_CODE_SUCCESS) { TSDB_CODE_SUCCESS) {
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal); return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal);
} }
*(int64_t*)&pVal->typeData = pVal->datum.i;
break; break;
} }
case TSDB_DATA_TYPE_NCHAR: case TSDB_DATA_TYPE_NCHAR:

View File

@ -206,6 +206,8 @@ static int32_t cpdMergeCond(SNode** pDst, SNode** pSrc) {
if (NULL == pLogicCond) { if (NULL == pLogicCond) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
pLogicCond->node.resType.type = TSDB_DATA_TYPE_BOOL;
pLogicCond->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_BOOL].bytes;
pLogicCond->condType = LOGIC_COND_TYPE_AND; pLogicCond->condType = LOGIC_COND_TYPE_AND;
int32_t code = nodesListMakeAppend(&pLogicCond->pParameterList, *pSrc); int32_t code = nodesListMakeAppend(&pLogicCond->pParameterList, *pSrc);
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {

View File

@ -104,8 +104,9 @@ static int32_t setValueByBindParam(SValueNode* pVal, TAOS_MULTI_BIND* pParam) {
pVal->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_NULL].bytes; pVal->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_NULL].bytes;
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t inputSize = (NULL != pParam->length ? *(pParam->length) : tDataTypes[pParam->buffer_type].bytes);
pVal->node.resType.type = pParam->buffer_type; pVal->node.resType.type = pParam->buffer_type;
pVal->node.resType.bytes = NULL != pParam->length ? *(pParam->length) : tDataTypes[pParam->buffer_type].bytes; pVal->node.resType.bytes = inputSize;
switch (pParam->buffer_type) { switch (pParam->buffer_type) {
case TSDB_DATA_TYPE_BOOL: case TSDB_DATA_TYPE_BOOL:
pVal->datum.b = *((bool*)pParam->buffer); pVal->datum.b = *((bool*)pParam->buffer);
@ -130,7 +131,6 @@ static int32_t setValueByBindParam(SValueNode* pVal, TAOS_MULTI_BIND* pParam) {
break; break;
case TSDB_DATA_TYPE_VARCHAR: case TSDB_DATA_TYPE_VARCHAR:
case TSDB_DATA_TYPE_VARBINARY: case TSDB_DATA_TYPE_VARBINARY:
case TSDB_DATA_TYPE_NCHAR:
pVal->datum.p = taosMemoryCalloc(1, pVal->node.resType.bytes + VARSTR_HEADER_SIZE + 1); pVal->datum.p = taosMemoryCalloc(1, pVal->node.resType.bytes + VARSTR_HEADER_SIZE + 1);
if (NULL == pVal->datum.p) { if (NULL == pVal->datum.p) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
@ -138,6 +138,21 @@ static int32_t setValueByBindParam(SValueNode* pVal, TAOS_MULTI_BIND* pParam) {
varDataSetLen(pVal->datum.p, pVal->node.resType.bytes); varDataSetLen(pVal->datum.p, pVal->node.resType.bytes);
strncpy(varDataVal(pVal->datum.p), (const char*)pParam->buffer, pVal->node.resType.bytes); strncpy(varDataVal(pVal->datum.p), (const char*)pParam->buffer, pVal->node.resType.bytes);
break; break;
case TSDB_DATA_TYPE_NCHAR: {
pVal->node.resType.bytes *= TSDB_NCHAR_SIZE;
pVal->datum.p = taosMemoryCalloc(1, pVal->node.resType.bytes + VARSTR_HEADER_SIZE + 1);
if (NULL == pVal->datum.p) {
return TSDB_CODE_OUT_OF_MEMORY;
}
int32_t output = 0;
if (!taosMbsToUcs4(pParam->buffer, inputSize, (TdUcs4*)varDataVal(pVal->datum.p), pVal->node.resType.bytes, &output)) {
return errno;
}
varDataSetLen(pVal->datum.p, output);
pVal->node.resType.bytes = output;
break;
}
case TSDB_DATA_TYPE_TIMESTAMP: case TSDB_DATA_TYPE_TIMESTAMP:
pVal->datum.i = *((int64_t*)pParam->buffer); pVal->datum.i = *((int64_t*)pParam->buffer);
break; break;
@ -181,13 +196,20 @@ static EDealRes updatePlanQueryId(SNode* pNode, void* pContext) {
int32_t qStmtBindParam(SQueryPlan* pPlan, TAOS_MULTI_BIND* pParams, int32_t colIdx, uint64_t queryId) { int32_t qStmtBindParam(SQueryPlan* pPlan, TAOS_MULTI_BIND* pParams, int32_t colIdx, uint64_t queryId) {
int32_t size = taosArrayGetSize(pPlan->pPlaceholderValues); int32_t size = taosArrayGetSize(pPlan->pPlaceholderValues);
int32_t code = 0;
if (colIdx < 0) { if (colIdx < 0) {
for (int32_t i = 0; i < size; ++i) { for (int32_t i = 0; i < size; ++i) {
setValueByBindParam((SValueNode*)taosArrayGetP(pPlan->pPlaceholderValues, i), pParams + i); code = setValueByBindParam((SValueNode*)taosArrayGetP(pPlan->pPlaceholderValues, i), pParams + i);
if (code) {
return code;
}
} }
} else { } else {
setValueByBindParam((SValueNode*)taosArrayGetP(pPlan->pPlaceholderValues, colIdx), pParams); code = setValueByBindParam((SValueNode*)taosArrayGetP(pPlan->pPlaceholderValues, colIdx), pParams);
if (code) {
return code;
}
} }
if (colIdx < 0 || ((colIdx + 1) == size)) { if (colIdx < 0 || ((colIdx + 1) == size)) {

View File

@ -23,6 +23,7 @@ extern "C" {
#include "qworker.h" #include "qworker.h"
#include "tlockfree.h" #include "tlockfree.h"
#include "ttimer.h" #include "ttimer.h"
#include "tref.h"
#define QW_DEFAULT_SCHEDULER_NUMBER 10000 #define QW_DEFAULT_SCHEDULER_NUMBER 10000
#define QW_DEFAULT_TASK_NUMBER 10000 #define QW_DEFAULT_TASK_NUMBER 10000
@ -85,6 +86,12 @@ typedef struct SQWMsg {
SQWConnInfo connInfo; SQWConnInfo connInfo;
} SQWMsg; } SQWMsg;
typedef struct SQWHbParam {
bool inUse;
int32_t qwrId;
int64_t refId;
} SQWHbParam;
typedef struct SQWHbInfo { typedef struct SQWHbInfo {
SSchedulerHbRsp rsp; SSchedulerHbRsp rsp;
SQWConnInfo connInfo; SQWConnInfo connInfo;
@ -137,7 +144,8 @@ typedef struct SQWSchStatus {
} SQWSchStatus; } SQWSchStatus;
// Qnode/Vnode level task management // Qnode/Vnode level task management
typedef struct SQWorkerMgmt { typedef struct SQWorker {
int64_t refId;
SQWorkerCfg cfg; SQWorkerCfg cfg;
int8_t nodeType; int8_t nodeType;
int32_t nodeId; int32_t nodeId;
@ -148,9 +156,17 @@ typedef struct SQWorkerMgmt {
SHashObj *schHash; // key: schedulerId, value: SQWSchStatus SHashObj *schHash; // key: schedulerId, value: SQWSchStatus
SHashObj *ctxHash; // key: queryId+taskId, value: SQWTaskCtx SHashObj *ctxHash; // key: queryId+taskId, value: SQWTaskCtx
SMsgCb msgCb; SMsgCb msgCb;
} SQWorker;
typedef struct SQWorkerMgmt {
SRWLatch lock;
int32_t qwRef;
int32_t qwNum;
SQWHbParam param[1024];
int32_t paramIdx;
} SQWorkerMgmt; } SQWorkerMgmt;
#define QW_FPARAMS_DEF SQWorkerMgmt *mgmt, uint64_t sId, uint64_t qId, uint64_t tId, int64_t rId #define QW_FPARAMS_DEF SQWorker *mgmt, uint64_t sId, uint64_t qId, uint64_t tId, int64_t rId
#define QW_IDS() sId, qId, tId, rId #define QW_IDS() sId, qId, tId, rId
#define QW_FPARAMS() mgmt, QW_IDS() #define QW_FPARAMS() mgmt, QW_IDS()
@ -209,13 +225,13 @@ typedef struct SQWorkerMgmt {
} \ } \
} while (0) } while (0)
#define QW_ELOG(param, ...) qError("QW:%p " param, mgmt, __VA_ARGS__) #define QW_ELOG(_param, ...) qError("QW:%p " _param, mgmt, __VA_ARGS__)
#define QW_DLOG(param, ...) qDebug("QW:%p " param, mgmt, __VA_ARGS__) #define QW_DLOG(_param, ...) qDebug("QW:%p " _param, mgmt, __VA_ARGS__)
#define QW_DUMP(param, ...) \ #define QW_DUMP(_param, ...) \
do { \ do { \
if (gQWDebug.dumpEnable) { \ if (gQWDebug.dumpEnable) { \
qDebug("QW:%p " param, mgmt, __VA_ARGS__); \ qDebug("QW:%p " _param, mgmt, __VA_ARGS__); \
} \ } \
} while (0) } while (0)
@ -282,6 +298,14 @@ typedef struct SQWorkerMgmt {
} \ } \
} while (0) } while (0)
extern SQWorkerMgmt gQwMgmt;
FORCE_INLINE SQWorker *qwAcquire(int64_t refId) { return (SQWorker *)taosAcquireRef(atomic_load_32(&gQwMgmt.qwRef), refId); }
FORCE_INLINE int32_t qwRelease(int64_t refId) { return taosReleaseRef(gQwMgmt.qwRef, refId); }
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -28,7 +28,7 @@ int32_t qwProcessCQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg);
int32_t qwProcessReady(QW_FPARAMS_DEF, SQWMsg *qwMsg); int32_t qwProcessReady(QW_FPARAMS_DEF, SQWMsg *qwMsg);
int32_t qwProcessFetch(QW_FPARAMS_DEF, SQWMsg *qwMsg); int32_t qwProcessFetch(QW_FPARAMS_DEF, SQWMsg *qwMsg);
int32_t qwProcessDrop(QW_FPARAMS_DEF, SQWMsg *qwMsg); int32_t qwProcessDrop(QW_FPARAMS_DEF, SQWMsg *qwMsg);
int32_t qwProcessHb(SQWorkerMgmt *mgmt, SQWMsg *qwMsg, SSchedulerHbReq *req); int32_t qwProcessHb(SQWorker *mgmt, SQWMsg *qwMsg, SSchedulerHbReq *req);
int32_t qwBuildAndSendDropRsp(SQWConnInfo *pConn, int32_t code); int32_t qwBuildAndSendDropRsp(SQWConnInfo *pConn, int32_t code);
int32_t qwBuildAndSendCancelRsp(SQWConnInfo *pConn, int32_t code); int32_t qwBuildAndSendCancelRsp(SQWConnInfo *pConn, int32_t code);
@ -41,10 +41,10 @@ int32_t qwBuildAndSendQueryRsp(SQWConnInfo *pConn, int32_t code);
int32_t qwBuildAndSendExplainRsp(SQWConnInfo *pConn, SExplainExecInfo *execInfo, int32_t num); int32_t qwBuildAndSendExplainRsp(SQWConnInfo *pConn, SExplainExecInfo *execInfo, int32_t num);
void qwFreeFetchRsp(void *msg); void qwFreeFetchRsp(void *msg);
int32_t qwMallocFetchRsp(int32_t length, SRetrieveTableRsp **rsp); int32_t qwMallocFetchRsp(int32_t length, SRetrieveTableRsp **rsp);
int32_t qwGetSchTasksStatus(SQWorkerMgmt *mgmt, uint64_t sId, SSchedulerStatusRsp **rsp); int32_t qwGetSchTasksStatus(SQWorker *mgmt, uint64_t sId, SSchedulerStatusRsp **rsp);
int32_t qwBuildAndSendHbRsp(SQWConnInfo *pConn, SSchedulerHbRsp *rsp, int32_t code); int32_t qwBuildAndSendHbRsp(SQWConnInfo *pConn, SSchedulerHbRsp *rsp, int32_t code);
int32_t qwRegisterQueryBrokenLinkArg(QW_FPARAMS_DEF, SQWConnInfo *pConn); int32_t qwRegisterQueryBrokenLinkArg(QW_FPARAMS_DEF, SQWConnInfo *pConn);
int32_t qwRegisterHbBrokenLinkArg(SQWorkerMgmt *mgmt, uint64_t sId, SQWConnInfo *pConn); int32_t qwRegisterHbBrokenLinkArg(SQWorker *mgmt, uint64_t sId, SQWConnInfo *pConn);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -10,6 +10,11 @@
#include "tname.h" #include "tname.h"
SQWDebug gQWDebug = {.statusEnable = true, .dumpEnable = true}; SQWDebug gQWDebug = {.statusEnable = true, .dumpEnable = true};
SQWorkerMgmt gQwMgmt = {
.lock = 0,
.qwRef = -1,
.qwNum = 0,
};
int32_t qwDbgValidateStatus(QW_FPARAMS_DEF, int8_t oriStatus, int8_t newStatus, bool *ignore) { int32_t qwDbgValidateStatus(QW_FPARAMS_DEF, int8_t oriStatus, int8_t newStatus, bool *ignore) {
if (!gQWDebug.statusEnable) { if (!gQWDebug.statusEnable) {
@ -98,7 +103,7 @@ _return:
void qwDbgDumpSchInfo(SQWSchStatus *sch, int32_t i) {} void qwDbgDumpSchInfo(SQWSchStatus *sch, int32_t i) {}
void qwDbgDumpMgmtInfo(SQWorkerMgmt *mgmt) { void qwDbgDumpMgmtInfo(SQWorker *mgmt) {
if (!gQWDebug.dumpEnable) { if (!gQWDebug.dumpEnable) {
return; return;
} }
@ -186,7 +191,7 @@ int32_t qwSetTaskStatus(QW_FPARAMS_DEF, SQWTaskStatus *task, int8_t status) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t qwAddSchedulerImpl(SQWorkerMgmt *mgmt, uint64_t sId, int32_t rwType) { int32_t qwAddSchedulerImpl(SQWorker *mgmt, uint64_t sId, int32_t rwType) {
SQWSchStatus newSch = {0}; SQWSchStatus newSch = {0};
newSch.tasksHash = newSch.tasksHash =
taosHashInit(mgmt->cfg.maxSchTaskNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK); taosHashInit(mgmt->cfg.maxSchTaskNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
@ -213,7 +218,7 @@ int32_t qwAddSchedulerImpl(SQWorkerMgmt *mgmt, uint64_t sId, int32_t rwType) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t qwAcquireSchedulerImpl(SQWorkerMgmt *mgmt, uint64_t sId, int32_t rwType, SQWSchStatus **sch, int32_t nOpt) { int32_t qwAcquireSchedulerImpl(SQWorker *mgmt, uint64_t sId, int32_t rwType, SQWSchStatus **sch, int32_t nOpt) {
while (true) { while (true) {
QW_LOCK(rwType, &mgmt->schLock); QW_LOCK(rwType, &mgmt->schLock);
*sch = taosHashGet(mgmt->schHash, &sId, sizeof(sId)); *sch = taosHashGet(mgmt->schHash, &sId, sizeof(sId));
@ -240,15 +245,15 @@ int32_t qwAcquireSchedulerImpl(SQWorkerMgmt *mgmt, uint64_t sId, int32_t rwType,
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t qwAcquireAddScheduler(SQWorkerMgmt *mgmt, uint64_t sId, int32_t rwType, SQWSchStatus **sch) { int32_t qwAcquireAddScheduler(SQWorker *mgmt, uint64_t sId, int32_t rwType, SQWSchStatus **sch) {
return qwAcquireSchedulerImpl(mgmt, sId, rwType, sch, QW_NOT_EXIST_ADD); return qwAcquireSchedulerImpl(mgmt, sId, rwType, sch, QW_NOT_EXIST_ADD);
} }
int32_t qwAcquireScheduler(SQWorkerMgmt *mgmt, uint64_t sId, int32_t rwType, SQWSchStatus **sch) { int32_t qwAcquireScheduler(SQWorker *mgmt, uint64_t sId, int32_t rwType, SQWSchStatus **sch) {
return qwAcquireSchedulerImpl(mgmt, sId, rwType, sch, QW_NOT_EXIST_RET_ERR); return qwAcquireSchedulerImpl(mgmt, sId, rwType, sch, QW_NOT_EXIST_RET_ERR);
} }
void qwReleaseScheduler(int32_t rwType, SQWorkerMgmt *mgmt) { QW_UNLOCK(rwType, &mgmt->schLock); } void qwReleaseScheduler(int32_t rwType, SQWorker *mgmt) { QW_UNLOCK(rwType, &mgmt->schLock); }
int32_t qwAcquireTaskStatus(QW_FPARAMS_DEF, int32_t rwType, SQWSchStatus *sch, SQWTaskStatus **task) { int32_t qwAcquireTaskStatus(QW_FPARAMS_DEF, int32_t rwType, SQWSchStatus *sch, SQWTaskStatus **task) {
char id[sizeof(qId) + sizeof(tId)] = {0}; char id[sizeof(qId) + sizeof(tId)] = {0};
@ -384,7 +389,7 @@ int32_t qwAddTaskCtx(QW_FPARAMS_DEF) { QW_RET(qwAddTaskCtxImpl(QW_FPARAMS(), fal
int32_t qwAddAcquireTaskCtx(QW_FPARAMS_DEF, SQWTaskCtx **ctx) { return qwAddTaskCtxImpl(QW_FPARAMS(), true, ctx); } int32_t qwAddAcquireTaskCtx(QW_FPARAMS_DEF, SQWTaskCtx **ctx) { return qwAddTaskCtxImpl(QW_FPARAMS(), true, ctx); }
void qwReleaseTaskCtx(SQWorkerMgmt *mgmt, void *ctx) { taosHashRelease(mgmt->ctxHash, ctx); } void qwReleaseTaskCtx(SQWorker *mgmt, void *ctx) { taosHashRelease(mgmt->ctxHash, ctx); }
void qwFreeTaskHandle(QW_FPARAMS_DEF, qTaskInfo_t *taskHandle) { void qwFreeTaskHandle(QW_FPARAMS_DEF, qTaskInfo_t *taskHandle) {
// Note: free/kill may in RC // Note: free/kill may in RC
@ -606,7 +611,7 @@ int32_t qwExecTask(QW_FPARAMS_DEF, SQWTaskCtx *ctx, bool *queryEnd) {
QW_RET(code); QW_RET(code);
} }
int32_t qwGenerateSchHbRsp(SQWorkerMgmt *mgmt, SQWSchStatus *sch, SQWHbInfo *hbInfo) { int32_t qwGenerateSchHbRsp(SQWorker *mgmt, SQWSchStatus *sch, SQWHbInfo *hbInfo) {
int32_t taskNum = 0; int32_t taskNum = 0;
hbInfo->connInfo = sch->hbConnInfo; hbInfo->connInfo = sch->hbConnInfo;
@ -1262,7 +1267,7 @@ _return:
QW_RET(TSDB_CODE_SUCCESS); QW_RET(TSDB_CODE_SUCCESS);
} }
int32_t qwProcessHbLinkBroken(SQWorkerMgmt *mgmt, SQWMsg *qwMsg, SSchedulerHbReq *req) { int32_t qwProcessHbLinkBroken(SQWorker *mgmt, SQWMsg *qwMsg, SSchedulerHbReq *req) {
int32_t code = 0; int32_t code = 0;
SSchedulerHbRsp rsp = {0}; SSchedulerHbRsp rsp = {0};
SQWSchStatus * sch = NULL; SQWSchStatus * sch = NULL;
@ -1288,7 +1293,7 @@ int32_t qwProcessHbLinkBroken(SQWorkerMgmt *mgmt, SQWMsg *qwMsg, SSchedulerHbReq
QW_RET(TSDB_CODE_SUCCESS); QW_RET(TSDB_CODE_SUCCESS);
} }
int32_t qwProcessHb(SQWorkerMgmt *mgmt, SQWMsg *qwMsg, SSchedulerHbReq *req) { int32_t qwProcessHb(SQWorker *mgmt, SQWMsg *qwMsg, SSchedulerHbReq *req) {
int32_t code = 0; int32_t code = 0;
SSchedulerHbRsp rsp = {0}; SSchedulerHbRsp rsp = {0};
SQWSchStatus * sch = NULL; SQWSchStatus * sch = NULL;
@ -1333,7 +1338,19 @@ _return:
} }
void qwProcessHbTimerEvent(void *param, void *tmrId) { void qwProcessHbTimerEvent(void *param, void *tmrId) {
SQWorkerMgmt *mgmt = (SQWorkerMgmt *)param; SQWHbParam* hbParam = (SQWHbParam*)param;
if (hbParam->qwrId != atomic_load_32(&gQwMgmt.qwRef)) {
return;
}
int64_t refId = hbParam->refId;
SQWorker *mgmt = qwAcquire(refId);
if (NULL == mgmt) {
QW_DLOG("qwAcquire %" PRIx64 "failed", refId);
taosMemoryFree(param);
return;
}
SQWSchStatus *sch = NULL; SQWSchStatus *sch = NULL;
int32_t taskNum = 0; int32_t taskNum = 0;
SQWHbInfo * rspList = NULL; SQWHbInfo * rspList = NULL;
@ -1347,6 +1364,7 @@ void qwProcessHbTimerEvent(void *param, void *tmrId) {
if (schNum <= 0) { if (schNum <= 0) {
QW_UNLOCK(QW_READ, &mgmt->schLock); QW_UNLOCK(QW_READ, &mgmt->schLock);
taosTmrReset(qwProcessHbTimerEvent, QW_DEFAULT_HEARTBEAT_MSEC, param, mgmt->timer, &mgmt->hbTimer); taosTmrReset(qwProcessHbTimerEvent, QW_DEFAULT_HEARTBEAT_MSEC, param, mgmt->timer, &mgmt->hbTimer);
qwRelease(refId);
return; return;
} }
@ -1355,6 +1373,7 @@ void qwProcessHbTimerEvent(void *param, void *tmrId) {
QW_UNLOCK(QW_READ, &mgmt->schLock); QW_UNLOCK(QW_READ, &mgmt->schLock);
QW_ELOG("calloc %d SQWHbInfo failed", schNum); QW_ELOG("calloc %d SQWHbInfo failed", schNum);
taosTmrReset(qwProcessHbTimerEvent, QW_DEFAULT_HEARTBEAT_MSEC, param, mgmt->timer, &mgmt->hbTimer); taosTmrReset(qwProcessHbTimerEvent, QW_DEFAULT_HEARTBEAT_MSEC, param, mgmt->timer, &mgmt->hbTimer);
qwRelease(refId);
return; return;
} }
@ -1396,6 +1415,74 @@ _return:
taosMemoryFreeClear(rspList); taosMemoryFreeClear(rspList);
taosTmrReset(qwProcessHbTimerEvent, QW_DEFAULT_HEARTBEAT_MSEC, param, mgmt->timer, &mgmt->hbTimer); taosTmrReset(qwProcessHbTimerEvent, QW_DEFAULT_HEARTBEAT_MSEC, param, mgmt->timer, &mgmt->hbTimer);
qwRelease(refId);
}
void qwCloseRef(void) {
taosWLockLatch(&gQwMgmt.lock);
if (atomic_load_32(&gQwMgmt.qwNum) <= 0 && gQwMgmt.qwRef >= 0) {
taosCloseRef(gQwMgmt.qwRef);
gQwMgmt.qwRef= -1;
}
taosWUnLockLatch(&gQwMgmt.lock);
}
void qwDestroyImpl(void *pMgmt) {
SQWorker *mgmt = (SQWorker *)pMgmt;
taosTmrStopA(&mgmt->hbTimer);
taosTmrCleanUp(mgmt->timer);
// TODO STOP ALL QUERY
// TODO FREE ALL
taosHashCleanup(mgmt->ctxHash);
taosHashCleanup(mgmt->schHash);
taosMemoryFree(mgmt);
atomic_sub_fetch_32(&gQwMgmt.qwNum, 1);
qwCloseRef();
}
int32_t qwOpenRef(void) {
taosWLockLatch(&gQwMgmt.lock);
if (gQwMgmt.qwRef < 0) {
gQwMgmt.qwRef= taosOpenRef(100, qwDestroyImpl);
if (gQwMgmt.qwRef < 0) {
taosWUnLockLatch(&gQwMgmt.lock);
qError("init qworker ref failed");
QW_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
}
}
taosWUnLockLatch(&gQwMgmt.lock);
return TSDB_CODE_SUCCESS;
}
void qwSetHbParam(int64_t refId, SQWHbParam **pParam) {
int32_t paramIdx = 0;
int32_t newParamIdx = 0;
while (true) {
paramIdx = atomic_load_32(&gQwMgmt.paramIdx);
if (paramIdx == tListLen(gQwMgmt.param)) {
newParamIdx = 0;
} else {
newParamIdx = paramIdx + 1;
}
if (paramIdx == atomic_val_compare_exchange_32(&gQwMgmt.paramIdx, paramIdx, newParamIdx)) {
break;
}
}
gQwMgmt.param[paramIdx].qwrId = gQwMgmt.qwRef;
gQwMgmt.param[paramIdx].refId = refId;
*pParam = &gQwMgmt.param[paramIdx];
} }
int32_t qWorkerInit(int8_t nodeType, int32_t nodeId, SQWorkerCfg *cfg, void **qWorkerMgmt, const SMsgCb *pMsgCb) { int32_t qWorkerInit(int8_t nodeType, int32_t nodeId, SQWorkerCfg *cfg, void **qWorkerMgmt, const SMsgCb *pMsgCb) {
@ -1404,10 +1491,21 @@ int32_t qWorkerInit(int8_t nodeType, int32_t nodeId, SQWorkerCfg *cfg, void **qW
QW_RET(TSDB_CODE_QRY_INVALID_INPUT); QW_RET(TSDB_CODE_QRY_INVALID_INPUT);
} }
int32_t code = 0; int32_t qwNum = atomic_add_fetch_32(&gQwMgmt.qwNum, 1);
SQWorkerMgmt *mgmt = taosMemoryCalloc(1, sizeof(SQWorkerMgmt)); if (1 == qwNum) {
memset(gQwMgmt.param, 0, sizeof(gQwMgmt.param));
}
int32_t code = qwOpenRef();
if (code) {
atomic_sub_fetch_32(&gQwMgmt.qwNum, 1);
QW_RET(code);
}
SQWorker *mgmt = taosMemoryCalloc(1, sizeof(SQWorker));
if (NULL == mgmt) { if (NULL == mgmt) {
qError("calloc %d failed", (int32_t)sizeof(SQWorkerMgmt)); qError("calloc %d failed", (int32_t)sizeof(SQWorker));
atomic_sub_fetch_32(&gQwMgmt.qwNum, 1);
QW_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); QW_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
} }
@ -1449,16 +1547,25 @@ int32_t qWorkerInit(int8_t nodeType, int32_t nodeId, SQWorkerCfg *cfg, void **qW
QW_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); QW_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY);
} }
mgmt->hbTimer = taosTmrStart(qwProcessHbTimerEvent, QW_DEFAULT_HEARTBEAT_MSEC, mgmt, mgmt->timer); mgmt->nodeType = nodeType;
mgmt->nodeId = nodeId;
mgmt->msgCb = *pMsgCb;
mgmt->refId = taosAddRef(gQwMgmt.qwRef, mgmt);
if (mgmt->refId < 0) {
qError("taosAddRef qw failed, error:%s", tstrerror(terrno));
QW_ERR_JRET(terrno);
}
SQWHbParam *param = NULL;
qwSetHbParam(mgmt->refId, &param);
mgmt->hbTimer = taosTmrStart(qwProcessHbTimerEvent, QW_DEFAULT_HEARTBEAT_MSEC, (void*)param, mgmt->timer);
if (NULL == mgmt->hbTimer) { if (NULL == mgmt->hbTimer) {
qError("start hb timer failed"); qError("start hb timer failed");
QW_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); QW_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY);
} }
mgmt->nodeType = nodeType;
mgmt->nodeId = nodeId;
mgmt->msgCb = *pMsgCb;
*qWorkerMgmt = mgmt; *qWorkerMgmt = mgmt;
qDebug("qworker initialized for node, type:%d, id:%d, handle:%p", mgmt->nodeType, mgmt->nodeId, mgmt); qDebug("qworker initialized for node, type:%d, id:%d, handle:%p", mgmt->nodeType, mgmt->nodeId, mgmt);
@ -1467,12 +1574,16 @@ int32_t qWorkerInit(int8_t nodeType, int32_t nodeId, SQWorkerCfg *cfg, void **qW
_return: _return:
taosHashCleanup(mgmt->schHash); if (mgmt->refId >= 0) {
taosHashCleanup(mgmt->ctxHash); qwRelease(mgmt->refId);
} else {
taosHashCleanup(mgmt->schHash);
taosHashCleanup(mgmt->ctxHash);
taosTmrCleanUp(mgmt->timer);
taosMemoryFreeClear(mgmt);
taosTmrCleanUp(mgmt->timer); atomic_sub_fetch_32(&gQwMgmt.qwNum, 1);
}
taosMemoryFreeClear(mgmt);
QW_RET(code); QW_RET(code);
} }
@ -1482,22 +1593,14 @@ void qWorkerDestroy(void **qWorkerMgmt) {
return; return;
} }
SQWorkerMgmt *mgmt = *qWorkerMgmt; SQWorker *mgmt = *qWorkerMgmt;
taosTmrStopA(&mgmt->hbTimer); if (taosRemoveRef(gQwMgmt.qwRef, mgmt->refId)) {
taosTmrCleanUp(mgmt->timer); qError("remove qw from ref list failed, refId:%" PRIx64, mgmt->refId);
}
// TODO STOP ALL QUERY
// TODO FREE ALL
taosHashCleanup(mgmt->ctxHash);
taosHashCleanup(mgmt->schHash);
taosMemoryFreeClear(*qWorkerMgmt);
} }
int32_t qwGetSchTasksStatus(SQWorkerMgmt *mgmt, uint64_t sId, SSchedulerStatusRsp **rsp) { int32_t qwGetSchTasksStatus(SQWorker *mgmt, uint64_t sId, SSchedulerStatusRsp **rsp) {
/* /*
SQWSchStatus *sch = NULL; SQWSchStatus *sch = NULL;
int32_t taskNum = 0; int32_t taskNum = 0;
@ -1544,7 +1647,7 @@ int32_t qwGetSchTasksStatus(SQWorkerMgmt *mgmt, uint64_t sId, SSchedulerStatusRs
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t qwUpdateSchLastAccess(SQWorkerMgmt *mgmt, uint64_t sId, uint64_t qId, uint64_t tId) { int32_t qwUpdateSchLastAccess(SQWorker *mgmt, uint64_t sId, uint64_t qId, uint64_t tId) {
SQWSchStatus *sch = NULL; SQWSchStatus *sch = NULL;
/* /*
@ -1557,7 +1660,7 @@ int32_t qwUpdateSchLastAccess(SQWorkerMgmt *mgmt, uint64_t sId, uint64_t qId, ui
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t qwGetTaskStatus(SQWorkerMgmt *mgmt, uint64_t sId, uint64_t qId, uint64_t tId, int8_t *taskStatus) { int32_t qwGetTaskStatus(SQWorker *mgmt, uint64_t sId, uint64_t qId, uint64_t tId, int8_t *taskStatus) {
SQWSchStatus * sch = NULL; SQWSchStatus * sch = NULL;
SQWTaskStatus *task = NULL; SQWTaskStatus *task = NULL;
int32_t code = 0; int32_t code = 0;
@ -1584,7 +1687,7 @@ int32_t qwGetTaskStatus(SQWorkerMgmt *mgmt, uint64_t sId, uint64_t qId, uint64_t
QW_RET(code); QW_RET(code);
} }
int32_t qwCancelTask(SQWorkerMgmt *mgmt, uint64_t sId, uint64_t qId, uint64_t tId) { int32_t qwCancelTask(SQWorker *mgmt, uint64_t sId, uint64_t qId, uint64_t tId) {
SQWSchStatus * sch = NULL; SQWSchStatus * sch = NULL;
SQWTaskStatus *task = NULL; SQWTaskStatus *task = NULL;
int32_t code = 0; int32_t code = 0;

View File

@ -320,7 +320,7 @@ int32_t qwRegisterQueryBrokenLinkArg(QW_FPARAMS_DEF, SQWConnInfo *pConn) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t qwRegisterHbBrokenLinkArg(SQWorkerMgmt *mgmt, uint64_t sId, SQWConnInfo *pConn) { int32_t qwRegisterHbBrokenLinkArg(SQWorker *mgmt, uint64_t sId, SQWConnInfo *pConn) {
SSchedulerHbReq req = {0}; SSchedulerHbReq req = {0};
req.header.vgId = mgmt->nodeId; req.header.vgId = mgmt->nodeId;
req.sId = sId; req.sId = sId;
@ -363,7 +363,7 @@ int32_t qWorkerProcessQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) {
int32_t code = 0; int32_t code = 0;
SSubQueryMsg *msg = pMsg->pCont; SSubQueryMsg *msg = pMsg->pCont;
SQWorkerMgmt *mgmt = (SQWorkerMgmt *)qWorkerMgmt; SQWorker *mgmt = (SQWorker *)qWorkerMgmt;
if (NULL == msg || pMsg->contLen <= sizeof(*msg)) { if (NULL == msg || pMsg->contLen <= sizeof(*msg)) {
QW_ELOG("invalid query msg, msg:%p, msgLen:%d", msg, pMsg->contLen); QW_ELOG("invalid query msg, msg:%p, msgLen:%d", msg, pMsg->contLen);
@ -405,7 +405,7 @@ int32_t qWorkerProcessCQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) {
SQueryContinueReq *msg = (SQueryContinueReq *)pMsg->pCont; SQueryContinueReq *msg = (SQueryContinueReq *)pMsg->pCont;
bool needStop = false; bool needStop = false;
SQWTaskCtx *handles = NULL; SQWTaskCtx *handles = NULL;
SQWorkerMgmt *mgmt = (SQWorkerMgmt *)qWorkerMgmt; SQWorker *mgmt = (SQWorker *)qWorkerMgmt;
if (NULL == msg || pMsg->contLen < sizeof(*msg)) { if (NULL == msg || pMsg->contLen < sizeof(*msg)) {
QW_ELOG("invalid cquery msg, msg:%p, msgLen:%d", msg, pMsg->contLen); QW_ELOG("invalid cquery msg, msg:%p, msgLen:%d", msg, pMsg->contLen);
@ -436,7 +436,7 @@ int32_t qWorkerProcessReadyMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) {
return TSDB_CODE_QRY_INVALID_INPUT; return TSDB_CODE_QRY_INVALID_INPUT;
} }
SQWorkerMgmt *mgmt = (SQWorkerMgmt *)qWorkerMgmt; SQWorker *mgmt = (SQWorker *)qWorkerMgmt;
SResReadyReq *msg = pMsg->pCont; SResReadyReq *msg = pMsg->pCont;
if (NULL == msg || pMsg->contLen < sizeof(*msg)) { if (NULL == msg || pMsg->contLen < sizeof(*msg)) {
QW_ELOG("invalid task ready msg, msg:%p, msgLen:%d", msg, pMsg->contLen); QW_ELOG("invalid task ready msg, msg:%p, msgLen:%d", msg, pMsg->contLen);
@ -478,7 +478,7 @@ int32_t qWorkerProcessStatusMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) {
QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
} }
SQWorkerMgmt *mgmt = (SQWorkerMgmt *)qWorkerMgmt; SQWorker *mgmt = (SQWorker *)qWorkerMgmt;
msg->sId = htobe64(msg->sId); msg->sId = htobe64(msg->sId);
uint64_t sId = msg->sId; uint64_t sId = msg->sId;
@ -499,7 +499,7 @@ int32_t qWorkerProcessFetchMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) {
} }
SResFetchReq *msg = pMsg->pCont; SResFetchReq *msg = pMsg->pCont;
SQWorkerMgmt *mgmt = (SQWorkerMgmt *)qWorkerMgmt; SQWorker *mgmt = (SQWorker *)qWorkerMgmt;
if (NULL == msg || pMsg->contLen < sizeof(*msg)) { if (NULL == msg || pMsg->contLen < sizeof(*msg)) {
QW_ELOG("invalid fetch msg, msg:%p, msgLen:%d", msg, pMsg->contLen); QW_ELOG("invalid fetch msg, msg:%p, msgLen:%d", msg, pMsg->contLen);
@ -539,7 +539,7 @@ int32_t qWorkerProcessCancelMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) {
return TSDB_CODE_QRY_INVALID_INPUT; return TSDB_CODE_QRY_INVALID_INPUT;
} }
SQWorkerMgmt *mgmt = (SQWorkerMgmt *)qWorkerMgmt; SQWorker *mgmt = (SQWorker *)qWorkerMgmt;
int32_t code = 0; int32_t code = 0;
STaskCancelReq *msg = pMsg->pCont; STaskCancelReq *msg = pMsg->pCont;
if (NULL == msg || pMsg->contLen < sizeof(*msg)) { if (NULL == msg || pMsg->contLen < sizeof(*msg)) {
@ -579,7 +579,7 @@ int32_t qWorkerProcessDropMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) {
int32_t code = 0; int32_t code = 0;
STaskDropReq *msg = pMsg->pCont; STaskDropReq *msg = pMsg->pCont;
SQWorkerMgmt *mgmt = (SQWorkerMgmt *)qWorkerMgmt; SQWorker *mgmt = (SQWorker *)qWorkerMgmt;
if (NULL == msg || pMsg->contLen < sizeof(*msg)) { if (NULL == msg || pMsg->contLen < sizeof(*msg)) {
QW_ELOG("invalid task drop msg, msg:%p, msgLen:%d", msg, pMsg->contLen); QW_ELOG("invalid task drop msg, msg:%p, msgLen:%d", msg, pMsg->contLen);
@ -621,7 +621,7 @@ int32_t qWorkerProcessHbMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) {
int32_t code = 0; int32_t code = 0;
SSchedulerHbReq req = {0}; SSchedulerHbReq req = {0};
SQWorkerMgmt *mgmt = (SQWorkerMgmt *)qWorkerMgmt; SQWorker *mgmt = (SQWorker *)qWorkerMgmt;
if (NULL == pMsg->pCont) { if (NULL == pMsg->pCont) {
QW_ELOG("invalid hb msg, msg:%p, msgLen:%d", pMsg->pCont, pMsg->contLen); QW_ELOG("invalid hb msg, msg:%p, msgLen:%d", pMsg->pCont, pMsg->contLen);

View File

@ -3765,6 +3765,7 @@ int32_t filterInitFromNode(SNode* pNode, SFilterInfo **pInfo, uint32_t options)
FLT_ERR_JRET(fltReviseNodes(info, &pNode, &stat)); FLT_ERR_JRET(fltReviseNodes(info, &pNode, &stat));
info->scalarMode = stat.scalarMode; info->scalarMode = stat.scalarMode;
fltDebug("scalar mode: %d", info->scalarMode);
if (!info->scalarMode) { if (!info->scalarMode) {
FLT_ERR_JRET(fltInitFromNode(pNode, info, options)); FLT_ERR_JRET(fltInitFromNode(pNode, info, options));

View File

@ -75,7 +75,15 @@ int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type) {
if (valueNode->node.resType.type != type) { if (valueNode->node.resType.type != type) {
out.columnData->info.type = type; out.columnData->info.type = type;
out.columnData->info.bytes = tDataTypes[type].bytes; if (IS_VAR_DATA_TYPE(type)) {
if (IS_VAR_DATA_TYPE(valueNode->node.resType.type)) {
out.columnData->info.bytes = valueNode->node.resType.bytes * TSDB_NCHAR_SIZE;
} else {
out.columnData->info.bytes = 64 * TSDB_NCHAR_SIZE;
}
} else {
out.columnData->info.bytes = tDataTypes[type].bytes;
}
code = doConvertDataType(valueNode, &out); code = doConvertDataType(valueNode, &out);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
@ -598,7 +606,7 @@ EDealRes sclRewriteFunction(SNode** pNode, SScalarCtx *ctx) {
res->datum.p = taosMemoryCalloc(res->node.resType.bytes + VARSTR_HEADER_SIZE + 1, 1); res->datum.p = taosMemoryCalloc(res->node.resType.bytes + VARSTR_HEADER_SIZE + 1, 1);
memcpy(res->datum.p, output.columnData->pData, varDataTLen(output.columnData->pData)); memcpy(res->datum.p, output.columnData->pData, varDataTLen(output.columnData->pData));
} else { } else {
memcpy(nodesGetValueFromNode(res), output.columnData->pData, tDataTypes[type].bytes); nodesSetValueNodeValue(res, output.columnData->pData);
} }
} }
@ -638,7 +646,7 @@ EDealRes sclRewriteLogic(SNode** pNode, SScalarCtx *ctx) {
res->datum.p = output.columnData->pData; res->datum.p = output.columnData->pData;
output.columnData->pData = NULL; output.columnData->pData = NULL;
} else { } else {
memcpy(nodesGetValueFromNode(res), output.columnData->pData, tDataTypes[type].bytes); nodesSetValueNodeValue(res, output.columnData->pData);
} }
nodesDestroyNode(*pNode); nodesDestroyNode(*pNode);
@ -680,7 +688,7 @@ EDealRes sclRewriteOperator(SNode** pNode, SScalarCtx *ctx) {
res->datum.p = output.columnData->pData; res->datum.p = output.columnData->pData;
output.columnData->pData = NULL; output.columnData->pData = NULL;
} else { } else {
memcpy(nodesGetValueFromNode(res), output.columnData->pData, tDataTypes[type].bytes); nodesSetValueNodeValue(res, output.columnData->pData);
} }
} }

View File

@ -85,7 +85,10 @@ typedef struct SSchedulerMgmt {
uint64_t taskId; // sequential taksId uint64_t taskId; // sequential taksId
uint64_t sId; // schedulerId uint64_t sId; // schedulerId
SSchedulerCfg cfg; SSchedulerCfg cfg;
SRWLatch lock;
bool exit;
int32_t jobRef; int32_t jobRef;
int32_t jobNum;
SSchedulerStat stat; SSchedulerStat stat;
SHashObj *hbConnections; SHashObj *hbConnections;
} SSchedulerMgmt; } SSchedulerMgmt;

View File

@ -21,7 +21,9 @@
#include "tref.h" #include "tref.h"
#include "trpc.h" #include "trpc.h"
SSchedulerMgmt schMgmt = {0}; SSchedulerMgmt schMgmt = {
.jobRef = -1,
};
FORCE_INLINE SSchJob *schAcquireJob(int64_t refId) { return (SSchJob *)taosAcquireRef(schMgmt.jobRef, refId); } FORCE_INLINE SSchJob *schAcquireJob(int64_t refId) { return (SSchJob *)taosAcquireRef(schMgmt.jobRef, refId); }
@ -70,6 +72,7 @@ int32_t schInitTask(SSchJob *pJob, SSchTask *pTask, SSubplan *pPlan, SSchLevel *
int32_t schInitJob(SSchJob **pSchJob, SQueryPlan *pDag, void *transport, SArray *pNodeList, const char *sql, int32_t schInitJob(SSchJob **pSchJob, SQueryPlan *pDag, void *transport, SArray *pNodeList, const char *sql,
int64_t startTs, bool syncSchedule) { int64_t startTs, bool syncSchedule) {
int32_t code = 0; int32_t code = 0;
int64_t refId = -1;
SSchJob *pJob = taosMemoryCalloc(1, sizeof(SSchJob)); SSchJob *pJob = taosMemoryCalloc(1, sizeof(SSchJob));
if (NULL == pJob) { if (NULL == pJob) {
qError("QID:%" PRIx64 " calloc %d failed", pDag->queryId, (int32_t)sizeof(SSchJob)); qError("QID:%" PRIx64 " calloc %d failed", pDag->queryId, (int32_t)sizeof(SSchJob));
@ -114,15 +117,17 @@ int32_t schInitJob(SSchJob **pSchJob, SQueryPlan *pDag, void *transport, SArray
tsem_init(&pJob->rspSem, 0, 0); tsem_init(&pJob->rspSem, 0, 0);
int64_t refId = taosAddRef(schMgmt.jobRef, pJob); refId = taosAddRef(schMgmt.jobRef, pJob);
if (refId < 0) { if (refId < 0) {
SCH_JOB_ELOG("taosAddRef job failed, error:%s", tstrerror(terrno)); SCH_JOB_ELOG("taosAddRef job failed, error:%s", tstrerror(terrno));
SCH_ERR_JRET(terrno); SCH_ERR_JRET(terrno);
} }
atomic_add_fetch_32(&schMgmt.jobNum, 1);
if (NULL == schAcquireJob(refId)) { if (NULL == schAcquireJob(refId)) {
SCH_JOB_ELOG("schAcquireJob job failed, refId:%" PRIx64, refId); SCH_JOB_ELOG("schAcquireJob job failed, refId:%" PRIx64, refId);
SCH_RET(TSDB_CODE_SCH_STATUS_ERROR); SCH_ERR_JRET(TSDB_CODE_SCH_STATUS_ERROR);
} }
pJob->refId = refId; pJob->refId = refId;
@ -137,7 +142,11 @@ int32_t schInitJob(SSchJob **pSchJob, SQueryPlan *pDag, void *transport, SArray
_return: _return:
schFreeJobImpl(pJob); if (refId < 0) {
schFreeJobImpl(pJob);
} else {
taosRemoveRef(schMgmt.jobRef, refId);
}
SCH_RET(code); SCH_RET(code);
} }
@ -2239,6 +2248,19 @@ int32_t schCancelJob(SSchJob *pJob) {
// TODO MOVE ALL TASKS FROM EXEC LIST TO FAIL LIST // TODO MOVE ALL TASKS FROM EXEC LIST TO FAIL LIST
} }
void schCloseJobRef(void) {
if (!atomic_load_8((int8_t*)&schMgmt.exit)) {
return;
}
SCH_LOCK(SCH_WRITE, &schMgmt.lock);
if (atomic_load_32(&schMgmt.jobNum) <= 0 && schMgmt.jobRef >= 0) {
taosCloseRef(schMgmt.jobRef);
schMgmt.jobRef = -1;
}
SCH_UNLOCK(SCH_WRITE, &schMgmt.lock);
}
void schFreeJobImpl(void *job) { void schFreeJobImpl(void *job) {
if (NULL == job) { if (NULL == job) {
return; return;
@ -2284,6 +2306,10 @@ void schFreeJobImpl(void *job) {
taosMemoryFreeClear(pJob); taosMemoryFreeClear(pJob);
qDebug("QID:0x%" PRIx64 " job freed, refId:%" PRIx64 ", pointer:%p", queryId, refId, pJob); qDebug("QID:0x%" PRIx64 " job freed, refId:%" PRIx64 ", pointer:%p", queryId, refId, pJob);
atomic_sub_fetch_32(&schMgmt.jobNum, 1);
schCloseJobRef();
} }
static int32_t schExecJobImpl(void *transport, SArray *pNodeList, SQueryPlan *pDag, int64_t *job, const char *sql, static int32_t schExecJobImpl(void *transport, SArray *pNodeList, SQueryPlan *pDag, int64_t *job, const char *sql,
@ -2368,7 +2394,7 @@ _return:
} }
int32_t schedulerInit(SSchedulerCfg *cfg) { int32_t schedulerInit(SSchedulerCfg *cfg) {
if (schMgmt.jobRef) { if (schMgmt.jobRef >= 0) {
qError("scheduler already initialized"); qError("scheduler already initialized");
return TSDB_CODE_QRY_INVALID_INPUT; return TSDB_CODE_QRY_INVALID_INPUT;
} }
@ -2732,7 +2758,9 @@ void schedulerFreeTaskList(SArray *taskList) {
} }
void schedulerDestroy(void) { void schedulerDestroy(void) {
if (schMgmt.jobRef) { atomic_store_8((int8_t*)&schMgmt.exit, 1);
if (schMgmt.jobRef >= 0) {
SSchJob *pJob = taosIterateRef(schMgmt.jobRef, 0); SSchJob *pJob = taosIterateRef(schMgmt.jobRef, 0);
int64_t refId = 0; int64_t refId = 0;
@ -2745,9 +2773,6 @@ void schedulerDestroy(void) {
pJob = taosIterateRef(schMgmt.jobRef, refId); pJob = taosIterateRef(schMgmt.jobRef, refId);
} }
taosCloseRef(schMgmt.jobRef);
schMgmt.jobRef = 0;
} }
if (schMgmt.hbConnections) { if (schMgmt.hbConnections) {

View File

@ -11,7 +11,8 @@
int32_t shortColList[] = {TSDB_DATA_TYPE_TIMESTAMP, TSDB_DATA_TYPE_INT}; int32_t shortColList[] = {TSDB_DATA_TYPE_TIMESTAMP, TSDB_DATA_TYPE_INT};
int32_t fullColList[] = {TSDB_DATA_TYPE_TIMESTAMP, TSDB_DATA_TYPE_BOOL, TSDB_DATA_TYPE_TINYINT, TSDB_DATA_TYPE_UTINYINT, TSDB_DATA_TYPE_SMALLINT, TSDB_DATA_TYPE_USMALLINT, TSDB_DATA_TYPE_INT, TSDB_DATA_TYPE_UINT, TSDB_DATA_TYPE_BIGINT, TSDB_DATA_TYPE_UBIGINT, TSDB_DATA_TYPE_FLOAT, TSDB_DATA_TYPE_DOUBLE, TSDB_DATA_TYPE_BINARY, TSDB_DATA_TYPE_NCHAR}; int32_t fullColList[] = {TSDB_DATA_TYPE_TIMESTAMP, TSDB_DATA_TYPE_BOOL, TSDB_DATA_TYPE_TINYINT, TSDB_DATA_TYPE_UTINYINT, TSDB_DATA_TYPE_SMALLINT, TSDB_DATA_TYPE_USMALLINT, TSDB_DATA_TYPE_INT, TSDB_DATA_TYPE_UINT, TSDB_DATA_TYPE_BIGINT, TSDB_DATA_TYPE_UBIGINT, TSDB_DATA_TYPE_FLOAT, TSDB_DATA_TYPE_DOUBLE, TSDB_DATA_TYPE_BINARY, TSDB_DATA_TYPE_NCHAR};
int32_t bindColTypeList[] = {TSDB_DATA_TYPE_TIMESTAMP}; int32_t bindColTypeList[] = {TSDB_DATA_TYPE_TIMESTAMP, TSDB_DATA_TYPE_NCHAR, TSDB_DATA_TYPE_BOOL};
int32_t optrIdxList[] = {2, 11, 6};
typedef struct { typedef struct {
char* oper; char* oper;
@ -32,7 +33,7 @@ OperInfo operInfo[] = {
{"like", 2, false}, {"like", 2, false},
{"not like", 2, false}, {"not like", 2, false},
{"match", 2, false}, {"match", 2, false},
{"nmake", 2, false}, {"nmatch", 2, false},
}; };
int32_t operatorList[] = {0, 1, 2, 3, 4, 5, 6, 7}; int32_t operatorList[] = {0, 1, 2, 3, 4, 5, 6, 7};
@ -139,9 +140,7 @@ CaseCfg gCase[] = {
{"insert:MPME1-C012", tListLen(fullColList), fullColList, TTYPE_INSERT, false, false, insertMPMETest1, 10, 10, 2, 12, 0, 1, -1}, {"insert:MPME1-C012", tListLen(fullColList), fullColList, TTYPE_INSERT, false, false, insertMPMETest1, 10, 10, 2, 12, 0, 1, -1},
// 22 // 22
//{"query:SUBT-FULL", tListLen(fullColList), fullColList, TTYPE_QUERY, false, false, querySUBTTest1, 10, 10, 1, 3, 0, 1, 2}, {"query:SUBT-FULL", tListLen(fullColList), fullColList, TTYPE_QUERY, false, false, querySUBTTest1, 10, 10, 1, 3, 0, 1, 2},
{"query:SUBT-FULL", tListLen(fullColList), fullColList, TTYPE_QUERY, false, false, querySUBTTest1, 1, 10, 1, 3, 0, 1, 2},
}; };
@ -161,6 +160,8 @@ typedef struct {
int32_t bindRowNum; //row num for once bind int32_t bindRowNum; //row num for once bind
int32_t bindColTypeNum; int32_t bindColTypeNum;
int32_t* bindColTypeList; int32_t* bindColTypeList;
int32_t optrIdxListNum;
int32_t* optrIdxList;
int32_t runTimes; int32_t runTimes;
int32_t caseIdx; // static case idx int32_t caseIdx; // static case idx
int32_t caseNum; // num in static case list int32_t caseNum; // num in static case list
@ -178,8 +179,10 @@ CaseCtrl gCaseCtrl = {
.rowNum = 0, .rowNum = 0,
.bindColNum = 0, .bindColNum = 0,
.bindRowNum = 0, .bindRowNum = 0,
// .bindColTypeNum = 0, .bindColTypeNum = 0,
// .bindColTypeList = NULL, .bindColTypeList = NULL,
.optrIdxListNum = 0,
.optrIdxList = NULL,
.checkParamNum = false, .checkParamNum = false,
.printRes = true, .printRes = true,
.runTimes = 0, .runTimes = 0,
@ -188,8 +191,11 @@ CaseCtrl gCaseCtrl = {
.caseRunIdx = -1, .caseRunIdx = -1,
// .caseRunNum = -1, // .caseRunNum = -1,
.bindColTypeNum = tListLen(bindColTypeList),
.bindColTypeList = bindColTypeList, // .optrIdxListNum = tListLen(optrIdxList),
// .optrIdxList = optrIdxList,
// .bindColTypeNum = tListLen(bindColTypeList),
// .bindColTypeList = bindColTypeList,
.caseIdx = 22, .caseIdx = 22,
.caseNum = 1, .caseNum = 1,
.caseRunNum = 1, .caseRunNum = 1,
@ -210,10 +216,10 @@ CaseCtrl gCaseCtrl = {
.checkParamNum = false, .checkParamNum = false,
.printRes = true, .printRes = true,
.runTimes = 0, .runTimes = 0,
.caseIdx = -1, .caseIdx = 2,
.caseNum = -1, .caseNum = 1,
.caseRunIdx = -1, .caseRunIdx = -1,
.caseRunNum = -1, .caseRunNum = 1,
}; };
#endif #endif
@ -318,7 +324,7 @@ void generateInsertSQL(BindData *data) {
len += sprintf(data->sql + len, "ubigdata"); len += sprintf(data->sql + len, "ubigdata");
break; break;
default: default:
printf("invalid col type:%d", data->pBind[c].buffer_type); printf("!!!invalid col type:%d", data->pBind[c].buffer_type);
exit(1); exit(1);
} }
} }
@ -336,17 +342,21 @@ void generateInsertSQL(BindData *data) {
len += sprintf(data->sql + len, ")"); len += sprintf(data->sql + len, ")");
if (gCaseCtrl.printStmtSql) { if (gCaseCtrl.printStmtSql) {
printf("SQL: %s\n", data->sql); printf("\tSQL: %s\n", data->sql);
} }
} }
void bpAppendOperatorParam(BindData *data, int32_t *len, int32_t dataType) { void bpAppendOperatorParam(BindData *data, int32_t *len, int32_t dataType, int32_t idx) {
OperInfo *pInfo = NULL; OperInfo *pInfo = NULL;
if (TSDB_DATA_TYPE_VARCHAR == dataType || TSDB_DATA_TYPE_NCHAR == dataType) { if (gCaseCtrl.optrIdxListNum > 0) {
pInfo = &operInfo[varoperatorList[rand() % tListLen(varoperatorList)]]; pInfo = &operInfo[gCaseCtrl.optrIdxList[idx]];
} else { } else {
pInfo = &operInfo[operatorList[rand() % tListLen(operatorList)]]; if (TSDB_DATA_TYPE_VARCHAR == dataType || TSDB_DATA_TYPE_NCHAR == dataType) {
pInfo = &operInfo[varoperatorList[rand() % tListLen(varoperatorList)]];
} else {
pInfo = &operInfo[operatorList[rand() % tListLen(operatorList)]];
}
} }
switch (pInfo->paramNum) { switch (pInfo->paramNum) {
@ -358,7 +368,7 @@ void bpAppendOperatorParam(BindData *data, int32_t *len, int32_t dataType) {
} }
break; break;
default: default:
printf("invalid paramNum:%d\n", pInfo->paramNum); printf("!!!invalid paramNum:%d\n", pInfo->paramNum);
exit(1); exit(1);
} }
} }
@ -414,16 +424,16 @@ void generateQuerySQL(BindData *data, int32_t tblIdx) {
len += sprintf(data->sql + len, "ubigdata"); len += sprintf(data->sql + len, "ubigdata");
break; break;
default: default:
printf("invalid col type:%d", data->pBind[c].buffer_type); printf("!!!invalid col type:%d", data->pBind[c].buffer_type);
exit(1); exit(1);
} }
bpAppendOperatorParam(data, &len, data->pBind[c].buffer_type); bpAppendOperatorParam(data, &len, data->pBind[c].buffer_type, c);
} }
} }
if (gCaseCtrl.printStmtSql) { if (gCaseCtrl.printStmtSql) {
printf("SQL: %s\n", data->sql); printf("\tSTMT SQL: %s\n", data->sql);
} }
} }
@ -551,7 +561,7 @@ int32_t prepareColData(BindData *data, int32_t bindIdx, int32_t rowIdx, int32_t
data->pBind[bindIdx].is_null = data->isNull ? (data->isNull + rowIdx) : NULL; data->pBind[bindIdx].is_null = data->isNull ? (data->isNull + rowIdx) : NULL;
break; break;
default: default:
printf("invalid col type:%d", dataType); printf("!!!invalid col type:%d", dataType);
exit(1); exit(1);
} }
@ -709,7 +719,7 @@ void bpFetchRows(TAOS_RES *result, bool printr, int32_t *rows) {
if (printr) { if (printr) {
memset(temp, 0, sizeof(temp)); memset(temp, 0, sizeof(temp));
taos_print_row(temp, row, fields, num_fields); taos_print_row(temp, row, fields, num_fields);
printf("[%s]\n", temp); printf("\t[%s]\n", temp);
} }
} }
} }
@ -718,7 +728,7 @@ void bpExecQuery(TAOS * taos, char* sql, bool printr, int32_t *rows) {
TAOS_RES *result = taos_query(taos, sql); TAOS_RES *result = taos_query(taos, sql);
int code = taos_errno(result); int code = taos_errno(result);
if (code != 0) { if (code != 0) {
printf("failed to query table, reason:%s\n", taos_errstr(result)); printf("!!!failed to query table, reason:%s\n", taos_errstr(result));
taos_free_result(result); taos_free_result(result);
exit(1); exit(1);
} }
@ -791,7 +801,7 @@ int32_t bpAppendValueString(char *buf, int type, void *value, int32_t valueLen,
break; break;
default: default:
printf("invalid data type:%d\n", type); printf("!!!invalid data type:%d\n", type);
exit(1); exit(1);
} }
} }
@ -803,13 +813,13 @@ int32_t bpBindParam(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind) {
if (gCurCase->bindRowNum > 1) { if (gCurCase->bindRowNum > 1) {
if (0 == (n++%2)) { if (0 == (n++%2)) {
if (taos_stmt_bind_param_batch(stmt, bind)) { if (taos_stmt_bind_param_batch(stmt, bind)) {
printf("taos_stmt_bind_param_batch error:%s\n", taos_stmt_errstr(stmt)); printf("!!!taos_stmt_bind_param_batch error:%s\n", taos_stmt_errstr(stmt));
exit(1); exit(1);
} }
} else { } else {
for (int32_t i = 0; i < gCurCase->bindColNum; ++i) { for (int32_t i = 0; i < gCurCase->bindColNum; ++i) {
if (taos_stmt_bind_single_param_batch(stmt, bind++, i)) { if (taos_stmt_bind_single_param_batch(stmt, bind++, i)) {
printf("taos_stmt_bind_single_param_batch error:%s\n", taos_stmt_errstr(stmt)); printf("!!!taos_stmt_bind_single_param_batch error:%s\n", taos_stmt_errstr(stmt));
exit(1); exit(1);
} }
} }
@ -817,12 +827,12 @@ int32_t bpBindParam(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind) {
} else { } else {
if (0 == (n++%2)) { if (0 == (n++%2)) {
if (taos_stmt_bind_param_batch(stmt, bind)) { if (taos_stmt_bind_param_batch(stmt, bind)) {
printf("taos_stmt_bind_param_batch error:%s\n", taos_stmt_errstr(stmt)); printf("!!!taos_stmt_bind_param_batch error:%s\n", taos_stmt_errstr(stmt));
exit(1); exit(1);
} }
} else { } else {
if (taos_stmt_bind_param(stmt, bind)) { if (taos_stmt_bind_param(stmt, bind)) {
printf("taos_stmt_bind_param error:%s\n", taos_stmt_errstr(stmt)); printf("!!!taos_stmt_bind_param error:%s\n", taos_stmt_errstr(stmt));
exit(1); exit(1);
} }
} }
@ -834,12 +844,12 @@ int32_t bpBindParam(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind) {
void bpCheckIsInsert(TAOS_STMT *stmt, int32_t insert) { void bpCheckIsInsert(TAOS_STMT *stmt, int32_t insert) {
int32_t isInsert = 0; int32_t isInsert = 0;
if (taos_stmt_is_insert(stmt, &isInsert)) { if (taos_stmt_is_insert(stmt, &isInsert)) {
printf("taos_stmt_is_insert error:%s\n", taos_stmt_errstr(stmt)); printf("!!!taos_stmt_is_insert error:%s\n", taos_stmt_errstr(stmt));
exit(1); exit(1);
} }
if (insert != isInsert) { if (insert != isInsert) {
printf("is insert failed\n"); printf("!!!is insert failed\n");
exit(1); exit(1);
} }
} }
@ -847,12 +857,12 @@ void bpCheckIsInsert(TAOS_STMT *stmt, int32_t insert) {
void bpCheckParamNum(TAOS_STMT *stmt) { void bpCheckParamNum(TAOS_STMT *stmt) {
int32_t num = 0; int32_t num = 0;
if (taos_stmt_num_params(stmt, &num)) { if (taos_stmt_num_params(stmt, &num)) {
printf("taos_stmt_num_params error:%s\n", taos_stmt_errstr(stmt)); printf("!!!taos_stmt_num_params error:%s\n", taos_stmt_errstr(stmt));
exit(1); exit(1);
} }
if (gCurCase->bindColNum != num) { if (gCurCase->bindColNum != num) {
printf("is insert failed\n"); printf("!!!is insert failed\n");
exit(1); exit(1);
} }
} }
@ -861,7 +871,7 @@ void bpCheckAffectedRows(TAOS_STMT *stmt, int32_t times) {
int32_t rows = taos_stmt_affected_rows(stmt); int32_t rows = taos_stmt_affected_rows(stmt);
int32_t insertNum = gCurCase->rowNum * gCurCase->tblNum * times; int32_t insertNum = gCurCase->rowNum * gCurCase->tblNum * times;
if (insertNum != rows) { if (insertNum != rows) {
printf("affected rows %d mis-match with insert num %d\n", rows, insertNum); printf("!!!affected rows %d mis-match with insert num %d\n", rows, insertNum);
exit(1); exit(1);
} }
} }
@ -869,7 +879,7 @@ void bpCheckAffectedRows(TAOS_STMT *stmt, int32_t times) {
void bpCheckAffectedRowsOnce(TAOS_STMT *stmt, int32_t expectedNum) { void bpCheckAffectedRowsOnce(TAOS_STMT *stmt, int32_t expectedNum) {
int32_t rows = taos_stmt_affected_rows_once(stmt); int32_t rows = taos_stmt_affected_rows_once(stmt);
if (expectedNum != rows) { if (expectedNum != rows) {
printf("affected rows %d mis-match with expected num %d\n", rows, expectedNum); printf("!!!affected rows %d mis-match with expected num %d\n", rows, expectedNum);
exit(1); exit(1);
} }
} }
@ -904,16 +914,16 @@ void bpCheckQueryResult(TAOS_STMT *stmt, TAOS *taos, char *stmtSql, TAOS_MULTI_B
} }
if (gCaseCtrl.printQuerySql) { if (gCaseCtrl.printQuerySql) {
printf("Query SQL: %s\n", sql); printf("\tQuery SQL: %s\n", sql);
} }
bpExecQuery(taos, sql, gCaseCtrl.printRes, &sqlResNum); bpExecQuery(taos, sql, gCaseCtrl.printRes, &sqlResNum);
if (sqlResNum != stmtResNum) { if (sqlResNum != stmtResNum) {
printf("sql res num %d mis-match stmt res num %d\n", sqlResNum, stmtResNum); printf("!!!sql res num %d mis-match stmt res num %d\n", sqlResNum, stmtResNum);
exit(1); exit(1);
} }
printf("sql res num match stmt res num %d\n", stmtResNum); printf("***sql res num match stmt res num %d\n", stmtResNum);
} }
/* prepare [settbname [bind add]] exec */ /* prepare [settbname [bind add]] exec */
@ -923,7 +933,7 @@ int insertMBSETest1(TAOS_STMT *stmt, TAOS *taos) {
int code = taos_stmt_prepare(stmt, data.sql, 0); int code = taos_stmt_prepare(stmt, data.sql, 0);
if (code != 0){ if (code != 0){
printf("failed to execute taos_stmt_prepare. error:%s\n", taos_stmt_errstr(stmt)); printf("!!!failed to execute taos_stmt_prepare. error:%s\n", taos_stmt_errstr(stmt));
exit(1); exit(1);
} }
@ -936,7 +946,7 @@ int insertMBSETest1(TAOS_STMT *stmt, TAOS *taos) {
sprintf(buf, "t%d", t); sprintf(buf, "t%d", t);
code = taos_stmt_set_tbname(stmt, buf); code = taos_stmt_set_tbname(stmt, buf);
if (code != 0){ if (code != 0){
printf("taos_stmt_set_tbname error:%s\n", taos_stmt_errstr(stmt)); printf("!!!taos_stmt_set_tbname error:%s\n", taos_stmt_errstr(stmt));
exit(1); exit(1);
} }
} }
@ -951,14 +961,14 @@ int insertMBSETest1(TAOS_STMT *stmt, TAOS *taos) {
} }
if (taos_stmt_add_batch(stmt)) { if (taos_stmt_add_batch(stmt)) {
printf("taos_stmt_add_batch error:%s\n", taos_stmt_errstr(stmt)); printf("!!!taos_stmt_add_batch error:%s\n", taos_stmt_errstr(stmt));
exit(1); exit(1);
} }
} }
} }
if (taos_stmt_execute(stmt) != 0) { if (taos_stmt_execute(stmt) != 0) {
printf("taos_stmt_execute error:%s\n", taos_stmt_errstr(stmt)); printf("!!!taos_stmt_execute error:%s\n", taos_stmt_errstr(stmt));
exit(1); exit(1);
} }
@ -978,7 +988,7 @@ int insertMBSETest2(TAOS_STMT *stmt, TAOS *taos) {
int code = taos_stmt_prepare(stmt, data.sql, 0); int code = taos_stmt_prepare(stmt, data.sql, 0);
if (code != 0){ if (code != 0){
printf("failed to execute taos_stmt_prepare. error:%s\n", taos_stmt_errstr(stmt)); printf("!!!failed to execute taos_stmt_prepare. error:%s\n", taos_stmt_errstr(stmt));
exit(1); exit(1);
} }
@ -993,7 +1003,7 @@ int insertMBSETest2(TAOS_STMT *stmt, TAOS *taos) {
sprintf(buf, "t%d", t); sprintf(buf, "t%d", t);
code = taos_stmt_set_tbname(stmt, buf); code = taos_stmt_set_tbname(stmt, buf);
if (code != 0){ if (code != 0){
printf("taos_stmt_set_tbname error:%s\n", taos_stmt_errstr(stmt)); printf("!!!taos_stmt_set_tbname error:%s\n", taos_stmt_errstr(stmt));
exit(1); exit(1);
} }
} }
@ -1007,14 +1017,14 @@ int insertMBSETest2(TAOS_STMT *stmt, TAOS *taos) {
} }
if (taos_stmt_add_batch(stmt)) { if (taos_stmt_add_batch(stmt)) {
printf("taos_stmt_add_batch error:%s\n", taos_stmt_errstr(stmt)); printf("!!!taos_stmt_add_batch error:%s\n", taos_stmt_errstr(stmt));
exit(1); exit(1);
} }
} }
} }
if (taos_stmt_execute(stmt) != 0) { if (taos_stmt_execute(stmt) != 0) {
printf("taos_stmt_execute error:%s\n", taos_stmt_errstr(stmt)); printf("!!!taos_stmt_execute error:%s\n", taos_stmt_errstr(stmt));
exit(1); exit(1);
} }
@ -1033,7 +1043,7 @@ int insertMBMETest1(TAOS_STMT *stmt, TAOS *taos) {
int code = taos_stmt_prepare(stmt, data.sql, 0); int code = taos_stmt_prepare(stmt, data.sql, 0);
if (code != 0){ if (code != 0){
printf("failed to execute taos_stmt_prepare. error:%s\n", taos_stmt_errstr(stmt)); printf("!!!failed to execute taos_stmt_prepare. error:%s\n", taos_stmt_errstr(stmt));
exit(1); exit(1);
} }
@ -1046,7 +1056,7 @@ int insertMBMETest1(TAOS_STMT *stmt, TAOS *taos) {
sprintf(buf, "t%d", t); sprintf(buf, "t%d", t);
code = taos_stmt_set_tbname(stmt, buf); code = taos_stmt_set_tbname(stmt, buf);
if (code != 0){ if (code != 0){
printf("taos_stmt_set_tbname error:%s\n", taos_stmt_errstr(stmt)); printf("!!!taos_stmt_set_tbname error:%s\n", taos_stmt_errstr(stmt));
exit(1); exit(1);
} }
} }
@ -1061,13 +1071,13 @@ int insertMBMETest1(TAOS_STMT *stmt, TAOS *taos) {
} }
if (taos_stmt_add_batch(stmt)) { if (taos_stmt_add_batch(stmt)) {
printf("taos_stmt_add_batch error:%s\n", taos_stmt_errstr(stmt)); printf("!!!taos_stmt_add_batch error:%s\n", taos_stmt_errstr(stmt));
exit(1); exit(1);
} }
} }
if (taos_stmt_execute(stmt) != 0) { if (taos_stmt_execute(stmt) != 0) {
printf("taos_stmt_execute error:%s\n", taos_stmt_errstr(stmt)); printf("!!!taos_stmt_execute error:%s\n", taos_stmt_errstr(stmt));
exit(1); exit(1);
} }
} }
@ -1087,7 +1097,7 @@ int insertMBMETest2(TAOS_STMT *stmt, TAOS *taos) {
int code = taos_stmt_prepare(stmt, data.sql, 0); int code = taos_stmt_prepare(stmt, data.sql, 0);
if (code != 0){ if (code != 0){
printf("failed to execute taos_stmt_prepare. error:%s\n", taos_stmt_errstr(stmt)); printf("!!!failed to execute taos_stmt_prepare. error:%s\n", taos_stmt_errstr(stmt));
exit(1); exit(1);
} }
@ -1100,7 +1110,7 @@ int insertMBMETest2(TAOS_STMT *stmt, TAOS *taos) {
sprintf(buf, "t%d", t); sprintf(buf, "t%d", t);
code = taos_stmt_set_tbname(stmt, buf); code = taos_stmt_set_tbname(stmt, buf);
if (code != 0){ if (code != 0){
printf("taos_stmt_set_tbname error:%s\n", taos_stmt_errstr(stmt)); printf("!!!taos_stmt_set_tbname error:%s\n", taos_stmt_errstr(stmt));
exit(1); exit(1);
} }
} }
@ -1115,12 +1125,12 @@ int insertMBMETest2(TAOS_STMT *stmt, TAOS *taos) {
} }
if (taos_stmt_add_batch(stmt)) { if (taos_stmt_add_batch(stmt)) {
printf("taos_stmt_add_batch error:%s\n", taos_stmt_errstr(stmt)); printf("!!!taos_stmt_add_batch error:%s\n", taos_stmt_errstr(stmt));
exit(1); exit(1);
} }
if (taos_stmt_execute(stmt) != 0) { if (taos_stmt_execute(stmt) != 0) {
printf("taos_stmt_execute error:%s\n", taos_stmt_errstr(stmt)); printf("!!!taos_stmt_execute error:%s\n", taos_stmt_errstr(stmt));
exit(1); exit(1);
} }
} }
@ -1141,7 +1151,7 @@ int insertMBMETest3(TAOS_STMT *stmt, TAOS *taos) {
int code = taos_stmt_prepare(stmt, data.sql, 0); int code = taos_stmt_prepare(stmt, data.sql, 0);
if (code != 0){ if (code != 0){
printf("failed to execute taos_stmt_prepare. error:%s\n", taos_stmt_errstr(stmt)); printf("!!!failed to execute taos_stmt_prepare. error:%s\n", taos_stmt_errstr(stmt));
exit(1); exit(1);
} }
@ -1154,7 +1164,7 @@ int insertMBMETest3(TAOS_STMT *stmt, TAOS *taos) {
sprintf(buf, "t%d", t); sprintf(buf, "t%d", t);
code = taos_stmt_set_tbname(stmt, buf); code = taos_stmt_set_tbname(stmt, buf);
if (code != 0){ if (code != 0){
printf("taos_stmt_set_tbname error:%s\n", taos_stmt_errstr(stmt)); printf("!!!taos_stmt_set_tbname error:%s\n", taos_stmt_errstr(stmt));
exit(1); exit(1);
} }
} }
@ -1169,7 +1179,7 @@ int insertMBMETest3(TAOS_STMT *stmt, TAOS *taos) {
sprintf(buf, "t%d", t); sprintf(buf, "t%d", t);
code = taos_stmt_set_tbname(stmt, buf); code = taos_stmt_set_tbname(stmt, buf);
if (code != 0){ if (code != 0){
printf("taos_stmt_set_tbname error:%s\n", taos_stmt_errstr(stmt)); printf("!!!taos_stmt_set_tbname error:%s\n", taos_stmt_errstr(stmt));
exit(1); exit(1);
} }
} }
@ -1179,12 +1189,12 @@ int insertMBMETest3(TAOS_STMT *stmt, TAOS *taos) {
} }
if (taos_stmt_add_batch(stmt)) { if (taos_stmt_add_batch(stmt)) {
printf("taos_stmt_add_batch error:%s\n", taos_stmt_errstr(stmt)); printf("!!!taos_stmt_add_batch error:%s\n", taos_stmt_errstr(stmt));
exit(1); exit(1);
} }
if (taos_stmt_execute(stmt) != 0) { if (taos_stmt_execute(stmt) != 0) {
printf("taos_stmt_execute error:%s\n", taos_stmt_errstr(stmt)); printf("!!!taos_stmt_execute error:%s\n", taos_stmt_errstr(stmt));
exit(1); exit(1);
} }
} }
@ -1206,7 +1216,7 @@ int insertMBMETest4(TAOS_STMT *stmt, TAOS *taos) {
int code = taos_stmt_prepare(stmt, data.sql, 0); int code = taos_stmt_prepare(stmt, data.sql, 0);
if (code != 0){ if (code != 0){
printf("failed to execute taos_stmt_prepare. error:%s\n", taos_stmt_errstr(stmt)); printf("!!!failed to execute taos_stmt_prepare. error:%s\n", taos_stmt_errstr(stmt));
exit(1); exit(1);
} }
@ -1221,7 +1231,7 @@ int insertMBMETest4(TAOS_STMT *stmt, TAOS *taos) {
sprintf(buf, "t%d", t); sprintf(buf, "t%d", t);
code = taos_stmt_set_tbname(stmt, buf); code = taos_stmt_set_tbname(stmt, buf);
if (code != 0){ if (code != 0){
printf("taos_stmt_set_tbname error:%s\n", taos_stmt_errstr(stmt)); printf("!!!taos_stmt_set_tbname error:%s\n", taos_stmt_errstr(stmt));
exit(1); exit(1);
} }
} }
@ -1235,12 +1245,12 @@ int insertMBMETest4(TAOS_STMT *stmt, TAOS *taos) {
} }
if (taos_stmt_add_batch(stmt)) { if (taos_stmt_add_batch(stmt)) {
printf("taos_stmt_add_batch error:%s\n", taos_stmt_errstr(stmt)); printf("!!!taos_stmt_add_batch error:%s\n", taos_stmt_errstr(stmt));
exit(1); exit(1);
} }
if (taos_stmt_execute(stmt) != 0) { if (taos_stmt_execute(stmt) != 0) {
printf("taos_stmt_execute error:%s\n", taos_stmt_errstr(stmt)); printf("!!!taos_stmt_execute error:%s\n", taos_stmt_errstr(stmt));
exit(1); exit(1);
} }
} }
@ -1264,7 +1274,7 @@ int insertMPMETest1(TAOS_STMT *stmt, TAOS *taos) {
int code = taos_stmt_prepare(stmt, data.sql, 0); int code = taos_stmt_prepare(stmt, data.sql, 0);
if (code != 0){ if (code != 0){
printf("failed to execute taos_stmt_prepare. error:%s\n", taos_stmt_errstr(stmt)); printf("!!!failed to execute taos_stmt_prepare. error:%s\n", taos_stmt_errstr(stmt));
exit(1); exit(1);
} }
@ -1277,7 +1287,7 @@ int insertMPMETest1(TAOS_STMT *stmt, TAOS *taos) {
sprintf(buf, "t%d", t); sprintf(buf, "t%d", t);
code = taos_stmt_set_tbname(stmt, buf); code = taos_stmt_set_tbname(stmt, buf);
if (code != 0){ if (code != 0){
printf("taos_stmt_set_tbname error:%s\n", taos_stmt_errstr(stmt)); printf("!!!taos_stmt_set_tbname error:%s\n", taos_stmt_errstr(stmt));
exit(1); exit(1);
} }
} }
@ -1292,13 +1302,13 @@ int insertMPMETest1(TAOS_STMT *stmt, TAOS *taos) {
} }
if (taos_stmt_add_batch(stmt)) { if (taos_stmt_add_batch(stmt)) {
printf("taos_stmt_add_batch error:%s\n", taos_stmt_errstr(stmt)); printf("!!!taos_stmt_add_batch error:%s\n", taos_stmt_errstr(stmt));
exit(1); exit(1);
} }
} }
if (taos_stmt_execute(stmt) != 0) { if (taos_stmt_execute(stmt) != 0) {
printf("taos_stmt_execute error:%s\n", taos_stmt_errstr(stmt)); printf("!!!taos_stmt_execute error:%s\n", taos_stmt_errstr(stmt));
exit(1); exit(1);
} }
} }
@ -1328,7 +1338,7 @@ int querySUBTTest1(TAOS_STMT *stmt, TAOS *taos) {
int code = taos_stmt_prepare(stmt, data.sql, 0); int code = taos_stmt_prepare(stmt, data.sql, 0);
if (code != 0){ if (code != 0){
printf("failed to execute taos_stmt_prepare. error:%s\n", taos_stmt_errstr(stmt)); printf("!!!failed to execute taos_stmt_prepare. error:%s\n", taos_stmt_errstr(stmt));
exit(1); exit(1);
} }
@ -1344,12 +1354,12 @@ int querySUBTTest1(TAOS_STMT *stmt, TAOS *taos) {
} }
if (taos_stmt_add_batch(stmt)) { if (taos_stmt_add_batch(stmt)) {
printf("taos_stmt_add_batch error:%s\n", taos_stmt_errstr(stmt)); printf("!!!taos_stmt_add_batch error:%s\n", taos_stmt_errstr(stmt));
exit(1); exit(1);
} }
if (taos_stmt_execute(stmt) != 0) { if (taos_stmt_execute(stmt) != 0) {
printf("taos_stmt_execute error:%s\n", taos_stmt_errstr(stmt)); printf("!!!taos_stmt_execute error:%s\n", taos_stmt_errstr(stmt));
exit(1); exit(1);
} }
@ -4249,10 +4259,10 @@ void prepareCheckResultImpl(TAOS * taos, char *tname, bool printr, int expec
if (rows == expected) { if (rows == expected) {
if (!silent) { if (!silent) {
printf("%d rows are fetched as expected from %s\n", rows, tname); printf("***%d rows are fetched as expected from %s\n", rows, tname);
} }
} else { } else {
printf("!!!expect %d rows, but %d rows are fetched from %s\n", expected, rows, tname); printf("!!!expect rows %d mis-match rows %d fetched from %s\n", expected, rows, tname);
exit(1); exit(1);
} }
} }
@ -4302,7 +4312,7 @@ int sql_perf1(TAOS *taos) {
result = taos_query(taos, sql[i]); result = taos_query(taos, sql[i]);
int code = taos_errno(result); int code = taos_errno(result);
if (code != 0) { if (code != 0) {
printf("failed to query table, reason:%s\n", taos_errstr(result)); printf("%d failed to query table, reason:%s\n", taos_errstr(result));
taos_free_result(result); taos_free_result(result);
exit(1); exit(1);
} }
@ -4539,7 +4549,7 @@ void generateCreateTableSQL(char *buf, int32_t tblIdx, int32_t colNum, int32_t *
blen += sprintf(buf + blen, ")"); blen += sprintf(buf + blen, ")");
if (gCaseCtrl.printCreateTblSql) { if (gCaseCtrl.printCreateTblSql) {
printf("Create Table SQL:%s\n", buf); printf("\tCreate Table SQL:%s\n", buf);
} }
} }
@ -4553,7 +4563,7 @@ void prepare(TAOS *taos, int32_t colNum, int32_t *colList, int prepareStb) {
result = taos_query(taos, "create database demo keep 36500"); result = taos_query(taos, "create database demo keep 36500");
code = taos_errno(result); code = taos_errno(result);
if (code != 0) { if (code != 0) {
printf("failed to create database, reason:%s\n", taos_errstr(result)); printf("!!!failed to create database, reason:%s\n", taos_errstr(result));
taos_free_result(result); taos_free_result(result);
exit(1); exit(1);
} }
@ -4570,7 +4580,7 @@ void prepare(TAOS *taos, int32_t colNum, int32_t *colList, int prepareStb) {
result = taos_query(taos, buf); result = taos_query(taos, buf);
code = taos_errno(result); code = taos_errno(result);
if (code != 0) { if (code != 0) {
printf("failed to create table, reason:%s\n", taos_errstr(result)); printf("!!!failed to create table, reason:%s\n", taos_errstr(result));
taos_free_result(result); taos_free_result(result);
exit(1); exit(1);
} }
@ -4583,7 +4593,7 @@ void prepare(TAOS *taos, int32_t colNum, int32_t *colList, int prepareStb) {
result = taos_query(taos, buf); result = taos_query(taos, buf);
code = taos_errno(result); code = taos_errno(result);
if (code != 0) { if (code != 0) {
printf("failed to create table, reason:%s\n", taos_errstr(result)); printf("!!!failed to create table, reason:%s\n", taos_errstr(result));
taos_free_result(result); taos_free_result(result);
exit(1); exit(1);
} }
@ -4654,7 +4664,7 @@ int32_t runCase(TAOS *taos, int32_t caseIdx, int32_t caseRunIdx, bool silent) {
stmt = taos_stmt_init(taos); stmt = taos_stmt_init(taos);
if (NULL == stmt) { if (NULL == stmt) {
printf("taos_stmt_init failed, error:%s\n", taos_stmt_errstr(stmt)); printf("!!!taos_stmt_init failed, error:%s\n", taos_stmt_errstr(stmt));
exit(1); exit(1);
} }