mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-30 19:00:29 +08:00
During index build, check and elog (not just Assert) for broken HOT chain.
The recently-fixed bug in WAL replay could result in not finding a parent tuple for a heap-only tuple. The existing code would either Assert or generate an invalid index entry, neither of which is desirable. Throw a regular error instead.
This commit is contained in:
parent
d663d4399e
commit
d70cf811f7
@ -2438,7 +2438,10 @@ IndexBuildHeapScan(Relation heapRelation,
|
||||
rootTuple = *heapTuple;
|
||||
offnum = ItemPointerGetOffsetNumber(&heapTuple->t_self);
|
||||
|
||||
Assert(OffsetNumberIsValid(root_offsets[offnum - 1]));
|
||||
if (!OffsetNumberIsValid(root_offsets[offnum - 1]))
|
||||
elog(ERROR, "failed to find parent tuple for heap-only tuple at (%u,%u) in table \"%s\"",
|
||||
ItemPointerGetBlockNumber(&heapTuple->t_self),
|
||||
offnum, RelationGetRelationName(heapRelation));
|
||||
|
||||
ItemPointerSetOffsetNumber(&rootTuple.t_self,
|
||||
root_offsets[offnum - 1]);
|
||||
@ -2856,7 +2859,11 @@ validate_index_heapscan(Relation heapRelation,
|
||||
if (HeapTupleIsHeapOnly(heapTuple))
|
||||
{
|
||||
root_offnum = root_offsets[root_offnum - 1];
|
||||
Assert(OffsetNumberIsValid(root_offnum));
|
||||
if (!OffsetNumberIsValid(root_offnum))
|
||||
elog(ERROR, "failed to find parent tuple for heap-only tuple at (%u,%u) in table \"%s\"",
|
||||
ItemPointerGetBlockNumber(heapcursor),
|
||||
ItemPointerGetOffsetNumber(heapcursor),
|
||||
RelationGetRelationName(heapRelation));
|
||||
ItemPointerSetOffsetNumber(&rootTuple, root_offnum);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user