postgresql/src/backend/utils
Peter Geoghegan 1272630a24 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-
2022-04-20 17:17:39 -07:00
..
adt Disallow infinite endpoints in generate_series() for timestamps. 2022-04-20 18:08:15 -04:00
cache Don't call fwrite() with len == 0 when writing out relcache init file. 2022-03-23 13:13:20 -07:00
error Log the location field before any backtrace 2020-07-10 08:31:48 +02:00
fmgr Fix broken ruleutils support for function TRANSFORM clauses. 2021-01-25 13:03:11 -05:00
hash Initial pgindent and pgperltidy run for v13. 2020-05-14 13:06:50 -04:00
init Suppress warning about stack_base_ptr with late-model GCC. 2022-02-17 22:45:34 -05:00
mb Dial back -Wimplicit-fallthrough to level 3 2020-05-13 15:31:14 -04:00
misc Fix breakage of get_ps_display() in the PS_USE_NONE case. 2022-03-27 12:57:57 -04:00
mmgr Fix Portal snapshot tracking to handle subtransactions properly. 2021-10-01 11:10:12 -04:00
resowner Improve performance of "simple expressions" in PL/pgSQL. 2020-03-26 18:58:57 -04:00
sort Fix CLUSTER tuplesorts on abbreviated expressions. 2022-04-20 17:17:39 -07:00
time Clean up assorted failures under clang's -fsanitize=undefined checks. 2022-03-03 18:13:24 -05:00
.gitignore Rearrange makefile rules for running Gen_fmgrtab.pl. 2018-05-03 17:54:18 -04:00
errcodes.txt Make SQL/JSON error code names match SQL standard 2020-04-30 09:34:54 +02:00
Gen_dummy_probes.pl Emit dummy statements for probes.d probes when disabled 2021-05-10 13:56:21 +02:00
Gen_dummy_probes.sed Emit dummy statements for probes.d probes when disabled 2021-05-10 13:56:21 +02:00
Gen_fmgrtab.pl Use perl warnings pragma consistently 2020-04-13 11:55:45 -04:00
generate-errcodes.pl Update copyrights for 2020 2020-01-01 12:21:45 -05:00
Makefile Update copyrights for 2020 2020-01-01 12:21:45 -05:00
probes.d Update copyrights for 2020 2020-01-01 12:21:45 -05:00