Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e42b3c3

Browse files
Fix GiST index deletion assert issue.
Avoid calling heap_index_delete_tuples() with an empty deltids array to avoid an assertion failure. This issue was arguably an oversight in commit b5f58cf, though the failing assert itself was added by my recent commit d168b66. No backpatch, though, since the oversight is harmless in the back branches. Author: Peter Geoghegan <pg@bowt.ie> Reported-By: Jaime Casanova <jcasanov@systemguards.com.ec> Discussion: https://postgr.es/m/CAJKUy5jscES84n3puE=sYngyF+zpb4wv8UMtuLnLPv5z=6yyNw@mail.gmail.com
1 parent 32bef75 commit e42b3c3

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/backend/access/gist/gist.c

+7-6
Original file line numberDiff line numberDiff line change
@@ -1645,7 +1645,6 @@ gistprunepage(Relation rel, Page page, Buffer buffer, Relation heapRel)
16451645
int ndeletable = 0;
16461646
OffsetNumber offnum,
16471647
maxoff;
1648-
TransactionId latestRemovedXid = InvalidTransactionId;
16491648

16501649
Assert(GistPageIsLeaf(page));
16511650

@@ -1664,13 +1663,15 @@ gistprunepage(Relation rel, Page page, Buffer buffer, Relation heapRel)
16641663
deletable[ndeletable++] = offnum;
16651664
}
16661665

1667-
if (XLogStandbyInfoActive() && RelationNeedsWAL(rel))
1668-
latestRemovedXid =
1669-
index_compute_xid_horizon_for_tuples(rel, heapRel, buffer,
1670-
deletable, ndeletable);
1671-
16721666
if (ndeletable > 0)
16731667
{
1668+
TransactionId latestRemovedXid = InvalidTransactionId;
1669+
1670+
if (XLogStandbyInfoActive() && RelationNeedsWAL(rel))
1671+
latestRemovedXid =
1672+
index_compute_xid_horizon_for_tuples(rel, heapRel, buffer,
1673+
deletable, ndeletable);
1674+
16741675
START_CRIT_SECTION();
16751676

16761677
PageIndexMultiDelete(page, deletable, ndeletable);

src/backend/access/index/genam.c

+2
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,8 @@ index_compute_xid_horizon_for_tuples(Relation irel,
301301
Page ipage = BufferGetPage(ibuf);
302302
IndexTuple itup;
303303

304+
Assert(nitems > 0);
305+
304306
delstate.bottomup = false;
305307
delstate.bottomupfreespace = 0;
306308
delstate.ndeltids = 0;

0 commit comments

Comments
 (0)