postgresql/src
David Rowley 16dfe253e3 Fix hypothetical bug in heap backward scans
Both heapgettup() and heapgettup_pagemode() incorrectly set the first page
to scan in a backward scan in which the number of pages to scan was
specified by heap_setscanlimits().  The code incorrectly started the scan
at the end of the relation when startBlk was 0, or otherwise at
startBlk - 1, neither of which is correct when only scanning a subset of
pages.

The fix here checks if heap_setscanlimits() has changed the number of
pages to scan and if so we set the first page to scan as the final page in
the specified range during backward scans.

Proper adjustment of this code was forgotten when heap_setscanlimits() was
added in 7516f5259 back in 9.5.  However, practice, nowhere in core code
performs backward scans after having used heap_setscanlimits(), yet, it is
possible an extension uses the heap functions in this way, hence
backpatch.

An upcoming patch does use heap_setscanlimits() with backward scans, so
this must be fixed before that can go in.

Author: David Rowley
Discussion: https://postgr.es/m/CAApHDvpGc9h0_oVD2CtgBcxCS1N-qDYZSeBRnUh+0CWJA9cMaA@mail.gmail.com
Backpatch-through: 9.5, all supported versions
2021-01-25 19:52:18 +13:00
..
backend Fix hypothetical bug in heap backward scans 2021-01-25 19:52:18 +13:00
bin Avoid redundantly prefixing PQerrorMessage for a connection failure. 2021-01-22 16:52:31 -05:00
common Introduce SHA1 implementations in the cryptohash infrastructure 2021-01-23 11:33:04 +09:00
fe_utils Update copyright for 2021 2021-01-02 13:06:25 -05:00
include Make storage/standby.h compile standalone again. 2021-01-24 18:08:55 -05:00
interfaces Update ecpg's connect-test1 for connection-failure message changes. 2021-01-23 15:08:39 -05:00
makefiles Remove libpq.rc, use win32ver.rc for libpq 2020-01-15 15:06:12 +01:00
pl Fix plpgsql tests for debug_invalidate_system_caches_always. 2021-01-08 18:12:07 -05:00
port Move our p{read,write}v replacements into their own files. 2021-01-14 11:16:59 +13:00
template Further tweaking of PG_SYSROOT heuristics for macOS. 2021-01-20 12:07:23 -05:00
test Fix ALTER PUBLICATION...DROP TABLE behavior. 2021-01-25 07:39:29 +05:30
timezone Update time zone data files to tzdata release 2021a. 2021-01-24 16:29:47 -05:00
tools Remove make_diff set of tools 2021-01-24 14:19:00 +01:00
tutorial Doc, more or less: uncomment tutorial example that was fixed long ago. 2021-01-13 16:00:03 -05:00
.gitignore
DEVELOPERS
Makefile Remove the option to build thread_test.c outside configure. 2020-10-21 12:08:48 -04:00
Makefile.global.in Introduce SHA1 implementations in the cryptohash infrastructure 2021-01-23 11:33:04 +09:00
Makefile.shlib Add PostgreSQL home page to --help output 2020-02-28 13:12:21 +01:00
nls-global.mk NLS: Fix backend gettext triggers 2019-09-23 09:04:20 +02:00