提交 ed0d0819 编写于 作者: S slzhou

fix: fix bugs of condition is null

上级 99bc3293
...@@ -2355,24 +2355,25 @@ static bool sysTableIsOperatorCondOnOneTable(SNode* pCond, char* condTable) { ...@@ -2355,24 +2355,25 @@ static bool sysTableIsOperatorCondOnOneTable(SNode* pCond, char* condTable) {
} }
static bool sysTableIsCondOnOneTable(SNode* pCond, char* condTable) { static bool sysTableIsCondOnOneTable(SNode* pCond, char* condTable) {
if (pCond == NULL) {
return false;
}
if (nodeType(pCond) == QUERY_NODE_LOGIC_CONDITION) { if (nodeType(pCond) == QUERY_NODE_LOGIC_CONDITION) {
SLogicConditionNode* node = (SLogicConditionNode*)pCond; SLogicConditionNode* node = (SLogicConditionNode*)pCond;
if (LOGIC_COND_TYPE_AND == node->condType) { if (LOGIC_COND_TYPE_AND == node->condType) {
SListCell* cell = node->pParameterList->pHead; SNode* pChild = NULL;
for (int32_t i = 0; i < node->pParameterList->length; ++i) { FOREACH(pChild, node->pParameterList) {
SNode* pChild = cell->pNode; if (QUERY_NODE_OPERATOR == nodeType(pChild) && sysTableIsOperatorCondOnOneTable(pChild, condTable)) {
if (QUERY_NODE_OPERATOR == nodeType(pChild)) { return true;
if (sysTableIsOperatorCondOnOneTable(pChild, condTable)) {
return true;
}
} }
cell = cell->pNext;
} }
} }
} }
if (QUERY_NODE_OPERATOR == nodeType(pCond)) { if (QUERY_NODE_OPERATOR == nodeType(pCond)) {
return sysTableIsOperatorCondOnOneTable(pCond, condTable); return sysTableIsOperatorCondOnOneTable(pCond, condTable);
} }
return false; return false;
} }
...@@ -2401,8 +2402,8 @@ static SSDataBlock* sysTableScanUserTags(SOperatorInfo* pOperator) { ...@@ -2401,8 +2402,8 @@ static SSDataBlock* sysTableScanUserTags(SOperatorInfo* pOperator) {
varDataSetLen(dbname, strlen(varDataVal(dbname))); varDataSetLen(dbname, strlen(varDataVal(dbname)));
char condTableName[TSDB_TABLE_NAME_LEN] = {0}; char condTableName[TSDB_TABLE_NAME_LEN] = {0};
// optimize when sql like where table_name='tablename' and xxx. // optimize when sql like where table_name='tablename' and xxx.
if (sysTableIsCondOnOneTable(pInfo->pCondition, condTableName)) { if (pInfo->pCondition && sysTableIsCondOnOneTable(pInfo->pCondition, condTableName)) {
char tableName[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; char tableName[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
STR_TO_VARSTR(tableName, condTableName); STR_TO_VARSTR(tableName, condTableName);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册