Merge remote-tracking branch 'origin/develop' into feature/crash_gen

This commit is contained in:
Steven Li 2020-06-12 17:16:28 -07:00
commit 53892448df
40 changed files with 815 additions and 158 deletions

View File

@ -279,7 +279,8 @@ static void tscProcessCurrentUser(SSqlObj *pSql) {
pExpr->resType = TSDB_DATA_TYPE_BINARY; pExpr->resType = TSDB_DATA_TYPE_BINARY;
char* vx = calloc(1, pExpr->resBytes); char* vx = calloc(1, pExpr->resBytes);
STR_WITH_MAXSIZE_TO_VARSTR(vx, pSql->pTscObj->user, sizeof(pSql->pTscObj->user)); size_t size = sizeof(pSql->pTscObj->user);
STR_WITH_MAXSIZE_TO_VARSTR(vx, pSql->pTscObj->user, size);
tscSetLocalQueryResult(pSql, vx, pExpr->aliasName, pExpr->resType, pExpr->resBytes); tscSetLocalQueryResult(pSql, vx, pExpr->aliasName, pExpr->resType, pExpr->resBytes);
free(vx); free(vx);

View File

@ -217,7 +217,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
pReducer->numOfBuffer = numOfFlush; pReducer->numOfBuffer = numOfFlush;
pReducer->numOfVnode = numOfBuffer; pReducer->numOfVnode = numOfBuffer;
pReducer->pDesc = pDesc; pReducer->pDesc = pDesc;
tscTrace("%p the number of merged leaves is: %d", pSql, pReducer->numOfBuffer); tscTrace("%p the number of merged leaves is: %d", pSql, pReducer->numOfBuffer);
@ -604,7 +604,7 @@ bool isSameGroup(SSqlCmd *pCmd, SLocalReducer *pReducer, char *pPrev, tFilePage
tOrderDescriptor *pOrderDesc = pReducer->pDesc; tOrderDescriptor *pOrderDesc = pReducer->pDesc;
SColumnOrderInfo* orderInfo = &pOrderDesc->orderInfo; SColumnOrderInfo* orderInfo = &pOrderDesc->orderInfo;
// no group by columns, all data belongs to one group // no group by columns, all data belongs to one group
int32_t numOfCols = orderInfo->numOfCols; int32_t numOfCols = orderInfo->numOfCols;
if (numOfCols <= 0) { if (numOfCols <= 0) {
@ -627,7 +627,7 @@ bool isSameGroup(SSqlCmd *pCmd, SLocalReducer *pReducer, char *pPrev, tFilePage
// only one row exists // only one row exists
int32_t index = orderInfo->pData[0]; int32_t index = orderInfo->pData[0];
int32_t offset = (pOrderDesc->pColumnModel)->pFields[index].offset; int32_t offset = (pOrderDesc->pColumnModel)->pFields[index].offset;
int32_t ret = memcmp(pPrev + offset, tmpBuffer->data + offset, pOrderDesc->pColumnModel->rowSize - offset); int32_t ret = memcmp(pPrev + offset, tmpBuffer->data + offset, pOrderDesc->pColumnModel->rowSize - offset);
return ret == 0; return ret == 0;
} }
@ -1040,7 +1040,7 @@ static void savePreviousRow(SLocalReducer *pLocalReducer, tFilePage *tmpBuffer)
static void doExecuteSecondaryMerge(SSqlCmd *pCmd, SLocalReducer *pLocalReducer, bool needInit) { static void doExecuteSecondaryMerge(SSqlCmd *pCmd, SLocalReducer *pLocalReducer, bool needInit) {
// the tag columns need to be set before all functions execution // the tag columns need to be set before all functions execution
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex); SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
size_t size = tscSqlExprNumOfExprs(pQueryInfo); size_t size = tscSqlExprNumOfExprs(pQueryInfo);
for (int32_t j = 0; j < size; ++j) { for (int32_t j = 0; j < size; ++j) {
SQLFunctionCtx *pCtx = &pLocalReducer->pCtx[j]; SQLFunctionCtx *pCtx = &pLocalReducer->pCtx[j];
@ -1182,7 +1182,7 @@ int32_t finalizeRes(SQueryInfo *pQueryInfo, SLocalReducer *pLocalReducer) {
*/ */
bool needToMerge(SQueryInfo *pQueryInfo, SLocalReducer *pLocalReducer, tFilePage *tmpBuffer) { bool needToMerge(SQueryInfo *pQueryInfo, SLocalReducer *pLocalReducer, tFilePage *tmpBuffer) {
int32_t ret = 0; // merge all result by default int32_t ret = 0; // merge all result by default
int16_t functionId = pLocalReducer->pCtx[0].functionId; int16_t functionId = pLocalReducer->pCtx[0].functionId;
// todo opt performance // todo opt performance

View File

@ -209,6 +209,7 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcIpSet *pIpSet) {
tscError("%p sql is already released", pSql->signature); tscError("%p sql is already released", pSql->signature);
return; return;
} }
if (pSql->signature != pSql) { if (pSql->signature != pSql) {
tscError("%p sql is already released, signature:%p", pSql, pSql->signature); tscError("%p sql is already released, signature:%p", pSql, pSql->signature);
return; return;
@ -217,10 +218,9 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcIpSet *pIpSet) {
SSqlRes *pRes = &pSql->res; SSqlRes *pRes = &pSql->res;
SSqlCmd *pCmd = &pSql->cmd; SSqlCmd *pCmd = &pSql->cmd;
STscObj *pObj = pSql->pTscObj; STscObj *pObj = pSql->pTscObj;
// tscTrace("%p msg:%s is received from server", pSql, taosMsg[rpcMsg->msgType]);
if (pObj->signature != pObj) { if (pObj->signature != pObj || pSql->freed == 1) {
tscTrace("%p sql is already released or DB connection is closed, freed:%d pObj:%p signature:%p", pSql, pSql->freed, tscTrace("%p sqlObj needs to be released or DB connection is closed, freed:%d pObj:%p signature:%p", pSql, pSql->freed,
pObj, pObj->signature); pObj, pObj->signature);
tscFreeSqlObj(pSql); tscFreeSqlObj(pSql);
rpcFreeCont(rpcMsg->pCont); rpcFreeCont(rpcMsg->pCont);
@ -375,7 +375,7 @@ int tscProcessSql(SSqlObj *pSql) {
SQueryInfo * pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex); SQueryInfo * pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
STableMetaInfo *pTableMetaInfo = NULL; STableMetaInfo *pTableMetaInfo = NULL;
uint16_t type = 0; uint32_t type = 0;
if (pQueryInfo != NULL) { if (pQueryInfo != NULL) {
pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
@ -424,7 +424,7 @@ void tscKillSTableQuery(SSqlObj *pSql) {
* sub-queries not correctly released and master sql object of super table query reaches an abnormal state. * sub-queries not correctly released and master sql object of super table query reaches an abnormal state.
*/ */
pSql->pSubs[i]->res.code = TSDB_CODE_TSC_QUERY_CANCELLED; pSql->pSubs[i]->res.code = TSDB_CODE_TSC_QUERY_CANCELLED;
//taosStopRpcConn(pSql->pSubs[i]->thandle); // taosStopRpcConn(pSql->pSubs[i]->);
} }
/* /*
@ -1708,8 +1708,9 @@ int tscBuildSTableVgroupMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
for(int32_t i = 0; i < pQueryInfo->numOfTables; ++i) { for(int32_t i = 0; i < pQueryInfo->numOfTables; ++i) {
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, i); STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, i);
tstrncpy(pMsg, pTableMetaInfo->name, sizeof(pTableMetaInfo->name)); size_t size = sizeof(pTableMetaInfo->name);
pMsg += sizeof(pTableMetaInfo->name); tstrncpy(pMsg, pTableMetaInfo->name, size);
pMsg += size;
} }
pCmd->msgType = TSDB_MSG_TYPE_CM_STABLE_VGROUP; pCmd->msgType = TSDB_MSG_TYPE_CM_STABLE_VGROUP;

View File

@ -219,6 +219,11 @@ void waitForQueryRsp(void *param, TAOS_RES *tres, int code) {
sem_post(&pSql->rspSem); sem_post(&pSql->rspSem);
} }
static void waitForRetrieveRsp(void *param, TAOS_RES *tres, int numOfRows) {
SSqlObj* pSql = (SSqlObj*) tres;
sem_post(&pSql->rspSem);
}
TAOS_RES* taos_query(TAOS *taos, const char *sqlstr) { TAOS_RES* taos_query(TAOS *taos, const char *sqlstr) {
STscObj *pObj = (STscObj *)taos; STscObj *pObj = (STscObj *)taos;
if (pObj == NULL || pObj->signature != pObj) { if (pObj == NULL || pObj->signature != pObj) {
@ -369,11 +374,6 @@ int taos_fetch_block_impl(TAOS_RES *res, TAOS_ROW *rows) {
return (pQueryInfo->order.order == TSDB_ORDER_DESC) ? pRes->numOfRows : -pRes->numOfRows; return (pQueryInfo->order.order == TSDB_ORDER_DESC) ? pRes->numOfRows : -pRes->numOfRows;
} }
static void waitForRetrieveRsp(void *param, TAOS_RES *tres, int numOfRows) {
SSqlObj* pSql = (SSqlObj*) tres;
sem_post(&pSql->rspSem);
}
TAOS_ROW taos_fetch_row(TAOS_RES *res) { TAOS_ROW taos_fetch_row(TAOS_RES *res) {
SSqlObj *pSql = (SSqlObj *)res; SSqlObj *pSql = (SSqlObj *)res;
if (pSql == NULL || pSql->signature != pSql) { if (pSql == NULL || pSql->signature != pSql) {
@ -476,7 +476,7 @@ int taos_select_db(TAOS *taos, const char *db) {
} }
// send free message to vnode to free qhandle and corresponding resources in vnode // send free message to vnode to free qhandle and corresponding resources in vnode
static void tscFreeQhandleInVnode(SSqlObj* pSql) { static bool tscFreeQhandleInVnode(SSqlObj* pSql) {
SSqlCmd* pCmd = &pSql->cmd; SSqlCmd* pCmd = &pSql->cmd;
SSqlRes* pRes = &pSql->res; SSqlRes* pRes = &pSql->res;
@ -496,10 +496,19 @@ static void tscFreeQhandleInVnode(SSqlObj* pSql) {
tscProcessSql(pSql); tscProcessSql(pSql);
// in case of sync model query, waits for response and then goes on // in case of sync model query, waits for response and then goes on
if (pSql->fp == waitForQueryRsp || pSql->fp == waitForRetrieveRsp) { // if (pSql->fp == waitForQueryRsp || pSql->fp == waitForRetrieveRsp) {
sem_wait(&pSql->rspSem); // sem_wait(&pSql->rspSem);
}
// tscFreeSqlObj(pSql);
// tscTrace("%p sqlObj is freed by app", pSql);
// } else {
tscTrace("%p sqlObj will be freed while rsp received", pSql);
// }
return true;
} }
return false;
} }
void taos_free_result(TAOS_RES *res) { void taos_free_result(TAOS_RES *res) {
@ -527,10 +536,10 @@ void taos_free_result(TAOS_RES *res) {
} }
pQueryInfo->type = TSDB_QUERY_TYPE_FREE_RESOURCE; pQueryInfo->type = TSDB_QUERY_TYPE_FREE_RESOURCE;
tscFreeQhandleInVnode(pSql); if (!tscFreeQhandleInVnode(pSql)) {
tscFreeSqlObj(pSql); tscFreeSqlObj(pSql);
tscTrace("%p sqlObj is freed by app", pSql);
tscTrace("%p sql result is freed by app", pSql); }
} }
// todo should not be used in async query // todo should not be used in async query

View File

@ -134,24 +134,6 @@ void tscGetDBInfoFromMeterId(char* tableId, char* db) {
db[0] = 0; db[0] = 0;
} }
//STableIdInfo* tscGetMeterSidInfo(SVnodeSidList* pSidList, int32_t idx) {
// if (pSidList == NULL) {
// tscError("illegal sidlist");
// return 0;
// }
//
// if (idx < 0 || idx >= pSidList->numOfSids) {
// int32_t sidRange = (pSidList->numOfSids > 0) ? (pSidList->numOfSids - 1) : 0;
//
// tscError("illegal sidIdx:%d, reset to 0, sidIdx range:%d-%d", idx, 0, sidRange);
// idx = 0;
// }
//
// assert(pSidList->pSidExtInfoList[idx] >= 0);
//
// return (STableIdInfo*)(pSidList->pSidExtInfoList[idx] + (char*)pSidList);
//}
bool tscIsTwoStageSTableQuery(SQueryInfo* pQueryInfo, int32_t tableIndex) { bool tscIsTwoStageSTableQuery(SQueryInfo* pQueryInfo, int32_t tableIndex) {
if (pQueryInfo == NULL) { if (pQueryInfo == NULL) {
return false; return false;
@ -176,8 +158,7 @@ bool tscIsTwoStageSTableQuery(SQueryInfo* pQueryInfo, int32_t tableIndex) {
return false; return false;
} }
if (((pQueryInfo->type & TSDB_QUERY_TYPE_STABLE_SUBQUERY) != TSDB_QUERY_TYPE_STABLE_SUBQUERY) && if (!TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_STABLE_SUBQUERY) && pQueryInfo->command == TSDB_SQL_SELECT) {
pQueryInfo->command == TSDB_SQL_SELECT) {
return UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo); return UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo);
} }

View File

@ -1262,10 +1262,11 @@ bool taosCheckGlobalCfg() {
taosSetAllDebugFlag(); taosSetAllDebugFlag();
} }
if (tsLocalFqdn[0] == 0) if (tsLocalFqdn[0] == 0) {
taosGetFqdn(tsLocalEp); taosGetFqdn(tsLocalFqdn);
else }
strcpy(tsLocalEp, tsLocalFqdn);
strcpy(tsLocalEp, tsLocalFqdn);
snprintf(tsLocalEp + strlen(tsLocalEp), sizeof(tsLocalEp), ":%d", tsServerPort); snprintf(tsLocalEp + strlen(tsLocalEp), sizeof(tsLocalEp), ":%d", tsServerPort);
uPrint("localEp is: %s", tsLocalEp); uPrint("localEp is: %s", tsLocalEp);

View File

@ -83,7 +83,7 @@ void rpcSendResponse(const SRpcMsg *pMsg);
void rpcSendRedirectRsp(void *pConn, const SRpcIpSet *pIpSet); void rpcSendRedirectRsp(void *pConn, const SRpcIpSet *pIpSet);
int rpcGetConnInfo(void *thandle, SRpcConnInfo *pInfo); int rpcGetConnInfo(void *thandle, SRpcConnInfo *pInfo);
void rpcSendRecv(void *shandle, SRpcIpSet *pIpSet, const SRpcMsg *pReq, SRpcMsg *pRsp); void rpcSendRecv(void *shandle, SRpcIpSet *pIpSet, const SRpcMsg *pReq, SRpcMsg *pRsp);
void rpcReportProgress(void *pConn, char *pCont, int contLen); int rpcReportProgress(void *pConn, char *pCont, int contLen);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -235,12 +235,14 @@ static int32_t mnodeRetrieveConns(SShowObj *pShow, char *data, int32_t rows, voi
cols++; cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pConnObj->user, sizeof(pConnObj->user)); size_t size = sizeof(pConnObj->user);
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pConnObj->user, size);
cols++; cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
snprintf(ipStr, sizeof(ipStr), "%s:%u", taosIpStr(pConnObj->ip), pConnObj->port); snprintf(ipStr, sizeof(ipStr), "%s:%u", taosIpStr(pConnObj->ip), pConnObj->port);
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, ipStr, sizeof(ipStr)); size = sizeof(ipStr);
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, ipStr, size);
cols++; cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
@ -358,12 +360,14 @@ static int32_t mnodeRetrieveQueries(SShowObj *pShow, char *data, int32_t rows, v
cols++; cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pConnObj->user, sizeof(pConnObj->user)); size_t size = sizeof(pConnObj->user);
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pConnObj->user, size);
cols++; cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
snprintf(ipStr, sizeof(ipStr), "%s:%u", taosIpStr(pConnObj->ip), pConnObj->port); snprintf(ipStr, sizeof(ipStr), "%s:%u", taosIpStr(pConnObj->ip), pConnObj->port);
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, ipStr, sizeof(ipStr)); size = sizeof(ipStr);
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, ipStr, size);
cols++; cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
@ -479,12 +483,14 @@ static int32_t mnodeRetrieveStreams(SShowObj *pShow, char *data, int32_t rows, v
cols++; cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pConnObj->user, sizeof(pConnObj->user)); size_t size = sizeof(pConnObj->user);
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pConnObj->user, size);
cols++; cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
snprintf(ipStr, sizeof(ipStr), "%s:%u", taosIpStr(pConnObj->ip), pConnObj->port); snprintf(ipStr, sizeof(ipStr), "%s:%u", taosIpStr(pConnObj->ip), pConnObj->port);
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, ipStr, sizeof(ipStr)); size = sizeof(ipStr);
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, ipStr, size);
cols++; cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;

View File

@ -451,7 +451,7 @@ static int32_t sdbInsertHash(SSdbTable *pTable, SSdbOper *pOper) {
pthread_mutex_unlock(&pTable->mutex); pthread_mutex_unlock(&pTable->mutex);
sdbTrace("table:%s, insert record:%s to hash, rowSize:%d vnumOfRows:%" PRId64 " version:%" PRIu64, pTable->tableName, sdbTrace("table:%s, insert record:%s to hash, rowSize:%d numOfRows:%" PRId64 " version:%" PRIu64, pTable->tableName,
sdbGetKeyStrFromObj(pTable, pOper->pObj), pOper->rowSize, pTable->numOfRows, sdbGetVersion()); sdbGetKeyStrFromObj(pTable, pOper->pObj), pOper->rowSize, pTable->numOfRows, sdbGetVersion());
(*pTable->insertFp)(pOper); (*pTable->insertFp)(pOper);
@ -475,7 +475,7 @@ static int32_t sdbDeleteHash(SSdbTable *pTable, SSdbOper *pOper) {
pTable->numOfRows--; pTable->numOfRows--;
pthread_mutex_unlock(&pTable->mutex); pthread_mutex_unlock(&pTable->mutex);
sdbTrace("table:%s, delete record:%s from hash, numOfRows:%d" PRId64 "version:%" PRIu64, pTable->tableName, sdbTrace("table:%s, delete record:%s from hash, numOfRows:%" PRId64 "version:%" PRIu64, pTable->tableName,
sdbGetKeyStrFromObj(pTable, pOper->pObj), pTable->numOfRows, sdbGetVersion()); sdbGetKeyStrFromObj(pTable, pOper->pObj), pTable->numOfRows, sdbGetVersion());
int8_t *updateEnd = pOper->pObj + pTable->refCountPos - 1; int8_t *updateEnd = pOper->pObj + pTable->refCountPos - 1;

View File

@ -1004,7 +1004,7 @@ static int32_t mnodeAddSuperTableColumn(SDbObj *pDb, SSuperTableObj *pStable, SS
sizeof(SSchema) * pStable->numOfTags); sizeof(SSchema) * pStable->numOfTags);
memcpy(pStable->schema + pStable->numOfColumns, schema, sizeof(SSchema) * ncols); memcpy(pStable->schema + pStable->numOfColumns, schema, sizeof(SSchema) * ncols);
SSchema *tschema = (SSchema *) (pStable->schema + sizeof(SSchema) * pStable->numOfColumns); SSchema *tschema = (SSchema *) (pStable->schema + pStable->numOfColumns);
for (int32_t i = 0; i < ncols; i++) { for (int32_t i = 0; i < ncols; i++) {
tschema[i].colId = pStable->nextColId++; tschema[i].colId = pStable->nextColId++;
} }
@ -1770,7 +1770,8 @@ static int32_t mnodeAutoCreateChildTable(SMnodeMsg *pMsg) {
return TSDB_CODE_MND_OUT_OF_MEMORY; return TSDB_CODE_MND_OUT_OF_MEMORY;
} }
tstrncpy(pCreateMsg->tableId, pInfo->tableId, sizeof(pInfo->tableId)); size_t size = sizeof(pInfo->tableId);
tstrncpy(pCreateMsg->tableId, pInfo->tableId, size);
tstrncpy(pCreateMsg->db, pMsg->pDb->name, sizeof(pCreateMsg->db)); tstrncpy(pCreateMsg->db, pMsg->pDb->name, sizeof(pCreateMsg->db));
pCreateMsg->igExists = 1; pCreateMsg->igExists = 1;
pCreateMsg->getMeta = 1; pCreateMsg->getMeta = 1;

View File

@ -315,7 +315,8 @@ static int32_t mnodeRetrieveUsers(SShowObj *pShow, char *data, int32_t rows, voi
cols = 0; cols = 0;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pUser->user, sizeof(pUser->user)); size_t size = sizeof(pUser->user);
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pUser->user, size);
cols++; cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;

View File

@ -101,8 +101,10 @@ bool httpParseTaosdAuthToken(HttpContext *pContext, char *token, int len) {
bool httpGenTaosdAuthToken(HttpContext *pContext, char *token, int maxLen) { bool httpGenTaosdAuthToken(HttpContext *pContext, char *token, int maxLen) {
char buffer[sizeof(pContext->user) + sizeof(pContext->pass)] = {0}; char buffer[sizeof(pContext->user) + sizeof(pContext->pass)] = {0};
tstrncpy(buffer, pContext->user, sizeof(pContext->user)); size_t size = sizeof(pContext->user);
tstrncpy(buffer + sizeof(pContext->user), pContext->pass, sizeof(pContext->pass)); tstrncpy(buffer, pContext->user, size);
size = sizeof(pContext->pass);
tstrncpy(buffer + sizeof(pContext->user), pContext->pass, size);
char *encrypt = taosDesEncode(KEY_DES_4, buffer, TSDB_USER_LEN + TSDB_PASSWORD_LEN); char *encrypt = taosDesEncode(KEY_DES_4, buffer, TSDB_USER_LEN + TSDB_PASSWORD_LEN);
char *base64 = base64_encode((const unsigned char *)encrypt, TSDB_USER_LEN + TSDB_PASSWORD_LEN); char *base64 = base64_encode((const unsigned char *)encrypt, TSDB_USER_LEN + TSDB_PASSWORD_LEN);

View File

@ -112,7 +112,7 @@ enum {
#define QUERY_IS_STABLE_QUERY(type) (((type)&TSDB_QUERY_TYPE_STABLE_QUERY) != 0) #define QUERY_IS_STABLE_QUERY(type) (((type)&TSDB_QUERY_TYPE_STABLE_QUERY) != 0)
#define QUERY_IS_JOIN_QUERY(type) (TSDB_QUERY_HAS_TYPE(type, TSDB_QUERY_TYPE_JOIN_QUERY)) #define QUERY_IS_JOIN_QUERY(type) (TSDB_QUERY_HAS_TYPE(type, TSDB_QUERY_TYPE_JOIN_QUERY))
#define QUERY_IS_PROJECTION_QUERY(type) (((type)&TSDB_QUERY_TYPE_PROJECTION_QUERY) != 0) #define QUERY_IS_PROJECTION_QUERY(type) (((type)&TSDB_QUERY_TYPE_PROJECTION_QUERY) != 0)
#define QUERY_IS_FREE_RESOURCE(type) (((type)&TSDB_QUERY_TYPE_FREE_RESOURCE) != 0) #define QUERY_IS_FREE_RESOURCE(type) (((type)&TSDB_QUERY_TYPE_FREE_RESOURCE) != 0)
typedef struct SArithmeticSupport { typedef struct SArithmeticSupport {

View File

@ -484,7 +484,7 @@ static int32_t setWindowOutputBufByKey(SQueryRuntimeEnv *pRuntimeEnv, SWindowRes
// set time window for current result // set time window for current result
pWindowRes->window = *win; pWindowRes->window = *win;
setWindowResOutputBufInitCtx(pRuntimeEnv, pWindowRes); setWindowResOutputBufInitCtx(pRuntimeEnv, pWindowRes);
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
@ -685,14 +685,14 @@ static int32_t getNextQualifiedWindow(SQueryRuntimeEnv *pRuntimeEnv, STimeWindow
SDataBlockInfo *pDataBlockInfo, TSKEY *primaryKeys, SDataBlockInfo *pDataBlockInfo, TSKEY *primaryKeys,
__block_search_fn_t searchFn) { __block_search_fn_t searchFn) {
SQuery *pQuery = pRuntimeEnv->pQuery; SQuery *pQuery = pRuntimeEnv->pQuery;
// tumbling time window query, a special case of sliding time window query // tumbling time window query, a special case of sliding time window query
if (pQuery->slidingTime == pQuery->intervalTime) { if (pQuery->slidingTime == pQuery->intervalTime) {
// todo opt // todo opt
} }
getNextTimeWindow(pQuery, pNextWin); getNextTimeWindow(pQuery, pNextWin);
// next time window is not in current block // next time window is not in current block
if ((pNextWin->skey > pDataBlockInfo->window.ekey && QUERY_IS_ASC_QUERY(pQuery)) || if ((pNextWin->skey > pDataBlockInfo->window.ekey && QUERY_IS_ASC_QUERY(pQuery)) ||
(pNextWin->ekey < pDataBlockInfo->window.skey && !QUERY_IS_ASC_QUERY(pQuery))) { (pNextWin->ekey < pDataBlockInfo->window.skey && !QUERY_IS_ASC_QUERY(pQuery))) {
@ -720,7 +720,7 @@ static int32_t getNextQualifiedWindow(SQueryRuntimeEnv *pRuntimeEnv, STimeWindow
*/ */
if (QUERY_IS_ASC_QUERY(pQuery) && primaryKeys[startPos] > pNextWin->ekey) { if (QUERY_IS_ASC_QUERY(pQuery) && primaryKeys[startPos] > pNextWin->ekey) {
TSKEY next = primaryKeys[startPos]; TSKEY next = primaryKeys[startPos];
pNextWin->ekey += ((next - pNextWin->ekey + pQuery->slidingTime - 1)/pQuery->slidingTime) * pQuery->slidingTime; pNextWin->ekey += ((next - pNextWin->ekey + pQuery->slidingTime - 1)/pQuery->slidingTime) * pQuery->slidingTime;
pNextWin->skey = pNextWin->ekey - pQuery->intervalTime + 1; pNextWin->skey = pNextWin->ekey - pQuery->intervalTime + 1;
} else if ((!QUERY_IS_ASC_QUERY(pQuery)) && primaryKeys[startPos] < pNextWin->skey) { } else if ((!QUERY_IS_ASC_QUERY(pQuery)) && primaryKeys[startPos] < pNextWin->skey) {
@ -729,7 +729,7 @@ static int32_t getNextQualifiedWindow(SQueryRuntimeEnv *pRuntimeEnv, STimeWindow
pNextWin->skey -= ((pNextWin->skey - next + pQuery->slidingTime - 1) / pQuery->slidingTime) * pQuery->slidingTime; pNextWin->skey -= ((pNextWin->skey - next + pQuery->slidingTime - 1) / pQuery->slidingTime) * pQuery->slidingTime;
pNextWin->ekey = pNextWin->skey + pQuery->intervalTime - 1; pNextWin->ekey = pNextWin->skey + pQuery->intervalTime - 1;
} }
return startPos; return startPos;
} }
@ -2072,7 +2072,7 @@ static int64_t doScanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) {
SQuery *pQuery = pRuntimeEnv->pQuery; SQuery *pQuery = pRuntimeEnv->pQuery;
STableQueryInfo* pTableQueryInfo = pQuery->current; STableQueryInfo* pTableQueryInfo = pQuery->current;
SQueryCostInfo* summary = &pRuntimeEnv->summary; SQueryCostInfo* summary = &pRuntimeEnv->summary;
qTrace("QInfo:%p query start, qrange:%" PRId64 "-%" PRId64 ", lastkey:%" PRId64 ", order:%d", qTrace("QInfo:%p query start, qrange:%" PRId64 "-%" PRId64 ", lastkey:%" PRId64 ", order:%d",
GET_QINFO_ADDR(pRuntimeEnv), pTableQueryInfo->win.skey, pTableQueryInfo->win.ekey, pTableQueryInfo->lastKey, GET_QINFO_ADDR(pRuntimeEnv), pTableQueryInfo->win.skey, pTableQueryInfo->win.ekey, pTableQueryInfo->lastKey,
pQuery->order.order); pQuery->order.order);
@ -2113,7 +2113,7 @@ static int64_t doScanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) {
SDataStatis *pStatis = NULL; SDataStatis *pStatis = NULL;
SArray *pDataBlock = loadDataBlockOnDemand(pRuntimeEnv, pQueryHandle, &blockInfo, &pStatis); SArray *pDataBlock = loadDataBlockOnDemand(pRuntimeEnv, pQueryHandle, &blockInfo, &pStatis);
// query start position can not move into tableApplyFunctionsOnBlock due to limit/offset condition // query start position can not move into tableApplyFunctionsOnBlock due to limit/offset condition
pQuery->pos = QUERY_IS_ASC_QUERY(pQuery)? 0 : blockInfo.rows - 1; pQuery->pos = QUERY_IS_ASC_QUERY(pQuery)? 0 : blockInfo.rows - 1;
int32_t numOfRes = tableApplyFunctionsOnBlock(pRuntimeEnv, &blockInfo, pStatis, binarySearchForKey, pDataBlock); int32_t numOfRes = tableApplyFunctionsOnBlock(pRuntimeEnv, &blockInfo, pStatis, binarySearchForKey, pDataBlock);
@ -2502,7 +2502,7 @@ int64_t getNumOfResultWindowRes(SQuery *pQuery, SWindowResult *pWindowRes) {
SResultInfo *pResultInfo = &pWindowRes->resultInfo[j]; SResultInfo *pResultInfo = &pWindowRes->resultInfo[j];
assert(pResultInfo != NULL); assert(pResultInfo != NULL);
if (pResultInfo->numOfRes > 0) { if (pResultInfo->numOfRes > 0) {
return pResultInfo->numOfRes; return pResultInfo->numOfRes;
} }
@ -2551,7 +2551,7 @@ int32_t mergeIntoGroupResultImpl(SQInfo *pQInfo, SArray *pGroup) {
assert(pQInfo->numOfGroupResultPages == 0); assert(pQInfo->numOfGroupResultPages == 0);
return 0; return 0;
} else if (numOfTables == 1) { // no need to merge results since only one table in each group } else if (numOfTables == 1) { // no need to merge results since only one table in each group
} }
SCompSupporter cs = {pTableList, posList, pQInfo}; SCompSupporter cs = {pTableList, posList, pQInfo};
@ -2640,7 +2640,7 @@ int32_t mergeIntoGroupResultImpl(SQInfo *pQInfo, SArray *pGroup) {
#endif #endif
qTrace("QInfo:%p result merge completed for group:%d, elapsed time:%" PRId64 " ms", pQInfo, pQInfo->groupIndex, endt - startt); qTrace("QInfo:%p result merge completed for group:%d, elapsed time:%" PRId64 " ms", pQInfo, pQInfo->groupIndex, endt - startt);
tfree(pTableList); tfree(pTableList);
tfree(posList); tfree(posList);
tfree(pTree); tfree(pTree);
@ -2870,12 +2870,12 @@ void initCtxOutputBuf(SQueryRuntimeEnv *pRuntimeEnv) {
for (int32_t j = 0; j < pQuery->numOfOutput; ++j) { for (int32_t j = 0; j < pQuery->numOfOutput; ++j) {
int32_t functionId = pQuery->pSelectExpr[j].base.functionId; int32_t functionId = pQuery->pSelectExpr[j].base.functionId;
pRuntimeEnv->pCtx[j].currentStage = 0; pRuntimeEnv->pCtx[j].currentStage = 0;
SResultInfo* pResInfo = GET_RES_INFO(&pRuntimeEnv->pCtx[j]); SResultInfo* pResInfo = GET_RES_INFO(&pRuntimeEnv->pCtx[j]);
if (pResInfo->initialized) { if (pResInfo->initialized) {
continue; continue;
} }
aAggs[functionId].init(&pRuntimeEnv->pCtx[j]); aAggs[functionId].init(&pRuntimeEnv->pCtx[j]);
} }
} }
@ -3248,7 +3248,7 @@ void setWindowResOutputBuf(SQueryRuntimeEnv *pRuntimeEnv, SWindowResult *pResult
for (int32_t i = 0; i < pQuery->numOfOutput; ++i) { for (int32_t i = 0; i < pQuery->numOfOutput; ++i) {
SQLFunctionCtx *pCtx = &pRuntimeEnv->pCtx[i]; SQLFunctionCtx *pCtx = &pRuntimeEnv->pCtx[i];
pCtx->aOutputBuf = getPosInResultPage(pRuntimeEnv, i, pResult); pCtx->aOutputBuf = getPosInResultPage(pRuntimeEnv, i, pResult);
int32_t functionId = pQuery->pSelectExpr[i].base.functionId; int32_t functionId = pQuery->pSelectExpr[i].base.functionId;
if (functionId == TSDB_FUNC_TOP || functionId == TSDB_FUNC_BOTTOM || functionId == TSDB_FUNC_DIFF) { if (functionId == TSDB_FUNC_TOP || functionId == TSDB_FUNC_BOTTOM || functionId == TSDB_FUNC_DIFF) {
pCtx->ptsOutputBuf = pRuntimeEnv->pCtx[0].aOutputBuf; pCtx->ptsOutputBuf = pRuntimeEnv->pCtx[0].aOutputBuf;
@ -3268,7 +3268,7 @@ void setWindowResOutputBuf(SQueryRuntimeEnv *pRuntimeEnv, SWindowResult *pResult
void setWindowResOutputBufInitCtx(SQueryRuntimeEnv *pRuntimeEnv, SWindowResult *pResult) { void setWindowResOutputBufInitCtx(SQueryRuntimeEnv *pRuntimeEnv, SWindowResult *pResult) {
SQuery *pQuery = pRuntimeEnv->pQuery; SQuery *pQuery = pRuntimeEnv->pQuery;
// Note: pResult->pos[i]->num == 0, there is only fixed number of results for each group // Note: pResult->pos[i]->num == 0, there is only fixed number of results for each group
for (int32_t i = 0; i < pQuery->numOfOutput; ++i) { for (int32_t i = 0; i < pQuery->numOfOutput; ++i) {
SQLFunctionCtx *pCtx = &pRuntimeEnv->pCtx[i]; SQLFunctionCtx *pCtx = &pRuntimeEnv->pCtx[i];
@ -3277,21 +3277,21 @@ void setWindowResOutputBufInitCtx(SQueryRuntimeEnv *pRuntimeEnv, SWindowResult *
if (pCtx->resultInfo->complete) { if (pCtx->resultInfo->complete) {
continue; continue;
} }
pCtx->aOutputBuf = getPosInResultPage(pRuntimeEnv, i, pResult); pCtx->aOutputBuf = getPosInResultPage(pRuntimeEnv, i, pResult);
pCtx->currentStage = 0; pCtx->currentStage = 0;
int32_t functionId = pCtx->functionId; int32_t functionId = pCtx->functionId;
if (functionId == TSDB_FUNC_TOP || functionId == TSDB_FUNC_BOTTOM || functionId == TSDB_FUNC_DIFF) { if (functionId == TSDB_FUNC_TOP || functionId == TSDB_FUNC_BOTTOM || functionId == TSDB_FUNC_DIFF) {
pCtx->ptsOutputBuf = pRuntimeEnv->pCtx[0].aOutputBuf; pCtx->ptsOutputBuf = pRuntimeEnv->pCtx[0].aOutputBuf;
} }
/* /*
* set the output buffer information and intermediate buffer * set the output buffer information and intermediate buffer
* not all queries require the interResultBuf, such as COUNT * not all queries require the interResultBuf, such as COUNT
*/ */
pCtx->resultInfo->superTableQ = pRuntimeEnv->stableQuery; // set super table query flag pCtx->resultInfo->superTableQ = pRuntimeEnv->stableQuery; // set super table query flag
if (!pCtx->resultInfo->initialized) { if (!pCtx->resultInfo->initialized) {
aAggs[functionId].init(pCtx); aAggs[functionId].init(pCtx);
} }
@ -4470,7 +4470,7 @@ static void multiTableQueryProcess(SQInfo *pQInfo) {
// query error occurred or query is killed, abort current execution // query error occurred or query is killed, abort current execution
if (pQInfo->code != TSDB_CODE_SUCCESS || isQueryKilled(pQInfo)) { if (pQInfo->code != TSDB_CODE_SUCCESS || isQueryKilled(pQInfo)) {
qTrace("QInfo:%p query killed or error occurred, code:%d, abort", pQInfo, pQInfo->code); qTrace("QInfo:%p query killed or error occurred, code:%s, abort", pQInfo, tstrerror(pQInfo->code));
return; return;
} }
@ -4491,7 +4491,7 @@ static void multiTableQueryProcess(SQInfo *pQInfo) {
setQueryStatus(pQuery, QUERY_COMPLETED); setQueryStatus(pQuery, QUERY_COMPLETED);
if (pQInfo->code != TSDB_CODE_SUCCESS || isQueryKilled(pQInfo)) { if (pQInfo->code != TSDB_CODE_SUCCESS || isQueryKilled(pQInfo)) {
qTrace("QInfo:%p query killed or error occurred, code:%d, abort", pQInfo, pQInfo->code); qTrace("QInfo:%p query killed or error occurred, code:%s, abort", pQInfo, tstrerror(pQInfo->code));
return; return;
} }
@ -4867,7 +4867,7 @@ static bool validateQuerySourceCols(SQueryTableMsg *pQueryMsg, SSqlFuncMsg** pEx
(pFuncMsg->functionId == TSDB_FUNC_COUNT && pFuncMsg->colInfo.colId == TSDB_TBNAME_COLUMN_INDEX)) { (pFuncMsg->functionId == TSDB_FUNC_COUNT && pFuncMsg->colInfo.colId == TSDB_TBNAME_COLUMN_INDEX)) {
continue; continue;
} }
return false; return false;
} }
} }
@ -5851,6 +5851,8 @@ void qDestroyQueryInfo(qinfo_t qHandle) {
} }
int16_t ref = T_REF_DEC(pQInfo); int16_t ref = T_REF_DEC(pQInfo);
qTrace("QInfo:%p dec refCount, value:%d", pQInfo, ref);
if (ref == 0) { if (ref == 0) {
doDestoryQueryInfo(pQInfo); doDestoryQueryInfo(pQInfo);
} }
@ -5994,25 +5996,25 @@ static void buildTagQueryResult(SQInfo* pQInfo) {
size_t numOfGroup = taosArrayGetSize(pQInfo->groupInfo.pGroupList); size_t numOfGroup = taosArrayGetSize(pQInfo->groupInfo.pGroupList);
assert(numOfGroup == 0 || numOfGroup == 1); assert(numOfGroup == 0 || numOfGroup == 1);
if (numOfGroup == 0) { if (numOfGroup == 0) {
return; return;
} }
SArray* pa = taosArrayGetP(pQInfo->groupInfo.pGroupList, 0); SArray* pa = taosArrayGetP(pQInfo->groupInfo.pGroupList, 0);
size_t num = taosArrayGetSize(pa); size_t num = taosArrayGetSize(pa);
assert(num == pQInfo->groupInfo.numOfTables); assert(num == pQInfo->groupInfo.numOfTables);
int32_t count = 0; int32_t count = 0;
int32_t functionId = pQuery->pSelectExpr[0].base.functionId; int32_t functionId = pQuery->pSelectExpr[0].base.functionId;
if (functionId == TSDB_FUNC_TID_TAG) { // return the tags & table Id if (functionId == TSDB_FUNC_TID_TAG) { // return the tags & table Id
assert(pQuery->numOfOutput == 1); assert(pQuery->numOfOutput == 1);
SExprInfo* pExprInfo = &pQuery->pSelectExpr[0]; SExprInfo* pExprInfo = &pQuery->pSelectExpr[0];
int32_t rsize = pExprInfo->bytes; int32_t rsize = pExprInfo->bytes;
count = 0; count = 0;
while(pQInfo->tableIndex < num && count < pQuery->rec.capacity) { while(pQInfo->tableIndex < num && count < pQuery->rec.capacity) {
int32_t i = pQInfo->tableIndex++; int32_t i = pQInfo->tableIndex++;
SGroupItem *item = taosArrayGet(pa, i); SGroupItem *item = taosArrayGet(pa, i);
@ -6054,12 +6056,12 @@ static void buildTagQueryResult(SQInfo* pQInfo) {
} }
} }
} }
count += 1; count += 1;
} }
qTrace("QInfo:%p create (tableId, tag) info completed, rows:%d", pQInfo, count); qTrace("QInfo:%p create (tableId, tag) info completed, rows:%d", pQInfo, count);
} else if (functionId == TSDB_FUNC_COUNT) {// handle the "count(tbname)" query } else if (functionId == TSDB_FUNC_COUNT) {// handle the "count(tbname)" query
*(int64_t*) pQuery->sdata[0]->data = num; *(int64_t*) pQuery->sdata[0]->data = num;
@ -6071,7 +6073,7 @@ static void buildTagQueryResult(SQInfo* pQInfo) {
SSchema tbnameSchema = tGetTableNameColumnSchema(); SSchema tbnameSchema = tGetTableNameColumnSchema();
while(pQInfo->tableIndex < num && count < pQuery->rec.capacity) { while(pQInfo->tableIndex < num && count < pQuery->rec.capacity) {
int32_t i = pQInfo->tableIndex++; int32_t i = pQInfo->tableIndex++;
SExprInfo* pExprInfo = pQuery->pSelectExpr; SExprInfo* pExprInfo = pQuery->pSelectExpr;
SGroupItem* item = taosArrayGet(pa, i); SGroupItem* item = taosArrayGet(pa, i);
@ -6086,7 +6088,7 @@ static void buildTagQueryResult(SQInfo* pQInfo) {
char* data = tsdbGetTableTagVal(pQInfo->tsdb, &item->id, pExprInfo[j].base.colInfo.colId, type, bytes); char* data = tsdbGetTableTagVal(pQInfo->tsdb, &item->id, pExprInfo[j].base.colInfo.colId, type, bytes);
char* dst = pQuery->sdata[j]->data + count * pExprInfo[j].bytes; char* dst = pQuery->sdata[j]->data + count * pExprInfo[j].bytes;
if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR) { if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR) {
if (data == NULL) { if (data == NULL) {
setVardataNull(dst, type); setVardataNull(dst, type);
@ -6104,7 +6106,7 @@ static void buildTagQueryResult(SQInfo* pQInfo) {
} }
count += 1; count += 1;
} }
qTrace("QInfo:%p create tag values results completed, rows:%d", pQInfo, count); qTrace("QInfo:%p create tag values results completed, rows:%d", pQInfo, count);
} }

View File

@ -393,7 +393,6 @@ void rpcSendResponse(const SRpcMsg *pRsp) {
if ( pConn->inType == 0 || pConn->user[0] == 0 ) { if ( pConn->inType == 0 || pConn->user[0] == 0 ) {
tTrace("%s, connection is already released, rsp wont be sent", pConn->info); tTrace("%s, connection is already released, rsp wont be sent", pConn->info);
rpcUnlockConn(pConn); rpcUnlockConn(pConn);
rpcDecRef(pRpc);
return; return;
} }
@ -487,12 +486,19 @@ void rpcSendRecv(void *shandle, SRpcIpSet *pIpSet, const SRpcMsg *pMsg, SRpcMsg
} }
// this API is used by server app to keep an APP context in case connection is broken // this API is used by server app to keep an APP context in case connection is broken
void rpcReportProgress(void *handle, char *pCont, int contLen) { int rpcReportProgress(void *handle, char *pCont, int contLen) {
SRpcConn *pConn = (SRpcConn *)handle; SRpcConn *pConn = (SRpcConn *)handle;
// pReqMsg and reqMsgLen is re-used to store the context from app server if (pConn->user[0]) {
pConn->pReqMsg = pCont; // pReqMsg and reqMsgLen is re-used to store the context from app server
pConn->reqMsgLen = contLen; pConn->pReqMsg = pCont;
pConn->reqMsgLen = contLen;
return 0;
}
tTrace("%s, rpc connection is already released", pConn->info);
rpcFreeCont(pCont);
return -1;
} }
static void rpcFreeMsg(void *msg) { static void rpcFreeMsg(void *msg) {

View File

@ -72,7 +72,7 @@ typedef struct STableCheckInfo {
int32_t compSize; int32_t compSize;
int32_t numOfBlocks; // number of qualified data blocks not the original blocks int32_t numOfBlocks; // number of qualified data blocks not the original blocks
SDataCols* pDataCols; SDataCols* pDataCols;
int32_t chosen; // indicate which iterator should move forward int32_t chosen; // indicate which iterator should move forward
bool initBuf; // whether to initialize the in-memory skip list iterator or not bool initBuf; // whether to initialize the in-memory skip list iterator or not
SSkipListIterator* iter; // mem buffer skip list iterator SSkipListIterator* iter; // mem buffer skip list iterator
@ -311,14 +311,14 @@ SDataRow getSDataRowInTableMem(STableCheckInfo* pCheckInfo) {
rmem = SL_GET_NODE_DATA(node); rmem = SL_GET_NODE_DATA(node);
} }
} }
if (pCheckInfo->iiter) { if (pCheckInfo->iiter) {
SSkipListNode* node = tSkipListIterGet(pCheckInfo->iiter); SSkipListNode* node = tSkipListIterGet(pCheckInfo->iiter);
if (node != NULL) { if (node != NULL) {
rimem = SL_GET_NODE_DATA(node); rimem = SL_GET_NODE_DATA(node);
} }
} }
if (rmem != NULL && rimem != NULL) { if (rmem != NULL && rimem != NULL) {
if (dataRowKey(rmem) < dataRowKey(rimem)) { if (dataRowKey(rmem) < dataRowKey(rimem)) {
pCheckInfo->chosen = 0; pCheckInfo->chosen = 0;
@ -333,17 +333,17 @@ SDataRow getSDataRowInTableMem(STableCheckInfo* pCheckInfo) {
return rimem; return rimem;
} }
} }
if (rmem != NULL) { if (rmem != NULL) {
pCheckInfo->chosen = 0; pCheckInfo->chosen = 0;
return rmem; return rmem;
} }
if (rimem != NULL) { if (rimem != NULL) {
pCheckInfo->chosen = 1; pCheckInfo->chosen = 1;
return rimem; return rimem;
} }
return NULL; return NULL;
} }
@ -353,11 +353,11 @@ bool moveToNextRow(STableCheckInfo* pCheckInfo) {
if (pCheckInfo->iter != NULL) { if (pCheckInfo->iter != NULL) {
hasNext = tSkipListIterNext(pCheckInfo->iter); hasNext = tSkipListIterNext(pCheckInfo->iter);
} }
if (hasNext) { if (hasNext) {
return hasNext; return hasNext;
} }
if (pCheckInfo->iiter != NULL) { if (pCheckInfo->iiter != NULL) {
return tSkipListIterGet(pCheckInfo->iiter) != NULL; return tSkipListIterGet(pCheckInfo->iiter) != NULL;
} }
@ -366,17 +366,17 @@ bool moveToNextRow(STableCheckInfo* pCheckInfo) {
if (pCheckInfo->iiter != NULL) { if (pCheckInfo->iiter != NULL) {
hasNext = tSkipListIterNext(pCheckInfo->iiter); hasNext = tSkipListIterNext(pCheckInfo->iiter);
} }
if (hasNext) { if (hasNext) {
return hasNext; return hasNext;
} }
if (pCheckInfo->iter != NULL) { if (pCheckInfo->iter != NULL) {
return tSkipListIterGet(pCheckInfo->iter) != NULL; return tSkipListIterGet(pCheckInfo->iter) != NULL;
} }
} }
} }
return hasNext; return hasNext;
} }
@ -395,7 +395,7 @@ static bool hasMoreDataInCache(STsdbQueryHandle* pHandle) {
if (row == NULL) { if (row == NULL) {
return false; return false;
} }
pCheckInfo->lastKey = dataRowKey(row); // first timestamp in buffer pCheckInfo->lastKey = dataRowKey(row); // first timestamp in buffer
tsdbTrace("%p uid:%" PRId64", tid:%d check data in buffer from skey:%" PRId64 ", order:%d, %p", pHandle, tsdbTrace("%p uid:%" PRId64", tid:%d check data in buffer from skey:%" PRId64 ", order:%d, %p", pHandle,
pCheckInfo->tableId.uid, pCheckInfo->tableId.tid, pCheckInfo->lastKey, pHandle->order, pHandle->qinfo); pCheckInfo->tableId.uid, pCheckInfo->tableId.tid, pCheckInfo->lastKey, pHandle->order, pHandle->qinfo);
@ -581,9 +581,9 @@ static bool doLoadFileDataBlock(STsdbQueryHandle* pQueryHandle, SCompBlock* pBlo
bool blockLoaded = false; bool blockLoaded = false;
SArray* sa = getDefaultLoadColumns(pQueryHandle, true); SArray* sa = getDefaultLoadColumns(pQueryHandle, true);
int64_t st = taosGetTimestampUs(); int64_t st = taosGetTimestampUs();
if (pCheckInfo->pDataCols == NULL) { if (pCheckInfo->pDataCols == NULL) {
STsdbMeta* pMeta = tsdbGetMeta(pRepo); STsdbMeta* pMeta = tsdbGetMeta(pRepo);
pCheckInfo->pDataCols = tdNewDataCols(pMeta->maxRowBytes, pMeta->maxCols, pRepo->config.maxRowsPerFileBlock); pCheckInfo->pDataCols = tdNewDataCols(pMeta->maxRowBytes, pMeta->maxCols, pRepo->config.maxRowsPerFileBlock);
@ -603,13 +603,13 @@ static bool doLoadFileDataBlock(STsdbQueryHandle* pQueryHandle, SCompBlock* pBlo
SDataCols* pCols = pQueryHandle->rhelper.pDataCols[0]; SDataCols* pCols = pQueryHandle->rhelper.pDataCols[0];
assert(pCols->numOfRows != 0); assert(pCols->numOfRows != 0);
taosArrayDestroy(sa); taosArrayDestroy(sa);
tfree(data); tfree(data);
int64_t et = taosGetTimestampUs() - st; int64_t et = taosGetTimestampUs() - st;
tsdbTrace("%p load file block into buffer, elapsed time:%"PRId64 " us", pQueryHandle, et); tsdbTrace("%p load file block into buffer, elapsed time:%"PRId64 " us", pQueryHandle, et);
return blockLoaded; return blockLoaded;
} }
@ -681,7 +681,7 @@ static bool loadFileDataBlock(STsdbQueryHandle* pQueryHandle, SCompBlock* pBlock
if (!doLoadFileDataBlock(pQueryHandle, pBlock, pCheckInfo)) { if (!doLoadFileDataBlock(pQueryHandle, pBlock, pCheckInfo)) {
return false; return false;
} }
SDataCols* pTSCol = pQueryHandle->rhelper.pDataCols[0]; SDataCols* pTSCol = pQueryHandle->rhelper.pDataCols[0];
assert(pTSCol->cols->type == TSDB_DATA_TYPE_TIMESTAMP && pTSCol->numOfRows == pBlock->numOfRows); assert(pTSCol->cols->type == TSDB_DATA_TYPE_TIMESTAMP && pTSCol->numOfRows == pBlock->numOfRows);
@ -1212,7 +1212,7 @@ static int32_t createDataBlocksInfo(STsdbQueryHandle* pQueryHandle, int32_t numO
*numOfAllocBlocks = numOfBlocks; *numOfAllocBlocks = numOfBlocks;
int32_t numOfTables = taosArrayGetSize(pQueryHandle->pTableCheckInfo); int32_t numOfTables = taosArrayGetSize(pQueryHandle->pTableCheckInfo);
SBlockOrderSupporter sup = {0}; SBlockOrderSupporter sup = {0};
sup.numOfTables = numOfTables; sup.numOfTables = numOfTables;
sup.numOfBlocksPerTable = calloc(1, sizeof(int32_t) * numOfTables); sup.numOfBlocksPerTable = calloc(1, sizeof(int32_t) * numOfTables);
@ -1256,17 +1256,17 @@ static int32_t createDataBlocksInfo(STsdbQueryHandle* pQueryHandle, int32_t numO
} }
assert(numOfBlocks == cnt); assert(numOfBlocks == cnt);
// since there is only one table qualified, blocks are not sorted // since there is only one table qualified, blocks are not sorted
if (numOfQualTables == 1) { if (numOfQualTables == 1) {
memcpy(pQueryHandle->pDataBlockInfo, sup.pDataBlockInfo[0], sizeof(STableBlockInfo) * numOfBlocks); memcpy(pQueryHandle->pDataBlockInfo, sup.pDataBlockInfo[0], sizeof(STableBlockInfo) * numOfBlocks);
cleanBlockOrderSupporter(&sup, numOfQualTables); cleanBlockOrderSupporter(&sup, numOfQualTables);
tsdbTrace("%p create data blocks info struct completed for 1 table, %d blocks not sorted %p ", pQueryHandle, cnt, tsdbTrace("%p create data blocks info struct completed for 1 table, %d blocks not sorted %p ", pQueryHandle, cnt,
pQueryHandle->qinfo); pQueryHandle->qinfo);
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
tsdbTrace("%p create data blocks info struct completed, %d blocks in %d tables %p", pQueryHandle, cnt, tsdbTrace("%p create data blocks info struct completed, %d blocks in %d tables %p", pQueryHandle, cnt,
numOfQualTables, pQueryHandle->qinfo); numOfQualTables, pQueryHandle->qinfo);
@ -1683,7 +1683,7 @@ static int tsdbReadRowsFromCache(STableCheckInfo* pCheckInfo, TSKEY maxKey, int
int64_t elapsedTime = taosGetTimestampUs() - st; int64_t elapsedTime = taosGetTimestampUs() - st;
tsdbTrace("%p build data block from cache completed, elapsed time:%"PRId64" us, numOfRows:%d, numOfCols:%d", pQueryHandle, tsdbTrace("%p build data block from cache completed, elapsed time:%"PRId64" us, numOfRows:%d, numOfCols:%d", pQueryHandle,
elapsedTime, numOfRows, numOfCols); elapsedTime, numOfRows, numOfCols);
return numOfRows; return numOfRows;
} }

View File

@ -68,6 +68,7 @@ static void vnodeNotifyCurrentQhandle(void* handle, void* qhandle, int32_t vgId)
killQueryMsg->header.vgId = htonl(vgId); killQueryMsg->header.vgId = htonl(vgId);
killQueryMsg->header.contLen = htonl(sizeof(SRetrieveTableMsg)); killQueryMsg->header.contLen = htonl(sizeof(SRetrieveTableMsg));
vTrace("QInfo:%p register qhandle to connect:%p", qhandle, handle);
rpcReportProgress(handle, (char*) killQueryMsg, sizeof(SRetrieveTableMsg)); rpcReportProgress(handle, (char*) killQueryMsg, sizeof(SRetrieveTableMsg));
} }
@ -85,10 +86,11 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) {
killQueryMsg->free = htons(killQueryMsg->free); killQueryMsg->free = htons(killQueryMsg->free);
killQueryMsg->qhandle = htobe64(killQueryMsg->qhandle); killQueryMsg->qhandle = htobe64(killQueryMsg->qhandle);
vWarn("QInfo:%p connection %p broken, kill query", killQueryMsg->qhandle, pReadMsg->rpcMsg.handle);
assert(pReadMsg->rpcMsg.contLen > 0 && killQueryMsg->free == 1); assert(pReadMsg->rpcMsg.contLen > 0 && killQueryMsg->free == 1);
qDestroyQueryInfo((qinfo_t) killQueryMsg->qhandle);
return TSDB_CODE_SUCCESS; qKillQuery((qinfo_t) killQueryMsg->qhandle);
return TSDB_CODE_TSC_QUERY_CANCELLED; // todo change the error code
} }
int32_t code = TSDB_CODE_SUCCESS; int32_t code = TSDB_CODE_SUCCESS;

View File

@ -134,6 +134,9 @@ python3 ./test.py -f query/filter.py
python3 ./test.py -f query/filterCombo.py python3 ./test.py -f query/filterCombo.py
python3 ./test.py -f query/queryNormal.py python3 ./test.py -f query/queryNormal.py
python3 ./test.py -f query/queryError.py python3 ./test.py -f query/queryError.py
python3 ./test.py -f query/filterAllIntTypes.py
python3 ./test.py -f query/filterFloatAndDouble.py
python3 ./test.py -f query/filterOtherTypes.py
#stream #stream
python3 ./test.py -f stream/stream1.py python3 ./test.py -f stream/stream1.py

View File

@ -0,0 +1,117 @@
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import sys
import taos
from util.log import *
from util.cases import *
from util.sql import *
class TDTestCase:
def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor())
self.powers = [7, 15, 31, 63]
self.types = ["tinyint", "smallint", "int", "bigint"]
self.rowNum = 10
self.ts = 1537146000000
def run(self):
tdSql.prepare()
for i in range(len(self.powers)):
curType = self.types[i]
print("======= Verify filter for %s type =========" % (curType))
tdLog.debug(
"create table st%s(ts timestamp, num %s) tags(id %s)" % (curType, curType, curType))
tdSql.execute(
"create table st%s(ts timestamp, num %s) tags(id %s)" % (curType, curType, curType))
#create 10 tables, insert 10 rows for each table
for j in range(self.rowNum):
tdSql.execute("create table st%s%d using st%s tags(%d)" % (curType, j + 1, curType, j + 1))
for k in range(self.rowNum):
tdSql.execute("insert into st%s%d values(%d, %d)" % (curType, j + 1, self.ts + k + 1, j * 10 + k + 1))
tdSql.error("insert into st%s10 values(%d, %d)" % (curType, self.ts + 11, pow(2, self.powers[i])))
tdSql.execute("insert into st%s10 values(%d, %d)" % (curType, self.ts + 12, pow(2, self.powers[i]) - 1))
tdSql.error("insert into st%s10 values(%d, %d)" % (curType, self.ts + 13, pow(-2, self.powers[i])))
tdSql.execute("insert into st%s10 values(%d, %d)" % (curType, self.ts + 14, pow(-2, self.powers[i]) + 1))
# > for int type on column
tdSql.query("select * from st%s where num > 50" % curType)
tdSql.checkRows(51)
# >= for int type on column
tdSql.query("select * from st%s where num >= 50" % curType)
tdSql.checkRows(52)
# = for int type on column
tdSql.query("select * from st%s where num = 50" % curType)
tdSql.checkRows(1)
# < for int type on column
tdSql.query("select * from st%s where num < 50" % curType)
tdSql.checkRows(50)
# <= for int type on column
tdSql.query("select * from st%s where num <= 50" % curType)
tdSql.checkRows(51)
# <> for int type on column
tdSql.query("select * from st%s where num <> 50" % curType)
tdSql.checkRows(101)
# != for int type on column
tdSql.query("select * from st%s where num != 50" % curType)
tdSql.checkRows(101)
# > for int type on tag
tdSql.query("select * from st%s where id > 5" % curType)
tdSql.checkRows(52)
# >= for int type on tag
tdSql.query("select * from st%s where id >= 5" % curType)
tdSql.checkRows(62)
# = for int type on tag
tdSql.query("select * from st%s where id = 5" % curType)
tdSql.checkRows(10)
# < for int type on tag
tdSql.query("select * from st%s where id < 5" % curType)
tdSql.checkRows(40)
# <= for int type on tag
tdSql.query("select * from st%s where id <= 5" % curType)
tdSql.checkRows(50)
# <> for int type on tag
tdSql.query("select * from st%s where id <> 5" % curType)
tdSql.checkRows(92)
# != for int type on tag
tdSql.query("select * from st%s where id != 5" % curType)
tdSql.checkRows(92)
print("======= Verify filter for %s type finished =========" % curType)
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())

View File

@ -0,0 +1,160 @@
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import sys
import taos
from util.log import *
from util.cases import *
from util.sql import *
class TDTestCase:
def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor())
self.rowNum = 10
self.ts = 1537146000000
def run(self):
tdSql.prepare()
print("======= Verify filter for float and double type =========")
tdLog.debug(
"create table st(ts timestamp, num float, speed double) tags(tagcol1 float, tagcol2 double)")
tdSql.execute(
"create table st(ts timestamp, num float, speed double) tags(tagcol1 float, tagcol2 double)")
for j in range(self.rowNum):
tdSql.execute(
"insert into st1 using st tags(1.1, 2.3) values(%d, %f, %f)" % (self.ts + j + 1, 1.1 * (j + 1), 2.3 * (j + 1)))
# > for float type on column
tdSql.query("select * from st where num > 5.5")
tdSql.checkRows(5)
# >= for float type on column
tdSql.query("select * from st where num >= 5.5")
tdSql.checkRows(6)
# = for float type on column
tdSql.query("select * from st where num = 5.5")
tdSql.checkRows(1)
# <> for float type on column
tdSql.query("select * from st where num <> 5.5")
tdSql.checkRows(9)
# != for float type on column
tdSql.query("select * from st where num != 5.5")
tdSql.checkRows(9)
# <= for float type on column
tdSql.query("select * from st where num <= 5.5")
tdSql.checkRows(5)
# < for float type on column
tdSql.query("select * from st where num < 5.5")
tdSql.checkRows(4)
# > for float type on tag
tdSql.query("select * from st where tagcol1 > 1.1")
tdSql.checkRows(0)
# >= for float type on tag
tdSql.query("select * from st where tagcol1 >= 1.1")
tdSql.checkRows(10)
# = for float type on tag
tdSql.query("select * from st where tagcol1 = 1.1")
tdSql.checkRows(10)
# <> for float type on tag
tdSql.query("select * from st where tagcol1 <> 1.1")
tdSql.checkRows(0)
# != for float type on tag
tdSql.query("select * from st where tagcol1 != 1.1")
tdSql.checkRows(0)
# <= for float type on tag
tdSql.query("select * from st where tagcol1 <= 1.1")
tdSql.checkRows(10)
# < for float type on tag
tdSql.query("select * from st where tagcol1 < 1.1")
tdSql.checkRows(0)
# > for double type on column
tdSql.query("select * from st where speed > 11.5")
tdSql.checkRows(5)
# >= for double type on column
tdSql.query("select * from st where speed >= 11.5")
tdSql.checkRows(6)
# = for double type on column
tdSql.query("select * from st where speed = 11.5")
tdSql.checkRows(1)
# <> for double type on column
tdSql.query("select * from st where speed <> 11.5")
tdSql.checkRows(9)
# != for double type on column
tdSql.query("select * from st where speed != 11.5")
tdSql.checkRows(9)
# <= for double type on column
tdSql.query("select * from st where speed <= 11.5")
tdSql.checkRows(5)
# < for double type on column
tdSql.query("select * from st where speed < 11.5")
tdSql.checkRows(4)
# > for double type on tag
tdSql.query("select * from st where tagcol2 > 2.3")
tdSql.checkRows(0)
# >= for double type on tag
tdSql.query("select * from st where tagcol2 >= 2.3")
tdSql.checkRows(10)
# = for double type on tag
tdSql.query("select * from st where tagcol2 = 2.3")
tdSql.checkRows(10)
# <> for double type on tag
tdSql.query("select * from st where tagcol2 <> 2.3")
tdSql.checkRows(0)
# != for double type on tag
tdSql.query("select * from st where tagcol2 != 2.3")
tdSql.checkRows(0)
# <= for double type on tag
tdSql.query("select * from st where tagcol2 <= 2.3")
tdSql.checkRows(10)
# < for double type on tag
tdSql.query("select * from st where tagcol2 < 2.3")
tdSql.checkRows(0)
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())

View File

@ -0,0 +1,362 @@
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import sys
import taos
from util.log import *
from util.cases import *
from util.sql import *
class TDTestCase:
def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor())
self.ts = 1537146000000
def run(self):
tdSql.prepare()
print("======= Verify filter for bool, nchar and binary type =========")
tdLog.debug(
"create table st(ts timestamp, tbcol1 bool, tbcol2 nchar(10), tbcol3 binary(20)) tags(tagcol1 bool, tagcol2 nchar(10), tagcol3 binary(10))")
tdSql.execute(
"create table st(ts timestamp, tbcol1 bool, tbcol2 nchar(10), tbcol3 binary(20)) tags(tagcol1 bool, tagcol2 nchar(10), tagcol3 binary(10))")
tdSql.execute("create table st1 using st tags(true, 'table1', '水表')")
for i in range(1, 6):
tdSql.execute("insert into st1 values(%d, %d, 'taosdata%d', '涛思数据%d')" % (self.ts + i, i % 2, i, i))
tdSql.execute("create table st2 using st tags(false, 'table2', '电表')")
for i in range(6, 11):
tdSql.execute("insert into st2 values(%d, %d, 'taosdata%d', '涛思数据%d')" % (self.ts + i, i % 2, i, i))
# =============Verify stable columns====================
# > for bool type on column
tdSql.error("select * from st where tbcol1 > false")
# >= for bool type on column
tdSql.error("select * from st where tbcol1 >= false")
# = for bool type on column
tdSql.query("select * from st where tbcol1 = false")
tdSql.checkRows(5)
# <> for bool type on column
tdSql.query("select * from st where tbcol1 <> true")
tdSql.checkRows(5)
# != for bool type on column
tdSql.query("select * from st where tbcol1 != true")
tdSql.checkRows(5)
# > for bool type on column
tdSql.error("select * from st where tbcol1 < true")
# >= for bool type on column
tdSql.error("select * from st where tbcol1 <= true")
# % for bool type on column
tdSql.error("select * from st where tbcol1 like '%'")
# _ for bool type on column
tdSql.error("select * from st where tbcol1 like '____'")
# > for nchar type on column
tdSql.error("select * from st where tbcol2 > 'taosdata'")
# >= for nchar type on column
tdSql.error("select * from st where tbcol2 >= 'taosdata'")
# = for nchar type on column
tdSql.query("select * from st where tbcol2 = 'taosdata1'")
tdSql.checkRows(1)
# <> for nchar type on column
tdSql.query("select * from st where tbcol2 <> 'taosdata1'")
tdSql.checkRows(9)
# != for nchar type on column
tdSql.query("select * from st where tbcol2 != 'taosdata1'")
tdSql.checkRows(9)
# > for nchar type on column
tdSql.error("select * from st where tbcol2 < 'taodata'")
# >= for nchar type on column
tdSql.error("select * from st where tbcol2 <= 'taodata'")
# % for nchar type on column case 1
tdSql.query("select * from st where tbcol2 like '%'")
tdSql.checkRows(10)
# % for nchar type on column case 2
tdSql.query("select * from st where tbcol2 like 'a%'")
tdSql.checkRows(0)
# % for nchar type on column case 3
tdSql.query("select * from st where tbcol2 like 't%_'")
tdSql.checkRows(10)
# % for nchar type on column case 4
tdSql.query("select * from st where tbcol2 like '%1'")
# tdSql.checkRows(2)
# _ for nchar type on column case 1
tdSql.query("select * from st where tbcol2 like '____________'")
tdSql.checkRows(0)
# _ for nchar type on column case 2
tdSql.query("select * from st where tbcol2 like '__________'")
tdSql.checkRows(1)
# _ for nchar type on column case 3
tdSql.query("select * from st where tbcol2 like '_________'")
tdSql.checkRows(9)
# _ for nchar type on column case 4
tdSql.query("select * from st where tbcol2 like 't________'")
tdSql.checkRows(9)
# _ for nchar type on column case 5
tdSql.query("select * from st where tbcol2 like '%________'")
tdSql.checkRows(10)
# > for binary type on column
tdSql.error("select * from st where tbcol3 > '涛思数据'")
# >= for binary type on column
tdSql.error("select * from st where tbcol3 >= '涛思数据'")
# = for binary type on column
tdSql.query("select * from st where tbcol3 = '涛思数据1'")
tdSql.checkRows(1)
# <> for binary type on column
tdSql.query("select * from st where tbcol3 <> '涛思数据1'")
tdSql.checkRows(9)
# != for binary type on column
tdSql.query("select * from st where tbcol3 != '涛思数据1'")
tdSql.checkRows(9)
# > for binary type on column
tdSql.error("select * from st where tbcol3 < '涛思数据'")
# >= for binary type on column
tdSql.error("select * from st where tbcol3 <= '涛思数据'")
# % for binary type on column case 1
tdSql.query("select * from st where tbcol3 like '%'")
tdSql.checkRows(10)
# % for binary type on column case 2
tdSql.query("select * from st where tbcol3 like '%'")
tdSql.checkRows(0)
# % for binary type on column case 3
tdSql.query("select * from st where tbcol3 like '%_'")
tdSql.checkRows(10)
# % for binary type on column case 4
tdSql.query("select * from st where tbcol3 like '%1'")
tdSql.checkRows(1)
# _ for binary type on column case 1
tdSql.query("select * from st where tbcol3 like '_______'")
tdSql.checkRows(0)
# _ for binary type on column case 2
tdSql.query("select * from st where tbcol3 like '______'")
tdSql.checkRows(1)
# _ for binary type on column case 2
tdSql.query("select * from st where tbcol3 like '_____'")
tdSql.checkRows(9)
# _ for binary type on column case 3
tdSql.query("select * from st where tbcol3 like '____'")
tdSql.checkRows(0)
# _ for binary type on column case 4
tdSql.query("select * from st where tbcol3 like 't____'")
tdSql.checkRows(0)
# =============Verify stable tags====================
# > for bool type on tag
tdSql.error("select * from st where tagcol1 > false")
# >= for bool type on tag
tdSql.error("select * from st where tagcol1 >= false")
# = for bool type on tag
tdSql.query("select * from st where tagcol1 = false")
tdSql.checkRows(5)
# <> for bool type on tag
tdSql.query("select * from st where tagcol1 <> true")
tdSql.checkRows(5)
# != for bool type on tag
tdSql.query("select * from st where tagcol1 != true")
tdSql.checkRows(5)
# > for bool type on tag
tdSql.error("select * from st where tagcol1 < true")
# >= for bool type on tag
tdSql.error("select * from st where tagcol1 <= true")
# % for bool type on tag
tdSql.error("select * from st where tagcol1 like '%'")
# _ for bool type on tag
tdSql.error("select * from st where tagcol1 like '____'")
# > for nchar type on tag
tdSql.error("select * from st where tagcol2 > 'table'")
# >= for nchar type on tag
tdSql.error("select * from st where tagcol2 >= 'table'")
# = for nchar type on tag
tdSql.query("select * from st where tagcol2 = 'table1'")
tdSql.checkRows(5)
# <> for nchar type on tag
tdSql.query("select * from st where tagcol2 <> 'table1'")
tdSql.checkRows(5)
# != for nchar type on tag
tdSql.query("select * from st where tagcol2 != 'table'")
tdSql.checkRows(10)
# > for nchar type on tag
tdSql.error("select * from st where tagcol2 < 'table'")
# >= for nchar type on tag
tdSql.error("select * from st where tagcol2 <= 'table'")
# % for nchar type on tag case 1
tdSql.query("select * from st where tagcol2 like '%'")
tdSql.checkRows(10)
# % for nchar type on tag case 2
tdSql.query("select * from st where tagcol2 like 'a%'")
tdSql.checkRows(0)
# % for nchar type on tag case 3
tdSql.query("select * from st where tagcol2 like 't%_'")
tdSql.checkRows(10)
# % for nchar type on tag case 4
tdSql.query("select * from st where tagcol2 like '%1'")
tdSql.checkRows(5)
# _ for nchar type on tag case 1
tdSql.query("select * from st where tagcol2 like '_______'")
tdSql.checkRows(0)
# _ for nchar type on tag case 2
tdSql.query("select * from st where tagcol2 like '______'")
tdSql.checkRows(10)
# _ for nchar type on tag case 3
tdSql.query("select * from st where tagcol2 like 't_____'")
tdSql.checkRows(10)
# _ for nchar type on tag case 4
tdSql.query("select * from st where tagcol2 like 's________'")
tdSql.checkRows(0)
# _ for nchar type on tag case 5
tdSql.query("select * from st where tagcol2 like '%__'")
tdSql.checkRows(10)
# > for binary type on tag
tdSql.error("select * from st where tagcol3 > ''")
# >= for binary type on tag
tdSql.error("select * from st where tagcol3 >= ''")
# = for binary type on tag
tdSql.query("select * from st where tagcol3 = '水表'")
tdSql.checkRows(5)
# <> for binary type on tag
tdSql.query("select * from st where tagcol3 <> '水表'")
tdSql.checkRows(5)
# != for binary type on tag
tdSql.query("select * from st where tagcol3 != '水表'")
tdSql.checkRows(5)
# > for binary type on tag
tdSql.error("select * from st where tagcol3 < '水表'")
# >= for binary type on tag
tdSql.error("select * from st where tagcol3 <= '水表'")
# % for binary type on tag case 1
tdSql.query("select * from st where tagcol3 like '%'")
tdSql.checkRows(10)
# % for binary type on tag case 2
tdSql.query("select * from st where tagcol3 like '%'")
tdSql.checkRows(5)
# % for binary type on tag case 3
tdSql.query("select * from st where tagcol3 like '%_'")
tdSql.checkRows(0)
# % for binary type on tag case 4
tdSql.query("select * from st where tagcol3 like '%'")
tdSql.checkRows(10)
# % for binary type on tag case 5
tdSql.query("select * from st where tagcol3 like '%'")
tdSql.checkRows(0)
# _ for binary type on tag case 1
tdSql.query("select * from st where tagcol3 like '__'")
tdSql.checkRows(10)
# _ for binary type on tag case 2
tdSql.query("select * from st where tagcol3 like '水_'")
tdSql.checkRows(5)
# _ for binary type on tag case 2
tdSql.query("select * from st where tagcol3 like '_表'")
tdSql.checkRows(10)
# _ for binary type on tag case 3
tdSql.query("select * from st where tagcol3 like '___'")
tdSql.checkRows(0)
# _ for binary type on tag case 4
tdSql.query("select * from st where tagcol3 like '数_'")
tdSql.checkRows(0)
# _ for binary type on tag case 5
tdSql.query("select * from st where tagcol3 like '_据'")
tdSql.checkRows(0)
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())

View File

@ -131,6 +131,8 @@ python3 ./test.py -f user/pass_len.py
#query #query
python3 ./test.py -f query/filter.py python3 ./test.py -f query/filter.py
python3 ./test.py -f query/filterAllIntTypes.py
python3 ./test.py -f query/filterFloatAndDouble.py
#stream #stream

View File

@ -51,7 +51,7 @@ system sh/exec.sh -n dnode2 -s start
sql create dnode $hostname2 sql create dnode $hostname2
sleep 3000 sleep 3000
$totalTableNum = 10000 $totalTableNum = 10
$sleepTimer = 10000 $sleepTimer = 10000
$db = db $db = db
@ -192,7 +192,7 @@ if $data00 != $totalRows then
endi endi
print ============== step4: stop dnode2 for checking if sync success print ============== step4: stop dnode2 for checking if sync ok
system sh/exec.sh -n dnode2 -s stop system sh/exec.sh -n dnode2 -s stop
sleep $sleepTimer sleep $sleepTimer

View File

@ -55,7 +55,7 @@ sql create dnode $hostname3
sql create dnode $hostname4 sql create dnode $hostname4
sleep 3000 sleep 3000
$totalTableNum = 1000 $totalTableNum = 10
$sleepTimer = 10000 $sleepTimer = 10000
$db = db $db = db

View File

@ -173,7 +173,7 @@ if $rows != 3 then
return -1 return -1
endi endi
print ============== step5: remove dnode4 director, then recreate dnode4 into cluster, result should success print ============== step5: remove dnode4 director, then recreate dnode4 into cluster, result should ok
system sh/exec.sh -n dnode4 -s stop system sh/exec.sh -n dnode4 -s stop
system rm -rf ../../../sim/dnode4 system rm -rf ../../../sim/dnode4

View File

@ -55,7 +55,7 @@ sql create dnode $hostname3
sql create dnode $hostname4 sql create dnode $hostname4
sleep 3000 sleep 3000
$totalTableNum = 100 $totalTableNum = 10
$sleepTimer = 3000 $sleepTimer = 3000
$db = db $db = db

View File

@ -55,7 +55,7 @@ sql create dnode $hostname3
#sql create dnode $hostname4 #sql create dnode $hostname4
sleep 3000 sleep 3000
$totalTableNum = 100 $totalTableNum = 10
$sleepTimer = 3000 $sleepTimer = 3000
$db = db $db = db
@ -177,7 +177,7 @@ if $data00 != $totalRows then
return -1 return -1
endi endi
print ============== step5: stop dnode2, and check if dnode3 sync success print ============== step5: stop dnode2, and check if dnode3 sync ok
system sh/exec.sh -n dnode2 -s stop -x SIGINT system sh/exec.sh -n dnode2 -s stop -x SIGINT
sleep $sleepTimer sleep $sleepTimer
wait_dnode2_offline_0: wait_dnode2_offline_0:

View File

@ -55,7 +55,7 @@ sql create dnode $hostname3
#sql create dnode $hostname4 #sql create dnode $hostname4
sleep 3000 sleep 3000
$totalTableNum = 100 $totalTableNum = 10
$sleepTimer = 3000 $sleepTimer = 3000
$db = db $db = db
@ -105,7 +105,7 @@ if $data00 != $totalRows then
return -1 return -1
endi endi
print ============== step5: stop dnode2, and check if dnode3 sync success print ============== step5: stop dnode2, and check if dnode3 sync ok
system sh/exec.sh -n dnode2 -s stop -x SIGINT system sh/exec.sh -n dnode2 -s stop -x SIGINT
sleep $sleepTimer sleep $sleepTimer
wait_dnode2_offline_0: wait_dnode2_offline_0:

View File

@ -55,7 +55,7 @@ sql create dnode $hostname3
sql create dnode $hostname4 sql create dnode $hostname4
sleep 3000 sleep 3000
$totalTableNum = 100 $totalTableNum = 10
$sleepTimer = 3000 $sleepTimer = 3000
$db = db $db = db

View File

@ -55,7 +55,7 @@ sql create dnode $hostname3
sql create dnode $hostname4 sql create dnode $hostname4
sleep 3000 sleep 3000
$totalTableNum = 100 $totalTableNum = 10
$sleepTimer = 3000 $sleepTimer = 3000
$db = db $db = db
@ -152,7 +152,7 @@ print ============== step4: restart dnode2, then create database with replica 2,
system sh/exec.sh -n dnode2 -s start system sh/exec.sh -n dnode2 -s start
sleep 3000 sleep 3000
$totalTableNum = 100 $totalTableNum = 10
$sleepTimer = 3000 $sleepTimer = 3000
$db = db1 $db = db1

View File

@ -56,7 +56,7 @@ sql create dnode $hostname2
sql create dnode $hostname4 sql create dnode $hostname4
sleep 3000 sleep 3000
$totalTableNum = 100 $totalTableNum = 10
$sleepTimer = 3000 $sleepTimer = 3000
$db = db $db = db

View File

@ -67,7 +67,7 @@ sql use $db
# create table , insert data # create table , insert data
$stb = stb $stb = stb
sql create table $stb (ts timestamp, c1 int, c2 int) tags(t1 int) sql create table $stb (ts timestamp, c1 int, c2 int) tags(t0 int, t1 int)
$rowNum = 500 $rowNum = 500
$tblNum = $totalTableNum $tblNum = $totalTableNum
$totalRows = 0 $totalRows = 0
@ -77,7 +77,7 @@ $tsEnd = 0
$i = 0 $i = 0
while $i < $tblNum while $i < $tblNum
$tb = tb . $i $tb = tb . $i
sql create table $tb using $stb tags( $i ) sql create table $tb using $stb tags( $i , $i )
$x = 0 $x = 0
while $x < $rowNum while $x < $rowNum
@ -164,7 +164,7 @@ $totalRows = 0
$i = 0 $i = 0
while $i < $tblNum while $i < $tblNum
$tb = tb . $i $tb = tb . $i
sql create table $tb using $stb tags( $i , $i ) sql create table $tb using $stb tags( $i , $i , $i )
$x = 0 $x = 0
while $x < $rowNum while $x < $rowNum

View File

@ -56,7 +56,7 @@ sql create dnode $hostname2
sql create dnode $hostname4 sql create dnode $hostname4
sleep 3000 sleep 3000
$totalTableNum = 100 $totalTableNum = 10
$sleepTimer = 3000 $sleepTimer = 3000
$maxTables = $totalTableNum * 2 $maxTables = $totalTableNum * 2

View File

@ -56,7 +56,7 @@ sql create dnode $hostname2
sql create dnode $hostname4 sql create dnode $hostname4
sleep 3000 sleep 3000
$totalTableNum = 100 $totalTableNum = 10
$sleepTimer = 3000 $sleepTimer = 3000
$db = db $db = db

View File

@ -56,7 +56,7 @@ sql create dnode $hostname2
sql create dnode $hostname4 sql create dnode $hostname4
sleep 3000 sleep 3000
$totalTableNum = 100 $totalTableNum = 10
$sleepTimer = 3000 $sleepTimer = 3000
$db = db $db = db
@ -146,14 +146,14 @@ endi
print ============== step4: drop some tables print ============== step4: drop some tables
$i = 1 $i = 1
$dropTblNum = 21 $dropTblNum = 6
while $i < $dropTblNum while $i < $dropTblNum
$tb = tb . $i $tb = tb . $i
sql drop table if exists $tb sql drop table if exists $tb
$i = $i + 1 $i = $i + 1
endw endw
$tblNum = $tblNum - 20 $tblNum = $tblNum - 5
print ============== step5: restart dnode4, waiting dnode4 synced print ============== step5: restart dnode4, waiting dnode4 synced
system sh/exec.sh -n dnode4 -s start system sh/exec.sh -n dnode4 -s start

View File

@ -56,7 +56,7 @@ sql create dnode $hostname3
sql create dnode $hostname4 sql create dnode $hostname4
sleep 3000 sleep 3000
$totalTableNum = 100 $totalTableNum = 10
$sleepTimer = 3000 $sleepTimer = 3000
$db = db $db = db

View File

@ -67,7 +67,7 @@ sql use $db
# create table , insert data # create table , insert data
$stb = stb $stb = stb
sql create table $stb (ts timestamp, c1 int, c2 int) tags(t1 int) sql create table $stb (ts timestamp, c1 int, c2 int) tags(t0 int, t1 int)
$rowNum = 500 $rowNum = 500
$tblNum = $totalTableNum $tblNum = $totalTableNum
$totalRows = 0 $totalRows = 0
@ -77,7 +77,7 @@ $tsEnd = 0
$i = 0 $i = 0
while $i < $tblNum while $i < $tblNum
$tb = tb . $i $tb = tb . $i
sql create table $tb using $stb tags( $i ) sql create table $tb using $stb tags( $i , $i )
$x = 0 $x = 0
while $x < $rowNum while $x < $rowNum
@ -164,7 +164,7 @@ $totalRows = 0
$i = 0 $i = 0
while $i < $tblNum while $i < $tblNum
$tb = tb . $i $tb = tb . $i
sql create table $tb using $stb tags( $i , $i ) sql create table $tb using $stb tags( $i , $i , $i )
$x = 0 $x = 0
while $x < $rowNum while $x < $rowNum

View File

@ -56,7 +56,7 @@ sql create dnode $hostname3
sql create dnode $hostname4 sql create dnode $hostname4
sleep 3000 sleep 3000
$totalTableNum = 100 $totalTableNum = 10
$sleepTimer = 3000 $sleepTimer = 3000
$maxTables = $totalTableNum * 2 $maxTables = $totalTableNum * 2

View File

@ -56,7 +56,7 @@ sql create dnode $hostname3
sql create dnode $hostname4 sql create dnode $hostname4
sleep 3000 sleep 3000
$totalTableNum = 100 $totalTableNum = 10
$sleepTimer = 3000 $sleepTimer = 3000
$db = db $db = db

View File

@ -56,7 +56,7 @@ sql create dnode $hostname3
sql create dnode $hostname4 sql create dnode $hostname4
sleep 3000 sleep 3000
$totalTableNum = 100 $totalTableNum = 10
$sleepTimer = 3000 $sleepTimer = 3000
$db = db $db = db
@ -146,14 +146,14 @@ endi
print ============== step4: drop some tables print ============== step4: drop some tables
$i = 1 $i = 1
$dropTblNum = 21 $dropTblNum = 6
while $i < $dropTblNum while $i < $dropTblNum
$tb = tb . $i $tb = tb . $i
sql drop table if exists $tb sql drop table if exists $tb
$i = $i + 1 $i = $i + 1
endw endw
$tblNum = $tblNum - 20 $tblNum = $tblNum - 5
print ============== step5: restart dnode4, waiting dnode4 synced print ============== step5: restart dnode4, waiting dnode4 synced
system sh/exec.sh -n dnode4 -s start system sh/exec.sh -n dnode4 -s start