fix issue

This commit is contained in:
54liuyao 2024-08-20 10:15:52 +08:00
parent 21d7820bb5
commit 1bff0e89f4
2 changed files with 92 additions and 10 deletions

View File

@ -12628,6 +12628,27 @@ static int32_t createParOperatorNode(EOperatorType opType, const char* pLeftCol,
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
static int32_t createIsOperatorNode(EOperatorType opType, const char* pColName, SNode** pOp) {
SOperatorNode* pOper = NULL;
int32_t code = nodesMakeNode(QUERY_NODE_OPERATOR, (SNode**)&pOper);
if (NULL == pOper) {
return code;
}
pOper->opType = opType;
code = nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)&pOper->pLeft);
if (TSDB_CODE_SUCCESS != code) {
nodesDestroyNode((SNode*)pOper);
return code;
}
pOper->pRight = NULL;
snprintf(((SColumnNode*)pOper->pLeft)->colName, sizeof(((SColumnNode*)pOper->pLeft)->colName), "%s", pColName);
*pOp = (SNode*)pOper;
return TSDB_CODE_SUCCESS;
}
static const char* getTbNameColName(ENodeType type) { static const char* getTbNameColName(ENodeType type) {
const char* colName; const char* colName;
switch (type) { switch (type) {
@ -15190,23 +15211,42 @@ static int32_t rewriteShowAliveStmt(STranslateContext* pCxt, SQuery* pQuery) {
return code; return code;
} }
// pSubSelect, pTemp1, pTempVal need to free SNode* pCondIsNULL = NULL;
code = createIsOperatorNode(OP_TYPE_IS_NULL, pSumColAlias, &pCondIsNULL);
pThen = NULL;
code = nodesMakeValueNodeFromInt32(1, &pThen);
if (TSDB_CODE_SUCCESS != code) { if (TSDB_CODE_SUCCESS != code) {
nodesDestroyNode((SNode*)pSubSelect); nodesDestroyNode((SNode*)pSubSelect);
nodesDestroyNode(pTemp1); nodesDestroyNode(pTemp1);
nodesDestroyNode(pTempVal); nodesDestroyNode(pTempVal);
return code; return code;
} }
// pSubSelect, pTemp1, pThen, pTempVal need to free
pWhenThen = NULL; SNode* pCondFull1 = NULL;
code = createParWhenThenNode(pTemp1, pThen, &pWhenThen); code = createLogicCondNode(&pTemp1, &pCondIsNULL, &pCondFull1, LOGIC_COND_TYPE_OR);
if (TSDB_CODE_SUCCESS != code) { if (TSDB_CODE_SUCCESS != code) {
nodesDestroyNode((SNode*)pSubSelect); nodesDestroyNode((SNode*)pSubSelect);
nodesDestroyNode(pTemp1); nodesDestroyNode(pTemp1);
nodesDestroyNode(pTempVal);
nodesDestroyNode(pCondIsNULL);
return code;
}
// pSubSelect, pCondFull1, pTempVal need to free
pThen = NULL;
code = nodesMakeValueNodeFromInt32(1, &pThen);
if (TSDB_CODE_SUCCESS != code) {
nodesDestroyNode((SNode*)pSubSelect);
nodesDestroyNode(pCondFull1);
nodesDestroyNode(pTempVal);
return code;
}
// pSubSelect, pCondFull1, pThen, pTempVal need to free
pWhenThen = NULL;
code = createParWhenThenNode(pCondFull1, pThen, &pWhenThen);
if (TSDB_CODE_SUCCESS != code) {
nodesDestroyNode((SNode*)pSubSelect);
nodesDestroyNode(pCondFull1);
nodesDestroyNode(pThen); nodesDestroyNode(pThen);
nodesDestroyNode(pTempVal); nodesDestroyNode(pTempVal);
return code; return code;
@ -15289,7 +15329,7 @@ static int32_t rewriteShowAliveStmt(STranslateContext* pCxt, SQuery* pQuery) {
} }
// pSubSelect, pWhenThenlist need to free // pSubSelect, pWhenThenlist need to free
// case when leader_col = count_col and count_col > 0 then 1 when leader_col < count_col and count_col > 0 then 2 else // case when leader_col = count_col and leader_col > 0 then 1 when leader_col < count_col and leader_col > 0 then 2 else
// 0 end as status // 0 end as status
pElse = NULL; pElse = NULL;
code = nodesMakeValueNodeFromInt32(0, &pElse); code = nodesMakeValueNodeFromInt32(0, &pElse);

View File

@ -21,6 +21,30 @@ sql create dnode $hostname4 port 7500
sleep 1000 sleep 1000
$loop_count = 0
loop00:
sleep 1000
$loop_count = $loop_count + 1
if $loop_count == 20 then
return -1
endi
print 0 show cluster alive;
sql show cluster alive;
print res------------------------
print $data00 $data01
print $data10 $data11
if $data00 != 1 then
print =====data00=$data00
goto loop00
endi
print =============== create database, stable, table print =============== create database, stable, table
sql create database test vgroups 6; sql create database test vgroups 6;
sql use test; sql use test;
@ -46,6 +70,15 @@ endi
print show cluster alive; print show cluster alive;
sql show cluster alive; sql show cluster alive;
print res------------------------
print $data00 $data01
print $data10 $data11
if $rows != 1 then
print =====rows=$rows
goto loop0
endi
if $data00 != 1 then if $data00 != 1 then
print =====data00=$data00 print =====data00=$data00
goto loop0 goto loop0
@ -54,6 +87,15 @@ endi
print show test.alive; print show test.alive;
sql show test.alive; sql show test.alive;
print res------------------------
print $data00 $data01
print $data10 $data11
if $rows != 1 then
print =====rows=$rows
goto loop0
endi
if $data00 != 1 then if $data00 != 1 then
print =====data00=$data00 print =====data00=$data00
goto loop0 goto loop0