diff --git a/src/gausskernel/optimizer/plan/createplan.cpp b/src/gausskernel/optimizer/plan/createplan.cpp index 9ada54aa5..fbd71ad57 100755 --- a/src/gausskernel/optimizer/plan/createplan.cpp +++ b/src/gausskernel/optimizer/plan/createplan.cpp @@ -8220,7 +8220,12 @@ static Plan* parallel_limit_sort( plan = create_local_gather(plan); plan = (Plan*)make_sort_from_pathkeys(root, plan, root->sort_pathkeys, -1.0); } else { +#ifdef ENABLE_MULTIPLE_NODES plan = create_local_gather(lefttree); +#else + plan = (Plan*)make_limit(root, lefttree, limitOffset, limitCount, offset_est, count_est, false); + plan = create_local_gather(plan); +#endif } return plan; diff --git a/src/test/regress/expected/smp.out b/src/test/regress/expected/smp.out index 0090f86eb..c2de670f9 100644 --- a/src/test/regress/expected/smp.out +++ b/src/test/regress/expected/smp.out @@ -1127,6 +1127,40 @@ select * from t1 order by a limit 10 offset 20; 30 | 10 | 2 | 30 (10 rows) +-- test limit and offset +explain (costs off) select * from t1 limit 1; + QUERY PLAN +---------------------------------------------- + Limit + -> Streaming(type: LOCAL GATHER dop: 1/2) + -> Limit + -> Seq Scan on t1 +(4 rows) + +explain (costs off) select * from t1 limit 1 offset 10; + QUERY PLAN +---------------------------------------------------- + Limit + -> Limit + -> Streaming(type: LOCAL GATHER dop: 1/2) + -> Limit + -> Seq Scan on t1 +(5 rows) + +explain (costs off) select * from t1 order by 1 limit 1 offset 10; + QUERY PLAN +---------------------------------------------------------- + Limit + -> Limit + -> Sort + Sort Key: a + -> Streaming(type: LOCAL GATHER dop: 1/2) + -> Limit + -> Sort + Sort Key: a + -> Seq Scan on t1 +(9 rows) + --clean set search_path=public; drop schema test_smp cascade; diff --git a/src/test/regress/sql/smp.sql b/src/test/regress/sql/smp.sql index ad6d1efe9..765b090bb 100644 --- a/src/test/regress/sql/smp.sql +++ b/src/test/regress/sql/smp.sql @@ -61,6 +61,13 @@ select * from t1 order by a limit 10; explain (costs off) select * from t1 order by a limit 10 offset 20; select * from t1 order by a limit 10 offset 20; +-- test limit and offset +explain (costs off) select * from t1 limit 1; + +explain (costs off) select * from t1 limit 1 offset 10; + +explain (costs off) select * from t1 order by 1 limit 1 offset 10; + --clean set search_path=public; drop schema test_smp cascade;