8000 Fix possible sorting error when aborting use of abbreviated keys. · patchsoft/postgres@da9659f · GitHub
[go: up one dir, main page]

Skip to content

Commit da9659f

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 ac3aac3 commit da9659f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/backend/utils/sort/tuplesort.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,7 +1314,7 @@ tuplesort_putindextuplevalues(Tuplesortstate *state, Relation rel,
13141314
mtup->datum1 = index_getattr(tuple,
13151315
1,
13161316
RelationGetDescr(state->indexRel),
1317-
&stup.isnull1);
1317+
&mtup->isnull1);
13181318
}
13191319
}
13201320

@@ -3440,7 +3440,7 @@ copytup_cluster(Tuplesortstate *state, SortTuple *stup, void *tup)
34403440
mtup->datum1 = heap_getattr(tuple,
34413441
state->indexInfo->ii_KeyAttrNumbers[0],
34423442
state->tupDesc,
3443-
&stup->isnull1);
3443+
&mtup->isnull1);
34443444
}
34453445
}
34463446
}
@@ -3744,7 +3744,7 @@ copytup_index(Tuplesortstate *state, SortTuple *stup, void *tup)
37443744
mtup->datum1 = index_getattr(tuple,
37453745
1,
37463746
RelationGetDescr(state->indexRel),
3747-
&stup->isnull1);
3747+
&mtup->isnull1);
37483748
}
37493749
}
37503750
}

0 commit comments

Comments
 (0)
0