From d3a9de055f04863a03bb372829cd422b311934e5 Mon Sep 17 00:00:00 2001 From: Zongtian Hou Date: Wed, 1 Feb 2023 16:35:32 +0800 Subject: [PATCH] fix wrong answer in connectby nocycle & siblings case --- .../optimizer/plan/planstartwith.cpp | 46 -- .../runtime/executor/nodeRecursiveunion.cpp | 21 - .../runtime/executor/nodeStartWithOp.cpp | 69 +-- src/include/nodes/execnodes.h | 6 - .../expected/enable_expr_fusion_flatten.out | 26 +- src/test/regress/expected/sw_basic.out | 289 ++++----- src/test/regress/expected/sw_bugfix-1.out | 582 +++++++++--------- src/test/regress/expected/sw_bugfix-2.out | 491 ++++++++------- src/test/regress/expected/sw_icbc.out | 32 +- src/test/regress/expected/sw_siblings.out | 300 +++++---- src/test/regress/sql/sw_bugfix-2.sql | 8 +- 11 files changed, 873 insertions(+), 997 deletions(-) diff --git a/src/gausskernel/optimizer/plan/planstartwith.cpp b/src/gausskernel/optimizer/plan/planstartwith.cpp index 4ac937485..c773e9be9 100644 --- a/src/gausskernel/optimizer/plan/planstartwith.cpp +++ b/src/gausskernel/optimizer/plan/planstartwith.cpp @@ -176,8 +176,6 @@ static Sort *CreateSiblingsSortPlan(PlannerInfo* root, Plan* lefttree, List *sortEntryList, double limit_tuples); static Sort *CreateSortPlanUnderRU(PlannerInfo* root, Plan* lefttree, List *siblings, double limit_tuples); -static Sort *CreateSortPlanAboveRU(PlannerInfo* root, Plan* lefttree, - double limit_tuples); static char *CheckAndFixSiblingsColName(PlannerInfo *root, Plan *basePlan, char *colname, TargetEntry *te); static char *GetOrderSiblingsColName(PlannerInfo* root, SortBy *sb, Plan *basePlan); @@ -1007,9 +1005,6 @@ static void ProcessOrderSiblings(PlannerInfo *root, StartWithOp *swplan) swoptions->siblings_orderby_clause, -1); ruplan->plan.righttree = (Plan *)CreateSortPlanUnderRU(root, ruplan->plan.righttree, swoptions->siblings_orderby_clause, -1); - - /* 2. Add up RU sort plan */ - swplan->plan.lefttree = (Plan *)CreateSortPlanAboveRU(root, swplan->plan.lefttree, -1); } @@ -1621,47 +1616,6 @@ static Sort *CreateSortPlanUnderRU(PlannerInfo* root, Plan* lefttree, List *sibl return sort; } -/* - * @Brief: Generate sort key above recursive union according array_siblings pseudo column - * that was filled by recursive union. Like the query below - * select * from t1 start with...connect by...order siblings by c1,c2,c3 - * the plan like this: - * ------------------QUERY PLAN-------------------- - * > StartWithOP - * Sort Key, sort by array_siblings pseudo column <<<<< we are have - * > Recursive Union - * > Sort Key, sort by c1, c2, c3 - * > Seqscan - * > Sort Key, sort by c1, c2, c3 - * > Seqscan - */ -static Sort *CreateSortPlanAboveRU(PlannerInfo* root, Plan* lefttree, double limit_tuples) -{ - Sort *sort = NULL; - List *sortEntryList = NIL; - ListCell *lc = NULL; - - foreach (lc, lefttree->targetlist) { - TargetEntry *tle = (TargetEntry *)lfirst(lc); - - if (strcmp(tle->resname, "array_siblings") == 0) { - OrderSiblingSortEntry *entry = - CreateOrderSiblingSortEntry(tle, SORTBY_ASC); - sortEntryList = lappend(sortEntryList, entry); - - if (u_sess->attr.attr_sql.enable_startwith_debug) { - elog(WARNING, "Good we got siblings sort key above RU."); - } - } - } - - sort = CreateSiblingsSortPlan(root, lefttree, sortEntryList, limit_tuples); - - /* Free sort entries */ - list_free_deep(sortEntryList); - - return sort; -} /* * -------------------------------------------------------------------------------------- diff --git a/src/gausskernel/runtime/executor/nodeRecursiveunion.cpp b/src/gausskernel/runtime/executor/nodeRecursiveunion.cpp index b096051a9..fefbe5276 100644 --- a/src/gausskernel/runtime/executor/nodeRecursiveunion.cpp +++ b/src/gausskernel/runtime/executor/nodeRecursiveunion.cpp @@ -406,27 +406,6 @@ static TupleTableSlot* ExecRecursiveUnion(PlanState* state) /* Not satisfy connect_by_level_qual,skip this tuple */ continue; } - - /* - * In ORDER SIBLINGS case, as we add SORT-Operator(material) on top of - * RecursiveUnion, so we have to do nocycle check here - */ - if (swplan->swoptions->siblings_orderby_clause) { - StartWithOpState *swstate = (StartWithOpState *)node->swstate; - if (swstate->sw_nocycleStopOrderSiblings) { - return (TupleTableSlot*)NULL; - } - - if (CheckCycleExeception(swstate, slot)) { - /* - * Mark execution stop for order siblings, note we let the cycle-causing - * tuple return to upper node and stop next one - */ - swstate->sw_nocycleStopOrderSiblings = true; - elog(DEBUG1, "nocycle option take effect on RecursiveUnion for Order Siblings! %s", - swstate->sw_curKeyArrayStr); - } - } } tuplestore_puttupleslot(node->intermediate_table, slot); diff --git a/src/gausskernel/runtime/executor/nodeStartWithOp.cpp b/src/gausskernel/runtime/executor/nodeStartWithOp.cpp index c431151f2..975822836 100644 --- a/src/gausskernel/runtime/executor/nodeStartWithOp.cpp +++ b/src/gausskernel/runtime/executor/nodeStartWithOp.cpp @@ -354,18 +354,9 @@ StartWithOpState* ExecInitStartWithOp(StartWithOp* node, EState* estate, int efl state->sw_curKeyArrayStr = NULL; state->sw_cycle_rowmarks = NULL; - /* Initialize nocycle controling flag */ - state->sw_nocycleStopOrderSiblings = false; - /* set underlying RecursiveUnionState pointing to current curernt node */ - if (node->swoptions->siblings_orderby_clause != NULL) { - SortState *sstate = (SortState *)outerPlanState(state); - RecursiveUnionState *rustate = (RecursiveUnionState *)outerPlanState(sstate); - rustate->swstate = state; - } else { - RecursiveUnionState *rustate = (RecursiveUnionState *)outerPlanState(state); - rustate->swstate = state; - } + RecursiveUnionState *rustate = (RecursiveUnionState *)outerPlanState(state); + rustate->swstate = state; /* init other elements */ state->sw_level = 0; @@ -381,12 +372,7 @@ bool CheckCycleExeception(StartWithOpState *node, TupleTableSlot *slot) bool nocycle = swplan->swoptions->nocycle; bool incycle = false; - if (swplan->swoptions->siblings_orderby_clause != NULL) { - SortState *sstate = (SortState *)node->ps.lefttree; - rustate = (RecursiveUnionState *)sstate->ss.ps.lefttree; - } else { - rustate = (RecursiveUnionState *)node->ps.lefttree; - } + rustate = (RecursiveUnionState *)node->ps.lefttree; Assert (IsA(rustate, RecursiveUnionState)); @@ -640,8 +626,6 @@ static TupleTableSlot* ExecStartWithOp(PlanState* state) { StartWithOpState *node = castNode(StartWithOpState, state); TupleTableSlot *dstSlot = node->ps.ps_ResultTupleSlot; - PlanState *outerNode = outerPlanState(node); - StartWithOp *swplan = (StartWithOp *)node->ps.plan; /* initialize row num count */ node->sw_rownum = 0; @@ -651,46 +635,9 @@ static TupleTableSlot* ExecStartWithOp(PlanState* state) case SWOP_BUILD: { Assert (node->sw_workingTable != NULL); markSWLevelBegin(node); - bool isDfsEnabled = swplan->swoptions->nocycle && !IsA(outerNode, SortState); - if (isDfsEnabled) { - /* For nocycle and non-order-siblings cases we use - * depth-first connect by to achieve result consistency. - */ - - /* Kick off dfs with StartWith tuples */ - int dfsRowCount = 0; - depth_first_connect(1, node, makeStartTuples(node), &dfsRowCount); - } - - /* Otherwise, use breadth-first style connect-by routine */ - /* Materialize all content to make internal part ready */ - for (; !isDfsEnabled;) { - /* - * We check for interrupts here because infinite loop might happen. - */ - CHECK_FOR_INTERRUPTS(); - - /* - * The actual executions and conversions are done - * in the underlying recursve union node. - */ - dstSlot = ExecProcNode(outerNode); - - if (TupIsNull(dstSlot)) { - break; - } - - /* - * 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)) { - continue; - } - - tuplestore_puttupleslot(node->sw_workingTable, dstSlot); - } + /* Kick off dfs with StartWith tuples */ + int dfsRowCount = 0; + depth_first_connect(1, node, makeStartTuples(node), &dfsRowCount); /* report we have done material step for current StartWithOp node */ ereport(DEBUG1, @@ -709,7 +656,7 @@ static TupleTableSlot* ExecStartWithOp(PlanState* state) */ tuplestore_rescan(node->sw_workingTable); node->swop_status = SWOP_EXECUTE; - } + } // @suppress("No break at end of case") /* fall-thru for first time */ case SWOP_EXECUTE: { @@ -774,8 +721,6 @@ void ExecReScanStartWithOp(StartWithOpState *state) tuplestore_clear(state->sw_backupTable); tuplestore_clear(state->sw_resultTable); - state->sw_nocycleStopOrderSiblings = false; - /* init other elements */ state->sw_level = 0; state->sw_numtuples = 0; diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h index 6b1107fc3..baff88d62 100755 --- a/src/include/nodes/execnodes.h +++ b/src/include/nodes/execnodes.h @@ -1675,12 +1675,6 @@ typedef struct StartWithOpState int sw_level; int sw_numtuples; /* number of tuples in current level */ - /* - * nocycle stop flag, normally is used to handle nocycle stop on order siblings - * case, as order-siblings add a sort operator on top of RU - */ - bool sw_nocycleStopOrderSiblings; - MemoryContext sw_context; List* sw_cycle_rowmarks; } StartWithOpState; diff --git a/src/test/regress/expected/enable_expr_fusion_flatten.out b/src/test/regress/expected/enable_expr_fusion_flatten.out index 46c0fa078..4c7cca0d7 100644 --- a/src/test/regress/expected/enable_expr_fusion_flatten.out +++ b/src/test/regress/expected/enable_expr_fusion_flatten.out @@ -554,26 +554,26 @@ CONNECT BY PRIOR id = fatherid; ----+--------+----------+-----------+-------+-------------------+--------------------+-----------------+------------------------------------ 1 | 中国 | 0 | China | 1 | 0 | 0 | China | @China 2 | 湖南省 | 1 | Hunan | 2 | 0 | 0 | China | @China@Hunan + 11 | 长沙市 | 2 | Changsha | 3 | 1 | 0 | China | @China@Hunan@Changsha + 13 | 衡阳市 | 2 | Hengyang | 3 | 0 | 0 | China | @China@Hunan@Hengyang + 22 | 祁北县 | 13 | Qibei | 4 | 1 | 0 | China | @China@Hunan@Hengyang@Qibei + 21 | 祁西县 | 13 | Qixi | 4 | 1 | 0 | China | @China@Hunan@Hengyang@Qixi + 14 | 耒阳市 | 13 | Leiyang | 4 | 1 | 0 | China | @China@Hunan@Hengyang@Leiyang + 19 | 祁东县 | 13 | Qidong | 4 | 1 | 0 | China | @China@Hunan@Hengyang@Qidong + 18 | 常宁市 | 13 | Changning | 4 | 1 | 0 | China | @China@Hunan@Hengyang@Changning + 20 | 祁南县 | 13 | Qinan | 4 | 1 | 0 | China | @China@Hunan@Hengyang@Qinan 3 | 广东省 | 1 | Guangdong | 2 | 0 | 0 | China | @China@Guangdong + 10 | 深圳市 | 3 | Shenzhen | 3 | 0 | 0 | China | @China@Guangdong@Shenzhen + 12 | 南山区 | 10 | Nanshan | 4 | 1 | 0 | China | @China@Guangdong@Shenzhen@Nanshan + 15 | 龙岗区 | 10 | Longgang | 4 | 1 | 0 | China | @China@Guangdong@Shenzhen@Longgang + 16 | 福田区 | 10 | Futian | 4 | 1 | 0 | China | @China@Guangdong@Shenzhen@Futian + 17 | 宝安区 | 10 | Baoan | 4 | 1 | 0 | China | @China@Guangdong@Shenzhen@Baoan 4 | 海南省 | 1 | Hainan | 2 | 1 | 0 | China | @China@Hainan 5 | 河北省 | 1 | Hebei | 2 | 1 | 0 | China | @China@Hebei 6 | 河南省 | 1 | Henan | 2 | 1 | 0 | China | @China@Henan 7 | 山东省 | 1 | Shandong | 2 | 1 | 0 | China | @China@Shandong 8 | 湖北省 | 1 | Hubei | 2 | 1 | 0 | China | @China@Hubei 9 | 江苏省 | 1 | Jiangsu | 2 | 1 | 0 | China | @China@Jiangsu - 10 | 深圳市 | 3 | Shenzhen | 3 | 0 | 0 | China | @China@Guangdong@Shenzhen - 11 | 长沙市 | 2 | Changsha | 3 | 1 | 0 | China | @China@Hunan@Changsha - 13 | 衡阳市 | 2 | Hengyang | 3 | 0 | 0 | China | @China@Hunan@Hengyang - 22 | 祁北县 | 13 | Qibei | 4 | 1 | 0 | China | @China@Hunan@Hengyang@Qibei - 12 | 南山区 | 10 | Nanshan | 4 | 1 | 0 | China | @China@Guangdong@Shenzhen@Nanshan - 21 | 祁西县 | 13 | Qixi | 4 | 1 | 0 | China | @China@Hunan@Hengyang@Qixi - 14 | 耒阳市 | 13 | Leiyang | 4 | 1 | 0 | China | @China@Hunan@Hengyang@Leiyang - 15 | 龙岗区 | 10 | Longgang | 4 | 1 | 0 | China | @China@Guangdong@Shenzhen@Longgang - 16 | 福田区 | 10 | Futian | 4 | 1 | 0 | China | @China@Guangdong@Shenzhen@Futian - 17 | 宝安区 | 10 | Baoan | 4 | 1 | 0 | China | @China@Guangdong@Shenzhen@Baoan - 19 | 祁东县 | 13 | Qidong | 4 | 1 | 0 | China | @China@Hunan@Hengyang@Qidong - 18 | 常宁市 | 13 | Changning | 4 | 1 | 0 | China | @China@Hunan@Hengyang@Changning - 20 | 祁南县 | 13 | Qinan | 4 | 1 | 0 | China | @China@Hunan@Hengyang@Qinan (22 rows) drop table test_area; diff --git a/src/test/regress/expected/sw_basic.out b/src/test/regress/expected/sw_basic.out index a164e2d98..fa091536b 100644 --- a/src/test/regress/expected/sw_basic.out +++ b/src/test/regress/expected/sw_basic.out @@ -66,26 +66,26 @@ CONNECT BY PRIOR id = fatherid; ----+--------+----------+-----------+-------+-------------------+--------------------+-----------------+------------------------------------ 1 | 中国 | 0 | China | 1 | 0 | 0 | China | @China 2 | 湖南省 | 1 | Hunan | 2 | 0 | 0 | China | @China@Hunan + 11 | 长沙市 | 2 | Changsha | 3 | 1 | 0 | China | @China@Hunan@Changsha + 13 | 衡阳市 | 2 | Hengyang | 3 | 0 | 0 | China | @China@Hunan@Hengyang + 22 | 祁北县 | 13 | Qibei | 4 | 1 | 0 | China | @China@Hunan@Hengyang@Qibei + 21 | 祁西县 | 13 | Qixi | 4 | 1 | 0 | China | @China@Hunan@Hengyang@Qixi + 14 | 耒阳市 | 13 | Leiyang | 4 | 1 | 0 | China | @China@Hunan@Hengyang@Leiyang + 19 | 祁东县 | 13 | Qidong | 4 | 1 | 0 | China | @China@Hunan@Hengyang@Qidong + 18 | 常宁市 | 13 | Changning | 4 | 1 | 0 | China | @China@Hunan@Hengyang@Changning + 20 | 祁南县 | 13 | Qinan | 4 | 1 | 0 | China | @China@Hunan@Hengyang@Qinan 3 | 广东省 | 1 | Guangdong | 2 | 0 | 0 | China | @China@Guangdong + 10 | 深圳市 | 3 | Shenzhen | 3 | 0 | 0 | China | @China@Guangdong@Shenzhen + 12 | 南山区 | 10 | Nanshan | 4 | 1 | 0 | China | @China@Guangdong@Shenzhen@Nanshan + 15 | 龙岗区 | 10 | Longgang | 4 | 1 | 0 | China | @China@Guangdong@Shenzhen@Longgang + 16 | 福田区 | 10 | Futian | 4 | 1 | 0 | China | @China@Guangdong@Shenzhen@Futian + 17 | 宝安区 | 10 | Baoan | 4 | 1 | 0 | China | @China@Guangdong@Shenzhen@Baoan 4 | 海南省 | 1 | Hainan | 2 | 1 | 0 | China | @China@Hainan 5 | 河北省 | 1 | Hebei | 2 | 1 | 0 | China | @China@Hebei 6 | 河南省 | 1 | Henan | 2 | 1 | 0 | China | @China@Henan 7 | 山东省 | 1 | Shandong | 2 | 1 | 0 | China | @China@Shandong 8 | 湖北省 | 1 | Hubei | 2 | 1 | 0 | China | @China@Hubei 9 | 江苏省 | 1 | Jiangsu | 2 | 1 | 0 | China | @China@Jiangsu - 10 | 深圳市 | 3 | Shenzhen | 3 | 0 | 0 | China | @China@Guangdong@Shenzhen - 11 | 长沙市 | 2 | Changsha | 3 | 1 | 0 | China | @China@Hunan@Changsha - 13 | 衡阳市 | 2 | Hengyang | 3 | 0 | 0 | China | @China@Hunan@Hengyang - 22 | 祁北县 | 13 | Qibei | 4 | 1 | 0 | China | @China@Hunan@Hengyang@Qibei - 12 | 南山区 | 10 | Nanshan | 4 | 1 | 0 | China | @China@Guangdong@Shenzhen@Nanshan - 21 | 祁西县 | 13 | Qixi | 4 | 1 | 0 | China | @China@Hunan@Hengyang@Qixi - 14 | 耒阳市 | 13 | Leiyang | 4 | 1 | 0 | China | @China@Hunan@Hengyang@Leiyang - 15 | 龙岗区 | 10 | Longgang | 4 | 1 | 0 | China | @China@Guangdong@Shenzhen@Longgang - 16 | 福田区 | 10 | Futian | 4 | 1 | 0 | China | @China@Guangdong@Shenzhen@Futian - 17 | 宝安区 | 10 | Baoan | 4 | 1 | 0 | China | @China@Guangdong@Shenzhen@Baoan - 19 | 祁东县 | 13 | Qidong | 4 | 1 | 0 | China | @China@Hunan@Hengyang@Qidong - 18 | 常宁市 | 13 | Changning | 4 | 1 | 0 | China | @China@Hunan@Hengyang@Changning - 20 | 祁南县 | 13 | Qinan | 4 | 1 | 0 | China | @China@Hunan@Hengyang@Qinan (22 rows) /* @@ -155,13 +155,13 @@ CONNECT BY id = PRIOR fatherid; id | name | fatherid | name_desc | level | connect_by_isleaf | connect_by_iscycle | connect_by_root | sys_connect_by_path ----+--------+----------+-----------+-------+-------------------+--------------------+-----------------+--------------------------------- 14 | 耒阳市 | 13 | Leiyang | 1 | 0 | 0 | Leiyang | @Leiyang - 17 | 宝安区 | 10 | Baoan | 1 | 0 | 0 | Baoan | @Baoan - 10 | 深圳市 | 3 | Shenzhen | 2 | 0 | 0 | Baoan | @Baoan@Shenzhen 13 | 衡阳市 | 2 | Hengyang | 2 | 0 | 0 | Leiyang | @Leiyang@Hengyang 2 | 湖南省 | 1 | Hunan | 3 | 0 | 0 | Leiyang | @Leiyang@Hengyang@Hunan + 1 | 中国 | 0 | China | 4 | 1 | 0 | Leiyang | @Leiyang@Hengyang@Hunan@China + 17 | 宝安区 | 10 | Baoan | 1 | 0 | 0 | Baoan | @Baoan + 10 | 深圳市 | 3 | Shenzhen | 2 | 0 | 0 | Baoan | @Baoan@Shenzhen 3 | 广东省 | 1 | Guangdong | 3 | 0 | 0 | Baoan | @Baoan@Shenzhen@Guangdong 1 | 中国 | 0 | China | 4 | 1 | 0 | Baoan | @Baoan@Shenzhen@Guangdong@China - 1 | 中国 | 0 | China | 4 | 1 | 0 | Leiyang | @Leiyang@Hengyang@Hunan@China (8 rows) /* @@ -196,26 +196,26 @@ CONNECT BY PRIOR id = fatherid; ----+--------+----------+-----------+-------+-------------------+--------------------+-----------------+-------------------------------------------- 1 | 中国 | 0 | China | 1 | 0 | 0 | China | =>>China 2 | 湖南省 | 1 | Hunan | 2 | 0 | 0 | China | =>>China=>>Hunan + 11 | 长沙市 | 2 | Changsha | 3 | 1 | 0 | China | =>>China=>>Hunan=>>Changsha + 13 | 衡阳市 | 2 | Hengyang | 3 | 0 | 0 | China | =>>China=>>Hunan=>>Hengyang + 22 | 祁北县 | 13 | Qibei | 4 | 1 | 0 | China | =>>China=>>Hunan=>>Hengyang=>>Qibei + 21 | 祁西县 | 13 | Qixi | 4 | 1 | 0 | China | =>>China=>>Hunan=>>Hengyang=>>Qixi + 14 | 耒阳市 | 13 | Leiyang | 4 | 1 | 0 | China | =>>China=>>Hunan=>>Hengyang=>>Leiyang + 19 | 祁东县 | 13 | Qidong | 4 | 1 | 0 | China | =>>China=>>Hunan=>>Hengyang=>>Qidong + 18 | 常宁市 | 13 | Changning | 4 | 1 | 0 | China | =>>China=>>Hunan=>>Hengyang=>>Changning + 20 | 祁南县 | 13 | Qinan | 4 | 1 | 0 | China | =>>China=>>Hunan=>>Hengyang=>>Qinan 3 | 广东省 | 1 | Guangdong | 2 | 0 | 0 | China | =>>China=>>Guangdong + 10 | 深圳市 | 3 | Shenzhen | 3 | 0 | 0 | China | =>>China=>>Guangdong=>>Shenzhen + 12 | 南山区 | 10 | Nanshan | 4 | 1 | 0 | China | =>>China=>>Guangdong=>>Shenzhen=>>Nanshan + 15 | 龙岗区 | 10 | Longgang | 4 | 1 | 0 | China | =>>China=>>Guangdong=>>Shenzhen=>>Longgang + 16 | 福田区 | 10 | Futian | 4 | 1 | 0 | China | =>>China=>>Guangdong=>>Shenzhen=>>Futian + 17 | 宝安区 | 10 | Baoan | 4 | 1 | 0 | China | =>>China=>>Guangdong=>>Shenzhen=>>Baoan 4 | 海南省 | 1 | Hainan | 2 | 1 | 0 | China | =>>China=>>Hainan 5 | 河北省 | 1 | Hebei | 2 | 1 | 0 | China | =>>China=>>Hebei 6 | 河南省 | 1 | Henan | 2 | 1 | 0 | China | =>>China=>>Henan 7 | 山东省 | 1 | Shandong | 2 | 1 | 0 | China | =>>China=>>Shandong 8 | 湖北省 | 1 | Hubei | 2 | 1 | 0 | China | =>>China=>>Hubei 9 | 江苏省 | 1 | Jiangsu | 2 | 1 | 0 | China | =>>China=>>Jiangsu - 10 | 深圳市 | 3 | Shenzhen | 3 | 0 | 0 | China | =>>China=>>Guangdong=>>Shenzhen - 11 | 长沙市 | 2 | Changsha | 3 | 1 | 0 | China | =>>China=>>Hunan=>>Changsha - 13 | 衡阳市 | 2 | Hengyang | 3 | 0 | 0 | China | =>>China=>>Hunan=>>Hengyang - 22 | 祁北县 | 13 | Qibei | 4 | 1 | 0 | China | =>>China=>>Hunan=>>Hengyang=>>Qibei - 12 | 南山区 | 10 | Nanshan | 4 | 1 | 0 | China | =>>China=>>Guangdong=>>Shenzhen=>>Nanshan - 21 | 祁西县 | 13 | Qixi | 4 | 1 | 0 | China | =>>China=>>Hunan=>>Hengyang=>>Qixi - 14 | 耒阳市 | 13 | Leiyang | 4 | 1 | 0 | China | =>>China=>>Hunan=>>Hengyang=>>Leiyang - 15 | 龙岗区 | 10 | Longgang | 4 | 1 | 0 | China | =>>China=>>Guangdong=>>Shenzhen=>>Longgang - 16 | 福田区 | 10 | Futian | 4 | 1 | 0 | China | =>>China=>>Guangdong=>>Shenzhen=>>Futian - 17 | 宝安区 | 10 | Baoan | 4 | 1 | 0 | China | =>>China=>>Guangdong=>>Shenzhen=>>Baoan - 19 | 祁东县 | 13 | Qidong | 4 | 1 | 0 | China | =>>China=>>Hunan=>>Hengyang=>>Qidong - 18 | 常宁市 | 13 | Changning | 4 | 1 | 0 | China | =>>China=>>Hunan=>>Hengyang=>>Changning - 20 | 祁南县 | 13 | Qinan | 4 | 1 | 0 | China | =>>China=>>Hunan=>>Hengyang=>>Qinan (22 rows) /* @@ -249,20 +249,20 @@ CONNECT BY id = PRIOR fatherid; id | name | fatherid | name_desc | level | connect_by_isleaf | connect_by_iscycle | connect_by_root | sys_connect_by_path ----+--------+----------+-----------+-------+-------------------+--------------------+-----------------+-------------------------------------------- 12 | 南山区 | 10 | Nanshan | 1 | 0 | 0 | Nanshan | -*>Nanshan - 15 | 龙岗区 | 10 | Longgang | 1 | 0 | 0 | Longgang | -*>Longgang - 16 | 福田区 | 10 | Futian | 1 | 0 | 0 | Futian | -*>Futian - 17 | 宝安区 | 10 | Baoan | 1 | 0 | 0 | Baoan | -*>Baoan 10 | 深圳市 | 3 | Shenzhen | 2 | 0 | 0 | Nanshan | -*>Nanshan-*>Shenzhen - 10 | 深圳市 | 3 | Shenzhen | 2 | 0 | 0 | Longgang | -*>Longgang-*>Shenzhen - 10 | 深圳市 | 3 | Shenzhen | 2 | 0 | 0 | Futian | -*>Futian-*>Shenzhen - 10 | 深圳市 | 3 | Shenzhen | 2 | 0 | 0 | Baoan | -*>Baoan-*>Shenzhen 3 | 广东省 | 1 | Guangdong | 3 | 0 | 0 | Nanshan | -*>Nanshan-*>Shenzhen-*>Guangdong - 3 | 广东省 | 1 | Guangdong | 3 | 0 | 0 | Longgang | -*>Longgang-*>Shenzhen-*>Guangdong - 3 | 广东省 | 1 | Guangdong | 3 | 0 | 0 | Futian | -*>Futian-*>Shenzhen-*>Guangdong - 3 | 广东省 | 1 | Guangdong | 3 | 0 | 0 | Baoan | -*>Baoan-*>Shenzhen-*>Guangdong 1 | 中国 | 0 | China | 4 | 1 | 0 | Nanshan | -*>Nanshan-*>Shenzhen-*>Guangdong-*>China + 15 | 龙岗区 | 10 | Longgang | 1 | 0 | 0 | Longgang | -*>Longgang + 10 | 深圳市 | 3 | Shenzhen | 2 | 0 | 0 | Longgang | -*>Longgang-*>Shenzhen + 3 | 广东省 | 1 | Guangdong | 3 | 0 | 0 | Longgang | -*>Longgang-*>Shenzhen-*>Guangdong 1 | 中国 | 0 | China | 4 | 1 | 0 | Longgang | -*>Longgang-*>Shenzhen-*>Guangdong-*>China + 16 | 福田区 | 10 | Futian | 1 | 0 | 0 | Futian | -*>Futian + 10 | 深圳市 | 3 | Shenzhen | 2 | 0 | 0 | Futian | -*>Futian-*>Shenzhen + 3 | 广东省 | 1 | Guangdong | 3 | 0 | 0 | Futian | -*>Futian-*>Shenzhen-*>Guangdong 1 | 中国 | 0 | China | 4 | 1 | 0 | Futian | -*>Futian-*>Shenzhen-*>Guangdong-*>China + 17 | 宝安区 | 10 | Baoan | 1 | 0 | 0 | Baoan | -*>Baoan + 10 | 深圳市 | 3 | Shenzhen | 2 | 0 | 0 | Baoan | -*>Baoan-*>Shenzhen + 3 | 广东省 | 1 | Guangdong | 3 | 0 | 0 | Baoan | -*>Baoan-*>Shenzhen-*>Guangdong 1 | 中国 | 0 | China | 4 | 1 | 0 | Baoan | -*>Baoan-*>Shenzhen-*>Guangdong-*>China (16 rows) @@ -302,36 +302,36 @@ CONNECT BY PRIOR id = fatherid; id | name | fatherid | name_desc | level | connect_by_isleaf | connect_by_iscycle | connect_by_root | sys_connect_by_path ----+--------+----------+-----------+-------+-------------------+--------------------+-----------------+------------------------------------ 1 | 中国 | 0 | China | 1 | 0 | 0 | China | /China - 2 | 湖南省 | 1 | Hunan | 1 | 0 | 0 | Hunan | /Hunan 2 | 湖南省 | 1 | Hunan | 2 | 0 | 0 | China | /China/Hunan + 11 | 长沙市 | 2 | Changsha | 3 | 1 | 0 | China | /China/Hunan/Changsha + 13 | 衡阳市 | 2 | Hengyang | 3 | 0 | 0 | China | /China/Hunan/Hengyang + 22 | 祁北县 | 13 | Qibei | 4 | 1 | 0 | China | /China/Hunan/Hengyang/Qibei + 21 | 祁西县 | 13 | Qixi | 4 | 1 | 0 | China | /China/Hunan/Hengyang/Qixi + 14 | 耒阳市 | 13 | Leiyang | 4 | 1 | 0 | China | /China/Hunan/Hengyang/Leiyang + 19 | 祁东县 | 13 | Qidong | 4 | 1 | 0 | China | /China/Hunan/Hengyang/Qidong + 18 | 常宁市 | 13 | Changning | 4 | 1 | 0 | China | /China/Hunan/Hengyang/Changning + 20 | 祁南县 | 13 | Qinan | 4 | 1 | 0 | China | /China/Hunan/Hengyang/Qinan 3 | 广东省 | 1 | Guangdong | 2 | 0 | 0 | China | /China/Guangdong + 10 | 深圳市 | 3 | Shenzhen | 3 | 0 | 0 | China | /China/Guangdong/Shenzhen + 12 | 南山区 | 10 | Nanshan | 4 | 1 | 0 | China | /China/Guangdong/Shenzhen/Nanshan + 15 | 龙岗区 | 10 | Longgang | 4 | 1 | 0 | China | /China/Guangdong/Shenzhen/Longgang + 16 | 福田区 | 10 | Futian | 4 | 1 | 0 | China | /China/Guangdong/Shenzhen/Futian + 17 | 宝安区 | 10 | Baoan | 4 | 1 | 0 | China | /China/Guangdong/Shenzhen/Baoan 4 | 海南省 | 1 | Hainan | 2 | 1 | 0 | China | /China/Hainan 5 | 河北省 | 1 | Hebei | 2 | 1 | 0 | China | /China/Hebei 6 | 河南省 | 1 | Henan | 2 | 1 | 0 | China | /China/Henan 7 | 山东省 | 1 | Shandong | 2 | 1 | 0 | China | /China/Shandong 8 | 湖北省 | 1 | Hubei | 2 | 1 | 0 | China | /China/Hubei 9 | 江苏省 | 1 | Jiangsu | 2 | 1 | 0 | China | /China/Jiangsu + 2 | 湖南省 | 1 | Hunan | 1 | 0 | 0 | Hunan | /Hunan 11 | 长沙市 | 2 | Changsha | 2 | 1 | 0 | Hunan | /Hunan/Changsha 13 | 衡阳市 | 2 | Hengyang | 2 | 0 | 0 | Hunan | /Hunan/Hengyang - 10 | 深圳市 | 3 | Shenzhen | 3 | 0 | 0 | China | /China/Guangdong/Shenzhen - 11 | 长沙市 | 2 | Changsha | 3 | 1 | 0 | China | /China/Hunan/Changsha 22 | 祁北县 | 13 | Qibei | 3 | 1 | 0 | Hunan | /Hunan/Hengyang/Qibei 21 | 祁西县 | 13 | Qixi | 3 | 1 | 0 | Hunan | /Hunan/Hengyang/Qixi - 13 | 衡阳市 | 2 | Hengyang | 3 | 0 | 0 | China | /China/Hunan/Hengyang 14 | 耒阳市 | 13 | Leiyang | 3 | 1 | 0 | Hunan | /Hunan/Hengyang/Leiyang 19 | 祁东县 | 13 | Qidong | 3 | 1 | 0 | Hunan | /Hunan/Hengyang/Qidong 18 | 常宁市 | 13 | Changning | 3 | 1 | 0 | Hunan | /Hunan/Hengyang/Changning 20 | 祁南县 | 13 | Qinan | 3 | 1 | 0 | Hunan | /Hunan/Hengyang/Qinan - 22 | 祁北县 | 13 | Qibei | 4 | 1 | 0 | China | /China/Hunan/Hengyang/Qibei - 12 | 南山区 | 10 | Nanshan | 4 | 1 | 0 | China | /China/Guangdong/Shenzhen/Nanshan - 21 | 祁西县 | 13 | Qixi | 4 | 1 | 0 | China | /China/Hunan/Hengyang/Qixi - 14 | 耒阳市 | 13 | Leiyang | 4 | 1 | 0 | China | /China/Hunan/Hengyang/Leiyang - 15 | 龙岗区 | 10 | Longgang | 4 | 1 | 0 | China | /China/Guangdong/Shenzhen/Longgang - 16 | 福田区 | 10 | Futian | 4 | 1 | 0 | China | /China/Guangdong/Shenzhen/Futian - 17 | 宝安区 | 10 | Baoan | 4 | 1 | 0 | China | /China/Guangdong/Shenzhen/Baoan - 19 | 祁东县 | 13 | Qidong | 4 | 1 | 0 | China | /China/Hunan/Hengyang/Qidong - 18 | 常宁市 | 13 | Changning | 4 | 1 | 0 | China | /China/Hunan/Hengyang/Changning - 20 | 祁南县 | 13 | Qinan | 4 | 1 | 0 | China | /China/Hunan/Hengyang/Qinan (31 rows) /* @@ -371,25 +371,25 @@ START WITH name IN (select name from test_area where id < 3) CONNECT BY PRIOR id = fatherid; id | name | fatherid | name_desc | level | connect_by_isleaf | connect_by_iscycle | connect_by_root | sys_connect_by_path ----+--------+----------+-----------+-------+-------------------+--------------------+-----------------+------------------------------------ - 10 | 深圳市 | 3 | Shenzhen | 3 | 0 | 0 | China | /China/Guangdong/Shenzhen 11 | 长沙市 | 2 | Changsha | 3 | 1 | 0 | China | /China/Hunan/Changsha + 13 | 衡阳市 | 2 | Hengyang | 3 | 0 | 0 | China | /China/Hunan/Hengyang + 22 | 祁北县 | 13 | Qibei | 4 | 1 | 0 | China | /China/Hunan/Hengyang/Qibei + 21 | 祁西县 | 13 | Qixi | 4 | 1 | 0 | China | /China/Hunan/Hengyang/Qixi + 14 | 耒阳市 | 13 | Leiyang | 4 | 1 | 0 | China | /China/Hunan/Hengyang/Leiyang + 19 | 祁东县 | 13 | Qidong | 4 | 1 | 0 | China | /China/Hunan/Hengyang/Qidong + 18 | 常宁市 | 13 | Changning | 4 | 1 | 0 | China | /China/Hunan/Hengyang/Changning + 20 | 祁南县 | 13 | Qinan | 4 | 1 | 0 | China | /China/Hunan/Hengyang/Qinan + 10 | 深圳市 | 3 | Shenzhen | 3 | 0 | 0 | China | /China/Guangdong/Shenzhen + 12 | 南山区 | 10 | Nanshan | 4 | 1 | 0 | China | /China/Guangdong/Shenzhen/Nanshan + 15 | 龙岗区 | 10 | Longgang | 4 | 1 | 0 | China | /China/Guangdong/Shenzhen/Longgang + 16 | 福田区 | 10 | Futian | 4 | 1 | 0 | China | /China/Guangdong/Shenzhen/Futian + 17 | 宝安区 | 10 | Baoan | 4 | 1 | 0 | China | /China/Guangdong/Shenzhen/Baoan 22 | 祁北县 | 13 | Qibei | 3 | 1 | 0 | Hunan | /Hunan/Hengyang/Qibei 21 | 祁西县 | 13 | Qixi | 3 | 1 | 0 | Hunan | /Hunan/Hengyang/Qixi - 13 | 衡阳市 | 2 | Hengyang | 3 | 0 | 0 | China | /China/Hunan/Hengyang 14 | 耒阳市 | 13 | Leiyang | 3 | 1 | 0 | Hunan | /Hunan/Hengyang/Leiyang 19 | 祁东县 | 13 | Qidong | 3 | 1 | 0 | Hunan | /Hunan/Hengyang/Qidong 18 | 常宁市 | 13 | Changning | 3 | 1 | 0 | Hunan | /Hunan/Hengyang/Changning 20 | 祁南县 | 13 | Qinan | 3 | 1 | 0 | Hunan | /Hunan/Hengyang/Qinan - 22 | 祁北县 | 13 | Qibei | 4 | 1 | 0 | China | /China/Hunan/Hengyang/Qibei - 12 | 南山区 | 10 | Nanshan | 4 | 1 | 0 | China | /China/Guangdong/Shenzhen/Nanshan - 21 | 祁西县 | 13 | Qixi | 4 | 1 | 0 | China | /China/Hunan/Hengyang/Qixi - 14 | 耒阳市 | 13 | Leiyang | 4 | 1 | 0 | China | /China/Hunan/Hengyang/Leiyang - 15 | 龙岗区 | 10 | Longgang | 4 | 1 | 0 | China | /China/Guangdong/Shenzhen/Longgang - 16 | 福田区 | 10 | Futian | 4 | 1 | 0 | China | /China/Guangdong/Shenzhen/Futian - 17 | 宝安区 | 10 | Baoan | 4 | 1 | 0 | China | /China/Guangdong/Shenzhen/Baoan - 19 | 祁东县 | 13 | Qidong | 4 | 1 | 0 | China | /China/Hunan/Hengyang/Qidong - 18 | 常宁市 | 13 | Changning | 4 | 1 | 0 | China | /China/Hunan/Hengyang/Changning - 20 | 祁南县 | 13 | Qinan | 4 | 1 | 0 | China | /China/Hunan/Hengyang/Qinan (19 rows) /* @@ -429,25 +429,25 @@ START WITH name IN (select name from test_area where id < 3) CONNECT BY PRIOR id = fatherid; id | name | fatherid | name_desc | level | connect_by_isleaf | connect_by_iscycle | connect_by_root | sys_connect_by_path ----+--------+----------+-----------+-------+-------------------+--------------------+-----------------+------------------------------------ - 10 | 深圳市 | 3 | Shenzhen | 3 | 0 | 0 | China | /China/Guangdong/Shenzhen 11 | 长沙市 | 2 | Changsha | 3 | 1 | 0 | China | /China/Hunan/Changsha + 13 | 衡阳市 | 2 | Hengyang | 3 | 0 | 0 | China | /China/Hunan/Hengyang + 22 | 祁北县 | 13 | Qibei | 4 | 1 | 0 | China | /China/Hunan/Hengyang/Qibei + 21 | 祁西县 | 13 | Qixi | 4 | 1 | 0 | China | /China/Hunan/Hengyang/Qixi + 14 | 耒阳市 | 13 | Leiyang | 4 | 1 | 0 | China | /China/Hunan/Hengyang/Leiyang + 19 | 祁东县 | 13 | Qidong | 4 | 1 | 0 | China | /China/Hunan/Hengyang/Qidong + 18 | 常宁市 | 13 | Changning | 4 | 1 | 0 | China | /China/Hunan/Hengyang/Changning + 20 | 祁南县 | 13 | Qinan | 4 | 1 | 0 | China | /China/Hunan/Hengyang/Qinan + 10 | 深圳市 | 3 | Shenzhen | 3 | 0 | 0 | China | /China/Guangdong/Shenzhen + 12 | 南山区 | 10 | Nanshan | 4 | 1 | 0 | China | /China/Guangdong/Shenzhen/Nanshan + 15 | 龙岗区 | 10 | Longgang | 4 | 1 | 0 | China | /China/Guangdong/Shenzhen/Longgang + 16 | 福田区 | 10 | Futian | 4 | 1 | 0 | China | /China/Guangdong/Shenzhen/Futian + 17 | 宝安区 | 10 | Baoan | 4 | 1 | 0 | China | /China/Guangdong/Shenzhen/Baoan 22 | 祁北县 | 13 | Qibei | 3 | 1 | 0 | Hunan | /Hunan/Hengyang/Qibei 21 | 祁西县 | 13 | Qixi | 3 | 1 | 0 | Hunan | /Hunan/Hengyang/Qixi - 13 | 衡阳市 | 2 | Hengyang | 3 | 0 | 0 | China | /China/Hunan/Hengyang 14 | 耒阳市 | 13 | Leiyang | 3 | 1 | 0 | Hunan | /Hunan/Hengyang/Leiyang 19 | 祁东县 | 13 | Qidong | 3 | 1 | 0 | Hunan | /Hunan/Hengyang/Qidong 18 | 常宁市 | 13 | Changning | 3 | 1 | 0 | Hunan | /Hunan/Hengyang/Changning 20 | 祁南县 | 13 | Qinan | 3 | 1 | 0 | Hunan | /Hunan/Hengyang/Qinan - 22 | 祁北县 | 13 | Qibei | 4 | 1 | 0 | China | /China/Hunan/Hengyang/Qibei - 12 | 南山区 | 10 | Nanshan | 4 | 1 | 0 | China | /China/Guangdong/Shenzhen/Nanshan - 21 | 祁西县 | 13 | Qixi | 4 | 1 | 0 | China | /China/Hunan/Hengyang/Qixi - 14 | 耒阳市 | 13 | Leiyang | 4 | 1 | 0 | China | /China/Hunan/Hengyang/Leiyang - 15 | 龙岗区 | 10 | Longgang | 4 | 1 | 0 | China | /China/Guangdong/Shenzhen/Longgang - 16 | 福田区 | 10 | Futian | 4 | 1 | 0 | China | /China/Guangdong/Shenzhen/Futian - 17 | 宝安区 | 10 | Baoan | 4 | 1 | 0 | China | /China/Guangdong/Shenzhen/Baoan - 19 | 祁东县 | 13 | Qidong | 4 | 1 | 0 | China | /China/Hunan/Hengyang/Qidong - 18 | 常宁市 | 13 | Changning | 4 | 1 | 0 | China | /China/Hunan/Hengyang/Changning - 20 | 祁南县 | 13 | Qinan | 4 | 1 | 0 | China | /China/Hunan/Hengyang/Qinan (19 rows) -- 三、 打开guc enable_startwith_debug = on测试 @@ -492,7 +492,10 @@ WARNING: Pushdown pseudo_tlist >>>>> [ -> WorkTableScan(tlist_len:12) -> Hash(t WARNING: Pushdown pseudo_tlist >>>>> [ -> CteScan(tlist_len:11)] LOG: StartWithDebug: LEVEL:1 array_key_1:/{13} LOG: StartWithDebug: LEVEL:2 array_key_1:/{13}/{2} +LOG: StartWithDebug: LEVEL:2 array_key_1:/{13}/{2} LOG: StartWithDebug: LEVEL:3 array_key_1:/{13}/{2}/{1} +LOG: StartWithDebug: LEVEL:3 array_key_1:/{13}/{2}/{1} +LOG: StartWithDebug: LEVEL:4 array_key_1:/{13}/{2}/{1}/{0} LOG: StartWithDebug: LEVEL:4 array_key_1:/{13}/{2}/{1}/{0} id | name | fatherid | name_desc | level | connect_by_root | cpath | RUITR | array_key_3 | array_col_2 | array_col_4 ----+--------+----------+-----------+-------+-----------------+----------------------------+-------+-------------------+----------------------------+------------------------------- @@ -515,30 +518,27 @@ order siblings by id; LOG: Accept a other Const val when evaluate FakeConst to rownum/level WARNING: Good we got siblings sort key under RU. WARNING: Good we got siblings sort key under RU. -WARNING: Good we got siblings sort key above RU. WARNING: Pushdown pseudo_tlist >>>>> [ -> WorkTableScan(tlist_len:13) -> Hash(tlist_len:13) -> HashJoin(tlist_len:13) -> Sort(tlist_len:13) -> RecursiveUnion(tlist_len:13)] WARNING: Pushdown pseudo_tlist >>>>> [ -> CteScan(tlist_len:12)] - QUERY PLAN ------------------------------------------------------------------------------------------------------- + QUERY PLAN +------------------------------------------------------------------------------------------------ CTE Scan on tmp_reuslt CTE tmp_reuslt -> StartWith Operator Start With pseudo atts: RUITR, array_key_1, array_col_2, array_col_4, array_siblings - -> Sort - Sort Key: array_siblings - -> Recursive Union - -> Sort - Sort Key: swtest.test_area.id + -> Recursive Union + -> Sort + Sort Key: swtest.test_area.id + -> Seq Scan on test_area + Filter: (name = '中国'::text) + -> Sort + Sort Key: swtest.test_area.id + -> Hash Join + Hash Cond: (swtest.test_area.fatherid = tmp_reuslt."test_area@id") -> Seq Scan on test_area - Filter: (name = '中国'::text) - -> Sort - Sort Key: swtest.test_area.id - -> Hash Join - Hash Cond: (swtest.test_area.fatherid = tmp_reuslt."test_area@id") - -> Seq Scan on test_area - -> Hash - -> WorkTable Scan on tmp_reuslt -(18 rows) + -> Hash + -> WorkTable Scan on tmp_reuslt +(16 rows) select *, LEVEL, CONNECT_BY_ROOT(name_desc), SYS_CONNECT_BY_PATH(name, '/') cpath from test_area START WITH name = '中国' @@ -551,7 +551,6 @@ order siblings by id; LOG: Accept a other Const val when evaluate FakeConst to rownum/level WARNING: Good we got siblings sort key under RU. WARNING: Good we got siblings sort key under RU. -WARNING: Good we got siblings sort key above RU. WARNING: Pushdown pseudo_tlist >>>>> [ -> WorkTableScan(tlist_len:13) -> Hash(tlist_len:13) -> HashJoin(tlist_len:13) -> Sort(tlist_len:13) -> RecursiveUnion(tlist_len:13)] WARNING: Pushdown pseudo_tlist >>>>> [ -> CteScan(tlist_len:12)] LOG: siblings key is \x01000000 current level is 1 tuple position is 1. @@ -559,69 +558,77 @@ LOG: StartWithDebug: LEVEL:1 array_key_1:/{1} LOG: siblings key is \x0100000001000000 current level is 2 tuple position is 1 LOG: StartWithDebug: LEVEL:2 array_key_1:/{1}/{2} LOG: siblings key is \x0100000002000000 current level is 2 tuple position is 2 -LOG: StartWithDebug: LEVEL:2 array_key_1:/{1}/{3} +LOG: StartWithDebug: LEVEL:2 array_key_1:/{1}/{2} LOG: siblings key is \x0100000003000000 current level is 2 tuple position is 3 -LOG: StartWithDebug: LEVEL:2 array_key_1:/{1}/{4} +LOG: StartWithDebug: LEVEL:2 array_key_1:/{1}/{3} LOG: siblings key is \x0100000004000000 current level is 2 tuple position is 4 -LOG: StartWithDebug: LEVEL:2 array_key_1:/{1}/{5} +LOG: StartWithDebug: LEVEL:2 array_key_1:/{1}/{4} LOG: siblings key is \x0100000005000000 current level is 2 tuple position is 5 -LOG: StartWithDebug: LEVEL:2 array_key_1:/{1}/{6} +LOG: StartWithDebug: LEVEL:2 array_key_1:/{1}/{5} LOG: siblings key is \x0100000006000000 current level is 2 tuple position is 6 -LOG: StartWithDebug: LEVEL:2 array_key_1:/{1}/{7} +LOG: StartWithDebug: LEVEL:2 array_key_1:/{1}/{6} LOG: siblings key is \x0100000007000000 current level is 2 tuple position is 7 -LOG: StartWithDebug: LEVEL:2 array_key_1:/{1}/{8} +LOG: StartWithDebug: LEVEL:2 array_key_1:/{1}/{7} LOG: siblings key is \x0100000008000000 current level is 2 tuple position is 8 +LOG: StartWithDebug: LEVEL:2 array_key_1:/{1}/{8} +LOG: siblings key is \x0100000009000000 current level is 2 tuple position is 9 LOG: StartWithDebug: LEVEL:2 array_key_1:/{1}/{9} -LOG: siblings key is \x010000000200000001000000 current level is 3 tuple position is 1 +LOG: siblings key is \x010000000300000001000000 current level is 3 tuple position is 1 LOG: StartWithDebug: LEVEL:3 array_key_1:/{1}/{3}/{10} -LOG: siblings key is \x010000000100000002000000 current level is 3 tuple position is 2 +LOG: siblings key is \x010000000200000002000000 current level is 3 tuple position is 2 LOG: StartWithDebug: LEVEL:3 array_key_1:/{1}/{2}/{11} -LOG: siblings key is \x010000000100000003000000 current level is 3 tuple position is 3 +LOG: siblings key is \x010000000200000003000000 current level is 3 tuple position is 3 LOG: StartWithDebug: LEVEL:3 array_key_1:/{1}/{2}/{13} -LOG: siblings key is \x01000000020000000100000001000000 current level is 4 tuple position is 1 -LOG: StartWithDebug: LEVEL:4 array_key_1:/{1}/{3}/{10}/{12} -LOG: siblings key is \x01000000010000000300000002000000 current level is 4 tuple position is 2 +LOG: siblings key is \x01000000020000000300000001000000 current level is 4 tuple position is 1 LOG: StartWithDebug: LEVEL:4 array_key_1:/{1}/{2}/{13}/{14} -LOG: siblings key is \x01000000020000000100000003000000 current level is 4 tuple position is 3 -LOG: StartWithDebug: LEVEL:4 array_key_1:/{1}/{3}/{10}/{15} -LOG: siblings key is \x01000000020000000100000004000000 current level is 4 tuple position is 4 -LOG: StartWithDebug: LEVEL:4 array_key_1:/{1}/{3}/{10}/{16} -LOG: siblings key is \x01000000020000000100000005000000 current level is 4 tuple position is 5 -LOG: StartWithDebug: LEVEL:4 array_key_1:/{1}/{3}/{10}/{17} -LOG: siblings key is \x01000000010000000300000006000000 current level is 4 tuple position is 6 +LOG: siblings key is \x01000000020000000300000002000000 current level is 4 tuple position is 2 +LOG: StartWithDebug: LEVEL:4 array_key_1:/{1}/{2}/{13}/{14} +LOG: siblings key is \x01000000020000000300000003000000 current level is 4 tuple position is 3 LOG: StartWithDebug: LEVEL:4 array_key_1:/{1}/{2}/{13}/{18} -LOG: siblings key is \x01000000010000000300000007000000 current level is 4 tuple position is 7 +LOG: siblings key is \x01000000020000000300000004000000 current level is 4 tuple position is 4 LOG: StartWithDebug: LEVEL:4 array_key_1:/{1}/{2}/{13}/{19} -LOG: siblings key is \x01000000010000000300000008000000 current level is 4 tuple position is 8 +LOG: siblings key is \x01000000020000000300000005000000 current level is 4 tuple position is 5 LOG: StartWithDebug: LEVEL:4 array_key_1:/{1}/{2}/{13}/{20} -LOG: siblings key is \x01000000010000000300000009000000 current level is 4 tuple position is 9 +LOG: siblings key is \x01000000020000000300000006000000 current level is 4 tuple position is 6 LOG: StartWithDebug: LEVEL:4 array_key_1:/{1}/{2}/{13}/{21} -LOG: siblings key is \x0100000001000000030000000a000000 current level is 4 tuple position is 10 +LOG: siblings key is \x01000000020000000300000007000000 current level is 4 tuple position is 7 LOG: StartWithDebug: LEVEL:4 array_key_1:/{1}/{2}/{13}/{22} +LOG: siblings key is \x010000000300000001000000 current level is 3 tuple position is 1 +LOG: StartWithDebug: LEVEL:3 array_key_1:/{1}/{3}/{10} +LOG: siblings key is \x01000000030000000100000001000000 current level is 4 tuple position is 1 +LOG: StartWithDebug: LEVEL:4 array_key_1:/{1}/{3}/{10}/{12} +LOG: siblings key is \x01000000030000000100000002000000 current level is 4 tuple position is 2 +LOG: StartWithDebug: LEVEL:4 array_key_1:/{1}/{3}/{10}/{12} +LOG: siblings key is \x01000000030000000100000003000000 current level is 4 tuple position is 3 +LOG: StartWithDebug: LEVEL:4 array_key_1:/{1}/{3}/{10}/{15} +LOG: siblings key is \x01000000030000000100000004000000 current level is 4 tuple position is 4 +LOG: StartWithDebug: LEVEL:4 array_key_1:/{1}/{3}/{10}/{16} +LOG: siblings key is \x01000000030000000100000005000000 current level is 4 tuple position is 5 +LOG: StartWithDebug: LEVEL:4 array_key_1:/{1}/{3}/{10}/{17} id | name | fatherid | name_desc | level | connect_by_root | cpath | RUITR | array_key_1 | array_col_2 | array_col_4 | array_siblings ----+--------+----------+-----------+-------+-----------------+----------------------------+-------+--------------------+----------------------------+------------------------------------+------------------------------------ 1 | 中国 | 0 | China | 1 | China | /中国 | 0 | /{1} | /中国 | /China | \x01000000 - 2 | 湖南省 | 1 | Hunan | 2 | China | /中国/湖南省 | 1 | /{1}/{2} | /中国/湖南省 | /China/Hunan | \x0100000001000000 - 11 | 长沙市 | 2 | Changsha | 3 | China | /中国/湖南省/长沙市 | 2 | /{1}/{2}/{11} | /中国/湖南省/长沙市 | /China/Hunan/Changsha | \x010000000100000002000000 - 13 | 衡阳市 | 2 | Hengyang | 3 | China | /中国/湖南省/衡阳市 | 2 | /{1}/{2}/{13} | /中国/湖南省/衡阳市 | /China/Hunan/Hengyang | \x010000000100000003000000 - 14 | 耒阳市 | 13 | Leiyang | 4 | China | /中国/湖南省/衡阳市/耒阳市 | 3 | /{1}/{2}/{13}/{14} | /中国/湖南省/衡阳市/耒阳市 | /China/Hunan/Hengyang/Leiyang | \x01000000010000000300000002000000 - 18 | 常宁市 | 13 | Changning | 4 | China | /中国/湖南省/衡阳市/常宁市 | 3 | /{1}/{2}/{13}/{18} | /中国/湖南省/衡阳市/常宁市 | /China/Hunan/Hengyang/Changning | \x01000000010000000300000006000000 - 19 | 祁东县 | 13 | Qidong | 4 | China | /中国/湖南省/衡阳市/祁东县 | 3 | /{1}/{2}/{13}/{19} | /中国/湖南省/衡阳市/祁东县 | /China/Hunan/Hengyang/Qidong | \x01000000010000000300000007000000 - 20 | 祁南县 | 13 | Qinan | 4 | China | /中国/湖南省/衡阳市/祁南县 | 3 | /{1}/{2}/{13}/{20} | /中国/湖南省/衡阳市/祁南县 | /China/Hunan/Hengyang/Qinan | \x01000000010000000300000008000000 - 21 | 祁西县 | 13 | Qixi | 4 | China | /中国/湖南省/衡阳市/祁西县 | 3 | /{1}/{2}/{13}/{21} | /中国/湖南省/衡阳市/祁西县 | /China/Hunan/Hengyang/Qixi | \x01000000010000000300000009000000 - 22 | 祁北县 | 13 | Qibei | 4 | China | /中国/湖南省/衡阳市/祁北县 | 3 | /{1}/{2}/{13}/{22} | /中国/湖南省/衡阳市/祁北县 | /China/Hunan/Hengyang/Qibei | \x0100000001000000030000000a000000 - 3 | 广东省 | 1 | Guangdong | 2 | China | /中国/广东省 | 1 | /{1}/{3} | /中国/广东省 | /China/Guangdong | \x0100000002000000 - 10 | 深圳市 | 3 | Shenzhen | 3 | China | /中国/广东省/深圳市 | 2 | /{1}/{3}/{10} | /中国/广东省/深圳市 | /China/Guangdong/Shenzhen | \x010000000200000001000000 - 12 | 南山区 | 10 | Nanshan | 4 | China | /中国/广东省/深圳市/南山区 | 3 | /{1}/{3}/{10}/{12} | /中国/广东省/深圳市/南山区 | /China/Guangdong/Shenzhen/Nanshan | \x01000000020000000100000001000000 - 15 | 龙岗区 | 10 | Longgang | 4 | China | /中国/广东省/深圳市/龙岗区 | 3 | /{1}/{3}/{10}/{15} | /中国/广东省/深圳市/龙岗区 | /China/Guangdong/Shenzhen/Longgang | \x01000000020000000100000003000000 - 16 | 福田区 | 10 | Futian | 4 | China | /中国/广东省/深圳市/福田区 | 3 | /{1}/{3}/{10}/{16} | /中国/广东省/深圳市/福田区 | /China/Guangdong/Shenzhen/Futian | \x01000000020000000100000004000000 - 17 | 宝安区 | 10 | Baoan | 4 | China | /中国/广东省/深圳市/宝安区 | 3 | /{1}/{3}/{10}/{17} | /中国/广东省/深圳市/宝安区 | /China/Guangdong/Shenzhen/Baoan | \x01000000020000000100000005000000 - 4 | 海南省 | 1 | Hainan | 2 | China | /中国/海南省 | 1 | /{1}/{4} | /中国/海南省 | /China/Hainan | \x0100000003000000 - 5 | 河北省 | 1 | Hebei | 2 | China | /中国/河北省 | 1 | /{1}/{5} | /中国/河北省 | /China/Hebei | \x0100000004000000 - 6 | 河南省 | 1 | Henan | 2 | China | /中国/河南省 | 1 | /{1}/{6} | /中国/河南省 | /China/Henan | \x0100000005000000 - 7 | 山东省 | 1 | Shandong | 2 | China | /中国/山东省 | 1 | /{1}/{7} | /中国/山东省 | /China/Shandong | \x0100000006000000 - 8 | 湖北省 | 1 | Hubei | 2 | China | /中国/湖北省 | 1 | /{1}/{8} | /中国/湖北省 | /China/Hubei | \x0100000007000000 - 9 | 江苏省 | 1 | Jiangsu | 2 | China | /中国/江苏省 | 1 | /{1}/{9} | /中国/江苏省 | /China/Jiangsu | \x0100000008000000 + 2 | 湖南省 | 1 | Hunan | 2 | China | /中国/湖南省 | 1 | /{1}/{2} | /中国/湖南省 | /China/Hunan | \x0100000002000000 + 11 | 长沙市 | 2 | Changsha | 3 | China | /中国/湖南省/长沙市 | 2 | /{1}/{2}/{11} | /中国/湖南省/长沙市 | /China/Hunan/Changsha | \x010000000200000002000000 + 13 | 衡阳市 | 2 | Hengyang | 3 | China | /中国/湖南省/衡阳市 | 2 | /{1}/{2}/{13} | /中国/湖南省/衡阳市 | /China/Hunan/Hengyang | \x010000000200000003000000 + 14 | 耒阳市 | 13 | Leiyang | 4 | China | /中国/湖南省/衡阳市/耒阳市 | 3 | /{1}/{2}/{13}/{14} | /中国/湖南省/衡阳市/耒阳市 | /China/Hunan/Hengyang/Leiyang | \x01000000020000000300000002000000 + 18 | 常宁市 | 13 | Changning | 4 | China | /中国/湖南省/衡阳市/常宁市 | 3 | /{1}/{2}/{13}/{18} | /中国/湖南省/衡阳市/常宁市 | /China/Hunan/Hengyang/Changning | \x01000000020000000300000003000000 + 19 | 祁东县 | 13 | Qidong | 4 | China | /中国/湖南省/衡阳市/祁东县 | 3 | /{1}/{2}/{13}/{19} | /中国/湖南省/衡阳市/祁东县 | /China/Hunan/Hengyang/Qidong | \x01000000020000000300000004000000 + 20 | 祁南县 | 13 | Qinan | 4 | China | /中国/湖南省/衡阳市/祁南县 | 3 | /{1}/{2}/{13}/{20} | /中国/湖南省/衡阳市/祁南县 | /China/Hunan/Hengyang/Qinan | \x01000000020000000300000005000000 + 21 | 祁西县 | 13 | Qixi | 4 | China | /中国/湖南省/衡阳市/祁西县 | 3 | /{1}/{2}/{13}/{21} | /中国/湖南省/衡阳市/祁西县 | /China/Hunan/Hengyang/Qixi | \x01000000020000000300000006000000 + 22 | 祁北县 | 13 | Qibei | 4 | China | /中国/湖南省/衡阳市/祁北县 | 3 | /{1}/{2}/{13}/{22} | /中国/湖南省/衡阳市/祁北县 | /China/Hunan/Hengyang/Qibei | \x01000000020000000300000007000000 + 3 | 广东省 | 1 | Guangdong | 2 | China | /中国/广东省 | 1 | /{1}/{3} | /中国/广东省 | /China/Guangdong | \x0100000003000000 + 10 | 深圳市 | 3 | Shenzhen | 3 | China | /中国/广东省/深圳市 | 2 | /{1}/{3}/{10} | /中国/广东省/深圳市 | /China/Guangdong/Shenzhen | \x010000000300000001000000 + 12 | 南山区 | 10 | Nanshan | 4 | China | /中国/广东省/深圳市/南山区 | 3 | /{1}/{3}/{10}/{12} | /中国/广东省/深圳市/南山区 | /China/Guangdong/Shenzhen/Nanshan | \x01000000030000000100000002000000 + 15 | 龙岗区 | 10 | Longgang | 4 | China | /中国/广东省/深圳市/龙岗区 | 3 | /{1}/{3}/{10}/{15} | /中国/广东省/深圳市/龙岗区 | /China/Guangdong/Shenzhen/Longgang | \x01000000030000000100000003000000 + 16 | 福田区 | 10 | Futian | 4 | China | /中国/广东省/深圳市/福田区 | 3 | /{1}/{3}/{10}/{16} | /中国/广东省/深圳市/福田区 | /China/Guangdong/Shenzhen/Futian | \x01000000030000000100000004000000 + 17 | 宝安区 | 10 | Baoan | 4 | China | /中国/广东省/深圳市/宝安区 | 3 | /{1}/{3}/{10}/{17} | /中国/广东省/深圳市/宝安区 | /China/Guangdong/Shenzhen/Baoan | \x01000000030000000100000005000000 + 4 | 海南省 | 1 | Hainan | 2 | China | /中国/海南省 | 1 | /{1}/{4} | /中国/海南省 | /China/Hainan | \x0100000004000000 + 5 | 河北省 | 1 | Hebei | 2 | China | /中国/河北省 | 1 | /{1}/{5} | /中国/河北省 | /China/Hebei | \x0100000005000000 + 6 | 河南省 | 1 | Henan | 2 | China | /中国/河南省 | 1 | /{1}/{6} | /中国/河南省 | /China/Henan | \x0100000006000000 + 7 | 山东省 | 1 | Shandong | 2 | China | /中国/山东省 | 1 | /{1}/{7} | /中国/山东省 | /China/Shandong | \x0100000007000000 + 8 | 湖北省 | 1 | Hubei | 2 | China | /中国/湖北省 | 1 | /{1}/{8} | /中国/湖北省 | /China/Hubei | \x0100000008000000 + 9 | 江苏省 | 1 | Jiangsu | 2 | China | /中国/江苏省 | 1 | /{1}/{9} | /中国/江苏省 | /China/Jiangsu | \x0100000009000000 (22 rows) reset enable_startwith_debug; @@ -649,11 +656,11 @@ select sys_connect_by_path(a, '@') from test_connect_sys start with x = 'A' conn --------------------- @ @ @ + @ @ @ + @ @ @ @ + @ @ @ @ @ @ @ @ @ - @ @ @ - @ @ @ @ - @ @ @ @ (7 rows) -- connect_by_root with blank value diff --git a/src/test/regress/expected/sw_bugfix-1.out b/src/test/regress/expected/sw_bugfix-1.out index aca15d099..140d38f83 100644 --- a/src/test/regress/expected/sw_bugfix-1.out +++ b/src/test/regress/expected/sw_bugfix-1.out @@ -107,50 +107,10 @@ select * from test_hcb_ptbc t1 start with t1.id = 11 connect by prior t1.id = t1 -----+------------+------+-----+--------------------------+----------+--------------------------+----------+-----+------------+------+------+--------------------------+----------+-------------------------- 11 | aa | aa | aa | Fri Jan 01 01:01:01 2021 | 01:01:01 | Fri Jan 01 01:01:01 2021 | 江苏省 | 1 | a | a | a | Sun Dec 12 12:12:12 2021 | 12:12:12 | Sun Dec 12 12:12:12 2021 111 | aaa | aaa | aaa | Fri Jan 01 01:01:10 2021 | 01:01:10 | Fri Jan 01 01:01:10 2021 | 南京市 | 11 | aa | aa | aa | Fri Jan 01 01:01:01 2021 | 01:01:01 | Fri Jan 01 01:01:01 2021 - 112 | aab | aab | aab | Fri Jan 01 01:01:11 2021 | 01:01:11 | Fri Jan 01 01:01:11 2021 | 宿迁市 | 11 | aa | aa | aa | Fri Jan 01 01:01:01 2021 | 01:01:01 | Fri Jan 01 01:01:01 2021 - 113 | aac | aac | aac | Fri Jan 01 01:01:12 2021 | 01:01:12 | Fri Jan 01 01:01:12 2021 | 徐州市 | 11 | aa | aa | aa | Fri Jan 01 01:01:01 2021 | 01:01:01 | Fri Jan 01 01:01:01 2021 - 114 | aad | aad | aad | Fri Jan 01 01:01:13 2021 | 01:01:13 | Fri Jan 01 01:01:13 2021 | 苏州市 | 11 | aa | aa | aa | Fri Jan 01 01:01:01 2021 | 01:01:01 | Fri Jan 01 01:01:01 2021 - 115 | aae | aae | aae | Fri Jan 01 01:01:14 2021 | 01:01:14 | Fri Jan 01 01:01:14 2021 | 盐城市 | 11 | aa | aa | aa | Fri Jan 01 01:01:01 2021 | 01:01:01 | Fri Jan 01 01:01:01 2021 - 117 | aag | aag | aag | Fri Jan 01 01:01:16 2021 | 01:01:16 | Fri Jan 01 01:01:16 2021 | 常州市 | 11 | aa | aa | aa | Fri Jan 01 01:01:01 2021 | 01:01:01 | Fri Jan 01 01:01:01 2021 - 116 | aaf | aaf | aaf | Fri Jan 01 01:01:15 2021 | 01:01:15 | Fri Jan 01 01:01:15 2021 | 无锡市 | 11 | aa | aa | aa | Fri Jan 01 01:01:01 2021 | 01:01:01 | Fri Jan 01 01:01:01 2021 - 118 | aah | aah | aah | Fri Jan 01 01:01:17 2021 | 01:01:17 | Fri Jan 01 01:01:17 2021 | 连云港 | 11 | aa | aa | aa | Fri Jan 01 01:01:01 2021 | 01:01:01 | Fri Jan 01 01:01:01 2021 - 119 | aai | aai | aai | Fri Jan 01 01:01:18 2021 | 01:01:18 | Fri Jan 01 01:01:18 2021 | 泰州市 | 11 | aa | aa | aa | Fri Jan 01 01:01:01 2021 | 01:01:01 | Fri Jan 01 01:01:01 2021 121 | aba | aba | aba | Fri Jan 01 01:01:20 2021 | 01:01:20 | Fri Jan 01 01:01:20 2021 | 江宁区 | 111 | aaa | aaa | aaa | Fri Jan 01 01:01:10 2021 | 01:01:10 | Fri Jan 01 01:01:10 2021 - 122 | abb | abb | abb | Fri Jan 01 01:01:21 2021 | 01:01:21 | Fri Jan 01 01:01:21 2021 | 雨花台 | 111 | aaa | aaa | aaa | Fri Jan 01 01:01:10 2021 | 01:01:10 | Fri Jan 01 01:01:10 2021 - 123 | abc | abc | abc | Fri Jan 01 01:01:22 2021 | 01:01:22 | Fri Jan 01 01:01:22 2021 | 鼓楼区 | 111 | aaa | aaa | aaa | Fri Jan 01 01:01:10 2021 | 01:01:10 | Fri Jan 01 01:01:10 2021 - 124 | abd | abd | abd | Fri Jan 01 01:01:23 2021 | 01:01:23 | Fri Jan 01 01:01:23 2021 | 玄武区 | 111 | aaa | aaa | aaa | Fri Jan 01 01:01:10 2021 | 01:01:10 | Fri Jan 01 01:01:10 2021 - 125 | abe | abe | abe | Fri Jan 01 01:01:24 2021 | 01:01:24 | Fri Jan 01 01:01:24 2021 | 建邺区 | 111 | aaa | aaa | aaa | Fri Jan 01 01:01:10 2021 | 01:01:10 | Fri Jan 01 01:01:10 2021 - 126 | abf | abf | abf | Fri Jan 01 01:01:25 2021 | 01:01:25 | Fri Jan 01 01:01:25 2021 | 秦淮区 | 111 | aaa | aaa | aaa | Fri Jan 01 01:01:10 2021 | 01:01:10 | Fri Jan 01 01:01:10 2021 - 127 | abg | abg | abg | Fri Jan 01 01:01:26 2021 | 01:01:26 | Fri Jan 01 01:01:26 2021 | 浦口区 | 111 | aaa | aaa | aaa | Fri Jan 01 01:01:10 2021 | 01:01:10 | Fri Jan 01 01:01:10 2021 - 128 | abh | abh | abh | Fri Jan 01 01:01:27 2021 | 01:01:27 | Fri Jan 01 01:01:27 2021 | 浦口区 | 111 | aaa | aaa | aaa | Fri Jan 01 01:01:10 2021 | 01:01:10 | Fri Jan 01 01:01:10 2021 - 129 | abi | abi | abi | Fri Jan 01 01:01:28 2021 | 01:01:28 | Fri Jan 01 01:01:28 2021 | 六合区 | 111 | aaa | aaa | aaa | Fri Jan 01 01:01:10 2021 | 01:01:10 | Fri Jan 01 01:01:10 2021 131 | aca | aca | aca | Fri Jan 01 01:01:30 2021 | 01:01:30 | Fri Jan 01 01:01:30 2021 | 东山街 | 121 | aba | aba | aba | Fri Jan 01 01:01:20 2021 | 01:01:20 | Fri Jan 01 01:01:20 2021 - 132 | acb | acb | acb | Fri Jan 01 01:01:31 2021 | 01:01:31 | Fri Jan 01 01:01:31 2021 | 秣陵街 | 121 | aba | aba | aba | Fri Jan 01 01:01:20 2021 | 01:01:20 | Fri Jan 01 01:01:20 2021 - 133 | acc | acc | acc | Fri Jan 01 01:01:32 2021 | 01:01:32 | Fri Jan 01 01:01:32 2021 | 汤山街 | 121 | aba | aba | aba | Fri Jan 01 01:01:20 2021 | 01:01:20 | Fri Jan 01 01:01:20 2021 - 135 | ace | ace | ace | Fri Jan 01 01:01:34 2021 | 01:01:34 | Fri Jan 01 01:01:34 2021 | 禄口街 | 121 | aba | aba | aba | Fri Jan 01 01:01:20 2021 | 01:01:20 | Fri Jan 01 01:01:20 2021 - 134 | acd | acd | acd | Fri Jan 01 01:01:33 2021 | 01:01:33 | Fri Jan 01 01:01:33 2021 | 淳化街 | 121 | aba | aba | aba | Fri Jan 01 01:01:20 2021 | 01:01:20 | Fri Jan 01 01:01:20 2021 - 136 | acf | acf | acf | Fri Jan 01 01:01:35 2021 | 01:01:35 | Fri Jan 01 01:01:35 2021 | 江宁街 | 121 | aba | aba | aba | Fri Jan 01 01:01:20 2021 | 01:01:20 | Fri Jan 01 01:01:20 2021 - 137 | acg | acg | acg | Fri Jan 01 01:01:36 2021 | 01:01:36 | Fri Jan 01 01:01:36 2021 | 谷里街 | 121 | aba | aba | aba | Fri Jan 01 01:01:20 2021 | 01:01:20 | Fri Jan 01 01:01:20 2021 - 138 | ach | ach | ach | Fri Jan 01 01:01:37 2021 | 01:01:37 | Fri Jan 01 01:01:37 2021 | 湖熟街 | 121 | aba | aba | aba | Fri Jan 01 01:01:20 2021 | 01:01:20 | Fri Jan 01 01:01:20 2021 - 139 | aci | aci | aci | Fri Jan 01 01:01:38 2021 | 01:01:38 | Fri Jan 01 01:01:38 2021 | 横溪街 | 121 | aba | aba | aba | Fri Jan 01 01:01:20 2021 | 01:01:20 | Fri Jan 01 01:01:20 2021 141 | ada | ada | ada | Fri Jan 01 01:01:40 2021 | 01:01:40 | Fri Jan 01 01:01:40 2021 | 江南摩卡 | 131 | aca | aca | aca | Fri Jan 01 01:01:30 2021 | 01:01:30 | Fri Jan 01 01:01:30 2021 - 142 | adb | adb | adb | Fri Jan 01 01:01:41 2021 | 01:01:41 | Fri Jan 01 01:01:41 2021 | 四季云顶 | 131 | aca | aca | aca | Fri Jan 01 01:01:30 2021 | 01:01:30 | Fri Jan 01 01:01:30 2021 - 143 | adc | adc | adc | Fri Jan 01 01:01:42 2021 | 01:01:42 | Fri Jan 01 01:01:42 2021 | 盛世江南 | 131 | aca | aca | aca | Fri Jan 01 01:01:30 2021 | 01:01:30 | Fri Jan 01 01:01:30 2021 - 144 | add | add | add | Fri Jan 01 01:01:43 2021 | 01:01:43 | Fri Jan 01 01:01:43 2021 | 七里香都 | 131 | aca | aca | aca | Fri Jan 01 01:01:30 2021 | 01:01:30 | Fri Jan 01 01:01:30 2021 - 145 | ade | ade | ade | Fri Jan 01 01:01:44 2021 | 01:01:44 | Fri Jan 01 01:01:44 2021 | 西山枫林 | 131 | aca | aca | aca | Fri Jan 01 01:01:30 2021 | 01:01:30 | Fri Jan 01 01:01:30 2021 - 146 | adf | adf | adf | Fri Jan 01 01:01:45 2021 | 01:01:45 | Fri Jan 01 01:01:45 2021 | 醉墨小镇 | 131 | aca | aca | aca | Fri Jan 01 01:01:30 2021 | 01:01:30 | Fri Jan 01 01:01:30 2021 - 147 | adg | adg | adg | Fri Jan 01 01:01:46 2021 | 01:01:46 | Fri Jan 01 01:01:46 2021 | 布拉格调 | 131 | aca | aca | aca | Fri Jan 01 01:01:30 2021 | 01:01:30 | Fri Jan 01 01:01:30 2021 - 148 | adh | adh | adh | Fri Jan 01 01:01:47 2021 | 01:01:47 | Fri Jan 01 01:01:47 2021 | 清幽别院 | 131 | aca | aca | aca | Fri Jan 01 01:01:30 2021 | 01:01:30 | Fri Jan 01 01:01:30 2021 - 149 | adi | adi | adi | Fri Jan 01 01:01:48 2021 | 01:01:48 | Fri Jan 01 01:01:48 2021 | 璀璨天城 | 131 | aca | aca | aca | Fri Jan 01 01:01:30 2021 | 01:01:30 | Fri Jan 01 01:01:30 2021 151 | aea | aea | aea | Fri Jan 01 01:01:50 2021 | 01:01:50 | Fri Jan 01 01:01:50 2021 | 江南一楼 | 141 | ada | ada | ada | Fri Jan 01 01:01:40 2021 | 01:01:40 | Fri Jan 01 01:01:40 2021 - 152 | aeb | aeb | aeb | Fri Jan 01 01:01:51 2021 | 01:01:51 | Fri Jan 01 01:01:51 2021 | 江南二楼 | 141 | ada | ada | ada | Fri Jan 01 01:01:40 2021 | 01:01:40 | Fri Jan 01 01:01:40 2021 - 153 | aec | aec | aec | Fri Jan 01 01:01:52 2021 | 01:01:52 | Fri Jan 01 01:01:52 2021 | 江南三楼 | 141 | ada | ada | ada | Fri Jan 01 01:01:40 2021 | 01:01:40 | Fri Jan 01 01:01:40 2021 - 154 | aed | aed | aed | Fri Jan 01 01:01:53 2021 | 01:01:53 | Fri Jan 01 01:01:53 2021 | 江南四楼 | 141 | ada | ada | ada | Fri Jan 01 01:01:40 2021 | 01:01:40 | Fri Jan 01 01:01:40 2021 - 155 | aee | aee | aee | Fri Jan 01 01:01:54 2021 | 01:01:54 | Fri Jan 01 01:01:54 2021 | 江南五楼 | 141 | ada | ada | ada | Fri Jan 01 01:01:40 2021 | 01:01:40 | Fri Jan 01 01:01:40 2021 - 156 | aef | aef | aef | Fri Jan 01 01:01:55 2021 | 01:01:55 | Fri Jan 01 01:01:55 2021 | 江南六楼 | 141 | ada | ada | ada | Fri Jan 01 01:01:40 2021 | 01:01:40 | Fri Jan 01 01:01:40 2021 - 157 | aeg | aeg | aeg | Fri Jan 01 01:01:56 2021 | 01:01:56 | Fri Jan 01 01:01:56 2021 | 江南七楼 | 141 | ada | ada | ada | Fri Jan 01 01:01:40 2021 | 01:01:40 | Fri Jan 01 01:01:40 2021 - 158 | aeh | aeh | aeh | Fri Jan 01 01:01:57 2021 | 01:01:57 | Fri Jan 01 01:01:57 2021 | 江南八楼 | 141 | ada | ada | ada | Fri Jan 01 01:01:40 2021 | 01:01:40 | Fri Jan 01 01:01:40 2021 - 159 | aei | aei | aei | Fri Jan 01 01:01:58 2021 | 01:01:58 | Fri Jan 01 01:01:58 2021 | 江南九楼 | 141 | ada | ada | ada | Fri Jan 01 01:01:40 2021 | 01:01:40 | Fri Jan 01 01:01:40 2021 161 | afa | afa | afa | Fri Jan 01 01:02:50 2021 | 01:02:50 | Fri Jan 01 01:02:50 2021 | 第一单元 | 151 | aea | aea | aea | Fri Jan 01 01:01:50 2021 | 01:01:50 | Fri Jan 01 01:01:50 2021 162 | afb | afb | afb | Fri Jan 01 01:02:51 2021 | 01:02:51 | Fri Jan 01 01:02:51 2021 | 第二单元 | 151 | aea | aea | aea | Fri Jan 01 01:01:50 2021 | 01:01:50 | Fri Jan 01 01:01:50 2021 163 | afc | afc | afc | Fri Jan 01 01:02:52 2021 | 01:02:52 | Fri Jan 01 01:02:52 2021 | 第三单元 | 151 | aea | aea | aea | Fri Jan 01 01:01:50 2021 | 01:01:50 | Fri Jan 01 01:01:50 2021 @@ -160,6 +120,46 @@ select * from test_hcb_ptbc t1 start with t1.id = 11 connect by prior t1.id = t1 167 | afg | afg | afg | Fri Jan 01 01:02:56 2021 | 01:02:56 | Fri Jan 01 01:02:56 2021 | 第七单元 | 151 | aea | aea | aea | Fri Jan 01 01:01:50 2021 | 01:01:50 | Fri Jan 01 01:01:50 2021 168 | afh | afh | afh | Fri Jan 01 01:02:57 2021 | 01:02:57 | Fri Jan 01 01:02:57 2021 | 第八单元 | 151 | aea | aea | aea | Fri Jan 01 01:01:50 2021 | 01:01:50 | Fri Jan 01 01:01:50 2021 169 | afi | afi | afi | Fri Jan 01 01:02:58 2021 | 01:02:58 | Fri Jan 01 01:02:58 2021 | 第九单元 | 151 | aea | aea | aea | Fri Jan 01 01:01:50 2021 | 01:01:50 | Fri Jan 01 01:01:50 2021 + 152 | aeb | aeb | aeb | Fri Jan 01 01:01:51 2021 | 01:01:51 | Fri Jan 01 01:01:51 2021 | 江南二楼 | 141 | ada | ada | ada | Fri Jan 01 01:01:40 2021 | 01:01:40 | Fri Jan 01 01:01:40 2021 + 153 | aec | aec | aec | Fri Jan 01 01:01:52 2021 | 01:01:52 | Fri Jan 01 01:01:52 2021 | 江南三楼 | 141 | ada | ada | ada | Fri Jan 01 01:01:40 2021 | 01:01:40 | Fri Jan 01 01:01:40 2021 + 154 | aed | aed | aed | Fri Jan 01 01:01:53 2021 | 01:01:53 | Fri Jan 01 01:01:53 2021 | 江南四楼 | 141 | ada | ada | ada | Fri Jan 01 01:01:40 2021 | 01:01:40 | Fri Jan 01 01:01:40 2021 + 155 | aee | aee | aee | Fri Jan 01 01:01:54 2021 | 01:01:54 | Fri Jan 01 01:01:54 2021 | 江南五楼 | 141 | ada | ada | ada | Fri Jan 01 01:01:40 2021 | 01:01:40 | Fri Jan 01 01:01:40 2021 + 156 | aef | aef | aef | Fri Jan 01 01:01:55 2021 | 01:01:55 | Fri Jan 01 01:01:55 2021 | 江南六楼 | 141 | ada | ada | ada | Fri Jan 01 01:01:40 2021 | 01:01:40 | Fri Jan 01 01:01:40 2021 + 157 | aeg | aeg | aeg | Fri Jan 01 01:01:56 2021 | 01:01:56 | Fri Jan 01 01:01:56 2021 | 江南七楼 | 141 | ada | ada | ada | Fri Jan 01 01:01:40 2021 | 01:01:40 | Fri Jan 01 01:01:40 2021 + 158 | aeh | aeh | aeh | Fri Jan 01 01:01:57 2021 | 01:01:57 | Fri Jan 01 01:01:57 2021 | 江南八楼 | 141 | ada | ada | ada | Fri Jan 01 01:01:40 2021 | 01:01:40 | Fri Jan 01 01:01:40 2021 + 159 | aei | aei | aei | Fri Jan 01 01:01:58 2021 | 01:01:58 | Fri Jan 01 01:01:58 2021 | 江南九楼 | 141 | ada | ada | ada | Fri Jan 01 01:01:40 2021 | 01:01:40 | Fri Jan 01 01:01:40 2021 + 142 | adb | adb | adb | Fri Jan 01 01:01:41 2021 | 01:01:41 | Fri Jan 01 01:01:41 2021 | 四季云顶 | 131 | aca | aca | aca | Fri Jan 01 01:01:30 2021 | 01:01:30 | Fri Jan 01 01:01:30 2021 + 143 | adc | adc | adc | Fri Jan 01 01:01:42 2021 | 01:01:42 | Fri Jan 01 01:01:42 2021 | 盛世江南 | 131 | aca | aca | aca | Fri Jan 01 01:01:30 2021 | 01:01:30 | Fri Jan 01 01:01:30 2021 + 144 | add | add | add | Fri Jan 01 01:01:43 2021 | 01:01:43 | Fri Jan 01 01:01:43 2021 | 七里香都 | 131 | aca | aca | aca | Fri Jan 01 01:01:30 2021 | 01:01:30 | Fri Jan 01 01:01:30 2021 + 145 | ade | ade | ade | Fri Jan 01 01:01:44 2021 | 01:01:44 | Fri Jan 01 01:01:44 2021 | 西山枫林 | 131 | aca | aca | aca | Fri Jan 01 01:01:30 2021 | 01:01:30 | Fri Jan 01 01:01:30 2021 + 146 | adf | adf | adf | Fri Jan 01 01:01:45 2021 | 01:01:45 | Fri Jan 01 01:01:45 2021 | 醉墨小镇 | 131 | aca | aca | aca | Fri Jan 01 01:01:30 2021 | 01:01:30 | Fri Jan 01 01:01:30 2021 + 147 | adg | adg | adg | Fri Jan 01 01:01:46 2021 | 01:01:46 | Fri Jan 01 01:01:46 2021 | 布拉格调 | 131 | aca | aca | aca | Fri Jan 01 01:01:30 2021 | 01:01:30 | Fri Jan 01 01:01:30 2021 + 148 | adh | adh | adh | Fri Jan 01 01:01:47 2021 | 01:01:47 | Fri Jan 01 01:01:47 2021 | 清幽别院 | 131 | aca | aca | aca | Fri Jan 01 01:01:30 2021 | 01:01:30 | Fri Jan 01 01:01:30 2021 + 149 | adi | adi | adi | Fri Jan 01 01:01:48 2021 | 01:01:48 | Fri Jan 01 01:01:48 2021 | 璀璨天城 | 131 | aca | aca | aca | Fri Jan 01 01:01:30 2021 | 01:01:30 | Fri Jan 01 01:01:30 2021 + 132 | acb | acb | acb | Fri Jan 01 01:01:31 2021 | 01:01:31 | Fri Jan 01 01:01:31 2021 | 秣陵街 | 121 | aba | aba | aba | Fri Jan 01 01:01:20 2021 | 01:01:20 | Fri Jan 01 01:01:20 2021 + 133 | acc | acc | acc | Fri Jan 01 01:01:32 2021 | 01:01:32 | Fri Jan 01 01:01:32 2021 | 汤山街 | 121 | aba | aba | aba | Fri Jan 01 01:01:20 2021 | 01:01:20 | Fri Jan 01 01:01:20 2021 + 135 | ace | ace | ace | Fri Jan 01 01:01:34 2021 | 01:01:34 | Fri Jan 01 01:01:34 2021 | 禄口街 | 121 | aba | aba | aba | Fri Jan 01 01:01:20 2021 | 01:01:20 | Fri Jan 01 01:01:20 2021 + 134 | acd | acd | acd | Fri Jan 01 01:01:33 2021 | 01:01:33 | Fri Jan 01 01:01:33 2021 | 淳化街 | 121 | aba | aba | aba | Fri Jan 01 01:01:20 2021 | 01:01:20 | Fri Jan 01 01:01:20 2021 + 136 | acf | acf | acf | Fri Jan 01 01:01:35 2021 | 01:01:35 | Fri Jan 01 01:01:35 2021 | 江宁街 | 121 | aba | aba | aba | Fri Jan 01 01:01:20 2021 | 01:01:20 | Fri Jan 01 01:01:20 2021 + 137 | acg | acg | acg | Fri Jan 01 01:01:36 2021 | 01:01:36 | Fri Jan 01 01:01:36 2021 | 谷里街 | 121 | aba | aba | aba | Fri Jan 01 01:01:20 2021 | 01:01:20 | Fri Jan 01 01:01:20 2021 + 138 | ach | ach | ach | Fri Jan 01 01:01:37 2021 | 01:01:37 | Fri Jan 01 01:01:37 2021 | 湖熟街 | 121 | aba | aba | aba | Fri Jan 01 01:01:20 2021 | 01:01:20 | Fri Jan 01 01:01:20 2021 + 139 | aci | aci | aci | Fri Jan 01 01:01:38 2021 | 01:01:38 | Fri Jan 01 01:01:38 2021 | 横溪街 | 121 | aba | aba | aba | Fri Jan 01 01:01:20 2021 | 01:01:20 | Fri Jan 01 01:01:20 2021 + 122 | abb | abb | abb | Fri Jan 01 01:01:21 2021 | 01:01:21 | Fri Jan 01 01:01:21 2021 | 雨花台 | 111 | aaa | aaa | aaa | Fri Jan 01 01:01:10 2021 | 01:01:10 | Fri Jan 01 01:01:10 2021 + 123 | abc | abc | abc | Fri Jan 01 01:01:22 2021 | 01:01:22 | Fri Jan 01 01:01:22 2021 | 鼓楼区 | 111 | aaa | aaa | aaa | Fri Jan 01 01:01:10 2021 | 01:01:10 | Fri Jan 01 01:01:10 2021 + 124 | abd | abd | abd | Fri Jan 01 01:01:23 2021 | 01:01:23 | Fri Jan 01 01:01:23 2021 | 玄武区 | 111 | aaa | aaa | aaa | Fri Jan 01 01:01:10 2021 | 01:01:10 | Fri Jan 01 01:01:10 2021 + 125 | abe | abe | abe | Fri Jan 01 01:01:24 2021 | 01:01:24 | Fri Jan 01 01:01:24 2021 | 建邺区 | 111 | aaa | aaa | aaa | Fri Jan 01 01:01:10 2021 | 01:01:10 | Fri Jan 01 01:01:10 2021 + 126 | abf | abf | abf | Fri Jan 01 01:01:25 2021 | 01:01:25 | Fri Jan 01 01:01:25 2021 | 秦淮区 | 111 | aaa | aaa | aaa | Fri Jan 01 01:01:10 2021 | 01:01:10 | Fri Jan 01 01:01:10 2021 + 127 | abg | abg | abg | Fri Jan 01 01:01:26 2021 | 01:01:26 | Fri Jan 01 01:01:26 2021 | 浦口区 | 111 | aaa | aaa | aaa | Fri Jan 01 01:01:10 2021 | 01:01:10 | Fri Jan 01 01:01:10 2021 + 128 | abh | abh | abh | Fri Jan 01 01:01:27 2021 | 01:01:27 | Fri Jan 01 01:01:27 2021 | 浦口区 | 111 | aaa | aaa | aaa | Fri Jan 01 01:01:10 2021 | 01:01:10 | Fri Jan 01 01:01:10 2021 + 129 | abi | abi | abi | Fri Jan 01 01:01:28 2021 | 01:01:28 | Fri Jan 01 01:01:28 2021 | 六合区 | 111 | aaa | aaa | aaa | Fri Jan 01 01:01:10 2021 | 01:01:10 | Fri Jan 01 01:01:10 2021 + 112 | aab | aab | aab | Fri Jan 01 01:01:11 2021 | 01:01:11 | Fri Jan 01 01:01:11 2021 | 宿迁市 | 11 | aa | aa | aa | Fri Jan 01 01:01:01 2021 | 01:01:01 | Fri Jan 01 01:01:01 2021 + 113 | aac | aac | aac | Fri Jan 01 01:01:12 2021 | 01:01:12 | Fri Jan 01 01:01:12 2021 | 徐州市 | 11 | aa | aa | aa | Fri Jan 01 01:01:01 2021 | 01:01:01 | Fri Jan 01 01:01:01 2021 + 114 | aad | aad | aad | Fri Jan 01 01:01:13 2021 | 01:01:13 | Fri Jan 01 01:01:13 2021 | 苏州市 | 11 | aa | aa | aa | Fri Jan 01 01:01:01 2021 | 01:01:01 | Fri Jan 01 01:01:01 2021 + 115 | aae | aae | aae | Fri Jan 01 01:01:14 2021 | 01:01:14 | Fri Jan 01 01:01:14 2021 | 盐城市 | 11 | aa | aa | aa | Fri Jan 01 01:01:01 2021 | 01:01:01 | Fri Jan 01 01:01:01 2021 + 117 | aag | aag | aag | Fri Jan 01 01:01:16 2021 | 01:01:16 | Fri Jan 01 01:01:16 2021 | 常州市 | 11 | aa | aa | aa | Fri Jan 01 01:01:01 2021 | 01:01:01 | Fri Jan 01 01:01:01 2021 + 116 | aaf | aaf | aaf | Fri Jan 01 01:01:15 2021 | 01:01:15 | Fri Jan 01 01:01:15 2021 | 无锡市 | 11 | aa | aa | aa | Fri Jan 01 01:01:01 2021 | 01:01:01 | Fri Jan 01 01:01:01 2021 + 118 | aah | aah | aah | Fri Jan 01 01:01:17 2021 | 01:01:17 | Fri Jan 01 01:01:17 2021 | 连云港 | 11 | aa | aa | aa | Fri Jan 01 01:01:01 2021 | 01:01:01 | Fri Jan 01 01:01:01 2021 + 119 | aai | aai | aai | Fri Jan 01 01:01:18 2021 | 01:01:18 | Fri Jan 01 01:01:18 2021 | 泰州市 | 11 | aa | aa | aa | Fri Jan 01 01:01:01 2021 | 01:01:01 | Fri Jan 01 01:01:01 2021 (55 rows) SELECT t1.id,t1.pid,t1.name,level FROM test_hcb_ptb t1,test_hcb_ptb t2 WHERE t1.id=t2.id START WITH t1.id=141 CONNECT BY PRIOR t1.id=t1.pid FOR UPDATE OF t2 NOWAIT; @@ -178,50 +178,10 @@ select pid x,id,CONNECT_BY_ROOT ID from test_hcb_ptbc t1 start with id = 11 conn -----+-----+------------------- 1 | 11 | 11 11 | 111 | 11 - 11 | 112 | 11 - 11 | 113 | 11 - 11 | 114 | 11 - 11 | 115 | 11 - 11 | 117 | 11 - 11 | 116 | 11 - 11 | 118 | 11 - 11 | 119 | 11 111 | 121 | 11 - 111 | 122 | 11 - 111 | 123 | 11 - 111 | 124 | 11 - 111 | 125 | 11 - 111 | 126 | 11 - 111 | 127 | 11 - 111 | 128 | 11 - 111 | 129 | 11 121 | 131 | 11 - 121 | 132 | 11 - 121 | 133 | 11 - 121 | 135 | 11 - 121 | 134 | 11 - 121 | 136 | 11 - 121 | 137 | 11 - 121 | 138 | 11 - 121 | 139 | 11 131 | 141 | 11 - 131 | 142 | 11 - 131 | 143 | 11 - 131 | 144 | 11 - 131 | 145 | 11 - 131 | 146 | 11 - 131 | 147 | 11 - 131 | 148 | 11 - 131 | 149 | 11 141 | 151 | 11 - 141 | 152 | 11 - 141 | 153 | 11 - 141 | 154 | 11 - 141 | 155 | 11 - 141 | 156 | 11 - 141 | 157 | 11 - 141 | 158 | 11 - 141 | 159 | 11 151 | 161 | 11 151 | 162 | 11 151 | 163 | 11 @@ -231,6 +191,46 @@ select pid x,id,CONNECT_BY_ROOT ID from test_hcb_ptbc t1 start with id = 11 conn 151 | 167 | 11 151 | 168 | 11 151 | 169 | 11 + 141 | 152 | 11 + 141 | 153 | 11 + 141 | 154 | 11 + 141 | 155 | 11 + 141 | 156 | 11 + 141 | 157 | 11 + 141 | 158 | 11 + 141 | 159 | 11 + 131 | 142 | 11 + 131 | 143 | 11 + 131 | 144 | 11 + 131 | 145 | 11 + 131 | 146 | 11 + 131 | 147 | 11 + 131 | 148 | 11 + 131 | 149 | 11 + 121 | 132 | 11 + 121 | 133 | 11 + 121 | 135 | 11 + 121 | 134 | 11 + 121 | 136 | 11 + 121 | 137 | 11 + 121 | 138 | 11 + 121 | 139 | 11 + 111 | 122 | 11 + 111 | 123 | 11 + 111 | 124 | 11 + 111 | 125 | 11 + 111 | 126 | 11 + 111 | 127 | 11 + 111 | 128 | 11 + 111 | 129 | 11 + 11 | 112 | 11 + 11 | 113 | 11 + 11 | 114 | 11 + 11 | 115 | 11 + 11 | 117 | 11 + 11 | 116 | 11 + 11 | 118 | 11 + 11 | 119 | 11 (55 rows) select pid x,id,CONNECT_BY_ROOT ID alias_id from test_hcb_ptbc t1 start with id = 11 connect by prior id = pid; @@ -238,50 +238,10 @@ select pid x,id,CONNECT_BY_ROOT ID alias_id from test_hcb_ptbc t1 start with id -----+-----+---------- 1 | 11 | 11 11 | 111 | 11 - 11 | 112 | 11 - 11 | 113 | 11 - 11 | 114 | 11 - 11 | 115 | 11 - 11 | 117 | 11 - 11 | 116 | 11 - 11 | 118 | 11 - 11 | 119 | 11 111 | 121 | 11 - 111 | 122 | 11 - 111 | 123 | 11 - 111 | 124 | 11 - 111 | 125 | 11 - 111 | 126 | 11 - 111 | 127 | 11 - 111 | 128 | 11 - 111 | 129 | 11 121 | 131 | 11 - 121 | 132 | 11 - 121 | 133 | 11 - 121 | 135 | 11 - 121 | 134 | 11 - 121 | 136 | 11 - 121 | 137 | 11 - 121 | 138 | 11 - 121 | 139 | 11 131 | 141 | 11 - 131 | 142 | 11 - 131 | 143 | 11 - 131 | 144 | 11 - 131 | 145 | 11 - 131 | 146 | 11 - 131 | 147 | 11 - 131 | 148 | 11 - 131 | 149 | 11 141 | 151 | 11 - 141 | 152 | 11 - 141 | 153 | 11 - 141 | 154 | 11 - 141 | 155 | 11 - 141 | 156 | 11 - 141 | 157 | 11 - 141 | 158 | 11 - 141 | 159 | 11 151 | 161 | 11 151 | 162 | 11 151 | 163 | 11 @@ -291,6 +251,46 @@ select pid x,id,CONNECT_BY_ROOT ID alias_id from test_hcb_ptbc t1 start with id 151 | 167 | 11 151 | 168 | 11 151 | 169 | 11 + 141 | 152 | 11 + 141 | 153 | 11 + 141 | 154 | 11 + 141 | 155 | 11 + 141 | 156 | 11 + 141 | 157 | 11 + 141 | 158 | 11 + 141 | 159 | 11 + 131 | 142 | 11 + 131 | 143 | 11 + 131 | 144 | 11 + 131 | 145 | 11 + 131 | 146 | 11 + 131 | 147 | 11 + 131 | 148 | 11 + 131 | 149 | 11 + 121 | 132 | 11 + 121 | 133 | 11 + 121 | 135 | 11 + 121 | 134 | 11 + 121 | 136 | 11 + 121 | 137 | 11 + 121 | 138 | 11 + 121 | 139 | 11 + 111 | 122 | 11 + 111 | 123 | 11 + 111 | 124 | 11 + 111 | 125 | 11 + 111 | 126 | 11 + 111 | 127 | 11 + 111 | 128 | 11 + 111 | 129 | 11 + 11 | 112 | 11 + 11 | 113 | 11 + 11 | 114 | 11 + 11 | 115 | 11 + 11 | 117 | 11 + 11 | 116 | 11 + 11 | 118 | 11 + 11 | 119 | 11 (55 rows) select pid x,id,CONNECT_BY_ROOT t1.ID from test_hcb_ptbc t1 start with id = 11 connect by prior id = pid; @@ -298,50 +298,10 @@ select pid x,id,CONNECT_BY_ROOT t1.ID from test_hcb_ptbc t1 start with id = 11 c -----+-----+---------------------- 1 | 11 | 11 11 | 111 | 11 - 11 | 112 | 11 - 11 | 113 | 11 - 11 | 114 | 11 - 11 | 115 | 11 - 11 | 117 | 11 - 11 | 116 | 11 - 11 | 118 | 11 - 11 | 119 | 11 111 | 121 | 11 - 111 | 122 | 11 - 111 | 123 | 11 - 111 | 124 | 11 - 111 | 125 | 11 - 111 | 126 | 11 - 111 | 127 | 11 - 111 | 128 | 11 - 111 | 129 | 11 121 | 131 | 11 - 121 | 132 | 11 - 121 | 133 | 11 - 121 | 135 | 11 - 121 | 134 | 11 - 121 | 136 | 11 - 121 | 137 | 11 - 121 | 138 | 11 - 121 | 139 | 11 131 | 141 | 11 - 131 | 142 | 11 - 131 | 143 | 11 - 131 | 144 | 11 - 131 | 145 | 11 - 131 | 146 | 11 - 131 | 147 | 11 - 131 | 148 | 11 - 131 | 149 | 11 141 | 151 | 11 - 141 | 152 | 11 - 141 | 153 | 11 - 141 | 154 | 11 - 141 | 155 | 11 - 141 | 156 | 11 - 141 | 157 | 11 - 141 | 158 | 11 - 141 | 159 | 11 151 | 161 | 11 151 | 162 | 11 151 | 163 | 11 @@ -351,6 +311,46 @@ select pid x,id,CONNECT_BY_ROOT t1.ID from test_hcb_ptbc t1 start with id = 11 c 151 | 167 | 11 151 | 168 | 11 151 | 169 | 11 + 141 | 152 | 11 + 141 | 153 | 11 + 141 | 154 | 11 + 141 | 155 | 11 + 141 | 156 | 11 + 141 | 157 | 11 + 141 | 158 | 11 + 141 | 159 | 11 + 131 | 142 | 11 + 131 | 143 | 11 + 131 | 144 | 11 + 131 | 145 | 11 + 131 | 146 | 11 + 131 | 147 | 11 + 131 | 148 | 11 + 131 | 149 | 11 + 121 | 132 | 11 + 121 | 133 | 11 + 121 | 135 | 11 + 121 | 134 | 11 + 121 | 136 | 11 + 121 | 137 | 11 + 121 | 138 | 11 + 121 | 139 | 11 + 111 | 122 | 11 + 111 | 123 | 11 + 111 | 124 | 11 + 111 | 125 | 11 + 111 | 126 | 11 + 111 | 127 | 11 + 111 | 128 | 11 + 111 | 129 | 11 + 11 | 112 | 11 + 11 | 113 | 11 + 11 | 114 | 11 + 11 | 115 | 11 + 11 | 117 | 11 + 11 | 116 | 11 + 11 | 118 | 11 + 11 | 119 | 11 (55 rows) select pid x,id,CONNECT_BY_ROOT t1.ID alias_id from test_hcb_ptbc t1 start with id = 11 connect by prior id = pid; @@ -358,50 +358,10 @@ select pid x,id,CONNECT_BY_ROOT t1.ID alias_id from test_hcb_ptbc t1 start with -----+-----+---------- 1 | 11 | 11 11 | 111 | 11 - 11 | 112 | 11 - 11 | 113 | 11 - 11 | 114 | 11 - 11 | 115 | 11 - 11 | 117 | 11 - 11 | 116 | 11 - 11 | 118 | 11 - 11 | 119 | 11 111 | 121 | 11 - 111 | 122 | 11 - 111 | 123 | 11 - 111 | 124 | 11 - 111 | 125 | 11 - 111 | 126 | 11 - 111 | 127 | 11 - 111 | 128 | 11 - 111 | 129 | 11 121 | 131 | 11 - 121 | 132 | 11 - 121 | 133 | 11 - 121 | 135 | 11 - 121 | 134 | 11 - 121 | 136 | 11 - 121 | 137 | 11 - 121 | 138 | 11 - 121 | 139 | 11 131 | 141 | 11 - 131 | 142 | 11 - 131 | 143 | 11 - 131 | 144 | 11 - 131 | 145 | 11 - 131 | 146 | 11 - 131 | 147 | 11 - 131 | 148 | 11 - 131 | 149 | 11 141 | 151 | 11 - 141 | 152 | 11 - 141 | 153 | 11 - 141 | 154 | 11 - 141 | 155 | 11 - 141 | 156 | 11 - 141 | 157 | 11 - 141 | 158 | 11 - 141 | 159 | 11 151 | 161 | 11 151 | 162 | 11 151 | 163 | 11 @@ -411,6 +371,46 @@ select pid x,id,CONNECT_BY_ROOT t1.ID alias_id from test_hcb_ptbc t1 start with 151 | 167 | 11 151 | 168 | 11 151 | 169 | 11 + 141 | 152 | 11 + 141 | 153 | 11 + 141 | 154 | 11 + 141 | 155 | 11 + 141 | 156 | 11 + 141 | 157 | 11 + 141 | 158 | 11 + 141 | 159 | 11 + 131 | 142 | 11 + 131 | 143 | 11 + 131 | 144 | 11 + 131 | 145 | 11 + 131 | 146 | 11 + 131 | 147 | 11 + 131 | 148 | 11 + 131 | 149 | 11 + 121 | 132 | 11 + 121 | 133 | 11 + 121 | 135 | 11 + 121 | 134 | 11 + 121 | 136 | 11 + 121 | 137 | 11 + 121 | 138 | 11 + 121 | 139 | 11 + 111 | 122 | 11 + 111 | 123 | 11 + 111 | 124 | 11 + 111 | 125 | 11 + 111 | 126 | 11 + 111 | 127 | 11 + 111 | 128 | 11 + 111 | 129 | 11 + 11 | 112 | 11 + 11 | 113 | 11 + 11 | 114 | 11 + 11 | 115 | 11 + 11 | 117 | 11 + 11 | 116 | 11 + 11 | 118 | 11 + 11 | 119 | 11 (55 rows) /* connect by union */ @@ -908,14 +908,6 @@ select t1.id,t1.pid,LEVEL,sys_connect_by_path(null, '->') pa, t1.name from test_ -----+-----+-------+--------------------+---------- 141 | 131 | 1 | ->null | 江南摩卡 151 | 141 | 2 | ->null->null | 江南一楼 - 152 | 141 | 2 | ->null->null | 江南二楼 - 153 | 141 | 2 | ->null->null | 江南三楼 - 154 | 141 | 2 | ->null->null | 江南四楼 - 155 | 141 | 2 | ->null->null | 江南五楼 - 156 | 141 | 2 | ->null->null | 江南六楼 - 157 | 141 | 2 | ->null->null | 江南七楼 - 158 | 141 | 2 | ->null->null | 江南八楼 - 159 | 141 | 2 | ->null->null | 江南九楼 161 | 151 | 3 | ->null->null->null | 第一单元 162 | 151 | 3 | ->null->null->null | 第二单元 163 | 151 | 3 | ->null->null->null | 第三单元 @@ -925,6 +917,14 @@ select t1.id,t1.pid,LEVEL,sys_connect_by_path(null, '->') pa, t1.name from test_ 167 | 151 | 3 | ->null->null->null | 第七单元 168 | 151 | 3 | ->null->null->null | 第八单元 169 | 151 | 3 | ->null->null->null | 第九单元 + 152 | 141 | 2 | ->null->null | 江南二楼 + 153 | 141 | 2 | ->null->null | 江南三楼 + 154 | 141 | 2 | ->null->null | 江南四楼 + 155 | 141 | 2 | ->null->null | 江南五楼 + 156 | 141 | 2 | ->null->null | 江南六楼 + 157 | 141 | 2 | ->null->null | 江南七楼 + 158 | 141 | 2 | ->null->null | 江南八楼 + 159 | 141 | 2 | ->null->null | 江南九楼 (19 rows) select t1.id,t1.pid,LEVEL,sys_connect_by_path('id', '->') pa, t1.name from test_hcb_ptb t1 start with id = 141 connect by prior id = pid; @@ -932,14 +932,6 @@ select t1.id,t1.pid,LEVEL,sys_connect_by_path('id', '->') pa, t1.name from test_ -----+-----+-------+--------------+---------- 141 | 131 | 1 | ->id | 江南摩卡 151 | 141 | 2 | ->id->id | 江南一楼 - 152 | 141 | 2 | ->id->id | 江南二楼 - 153 | 141 | 2 | ->id->id | 江南三楼 - 154 | 141 | 2 | ->id->id | 江南四楼 - 155 | 141 | 2 | ->id->id | 江南五楼 - 156 | 141 | 2 | ->id->id | 江南六楼 - 157 | 141 | 2 | ->id->id | 江南七楼 - 158 | 141 | 2 | ->id->id | 江南八楼 - 159 | 141 | 2 | ->id->id | 江南九楼 161 | 151 | 3 | ->id->id->id | 第一单元 162 | 151 | 3 | ->id->id->id | 第二单元 163 | 151 | 3 | ->id->id->id | 第三单元 @@ -949,6 +941,14 @@ select t1.id,t1.pid,LEVEL,sys_connect_by_path('id', '->') pa, t1.name from test_ 167 | 151 | 3 | ->id->id->id | 第七单元 168 | 151 | 3 | ->id->id->id | 第八单元 169 | 151 | 3 | ->id->id->id | 第九单元 + 152 | 141 | 2 | ->id->id | 江南二楼 + 153 | 141 | 2 | ->id->id | 江南三楼 + 154 | 141 | 2 | ->id->id | 江南四楼 + 155 | 141 | 2 | ->id->id | 江南五楼 + 156 | 141 | 2 | ->id->id | 江南六楼 + 157 | 141 | 2 | ->id->id | 江南七楼 + 158 | 141 | 2 | ->id->id | 江南八楼 + 159 | 141 | 2 | ->id->id | 江南九楼 (19 rows) select t1.id,t1.pid,LEVEL,sys_connect_by_path(' ', '->') pa, t1.name from test_hcb_ptb t1 start with id = 141 connect by prior id = pid; @@ -956,14 +956,6 @@ select t1.id,t1.pid,LEVEL,sys_connect_by_path(' ', '->') pa, t1.name from test_ -----+-----+-------+-----------+---------- 141 | 131 | 1 | ->  | 江南摩卡 151 | 141 | 2 | -> ->  | 江南一楼 - 152 | 141 | 2 | -> ->  | 江南二楼 - 153 | 141 | 2 | -> ->  | 江南三楼 - 154 | 141 | 2 | -> ->  | 江南四楼 - 155 | 141 | 2 | -> ->  | 江南五楼 - 156 | 141 | 2 | -> ->  | 江南六楼 - 157 | 141 | 2 | -> ->  | 江南七楼 - 158 | 141 | 2 | -> ->  | 江南八楼 - 159 | 141 | 2 | -> ->  | 江南九楼 161 | 151 | 3 | -> -> ->  | 第一单元 162 | 151 | 3 | -> -> ->  | 第二单元 163 | 151 | 3 | -> -> ->  | 第三单元 @@ -973,6 +965,14 @@ select t1.id,t1.pid,LEVEL,sys_connect_by_path(' ', '->') pa, t1.name from test_ 167 | 151 | 3 | -> -> ->  | 第七单元 168 | 151 | 3 | -> -> ->  | 第八单元 169 | 151 | 3 | -> -> ->  | 第九单元 + 152 | 141 | 2 | -> ->  | 江南二楼 + 153 | 141 | 2 | -> ->  | 江南三楼 + 154 | 141 | 2 | -> ->  | 江南四楼 + 155 | 141 | 2 | -> ->  | 江南五楼 + 156 | 141 | 2 | -> ->  | 江南六楼 + 157 | 141 | 2 | -> ->  | 江南七楼 + 158 | 141 | 2 | -> ->  | 江南八楼 + 159 | 141 | 2 | -> ->  | 江南九楼 (19 rows) explain select t1.id,t1.pid,t1.name,level from test_hcb_ptb t1 start with id=141 connect by prior id=pid Order By NLSSORT ( id, ' NLS_SORT = SCHINESE_PINYIN_M ' ); @@ -1179,59 +1179,11 @@ select t1.id, LEVEL, connect_by_iscycle from test_hcb_ptb t1 start with id = 1 c -----+-------+-------------------- 1 | 1 | 0 11 | 2 | 0 - 12 | 2 | 0 - 13 | 2 | 0 - 14 | 2 | 0 - 15 | 2 | 0 - 16 | 2 | 0 - 17 | 2 | 0 - 18 | 2 | 0 - 19 | 2 | 0 111 | 3 | 0 - 112 | 3 | 0 - 113 | 3 | 0 - 114 | 3 | 0 - 115 | 3 | 0 - 117 | 3 | 0 - 116 | 3 | 0 - 118 | 3 | 0 - 119 | 3 | 0 121 | 4 | 0 - 122 | 4 | 0 - 123 | 4 | 0 - 124 | 4 | 0 - 125 | 4 | 0 - 126 | 4 | 0 - 127 | 4 | 0 - 128 | 4 | 0 - 129 | 4 | 0 131 | 5 | 0 - 132 | 5 | 0 - 133 | 5 | 0 - 135 | 5 | 0 - 134 | 5 | 0 - 136 | 5 | 0 - 137 | 5 | 0 - 138 | 5 | 0 - 139 | 5 | 0 141 | 6 | 0 - 142 | 6 | 0 - 143 | 6 | 0 - 144 | 6 | 0 - 145 | 6 | 0 - 146 | 6 | 0 - 147 | 6 | 0 - 148 | 6 | 0 - 149 | 6 | 0 151 | 7 | 0 - 152 | 7 | 0 - 153 | 7 | 0 - 154 | 7 | 0 - 155 | 7 | 0 - 156 | 7 | 0 - 157 | 7 | 0 - 158 | 7 | 0 - 159 | 7 | 0 161 | 8 | 0 162 | 8 | 0 163 | 8 | 0 @@ -1241,6 +1193,54 @@ select t1.id, LEVEL, connect_by_iscycle from test_hcb_ptb t1 start with id = 1 c 167 | 8 | 0 168 | 8 | 0 169 | 8 | 0 + 152 | 7 | 0 + 153 | 7 | 0 + 154 | 7 | 0 + 155 | 7 | 0 + 156 | 7 | 0 + 157 | 7 | 0 + 158 | 7 | 0 + 159 | 7 | 0 + 142 | 6 | 0 + 143 | 6 | 0 + 144 | 6 | 0 + 145 | 6 | 0 + 146 | 6 | 0 + 147 | 6 | 0 + 148 | 6 | 0 + 149 | 6 | 0 + 132 | 5 | 0 + 133 | 5 | 0 + 135 | 5 | 0 + 134 | 5 | 0 + 136 | 5 | 0 + 137 | 5 | 0 + 138 | 5 | 0 + 139 | 5 | 0 + 122 | 4 | 0 + 123 | 4 | 0 + 124 | 4 | 0 + 125 | 4 | 0 + 126 | 4 | 0 + 127 | 4 | 0 + 128 | 4 | 0 + 129 | 4 | 0 + 112 | 3 | 0 + 113 | 3 | 0 + 114 | 3 | 0 + 115 | 3 | 0 + 117 | 3 | 0 + 116 | 3 | 0 + 118 | 3 | 0 + 119 | 3 | 0 + 12 | 2 | 0 + 13 | 2 | 0 + 14 | 2 | 0 + 15 | 2 | 0 + 16 | 2 | 0 + 17 | 2 | 0 + 18 | 2 | 0 + 19 | 2 | 0 (64 rows) create table mag_area @@ -1492,13 +1492,31 @@ SELECT prior AS start, connect AS prior, prior FROM START START START WITH conne SELECT start AS connect, prior AS start FROM CONNECT CONNECT CONNECT BY ROWNUM <5; connect | start ---------+------- + 1 | 2 + 1 | 2 + 1 | 2 1 | 2 1 | 3 3 | 4 3 | 5 5 | 6 6 | 7 -(6 rows) + 1 | 3 + 3 | 4 + 3 | 5 + 5 | 6 + 6 | 7 + 1 | 3 + 3 | 4 + 3 | 5 + 5 | 6 + 6 | 7 + 1 | 3 + 3 | 4 + 3 | 5 + 5 | 6 + 6 | 7 +(24 rows) DROP TABLE IF EXISTS start; DROP TABLE IF EXISTS connect; @@ -1560,10 +1578,18 @@ select c_int from t_test_array_base connect by c_int[1:2]=array[1,2] and rownum c_int ------------------ {1,2,NULL,10,11} - {1,2,2,10} - {1,2,2,10} {1,2,NULL,10,11} -(4 rows) + {1,2,NULL,10,11} + {1,2,NULL,10,11} + {1,2,2,10} + {1,2,2,10} + {1,2,2,10} + {1,2,2,10} + {1,2,2,10} + {1,2,2,10} + {1,2,2,10} + {1,2,2,10} +(12 rows) drop table t_test_array_base; -- test invalid columnref @@ -1707,8 +1733,8 @@ select sys_connect_by_path(name, '/') from test3 connect by parentid = prior id /root/a/a2 /a1 /a3/a31 - /b2 /root/a/a3 + /b2 /root/b/b1 /root/c /a/a3/a31 @@ -1793,8 +1819,8 @@ select max(name) from test3 connect by parentid = prior id group by sys_connect_ a2 a1 a31 - b2 a3 + b2 b1 c a31 diff --git a/src/test/regress/expected/sw_bugfix-2.out b/src/test/regress/expected/sw_bugfix-2.out index b5036cfe8..3fe9dc1a2 100755 --- a/src/test/regress/expected/sw_bugfix-2.out +++ b/src/test/regress/expected/sw_bugfix-2.out @@ -91,35 +91,35 @@ CONNECT BY id = PRIOR fatherid; id | name | fatherid | name_desc | connect_by_root | sys_connect_by_path ----+--------+----------+-----------+-----------------+----------------------------------- 14 | 耒阳市 | 13 | | | ->null - 14 | 耒阳市 | 13 | Leiyang | Leiyang | ->Leiyang - 13 | 衡阳市 | 2 | | | ->Leiyang->null 13 | 衡阳市 | 2 | | | ->null->null - 13 | 衡阳市 | 2 | Hengyang | Leiyang | ->Leiyang->Hengyang + 2 | 湖南省 | 1 | | | ->null->null->null + 1 | 中国 | 0 | | | ->null->null->null->null + 1 | 中国 | 0 | China | null | ->null->null->null->China + 2 | 湖南省 | 1 | Hunan | null | ->null->null->Hunan + 1 | 中国 | 0 | | | ->null->null->Hunan->null + 1 | 中国 | 0 | China | null | ->null->null->Hunan->China 13 | 衡阳市 | 2 | Hengyang | null | ->null->Hengyang 2 | 湖南省 | 1 | | | ->null->Hengyang->null - 2 | 湖南省 | 1 | | | ->Leiyang->Hengyang->null - 2 | 湖南省 | 1 | | | ->null->null->null - 2 | 湖南省 | 1 | | | ->Leiyang->null->null + 1 | 中国 | 0 | | | ->null->Hengyang->null->null + 1 | 中国 | 0 | China | null | ->null->Hengyang->null->China 2 | 湖南省 | 1 | Hunan | null | ->null->Hengyang->Hunan - 2 | 湖南省 | 1 | Hunan | Leiyang | ->Leiyang->Hengyang->Hunan - 2 | 湖南省 | 1 | Hunan | null | ->null->null->Hunan + 1 | 中国 | 0 | | | ->null->Hengyang->Hunan->null + 1 | 中国 | 0 | China | null | ->null->Hengyang->Hunan->China + 14 | 耒阳市 | 13 | Leiyang | Leiyang | ->Leiyang + 13 | 衡阳市 | 2 | | | ->Leiyang->null + 2 | 湖南省 | 1 | | | ->Leiyang->null->null + 1 | 中国 | 0 | | | ->Leiyang->null->null->null + 1 | 中国 | 0 | China | Leiyang | ->Leiyang->null->null->China 2 | 湖南省 | 1 | Hunan | Leiyang | ->Leiyang->null->Hunan 1 | 中国 | 0 | | | ->Leiyang->null->Hunan->null - 1 | 中国 | 0 | | | ->null->null->Hunan->null - 1 | 中国 | 0 | | | ->Leiyang->Hengyang->Hunan->null - 1 | 中国 | 0 | | | ->null->Hengyang->Hunan->null - 1 | 中国 | 0 | | | ->Leiyang->null->null->null - 1 | 中国 | 0 | | | ->null->null->null->null - 1 | 中国 | 0 | | | ->Leiyang->Hengyang->null->null - 1 | 中国 | 0 | | | ->null->Hengyang->null->null 1 | 中国 | 0 | China | Leiyang | ->Leiyang->null->Hunan->China - 1 | 中国 | 0 | China | null | ->null->null->Hunan->China - 1 | 中国 | 0 | China | Leiyang | ->Leiyang->Hengyang->Hunan->China - 1 | 中国 | 0 | China | null | ->null->Hengyang->Hunan->China - 1 | 中国 | 0 | China | Leiyang | ->Leiyang->null->null->China - 1 | 中国 | 0 | China | null | ->null->null->null->China + 13 | 衡阳市 | 2 | Hengyang | Leiyang | ->Leiyang->Hengyang + 2 | 湖南省 | 1 | | | ->Leiyang->Hengyang->null + 1 | 中国 | 0 | | | ->Leiyang->Hengyang->null->null 1 | 中国 | 0 | China | Leiyang | ->Leiyang->Hengyang->null->China - 1 | 中国 | 0 | China | null | ->null->Hengyang->null->China + 2 | 湖南省 | 1 | Hunan | Leiyang | ->Leiyang->Hengyang->Hunan + 1 | 中国 | 0 | | | ->Leiyang->Hengyang->Hunan->null + 1 | 中国 | 0 | China | Leiyang | ->Leiyang->Hengyang->Hunan->China (30 rows) SELECT * FROM t1_area START WITH id in ('1','2') CONNECT BY PRIOR fatherid = id; @@ -127,11 +127,11 @@ SELECT * FROM t1_area START WITH id in ('1','2') CONNECT BY PRIOR fatherid = id; ----+--------+----------+----------- 1 | 中国 | 0 | 2 | 湖南省 | 1 | + 1 | 中国 | 0 | + 1 | 中国 | 0 | China 1 | 中国 | 0 | China 2 | 湖南省 | 1 | Hunan 1 | 中国 | 0 | - 1 | 中国 | 0 | - 1 | 中国 | 0 | China 1 | 中国 | 0 | China (8 rows) @@ -140,17 +140,17 @@ SELECT * FROM t1_area START WITH (cast(id as varchar) COLLATE "C") in (cast(+ (i ----+--------+----------+----------- 1 | 中国 | 0 | 2 | 湖南省 | 1 | + 1 | 中国 | 0 | + 1 | 中国 | 0 | China 3 | 广东省 | 1 | + 1 | 中国 | 0 | + 1 | 中国 | 0 | China 1 | 中国 | 0 | China 2 | 湖南省 | 1 | Hunan + 1 | 中国 | 0 | + 1 | 中国 | 0 | China 3 | 广东省 | 1 | Guangdong 1 | 中国 | 0 | - 1 | 中国 | 0 | - 1 | 中国 | 0 | - 1 | 中国 | 0 | - 1 | 中国 | 0 | China - 1 | 中国 | 0 | China - 1 | 中国 | 0 | China 1 | 中国 | 0 | China (14 rows) @@ -503,23 +503,23 @@ select t1.id, t1.pid, t1.name from t1 start with not id=1 connect by prior pid=i id | pid | name ----+-----+------ 2 | 1 | 2 + 1 | 0 | 1 3 | 0 | 3 4 | 1 | 4 + 1 | 0 | 1 5 | 2 | 5 - 6 | 3 | 6 - 7 | 4 | 7 - 8 | 4 | 8 - 9 | 7 | 9 - 1 | 0 | 1 - 1 | 0 | 1 2 | 1 | 2 + 1 | 0 | 1 + 6 | 3 | 6 3 | 0 | 3 - 4 | 1 | 4 - 4 | 1 | 4 7 | 4 | 7 + 4 | 1 | 4 1 | 0 | 1 + 8 | 4 | 8 + 4 | 1 | 4 1 | 0 | 1 - 1 | 0 | 1 + 9 | 7 | 9 + 7 | 4 | 7 4 | 1 | 4 1 | 0 | 1 (20 rows) @@ -551,7 +551,7 @@ insert into t1 values(2,2,2); select *, connect_by_iscycle from t1 start with c1=1 connect by nocycle prior c1=c2 order siblings by 1,2; c1 | c2 | c3 | connect_by_iscycle ----+----+----+-------------------- - 1 | 1 | 1 | 0 + 1 | 1 | 1 | 1 (1 row) insert into t1 values(1,1,1); @@ -559,33 +559,33 @@ insert into t1 values(2,2,2); select *, connect_by_iscycle from t1 start with c1=1 connect by nocycle prior c1=c2 order siblings by 1,2; c1 | c2 | c3 | connect_by_iscycle ----+----+----+-------------------- - 1 | 1 | 1 | 0 - 1 | 1 | 1 | 0 + 1 | 1 | 1 | 1 + 1 | 1 | 1 | 1 (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; c1 | c2 | c3 | connect_by_iscycle ----+----+----+-------------------- - 1 | | 1 | 0 - 1 | 1 | 1 | 0 - 1 | 1 | 1 | 0 + 1 | | 1 | 1 + 1 | 1 | 1 | 1 + 1 | 1 | 1 | 1 (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 ----+----+----+-------------------- - 1 | 1 | 1 | 0 - 1 | 1 | 1 | 0 - 1 | | 1 | 0 + 1 | 1 | 1 | 1 + 1 | 1 | 1 | 1 + 1 | | 1 | 1 (3 rows) with cte1 as (select * from t1) select *, connect_by_iscycle from cte1 start with c1=1 connect by nocycle prior c1=c2 order siblings by 1,2 nulls last; c1 | c2 | c3 | connect_by_iscycle ----+----+----+-------------------- - 1 | 1 | 1 | 0 - 1 | 1 | 1 | 0 - 1 | | 1 | 0 + 1 | 1 | 1 | 1 + 1 | 1 | 1 | 1 + 1 | | 1 | 1 (3 rows) delete from t1 where c2 is null; @@ -611,20 +611,20 @@ select * from t1 connect by cast(level as bigint) < 3; c1 | c2 | c3 ----+----+---- 1 | 1 | 1 + 1 | 1 | 1 + 2 | 2 | 2 + 1 | 1 | 1 + 2 | 2 | 2 2 | 2 | 2 1 | 1 | 1 2 | 2 | 2 1 | 1 | 1 2 | 2 | 2 1 | 1 | 1 - 2 | 2 | 2 1 | 1 | 1 2 | 2 | 2 1 | 1 | 1 2 | 2 | 2 - 1 | 1 | 1 - 2 | 2 | 2 - 1 | 1 | 1 2 | 2 | 2 1 | 1 | 1 2 | 2 | 2 @@ -636,20 +636,20 @@ select * from t1 connect by cast(level as int4) < 3; c1 | c2 | c3 ----+----+---- 1 | 1 | 1 + 1 | 1 | 1 + 2 | 2 | 2 + 1 | 1 | 1 + 2 | 2 | 2 2 | 2 | 2 1 | 1 | 1 2 | 2 | 2 1 | 1 | 1 2 | 2 | 2 1 | 1 | 1 - 2 | 2 | 2 1 | 1 | 1 2 | 2 | 2 1 | 1 | 1 2 | 2 | 2 - 1 | 1 | 1 - 2 | 2 | 2 - 1 | 1 | 1 2 | 2 | 2 1 | 1 | 1 2 | 2 | 2 @@ -676,20 +676,20 @@ select * from t1 connect by level is not null and level < 3; c1 | c2 | c3 ----+----+---- 1 | 1 | 1 + 1 | 1 | 1 + 2 | 2 | 2 + 1 | 1 | 1 + 2 | 2 | 2 2 | 2 | 2 1 | 1 | 1 2 | 2 | 2 1 | 1 | 1 2 | 2 | 2 1 | 1 | 1 - 2 | 2 | 2 1 | 1 | 1 2 | 2 | 2 1 | 1 | 1 2 | 2 | 2 - 1 | 1 | 1 - 2 | 2 | 2 - 1 | 1 | 1 2 | 2 | 2 1 | 1 | 1 2 | 2 | 2 @@ -905,14 +905,14 @@ SELECT * FROM test_area START WITH name = '中国' CONNECT BY PRIOR id = fatheri ----+--------+----------+----------- 1 | 中国 | 0 | China 2 | 湖南省 | 1 | Hunan - 3 | 广东省 | 1 | Guangdong - 4 | 海南省 | 1 | Hainan - 5 | 河北省 | 1 | Hebei - 6 | 河南省 | 1 | Henan - 7 | 山东省 | 1 | Shandong - 8 | 湖北省 | 1 | Hubei - 9 | 江苏省 | 1 | Jiangsu - 10 | 深圳市 | 3 | Shenzhen + 11 | 长沙市 | 2 | Changsha + 13 | 衡阳市 | 2 | Hengyang + 22 | 祁北县 | 13 | Qibei + 21 | 祁西县 | 13 | Qixi + 14 | 耒阳市 | 13 | Leiyang + 19 | 祁东县 | 13 | Qidong + 18 | 常宁市 | 13 | Changning + 20 | 祁南县 | 13 | Qinan (10 rows) set max_recursive_times=1000; @@ -976,51 +976,51 @@ SELECT id,level FROM core_060 CONNECT BY level in (1,2); id | level ----+------- a | 1 + a | 2 + b | 2 + c | 2 b | 1 + a | 2 + b | 2 + c | 2 c | 1 a | 2 b | 2 c | 2 - a | 2 - b | 2 - c | 2 - a | 2 - b | 2 - c | 2 (12 rows) SELECT id,level FROM core_060 CONNECT BY not (level>2); id | level ----+------- a | 1 + a | 2 + b | 2 + c | 2 b | 1 + a | 2 + b | 2 + c | 2 c | 1 a | 2 b | 2 c | 2 - a | 2 - b | 2 - c | 2 - a | 2 - b | 2 - c | 2 (12 rows) SELECT id,level FROM core_060 CONNECT BY cast(level as number(38,0))<3; id | level ----+------- a | 1 + a | 2 + b | 2 + c | 2 b | 1 + a | 2 + b | 2 + c | 2 c | 1 a | 2 b | 2 c | 2 - a | 2 - b | 2 - c | 2 - a | 2 - b | 2 - c | 2 (12 rows) drop table core_060; @@ -1254,23 +1254,23 @@ SELECT id,pid,name,rownum,level FROM test_hcb_ptb START WITH id=1 CONNECT BY PRI -----+-----+--------+--------+------- 1 | 0 | 中国 | 1 | 1 11 | 1 | 江苏省 | 2 | 2 - 12 | 1 | 山东省 | 3 | 2 - 13 | 1 | 安徽省 | 4 | 2 - 14 | 1 | 河南省 | 5 | 2 - 15 | 1 | 河北省 | 6 | 2 - 16 | 1 | 湖南省 | 7 | 2 - 17 | 1 | 湖北省 | 8 | 2 - 18 | 1 | 贵州省 | 9 | 2 - 19 | 1 | 武汉省 | 10 | 2 - 111 | 11 | 南京市 | 11 | 3 - 112 | 11 | 宿迁市 | 12 | 3 - 113 | 11 | 徐州市 | 13 | 3 - 114 | 11 | 苏州市 | 14 | 3 - 115 | 11 | 盐城市 | 15 | 3 - 117 | 11 | 常州市 | 16 | 3 - 116 | 11 | 无锡市 | 17 | 3 - 118 | 11 | 连云港 | 18 | 3 - 119 | 11 | 泰州市 | 19 | 3 + 111 | 11 | 南京市 | 3 | 3 + 112 | 11 | 宿迁市 | 4 | 3 + 113 | 11 | 徐州市 | 5 | 3 + 114 | 11 | 苏州市 | 6 | 3 + 115 | 11 | 盐城市 | 7 | 3 + 117 | 11 | 常州市 | 8 | 3 + 116 | 11 | 无锡市 | 9 | 3 + 118 | 11 | 连云港 | 10 | 3 + 119 | 11 | 泰州市 | 11 | 3 + 12 | 1 | 山东省 | 12 | 2 + 13 | 1 | 安徽省 | 13 | 2 + 14 | 1 | 河南省 | 14 | 2 + 15 | 1 | 河北省 | 15 | 2 + 16 | 1 | 湖南省 | 16 | 2 + 17 | 1 | 湖北省 | 17 | 2 + 18 | 1 | 贵州省 | 18 | 2 + 19 | 1 | 武汉省 | 19 | 2 (19 rows) SELECT id,pid,name,rownum,level FROM test_hcb_ptb START WITH id=1 CONNECT BY NOCYCLE PRIOR id=pid AND level<4; @@ -1333,16 +1333,16 @@ explain performance select * from sw_dummy connect by level < 50; --?.* --?.* --?.* ---?.* ---?.* ---?.* ---?.* ---?.* ---?.* ---?.* ---?.* ---?.* ---?.* +--?.* +--?.* +--?.* +--?.* +--?.* +--?.* +--?.* +--?.* +--?.* +--?.* --?.* --?.* @@ -1375,14 +1375,6 @@ select t1.id,t1.pid,t2.id from test_hcb_ptb t1 join test_hcb_ptb t2 on t1.id=t2. -----+-----+----- 141 | 131 | 141 151 | 141 | 151 - 152 | 141 | 152 - 153 | 141 | 153 - 154 | 141 | 154 - 155 | 141 | 155 - 156 | 141 | 156 - 157 | 141 | 157 - 158 | 141 | 158 - 159 | 141 | 159 161 | 151 | 161 162 | 151 | 162 163 | 151 | 163 @@ -1392,6 +1384,14 @@ select t1.id,t1.pid,t2.id from test_hcb_ptb t1 join test_hcb_ptb t2 on t1.id=t2. 167 | 151 | 167 168 | 151 | 168 169 | 151 | 169 + 152 | 141 | 152 + 153 | 141 | 153 + 154 | 141 | 154 + 155 | 141 | 155 + 156 | 141 | 156 + 157 | 141 | 157 + 158 | 141 | 158 + 159 | 141 | 159 (19 rows) create or replace function prior(id int) returns int @@ -1522,30 +1522,28 @@ select ( where id=test_hcb_ptb.id) as siblings, pid,level from test_hcb_ptb start with id=141 connect by prior pid=id order siblings by 1; - QUERY PLAN -------------------------------------------------------------------------------------------------------------- + QUERY PLAN +------------------------------------------------------------------------------------------------------- CTE Scan on tmp_reuslt (cost=37.11..1472.07 rows=101 width=12) CTE tmp_reuslt -> StartWith Operator (cost=0.00..37.11 rows=101 width=102) Start With pseudo atts: RUITR, array_key_9, array_siblings - -> Sort (cost=40.47..40.72 rows=101 width=102) - Sort Key: array_siblings - -> Recursive Union (cost=0.00..37.11 rows=101 width=102) - -> Sort (cost=2.82..2.82 rows=1 width=102) - Sort Key: swtest.test_hcb_ptb.id - -> Seq Scan on test_hcb_ptb (cost=0.00..2.80 rows=1 width=102) - Filter: (id = 141) - -> Sort (cost=3.49..3.52 rows=10 width=102) - Sort Key: swtest.test_hcb_ptb.id - -> Hash Join (cost=0.33..3.23 rows=10 width=102) - Hash Cond: (swtest.test_hcb_ptb.id = tmp_reuslt."test_hcb_ptb@pid") - -> Seq Scan on test_hcb_ptb (cost=0.00..2.64 rows=64 width=102) - -> Hash (cost=0.20..0.20 rows=10 width=4) - -> WorkTable Scan on tmp_reuslt (cost=0.00..0.20 rows=10 width=4) + -> Recursive Union (cost=0.00..37.11 rows=101 width=102) + -> Sort (cost=2.82..2.82 rows=1 width=102) + Sort Key: swtest.test_hcb_ptb.id + -> Seq Scan on test_hcb_ptb (cost=0.00..2.80 rows=1 width=102) + Filter: (id = 141) + -> Sort (cost=3.49..3.52 rows=10 width=102) + Sort Key: swtest.test_hcb_ptb.id + -> Hash Join (cost=0.33..3.23 rows=10 width=102) + Hash Cond: (swtest.test_hcb_ptb.id = tmp_reuslt."test_hcb_ptb@pid") + -> Seq Scan on test_hcb_ptb (cost=0.00..2.64 rows=64 width=102) + -> Hash (cost=0.20..0.20 rows=10 width=4) + -> WorkTable Scan on tmp_reuslt (cost=0.00..0.20 rows=10 width=4) SubPlan 2 -> Seq Scan on test_place (cost=0.00..14.19 rows=2 width=4) Filter: (id = tmp_reuslt."test_hcb_ptb@id") -(21 rows) +(19 rows) select ( select id @@ -1571,30 +1569,28 @@ select ( where id=test_hcb_ptb.id) as siblings, pid,level from test_hcb_ptb start with id=141 connect by prior pid=id order siblings by siblings; - QUERY PLAN -------------------------------------------------------------------------------------------------------------- + QUERY PLAN +------------------------------------------------------------------------------------------------------- CTE Scan on tmp_reuslt (cost=37.11..1472.07 rows=101 width=12) CTE tmp_reuslt -> StartWith Operator (cost=0.00..37.11 rows=101 width=102) Start With pseudo atts: RUITR, array_key_9, array_siblings - -> Sort (cost=40.47..40.72 rows=101 width=102) - Sort Key: array_siblings - -> Recursive Union (cost=0.00..37.11 rows=101 width=102) - -> Sort (cost=2.82..2.82 rows=1 width=102) - Sort Key: swtest.test_hcb_ptb.id - -> Seq Scan on test_hcb_ptb (cost=0.00..2.80 rows=1 width=102) - Filter: (id = 141) - -> Sort (cost=3.49..3.52 rows=10 width=102) - Sort Key: swtest.test_hcb_ptb.id - -> Hash Join (cost=0.33..3.23 rows=10 width=102) - Hash Cond: (swtest.test_hcb_ptb.id = tmp_reuslt."test_hcb_ptb@pid") - -> Seq Scan on test_hcb_ptb (cost=0.00..2.64 rows=64 width=102) - -> Hash (cost=0.20..0.20 rows=10 width=4) - -> WorkTable Scan on tmp_reuslt (cost=0.00..0.20 rows=10 width=4) + -> Recursive Union (cost=0.00..37.11 rows=101 width=102) + -> Sort (cost=2.82..2.82 rows=1 width=102) + Sort Key: swtest.test_hcb_ptb.id + -> Seq Scan on test_hcb_ptb (cost=0.00..2.80 rows=1 width=102) + Filter: (id = 141) + -> Sort (cost=3.49..3.52 rows=10 width=102) + Sort Key: swtest.test_hcb_ptb.id + -> Hash Join (cost=0.33..3.23 rows=10 width=102) + Hash Cond: (swtest.test_hcb_ptb.id = tmp_reuslt."test_hcb_ptb@pid") + -> Seq Scan on test_hcb_ptb (cost=0.00..2.64 rows=64 width=102) + -> Hash (cost=0.20..0.20 rows=10 width=4) + -> WorkTable Scan on tmp_reuslt (cost=0.00..0.20 rows=10 width=4) SubPlan 2 -> Seq Scan on test_place (cost=0.00..14.19 rows=2 width=4) Filter: (id = tmp_reuslt."test_hcb_ptb@id") -(21 rows) +(19 rows) select ( select id @@ -1615,27 +1611,25 @@ from test_hcb_ptb start with id=141 connect by prior pid=id order siblings by si --- test case for unnamed expr with order siblings by colIndex explain select id*2, pid from test_hcb_ptb start with id=141 connect by prior pid=id order siblings by 1; - QUERY PLAN -------------------------------------------------------------------------------------------------------------- + QUERY PLAN +------------------------------------------------------------------------------------------------------- CTE Scan on tmp_reuslt (cost=37.11..39.38 rows=101 width=8) CTE tmp_reuslt -> StartWith Operator (cost=0.00..37.11 rows=101 width=102) Start With pseudo atts: RUITR, array_key_9, array_siblings - -> Sort (cost=40.47..40.72 rows=101 width=102) - Sort Key: array_siblings - -> Recursive Union (cost=0.00..37.11 rows=101 width=102) - -> Sort (cost=2.82..2.82 rows=1 width=102) - Sort Key: swtest.test_hcb_ptb.id - -> Seq Scan on test_hcb_ptb (cost=0.00..2.80 rows=1 width=102) - Filter: (id = 141) - -> Sort (cost=3.49..3.52 rows=10 width=102) - Sort Key: swtest.test_hcb_ptb.id - -> Hash Join (cost=0.33..3.23 rows=10 width=102) - Hash Cond: (swtest.test_hcb_ptb.id = tmp_reuslt."test_hcb_ptb@pid") - -> Seq Scan on test_hcb_ptb (cost=0.00..2.64 rows=64 width=102) - -> Hash (cost=0.20..0.20 rows=10 width=4) - -> WorkTable Scan on tmp_reuslt (cost=0.00..0.20 rows=10 width=4) -(18 rows) + -> Recursive Union (cost=0.00..37.11 rows=101 width=102) + -> Sort (cost=2.82..2.82 rows=1 width=102) + Sort Key: swtest.test_hcb_ptb.id + -> Seq Scan on test_hcb_ptb (cost=0.00..2.80 rows=1 width=102) + Filter: (id = 141) + -> Sort (cost=3.49..3.52 rows=10 width=102) + Sort Key: swtest.test_hcb_ptb.id + -> Hash Join (cost=0.33..3.23 rows=10 width=102) + Hash Cond: (swtest.test_hcb_ptb.id = tmp_reuslt."test_hcb_ptb@pid") + -> Seq Scan on test_hcb_ptb (cost=0.00..2.64 rows=64 width=102) + -> Hash (cost=0.20..0.20 rows=10 width=4) + -> WorkTable Scan on tmp_reuslt (cost=0.00..0.20 rows=10 width=4) +(16 rows) select id*2, pid from test_hcb_ptb start with id=141 connect by prior pid=id order siblings by 1; ?column? | pid @@ -1650,27 +1644,25 @@ select id*2, pid from test_hcb_ptb start with id=141 connect by prior pid=id ord explain select id*2 as a, pid from test_hcb_ptb start with id=141 connect by prior pid=id order siblings by a; - QUERY PLAN -------------------------------------------------------------------------------------------------------------- + QUERY PLAN +------------------------------------------------------------------------------------------------------- CTE Scan on tmp_reuslt (cost=37.11..39.38 rows=101 width=8) CTE tmp_reuslt -> StartWith Operator (cost=0.00..37.11 rows=101 width=102) Start With pseudo atts: RUITR, array_key_9, array_siblings - -> Sort (cost=40.47..40.72 rows=101 width=102) - Sort Key: array_siblings - -> Recursive Union (cost=0.00..37.11 rows=101 width=102) - -> Sort (cost=2.82..2.82 rows=1 width=102) - Sort Key: swtest.test_hcb_ptb.id - -> Seq Scan on test_hcb_ptb (cost=0.00..2.80 rows=1 width=102) - Filter: (id = 141) - -> Sort (cost=3.49..3.52 rows=10 width=102) - Sort Key: swtest.test_hcb_ptb.id - -> Hash Join (cost=0.33..3.23 rows=10 width=102) - Hash Cond: (swtest.test_hcb_ptb.id = tmp_reuslt."test_hcb_ptb@pid") - -> Seq Scan on test_hcb_ptb (cost=0.00..2.64 rows=64 width=102) - -> Hash (cost=0.20..0.20 rows=10 width=4) - -> WorkTable Scan on tmp_reuslt (cost=0.00..0.20 rows=10 width=4) -(18 rows) + -> Recursive Union (cost=0.00..37.11 rows=101 width=102) + -> Sort (cost=2.82..2.82 rows=1 width=102) + Sort Key: swtest.test_hcb_ptb.id + -> Seq Scan on test_hcb_ptb (cost=0.00..2.80 rows=1 width=102) + Filter: (id = 141) + -> Sort (cost=3.49..3.52 rows=10 width=102) + Sort Key: swtest.test_hcb_ptb.id + -> Hash Join (cost=0.33..3.23 rows=10 width=102) + Hash Cond: (swtest.test_hcb_ptb.id = tmp_reuslt."test_hcb_ptb@pid") + -> Seq Scan on test_hcb_ptb (cost=0.00..2.64 rows=64 width=102) + -> Hash (cost=0.20..0.20 rows=10 width=4) + -> WorkTable Scan on tmp_reuslt (cost=0.00..0.20 rows=10 width=4) +(16 rows) select id*2 as a, pid from test_hcb_ptb start with id=141 connect by prior pid=id order siblings by a; a | pid @@ -1686,27 +1678,25 @@ select id*2 as a, pid from test_hcb_ptb start with id=141 connect by prior pid=i -- test case for mix alias and colname in order siblings by calause explain select id as a,pid from test_hcb_ptb start with id=141 connect by prior pid=id order siblings by a; - QUERY PLAN -------------------------------------------------------------------------------------------------------------- + QUERY PLAN +------------------------------------------------------------------------------------------------------- CTE Scan on tmp_reuslt (cost=37.11..39.13 rows=101 width=8) CTE tmp_reuslt -> StartWith Operator (cost=0.00..37.11 rows=101 width=102) Start With pseudo atts: RUITR, array_key_9, array_siblings - -> Sort (cost=40.47..40.72 rows=101 width=102) - Sort Key: array_siblings - -> Recursive Union (cost=0.00..37.11 rows=101 width=102) - -> Sort (cost=2.82..2.82 rows=1 width=102) - Sort Key: swtest.test_hcb_ptb.id - -> Seq Scan on test_hcb_ptb (cost=0.00..2.80 rows=1 width=102) - Filter: (id = 141) - -> Sort (cost=3.49..3.52 rows=10 width=102) - Sort Key: swtest.test_hcb_ptb.id - -> Hash Join (cost=0.33..3.23 rows=10 width=102) - Hash Cond: (swtest.test_hcb_ptb.id = tmp_reuslt."test_hcb_ptb@pid") - -> Seq Scan on test_hcb_ptb (cost=0.00..2.64 rows=64 width=102) - -> Hash (cost=0.20..0.20 rows=10 width=4) - -> WorkTable Scan on tmp_reuslt (cost=0.00..0.20 rows=10 width=4) -(18 rows) + -> Recursive Union (cost=0.00..37.11 rows=101 width=102) + -> Sort (cost=2.82..2.82 rows=1 width=102) + Sort Key: swtest.test_hcb_ptb.id + -> Seq Scan on test_hcb_ptb (cost=0.00..2.80 rows=1 width=102) + Filter: (id = 141) + -> Sort (cost=3.49..3.52 rows=10 width=102) + Sort Key: swtest.test_hcb_ptb.id + -> Hash Join (cost=0.33..3.23 rows=10 width=102) + Hash Cond: (swtest.test_hcb_ptb.id = tmp_reuslt."test_hcb_ptb@pid") + -> Seq Scan on test_hcb_ptb (cost=0.00..2.64 rows=64 width=102) + -> Hash (cost=0.20..0.20 rows=10 width=4) + -> WorkTable Scan on tmp_reuslt (cost=0.00..0.20 rows=10 width=4) +(16 rows) select id as a,pid from test_hcb_ptb start with id=141 connect by prior pid=id order siblings by a; a | pid @@ -1721,27 +1711,25 @@ select id as a,pid from test_hcb_ptb start with id=141 connect by prior pid=id o explain select id as a,pid from test_hcb_ptb start with id=141 connect by prior pid=id order siblings by pid,a; - QUERY PLAN -------------------------------------------------------------------------------------------------------------- + QUERY PLAN +------------------------------------------------------------------------------------------------------- CTE Scan on tmp_reuslt (cost=37.11..39.13 rows=101 width=8) CTE tmp_reuslt -> StartWith Operator (cost=0.00..37.11 rows=101 width=102) Start With pseudo atts: RUITR, array_key_9, array_siblings - -> Sort (cost=40.47..40.72 rows=101 width=102) - Sort Key: array_siblings - -> Recursive Union (cost=0.00..37.11 rows=101 width=102) - -> Sort (cost=2.82..2.82 rows=1 width=102) - Sort Key: swtest.test_hcb_ptb.pid, swtest.test_hcb_ptb.id - -> Seq Scan on test_hcb_ptb (cost=0.00..2.80 rows=1 width=102) - Filter: (id = 141) - -> Sort (cost=3.49..3.52 rows=10 width=102) - Sort Key: swtest.test_hcb_ptb.pid, swtest.test_hcb_ptb.id - -> Hash Join (cost=0.33..3.23 rows=10 width=102) - Hash Cond: (swtest.test_hcb_ptb.id = tmp_reuslt."test_hcb_ptb@pid") - -> Seq Scan on test_hcb_ptb (cost=0.00..2.64 rows=64 width=102) - -> Hash (cost=0.20..0.20 rows=10 width=4) - -> WorkTable Scan on tmp_reuslt (cost=0.00..0.20 rows=10 width=4) -(18 rows) + -> Recursive Union (cost=0.00..37.11 rows=101 width=102) + -> Sort (cost=2.82..2.82 rows=1 width=102) + Sort Key: swtest.test_hcb_ptb.pid, swtest.test_hcb_ptb.id + -> Seq Scan on test_hcb_ptb (cost=0.00..2.80 rows=1 width=102) + Filter: (id = 141) + -> Sort (cost=3.49..3.52 rows=10 width=102) + Sort Key: swtest.test_hcb_ptb.pid, swtest.test_hcb_ptb.id + -> Hash Join (cost=0.33..3.23 rows=10 width=102) + Hash Cond: (swtest.test_hcb_ptb.id = tmp_reuslt."test_hcb_ptb@pid") + -> Seq Scan on test_hcb_ptb (cost=0.00..2.64 rows=64 width=102) + -> Hash (cost=0.20..0.20 rows=10 width=4) + -> WorkTable Scan on tmp_reuslt (cost=0.00..0.20 rows=10 width=4) +(16 rows) select id as a,pid from test_hcb_ptb start with id=141 connect by prior pid=id order siblings by pid,a; a | pid @@ -1906,33 +1894,36 @@ ERROR: column specified by prior cannot concide with ROWNUM/LEVEL. DETAIL: Unsupported node type: 900. DROP TABLE RLTEST; create table nocycle_tbl(id int, lid int, name text); -insert into nocycle_tbl values (1,3,'A'),(2,1,'B'),(3,2,'C'),(4,2,'D'); -select * from nocycle_tbl connect by nocycle prior id=lid start with id=1; - id | lid | name -----+-----+------ - 1 | 3 | A - 2 | 1 | B - 3 | 2 | C - 4 | 2 | D -(4 rows) +insert into nocycle_tbl values (1,3,'A'),(2,1,'B'),(3,2,'C'),(4,2,'D'),(5,3,'E'); +select *,connect_by_iscycle from nocycle_tbl connect by nocycle prior id=lid start with id=1; + id | lid | name | connect_by_iscycle +----+-----+------+-------------------- + 1 | 3 | A | 0 + 2 | 1 | B | 0 + 3 | 2 | C | 1 + 5 | 3 | E | 0 + 4 | 2 | D | 0 +(5 rows) -select * from nocycle_tbl connect by nocycle prior id=lid start with id=1 order siblings by id; - id | lid | name -----+-----+------ - 1 | 3 | A - 2 | 1 | B - 3 | 2 | C - 4 | 2 | D -(4 rows) +select *,connect_by_iscycle from nocycle_tbl connect by nocycle prior id=lid start with id=1 order siblings by id; + id | lid | name | connect_by_iscycle +----+-----+------+-------------------- + 1 | 3 | A | 0 + 2 | 1 | B | 0 + 3 | 2 | C | 1 + 5 | 3 | E | 0 + 4 | 2 | D | 0 +(5 rows) -select * from nocycle_tbl connect by nocycle prior id=lid start with id=1 order siblings by id desc; - id | lid | name -----+-----+------ - 1 | 3 | A - 2 | 1 | B - 4 | 2 | D - 3 | 2 | C -(4 rows) +select *,connect_by_iscycle from nocycle_tbl connect by nocycle prior id=lid start with id=1 order siblings by id desc; + id | lid | name | connect_by_iscycle +----+-----+------+-------------------- + 1 | 3 | A | 0 + 2 | 1 | B | 0 + 4 | 2 | D | 0 + 3 | 2 | C | 1 + 5 | 3 | E | 0 +(5 rows) drop table nocycle_tbl; CREATE TABLE swcb_employees ( employee_id VARCHAR, manager_id NUMBER(6)); diff --git a/src/test/regress/expected/sw_icbc.out b/src/test/regress/expected/sw_icbc.out index 258ecb39e..d8c19bc73 100755 --- a/src/test/regress/expected/sw_icbc.out +++ b/src/test/regress/expected/sw_icbc.out @@ -25,11 +25,11 @@ select * from t1 start with id = 1 connect by prior id = pid; ----+-----+------ 1 | 0 | 1 2 | 1 | 2 - 4 | 1 | 4 5 | 2 | 5 + 4 | 1 | 4 7 | 4 | 7 - 8 | 4 | 8 9 | 7 | 9 + 8 | 4 | 8 (7 rows) explain (costs off) @@ -55,11 +55,11 @@ select * from t1 start with t1.id = 1 connect by prior t1.id = t1.pid; ----+-----+------ 1 | 0 | 1 2 | 1 | 2 - 4 | 1 | 4 5 | 2 | 5 + 4 | 1 | 4 7 | 4 | 7 - 8 | 4 | 8 9 | 7 | 9 + 8 | 4 | 8 (7 rows) explain (costs off) @@ -85,11 +85,11 @@ select * from t1 as test start with test.id = 1 connect by prior test.id = test. ----+-----+------ 1 | 0 | 1 2 | 1 | 2 - 4 | 1 | 4 5 | 2 | 5 + 4 | 1 | 4 7 | 4 | 7 - 8 | 4 | 8 9 | 7 | 9 + 8 | 4 | 8 (7 rows) explain (costs off) @@ -181,11 +181,11 @@ select t1.id, t1.pid, t1.name from t1 start with id = 1 connect by prior id = pi ----+-----+------ 1 | 0 | 1 2 | 1 | 2 - 4 | 1 | 4 5 | 2 | 5 + 4 | 1 | 4 7 | 4 | 7 - 8 | 4 | 8 9 | 7 | 9 + 8 | 4 | 8 (7 rows) explain (costs off) select sum(name) from t1 start with id = 1 connect by prior id = pid group by id, pid; @@ -245,11 +245,11 @@ select * from t1 start with id = 1 connect by prior id = pid and id IN (select i ----+-----+------ 1 | 0 | 1 2 | 1 | 2 - 4 | 1 | 4 5 | 2 | 5 + 4 | 1 | 4 7 | 4 | 7 - 8 | 4 | 8 9 | 7 | 9 + 8 | 4 | 8 (7 rows) explain (costs off) select * from t1 start with id = 1 and id is not NULL connect by prior id = pid; @@ -274,11 +274,11 @@ select * from t1 start with id = 1 and id is not NULL connect by prior id = pid; ----+-----+------ 1 | 0 | 1 2 | 1 | 2 - 4 | 1 | 4 5 | 2 | 5 + 4 | 1 | 4 7 | 4 | 7 - 8 | 4 | 8 9 | 7 | 9 + 8 | 4 | 8 (7 rows) explain (costs off) @@ -326,11 +326,11 @@ connect by prior test.id = test.pid; ----+-----+------ 1 | 0 | 1 2 | 1 | 2 - 4 | 1 | 4 5 | 2 | 5 + 4 | 1 | 4 7 | 4 | 7 - 8 | 4 | 8 9 | 7 | 9 + 8 | 4 | 8 (7 rows) explain (costs off) @@ -417,11 +417,11 @@ START WITH tt.id = 1; ----+-----+------ 1 | 0 | 1 2 | 1 | 2 - 4 | 1 | 4 5 | 2 | 5 + 4 | 1 | 4 7 | 4 | 7 - 8 | 4 | 8 9 | 7 | 9 + 8 | 4 | 8 (7 rows) --test correlated sublink in targetlist diff --git a/src/test/regress/expected/sw_siblings.out b/src/test/regress/expected/sw_siblings.out index 8915a635a..14f109c14 100644 --- a/src/test/regress/expected/sw_siblings.out +++ b/src/test/regress/expected/sw_siblings.out @@ -42,27 +42,25 @@ FROM test_area START WITH name = '中国' CONNECT BY prior id = fatherid ORDER SIBLINGS BY id; - QUERY PLAN ------------------------------------------------------------------------------------------------------- + QUERY PLAN +------------------------------------------------------------------------------------------------ CTE Scan on tmp_reuslt CTE tmp_reuslt -> StartWith Operator Start With pseudo atts: RUITR, array_key_1, array_col_2, array_col_4, array_siblings - -> Sort - Sort Key: array_siblings - -> Recursive Union - -> Sort - Sort Key: swtest.test_area.id + -> Recursive Union + -> Sort + Sort Key: swtest.test_area.id + -> Seq Scan on test_area + Filter: (name = '中国'::text) + -> Sort + Sort Key: swtest.test_area.id + -> Hash Join + Hash Cond: (swtest.test_area.fatherid = tmp_reuslt."test_area@id") -> Seq Scan on test_area - Filter: (name = '中国'::text) - -> Sort - Sort Key: swtest.test_area.id - -> Hash Join - Hash Cond: (swtest.test_area.fatherid = tmp_reuslt."test_area@id") - -> Seq Scan on test_area - -> Hash - -> WorkTable Scan on tmp_reuslt -(18 rows) + -> Hash + -> WorkTable Scan on tmp_reuslt +(16 rows) SELECT *, LEVEL, connect_by_isleaf, connect_by_iscycle, connect_by_root(name_desc), SYS_CONNECT_BY_PATH(name, '@') cpath FROM test_area @@ -104,27 +102,25 @@ FROM test_area START WITH name = '中国' CONNECT BY prior id = fatherid ORDER SIBLINGS BY id desc; - QUERY PLAN ------------------------------------------------------------------------------------------------------- + QUERY PLAN +------------------------------------------------------------------------------------------------ CTE Scan on tmp_reuslt CTE tmp_reuslt -> StartWith Operator Start With pseudo atts: RUITR, array_key_1, array_col_2, array_col_4, array_siblings - -> Sort - Sort Key: array_siblings - -> Recursive Union - -> Sort - Sort Key: swtest.test_area.id DESC + -> Recursive Union + -> Sort + Sort Key: swtest.test_area.id DESC + -> Seq Scan on test_area + Filter: (name = '中国'::text) + -> Sort + Sort Key: swtest.test_area.id DESC + -> Hash Join + Hash Cond: (swtest.test_area.fatherid = tmp_reuslt."test_area@id") -> Seq Scan on test_area - Filter: (name = '中国'::text) - -> Sort - Sort Key: swtest.test_area.id DESC - -> Hash Join - Hash Cond: (swtest.test_area.fatherid = tmp_reuslt."test_area@id") - -> Seq Scan on test_area - -> Hash - -> WorkTable Scan on tmp_reuslt -(18 rows) + -> Hash + -> WorkTable Scan on tmp_reuslt +(16 rows) SELECT *, LEVEL, connect_by_isleaf, connect_by_iscycle, connect_by_root(name_desc), SYS_CONNECT_BY_PATH(name, '@') cpath FROM test_area @@ -166,27 +162,25 @@ FROM test_area START WITH name = '衡阳市' or name = '深圳市' CONNECT BY prior id = fatherid ORDER SIBLINGS BY id; - QUERY PLAN ------------------------------------------------------------------------------------------------------- + QUERY PLAN +------------------------------------------------------------------------------------------------ CTE Scan on tmp_reuslt CTE tmp_reuslt -> StartWith Operator Start With pseudo atts: RUITR, array_key_1, array_col_2, array_col_4, array_siblings - -> Sort - Sort Key: array_siblings - -> Recursive Union - -> Sort - Sort Key: swtest.test_area.id + -> Recursive Union + -> Sort + Sort Key: swtest.test_area.id + -> Seq Scan on test_area + Filter: ((name = '衡阳市'::text) OR (name = '深圳市'::text)) + -> Sort + Sort Key: swtest.test_area.id + -> Hash Join + Hash Cond: (swtest.test_area.fatherid = tmp_reuslt."test_area@id") -> Seq Scan on test_area - Filter: ((name = '衡阳市'::text) OR (name = '深圳市'::text)) - -> Sort - Sort Key: swtest.test_area.id - -> Hash Join - Hash Cond: (swtest.test_area.fatherid = tmp_reuslt."test_area@id") - -> Seq Scan on test_area - -> Hash - -> WorkTable Scan on tmp_reuslt -(18 rows) + -> Hash + -> WorkTable Scan on tmp_reuslt +(16 rows) SELECT *, LEVEL, connect_by_isleaf, connect_by_iscycle, connect_by_root(name_desc), SYS_CONNECT_BY_PATH(name, '@') cpath FROM test_area @@ -219,27 +213,25 @@ FROM test_area START WITH name = '衡阳市' or name = '深圳市' CONNECT BY prior id = fatherid ORDER SIBLINGS BY id desc; - QUERY PLAN ------------------------------------------------------------------------------------------------------- + QUERY PLAN +------------------------------------------------------------------------------------------------ CTE Scan on tmp_reuslt CTE tmp_reuslt -> StartWith Operator Start With pseudo atts: RUITR, array_key_1, array_col_2, array_col_4, array_siblings - -> Sort - Sort Key: array_siblings - -> Recursive Union - -> Sort - Sort Key: swtest.test_area.id DESC + -> Recursive Union + -> Sort + Sort Key: swtest.test_area.id DESC + -> Seq Scan on test_area + Filter: ((name = '衡阳市'::text) OR (name = '深圳市'::text)) + -> Sort + Sort Key: swtest.test_area.id DESC + -> Hash Join + Hash Cond: (swtest.test_area.fatherid = tmp_reuslt."test_area@id") -> Seq Scan on test_area - Filter: ((name = '衡阳市'::text) OR (name = '深圳市'::text)) - -> Sort - Sort Key: swtest.test_area.id DESC - -> Hash Join - Hash Cond: (swtest.test_area.fatherid = tmp_reuslt."test_area@id") - -> Seq Scan on test_area - -> Hash - -> WorkTable Scan on tmp_reuslt -(18 rows) + -> Hash + -> WorkTable Scan on tmp_reuslt +(16 rows) SELECT *, LEVEL, connect_by_isleaf, connect_by_iscycle, connect_by_root(name_desc), SYS_CONNECT_BY_PATH(name, '@') cpath FROM test_area @@ -272,27 +264,25 @@ FROM test_area START WITH name = '常宁市' CONNECT BY id = prior fatherid ORDER SIBLINGS BY id; - QUERY PLAN ------------------------------------------------------------------------------------------------------- + QUERY PLAN +------------------------------------------------------------------------------------------------ CTE Scan on tmp_reuslt CTE tmp_reuslt -> StartWith Operator Start With pseudo atts: RUITR, array_key_3, array_col_2, array_col_4, array_siblings - -> Sort - Sort Key: array_siblings - -> Recursive Union - -> Sort - Sort Key: swtest.test_area.id + -> Recursive Union + -> Sort + Sort Key: swtest.test_area.id + -> Seq Scan on test_area + Filter: (name = '常宁市'::text) + -> Sort + Sort Key: swtest.test_area.id + -> Hash Join + Hash Cond: (swtest.test_area.id = tmp_reuslt."test_area@fatherid") -> Seq Scan on test_area - Filter: (name = '常宁市'::text) - -> Sort - Sort Key: swtest.test_area.id - -> Hash Join - Hash Cond: (swtest.test_area.id = tmp_reuslt."test_area@fatherid") - -> Seq Scan on test_area - -> Hash - -> WorkTable Scan on tmp_reuslt -(18 rows) + -> Hash + -> WorkTable Scan on tmp_reuslt +(16 rows) SELECT *, LEVEL, connect_by_isleaf, connect_by_iscycle, connect_by_root(name_desc), SYS_CONNECT_BY_PATH(name, '@') cpath FROM test_area @@ -316,27 +306,25 @@ FROM test_area START WITH name = '常宁市' CONNECT BY id = prior fatherid ORDER SIBLINGS BY id desc; - QUERY PLAN ------------------------------------------------------------------------------------------------------- + QUERY PLAN +------------------------------------------------------------------------------------------------ CTE Scan on tmp_reuslt CTE tmp_reuslt -> StartWith Operator Start With pseudo atts: RUITR, array_key_3, array_col_2, array_col_4, array_siblings - -> Sort - Sort Key: array_siblings - -> Recursive Union - -> Sort - Sort Key: swtest.test_area.id DESC + -> Recursive Union + -> Sort + Sort Key: swtest.test_area.id DESC + -> Seq Scan on test_area + Filter: (name = '常宁市'::text) + -> Sort + Sort Key: swtest.test_area.id DESC + -> Hash Join + Hash Cond: (swtest.test_area.id = tmp_reuslt."test_area@fatherid") -> Seq Scan on test_area - Filter: (name = '常宁市'::text) - -> Sort - Sort Key: swtest.test_area.id DESC - -> Hash Join - Hash Cond: (swtest.test_area.id = tmp_reuslt."test_area@fatherid") - -> Seq Scan on test_area - -> Hash - -> WorkTable Scan on tmp_reuslt -(18 rows) + -> Hash + -> WorkTable Scan on tmp_reuslt +(16 rows) SELECT *, LEVEL, connect_by_isleaf, connect_by_iscycle, connect_by_root(name_desc), SYS_CONNECT_BY_PATH(name, '@') cpath FROM test_area @@ -361,27 +349,25 @@ FROM test_area START WITH name = '中国' CONNECT BY prior id = fatherid ORDER SIBLINGS BY 1; - QUERY PLAN ------------------------------------------------------------------------------------------------------- + QUERY PLAN +------------------------------------------------------------------------------------------------ CTE Scan on tmp_reuslt CTE tmp_reuslt -> StartWith Operator Start With pseudo atts: RUITR, array_key_1, array_col_2, array_col_4, array_siblings - -> Sort - Sort Key: array_siblings - -> Recursive Union - -> Sort - Sort Key: swtest.test_area.id + -> Recursive Union + -> Sort + Sort Key: swtest.test_area.id + -> Seq Scan on test_area + Filter: (name = '中国'::text) + -> Sort + Sort Key: swtest.test_area.id + -> Hash Join + Hash Cond: (swtest.test_area.fatherid = tmp_reuslt."test_area@id") -> Seq Scan on test_area - Filter: (name = '中国'::text) - -> Sort - Sort Key: swtest.test_area.id - -> Hash Join - Hash Cond: (swtest.test_area.fatherid = tmp_reuslt."test_area@id") - -> Seq Scan on test_area - -> Hash - -> WorkTable Scan on tmp_reuslt -(18 rows) + -> Hash + -> WorkTable Scan on tmp_reuslt +(16 rows) SELECT *, LEVEL, connect_by_isleaf, connect_by_iscycle, connect_by_root(name_desc), SYS_CONNECT_BY_PATH(name, '@') cpath FROM test_area @@ -420,81 +406,75 @@ SELECT * FROM test_area START WITH name = '中国' CONNECT BY prior id = fatherid ORDER SIBLINGS BY id, name, name_desc; - QUERY PLAN --------------------------------------------------------------------------------------------------------------- + QUERY PLAN +-------------------------------------------------------------------------------------------------------- CTE Scan on tmp_reuslt CTE tmp_reuslt -> StartWith Operator Start With pseudo atts: RUITR, array_key_1, array_siblings - -> Sort - Sort Key: array_siblings - -> Recursive Union - -> Sort - Sort Key: swtest.test_area.id, swtest.test_area.name, swtest.test_area.name_desc + -> Recursive Union + -> Sort + Sort Key: swtest.test_area.id, swtest.test_area.name, swtest.test_area.name_desc + -> Seq Scan on test_area + Filter: (name = '中国'::text) + -> Sort + Sort Key: swtest.test_area.id, swtest.test_area.name, swtest.test_area.name_desc + -> Hash Join + Hash Cond: (swtest.test_area.fatherid = tmp_reuslt."test_area@id") -> Seq Scan on test_area - Filter: (name = '中国'::text) - -> Sort - Sort Key: swtest.test_area.id, swtest.test_area.name, swtest.test_area.name_desc - -> Hash Join - Hash Cond: (swtest.test_area.fatherid = tmp_reuslt."test_area@id") - -> Seq Scan on test_area - -> Hash - -> WorkTable Scan on tmp_reuslt -(18 rows) + -> Hash + -> WorkTable Scan on tmp_reuslt +(16 rows) EXPLAIN (costs off) SELECT * FROM test_area START WITH name = '中国' CONNECT BY prior id = fatherid ORDER SIBLINGS BY id desc, name desc , name_desc desc; - QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------ + QUERY PLAN +----------------------------------------------------------------------------------------------------------------------- CTE Scan on tmp_reuslt CTE tmp_reuslt -> StartWith Operator Start With pseudo atts: RUITR, array_key_1, array_siblings - -> Sort - Sort Key: array_siblings - -> Recursive Union - -> Sort - Sort Key: swtest.test_area.id DESC, swtest.test_area.name DESC, swtest.test_area.name_desc DESC + -> Recursive Union + -> Sort + Sort Key: swtest.test_area.id DESC, swtest.test_area.name DESC, swtest.test_area.name_desc DESC + -> Seq Scan on test_area + Filter: (name = '中国'::text) + -> Sort + Sort Key: swtest.test_area.id DESC, swtest.test_area.name DESC, swtest.test_area.name_desc DESC + -> Hash Join + Hash Cond: (swtest.test_area.fatherid = tmp_reuslt."test_area@id") -> Seq Scan on test_area - Filter: (name = '中国'::text) - -> Sort - Sort Key: swtest.test_area.id DESC, swtest.test_area.name DESC, swtest.test_area.name_desc DESC - -> Hash Join - Hash Cond: (swtest.test_area.fatherid = tmp_reuslt."test_area@id") - -> Seq Scan on test_area - -> Hash - -> WorkTable Scan on tmp_reuslt -(18 rows) + -> Hash + -> WorkTable Scan on tmp_reuslt +(16 rows) EXPLAIN (costs off) SELECT * FROM test_area START WITH name = '中国' CONNECT BY prior id = fatherid ORDER SIBLINGS BY id desc, name, name_desc desc; - QUERY PLAN ------------------------------------------------------------------------------------------------------------------------- + QUERY PLAN +------------------------------------------------------------------------------------------------------------------ CTE Scan on tmp_reuslt CTE tmp_reuslt -> StartWith Operator Start With pseudo atts: RUITR, array_key_1, array_siblings - -> Sort - Sort Key: array_siblings - -> Recursive Union - -> Sort - Sort Key: swtest.test_area.id DESC, swtest.test_area.name, swtest.test_area.name_desc DESC + -> Recursive Union + -> Sort + Sort Key: swtest.test_area.id DESC, swtest.test_area.name, swtest.test_area.name_desc DESC + -> Seq Scan on test_area + Filter: (name = '中国'::text) + -> Sort + Sort Key: swtest.test_area.id DESC, swtest.test_area.name, swtest.test_area.name_desc DESC + -> Hash Join + Hash Cond: (swtest.test_area.fatherid = tmp_reuslt."test_area@id") -> Seq Scan on test_area - Filter: (name = '中国'::text) - -> Sort - Sort Key: swtest.test_area.id DESC, swtest.test_area.name, swtest.test_area.name_desc DESC - -> Hash Join - Hash Cond: (swtest.test_area.fatherid = tmp_reuslt."test_area@id") - -> Seq Scan on test_area - -> Hash - -> WorkTable Scan on tmp_reuslt -(18 rows) + -> Hash + -> WorkTable Scan on tmp_reuslt +(16 rows) -- test siblings by + limit SELECT *, LEVEL, connect_by_isleaf, connect_by_iscycle, connect_by_root(name_desc), SYS_CONNECT_BY_PATH(name, '@') cpath diff --git a/src/test/regress/sql/sw_bugfix-2.sql b/src/test/regress/sql/sw_bugfix-2.sql index f4123d438..dc269b148 100644 --- a/src/test/regress/sql/sw_bugfix-2.sql +++ b/src/test/regress/sql/sw_bugfix-2.sql @@ -644,10 +644,10 @@ SELECT * FROM RLTEST CONNECT BY PRIOR B=A AND (LEVEL=1 OR B<10) AND (ROWNUM<3 OR SELECT * FROM RLTEST CONNECT BY PRIOR B=A OR (MOD(ROWNUM+1,2) = 0); DROP TABLE RLTEST; create table nocycle_tbl(id int, lid int, name text); -insert into nocycle_tbl values (1,3,'A'),(2,1,'B'),(3,2,'C'),(4,2,'D'); -select * from nocycle_tbl connect by nocycle prior id=lid start with id=1; -select * from nocycle_tbl connect by nocycle prior id=lid start with id=1 order siblings by id; -select * from nocycle_tbl connect by nocycle prior id=lid start with id=1 order siblings by id desc; +insert into nocycle_tbl values (1,3,'A'),(2,1,'B'),(3,2,'C'),(4,2,'D'),(5,3,'E'); +select *,connect_by_iscycle from nocycle_tbl connect by nocycle prior id=lid start with id=1; +select *,connect_by_iscycle from nocycle_tbl connect by nocycle prior id=lid start with id=1 order siblings by id; +select *,connect_by_iscycle from nocycle_tbl connect by nocycle prior id=lid start with id=1 order siblings by id desc; drop table nocycle_tbl; CREATE TABLE swcb_employees ( employee_id VARCHAR, manager_id NUMBER(6));