提交 c597c8ad 编写于 作者: weixin_48148422's avatar weixin_48148422

TD-97: fix bug and update testcases

上级 a9e6abc0
...@@ -3545,7 +3545,7 @@ static int32_t setTableCondForSTableQuery(SQueryInfo* pQueryInfo, const char* ac ...@@ -3545,7 +3545,7 @@ static int32_t setTableCondForSTableQuery(SQueryInfo* pQueryInfo, const char* ac
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
SStringBuilder sb1; SStringBuilder sb1 = { 0 };
taosStringBuilderAppendStringLen(&sb1, QUERY_COND_REL_PREFIX_IN, QUERY_COND_REL_PREFIX_IN_LEN); taosStringBuilderAppendStringLen(&sb1, QUERY_COND_REL_PREFIX_IN, QUERY_COND_REL_PREFIX_IN_LEN);
char db[TSDB_TABLE_ID_LEN] = {0}; char db[TSDB_TABLE_ID_LEN] = {0};
......
...@@ -1855,7 +1855,7 @@ int tscBuildHeartBeatMsg(SSqlObj *pSql, SSqlInfo *pInfo) { ...@@ -1855,7 +1855,7 @@ int tscBuildHeartBeatMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pCmd->msgType = TSDB_MSG_TYPE_CM_HEARTBEAT; pCmd->msgType = TSDB_MSG_TYPE_CM_HEARTBEAT;
assert(msgLen + minMsgSize() <= size); assert(msgLen + minMsgSize() <= size);
return msgLen; return TSDB_CODE_SUCCESS;
} }
int tscProcessTableMetaRsp(SSqlObj *pSql) { int tscProcessTableMetaRsp(SSqlObj *pSql) {
......
...@@ -816,7 +816,7 @@ static void tQueryIndexlessColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo, ...@@ -816,7 +816,7 @@ static void tQueryIndexlessColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo,
if (pQueryInfo->optr == TSDB_RELATION_IN) { if (pQueryInfo->optr == TSDB_RELATION_IN) {
addToResult = pQueryInfo->compare(table->name, pQueryInfo->q.arr); addToResult = pQueryInfo->compare(table->name, pQueryInfo->q.arr);
} else if(pQueryInfo->optr == TSDB_RELATION_LIKE) { } else if(pQueryInfo->optr == TSDB_RELATION_LIKE) {
addToResult = pQueryInfo->compare(table->name, pQueryInfo->q.pz); addToResult = !pQueryInfo->compare(table->name, pQueryInfo->q.pz);
} }
} else { } else {
// TODO: other columns // TODO: other columns
...@@ -1188,6 +1188,7 @@ tExprNode* exprTreeFromTableName(const char* tbnameCond) { ...@@ -1188,6 +1188,7 @@ tExprNode* exprTreeFromTableName(const char* tbnameCond) {
// TODO: // TODO:
} }
memcpy(pVal->pz, tbnameCond + QUERY_COND_REL_PREFIX_LIKE_LEN, len); memcpy(pVal->pz, tbnameCond + QUERY_COND_REL_PREFIX_LIKE_LEN, len);
pVal->nLen = (int32_t)len;
} else if (strncmp(tbnameCond, QUERY_COND_REL_PREFIX_IN, QUERY_COND_REL_PREFIX_IN_LEN) == 0) { } else if (strncmp(tbnameCond, QUERY_COND_REL_PREFIX_IN, QUERY_COND_REL_PREFIX_IN_LEN) == 0) {
right->nodeType = TSQL_NODE_VALUE; right->nodeType = TSQL_NODE_VALUE;
......
...@@ -5430,13 +5430,6 @@ static int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SArray **pTableIdList, ...@@ -5430,13 +5430,6 @@ static int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SArray **pTableIdList,
pMsg += sizeof(int64_t) * pQueryMsg->numOfOutput; pMsg += sizeof(int64_t) * pQueryMsg->numOfOutput;
} }
// the tag query condition expression string is located at the end of query msg
if (pQueryMsg->tagCondLen > 0) {
*tagCond = calloc(1, pQueryMsg->tagCondLen);
memcpy(*tagCond, pMsg, pQueryMsg->tagCondLen);
pMsg += pQueryMsg->tagCondLen;
}
if (pQueryMsg->numOfTags > 0) { if (pQueryMsg->numOfTags > 0) {
(*tagCols) = calloc(1, sizeof(SColumnInfo) * pQueryMsg->numOfTags); (*tagCols) = calloc(1, sizeof(SColumnInfo) * pQueryMsg->numOfTags);
for (int32_t i = 0; i < pQueryMsg->numOfTags; ++i) { for (int32_t i = 0; i < pQueryMsg->numOfTags; ++i) {
...@@ -5448,13 +5441,22 @@ static int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SArray **pTableIdList, ...@@ -5448,13 +5441,22 @@ static int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SArray **pTableIdList,
pTagCol->numOfFilters = 0; pTagCol->numOfFilters = 0;
(*tagCols)[i] = *pTagCol; (*tagCols)[i] = *pTagCol;
pMsg += sizeof(SColumnInfo);
} }
} }
// the tag query condition expression string is located at the end of query msg
if (pQueryMsg->tagCondLen > 0) {
*tagCond = calloc(1, pQueryMsg->tagCondLen);
memcpy(*tagCond, pMsg, pQueryMsg->tagCondLen);
pMsg += pQueryMsg->tagCondLen;
}
if (*pMsg != 0) { if (*pMsg != 0) {
size_t len = strlen(pMsg); size_t len = strlen(pMsg) + 1;
*tbnameCond = malloc(len + 1); *tbnameCond = malloc(len);
strcpy(*tbnameCond, pMsg); strcpy(*tbnameCond, pMsg);
pMsg += len;
} }
qTrace("qmsg:%p query on %d table(s), qrange:%" PRId64 "-%" PRId64 qTrace("qmsg:%p query on %d table(s), qrange:%" PRId64 "-%" PRId64
......
...@@ -1448,7 +1448,7 @@ int32_t tsdbQueryByTagsCond( ...@@ -1448,7 +1448,7 @@ int32_t tsdbQueryByTagsCond(
size_t len, size_t len,
int16_t tagNameRelType, int16_t tagNameRelType,
const char* tbnameCond, const char* tbnameCond,
STableGroupInfo *pGroupList, STableGroupInfo *pGroupInfo,
SColIndex *pColIndex, SColIndex *pColIndex,
int32_t numOfCols int32_t numOfCols
) { ) {
...@@ -1465,16 +1465,15 @@ int32_t tsdbQueryByTagsCond( ...@@ -1465,16 +1465,15 @@ int32_t tsdbQueryByTagsCond(
if (tbnameCond == NULL && (pTagCond == NULL || len == 0)) { if (tbnameCond == NULL && (pTagCond == NULL || len == 0)) {
int32_t ret = getAllTableIdList(tsdb, uid, res); int32_t ret = getAllTableIdList(tsdb, uid, res);
if (ret == TSDB_CODE_SUCCESS) { if (ret == TSDB_CODE_SUCCESS) {
pGroupList->numOfTables = taosArrayGetSize(res);
pGroupList->pGroupList = createTableGroup(res, pTagSchema, pColIndex, numOfCols);
}
pGroupInfo->numOfTables = taosArrayGetSize(res); pGroupInfo->numOfTables = taosArrayGetSize(res);
pGroupInfo->pGroupList = createTableGroup(res, pTagSchema, pColIndex, numOfCols); pGroupInfo->pGroupList = createTableGroup(res, pTagSchema, pColIndex, numOfCols);
}
taosArrayDestroy(res); taosArrayDestroy(res);
return ret; return ret;
} }
int32_t ret = TSDB_CODE_SUCCESS;
tExprNode* expr = exprTreeFromTableName(tbnameCond); tExprNode* expr = exprTreeFromTableName(tbnameCond);
tExprNode* tagExpr = exprTreeFromBinary(pTagCond, len); tExprNode* tagExpr = exprTreeFromBinary(pTagCond, len);
if (tagExpr != NULL) { if (tagExpr != NULL) {
...@@ -1491,8 +1490,8 @@ int32_t tsdbQueryByTagsCond( ...@@ -1491,8 +1490,8 @@ int32_t tsdbQueryByTagsCond(
} }
doQueryTableList(pSTable, res, expr); doQueryTableList(pSTable, res, expr);
pGroupList->numOfTables = taosArrayGetSize(res); pGroupInfo->numOfTables = taosArrayGetSize(res);
pGroupList->pGroupList = createTableGroup(res, pTagSchema, pColIndex, numOfCols); pGroupInfo->pGroupList = createTableGroup(res, pTagSchema, pColIndex, numOfCols);
taosArrayDestroy(res); taosArrayDestroy(res);
return ret; return ret;
......
...@@ -39,29 +39,32 @@ class TDTestCase: ...@@ -39,29 +39,32 @@ class TDTestCase:
tdSql.query("select * from cars where tbname in ('carzero', 'cartwo')") tdSql.query("select * from cars where tbname in ('carzero', 'cartwo')")
tdSql.checkRows(1) tdSql.checkRows(1)
tdSql.query("select * from cars where id=1 or tbname in ('carzero0', 'cartwo')") tdSql.query("select * from cars where id=1 or tbname in ('carzero', 'cartwo')")
tdSql.checkRows(2) tdSql.checkRows(2)
tdSql.query("select * from cars where id=1 and tbname in ('carzero0', 'cartwo')") tdSql.query("select * from cars where id=1 and tbname in ('carzero', 'cartwo')")
tdSql.checkRows(0) tdSql.checkRows(0)
tdSql.query("select * from cars where id=0 and tbname in ('carzero0', 'cartwo')") tdSql.query("select * from cars where id=0 and tbname in ('carzero', 'cartwo')")
tdSql.checkRows(1) tdSql.checkRows(1)
tdSql.query("select * from cars where tbname like 'car%') """
tdSql.query("select * from cars where tbname like 'car%'")
tdSql.checkRows(2) tdSql.checkRows(2)
tdSql.query("select * from cars where tbname like '%%o') tdSql.cursor.execute("use db")
tdSql.query("select * from cars where tbname like '%o'")
tdSql.checkRows(1) tdSql.checkRows(1)
tdSql.query("select * from cars where id=1 and tbname like 'car%') tdSql.query("select * from cars where id=1 and tbname like 'car%')
tdSql.checkRows(1) tdSql.checkRows(1)
tdSql.query("select * from cars where id = 1 and tbname like '%%o') tdSql.query("select * from cars where id = 1 and tbname like '%o')
tdSql.checkRows(0) tdSql.checkRows(0)
tdSql.query("select * from cars where id = 1 or tbname like '%%o') tdSql.query("select * from cars where id = 1 or tbname like '%o')
tdSql.checkRows(2) tdSql.checkRows(2)
"""
def stop(self): def stop(self):
tdSql.close() tdSql.close()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册