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

Commit80cadb3

Browse files
committed
Prevent sorting from requesting a SortTuple array that exceeds MaxAllocSize;
we'll go over to disk-based sort if we reach that limit.This fixes Stefan Kaltenbrunner's observation that sorting can suffer an'invalid memory alloc request size' failure when sort_mem is set largeenough. It's unfortunately not so easy to fix in 8.1 ...
1 parentb3d0442 commit80cadb3

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

‎src/backend/utils/sort/tuplesort.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
* Portions Copyright (c) 1994, Regents of the University of California
9292
*
9393
* IDENTIFICATION
94-
* $PostgreSQL: pgsql/src/backend/utils/sort/tuplesort.c,v 1.60 2006/02/26 22:58:12 tgl Exp $
94+
* $PostgreSQL: pgsql/src/backend/utils/sort/tuplesort.c,v 1.61 2006/03/04 19:05:06 tgl Exp $
9595
*
9696
*-------------------------------------------------------------------------
9797
*/
@@ -741,6 +741,13 @@ grow_memtuples(Tuplesortstate *state)
741741
*/
742742
if (state->availMem <= (long) (state->memtupsize*sizeof(SortTuple)))
743743
return false;
744+
/*
745+
* On a 64-bit machine, allowedMem could be high enough to get us into
746+
* trouble with MaxAllocSize, too.
747+
*/
748+
if ((Size) (state->memtupsize*2) >=MaxAllocSize /sizeof(SortTuple))
749+
return false;
750+
744751
FREEMEM(state,GetMemoryChunkSpace(state->memtuples));
745752
state->memtupsize *=2;
746753
state->memtuples= (SortTuple*)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp