From 16f9c172ac07ff5dbe73b59b3f1346a914d10788 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Tue, 25 Oct 2022 18:20:20 +0800 Subject: [PATCH] fix: fix merge join crash issue --- source/libs/command/src/explain.c | 7 ++++++- tests/script/tsim/query/explain.sim | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/source/libs/command/src/explain.c b/source/libs/command/src/explain.c index e0a4218243..80a524496c 100644 --- a/source/libs/command/src/explain.c +++ b/source/libs/command/src/explain.c @@ -685,7 +685,12 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i EXPLAIN_ROW_NEW(level + 1, EXPLAIN_ON_CONDITIONS_FORMAT); QRY_ERR_RET( - nodesNodeToSQL(pJoinNode->pOnConditions, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen)); + nodesNodeToSQL(pJoinNode->pMergeCondition, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen)); + if (pJoinNode->pOnConditions) { + EXPLAIN_ROW_APPEND(" AND "); + QRY_ERR_RET( + nodesNodeToSQL(pJoinNode->pOnConditions, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen)); + } EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); } diff --git a/tests/script/tsim/query/explain.sim b/tests/script/tsim/query/explain.sim index 2871252d91..78d905233b 100644 --- a/tests/script/tsim/query/explain.sim +++ b/tests/script/tsim/query/explain.sim @@ -47,6 +47,7 @@ sql explain verbose true select ts from tb1 where f1 > 0; sql explain verbose true select * from st1 where f1 > 0 and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00'; sql explain verbose true select count(*) from st1 partition by tbname slimit 1 soffset 2 limit 2 offset 1; sql explain verbose true select * from information_schema.ins_stables where db_name='db2'; +sql explain verbose true select st1.f1 from st1 join st2 on st1.ts=st2.ts and st1.f1 > 0; print ======== step4 sql explain analyze select ts from st1 where -2; @@ -75,6 +76,7 @@ sql explain analyze verbose true select f1 from st1 where f1 > 0 and ts > '2020- sql explain analyze verbose true select * from information_schema.ins_stables where db_name='db2'; sql explain analyze verbose true select * from (select min(f1),count(*) a from st1 where f1 > 0) where a < 0; sql explain analyze verbose true select count(f1) from st1 group by tbname; +sql explain analyze verbose true select st1.f1 from st1 join st2 on st1.ts=st2.ts and st1.f1 > 0; #not pass case #sql explain verbose true select count(*),sum(f1) as aa from tb1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' order by aa; @@ -95,4 +97,4 @@ sql explain analyze verbose true select count(f1) from st1 group by tbname; #sql explain analyze verbose true select min(f1) from st1 interval(3m, 2a) sliding(1m); -system sh/exec.sh -n dnode1 -s stop -x SIGINT +#system sh/exec.sh -n dnode1 -s stop -x SIGINT