From ac3f9ce7e189c3683fb8c873cac03e879cb0e3ab Mon Sep 17 00:00:00 2001 From: chenxiaobin19 <1025221611@qq.com> Date: Mon, 21 Nov 2022 15:49:28 +0800 Subject: [PATCH] fix connect by nocycle bug --- .../runtime/executor/nodeStartWithOp.cpp | 6 +-- src/test/regress/expected/sw_bugfix-2.out | 42 +++++++++++++++---- src/test/regress/sql/sw_bugfix-2.sql | 8 +++- 3 files changed, 44 insertions(+), 12 deletions(-) diff --git a/src/gausskernel/runtime/executor/nodeStartWithOp.cpp b/src/gausskernel/runtime/executor/nodeStartWithOp.cpp index 68c64d46d..3489f89d5 100644 --- a/src/gausskernel/runtime/executor/nodeStartWithOp.cpp +++ b/src/gausskernel/runtime/executor/nodeStartWithOp.cpp @@ -648,16 +648,16 @@ TupleTableSlot* ExecStartWithOp(StartWithOpState *node) break; } - tuplestore_puttupleslot(node->sw_workingTable, dstSlot); - /* * check we need stop infinit recursive iteration if NOCYCLE is specified in * ConnectByExpr, then return. Also, in case of cycle-report-error the ereport * is processed inside of CheckCycleException() */ if (CheckCycleExeception(node, dstSlot)) { - break; + continue; } + + tuplestore_puttupleslot(node->sw_workingTable, dstSlot); } /* report we have done material step for current StartWithOp node */ diff --git a/src/test/regress/expected/sw_bugfix-2.out b/src/test/regress/expected/sw_bugfix-2.out index 0bc76833f..4c75cb3b3 100755 --- a/src/test/regress/expected/sw_bugfix-2.out +++ b/src/test/regress/expected/sw_bugfix-2.out @@ -552,8 +552,7 @@ select *, connect_by_iscycle from t1 start with c1=1 connect by nocycle prior c1 c1 | c2 | c3 | connect_by_iscycle ----+----+----+-------------------- 1 | 1 | 1 | 0 - 1 | 1 | 1 | 1 -(2 rows) +(1 row) insert into t1 values(1,1,1); insert into t1 values(2,2,2); @@ -562,8 +561,7 @@ select *, connect_by_iscycle from t1 start with c1=1 connect by nocycle prior c1 ----+----+----+-------------------- 1 | 1 | 1 | 0 1 | 1 | 1 | 0 - 1 | 1 | 1 | 1 -(3 rows) +(2 rows) insert into t1 values(1,NULL,1); select *, connect_by_iscycle from t1 start with c1=1 connect by nocycle prior c1=c2 order siblings by 1,2 nulls first; @@ -572,8 +570,7 @@ select *, connect_by_iscycle from t1 start with c1=1 connect by nocycle prior c1 1 | | 1 | 0 1 | 1 | 1 | 0 1 | 1 | 1 | 0 - 1 | 1 | 1 | 1 -(4 rows) +(3 rows) select *, connect_by_iscycle from t1 start with c1=1 connect by nocycle prior c1=c2 order siblings by 1,2 nulls last; c1 | c2 | c3 | connect_by_iscycle @@ -581,8 +578,7 @@ select *, connect_by_iscycle from t1 start with c1=1 connect by nocycle prior c1 1 | 1 | 1 | 0 1 | 1 | 1 | 0 1 | | 1 | 0 - 1 | 1 | 1 | 1 -(4 rows) +(3 rows) delete from t1 where c2 is null; select *, connect_by_iscycle from t1 start with c1<3 connect by nocycle prior c1