Commit 9f03ca915 removed the only COPYTUP() call that could reach copytup_index() in practice, making copytup_index() dead code.
The attached patch removes this dead code, in line with the existing copytup_datum() case, where tuplesort.c also doesn't directly support COPYTUP() (due to similar considerations around memory management). -- Peter Geoghegan
From 8b2c0d3b1844caaf144971f488201e806c7fcc5e Mon Sep 17 00:00:00 2001 From: Peter Geoghegan <p...@bowt.ie> Date: Thu, 23 Jun 2016 18:51:37 -0700 Subject: [PATCH] Remove dead COPYTUP routine in tuplesort.c Commit 9f03ca915 made copytup_index() dead code. Remove its body, and leave only a defensive stub implementation. --- 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 7878660..26eeab6 100644 --- a/src/backend/utils/sort/tuplesort.c +++ b/src/backend/utils/sort/tuplesort.c @@ -4492,67 +4492,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), - &stup->isnull1); - } - } + /* Not currently needed */ + elog(ERROR, "copytup_index() should not be called"); } static void -- 2.7.4
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers