postgresql/src/backend
Heikki Linnakangas c3c284b379 Fix another bug in parent page splitting during GiST index build.
Yet another bug in the ilk of commits a7ee7c851 and 741b88435. In
741b88435, we took care to clear the memorized location of the
downlink when we split the parent page, because splitting the parent
page can move the downlink. But we missed that even *updating* a tuple
on the parent can move it, because updating a tuple on a gist page is
implemented as a delete+insert, so the updated tuple gets moved to the
end of the page.

This commit fixes the bug in two different ways (belt and suspenders):

1. Clear the downlink when we update a tuple on the parent page, even
   if it's not split. This the same approach as in commits a7ee7c851
   and 741b88435.

   I also noticed that gistFindCorrectParent did not clear the
   'downlinkoffnum' when it stepped to the right sibling. Fix that
   too, as it seems like a clear bug even though I haven't been able
   to find a test case to hit that.

2. Change gistFindCorrectParent so that it treats 'downlinkoffnum'
   merely as a hint. It now always first checks if the downlink is
   still at that location, and if not, it scans the page like before.
   That's more robust if there are still more cases where we fail to
   clear 'downlinkoffnum' that we haven't yet uncovered. With this,
   it's no longer necessary to meticulously clear 'downlinkoffnum',
   so this makes the previous fixes unnecessary, but I didn't revert
   them because it still seems nice to clear it when we know that the
   downlink has moved.

Also add the test case using the same test data that Alexander
posted. I tried to reduce it to a smaller test, and I also tried to
reproduce this with different test data, but I was not able to, so
let's just include what we have.

Backpatch to v12, like the previous fixes.

Reported-by: Alexander Lakhin
Discussion: https://www.postgresql.org/message-id/18129-caca016eaf0c3702@postgresql.org
2023-09-26 14:15:19 +03:00
..
access Fix another bug in parent page splitting during GiST index build. 2023-09-26 14:15:19 +03:00
backup In basebackup.c, perform end-of-file test after checksum validation. 2023-03-06 10:20:17 -05:00
bootstrap Process session_preload_libraries within InitPostgres's transaction. 2022-07-25 10:27:43 -04:00
catalog Recalculate search_path after ALTER ROLE. 2023-08-07 15:12:49 -07:00
commands Reject substituting extension schemas or owners matching ["$'\]. 2023-08-07 06:06:00 -07:00
executor Fix RLS policy usage in MERGE. 2023-08-07 09:24:27 +01:00
foreign Rename SetSingleFuncCall() to InitMaterializedSRF() 2022-10-18 10:22:40 +09:00
jit Fix leak of LLVM "fatal-on-oom" section counter. 2023-07-05 13:13:30 +03:00
lib
libpq Avoid potential pfree on NULL on OpenSSL errors 2023-09-22 11:18:25 +02:00
main Fix outdated --help message for postgres -f 2022-08-15 13:37:32 +09:00
nodes Remove inappropriate raw_expression_tree_walker() code 2023-06-29 10:35:35 +02:00
optimizer Collect dependency information for parsed CallStmts. 2023-09-25 14:41:57 -04:00
parser Track nesting depth correctly when drilling down into RECORD Vars. 2023-09-15 17:01:26 -04:00
partitioning Fix incorrect partition pruning logic for boolean partitioned tables 2023-04-14 16:21:07 +12:00
po Translation updates 2023-08-07 12:39:07 +02:00
port
postmaster Initialize ListenSocket array earlier. 2023-08-29 09:12:35 +03:00
regex Avoid character classification in regex escape parsing. 2023-04-21 08:20:17 -07:00
replication Fix uninitialized access to InitialRunningXacts during decoding after ERROR. 2023-09-12 10:23:17 +05:30
rewrite Fix RLS policy usage in MERGE. 2023-08-07 09:24:27 +01:00
snowball In the Snowball dictionary, don't try to stem excessively-long words. 2022-08-31 10:42:05 -04:00
statistics Remove unnecessary code in dependency_is_compatible_expression(). 2023-03-14 11:10:45 -04:00
storage Invalidate smgr_targblock in smgrrelease(). 2023-08-17 15:54:31 +12:00
tcop Be more rigorous about local variables in PostgresMain(). 2023-07-10 12:14:34 -04:00
tsearch Limit to_tsvector_byid's initial array allocation to something sane. 2023-09-25 11:50:28 -04:00
utils Fix behavior of "force" in pgstat_report_wal() 2023-09-26 09:30:39 +09:00
.gitignore
common.mk
Makefile Move basebackup code to new directory src/backend/backup 2022-08-10 14:03:09 -04:00
nls.mk Translation updates 2022-11-07 14:04:05 +01:00