Subject: pgsql: Relax assertion in finding correct GiST parent

From: Heikki Linnakangas <[email-masked]>
Date: Fri, 04 Apr 2025 11:04:49 +0000

Relax assertion in finding correct GiST parent

Commit 28d3c2ddcf introduced an assertion that if the memorized
downlink location in the insertion stack isn't valid, the parent's
LSN should've changed too. Turns out that was too strict. In
gistFindCorrectParent(), if we walk right, we update the parent's
block number and clear its memorized 'downlinkoffnum'. That triggered
the assertion on next call to gistFindCorrectParent(), if the parent
needed to be split too. Relax the assertion, so that it's OK if
downlinkOffnum is InvalidOffsetNumber.

Backpatch to v13-, all supported versions. The assertion was added in
commit 28d3c2ddcf in v12.

Reported-by: Alexander Lakhin <[email-masked]>
Reviewed-by: Tender Wang <[email-masked]>
Discussion: https://www.postgresql.org/message-id/[email-masked]

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/41932139882e20724c6a0a8c0363b26211793c36

Modified Files
--------------
src/backend/access/gist/gist.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)