Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 48b9ca0

Browse files
committed
Fix possible sorting error when aborting use of abbreviated keys.
Due to an error in the abbreviated key abort logic, the most recently processed SortTuple could be incorrectly marked NULL, resulting in an incorrect final sort order. In the worst case, this could result in a corrupt btree index, which would need to be rebuild using REINDEX. However, abbrevation doesn't abort very often, not all data types use it, and only one tuple would end up in the wrong place, so the practical impact of this mistake may be somewhat limited. Report and patch by Peter Geoghegan.
1 parent c381326 commit 48b9ca0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/backend/utils/sort/tuplesort.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -1443,7 +1443,7 @@ tuplesort_putindextuplevalues(Tuplesortstate *state, Relation rel,
14431443
mtup->datum1 = index_getattr(tuple,
14441444
1,
14451445
RelationGetDescr(state->indexRel),
1446-
&stup.isnull1);
1446+
&mtup->isnull1);
14471447
}
14481448
}
14491449

@@ -4271,7 +4271,7 @@ copytup_cluster(Tuplesortstate *state, SortTuple *stup, void *tup)
42714271
mtup->datum1 = heap_getattr(tuple,
42724272
state->indexInfo->ii_KeyAttrNumbers[0],
42734273
state->tupDesc,
4274-
&stup->isnull1);
4274+
&mtup->isnull1);
42754275
}
42764276
}
42774277
}
@@ -4588,7 +4588,7 @@ copytup_index(Tuplesortstate *state, SortTuple *stup, void *tup)
45884588
mtup->datum1 = index_getattr(tuple,
45894589
1,
45904590
RelationGetDescr(state->indexRel),
4591-
&stup->isnull1);
4591+
&mtup->isnull1);
45924592
}
45934593
}
45944594
}

0 commit comments

Comments
 (0)