Commit 6593c5b5 authored by Heikki Linnakangas's avatar Heikki Linnakangas

Fix bug in freespace calculation in heap_multi_insert().

If the amount of freespace on page was less than the amount reserved by
fillfactor, the calculation would underflow.

This fixes bug #6643 reported by Tomonari Katsumata.
parent 00b0c73f
...@@ -2159,7 +2159,7 @@ heap_multi_insert(Relation relation, HeapTuple *tuples, int ntuples, ...@@ -2159,7 +2159,7 @@ heap_multi_insert(Relation relation, HeapTuple *tuples, int ntuples,
{ {
HeapTuple heaptup = heaptuples[ndone + nthispage]; HeapTuple heaptup = heaptuples[ndone + nthispage];
if (PageGetHeapFreeSpace(page) - saveFreeSpace < MAXALIGN(heaptup->t_len)) if (PageGetHeapFreeSpace(page) < MAXALIGN(heaptup->t_len) + saveFreeSpace)
break; break;
RelationPutHeapTuple(relation, buffer, heaptup); RelationPutHeapTuple(relation, buffer, heaptup);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment