postgresql/contrib/intarray
Heikki Linnakangas 747cef5a58 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:28 +03:00
..
bench Remove extraneous newlines added by perl copyright patch 2021-05-07 11:37:37 -04:00
data 1. Fixed error with empty array ( '{}' ), 2001-08-04 19:35:32 +00:00
expected Fix another bug in parent page splitting during GiST index build. 2023-09-26 14:15:28 +03:00
sql Fix another bug in parent page splitting during GiST index build. 2023-09-26 14:15:28 +03:00
.gitignore Support "make check" in contrib 2011-04-25 22:27:11 +03:00
Makefile Remove deprecated containment operators for contrib types. 2021-03-05 10:45:41 -05:00
_int.h Implement operator class parameters 2020-03-30 19:17:23 +03:00
_int_bool.c Initial pgindent and pgperltidy run for v13. 2020-05-14 13:06:50 -04:00
_int_gin.c Make the order of the header file includes consistent in contrib modules. 2019-10-24 08:05:34 +05:30
_int_gist.c intarray: Prevent out-of-bound memory reads with gist__int_ops 2023-06-15 13:45:40 +09:00
_int_op.c Clean up newlines following left parentheses 2020-01-30 13:42:14 -03:00
_int_selfuncs.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
_int_tool.c Implement operator class parameters 2020-03-30 19:17:23 +03:00
_intbig_gist.c Remove unnecessary pfree() in g_intbig_compress(). 2023-07-13 13:08:23 -04:00
intarray--1.0--1.1.sql Add selectivity estimation functions for intarray operators. 2015-07-21 20:59:24 +03:00
intarray--1.1--1.2.sql Make contrib modules' installation scripts more secure. 2020-08-10 10:44:42 -04:00
intarray--1.2--1.3.sql Implement operator class parameters 2020-03-30 19:17:23 +03:00
intarray--1.2.sql Update extensions with GIN/GIST support for parallel query. 2016-06-14 13:34:37 -04:00
intarray--1.3--1.4.sql Remove <@ from contrib/intarray's GiST operator classes. 2020-08-08 17:26:29 -04:00
intarray--1.4--1.5.sql Remove deprecated containment operators for contrib types. 2021-03-05 10:45:41 -05:00
intarray.control Remove deprecated containment operators for contrib types. 2021-03-05 10:45:41 -05:00