diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2020-10-12 18:01:34 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2020-10-12 18:01:34 -0400 |
commit | 962ab473ec3d4c1090ba75fa677167126956c1ee (patch) | |
tree | b35ac0e571019ac68ffee84f4426b8b78ca88c68 /src/backend/access/gist/gistbuildbuffers.c | |
parent | 9343bfefa4514e5623cfc2610c44e3d93d776e64 (diff) | |
download | postgresql-962ab473ec3d4c1090ba75fa677167126956c1ee.tar.gz postgresql-962ab473ec3d4c1090ba75fa677167126956c1ee.zip |
Fix GiST buffering build to work when there are included columns.
gistRelocateBuildBuffersOnSplit did not get the memo about which
attribute count to use. This could lead to a crash if there were
included columns and buffering build was chosen. (Because there
are random page-split decisions elsewhere in GiST index build,
the crashes are not entirely deterministic.)
Back-patch to v12 where GiST gained support for included columns.
Pavel Borisov
Discussion: https://postgr.es/m/CALT9ZEECCV5m7wvxg46PC-7x-EybUmnpupBGhSFMoAAay+r6HQ@mail.gmail.com
Diffstat (limited to 'src/backend/access/gist/gistbuildbuffers.c')
-rw-r--r-- | src/backend/access/gist/gistbuildbuffers.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/backend/access/gist/gistbuildbuffers.c b/src/backend/access/gist/gistbuildbuffers.c index 4eab9bb83ac..4ad67c88b4e 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) |