pgsql: Simplify loop logic in nodeIncrementalSort.c.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Simplify loop logic in nodeIncrementalSort.c.
Date: 2021-02-15 15:18:13
Message-ID: E1lBfdd-0002wQ-Vy@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Simplify loop logic in nodeIncrementalSort.c.

The inner loop in switchToPresortedPrefixMode() can be implemented
as a conventional integer-counter for() loop, removing a couple of
redundant boolean state variables. The old logic here was a remnant
of earlier development, but as things now stand there's no reason
for extra complexity.

Also, annotate the test case added by 82e0e2930 to explain why it
manages to hit the corner case fixed in that commit, and add an
EXPLAIN to verify that it's creating an incremental-sort plan.

Back-patch to v13, like the previous patch.

James Coleman and Tom Lane

Discussion: https://postgr.es/m/16846-ae49f51ac379a4cb@postgresql.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/0e5290312851557ee24e3d6103baf14d6066695c

Modified Files
--------------
src/backend/executor/nodeIncrementalSort.c | 45 +++++++-------------------
src/test/regress/expected/incremental_sort.out | 15 +++++++++
src/test/regress/sql/incremental_sort.sql | 4 +++
3 files changed, 30 insertions(+), 34 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2021-02-15 15:18:14 pgsql: Simplify loop logic in nodeIncrementalSort.c.
Previous Message Amit Kapila 2021-02-15 10:35:59 Re: pgsql: Allow multiple xacts during table sync in logical replication.