0001-Fix-for-the-case-of-GiST-buffered-build-of-index-wit.patch

application/octet-stream

Filename: 0001-Fix-for-the-case-of-GiST-buffered-build-of-index-wit.patch
Type: application/octet-stream
Part: 1
Message: Re: BUG #16329: Valgrind detects an invalid read when building a gist index with buffering

Patch

Format: format-patch
Series: patch 0001
Subject: Fix for the case of GiST buffered build of index with INCLUDE clause
File+
src/backend/access/gist/gistbuildbuffers.c 2 2
From be5285b754bc02b02c8f468c6a949606a3f8c465 Mon Sep 17 00:00:00 2001
From: Pavel Borisov <pashkin.elfe@gmail.com>
Date: Mon, 12 Oct 2020 15:36:37 +0400
Subject: [PATCH 1/2] Fix for the case of GiST buffered build of index with
 INCLUDE clause

---
 src/backend/access/gist/gistbuildbuffers.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/backend/access/gist/gistbuildbuffers.c b/src/backend/access/gist/gistbuildbuffers.c
index 4eab9bb83a..4ad67c88b4 100644
--- a/src/backend/access/gist/gistbuildbuffers.c
+++ b/src/backend/access/gist/gistbuildbuffers.c
@@ -666,7 +666,7 @@ gistRelocateBuildBuffersOnSplit(GISTBuildBuffers *gfbb, GISTSTATE *giststate,
 			zero_penalty = true;
 
 			/* Loop over index attributes. */
-			for (j = 0; j < r->rd_att->natts; j++)
+			for (j = 0; j < IndexRelationGetNumberOfKeyAttributes(r); j++)
 			{
 				float		usize;
 
@@ -692,7 +692,7 @@ gistRelocateBuildBuffersOnSplit(GISTBuildBuffers *gfbb, GISTSTATE *giststate,
 					which = i;
 					best_penalty[j] = usize;
 
-					if (j < r->rd_att->natts - 1)
+					if (j < IndexRelationGetNumberOfKeyAttributes(r) - 1)
 						best_penalty[j + 1] = -1;
 				}
 				else if (best_penalty[j] == usize)
-- 
2.28.0