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
diff --git a/src/backend/access/heap/tuptoaster.c b/src/backend/access/heap/tuptoaster.c new file mode 100644 index fdbaf38..9a63723 *** a/src/backend/access/heap/tuptoaster.c --- b/src/backend/access/heap/tuptoaster.c *************** toast_fetch_datum_slice(struct varlena * *** 2085,2094 **** result = (struct varlena *) palloc(length + VARHDRSZ); ! if (VARATT_EXTERNAL_IS_COMPRESSED(toast_pointer)) ! SET_VARSIZE_COMPRESSED(result, length + VARHDRSZ); ! else ! SET_VARSIZE(result, length + VARHDRSZ); if (length == 0) return result; /* Can save a lot of work at this point! */ --- 2085,2091 ---- result = (struct varlena *) palloc(length + VARHDRSZ); ! SET_VARSIZE(result, length + VARHDRSZ); if (length == 0) return result; /* Can save a lot of work at this point! */
signature.asc
Description: PGP signature
