From 7d962eaf50c093b4bb1d35a7b495d416a67b40e2 Mon Sep 17 00:00:00 2001 From: Andres Freund Date: Wed, 13 Nov 2019 15:57:01 -0800 Subject: [PATCH] Remove unused code from tuplesort. copytup_index() is unused, as tuplesort_putindextuplevalues() doesn't use COPYTUP(). Replace function body with an elog(ERROR), as already done e.g. for copytup_datum(). Author: Andres Freund Discussion: https://postgr.es/m/20191013144153.ooxrfglvnaocsrx2@alap3.anarazel.de --- src/backend/utils/sort/tuplesort.c | 63 +----------------------------- 1 file changed, 2 insertions(+), 61 deletions(-) diff --git a/src/backend/utils/sort/tuplesort.c b/src/backend/utils/sort/tuplesort.c index a507bd24984..7947d2bca0a 100644 --- a/src/backend/utils/sort/tuplesort.c +++ b/src/backend/utils/sort/tuplesort.c @@ -4141,67 +4141,8 @@ comparetup_index_hash(const SortTuple *a, const SortTuple *b, static void copytup_index(Tuplesortstate *state, SortTuple *stup, void *tup) { - IndexTuple tuple = (IndexTuple) tup; - unsigned int tuplen = IndexTupleSize(tuple); - IndexTuple newtuple; - Datum original; - - /* copy the tuple into sort storage */ - newtuple = (IndexTuple) MemoryContextAlloc(state->tuplecontext, tuplen); - memcpy(newtuple, tuple, tuplen); - USEMEM(state, GetMemoryChunkSpace(newtuple)); - stup->tuple = (void *) newtuple; - /* set up first-column key value */ - original = index_getattr(newtuple, - 1, - RelationGetDescr(state->indexRel), - &stup->isnull1); - - if (!state->sortKeys->abbrev_converter || stup->isnull1) - { - /* - * Store ordinary Datum representation, or NULL value. If there is a - * converter it won't expect NULL values, and cost model is not - * required to account for NULL, so in that case we avoid calling - * converter and just set datum1 to zeroed representation (to be - * consistent, and to support cheap inequality tests for NULL - * abbreviated keys). - */ - stup->datum1 = original; - } - else if (!consider_abort_common(state)) - { - /* Store abbreviated key representation */ - stup->datum1 = state->sortKeys->abbrev_converter(original, - state->sortKeys); - } - else - { - /* Abort abbreviation */ - int i; - - stup->datum1 = original; - - /* - * Set state to be consistent with never trying abbreviation. - * - * Alter datum1 representation in already-copied tuples, so as to - * ensure a consistent representation (current tuple was just - * handled). It does not matter if some dumped tuples are already - * sorted on tape, since serialized tuples lack abbreviated keys - * (TSS_BUILDRUNS state prevents control reaching here in any case). - */ - for (i = 0; i < state->memtupcount; i++) - { - SortTuple *mtup = &state->memtuples[i]; - - tuple = (IndexTuple) mtup->tuple; - mtup->datum1 = index_getattr(tuple, - 1, - RelationGetDescr(state->indexRel), - &mtup->isnull1); - } - } + /* Not currently needed */ + elog(ERROR, "copytup_index() should not be called"); } static void