]> granicus.if.org Git - postgresql/commitdiff
Remove dead code in toast_fetch_datum_slice
authorStephen Frost <sfrost@snowman.net>
Mon, 10 Dec 2018 14:31:38 +0000 (09:31 -0500)
committerStephen Frost <sfrost@snowman.net>
Mon, 10 Dec 2018 14:31:38 +0000 (09:31 -0500)
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.

src/backend/access/heap/tuptoaster.c

index fdbaf38126d99d0c3ba554fc01063a2f44634277..d1dad998d28c9053a262212ca301e30a5ffb544f 100644 (file)
@@ -2026,6 +2026,8 @@ toast_fetch_datum(struct varlena *attr)
  *
  *     Reconstruct a segment of a Datum from the chunks saved
  *     in the toast relation
+ *
+ *     Note that this function only supports non-compressed external datums.
  * ----------
  */
 static struct varlena *
@@ -2085,10 +2087,7 @@ toast_fetch_datum_slice(struct varlena *attr, int32 sliceoffset, int32 length)
 
        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);
+       SET_VARSIZE(result, length + VARHDRSZ);
 
        if (length == 0)
                return result;                  /* Can save a lot of work at this point! */