Skip to content

Commit 96c702c

Browse files
committed
Remove dead code in toast_fetch_datum_slice
In toast_fetch_datum_slice(), we Assert() that what is passed in isn't compressed, but we then later had a check to see what the length of if what was passed in is compressed. That later check is rather confusing since toast_fetch_datum_slice() is only ever called with non-compressed datums and the Assert() earlier makes it clear that one shouldn't be passing in compressed datums. Add a comment to make it clear that toast_fetch_datum_slice() is just for non-compressed datums, and remove the dead code.
1 parent 6d8727f commit 96c702c

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/backend/access/heap/tuptoaster.c

+3-4
Original file line numberDiff line numberDiff line change
@@ -2026,6 +2026,8 @@ toast_fetch_datum(struct varlena *attr)
20262026
*
20272027
* Reconstruct a segment of a Datum from the chunks saved
20282028
* in the toast relation
2029+
*
2030+
* Note that this function only supports non-compressed external datums.
20292031
* ----------
20302032
*/
20312033
static struct varlena *
@@ -2085,10 +2087,7 @@ toast_fetch_datum_slice(struct varlena *attr, int32 sliceoffset, int32 length)
20852087

20862088
result = (struct varlena *) palloc(length + VARHDRSZ);
20872089

2088-
if (VARATT_EXTERNAL_IS_COMPRESSED(toast_pointer))
2089-
SET_VARSIZE_COMPRESSED(result, length + VARHDRSZ);
2090-
else
2091-
SET_VARSIZE(result, length + VARHDRSZ);
2090+
SET_VARSIZE(result, length + VARHDRSZ);
20922091

20932092
if (length == 0)
20942093
return result; /* Can save a lot of work at this point! */

0 commit comments

Comments
 (0)