mirror of
https://github.com/postgres/postgres.git
synced 2025-10-22 14:32:25 +03:00
Mostly-cosmetic adjustments of TOAST-related macros.
The authors of bbe0a81db
hadn't quite got the idea that macros named
like SOMETHING_4B_C were only meant for internal endianness-related
details in postgres.h. Choose more legible names for macros that are
intended to be used elsewhere. Rearrange postgres.h a bit to clarify
the separation between those internal macros and ones intended for
wider use.
Also, avoid using the term "rawsize" for true decompressed size;
we've used "extsize" for that, because "rawsize" generally denotes
total Datum size including header. This choice seemed particularly
unfortunate in tests that were comparing one of these meanings to
the other.
This patch includes a couple of not-purely-cosmetic changes: be
sure that the shifts aligning compression methods are unsigned
(not critical today, but will be when compression method 2 exists),
and fix broken definition of VARATT_EXTERNAL_GET_COMPRESSION (now
VARATT_EXTERNAL_GET_COMPRESS_METHOD), whose callers worked only
accidentally.
Discussion: https://postgr.es/m/574197.1616428079@sss.pgh.pa.us
This commit is contained in:
@@ -24,22 +24,23 @@ typedef struct toast_compress_header
|
||||
{
|
||||
int32 vl_len_; /* varlena header (do not touch directly!) */
|
||||
uint32 tcinfo; /* 2 bits for compression method and 30 bits
|
||||
* rawsize */
|
||||
* external size; see va_extinfo */
|
||||
} toast_compress_header;
|
||||
|
||||
/*
|
||||
* Utilities for manipulation of header information for compressed
|
||||
* toast entries.
|
||||
*/
|
||||
#define TOAST_COMPRESS_METHOD(ptr) \
|
||||
(((toast_compress_header *) (ptr))->tcinfo >> VARLENA_RAWSIZE_BITS)
|
||||
#define TOAST_COMPRESS_SET_SIZE_AND_METHOD(ptr, len, cm_method) \
|
||||
#define TOAST_COMPRESS_METHOD(ptr) \
|
||||
(((toast_compress_header *) (ptr))->tcinfo >> VARLENA_EXTSIZE_BITS)
|
||||
|
||||
#define TOAST_COMPRESS_SET_SIZE_AND_COMPRESS_METHOD(ptr, len, cm_method) \
|
||||
do { \
|
||||
Assert((len) > 0 && (len) <= VARLENA_RAWSIZE_MASK); \
|
||||
Assert((len) > 0 && (len) <= VARLENA_EXTSIZE_MASK); \
|
||||
Assert((cm_method) == TOAST_PGLZ_COMPRESSION_ID || \
|
||||
(cm_method) == TOAST_LZ4_COMPRESSION_ID); \
|
||||
((toast_compress_header *) (ptr))->tcinfo = \
|
||||
((len) | (cm_method) << VARLENA_RAWSIZE_BITS); \
|
||||
(len) | ((uint32) (cm_method) << VARLENA_EXTSIZE_BITS); \
|
||||
} while (0)
|
||||
|
||||
extern Datum toast_compress_datum(Datum value, char cmethod);
|
||||
|
Reference in New Issue
Block a user