Dead code in toast_fetch_datum_slice? - Mailing list pgsql-hackers

From Stephen Frost
Subject Dead code in toast_fetch_datum_slice?
Date
Msg-id 20181207232529.GR3415@tamriel.snowman.net
Whole thread Raw
Responses Re: Dead code in toast_fetch_datum_slice?  (Paul Ramsey <pramsey@cleverelephant.ca>)
List pgsql-hackers
Greetings,

Perhaps I'm missing something, but in toast_fetch_datum_slice() there's:

    Assert(!VARATT_EXTERNAL_IS_COMPRESSED(toast_pointer));

Followed, not long after, by:

    if (VARATT_EXTERNAL_IS_COMPRESSED(toast_pointer))
        SET_VARSIZE_COMPRESSED(result, length + VARHDRSZ);
    else
        SET_VARSIZE(result, length + VARHDRSZ);

Further, the only caller of this function today is
heap_tuple_untoast_attr_slice(), which does:

    /* fast path for non-compressed external datums */
    if (!VARATT_EXTERNAL_IS_COMPRESSED(toast_pointer))
        return toast_fetch_datum_slice(attr, sliceoffset, slicelength);

As such, I'm feeling like that conditional to handle the case where this
function is passed a compressed TOAST value is rather confusing dead
code.

Hence I'm proposing the attached.

Thoughts?

Thanks!

Stephen

Attachment

pgsql-hackers by date:

Previous
From: John Naylor
Date:
Subject: Re: Thinking about EXPLAIN ALTER TABLE
Next
From: Stephen Frost
Date:
Subject: Re: pg_dump emits ALTER TABLE ONLY partitioned_table