diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2021-03-22 14:01:20 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2021-03-22 14:01:20 -0400 |
commit | 063dd37ebc7644e8db6419565b50dca019e69e86 (patch) | |
tree | b76475f5aa8f96a3ce81c2e1f34ab671070e06ac /src/include/access/toast_internals.h | |
parent | aeb1631ed207cef2d80e20f79eb52c72f03bca7d (diff) |
Short-circuit slice requests that are for more than the object's size.
substring(), and perhaps other callers, isn't careful to pass a
slice length that is no more than the datum's true size. Since
toast_decompress_datum_slice's children will palloc the requested
slice length, this can waste memory. Also, close study of the liblz4
documentation suggests that it is dependent on the caller to not ask
for more than the correct amount of decompressed data; this squares
with observed misbehavior with liblz4 1.8.3. Avoid these problems
by switching to the normal full-decompression code path if the
slice request is >= datum's decompressed size.
Tom Lane and Dilip Kumar
Discussion: https://postgr.es/m/507597.1616370729@sss.pgh.pa.us
Diffstat (limited to 'src/include/access/toast_internals.h')
-rw-r--r-- | src/include/access/toast_internals.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/include/access/toast_internals.h b/src/include/access/toast_internals.h index bf118f04829..1c28b07c4dd 100644 --- a/src/include/access/toast_internals.h +++ b/src/include/access/toast_internals.h @@ -31,6 +31,8 @@ typedef struct toast_compress_header * Utilities for manipulation of header information for compressed * toast entries. */ +#define TOAST_COMPRESS_EXTSIZE(ptr) \ + (((toast_compress_header *) (ptr))->tcinfo & VARLENA_EXTSIZE_MASK) #define TOAST_COMPRESS_METHOD(ptr) \ (((toast_compress_header *) (ptr))->tcinfo >> VARLENA_EXTSIZE_BITS) |