diff options
| author | Tom Lane | 2021-05-27 17:24:24 +0000 |
|---|---|---|
| committer | Tom Lane | 2021-05-27 17:24:27 +0000 |
| commit | e6241d8e030fbd2746b3ea3f44e728224298f35b (patch) | |
| tree | e4bfc50561023459635cb9faf0873fee1e891013 /src/include | |
| parent | a717e5c771610cf8607f2423ab3ab6b5d30f44ea (diff) | |
Rethink definition of pg_attribute.attcompression.
Redefine '\0' (InvalidCompressionMethod) as meaning "if we need to
compress, use the current setting of default_toast_compression".
This allows '\0' to be a suitable default choice regardless of
datatype, greatly simplifying code paths that initialize tupledescs
and the like. It seems like a more user-friendly approach as well,
because now the default compression choice doesn't migrate into table
definitions, meaning that changing default_toast_compression is
usually sufficient to flip an installation's behavior; one needn't
tediously issue per-column ALTER SET COMPRESSION commands.
Along the way, fix a few minor bugs and documentation issues
with the per-column-compression feature. Adopt more robust
APIs for SetIndexStorageProperties and GetAttributeCompression.
Bump catversion because typical contents of attcompression will now
be different. We could get away without doing that, but it seems
better to ensure v14 installations all agree on this. (We already
forced initdb for beta2, anyway.)
Discussion: https://postgr.es/m/626613.1621787110@sss.pgh.pa.us
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/access/toast_compression.h | 24 | ||||
| -rw-r--r-- | src/include/catalog/catversion.h | 2 | ||||
| -rw-r--r-- | src/include/catalog/pg_attribute.h | 8 |
3 files changed, 13 insertions, 21 deletions
diff --git a/src/include/access/toast_compression.h b/src/include/access/toast_compression.h index 9e2c1cbe1a6..c992ece4c4a 100644 --- a/src/include/access/toast_compression.h +++ b/src/include/access/toast_compression.h @@ -23,16 +23,16 @@ extern int default_toast_compression; /* - * Built-in compression method-id. The toast compression header will store + * Built-in compression method ID. The toast compression header will store * this in the first 2 bits of the raw length. These built-in compression - * method-id are directly mapped to the built-in compression methods. + * method IDs are directly mapped to the built-in compression methods. * * Don't use these values for anything other than understanding the meaning * of the raw bits from a varlena; in particular, if the goal is to identify * a compression method, use the constants TOAST_PGLZ_COMPRESSION, etc. * below. We might someday support more than 4 compression methods, but * we can never have more than 4 values in this enum, because there are - * only 2 bits available in the places where this is used. + * only 2 bits available in the places where this is stored. */ typedef enum ToastCompressionId { @@ -42,8 +42,9 @@ typedef enum ToastCompressionId } ToastCompressionId; /* - * Built-in compression methods. pg_attribute will store this in the - * attcompression column. + * Built-in compression methods. pg_attribute will store these in the + * attcompression column. In attcompression, InvalidCompressionMethod + * denotes the default behavior. */ #define TOAST_PGLZ_COMPRESSION 'p' #define TOAST_LZ4_COMPRESSION 'l' @@ -51,19 +52,6 @@ typedef enum ToastCompressionId #define CompressionMethodIsValid(cm) ((cm) != InvalidCompressionMethod) -#define IsStorageCompressible(storage) ((storage) != TYPSTORAGE_PLAIN && \ - (storage) != TYPSTORAGE_EXTERNAL) - -/* - * GetDefaultToastCompression -- get the default toast compression method - * - * This exists to hide the use of the default_toast_compression GUC variable. - */ -static inline char -GetDefaultToastCompression(void) -{ - return (char) default_toast_compression; -} /* pglz compression/decompression routines */ extern struct varlena *pglz_compress_datum(const struct varlena *value); diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index 958f12e66a1..9fe49fa2911 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -53,6 +53,6 @@ */ /* yyyymmddN */ -#define CATALOG_VERSION_NO 202105231 +#define CATALOG_VERSION_NO 202105271 #endif diff --git a/src/include/catalog/pg_attribute.h b/src/include/catalog/pg_attribute.h index 1e260162146..603392fe81b 100644 --- a/src/include/catalog/pg_attribute.h +++ b/src/include/catalog/pg_attribute.h @@ -126,8 +126,12 @@ CATALOG(pg_attribute,1249,AttributeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(75, char attstorage; /* - * Compression method. Must be InvalidCompressionMethod if and only if - * typstorage is 'plain' or 'external'. + * attcompression sets the current compression method of the attribute. + * Typically this is InvalidCompressionMethod ('\0') to specify use of the + * current default setting (see default_toast_compression). Otherwise, + * 'p' selects pglz compression, while 'l' selects LZ4 compression. + * However, this field is ignored whenever attstorage does not allow + * compression. */ char attcompression BKI_DEFAULT('\0'); |
