Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit10fcb83

Browse files
committed
Fix YA incremental sort bug.
switchToPresortedPrefixMode() did the wrong thing if it detecteda batch boundary just at the last tuple of a fullsort group.The initially-reported symptom was a "retrieved too many tuples in abounded sort" error, but the test case added here just silently givesthe wrong answer without this patch.I (tgl) am not really happy about committing this patch without reviewfrom the incremental-sort authors, but they seem AWOL and we are hardagainst a release deadline. This does demonstrably make some casesbetter, anyway.Per bug #16846 from Yoran Heling. Back-patch to v13 where incrementalsort was introduced.Neil ChenDiscussion:https://postgr.es/m/16846-ae49f51ac379a4cb@postgresql.org
1 parent57868d9 commit10fcb83

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

‎src/backend/executor/nodeIncrementalSort.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,13 @@ switchToPresortedPrefixMode(PlanState *pstate)
394394
* current prefix key group.
395395
*/
396396
ExecClearTuple(node->group_pivot);
397+
398+
/*
399+
* Also make sure we take the didn't-consume-all-the-tuples
400+
* path below, even if this happened to be the last tuple of
401+
* the batch.
402+
*/
403+
lastTuple= false;
397404
break;
398405
}
399406
}

‎src/test/regress/expected/incremental_sort.out

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,17 @@ select * from (select * from t order by a) s order by a, b limit 70;
675675
9 | 70
676676
(70 rows)
677677

678+
-- Checks case where we hit a group boundary at the last tuple of a batch.
679+
select * from (select * from t order by a) s order by a, b limit 5;
680+
a | b
681+
---+---
682+
1 | 1
683+
2 | 2
684+
3 | 3
685+
4 | 4
686+
9 | 5
687+
(5 rows)
688+
678689
-- Test rescan.
679690
begin;
680691
-- We force the planner to choose a plan with incremental sort on the right side

‎src/test/regress/sql/incremental_sort.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ insert into t(a, b) select (case when i < 5 then i else 9 end), i from generate_
149149
analyze t;
150150
explain (costs off)select*from (select*from torder by a) sorder by a, blimit70;
151151
select*from (select*from torder by a) sorder by a, blimit70;
152+
-- Checks case where we hit a group boundary at the last tuple of a batch.
153+
select*from (select*from torder by a) sorder by a, blimit5;
154+
152155
-- Test rescan.
153156
begin;
154157
-- We force the planner to choose a plan with incremental sort on the right side

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp