diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 959cd81e06..dab5110a43 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -8018,9 +8018,29 @@ static int32_t insertCondIntoSelectStmt(SSelectStmt* pSelect, SNode* pCond) { if (pSelect->pWhere == NULL) { pSelect->pWhere = pCond; } else { - SNode* pWhere = NULL; - createLogicCondNode(pSelect->pWhere, pCond, &pWhere, LOGIC_COND_TYPE_AND); - pSelect->pWhere = pWhere; + SNodeList* pLogicCondListWhere = NULL; + SNodeList* pLogicCondList2 = NULL; + if (nodeType(pSelect->pWhere) == QUERY_NODE_LOGIC_CONDITION && + ((SLogicConditionNode*)pSelect->pWhere)->condType == LOGIC_COND_TYPE_AND) { + pLogicCondListWhere = ((SLogicConditionNode*)pSelect->pWhere)->pParameterList; + } else { + nodesListMakeAppend(&pLogicCondListWhere, pSelect->pWhere); + } + + if (nodeType(pCond) == QUERY_NODE_LOGIC_CONDITION && + ((SLogicConditionNode*)pCond)->condType == LOGIC_COND_TYPE_AND) { + pLogicCondList2 = ((SLogicConditionNode*)pCond)->pParameterList; + } else { + nodesListMakeAppend(&pLogicCondList2, pCond); + } + + nodesListAppendList(pLogicCondListWhere, pLogicCondList2); + + SLogicConditionNode* pWhere = (SLogicConditionNode*)nodesMakeNode(QUERY_NODE_LOGIC_CONDITION); + pWhere->condType = LOGIC_COND_TYPE_AND; + pWhere->pParameterList = pLogicCondListWhere; + + pSelect->pWhere = (SNode*)pWhere; } return TSDB_CODE_SUCCESS; } diff --git a/tests/script/tsim/query/show_db_table_kind.sim b/tests/script/tsim/query/show_db_table_kind.sim index 9be2d36fd1..a35ca78a34 100644 --- a/tests/script/tsim/query/show_db_table_kind.sim +++ b/tests/script/tsim/query/show_db_table_kind.sim @@ -94,4 +94,14 @@ print $rows if $rows != 5 then return -1 endi +sql show child db2.tables like '%' +print $rows +if $rows != 5 then + return -1 +endi +sql show normal db2.tables like '%' +print $rows +if $rows != 0 then + return -1 +endi system sh/exec.sh -n dnode1 -s stop -x SIGINT