From: Peter Geoghegan <pg@bowt.ie>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix CLUSTER tuplesorts on abbreviated expressions.
Date: Thu, 21 Apr 2022 00:18:02 +0000
Message-ID: <E1nhKWH-000LU7-PU@gemulon.postgresql.org> (raw)
Fix CLUSTER tuplesorts on abbreviated expressions.
CLUSTER sort won't use the datum1 SortTuple field when clustering
against an index whose leading key is an expression. This makes it
unsafe to use the abbreviated keys optimization, which was missed by the
logic that sets up SortSupport state. Affected tuplesorts output tuples
in a completely bogus order as a result (the wrong SortSupport based
comparator was used for the leading attribute).
This issue is similar to the bug fixed on the master branch by recent
commit cc58eecc5d. But it's a far older issue, that dates back to the
introduction of the abbreviated keys optimization by commit 4ea51cdfe8.
Backpatch to all supported versions.
Author: Peter Geoghegan <pg@bowt.ie>
Author: Thomas Munro <thomas.munro@gmail.com>
Discussion: https://postgr.es/m/CA+hUKG+bA+bmwD36_oDxAoLrCwZjVtST2fqe=b4=qZcmU7u89A@mail.gmail.com
Backpatch: 10-
Branch
------
REL_10_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/a903895b3fe49c4ceb6fbcea73e357493245771d
Modified Files
--------------
src/backend/utils/sort/tuplesort.c | 4 +-
src/test/regress/expected/cluster.out | 121 ++++++++++++++++++++++++++++++++++
src/test/regress/sql/cluster.sql | 43 ++++++++++++
3 files changed, 167 insertions(+), 1 deletion(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: pg@bowt.ie
Subject: Re: pgsql: Fix CLUSTER tuplesorts on abbreviated expressions.
In-Reply-To: <E1nhKWH-000LU7-PU@gemulon.postgresql.org>
References: <E1nhKWH-000LU7-PU@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox