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