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

Commit2720e96

Browse files
committed
Fix handling of sortKeys field in Tuplesortstate.
Commit5cefbf5 introduced anassumption that this field would always be non-NULL when doing a mergepass, but that's not true. Without this fix, you can crash the serverby building a hash index that is sufficiently large relative tomaintenance_work_mem, or by triggering a large datum sort.Commit5ea86e6 changed the commentsfor that field to say that it would be set in all cases except for thehash index case, but that wasn't (and still isn't) true.The datum-sort failure was spotted by Tomas Vondra; initial analysisof that failure was by Peter Geoghegan. The remaining issues werespotted by me during review of the surrounding code, and the patch isall my fault.
1 parentf1fd515 commit2720e96

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -336,9 +336,9 @@ struct Tuplesortstate
336336
boolmarkpos_eof;/* saved "eof_reached" */
337337

338338
/*
339-
* The sortKeys variable is used by every case other than thehash index
340-
*case; it is set by tuplesort_begin_xxx. tupDesc is only used by the
341-
* MinimalTuple and CLUSTER routines, though.
339+
* The sortKeys variable is used by every case other than thedatum and
340+
*hash index cases; it is set by tuplesort_begin_xxx. tupDesc is only
341+
*used by theMinimalTuple and CLUSTER routines, though.
342342
*/
343343
TupleDesctupDesc;
344344
SortSupportsortKeys;/* array of length nKeys */
@@ -1246,7 +1246,7 @@ tuplesort_putindextuplevalues(Tuplesortstate *state, Relation rel,
12461246
RelationGetDescr(state->indexRel),
12471247
&stup.isnull1);
12481248

1249-
if (!state->sortKeys->abbrev_converter||stup.isnull1)
1249+
if (!state->sortKeys|| !state->sortKeys->abbrev_converter||stup.isnull1)
12501250
{
12511251
/*
12521252
* Store ordinary Datum representation, or NULL value. If there is a
@@ -2172,7 +2172,7 @@ mergeruns(Tuplesortstate *state)
21722172
return;
21732173
}
21742174

2175-
if (state->sortKeys->abbrev_converter)
2175+
if (state->sortKeys!=NULL&&state->sortKeys->abbrev_converter!=NULL)
21762176
{
21772177
/*
21782178
* If there are multiple runs to be merged, when we go to read back

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp