Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6264cd3

Browse files
committed
In multi-insert, don't go into infinite loop on a huge tuple and fillfactor.
If a tuple is larger than page size minus space reserved for fillfactor,heap_multi_insert would never find a page that it fits in and repeatedly askfor a new page from RelationGetBufferForTuple. If a tuple is too large tofit on any page, taking fillfactor into account, RelationGetBufferForTuplewill always expand the relation. In a normal insert, heap_insert will acceptthat and put the tuple on the new page. heap_multi_insert, however, does afillfactor check of its own, and doesn't accept the newly-extended pageRelationGetBufferForTuple returns, even though there is no other choice tomake the tuple fit.Fix that by making the logic in heap_multi_insert more like the heap_insertlogic. The first tuple is always put on the page RelationGetBufferForTuplegives us, and the fillfactor check is only applied to the subsequent tuples.Report from David Gould, although I didn't use his patch.
1 parent691c5eb commit6264cd3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

‎src/backend/access/heap/heapam.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2185,8 +2185,12 @@ heap_multi_insert(Relation relation, HeapTuple *tuples, int ntuples,
21852185
/* NO EREPORT(ERROR) from here till changes are logged */
21862186
START_CRIT_SECTION();
21872187

2188-
/* Put as many tuples as fit on this page */
2189-
for (nthispage=0;ndone+nthispage<ntuples;nthispage++)
2188+
/*
2189+
* RelationGetBufferForTuple has ensured that the first tuple fits.
2190+
* Put that on the page, and then as many other tuples as fit.
2191+
*/
2192+
RelationPutHeapTuple(relation,buffer,heaptuples[ndone]);
2193+
for (nthispage=1;ndone+nthispage<ntuples;nthispage++)
21902194
{
21912195
HeapTupleheaptup=heaptuples[ndone+nthispage];
21922196

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp