summaryrefslogtreecommitdiff
path: root/src/backend/access/gist/gist.c
diff options
context:
space:
mode:
authorPeter Geoghegan <pg@bowt.ie>2021-01-26 23:24:37 -0800
committerPeter Geoghegan <pg@bowt.ie>2021-01-26 23:24:37 -0800
commite42b3c3bd6a9c6233ac4c8a2e9b040367ba2f97c (patch)
treee000b8f0652d74c7717e4be6657f3f23d4c52e5b /src/backend/access/gist/gist.c
parent32bef758296142ce0fff944c3478d63fdefdaf33 (diff)
downloadpostgresql-e42b3c3bd6a9c6233ac4c8a2e9b040367ba2f97c.tar.gz
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 b5f58cf2, though the failing assert itself was added by my recent commit d168b666. 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
Diffstat (limited to 'src/backend/access/gist/gist.c')
-rw-r--r--src/backend/access/gist/gist.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/backend/access/gist/gist.c b/src/backend/access/gist/gist.c
index f203bb594c..0683f42c25 100644
--- a/src/backend/access/gist/gist.c
+++ b/src/backend/access/gist/gist.c
@@ -1645,7 +1645,6 @@ gistprunepage(Relation rel, Page page, Buffer buffer, Relation heapRel)
int ndeletable = 0;
OffsetNumber offnum,
maxoff;
- TransactionId latestRemovedXid = InvalidTransactionId;
Assert(GistPageIsLeaf(page));
@@ -1664,13 +1663,15 @@ gistprunepage(Relation rel, Page page, Buffer buffer, Relation heapRel)
deletable[ndeletable++] = offnum;
}
- if (XLogStandbyInfoActive() && RelationNeedsWAL(rel))
- latestRemovedXid =
- index_compute_xid_horizon_for_tuples(rel, heapRel, buffer,
- deletable, ndeletable);
-
if (ndeletable > 0)
{
+ TransactionId latestRemovedXid = InvalidTransactionId;
+
+ if (XLogStandbyInfoActive() && RelationNeedsWAL(rel))
+ latestRemovedXid =
+ index_compute_xid_horizon_for_tuples(rel, heapRel, buffer,
+ deletable, ndeletable);
+
START_CRIT_SECTION();
PageIndexMultiDelete(page, deletable, ndeletable);