fix: fix bugs of condition is null

This commit is contained in:
slzhou 2022-09-28 16:39:06 +08:00
parent 99bc329384
commit ed0d08192d
1 changed files with 11 additions and 10 deletions

View File

@ -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)) {
if (sysTableIsOperatorCondOnOneTable(pChild, condTable)) {
return true; 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;
} }
@ -2402,7 +2403,7 @@ static SSDataBlock* sysTableScanUserTags(SOperatorInfo* pOperator) {
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);