Dead code in toast_fetch_datum_slice?

From: Stephen Frost <sfrost(at)snowman(dot)net>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Dead code in toast_fetch_datum_slice?
Date: 2018-12-07 23:25:29
Message-ID: 20181207232529.GR3415@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 Content-Type Size
fix-dead-toast-datum-slice-v1_master.patch text/x-diff 821 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephen Frost 2018-12-08 00:17:36 Re: pg_dump emits ALTER TABLE ONLY partitioned_table
Previous Message John Naylor 2018-12-07 23:22:12 Re: Thinking about EXPLAIN ALTER TABLE