未验证 提交 21a31e41 编写于 作者: S Shengliang Guan 提交者: GitHub

Merge pull request #12450 from taosdata/feature/qnode

fix: fix catalog stable meta update issue
...@@ -71,7 +71,6 @@ typedef struct SStmtBindInfo { ...@@ -71,7 +71,6 @@ typedef struct SStmtBindInfo {
typedef struct SStmtExecInfo { typedef struct SStmtExecInfo {
int32_t affectedRows; int32_t affectedRows;
bool emptyRes;
SRequestObj* pRequest; SRequestObj* pRequest;
SHashObj* pVgHash; SHashObj* pVgHash;
SHashObj* pBlockHash; SHashObj* pBlockHash;
...@@ -87,7 +86,6 @@ typedef struct SStmtSQLInfo { ...@@ -87,7 +86,6 @@ typedef struct SStmtSQLInfo {
char* sqlStr; char* sqlStr;
int32_t sqlLen; int32_t sqlLen;
SArray* nodeList; SArray* nodeList;
SQueryPlan* pQueryPlan;
SStmtQueryResInfo queryRes; SStmtQueryResInfo queryRes;
bool autoCreateTbl; bool autoCreateTbl;
} SStmtSQLInfo; } SStmtSQLInfo;
......
...@@ -279,7 +279,6 @@ int32_t stmtCleanExecInfo(STscStmt* pStmt, bool keepTable, bool freeRequest) { ...@@ -279,7 +279,6 @@ int32_t stmtCleanExecInfo(STscStmt* pStmt, bool keepTable, bool freeRequest) {
} }
pStmt->exec.autoCreateTbl = false; pStmt->exec.autoCreateTbl = false;
pStmt->exec.emptyRes = false;
if (keepTable) { if (keepTable) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
...@@ -298,7 +297,6 @@ int32_t stmtCleanSQLInfo(STscStmt* pStmt) { ...@@ -298,7 +297,6 @@ int32_t stmtCleanSQLInfo(STscStmt* pStmt) {
taosMemoryFree(pStmt->sql.queryRes.userFields); 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);
taosArrayDestroy(pStmt->sql.nodeList); taosArrayDestroy(pStmt->sql.nodeList);
void* pIter = taosHashIterate(pStmt->sql.pTableCache, NULL); void* pIter = taosHashIterate(pStmt->sql.pTableCache, NULL);
...@@ -599,6 +597,8 @@ int32_t stmtFetchColFields(STscStmt* pStmt, int32_t* fieldNum, TAOS_FIELD** fiel ...@@ -599,6 +597,8 @@ int32_t stmtFetchColFields(STscStmt* pStmt, int32_t* fieldNum, TAOS_FIELD** fiel
int stmtBindBatch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind, int32_t colIdx) { int stmtBindBatch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind, int32_t colIdx) {
STscStmt* pStmt = (STscStmt*)stmt; STscStmt* pStmt = (STscStmt*)stmt;
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_BIND));
if (pStmt->bInfo.needParse && pStmt->sql.runTimes && pStmt->sql.type > 0 && if (pStmt->bInfo.needParse && pStmt->sql.runTimes && pStmt->sql.type > 0 &&
STMT_TYPE_MULTI_INSERT != pStmt->sql.type) { STMT_TYPE_MULTI_INSERT != pStmt->sql.type) {
pStmt->bInfo.needParse = false; pStmt->bInfo.needParse = false;
...@@ -617,21 +617,42 @@ int stmtBindBatch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind, int32_t colIdx) { ...@@ -617,21 +617,42 @@ int stmtBindBatch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind, int32_t colIdx) {
STMT_ERR_RET(stmtParseSql(pStmt)); STMT_ERR_RET(stmtParseSql(pStmt));
} }
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_BIND));
if (STMT_TYPE_QUERY == pStmt->sql.type) { if (STMT_TYPE_QUERY == pStmt->sql.type) {
if (NULL == pStmt->sql.pQueryPlan) { STMT_ERR_RET(qStmtBindParams(pStmt->sql.pQuery, bind, colIdx, pStmt->exec.pRequest->requestId));
STMT_ERR_RET(getQueryPlan(pStmt->exec.pRequest, pStmt->sql.pQuery, &pStmt->sql.nodeList));
pStmt->sql.pQueryPlan = pStmt->exec.pRequest->body.pDag; SParseContext ctx = {.requestId = pStmt->exec.pRequest->requestId,
pStmt->exec.pRequest->body.pDag = NULL; .acctId = pStmt->taos->acctId,
STMT_ERR_RET(stmtBackupQueryFields(pStmt)); .db = pStmt->exec.pRequest->pDb,
} else { .topicQuery = false,
STMT_ERR_RET(stmtRestoreQueryFields(pStmt)); .pSql = pStmt->sql.sqlStr,
.sqlLen = pStmt->sql.sqlLen,
.pMsg = pStmt->exec.pRequest->msgBuf,
.msgLen = ERROR_MSG_BUF_DEFAULT_SIZE,
.pTransporter = pStmt->taos->pAppInfo->pTransporter,
.pStmtCb = NULL,
.pUser = pStmt->taos->user};
ctx.mgmtEpSet = getEpSet_s(&pStmt->taos->pAppInfo->mgmtEp);
STMT_ERR_RET(catalogGetHandle(pStmt->taos->pAppInfo->clusterId, &ctx.pCatalog));
STMT_ERR_RET(qStmtParseQuerySql(&ctx, pStmt->sql.pQuery));
if (pStmt->sql.pQuery->haveResultSet) {
setResSchemaInfo(&pStmt->exec.pRequest->body.resInfo, pStmt->sql.pQuery->pResSchema, pStmt->sql.pQuery->numOfResCols);
setResPrecision(&pStmt->exec.pRequest->body.resInfo, pStmt->sql.pQuery->precision);
} }
TSWAP(pStmt->exec.pRequest->dbList, pStmt->sql.pQuery->pDbList);
TSWAP(pStmt->exec.pRequest->tableList, pStmt->sql.pQuery->pTableList);
STMT_RET(qStmtBindParam(pStmt->sql.pQueryPlan, bind, colIdx, pStmt->exec.pRequest->requestId, &pStmt->exec.emptyRes)); //if (STMT_TYPE_QUERY == pStmt->sql.queryRes) {
// STMT_ERR_RET(stmtRestoreQueryFields(pStmt));
//}
//STMT_ERR_RET(stmtBackupQueryFields(pStmt));
return TSDB_CODE_SUCCESS;
} }
STableDataBlocks **pDataBlock = (STableDataBlocks**)taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName)); STableDataBlocks **pDataBlock = (STableDataBlocks**)taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName));
if (NULL == pDataBlock) { if (NULL == pDataBlock) {
tscError("table %s not found in exec blockHash", pStmt->bInfo.tbFName); tscError("table %s not found in exec blockHash", pStmt->bInfo.tbFName);
...@@ -736,11 +757,7 @@ int stmtExec(TAOS_STMT *stmt) { ...@@ -736,11 +757,7 @@ int stmtExec(TAOS_STMT *stmt) {
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_EXECUTE)); STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_EXECUTE));
if (STMT_TYPE_QUERY == pStmt->sql.type) { if (STMT_TYPE_QUERY == pStmt->sql.type) {
if (pStmt->exec.emptyRes) { launchQueryImpl(pStmt->exec.pRequest, pStmt->sql.pQuery, TSDB_CODE_SUCCESS, true, NULL);
pStmt->exec.pRequest->type = TSDB_SQL_RETRIEVE_EMPTY_RESULT;
} else {
scheduleQuery(pStmt->exec.pRequest, pStmt->sql.pQueryPlan, pStmt->sql.nodeList, NULL);
}
} else { } else {
STMT_ERR_RET(qBuildStmtOutput(pStmt->sql.pQuery, pStmt->exec.pVgHash, pStmt->exec.pBlockHash)); STMT_ERR_RET(qBuildStmtOutput(pStmt->sql.pQuery, pStmt->exec.pVgHash, pStmt->exec.pBlockHash));
launchQueryImpl(pStmt->exec.pRequest, pStmt->sql.pQuery, TSDB_CODE_SUCCESS, true, (autoCreateTbl ? (void**)&pRsp : NULL)); launchQueryImpl(pStmt->exec.pRequest, pStmt->sql.pQuery, TSDB_CODE_SUCCESS, true, (autoCreateTbl ? (void**)&pRsp : NULL));
...@@ -839,16 +856,7 @@ int stmtGetParamNum(TAOS_STMT* stmt, int* nums) { ...@@ -839,16 +856,7 @@ int stmtGetParamNum(TAOS_STMT* stmt, int* nums) {
} }
if (STMT_TYPE_QUERY == pStmt->sql.type) { if (STMT_TYPE_QUERY == pStmt->sql.type) {
if (NULL == pStmt->sql.pQueryPlan) { *nums = taosArrayGetSize(pStmt->sql.pQuery->pPlaceholderValues);
STMT_ERR_RET(getQueryPlan(pStmt->exec.pRequest, pStmt->sql.pQuery, &pStmt->sql.nodeList));
pStmt->sql.pQueryPlan = pStmt->exec.pRequest->body.pDag;
pStmt->exec.pRequest->body.pDag = NULL;
STMT_ERR_RET(stmtBackupQueryFields(pStmt));
} else {
STMT_ERR_RET(stmtRestoreQueryFields(pStmt));
}
*nums = taosArrayGetSize(pStmt->sql.pQueryPlan->pPlaceholderValues);
} else { } else {
STMT_ERR_RET(stmtFetchColFields(stmt, nums, NULL)); STMT_ERR_RET(stmtFetchColFields(stmt, nums, NULL));
} }
......
...@@ -279,6 +279,7 @@ int32_t taosAddClientLogCfg(SConfig *pCfg) { ...@@ -279,6 +279,7 @@ int32_t taosAddClientLogCfg(SConfig *pCfg) {
if (cfgAddInt32(pCfg, "cDebugFlag", cDebugFlag, 0, 255, 1) != 0) return -1; if (cfgAddInt32(pCfg, "cDebugFlag", cDebugFlag, 0, 255, 1) != 0) return -1;
if (cfgAddInt32(pCfg, "uDebugFlag", uDebugFlag, 0, 255, 1) != 0) return -1; if (cfgAddInt32(pCfg, "uDebugFlag", uDebugFlag, 0, 255, 1) != 0) return -1;
if (cfgAddInt32(pCfg, "rpcDebugFlag", rpcDebugFlag, 0, 255, 1) != 0) return -1; if (cfgAddInt32(pCfg, "rpcDebugFlag", rpcDebugFlag, 0, 255, 1) != 0) return -1;
if (cfgAddInt32(pCfg, "qDebugFlag", qDebugFlag, 0, 255, 1) != 0) return -1;
if (cfgAddInt32(pCfg, "tmrDebugFlag", tmrDebugFlag, 0, 255, 1) != 0) return -1; if (cfgAddInt32(pCfg, "tmrDebugFlag", tmrDebugFlag, 0, 255, 1) != 0) return -1;
if (cfgAddInt32(pCfg, "jniDebugFlag", jniDebugFlag, 0, 255, 1) != 0) return -1; if (cfgAddInt32(pCfg, "jniDebugFlag", jniDebugFlag, 0, 255, 1) != 0) return -1;
if (cfgAddInt32(pCfg, "simDebugFlag", 143, 0, 255, 1) != 0) return -1; if (cfgAddInt32(pCfg, "simDebugFlag", 143, 0, 255, 1) != 0) return -1;
...@@ -456,6 +457,7 @@ static void taosSetClientLogCfg(SConfig *pCfg) { ...@@ -456,6 +457,7 @@ static void taosSetClientLogCfg(SConfig *pCfg) {
tsLogKeepDays = cfgGetItem(pCfg, "logKeepDays")->i32; tsLogKeepDays = cfgGetItem(pCfg, "logKeepDays")->i32;
cDebugFlag = cfgGetItem(pCfg, "cDebugFlag")->i32; cDebugFlag = cfgGetItem(pCfg, "cDebugFlag")->i32;
uDebugFlag = cfgGetItem(pCfg, "uDebugFlag")->i32; uDebugFlag = cfgGetItem(pCfg, "uDebugFlag")->i32;
qDebugFlag = cfgGetItem(pCfg, "qDebugFlag")->i32;
rpcDebugFlag = cfgGetItem(pCfg, "rpcDebugFlag")->i32; rpcDebugFlag = cfgGetItem(pCfg, "rpcDebugFlag")->i32;
tmrDebugFlag = cfgGetItem(pCfg, "tmrDebugFlag")->i32; tmrDebugFlag = cfgGetItem(pCfg, "tmrDebugFlag")->i32;
jniDebugFlag = cfgGetItem(pCfg, "jniDebugFlag")->i32; jniDebugFlag = cfgGetItem(pCfg, "jniDebugFlag")->i32;
......
...@@ -841,6 +841,8 @@ int32_t ctgGetTableMetaFromCache(SCatalog* pCtg, const SName* pTableName, STable ...@@ -841,6 +841,8 @@ int32_t ctgGetTableMetaFromCache(SCatalog* pCtg, const SName* pTableName, STable
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
ctgDebug("Got subtable meta from cache, type:%d, dbFName:%s, tbName:%s, suid:%" PRIx64, tbMeta->tableType, dbFName, pTableName->tname, tbMeta->suid);
CTG_LOCK(CTG_READ, &dbCache->tbCache.stbLock); CTG_LOCK(CTG_READ, &dbCache->tbCache.stbLock);
...@@ -1655,6 +1657,11 @@ int32_t ctgUpdateTblMeta(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFName, ui ...@@ -1655,6 +1657,11 @@ int32_t ctgUpdateTblMeta(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFName, ui
STableMeta *orig = taosHashGet(tbCache->metaCache, tbName, strlen(tbName)); STableMeta *orig = taosHashGet(tbCache->metaCache, tbName, strlen(tbName));
if (orig) { if (orig) {
origType = orig->tableType; origType = orig->tableType;
if (origType == meta->tableType && orig->uid == meta->uid && orig->sversion >= meta->sversion && orig->tversion >= meta->tversion) {
CTG_UNLOCK(CTG_READ, &tbCache->metaLock);
return TSDB_CODE_SUCCESS;
}
if (origType == TSDB_SUPER_TABLE) { if (origType == TSDB_SUPER_TABLE) {
if ((!isStb) || orig->suid != meta->suid) { if ((!isStb) || orig->suid != meta->suid) {
...@@ -1693,7 +1700,7 @@ int32_t ctgUpdateTblMeta(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFName, ui ...@@ -1693,7 +1700,7 @@ int32_t ctgUpdateTblMeta(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFName, ui
CTG_CACHE_STAT_ADD(tblNum, 1); CTG_CACHE_STAT_ADD(tblNum, 1);
} }
ctgDebug("tbmeta updated to cache, dbFName:%s, tbName:%s, tbType:%d", dbFName, tbName, meta->tableType); ctgDebug("tbmeta updated to cache, dbFName:%s, tbName:%s, tbType:%d, suid:%" PRIx64, dbFName, tbName, meta->tableType, meta->suid);
ctgdShowTableMeta(pCtg, tbName, meta); ctgdShowTableMeta(pCtg, tbName, meta);
if (!isStb) { if (!isStb) {
...@@ -1701,12 +1708,6 @@ int32_t ctgUpdateTblMeta(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFName, ui ...@@ -1701,12 +1708,6 @@ int32_t ctgUpdateTblMeta(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFName, ui
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
if (origType == TSDB_SUPER_TABLE && origSuid == meta->suid) {
CTG_UNLOCK(CTG_WRITE, &tbCache->stbLock);
CTG_UNLOCK(CTG_READ, &tbCache->metaLock);
return TSDB_CODE_SUCCESS;
}
STableMeta *tbMeta = taosHashGet(tbCache->metaCache, tbName, strlen(tbName)); STableMeta *tbMeta = taosHashGet(tbCache->metaCache, tbName, strlen(tbName));
if (taosHashPut(tbCache->stbCache, &meta->suid, sizeof(meta->suid), &tbMeta, POINTER_BYTES) != 0) { if (taosHashPut(tbCache->stbCache, &meta->suid, sizeof(meta->suid), &tbMeta, POINTER_BYTES) != 0) {
CTG_UNLOCK(CTG_WRITE, &tbCache->stbLock); CTG_UNLOCK(CTG_WRITE, &tbCache->stbLock);
...@@ -1721,7 +1722,7 @@ int32_t ctgUpdateTblMeta(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFName, ui ...@@ -1721,7 +1722,7 @@ int32_t ctgUpdateTblMeta(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFName, ui
CTG_UNLOCK(CTG_READ, &tbCache->metaLock); CTG_UNLOCK(CTG_READ, &tbCache->metaLock);
ctgDebug("stb updated to stbCache, dbFName:%s, tbName:%s, tbType:%d", dbFName, tbName, meta->tableType); ctgDebug("stb updated to stbCache, dbFName:%s, tbName:%s, tbType:%d, suid:%" PRIx64 ",ma:%p", dbFName, tbName, meta->tableType, meta->suid, tbMeta);
SSTableMetaVersion metaRent = {.dbId = dbId, .suid = meta->suid, .sversion = meta->sversion, .tversion = meta->tversion}; SSTableMetaVersion metaRent = {.dbId = dbId, .suid = meta->suid, .sversion = meta->sversion, .tversion = meta->tversion};
strcpy(metaRent.dbFName, dbFName); strcpy(metaRent.dbFName, dbFName);
......
...@@ -1227,16 +1227,20 @@ int32_t parseInsertSql(SParseContext* pContext, SQuery** pQuery) { ...@@ -1227,16 +1227,20 @@ int32_t parseInsertSql(SParseContext* pContext, SQuery** pQuery) {
if (NULL == *pQuery) { if (NULL == *pQuery) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
(*pQuery)->pTableList = taosArrayInit(taosHashGetSize(context.pTableNameHashObj), sizeof(SName));
if (NULL == (*pQuery)->pTableList) {
return TSDB_CODE_OUT_OF_MEMORY;
}
(*pQuery)->execMode = QUERY_EXEC_MODE_SCHEDULE; (*pQuery)->execMode = QUERY_EXEC_MODE_SCHEDULE;
(*pQuery)->haveResultSet = false; (*pQuery)->haveResultSet = false;
(*pQuery)->msgType = TDMT_VND_SUBMIT; (*pQuery)->msgType = TDMT_VND_SUBMIT;
(*pQuery)->pRoot = (SNode*)context.pOutput; (*pQuery)->pRoot = (SNode*)context.pOutput;
} }
if (NULL == (*pQuery)->pTableList) {
(*pQuery)->pTableList = taosArrayInit(taosHashGetSize(context.pTableNameHashObj), sizeof(SName));
if (NULL == (*pQuery)->pTableList) {
return TSDB_CODE_OUT_OF_MEMORY;
}
}
context.pOutput->payloadType = PAYLOAD_TYPE_KV; context.pOutput->payloadType = PAYLOAD_TYPE_KV;
int32_t code = skipInsertInto(&context); int32_t code = skipInsertInto(&context);
......
...@@ -184,5 +184,6 @@ int32_t qStmtParseQuerySql(SParseContext* pCxt, SQuery* pQuery) { ...@@ -184,5 +184,6 @@ int32_t qStmtParseQuerySql(SParseContext* pCxt, SQuery* pQuery) {
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = calculateConstant(pCxt, pQuery); code = calculateConstant(pCxt, pQuery);
} }
return code; return code;
} }
...@@ -290,6 +290,10 @@ int32_t queryCreateTableMetaFromMsg(STableMetaRsp *msg, bool isSuperTable, STabl ...@@ -290,6 +290,10 @@ int32_t queryCreateTableMetaFromMsg(STableMetaRsp *msg, bool isSuperTable, STabl
pTableMeta->sversion = msg->sversion; pTableMeta->sversion = msg->sversion;
pTableMeta->tversion = msg->tversion; pTableMeta->tversion = msg->tversion;
if (isSuperTable) {
qDebug("stable %s meta returned, suid:%" PRIx64, msg->stbName, pTableMeta->suid);
}
pTableMeta->tableInfo.numOfTags = msg->numOfTags; pTableMeta->tableInfo.numOfTags = msg->numOfTags;
pTableMeta->tableInfo.precision = msg->precision; pTableMeta->tableInfo.precision = msg->precision;
pTableMeta->tableInfo.numOfColumns = msg->numOfColumns; pTableMeta->tableInfo.numOfColumns = msg->numOfColumns;
......
...@@ -37,7 +37,8 @@ typedef struct SScalarCtx { ...@@ -37,7 +37,8 @@ typedef struct SScalarCtx {
#define SCL_IS_CONST_NODE(_node) ((NULL == (_node)) || (QUERY_NODE_VALUE == (_node)->type) || (QUERY_NODE_NODE_LIST == (_node)->type)) #define SCL_IS_CONST_NODE(_node) ((NULL == (_node)) || (QUERY_NODE_VALUE == (_node)->type) || (QUERY_NODE_NODE_LIST == (_node)->type))
#define SCL_IS_CONST_CALC(_ctx) (NULL == (_ctx)->pBlockList) #define SCL_IS_CONST_CALC(_ctx) (NULL == (_ctx)->pBlockList)
#define SCL_IS_NULL_VALUE_NODE(_node) ((QUERY_NODE_VALUE == nodeType(_node)) && (TSDB_DATA_TYPE_NULL == ((SValueNode *)_node)->node.resType.type) && (((SValueNode *)_node)->placeholderNo <= 0)) //#define SCL_IS_NULL_VALUE_NODE(_node) ((QUERY_NODE_VALUE == nodeType(_node)) && (TSDB_DATA_TYPE_NULL == ((SValueNode *)_node)->node.resType.type) && (((SValueNode *)_node)->placeholderNo <= 0))
#define SCL_IS_NULL_VALUE_NODE(_node) ((QUERY_NODE_VALUE == nodeType(_node)) && (TSDB_DATA_TYPE_NULL == ((SValueNode *)_node)->node.resType.type))
#define sclFatal(...) qFatal(__VA_ARGS__) #define sclFatal(...) qFatal(__VA_ARGS__)
#define sclError(...) qError(__VA_ARGS__) #define sclError(...) qError(__VA_ARGS__)
......
...@@ -9,10 +9,12 @@ ...@@ -9,10 +9,12 @@
#include <unistd.h> #include <unistd.h>
#include "../../../include/client/taos.h" #include "../../../include/client/taos.h"
#define FUNCTION_TEST_IDX 1
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, TSDB_DATA_TYPE_NCHAR}; int32_t bindColTypeList[] = {TSDB_DATA_TYPE_TIMESTAMP, TSDB_DATA_TYPE_INT};
int32_t optrIdxList[] = {0, 9}; int32_t optrIdxList[] = {0, 7};
typedef struct { typedef struct {
char* oper; char* oper;
...@@ -53,7 +55,6 @@ FuncInfo funcInfo[] = { ...@@ -53,7 +55,6 @@ FuncInfo funcInfo[] = {
{"count", 1}, {"count", 1},
{"sum", 1}, {"sum", 1},
{"min", 1}, {"min", 1},
{"sin", 1},
}; };
char *bpStbPrefix = "st"; char *bpStbPrefix = "st";
...@@ -66,6 +67,10 @@ int32_t bpDefaultStbId = 1; ...@@ -66,6 +67,10 @@ int32_t bpDefaultStbId = 1;
//char *varoperatorList[] = {">", ">=", "<", "<=", "=", "<>", "in", "not in", "like", "not like", "match", "nmatch"}; //char *varoperatorList[] = {">", ">=", "<", "<=", "=", "<>", "in", "not in", "like", "not like", "match", "nmatch"};
#define tListLen(x) (sizeof(x) / sizeof((x)[0])) #define tListLen(x) (sizeof(x) / sizeof((x)[0]))
#define IS_SIGNED_NUMERIC_TYPE(_t) ((_t) >= TSDB_DATA_TYPE_TINYINT && (_t) <= TSDB_DATA_TYPE_BIGINT)
#define IS_UNSIGNED_NUMERIC_TYPE(_t) ((_t) >= TSDB_DATA_TYPE_UTINYINT && (_t) <= TSDB_DATA_TYPE_UBIGINT)
#define IS_FLOAT_TYPE(_t) ((_t) == TSDB_DATA_TYPE_FLOAT || (_t) == TSDB_DATA_TYPE_DOUBLE)
#define IS_NUMERIC_TYPE(_t) ((IS_SIGNED_NUMERIC_TYPE(_t)) || (IS_UNSIGNED_NUMERIC_TYPE(_t)) || (IS_FLOAT_TYPE(_t)))
typedef struct { typedef struct {
int64_t* tsData; int64_t* tsData;
...@@ -165,8 +170,11 @@ CaseCfg gCase[] = { ...@@ -165,8 +170,11 @@ CaseCfg gCase[] = {
// 22 // 22
{"insert:AUTO1-FULL", tListLen(fullColList), fullColList, TTYPE_INSERT, true, true, insertAUTOTest1, 10, 10, 2, 0, 0, 0, 1, -1}, {"insert:AUTO1-FULL", tListLen(fullColList), fullColList, TTYPE_INSERT, true, true, insertAUTOTest1, 10, 10, 2, 0, 0, 0, 1, -1},
{"query:SUBT-COLUMN", tListLen(fullColList), fullColList, TTYPE_QUERY, false, false, queryColumnTest, 10, 10, 1, 3, 0, 0, 1, 2}, // {"query:SUBT-COLUMN", tListLen(fullColList), fullColList, TTYPE_QUERY, false, false, queryColumnTest, 10, 10, 1, 3, 0, 0, 1, 2},
{"query:SUBT-MISC", tListLen(fullColList), fullColList, TTYPE_QUERY, false, false, queryMiscTest, 2, 10, 1, 3, 0, 0, 1, 2}, // {"query:SUBT-MISC", tListLen(fullColList), fullColList, TTYPE_QUERY, false, false, queryMiscTest, 10, 10, 1, 3, 0, 0, 1, 2},
{"query:SUBT-COLUMN", tListLen(fullColList), fullColList, TTYPE_QUERY, false, false, queryColumnTest, 1, 10, 1, 1, 0, 0, 1, 2},
{"query:SUBT-MISC", tListLen(fullColList), fullColList, TTYPE_QUERY, false, false, queryMiscTest, 2, 10, 1, 1, 0, 0, 1, 2},
}; };
...@@ -181,6 +189,7 @@ typedef struct { ...@@ -181,6 +189,7 @@ typedef struct {
bool printQuerySql; bool printQuerySql;
bool printStmtSql; bool printStmtSql;
bool autoCreateTbl; bool autoCreateTbl;
bool numericParam;
int32_t rowNum; //row num for one table int32_t rowNum; //row num for one table
int32_t bindColNum; int32_t bindColNum;
int32_t bindTagNum; int32_t bindTagNum;
...@@ -207,6 +216,7 @@ CaseCtrl gCaseCtrl = { // default ...@@ -207,6 +216,7 @@ CaseCtrl gCaseCtrl = { // default
.printQuerySql = true, .printQuerySql = true,
.printStmtSql = true, .printStmtSql = true,
.autoCreateTbl = false, .autoCreateTbl = false,
.numericParam = false,
.rowNum = 0, .rowNum = 0,
.bindColNum = 0, .bindColNum = 0,
.bindTagNum = 0, .bindTagNum = 0,
...@@ -259,26 +269,22 @@ CaseCtrl gCaseCtrl = { ...@@ -259,26 +269,22 @@ CaseCtrl gCaseCtrl = {
#if 1 #if 1
CaseCtrl gCaseCtrl = { // query case with specified col&oper CaseCtrl gCaseCtrl = { // query case with specified col&oper
.bindNullNum = 0, .bindNullNum = 1,
.printCreateTblSql = false, .printCreateTblSql = false,
.printQuerySql = true, .printQuerySql = true,
.printStmtSql = true, .printStmtSql = true,
.rowNum = 0, .rowNum = 0,
.bindColNum = 0, .bindColNum = 0,
.bindRowNum = 0, .bindRowNum = 0,
.bindColTypeNum = 0, .optrIdxListNum = tListLen(optrIdxList),
.bindColTypeList = NULL, .optrIdxList = optrIdxList,
.optrIdxListNum = 0, .bindColTypeNum = tListLen(bindColTypeList),
.optrIdxList = NULL, .bindColTypeList = bindColTypeList,
.checkParamNum = false, .checkParamNum = false,
.printRes = true, .printRes = true,
.runTimes = 0, .runTimes = 0,
.caseRunIdx = -1, .caseRunIdx = -1,
.optrIdxListNum = 0, .caseIdx = 23,
.optrIdxList = NULL,
.bindColTypeNum = 0,
.bindColTypeList = NULL,
.caseIdx = 24,
.caseNum = 1, .caseNum = 1,
.caseRunNum = 1, .caseRunNum = 1,
}; };
...@@ -303,11 +309,11 @@ CaseCtrl gCaseCtrl = { // query case with specified col&oper ...@@ -303,11 +309,11 @@ CaseCtrl gCaseCtrl = { // query case with specified col&oper
.printRes = true, .printRes = true,
.runTimes = 0, .runTimes = 0,
.caseRunIdx = -1, .caseRunIdx = -1,
//.optrIdxListNum = tListLen(optrIdxList), .optrIdxListNum = tListLen(optrIdxList),
//.optrIdxList = optrIdxList, .optrIdxList = optrIdxList,
//.bindColTypeNum = tListLen(bindColTypeList), .bindColTypeNum = tListLen(bindColTypeList),
//.bindColTypeList = bindColTypeList, .bindColTypeList = bindColTypeList,
.caseIdx = 22, .caseIdx = 24,
.caseNum = 1, .caseNum = 1,
.caseRunNum = 1, .caseRunNum = 1,
}; };
...@@ -661,11 +667,11 @@ void bpGenerateConstInFuncSQL(BindData *data, int32_t tblIdx) { ...@@ -661,11 +667,11 @@ void bpGenerateConstInFuncSQL(BindData *data, int32_t tblIdx) {
void generateQueryMiscSQL(BindData *data, int32_t tblIdx) { void generateQueryMiscSQL(BindData *data, int32_t tblIdx) {
switch(tblIdx) { switch(tblIdx) {
case 0: case 0:
bpGenerateConstInOpSQL(data, tblIdx);
break;
case 1:
//TODO FILL TEST //TODO FILL TEST
default: default:
bpGenerateConstInOpSQL(data, tblIdx);
break;
case FUNCTION_TEST_IDX:
bpGenerateConstInFuncSQL(data, tblIdx); bpGenerateConstInFuncSQL(data, tblIdx);
break; break;
} }
...@@ -709,6 +715,16 @@ void generateColDataType(BindData *data, int32_t bindIdx, int32_t colIdx, int32_ ...@@ -709,6 +715,16 @@ void generateColDataType(BindData *data, int32_t bindIdx, int32_t colIdx, int32_
} else if (gCurCase->fullCol) { } else if (gCurCase->fullCol) {
*dataType = gCurCase->colList[bindIdx]; *dataType = gCurCase->colList[bindIdx];
return; return;
} else if (gCaseCtrl.numericParam) {
while (true) {
*dataType = rand() % (TSDB_DATA_TYPE_MAX - 1) + 1;
if (!IS_NUMERIC_TYPE(*dataType)) {
continue;
}
break;
}
return;
} else if (0 == colIdx) { } else if (0 == colIdx) {
*dataType = TSDB_DATA_TYPE_TIMESTAMP; *dataType = TSDB_DATA_TYPE_TIMESTAMP;
return; return;
...@@ -1046,6 +1062,10 @@ int32_t prepareQueryMiscData(BindData *data, int32_t tblIdx) { ...@@ -1046,6 +1062,10 @@ int32_t prepareQueryMiscData(BindData *data, int32_t tblIdx) {
data->binaryLen[i] = gVarCharLen; data->binaryLen[i] = gVarCharLen;
} }
if (tblIdx == FUNCTION_TEST_IDX) {
gCaseCtrl.numericParam = true;
}
for (int b = 0; b < bindNum; b++) { for (int b = 0; b < bindNum; b++) {
for (int c = 0; c < gCurCase->bindColNum; ++c) { for (int c = 0; c < gCurCase->bindColNum; ++c) {
prepareColData(BP_BIND_COL, data, b*gCurCase->bindColNum+c, b*gCurCase->bindRowNum, c); prepareColData(BP_BIND_COL, data, b*gCurCase->bindColNum+c, b*gCurCase->bindRowNum, c);
......
...@@ -14,10 +14,10 @@ from util.dnodes import * ...@@ -14,10 +14,10 @@ from util.dnodes import *
class TDTestCase: class TDTestCase:
hostname = socket.gethostname() hostname = socket.gethostname()
clientCfgDict = {'qdebugflag':'143'} #clientCfgDict = {'qdebugflag':'143'}
updatecfgDict = {'clientCfg': {}, 'qdebugflag':'143'} #updatecfgDict = {'clientCfg': {}, 'qdebugflag':'143'}
updatecfgDict["clientCfg"] = clientCfgDict #updatecfgDict["clientCfg"] = clientCfgDict
print ("===================: ", updatecfgDict) #print ("===================: ", updatecfgDict)
def init(self, conn, logSql): def init(self, conn, logSql):
tdLog.debug(f"start to excute {__file__}") tdLog.debug(f"start to excute {__file__}")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册