public inbox for [email protected]  
help / color / mirror / Atom feed
[PATCH 06/12] fixups.patch
46+ messages / 2 participants
[nested] [flat]

* [PATCH 06/12] fixups.patch
@ 2021-02-10 21:56  Robert Haas <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: Robert Haas @ 2021-02-10 21:56 UTC (permalink / raw)

---
 doc/src/sgml/ddl.sgml                         |  3 ---
 doc/src/sgml/ref/create_table.sgml            | 15 +++++++++++----
 src/backend/access/common/detoast.c           |  5 ++---
 src/backend/access/compression/compress_lz4.c | 10 +++++-----
 src/backend/executor/nodeModifyTable.c        |  2 +-
 src/include/nodes/execnodes.h                 |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 4d7ed698b9..1e9a4625cc 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3762,9 +3762,6 @@ CREATE TABLE measurement (
        <productname>PostgreSQL</productname>
        tables (or, possibly, foreign tables).  It is possible to specify a
        tablespace and storage parameters for each partition separately.
-       By default, each column in a partition inherits the compression method
-       from parent table's column, however a different compression method can be
-       set for each partition.
       </para>
 
       <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 3374012940..807597e648 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -997,10 +997,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
-      This sets the compression method for a column.  The supported compression
-      methods are <literal>pglz</literal> and <literal>lz4</literal>.
-      <literal>lz4</literal> is available only if <literal>--with-lz4</literal>
-      was used when building <productname>PostgreSQL</productname>. The default
+      The <literal>COMPRESSION</literal> clause sets the compression method
+      for a column.  Compression is supported only for variable-width data
+      types, and is used only for columns whose storage type is main or
+      extended. (See <xref linkend="sql-altertable"/> for information on
+      column storage types.) Setting this property for a partitioned table
+      has no direct effect, because such tables have no storage of their own,
+      but the configured value is inherited by newly-created partitions.
+      The supported compression methods are <literal>pglz</literal> and
+      <literal>lz4</literal>.  <literal>lz4</literal> is available only if
+      <literal>--with-lz4</literal> was used when building
+      <productname>PostgreSQL</productname>. The default
       is <literal>pglz</literal>.
      </para>
     </listitem>
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index b78d49167b..95d5b1c12a 100644
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -477,8 +477,8 @@ toast_get_compression_oid(struct varlena *attr)
 			return InvalidOid;
 
 		/*
-		 * Just fetch the toast compress header to know the compression method
-		 * in the compressed data.
+		 * Fetch just enough of the value to examine the compression header,
+		 * so that we can find out the compression method.
 		 */
 		attr = toast_fetch_datum_slice(attr, 0, VARHDRSZ_COMPRESS);
 	}
@@ -503,7 +503,6 @@ toast_get_compression_handler(struct varlena *attr)
 
 	cmid = TOAST_COMPRESS_METHOD(attr);
 
-	/* Get the handler routines for the compression method */
 	switch (cmid)
 	{
 		case PGLZ_COMPRESSION_ID:
diff --git a/src/backend/access/compression/compress_lz4.c b/src/backend/access/compression/compress_lz4.c
index 1856cf7df7..3079eff7eb 100644
--- a/src/backend/access/compression/compress_lz4.c
+++ b/src/backend/access/compression/compress_lz4.c
@@ -23,7 +23,7 @@
 /*
  * lz4_cmcompress - compression routine for lz4 compression method
  *
- * Compresses source into dest using the default strategy. Returns the
+ * Compresses source into dest using the LZ4 defaults. Returns the
  * compressed varlena, or NULL if compression fails.
  */
 static struct varlena *
@@ -42,8 +42,8 @@ lz4_cmcompress(const struct varlena *value)
 	valsize = VARSIZE_ANY_EXHDR(value);
 
 	/*
-	 * Get maximum size of the compressed data that lz4 compression may output
-	 * and allocate the memory for holding the compressed data and the header.
+	 * Figure out the maximum possible size of the LZ4 output, add the bytes
+	 * that will be needed for varlena overhead, and allocate that amount.
 	 */
 	max_size = LZ4_compressBound(valsize);
 	tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESS);
@@ -83,10 +83,10 @@ lz4_cmdecompress(const struct varlena *value)
 	int32		rawsize;
 	struct varlena *result;
 
-	/* allocate memory for holding the uncompressed data */
+	/* allocate memory for the uncompressed data */
 	result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ);
 
-	/* decompress data using lz4 routine */
+	/* decompress the data */
 	rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESS,
 								  VARDATA(result),
 								  VARSIZE(value) - VARHDRSZ_COMPRESS,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f77deee399..920d9dd0d5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2117,7 +2117,7 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
 		TupleTableSlot *newslot = *outslot;
 
 		/*
-		 * If the called has passed an invalid slot then create a new slot.
+		 * If the caller has passed an invalid slot then create a new slot.
 		 * Otherwise, just clear the existing tuple from the slot.  This slot
 		 * should be stored by the caller so that it can be reused for
 		 * decompressing the subsequent tuples.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index ac3884b3a8..182b77a0ff 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1186,8 +1186,8 @@ typedef struct ModifyTableState
 	TupleTableSlot *mt_root_tuple_slot;
 
 	/*
-	 * Slot for storing the modified tuple, incase the target attribute's
-	 * compression method doesn't match with the source table.
+	 * Slot for storing the modified tuple, in case the target attribute's
+	 * compression method doesn't match that of the source table.
 	 */
 	TupleTableSlot *mt_decompress_tuple_slot;
 
-- 
2.17.0


--9Ek0hoCL9XbhcSqy
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="0007-alter-table-set-compression.patch"



^ permalink  raw  reply  [nested|flat] 46+ messages in thread

* [PATCH v24 5/7] fixups.patch
@ 2021-02-10 21:56  Robert Haas <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: Robert Haas @ 2021-02-10 21:56 UTC (permalink / raw)

---
 doc/src/sgml/ddl.sgml                         |  3 ---
 doc/src/sgml/ref/create_table.sgml            | 15 +++++++++++----
 src/backend/access/common/detoast.c           |  5 ++---
 src/backend/access/compression/compress_lz4.c | 10 +++++-----
 src/backend/executor/nodeModifyTable.c        |  2 +-
 src/include/nodes/execnodes.h                 |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 4d7ed698b9..1e9a4625cc 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3762,9 +3762,6 @@ CREATE TABLE measurement (
        <productname>PostgreSQL</productname>
        tables (or, possibly, foreign tables).  It is possible to specify a
        tablespace and storage parameters for each partition separately.
-       By default, each column in a partition inherits the compression method
-       from parent table's column, however a different compression method can be
-       set for each partition.
       </para>
 
       <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 51a7a977a5..a4b297340f 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -997,10 +997,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
-      This sets the compression method for a column.  The supported compression
-      methods are <literal>pglz</literal> and <literal>lz4</literal>.
-      <literal>lz4</literal> is available only if <literal>--with-lz4</literal>
-      was used when building <productname>PostgreSQL</productname>. The default
+      The <literal>COMPRESSION</literal> clause sets the compression method
+      for a column.  Compression is supported only for variable-width data
+      types, and is used only for columns whose storage type is main or
+      extended. (See <xref linkend="sql-altertable"/> for information on
+      column storage types.) Setting this property for a partitioned table
+      has no direct effect, because such tables have no storage of their own,
+      but the configured value is inherited by newly-created partitions.
+      The supported compression methods are <literal>pglz</literal> and
+      <literal>lz4</literal>.  <literal>lz4</literal> is available only if
+      <literal>--with-lz4</literal> was used when building
+      <productname>PostgreSQL</productname>. The default
       is <literal>pglz</literal>.
      </para>
     </listitem>
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index b78d49167b..95d5b1c12a 100644
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -477,8 +477,8 @@ toast_get_compression_oid(struct varlena *attr)
 			return InvalidOid;
 
 		/*
-		 * Just fetch the toast compress header to know the compression method
-		 * in the compressed data.
+		 * Fetch just enough of the value to examine the compression header,
+		 * so that we can find out the compression method.
 		 */
 		attr = toast_fetch_datum_slice(attr, 0, VARHDRSZ_COMPRESS);
 	}
@@ -503,7 +503,6 @@ toast_get_compression_handler(struct varlena *attr)
 
 	cmid = TOAST_COMPRESS_METHOD(attr);
 
-	/* Get the handler routines for the compression method */
 	switch (cmid)
 	{
 		case PGLZ_COMPRESSION_ID:
diff --git a/src/backend/access/compression/compress_lz4.c b/src/backend/access/compression/compress_lz4.c
index 1856cf7df7..3079eff7eb 100644
--- a/src/backend/access/compression/compress_lz4.c
+++ b/src/backend/access/compression/compress_lz4.c
@@ -23,7 +23,7 @@
 /*
  * lz4_cmcompress - compression routine for lz4 compression method
  *
- * Compresses source into dest using the default strategy. Returns the
+ * Compresses source into dest using the LZ4 defaults. Returns the
  * compressed varlena, or NULL if compression fails.
  */
 static struct varlena *
@@ -42,8 +42,8 @@ lz4_cmcompress(const struct varlena *value)
 	valsize = VARSIZE_ANY_EXHDR(value);
 
 	/*
-	 * Get maximum size of the compressed data that lz4 compression may output
-	 * and allocate the memory for holding the compressed data and the header.
+	 * Figure out the maximum possible size of the LZ4 output, add the bytes
+	 * that will be needed for varlena overhead, and allocate that amount.
 	 */
 	max_size = LZ4_compressBound(valsize);
 	tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESS);
@@ -83,10 +83,10 @@ lz4_cmdecompress(const struct varlena *value)
 	int32		rawsize;
 	struct varlena *result;
 
-	/* allocate memory for holding the uncompressed data */
+	/* allocate memory for the uncompressed data */
 	result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ);
 
-	/* decompress data using lz4 routine */
+	/* decompress the data */
 	rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESS,
 								  VARDATA(result),
 								  VARSIZE(value) - VARHDRSZ_COMPRESS,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f77deee399..920d9dd0d5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2117,7 +2117,7 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
 		TupleTableSlot *newslot = *outslot;
 
 		/*
-		 * If the called has passed an invalid slot then create a new slot.
+		 * If the caller has passed an invalid slot then create a new slot.
 		 * Otherwise, just clear the existing tuple from the slot.  This slot
 		 * should be stored by the caller so that it can be reused for
 		 * decompressing the subsequent tuples.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 18e8ecfd90..d8483c36b3 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1183,8 +1183,8 @@ typedef struct ModifyTableState
 	TupleTableSlot *mt_root_tuple_slot;
 
 	/*
-	 * Slot for storing the modified tuple, incase the target attribute's
-	 * compression method doesn't match with the source table.
+	 * Slot for storing the modified tuple, in case the target attribute's
+	 * compression method doesn't match that of the source table.
 	 */
 	TupleTableSlot *mt_decompress_tuple_slot;
 
-- 
2.17.0


--YZ5djTAD1cGYuMQK
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v24-0006-alter-table-set-compression.patch"



^ permalink  raw  reply  [nested|flat] 46+ messages in thread

* [PATCH v24 05/10] fixups.patch
@ 2021-02-10 21:56  Robert Haas <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: Robert Haas @ 2021-02-10 21:56 UTC (permalink / raw)

---
 doc/src/sgml/ddl.sgml                         |  3 ---
 doc/src/sgml/ref/create_table.sgml            | 15 +++++++++++----
 src/backend/access/common/detoast.c           |  5 ++---
 src/backend/access/compression/compress_lz4.c | 10 +++++-----
 src/backend/executor/nodeModifyTable.c        |  2 +-
 src/include/nodes/execnodes.h                 |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 4d7ed698b9..1e9a4625cc 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3762,9 +3762,6 @@ CREATE TABLE measurement (
        <productname>PostgreSQL</productname>
        tables (or, possibly, foreign tables).  It is possible to specify a
        tablespace and storage parameters for each partition separately.
-       By default, each column in a partition inherits the compression method
-       from parent table's column, however a different compression method can be
-       set for each partition.
       </para>
 
       <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 51a7a977a5..a4b297340f 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -997,10 +997,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
-      This sets the compression method for a column.  The supported compression
-      methods are <literal>pglz</literal> and <literal>lz4</literal>.
-      <literal>lz4</literal> is available only if <literal>--with-lz4</literal>
-      was used when building <productname>PostgreSQL</productname>. The default
+      The <literal>COMPRESSION</literal> clause sets the compression method
+      for a column.  Compression is supported only for variable-width data
+      types, and is used only for columns whose storage type is main or
+      extended. (See <xref linkend="sql-altertable"/> for information on
+      column storage types.) Setting this property for a partitioned table
+      has no direct effect, because such tables have no storage of their own,
+      but the configured value is inherited by newly-created partitions.
+      The supported compression methods are <literal>pglz</literal> and
+      <literal>lz4</literal>.  <literal>lz4</literal> is available only if
+      <literal>--with-lz4</literal> was used when building
+      <productname>PostgreSQL</productname>. The default
       is <literal>pglz</literal>.
      </para>
     </listitem>
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index b78d49167b..95d5b1c12a 100644
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -477,8 +477,8 @@ toast_get_compression_oid(struct varlena *attr)
 			return InvalidOid;
 
 		/*
-		 * Just fetch the toast compress header to know the compression method
-		 * in the compressed data.
+		 * Fetch just enough of the value to examine the compression header,
+		 * so that we can find out the compression method.
 		 */
 		attr = toast_fetch_datum_slice(attr, 0, VARHDRSZ_COMPRESS);
 	}
@@ -503,7 +503,6 @@ toast_get_compression_handler(struct varlena *attr)
 
 	cmid = TOAST_COMPRESS_METHOD(attr);
 
-	/* Get the handler routines for the compression method */
 	switch (cmid)
 	{
 		case PGLZ_COMPRESSION_ID:
diff --git a/src/backend/access/compression/compress_lz4.c b/src/backend/access/compression/compress_lz4.c
index 1856cf7df7..3079eff7eb 100644
--- a/src/backend/access/compression/compress_lz4.c
+++ b/src/backend/access/compression/compress_lz4.c
@@ -23,7 +23,7 @@
 /*
  * lz4_cmcompress - compression routine for lz4 compression method
  *
- * Compresses source into dest using the default strategy. Returns the
+ * Compresses source into dest using the LZ4 defaults. Returns the
  * compressed varlena, or NULL if compression fails.
  */
 static struct varlena *
@@ -42,8 +42,8 @@ lz4_cmcompress(const struct varlena *value)
 	valsize = VARSIZE_ANY_EXHDR(value);
 
 	/*
-	 * Get maximum size of the compressed data that lz4 compression may output
-	 * and allocate the memory for holding the compressed data and the header.
+	 * Figure out the maximum possible size of the LZ4 output, add the bytes
+	 * that will be needed for varlena overhead, and allocate that amount.
 	 */
 	max_size = LZ4_compressBound(valsize);
 	tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESS);
@@ -83,10 +83,10 @@ lz4_cmdecompress(const struct varlena *value)
 	int32		rawsize;
 	struct varlena *result;
 
-	/* allocate memory for holding the uncompressed data */
+	/* allocate memory for the uncompressed data */
 	result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ);
 
-	/* decompress data using lz4 routine */
+	/* decompress the data */
 	rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESS,
 								  VARDATA(result),
 								  VARSIZE(value) - VARHDRSZ_COMPRESS,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f77deee399..920d9dd0d5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2117,7 +2117,7 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
 		TupleTableSlot *newslot = *outslot;
 
 		/*
-		 * If the called has passed an invalid slot then create a new slot.
+		 * If the caller has passed an invalid slot then create a new slot.
 		 * Otherwise, just clear the existing tuple from the slot.  This slot
 		 * should be stored by the caller so that it can be reused for
 		 * decompressing the subsequent tuples.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 18e8ecfd90..d8483c36b3 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1183,8 +1183,8 @@ typedef struct ModifyTableState
 	TupleTableSlot *mt_root_tuple_slot;
 
 	/*
-	 * Slot for storing the modified tuple, incase the target attribute's
-	 * compression method doesn't match with the source table.
+	 * Slot for storing the modified tuple, in case the target attribute's
+	 * compression method doesn't match that of the source table.
 	 */
 	TupleTableSlot *mt_decompress_tuple_slot;
 
-- 
2.17.0


--m51xatjYGsM+13rf
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v24-0006-alter-table-set-compression.patch"



^ permalink  raw  reply  [nested|flat] 46+ messages in thread

* [PATCH v24 5/7] fixups.patch
@ 2021-02-10 21:56  Robert Haas <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: Robert Haas @ 2021-02-10 21:56 UTC (permalink / raw)

---
 doc/src/sgml/ddl.sgml                         |  3 ---
 doc/src/sgml/ref/create_table.sgml            | 15 +++++++++++----
 src/backend/access/common/detoast.c           |  5 ++---
 src/backend/access/compression/compress_lz4.c | 10 +++++-----
 src/backend/executor/nodeModifyTable.c        |  2 +-
 src/include/nodes/execnodes.h                 |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 4d7ed698b9..1e9a4625cc 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3762,9 +3762,6 @@ CREATE TABLE measurement (
        <productname>PostgreSQL</productname>
        tables (or, possibly, foreign tables).  It is possible to specify a
        tablespace and storage parameters for each partition separately.
-       By default, each column in a partition inherits the compression method
-       from parent table's column, however a different compression method can be
-       set for each partition.
       </para>
 
       <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 51a7a977a5..a4b297340f 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -997,10 +997,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
-      This sets the compression method for a column.  The supported compression
-      methods are <literal>pglz</literal> and <literal>lz4</literal>.
-      <literal>lz4</literal> is available only if <literal>--with-lz4</literal>
-      was used when building <productname>PostgreSQL</productname>. The default
+      The <literal>COMPRESSION</literal> clause sets the compression method
+      for a column.  Compression is supported only for variable-width data
+      types, and is used only for columns whose storage type is main or
+      extended. (See <xref linkend="sql-altertable"/> for information on
+      column storage types.) Setting this property for a partitioned table
+      has no direct effect, because such tables have no storage of their own,
+      but the configured value is inherited by newly-created partitions.
+      The supported compression methods are <literal>pglz</literal> and
+      <literal>lz4</literal>.  <literal>lz4</literal> is available only if
+      <literal>--with-lz4</literal> was used when building
+      <productname>PostgreSQL</productname>. The default
       is <literal>pglz</literal>.
      </para>
     </listitem>
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index b78d49167b..95d5b1c12a 100644
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -477,8 +477,8 @@ toast_get_compression_oid(struct varlena *attr)
 			return InvalidOid;
 
 		/*
-		 * Just fetch the toast compress header to know the compression method
-		 * in the compressed data.
+		 * Fetch just enough of the value to examine the compression header,
+		 * so that we can find out the compression method.
 		 */
 		attr = toast_fetch_datum_slice(attr, 0, VARHDRSZ_COMPRESS);
 	}
@@ -503,7 +503,6 @@ toast_get_compression_handler(struct varlena *attr)
 
 	cmid = TOAST_COMPRESS_METHOD(attr);
 
-	/* Get the handler routines for the compression method */
 	switch (cmid)
 	{
 		case PGLZ_COMPRESSION_ID:
diff --git a/src/backend/access/compression/compress_lz4.c b/src/backend/access/compression/compress_lz4.c
index 1856cf7df7..3079eff7eb 100644
--- a/src/backend/access/compression/compress_lz4.c
+++ b/src/backend/access/compression/compress_lz4.c
@@ -23,7 +23,7 @@
 /*
  * lz4_cmcompress - compression routine for lz4 compression method
  *
- * Compresses source into dest using the default strategy. Returns the
+ * Compresses source into dest using the LZ4 defaults. Returns the
  * compressed varlena, or NULL if compression fails.
  */
 static struct varlena *
@@ -42,8 +42,8 @@ lz4_cmcompress(const struct varlena *value)
 	valsize = VARSIZE_ANY_EXHDR(value);
 
 	/*
-	 * Get maximum size of the compressed data that lz4 compression may output
-	 * and allocate the memory for holding the compressed data and the header.
+	 * Figure out the maximum possible size of the LZ4 output, add the bytes
+	 * that will be needed for varlena overhead, and allocate that amount.
 	 */
 	max_size = LZ4_compressBound(valsize);
 	tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESS);
@@ -83,10 +83,10 @@ lz4_cmdecompress(const struct varlena *value)
 	int32		rawsize;
 	struct varlena *result;
 
-	/* allocate memory for holding the uncompressed data */
+	/* allocate memory for the uncompressed data */
 	result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ);
 
-	/* decompress data using lz4 routine */
+	/* decompress the data */
 	rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESS,
 								  VARDATA(result),
 								  VARSIZE(value) - VARHDRSZ_COMPRESS,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f77deee399..920d9dd0d5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2117,7 +2117,7 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
 		TupleTableSlot *newslot = *outslot;
 
 		/*
-		 * If the called has passed an invalid slot then create a new slot.
+		 * If the caller has passed an invalid slot then create a new slot.
 		 * Otherwise, just clear the existing tuple from the slot.  This slot
 		 * should be stored by the caller so that it can be reused for
 		 * decompressing the subsequent tuples.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 18e8ecfd90..d8483c36b3 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1183,8 +1183,8 @@ typedef struct ModifyTableState
 	TupleTableSlot *mt_root_tuple_slot;
 
 	/*
-	 * Slot for storing the modified tuple, incase the target attribute's
-	 * compression method doesn't match with the source table.
+	 * Slot for storing the modified tuple, in case the target attribute's
+	 * compression method doesn't match that of the source table.
 	 */
 	TupleTableSlot *mt_decompress_tuple_slot;
 
-- 
2.17.0


--YZ5djTAD1cGYuMQK
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v24-0006-alter-table-set-compression.patch"



^ permalink  raw  reply  [nested|flat] 46+ messages in thread

* [PATCH v24 05/10] fixups.patch
@ 2021-02-10 21:56  Robert Haas <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: Robert Haas @ 2021-02-10 21:56 UTC (permalink / raw)

---
 doc/src/sgml/ddl.sgml                         |  3 ---
 doc/src/sgml/ref/create_table.sgml            | 15 +++++++++++----
 src/backend/access/common/detoast.c           |  5 ++---
 src/backend/access/compression/compress_lz4.c | 10 +++++-----
 src/backend/executor/nodeModifyTable.c        |  2 +-
 src/include/nodes/execnodes.h                 |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 4d7ed698b9..1e9a4625cc 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3762,9 +3762,6 @@ CREATE TABLE measurement (
        <productname>PostgreSQL</productname>
        tables (or, possibly, foreign tables).  It is possible to specify a
        tablespace and storage parameters for each partition separately.
-       By default, each column in a partition inherits the compression method
-       from parent table's column, however a different compression method can be
-       set for each partition.
       </para>
 
       <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 51a7a977a5..a4b297340f 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -997,10 +997,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
-      This sets the compression method for a column.  The supported compression
-      methods are <literal>pglz</literal> and <literal>lz4</literal>.
-      <literal>lz4</literal> is available only if <literal>--with-lz4</literal>
-      was used when building <productname>PostgreSQL</productname>. The default
+      The <literal>COMPRESSION</literal> clause sets the compression method
+      for a column.  Compression is supported only for variable-width data
+      types, and is used only for columns whose storage type is main or
+      extended. (See <xref linkend="sql-altertable"/> for information on
+      column storage types.) Setting this property for a partitioned table
+      has no direct effect, because such tables have no storage of their own,
+      but the configured value is inherited by newly-created partitions.
+      The supported compression methods are <literal>pglz</literal> and
+      <literal>lz4</literal>.  <literal>lz4</literal> is available only if
+      <literal>--with-lz4</literal> was used when building
+      <productname>PostgreSQL</productname>. The default
       is <literal>pglz</literal>.
      </para>
     </listitem>
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index b78d49167b..95d5b1c12a 100644
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -477,8 +477,8 @@ toast_get_compression_oid(struct varlena *attr)
 			return InvalidOid;
 
 		/*
-		 * Just fetch the toast compress header to know the compression method
-		 * in the compressed data.
+		 * Fetch just enough of the value to examine the compression header,
+		 * so that we can find out the compression method.
 		 */
 		attr = toast_fetch_datum_slice(attr, 0, VARHDRSZ_COMPRESS);
 	}
@@ -503,7 +503,6 @@ toast_get_compression_handler(struct varlena *attr)
 
 	cmid = TOAST_COMPRESS_METHOD(attr);
 
-	/* Get the handler routines for the compression method */
 	switch (cmid)
 	{
 		case PGLZ_COMPRESSION_ID:
diff --git a/src/backend/access/compression/compress_lz4.c b/src/backend/access/compression/compress_lz4.c
index 1856cf7df7..3079eff7eb 100644
--- a/src/backend/access/compression/compress_lz4.c
+++ b/src/backend/access/compression/compress_lz4.c
@@ -23,7 +23,7 @@
 /*
  * lz4_cmcompress - compression routine for lz4 compression method
  *
- * Compresses source into dest using the default strategy. Returns the
+ * Compresses source into dest using the LZ4 defaults. Returns the
  * compressed varlena, or NULL if compression fails.
  */
 static struct varlena *
@@ -42,8 +42,8 @@ lz4_cmcompress(const struct varlena *value)
 	valsize = VARSIZE_ANY_EXHDR(value);
 
 	/*
-	 * Get maximum size of the compressed data that lz4 compression may output
-	 * and allocate the memory for holding the compressed data and the header.
+	 * Figure out the maximum possible size of the LZ4 output, add the bytes
+	 * that will be needed for varlena overhead, and allocate that amount.
 	 */
 	max_size = LZ4_compressBound(valsize);
 	tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESS);
@@ -83,10 +83,10 @@ lz4_cmdecompress(const struct varlena *value)
 	int32		rawsize;
 	struct varlena *result;
 
-	/* allocate memory for holding the uncompressed data */
+	/* allocate memory for the uncompressed data */
 	result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ);
 
-	/* decompress data using lz4 routine */
+	/* decompress the data */
 	rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESS,
 								  VARDATA(result),
 								  VARSIZE(value) - VARHDRSZ_COMPRESS,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f77deee399..920d9dd0d5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2117,7 +2117,7 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
 		TupleTableSlot *newslot = *outslot;
 
 		/*
-		 * If the called has passed an invalid slot then create a new slot.
+		 * If the caller has passed an invalid slot then create a new slot.
 		 * Otherwise, just clear the existing tuple from the slot.  This slot
 		 * should be stored by the caller so that it can be reused for
 		 * decompressing the subsequent tuples.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 18e8ecfd90..d8483c36b3 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1183,8 +1183,8 @@ typedef struct ModifyTableState
 	TupleTableSlot *mt_root_tuple_slot;
 
 	/*
-	 * Slot for storing the modified tuple, incase the target attribute's
-	 * compression method doesn't match with the source table.
+	 * Slot for storing the modified tuple, in case the target attribute's
+	 * compression method doesn't match that of the source table.
 	 */
 	TupleTableSlot *mt_decompress_tuple_slot;
 
-- 
2.17.0


--m51xatjYGsM+13rf
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v24-0006-alter-table-set-compression.patch"



^ permalink  raw  reply  [nested|flat] 46+ messages in thread

* [PATCH v24 5/7] fixups.patch
@ 2021-02-10 21:56  Robert Haas <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: Robert Haas @ 2021-02-10 21:56 UTC (permalink / raw)

---
 doc/src/sgml/ddl.sgml                         |  3 ---
 doc/src/sgml/ref/create_table.sgml            | 15 +++++++++++----
 src/backend/access/common/detoast.c           |  5 ++---
 src/backend/access/compression/compress_lz4.c | 10 +++++-----
 src/backend/executor/nodeModifyTable.c        |  2 +-
 src/include/nodes/execnodes.h                 |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 4d7ed698b9..1e9a4625cc 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3762,9 +3762,6 @@ CREATE TABLE measurement (
        <productname>PostgreSQL</productname>
        tables (or, possibly, foreign tables).  It is possible to specify a
        tablespace and storage parameters for each partition separately.
-       By default, each column in a partition inherits the compression method
-       from parent table's column, however a different compression method can be
-       set for each partition.
       </para>
 
       <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 51a7a977a5..a4b297340f 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -997,10 +997,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
-      This sets the compression method for a column.  The supported compression
-      methods are <literal>pglz</literal> and <literal>lz4</literal>.
-      <literal>lz4</literal> is available only if <literal>--with-lz4</literal>
-      was used when building <productname>PostgreSQL</productname>. The default
+      The <literal>COMPRESSION</literal> clause sets the compression method
+      for a column.  Compression is supported only for variable-width data
+      types, and is used only for columns whose storage type is main or
+      extended. (See <xref linkend="sql-altertable"/> for information on
+      column storage types.) Setting this property for a partitioned table
+      has no direct effect, because such tables have no storage of their own,
+      but the configured value is inherited by newly-created partitions.
+      The supported compression methods are <literal>pglz</literal> and
+      <literal>lz4</literal>.  <literal>lz4</literal> is available only if
+      <literal>--with-lz4</literal> was used when building
+      <productname>PostgreSQL</productname>. The default
       is <literal>pglz</literal>.
      </para>
     </listitem>
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index b78d49167b..95d5b1c12a 100644
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -477,8 +477,8 @@ toast_get_compression_oid(struct varlena *attr)
 			return InvalidOid;
 
 		/*
-		 * Just fetch the toast compress header to know the compression method
-		 * in the compressed data.
+		 * Fetch just enough of the value to examine the compression header,
+		 * so that we can find out the compression method.
 		 */
 		attr = toast_fetch_datum_slice(attr, 0, VARHDRSZ_COMPRESS);
 	}
@@ -503,7 +503,6 @@ toast_get_compression_handler(struct varlena *attr)
 
 	cmid = TOAST_COMPRESS_METHOD(attr);
 
-	/* Get the handler routines for the compression method */
 	switch (cmid)
 	{
 		case PGLZ_COMPRESSION_ID:
diff --git a/src/backend/access/compression/compress_lz4.c b/src/backend/access/compression/compress_lz4.c
index 1856cf7df7..3079eff7eb 100644
--- a/src/backend/access/compression/compress_lz4.c
+++ b/src/backend/access/compression/compress_lz4.c
@@ -23,7 +23,7 @@
 /*
  * lz4_cmcompress - compression routine for lz4 compression method
  *
- * Compresses source into dest using the default strategy. Returns the
+ * Compresses source into dest using the LZ4 defaults. Returns the
  * compressed varlena, or NULL if compression fails.
  */
 static struct varlena *
@@ -42,8 +42,8 @@ lz4_cmcompress(const struct varlena *value)
 	valsize = VARSIZE_ANY_EXHDR(value);
 
 	/*
-	 * Get maximum size of the compressed data that lz4 compression may output
-	 * and allocate the memory for holding the compressed data and the header.
+	 * Figure out the maximum possible size of the LZ4 output, add the bytes
+	 * that will be needed for varlena overhead, and allocate that amount.
 	 */
 	max_size = LZ4_compressBound(valsize);
 	tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESS);
@@ -83,10 +83,10 @@ lz4_cmdecompress(const struct varlena *value)
 	int32		rawsize;
 	struct varlena *result;
 
-	/* allocate memory for holding the uncompressed data */
+	/* allocate memory for the uncompressed data */
 	result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ);
 
-	/* decompress data using lz4 routine */
+	/* decompress the data */
 	rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESS,
 								  VARDATA(result),
 								  VARSIZE(value) - VARHDRSZ_COMPRESS,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f77deee399..920d9dd0d5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2117,7 +2117,7 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
 		TupleTableSlot *newslot = *outslot;
 
 		/*
-		 * If the called has passed an invalid slot then create a new slot.
+		 * If the caller has passed an invalid slot then create a new slot.
 		 * Otherwise, just clear the existing tuple from the slot.  This slot
 		 * should be stored by the caller so that it can be reused for
 		 * decompressing the subsequent tuples.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 18e8ecfd90..d8483c36b3 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1183,8 +1183,8 @@ typedef struct ModifyTableState
 	TupleTableSlot *mt_root_tuple_slot;
 
 	/*
-	 * Slot for storing the modified tuple, incase the target attribute's
-	 * compression method doesn't match with the source table.
+	 * Slot for storing the modified tuple, in case the target attribute's
+	 * compression method doesn't match that of the source table.
 	 */
 	TupleTableSlot *mt_decompress_tuple_slot;
 
-- 
2.17.0


--YZ5djTAD1cGYuMQK
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v24-0006-alter-table-set-compression.patch"



^ permalink  raw  reply  [nested|flat] 46+ messages in thread

* [PATCH v24 05/10] fixups.patch
@ 2021-02-10 21:56  Robert Haas <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: Robert Haas @ 2021-02-10 21:56 UTC (permalink / raw)

---
 doc/src/sgml/ddl.sgml                         |  3 ---
 doc/src/sgml/ref/create_table.sgml            | 15 +++++++++++----
 src/backend/access/common/detoast.c           |  5 ++---
 src/backend/access/compression/compress_lz4.c | 10 +++++-----
 src/backend/executor/nodeModifyTable.c        |  2 +-
 src/include/nodes/execnodes.h                 |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 4d7ed698b9..1e9a4625cc 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3762,9 +3762,6 @@ CREATE TABLE measurement (
        <productname>PostgreSQL</productname>
        tables (or, possibly, foreign tables).  It is possible to specify a
        tablespace and storage parameters for each partition separately.
-       By default, each column in a partition inherits the compression method
-       from parent table's column, however a different compression method can be
-       set for each partition.
       </para>
 
       <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 51a7a977a5..a4b297340f 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -997,10 +997,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
-      This sets the compression method for a column.  The supported compression
-      methods are <literal>pglz</literal> and <literal>lz4</literal>.
-      <literal>lz4</literal> is available only if <literal>--with-lz4</literal>
-      was used when building <productname>PostgreSQL</productname>. The default
+      The <literal>COMPRESSION</literal> clause sets the compression method
+      for a column.  Compression is supported only for variable-width data
+      types, and is used only for columns whose storage type is main or
+      extended. (See <xref linkend="sql-altertable"/> for information on
+      column storage types.) Setting this property for a partitioned table
+      has no direct effect, because such tables have no storage of their own,
+      but the configured value is inherited by newly-created partitions.
+      The supported compression methods are <literal>pglz</literal> and
+      <literal>lz4</literal>.  <literal>lz4</literal> is available only if
+      <literal>--with-lz4</literal> was used when building
+      <productname>PostgreSQL</productname>. The default
       is <literal>pglz</literal>.
      </para>
     </listitem>
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index b78d49167b..95d5b1c12a 100644
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -477,8 +477,8 @@ toast_get_compression_oid(struct varlena *attr)
 			return InvalidOid;
 
 		/*
-		 * Just fetch the toast compress header to know the compression method
-		 * in the compressed data.
+		 * Fetch just enough of the value to examine the compression header,
+		 * so that we can find out the compression method.
 		 */
 		attr = toast_fetch_datum_slice(attr, 0, VARHDRSZ_COMPRESS);
 	}
@@ -503,7 +503,6 @@ toast_get_compression_handler(struct varlena *attr)
 
 	cmid = TOAST_COMPRESS_METHOD(attr);
 
-	/* Get the handler routines for the compression method */
 	switch (cmid)
 	{
 		case PGLZ_COMPRESSION_ID:
diff --git a/src/backend/access/compression/compress_lz4.c b/src/backend/access/compression/compress_lz4.c
index 1856cf7df7..3079eff7eb 100644
--- a/src/backend/access/compression/compress_lz4.c
+++ b/src/backend/access/compression/compress_lz4.c
@@ -23,7 +23,7 @@
 /*
  * lz4_cmcompress - compression routine for lz4 compression method
  *
- * Compresses source into dest using the default strategy. Returns the
+ * Compresses source into dest using the LZ4 defaults. Returns the
  * compressed varlena, or NULL if compression fails.
  */
 static struct varlena *
@@ -42,8 +42,8 @@ lz4_cmcompress(const struct varlena *value)
 	valsize = VARSIZE_ANY_EXHDR(value);
 
 	/*
-	 * Get maximum size of the compressed data that lz4 compression may output
-	 * and allocate the memory for holding the compressed data and the header.
+	 * Figure out the maximum possible size of the LZ4 output, add the bytes
+	 * that will be needed for varlena overhead, and allocate that amount.
 	 */
 	max_size = LZ4_compressBound(valsize);
 	tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESS);
@@ -83,10 +83,10 @@ lz4_cmdecompress(const struct varlena *value)
 	int32		rawsize;
 	struct varlena *result;
 
-	/* allocate memory for holding the uncompressed data */
+	/* allocate memory for the uncompressed data */
 	result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ);
 
-	/* decompress data using lz4 routine */
+	/* decompress the data */
 	rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESS,
 								  VARDATA(result),
 								  VARSIZE(value) - VARHDRSZ_COMPRESS,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f77deee399..920d9dd0d5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2117,7 +2117,7 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
 		TupleTableSlot *newslot = *outslot;
 
 		/*
-		 * If the called has passed an invalid slot then create a new slot.
+		 * If the caller has passed an invalid slot then create a new slot.
 		 * Otherwise, just clear the existing tuple from the slot.  This slot
 		 * should be stored by the caller so that it can be reused for
 		 * decompressing the subsequent tuples.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 18e8ecfd90..d8483c36b3 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1183,8 +1183,8 @@ typedef struct ModifyTableState
 	TupleTableSlot *mt_root_tuple_slot;
 
 	/*
-	 * Slot for storing the modified tuple, incase the target attribute's
-	 * compression method doesn't match with the source table.
+	 * Slot for storing the modified tuple, in case the target attribute's
+	 * compression method doesn't match that of the source table.
 	 */
 	TupleTableSlot *mt_decompress_tuple_slot;
 
-- 
2.17.0


--m51xatjYGsM+13rf
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v24-0006-alter-table-set-compression.patch"



^ permalink  raw  reply  [nested|flat] 46+ messages in thread

* [PATCH v24 5/7] fixups.patch
@ 2021-02-10 21:56  Robert Haas <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: Robert Haas @ 2021-02-10 21:56 UTC (permalink / raw)

---
 doc/src/sgml/ddl.sgml                         |  3 ---
 doc/src/sgml/ref/create_table.sgml            | 15 +++++++++++----
 src/backend/access/common/detoast.c           |  5 ++---
 src/backend/access/compression/compress_lz4.c | 10 +++++-----
 src/backend/executor/nodeModifyTable.c        |  2 +-
 src/include/nodes/execnodes.h                 |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 4d7ed698b9..1e9a4625cc 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3762,9 +3762,6 @@ CREATE TABLE measurement (
        <productname>PostgreSQL</productname>
        tables (or, possibly, foreign tables).  It is possible to specify a
        tablespace and storage parameters for each partition separately.
-       By default, each column in a partition inherits the compression method
-       from parent table's column, however a different compression method can be
-       set for each partition.
       </para>
 
       <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 51a7a977a5..a4b297340f 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -997,10 +997,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
-      This sets the compression method for a column.  The supported compression
-      methods are <literal>pglz</literal> and <literal>lz4</literal>.
-      <literal>lz4</literal> is available only if <literal>--with-lz4</literal>
-      was used when building <productname>PostgreSQL</productname>. The default
+      The <literal>COMPRESSION</literal> clause sets the compression method
+      for a column.  Compression is supported only for variable-width data
+      types, and is used only for columns whose storage type is main or
+      extended. (See <xref linkend="sql-altertable"/> for information on
+      column storage types.) Setting this property for a partitioned table
+      has no direct effect, because such tables have no storage of their own,
+      but the configured value is inherited by newly-created partitions.
+      The supported compression methods are <literal>pglz</literal> and
+      <literal>lz4</literal>.  <literal>lz4</literal> is available only if
+      <literal>--with-lz4</literal> was used when building
+      <productname>PostgreSQL</productname>. The default
       is <literal>pglz</literal>.
      </para>
     </listitem>
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index b78d49167b..95d5b1c12a 100644
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -477,8 +477,8 @@ toast_get_compression_oid(struct varlena *attr)
 			return InvalidOid;
 
 		/*
-		 * Just fetch the toast compress header to know the compression method
-		 * in the compressed data.
+		 * Fetch just enough of the value to examine the compression header,
+		 * so that we can find out the compression method.
 		 */
 		attr = toast_fetch_datum_slice(attr, 0, VARHDRSZ_COMPRESS);
 	}
@@ -503,7 +503,6 @@ toast_get_compression_handler(struct varlena *attr)
 
 	cmid = TOAST_COMPRESS_METHOD(attr);
 
-	/* Get the handler routines for the compression method */
 	switch (cmid)
 	{
 		case PGLZ_COMPRESSION_ID:
diff --git a/src/backend/access/compression/compress_lz4.c b/src/backend/access/compression/compress_lz4.c
index 1856cf7df7..3079eff7eb 100644
--- a/src/backend/access/compression/compress_lz4.c
+++ b/src/backend/access/compression/compress_lz4.c
@@ -23,7 +23,7 @@
 /*
  * lz4_cmcompress - compression routine for lz4 compression method
  *
- * Compresses source into dest using the default strategy. Returns the
+ * Compresses source into dest using the LZ4 defaults. Returns the
  * compressed varlena, or NULL if compression fails.
  */
 static struct varlena *
@@ -42,8 +42,8 @@ lz4_cmcompress(const struct varlena *value)
 	valsize = VARSIZE_ANY_EXHDR(value);
 
 	/*
-	 * Get maximum size of the compressed data that lz4 compression may output
-	 * and allocate the memory for holding the compressed data and the header.
+	 * Figure out the maximum possible size of the LZ4 output, add the bytes
+	 * that will be needed for varlena overhead, and allocate that amount.
 	 */
 	max_size = LZ4_compressBound(valsize);
 	tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESS);
@@ -83,10 +83,10 @@ lz4_cmdecompress(const struct varlena *value)
 	int32		rawsize;
 	struct varlena *result;
 
-	/* allocate memory for holding the uncompressed data */
+	/* allocate memory for the uncompressed data */
 	result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ);
 
-	/* decompress data using lz4 routine */
+	/* decompress the data */
 	rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESS,
 								  VARDATA(result),
 								  VARSIZE(value) - VARHDRSZ_COMPRESS,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f77deee399..920d9dd0d5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2117,7 +2117,7 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
 		TupleTableSlot *newslot = *outslot;
 
 		/*
-		 * If the called has passed an invalid slot then create a new slot.
+		 * If the caller has passed an invalid slot then create a new slot.
 		 * Otherwise, just clear the existing tuple from the slot.  This slot
 		 * should be stored by the caller so that it can be reused for
 		 * decompressing the subsequent tuples.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 18e8ecfd90..d8483c36b3 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1183,8 +1183,8 @@ typedef struct ModifyTableState
 	TupleTableSlot *mt_root_tuple_slot;
 
 	/*
-	 * Slot for storing the modified tuple, incase the target attribute's
-	 * compression method doesn't match with the source table.
+	 * Slot for storing the modified tuple, in case the target attribute's
+	 * compression method doesn't match that of the source table.
 	 */
 	TupleTableSlot *mt_decompress_tuple_slot;
 
-- 
2.17.0


--YZ5djTAD1cGYuMQK
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v24-0006-alter-table-set-compression.patch"



^ permalink  raw  reply  [nested|flat] 46+ messages in thread

* [PATCH v24 05/10] fixups.patch
@ 2021-02-10 21:56  Robert Haas <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: Robert Haas @ 2021-02-10 21:56 UTC (permalink / raw)

---
 doc/src/sgml/ddl.sgml                         |  3 ---
 doc/src/sgml/ref/create_table.sgml            | 15 +++++++++++----
 src/backend/access/common/detoast.c           |  5 ++---
 src/backend/access/compression/compress_lz4.c | 10 +++++-----
 src/backend/executor/nodeModifyTable.c        |  2 +-
 src/include/nodes/execnodes.h                 |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 4d7ed698b9..1e9a4625cc 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3762,9 +3762,6 @@ CREATE TABLE measurement (
        <productname>PostgreSQL</productname>
        tables (or, possibly, foreign tables).  It is possible to specify a
        tablespace and storage parameters for each partition separately.
-       By default, each column in a partition inherits the compression method
-       from parent table's column, however a different compression method can be
-       set for each partition.
       </para>
 
       <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 51a7a977a5..a4b297340f 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -997,10 +997,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
-      This sets the compression method for a column.  The supported compression
-      methods are <literal>pglz</literal> and <literal>lz4</literal>.
-      <literal>lz4</literal> is available only if <literal>--with-lz4</literal>
-      was used when building <productname>PostgreSQL</productname>. The default
+      The <literal>COMPRESSION</literal> clause sets the compression method
+      for a column.  Compression is supported only for variable-width data
+      types, and is used only for columns whose storage type is main or
+      extended. (See <xref linkend="sql-altertable"/> for information on
+      column storage types.) Setting this property for a partitioned table
+      has no direct effect, because such tables have no storage of their own,
+      but the configured value is inherited by newly-created partitions.
+      The supported compression methods are <literal>pglz</literal> and
+      <literal>lz4</literal>.  <literal>lz4</literal> is available only if
+      <literal>--with-lz4</literal> was used when building
+      <productname>PostgreSQL</productname>. The default
       is <literal>pglz</literal>.
      </para>
     </listitem>
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index b78d49167b..95d5b1c12a 100644
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -477,8 +477,8 @@ toast_get_compression_oid(struct varlena *attr)
 			return InvalidOid;
 
 		/*
-		 * Just fetch the toast compress header to know the compression method
-		 * in the compressed data.
+		 * Fetch just enough of the value to examine the compression header,
+		 * so that we can find out the compression method.
 		 */
 		attr = toast_fetch_datum_slice(attr, 0, VARHDRSZ_COMPRESS);
 	}
@@ -503,7 +503,6 @@ toast_get_compression_handler(struct varlena *attr)
 
 	cmid = TOAST_COMPRESS_METHOD(attr);
 
-	/* Get the handler routines for the compression method */
 	switch (cmid)
 	{
 		case PGLZ_COMPRESSION_ID:
diff --git a/src/backend/access/compression/compress_lz4.c b/src/backend/access/compression/compress_lz4.c
index 1856cf7df7..3079eff7eb 100644
--- a/src/backend/access/compression/compress_lz4.c
+++ b/src/backend/access/compression/compress_lz4.c
@@ -23,7 +23,7 @@
 /*
  * lz4_cmcompress - compression routine for lz4 compression method
  *
- * Compresses source into dest using the default strategy. Returns the
+ * Compresses source into dest using the LZ4 defaults. Returns the
  * compressed varlena, or NULL if compression fails.
  */
 static struct varlena *
@@ -42,8 +42,8 @@ lz4_cmcompress(const struct varlena *value)
 	valsize = VARSIZE_ANY_EXHDR(value);
 
 	/*
-	 * Get maximum size of the compressed data that lz4 compression may output
-	 * and allocate the memory for holding the compressed data and the header.
+	 * Figure out the maximum possible size of the LZ4 output, add the bytes
+	 * that will be needed for varlena overhead, and allocate that amount.
 	 */
 	max_size = LZ4_compressBound(valsize);
 	tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESS);
@@ -83,10 +83,10 @@ lz4_cmdecompress(const struct varlena *value)
 	int32		rawsize;
 	struct varlena *result;
 
-	/* allocate memory for holding the uncompressed data */
+	/* allocate memory for the uncompressed data */
 	result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ);
 
-	/* decompress data using lz4 routine */
+	/* decompress the data */
 	rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESS,
 								  VARDATA(result),
 								  VARSIZE(value) - VARHDRSZ_COMPRESS,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f77deee399..920d9dd0d5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2117,7 +2117,7 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
 		TupleTableSlot *newslot = *outslot;
 
 		/*
-		 * If the called has passed an invalid slot then create a new slot.
+		 * If the caller has passed an invalid slot then create a new slot.
 		 * Otherwise, just clear the existing tuple from the slot.  This slot
 		 * should be stored by the caller so that it can be reused for
 		 * decompressing the subsequent tuples.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 18e8ecfd90..d8483c36b3 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1183,8 +1183,8 @@ typedef struct ModifyTableState
 	TupleTableSlot *mt_root_tuple_slot;
 
 	/*
-	 * Slot for storing the modified tuple, incase the target attribute's
-	 * compression method doesn't match with the source table.
+	 * Slot for storing the modified tuple, in case the target attribute's
+	 * compression method doesn't match that of the source table.
 	 */
 	TupleTableSlot *mt_decompress_tuple_slot;
 
-- 
2.17.0


--m51xatjYGsM+13rf
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v24-0006-alter-table-set-compression.patch"



^ permalink  raw  reply  [nested|flat] 46+ messages in thread

* [PATCH v24 5/7] fixups.patch
@ 2021-02-10 21:56  Robert Haas <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: Robert Haas @ 2021-02-10 21:56 UTC (permalink / raw)

---
 doc/src/sgml/ddl.sgml                         |  3 ---
 doc/src/sgml/ref/create_table.sgml            | 15 +++++++++++----
 src/backend/access/common/detoast.c           |  5 ++---
 src/backend/access/compression/compress_lz4.c | 10 +++++-----
 src/backend/executor/nodeModifyTable.c        |  2 +-
 src/include/nodes/execnodes.h                 |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 4d7ed698b9..1e9a4625cc 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3762,9 +3762,6 @@ CREATE TABLE measurement (
        <productname>PostgreSQL</productname>
        tables (or, possibly, foreign tables).  It is possible to specify a
        tablespace and storage parameters for each partition separately.
-       By default, each column in a partition inherits the compression method
-       from parent table's column, however a different compression method can be
-       set for each partition.
       </para>
 
       <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 51a7a977a5..a4b297340f 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -997,10 +997,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
-      This sets the compression method for a column.  The supported compression
-      methods are <literal>pglz</literal> and <literal>lz4</literal>.
-      <literal>lz4</literal> is available only if <literal>--with-lz4</literal>
-      was used when building <productname>PostgreSQL</productname>. The default
+      The <literal>COMPRESSION</literal> clause sets the compression method
+      for a column.  Compression is supported only for variable-width data
+      types, and is used only for columns whose storage type is main or
+      extended. (See <xref linkend="sql-altertable"/> for information on
+      column storage types.) Setting this property for a partitioned table
+      has no direct effect, because such tables have no storage of their own,
+      but the configured value is inherited by newly-created partitions.
+      The supported compression methods are <literal>pglz</literal> and
+      <literal>lz4</literal>.  <literal>lz4</literal> is available only if
+      <literal>--with-lz4</literal> was used when building
+      <productname>PostgreSQL</productname>. The default
       is <literal>pglz</literal>.
      </para>
     </listitem>
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index b78d49167b..95d5b1c12a 100644
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -477,8 +477,8 @@ toast_get_compression_oid(struct varlena *attr)
 			return InvalidOid;
 
 		/*
-		 * Just fetch the toast compress header to know the compression method
-		 * in the compressed data.
+		 * Fetch just enough of the value to examine the compression header,
+		 * so that we can find out the compression method.
 		 */
 		attr = toast_fetch_datum_slice(attr, 0, VARHDRSZ_COMPRESS);
 	}
@@ -503,7 +503,6 @@ toast_get_compression_handler(struct varlena *attr)
 
 	cmid = TOAST_COMPRESS_METHOD(attr);
 
-	/* Get the handler routines for the compression method */
 	switch (cmid)
 	{
 		case PGLZ_COMPRESSION_ID:
diff --git a/src/backend/access/compression/compress_lz4.c b/src/backend/access/compression/compress_lz4.c
index 1856cf7df7..3079eff7eb 100644
--- a/src/backend/access/compression/compress_lz4.c
+++ b/src/backend/access/compression/compress_lz4.c
@@ -23,7 +23,7 @@
 /*
  * lz4_cmcompress - compression routine for lz4 compression method
  *
- * Compresses source into dest using the default strategy. Returns the
+ * Compresses source into dest using the LZ4 defaults. Returns the
  * compressed varlena, or NULL if compression fails.
  */
 static struct varlena *
@@ -42,8 +42,8 @@ lz4_cmcompress(const struct varlena *value)
 	valsize = VARSIZE_ANY_EXHDR(value);
 
 	/*
-	 * Get maximum size of the compressed data that lz4 compression may output
-	 * and allocate the memory for holding the compressed data and the header.
+	 * Figure out the maximum possible size of the LZ4 output, add the bytes
+	 * that will be needed for varlena overhead, and allocate that amount.
 	 */
 	max_size = LZ4_compressBound(valsize);
 	tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESS);
@@ -83,10 +83,10 @@ lz4_cmdecompress(const struct varlena *value)
 	int32		rawsize;
 	struct varlena *result;
 
-	/* allocate memory for holding the uncompressed data */
+	/* allocate memory for the uncompressed data */
 	result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ);
 
-	/* decompress data using lz4 routine */
+	/* decompress the data */
 	rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESS,
 								  VARDATA(result),
 								  VARSIZE(value) - VARHDRSZ_COMPRESS,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f77deee399..920d9dd0d5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2117,7 +2117,7 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
 		TupleTableSlot *newslot = *outslot;
 
 		/*
-		 * If the called has passed an invalid slot then create a new slot.
+		 * If the caller has passed an invalid slot then create a new slot.
 		 * Otherwise, just clear the existing tuple from the slot.  This slot
 		 * should be stored by the caller so that it can be reused for
 		 * decompressing the subsequent tuples.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 18e8ecfd90..d8483c36b3 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1183,8 +1183,8 @@ typedef struct ModifyTableState
 	TupleTableSlot *mt_root_tuple_slot;
 
 	/*
-	 * Slot for storing the modified tuple, incase the target attribute's
-	 * compression method doesn't match with the source table.
+	 * Slot for storing the modified tuple, in case the target attribute's
+	 * compression method doesn't match that of the source table.
 	 */
 	TupleTableSlot *mt_decompress_tuple_slot;
 
-- 
2.17.0


--YZ5djTAD1cGYuMQK
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v24-0006-alter-table-set-compression.patch"



^ permalink  raw  reply  [nested|flat] 46+ messages in thread

* [PATCH v24 05/10] fixups.patch
@ 2021-02-10 21:56  Robert Haas <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: Robert Haas @ 2021-02-10 21:56 UTC (permalink / raw)

---
 doc/src/sgml/ddl.sgml                         |  3 ---
 doc/src/sgml/ref/create_table.sgml            | 15 +++++++++++----
 src/backend/access/common/detoast.c           |  5 ++---
 src/backend/access/compression/compress_lz4.c | 10 +++++-----
 src/backend/executor/nodeModifyTable.c        |  2 +-
 src/include/nodes/execnodes.h                 |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 4d7ed698b9..1e9a4625cc 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3762,9 +3762,6 @@ CREATE TABLE measurement (
        <productname>PostgreSQL</productname>
        tables (or, possibly, foreign tables).  It is possible to specify a
        tablespace and storage parameters for each partition separately.
-       By default, each column in a partition inherits the compression method
-       from parent table's column, however a different compression method can be
-       set for each partition.
       </para>
 
       <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 51a7a977a5..a4b297340f 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -997,10 +997,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
-      This sets the compression method for a column.  The supported compression
-      methods are <literal>pglz</literal> and <literal>lz4</literal>.
-      <literal>lz4</literal> is available only if <literal>--with-lz4</literal>
-      was used when building <productname>PostgreSQL</productname>. The default
+      The <literal>COMPRESSION</literal> clause sets the compression method
+      for a column.  Compression is supported only for variable-width data
+      types, and is used only for columns whose storage type is main or
+      extended. (See <xref linkend="sql-altertable"/> for information on
+      column storage types.) Setting this property for a partitioned table
+      has no direct effect, because such tables have no storage of their own,
+      but the configured value is inherited by newly-created partitions.
+      The supported compression methods are <literal>pglz</literal> and
+      <literal>lz4</literal>.  <literal>lz4</literal> is available only if
+      <literal>--with-lz4</literal> was used when building
+      <productname>PostgreSQL</productname>. The default
       is <literal>pglz</literal>.
      </para>
     </listitem>
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index b78d49167b..95d5b1c12a 100644
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -477,8 +477,8 @@ toast_get_compression_oid(struct varlena *attr)
 			return InvalidOid;
 
 		/*
-		 * Just fetch the toast compress header to know the compression method
-		 * in the compressed data.
+		 * Fetch just enough of the value to examine the compression header,
+		 * so that we can find out the compression method.
 		 */
 		attr = toast_fetch_datum_slice(attr, 0, VARHDRSZ_COMPRESS);
 	}
@@ -503,7 +503,6 @@ toast_get_compression_handler(struct varlena *attr)
 
 	cmid = TOAST_COMPRESS_METHOD(attr);
 
-	/* Get the handler routines for the compression method */
 	switch (cmid)
 	{
 		case PGLZ_COMPRESSION_ID:
diff --git a/src/backend/access/compression/compress_lz4.c b/src/backend/access/compression/compress_lz4.c
index 1856cf7df7..3079eff7eb 100644
--- a/src/backend/access/compression/compress_lz4.c
+++ b/src/backend/access/compression/compress_lz4.c
@@ -23,7 +23,7 @@
 /*
  * lz4_cmcompress - compression routine for lz4 compression method
  *
- * Compresses source into dest using the default strategy. Returns the
+ * Compresses source into dest using the LZ4 defaults. Returns the
  * compressed varlena, or NULL if compression fails.
  */
 static struct varlena *
@@ -42,8 +42,8 @@ lz4_cmcompress(const struct varlena *value)
 	valsize = VARSIZE_ANY_EXHDR(value);
 
 	/*
-	 * Get maximum size of the compressed data that lz4 compression may output
-	 * and allocate the memory for holding the compressed data and the header.
+	 * Figure out the maximum possible size of the LZ4 output, add the bytes
+	 * that will be needed for varlena overhead, and allocate that amount.
 	 */
 	max_size = LZ4_compressBound(valsize);
 	tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESS);
@@ -83,10 +83,10 @@ lz4_cmdecompress(const struct varlena *value)
 	int32		rawsize;
 	struct varlena *result;
 
-	/* allocate memory for holding the uncompressed data */
+	/* allocate memory for the uncompressed data */
 	result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ);
 
-	/* decompress data using lz4 routine */
+	/* decompress the data */
 	rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESS,
 								  VARDATA(result),
 								  VARSIZE(value) - VARHDRSZ_COMPRESS,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f77deee399..920d9dd0d5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2117,7 +2117,7 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
 		TupleTableSlot *newslot = *outslot;
 
 		/*
-		 * If the called has passed an invalid slot then create a new slot.
+		 * If the caller has passed an invalid slot then create a new slot.
 		 * Otherwise, just clear the existing tuple from the slot.  This slot
 		 * should be stored by the caller so that it can be reused for
 		 * decompressing the subsequent tuples.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 18e8ecfd90..d8483c36b3 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1183,8 +1183,8 @@ typedef struct ModifyTableState
 	TupleTableSlot *mt_root_tuple_slot;
 
 	/*
-	 * Slot for storing the modified tuple, incase the target attribute's
-	 * compression method doesn't match with the source table.
+	 * Slot for storing the modified tuple, in case the target attribute's
+	 * compression method doesn't match that of the source table.
 	 */
 	TupleTableSlot *mt_decompress_tuple_slot;
 
-- 
2.17.0


--m51xatjYGsM+13rf
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v24-0006-alter-table-set-compression.patch"



^ permalink  raw  reply  [nested|flat] 46+ messages in thread

* [PATCH v24 5/7] fixups.patch
@ 2021-02-10 21:56  Robert Haas <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: Robert Haas @ 2021-02-10 21:56 UTC (permalink / raw)

---
 doc/src/sgml/ddl.sgml                         |  3 ---
 doc/src/sgml/ref/create_table.sgml            | 15 +++++++++++----
 src/backend/access/common/detoast.c           |  5 ++---
 src/backend/access/compression/compress_lz4.c | 10 +++++-----
 src/backend/executor/nodeModifyTable.c        |  2 +-
 src/include/nodes/execnodes.h                 |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 4d7ed698b9..1e9a4625cc 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3762,9 +3762,6 @@ CREATE TABLE measurement (
        <productname>PostgreSQL</productname>
        tables (or, possibly, foreign tables).  It is possible to specify a
        tablespace and storage parameters for each partition separately.
-       By default, each column in a partition inherits the compression method
-       from parent table's column, however a different compression method can be
-       set for each partition.
       </para>
 
       <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 51a7a977a5..a4b297340f 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -997,10 +997,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
-      This sets the compression method for a column.  The supported compression
-      methods are <literal>pglz</literal> and <literal>lz4</literal>.
-      <literal>lz4</literal> is available only if <literal>--with-lz4</literal>
-      was used when building <productname>PostgreSQL</productname>. The default
+      The <literal>COMPRESSION</literal> clause sets the compression method
+      for a column.  Compression is supported only for variable-width data
+      types, and is used only for columns whose storage type is main or
+      extended. (See <xref linkend="sql-altertable"/> for information on
+      column storage types.) Setting this property for a partitioned table
+      has no direct effect, because such tables have no storage of their own,
+      but the configured value is inherited by newly-created partitions.
+      The supported compression methods are <literal>pglz</literal> and
+      <literal>lz4</literal>.  <literal>lz4</literal> is available only if
+      <literal>--with-lz4</literal> was used when building
+      <productname>PostgreSQL</productname>. The default
       is <literal>pglz</literal>.
      </para>
     </listitem>
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index b78d49167b..95d5b1c12a 100644
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -477,8 +477,8 @@ toast_get_compression_oid(struct varlena *attr)
 			return InvalidOid;
 
 		/*
-		 * Just fetch the toast compress header to know the compression method
-		 * in the compressed data.
+		 * Fetch just enough of the value to examine the compression header,
+		 * so that we can find out the compression method.
 		 */
 		attr = toast_fetch_datum_slice(attr, 0, VARHDRSZ_COMPRESS);
 	}
@@ -503,7 +503,6 @@ toast_get_compression_handler(struct varlena *attr)
 
 	cmid = TOAST_COMPRESS_METHOD(attr);
 
-	/* Get the handler routines for the compression method */
 	switch (cmid)
 	{
 		case PGLZ_COMPRESSION_ID:
diff --git a/src/backend/access/compression/compress_lz4.c b/src/backend/access/compression/compress_lz4.c
index 1856cf7df7..3079eff7eb 100644
--- a/src/backend/access/compression/compress_lz4.c
+++ b/src/backend/access/compression/compress_lz4.c
@@ -23,7 +23,7 @@
 /*
  * lz4_cmcompress - compression routine for lz4 compression method
  *
- * Compresses source into dest using the default strategy. Returns the
+ * Compresses source into dest using the LZ4 defaults. Returns the
  * compressed varlena, or NULL if compression fails.
  */
 static struct varlena *
@@ -42,8 +42,8 @@ lz4_cmcompress(const struct varlena *value)
 	valsize = VARSIZE_ANY_EXHDR(value);
 
 	/*
-	 * Get maximum size of the compressed data that lz4 compression may output
-	 * and allocate the memory for holding the compressed data and the header.
+	 * Figure out the maximum possible size of the LZ4 output, add the bytes
+	 * that will be needed for varlena overhead, and allocate that amount.
 	 */
 	max_size = LZ4_compressBound(valsize);
 	tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESS);
@@ -83,10 +83,10 @@ lz4_cmdecompress(const struct varlena *value)
 	int32		rawsize;
 	struct varlena *result;
 
-	/* allocate memory for holding the uncompressed data */
+	/* allocate memory for the uncompressed data */
 	result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ);
 
-	/* decompress data using lz4 routine */
+	/* decompress the data */
 	rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESS,
 								  VARDATA(result),
 								  VARSIZE(value) - VARHDRSZ_COMPRESS,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f77deee399..920d9dd0d5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2117,7 +2117,7 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
 		TupleTableSlot *newslot = *outslot;
 
 		/*
-		 * If the called has passed an invalid slot then create a new slot.
+		 * If the caller has passed an invalid slot then create a new slot.
 		 * Otherwise, just clear the existing tuple from the slot.  This slot
 		 * should be stored by the caller so that it can be reused for
 		 * decompressing the subsequent tuples.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 18e8ecfd90..d8483c36b3 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1183,8 +1183,8 @@ typedef struct ModifyTableState
 	TupleTableSlot *mt_root_tuple_slot;
 
 	/*
-	 * Slot for storing the modified tuple, incase the target attribute's
-	 * compression method doesn't match with the source table.
+	 * Slot for storing the modified tuple, in case the target attribute's
+	 * compression method doesn't match that of the source table.
 	 */
 	TupleTableSlot *mt_decompress_tuple_slot;
 
-- 
2.17.0


--YZ5djTAD1cGYuMQK
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v24-0006-alter-table-set-compression.patch"



^ permalink  raw  reply  [nested|flat] 46+ messages in thread

* [PATCH v24 05/10] fixups.patch
@ 2021-02-10 21:56  Robert Haas <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: Robert Haas @ 2021-02-10 21:56 UTC (permalink / raw)

---
 doc/src/sgml/ddl.sgml                         |  3 ---
 doc/src/sgml/ref/create_table.sgml            | 15 +++++++++++----
 src/backend/access/common/detoast.c           |  5 ++---
 src/backend/access/compression/compress_lz4.c | 10 +++++-----
 src/backend/executor/nodeModifyTable.c        |  2 +-
 src/include/nodes/execnodes.h                 |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 4d7ed698b9..1e9a4625cc 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3762,9 +3762,6 @@ CREATE TABLE measurement (
        <productname>PostgreSQL</productname>
        tables (or, possibly, foreign tables).  It is possible to specify a
        tablespace and storage parameters for each partition separately.
-       By default, each column in a partition inherits the compression method
-       from parent table's column, however a different compression method can be
-       set for each partition.
       </para>
 
       <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 51a7a977a5..a4b297340f 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -997,10 +997,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
-      This sets the compression method for a column.  The supported compression
-      methods are <literal>pglz</literal> and <literal>lz4</literal>.
-      <literal>lz4</literal> is available only if <literal>--with-lz4</literal>
-      was used when building <productname>PostgreSQL</productname>. The default
+      The <literal>COMPRESSION</literal> clause sets the compression method
+      for a column.  Compression is supported only for variable-width data
+      types, and is used only for columns whose storage type is main or
+      extended. (See <xref linkend="sql-altertable"/> for information on
+      column storage types.) Setting this property for a partitioned table
+      has no direct effect, because such tables have no storage of their own,
+      but the configured value is inherited by newly-created partitions.
+      The supported compression methods are <literal>pglz</literal> and
+      <literal>lz4</literal>.  <literal>lz4</literal> is available only if
+      <literal>--with-lz4</literal> was used when building
+      <productname>PostgreSQL</productname>. The default
       is <literal>pglz</literal>.
      </para>
     </listitem>
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index b78d49167b..95d5b1c12a 100644
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -477,8 +477,8 @@ toast_get_compression_oid(struct varlena *attr)
 			return InvalidOid;
 
 		/*
-		 * Just fetch the toast compress header to know the compression method
-		 * in the compressed data.
+		 * Fetch just enough of the value to examine the compression header,
+		 * so that we can find out the compression method.
 		 */
 		attr = toast_fetch_datum_slice(attr, 0, VARHDRSZ_COMPRESS);
 	}
@@ -503,7 +503,6 @@ toast_get_compression_handler(struct varlena *attr)
 
 	cmid = TOAST_COMPRESS_METHOD(attr);
 
-	/* Get the handler routines for the compression method */
 	switch (cmid)
 	{
 		case PGLZ_COMPRESSION_ID:
diff --git a/src/backend/access/compression/compress_lz4.c b/src/backend/access/compression/compress_lz4.c
index 1856cf7df7..3079eff7eb 100644
--- a/src/backend/access/compression/compress_lz4.c
+++ b/src/backend/access/compression/compress_lz4.c
@@ -23,7 +23,7 @@
 /*
  * lz4_cmcompress - compression routine for lz4 compression method
  *
- * Compresses source into dest using the default strategy. Returns the
+ * Compresses source into dest using the LZ4 defaults. Returns the
  * compressed varlena, or NULL if compression fails.
  */
 static struct varlena *
@@ -42,8 +42,8 @@ lz4_cmcompress(const struct varlena *value)
 	valsize = VARSIZE_ANY_EXHDR(value);
 
 	/*
-	 * Get maximum size of the compressed data that lz4 compression may output
-	 * and allocate the memory for holding the compressed data and the header.
+	 * Figure out the maximum possible size of the LZ4 output, add the bytes
+	 * that will be needed for varlena overhead, and allocate that amount.
 	 */
 	max_size = LZ4_compressBound(valsize);
 	tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESS);
@@ -83,10 +83,10 @@ lz4_cmdecompress(const struct varlena *value)
 	int32		rawsize;
 	struct varlena *result;
 
-	/* allocate memory for holding the uncompressed data */
+	/* allocate memory for the uncompressed data */
 	result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ);
 
-	/* decompress data using lz4 routine */
+	/* decompress the data */
 	rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESS,
 								  VARDATA(result),
 								  VARSIZE(value) - VARHDRSZ_COMPRESS,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f77deee399..920d9dd0d5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2117,7 +2117,7 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
 		TupleTableSlot *newslot = *outslot;
 
 		/*
-		 * If the called has passed an invalid slot then create a new slot.
+		 * If the caller has passed an invalid slot then create a new slot.
 		 * Otherwise, just clear the existing tuple from the slot.  This slot
 		 * should be stored by the caller so that it can be reused for
 		 * decompressing the subsequent tuples.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 18e8ecfd90..d8483c36b3 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1183,8 +1183,8 @@ typedef struct ModifyTableState
 	TupleTableSlot *mt_root_tuple_slot;
 
 	/*
-	 * Slot for storing the modified tuple, incase the target attribute's
-	 * compression method doesn't match with the source table.
+	 * Slot for storing the modified tuple, in case the target attribute's
+	 * compression method doesn't match that of the source table.
 	 */
 	TupleTableSlot *mt_decompress_tuple_slot;
 
-- 
2.17.0


--m51xatjYGsM+13rf
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v24-0006-alter-table-set-compression.patch"



^ permalink  raw  reply  [nested|flat] 46+ messages in thread

* [PATCH v24 5/7] fixups.patch
@ 2021-02-10 21:56  Robert Haas <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: Robert Haas @ 2021-02-10 21:56 UTC (permalink / raw)

---
 doc/src/sgml/ddl.sgml                         |  3 ---
 doc/src/sgml/ref/create_table.sgml            | 15 +++++++++++----
 src/backend/access/common/detoast.c           |  5 ++---
 src/backend/access/compression/compress_lz4.c | 10 +++++-----
 src/backend/executor/nodeModifyTable.c        |  2 +-
 src/include/nodes/execnodes.h                 |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 4d7ed698b9..1e9a4625cc 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3762,9 +3762,6 @@ CREATE TABLE measurement (
        <productname>PostgreSQL</productname>
        tables (or, possibly, foreign tables).  It is possible to specify a
        tablespace and storage parameters for each partition separately.
-       By default, each column in a partition inherits the compression method
-       from parent table's column, however a different compression method can be
-       set for each partition.
       </para>
 
       <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 51a7a977a5..a4b297340f 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -997,10 +997,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
-      This sets the compression method for a column.  The supported compression
-      methods are <literal>pglz</literal> and <literal>lz4</literal>.
-      <literal>lz4</literal> is available only if <literal>--with-lz4</literal>
-      was used when building <productname>PostgreSQL</productname>. The default
+      The <literal>COMPRESSION</literal> clause sets the compression method
+      for a column.  Compression is supported only for variable-width data
+      types, and is used only for columns whose storage type is main or
+      extended. (See <xref linkend="sql-altertable"/> for information on
+      column storage types.) Setting this property for a partitioned table
+      has no direct effect, because such tables have no storage of their own,
+      but the configured value is inherited by newly-created partitions.
+      The supported compression methods are <literal>pglz</literal> and
+      <literal>lz4</literal>.  <literal>lz4</literal> is available only if
+      <literal>--with-lz4</literal> was used when building
+      <productname>PostgreSQL</productname>. The default
       is <literal>pglz</literal>.
      </para>
     </listitem>
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index b78d49167b..95d5b1c12a 100644
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -477,8 +477,8 @@ toast_get_compression_oid(struct varlena *attr)
 			return InvalidOid;
 
 		/*
-		 * Just fetch the toast compress header to know the compression method
-		 * in the compressed data.
+		 * Fetch just enough of the value to examine the compression header,
+		 * so that we can find out the compression method.
 		 */
 		attr = toast_fetch_datum_slice(attr, 0, VARHDRSZ_COMPRESS);
 	}
@@ -503,7 +503,6 @@ toast_get_compression_handler(struct varlena *attr)
 
 	cmid = TOAST_COMPRESS_METHOD(attr);
 
-	/* Get the handler routines for the compression method */
 	switch (cmid)
 	{
 		case PGLZ_COMPRESSION_ID:
diff --git a/src/backend/access/compression/compress_lz4.c b/src/backend/access/compression/compress_lz4.c
index 1856cf7df7..3079eff7eb 100644
--- a/src/backend/access/compression/compress_lz4.c
+++ b/src/backend/access/compression/compress_lz4.c
@@ -23,7 +23,7 @@
 /*
  * lz4_cmcompress - compression routine for lz4 compression method
  *
- * Compresses source into dest using the default strategy. Returns the
+ * Compresses source into dest using the LZ4 defaults. Returns the
  * compressed varlena, or NULL if compression fails.
  */
 static struct varlena *
@@ -42,8 +42,8 @@ lz4_cmcompress(const struct varlena *value)
 	valsize = VARSIZE_ANY_EXHDR(value);
 
 	/*
-	 * Get maximum size of the compressed data that lz4 compression may output
-	 * and allocate the memory for holding the compressed data and the header.
+	 * Figure out the maximum possible size of the LZ4 output, add the bytes
+	 * that will be needed for varlena overhead, and allocate that amount.
 	 */
 	max_size = LZ4_compressBound(valsize);
 	tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESS);
@@ -83,10 +83,10 @@ lz4_cmdecompress(const struct varlena *value)
 	int32		rawsize;
 	struct varlena *result;
 
-	/* allocate memory for holding the uncompressed data */
+	/* allocate memory for the uncompressed data */
 	result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ);
 
-	/* decompress data using lz4 routine */
+	/* decompress the data */
 	rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESS,
 								  VARDATA(result),
 								  VARSIZE(value) - VARHDRSZ_COMPRESS,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f77deee399..920d9dd0d5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2117,7 +2117,7 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
 		TupleTableSlot *newslot = *outslot;
 
 		/*
-		 * If the called has passed an invalid slot then create a new slot.
+		 * If the caller has passed an invalid slot then create a new slot.
 		 * Otherwise, just clear the existing tuple from the slot.  This slot
 		 * should be stored by the caller so that it can be reused for
 		 * decompressing the subsequent tuples.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 18e8ecfd90..d8483c36b3 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1183,8 +1183,8 @@ typedef struct ModifyTableState
 	TupleTableSlot *mt_root_tuple_slot;
 
 	/*
-	 * Slot for storing the modified tuple, incase the target attribute's
-	 * compression method doesn't match with the source table.
+	 * Slot for storing the modified tuple, in case the target attribute's
+	 * compression method doesn't match that of the source table.
 	 */
 	TupleTableSlot *mt_decompress_tuple_slot;
 
-- 
2.17.0


--YZ5djTAD1cGYuMQK
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v24-0006-alter-table-set-compression.patch"



^ permalink  raw  reply  [nested|flat] 46+ messages in thread

* [PATCH v24 05/10] fixups.patch
@ 2021-02-10 21:56  Robert Haas <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: Robert Haas @ 2021-02-10 21:56 UTC (permalink / raw)

---
 doc/src/sgml/ddl.sgml                         |  3 ---
 doc/src/sgml/ref/create_table.sgml            | 15 +++++++++++----
 src/backend/access/common/detoast.c           |  5 ++---
 src/backend/access/compression/compress_lz4.c | 10 +++++-----
 src/backend/executor/nodeModifyTable.c        |  2 +-
 src/include/nodes/execnodes.h                 |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 4d7ed698b9..1e9a4625cc 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3762,9 +3762,6 @@ CREATE TABLE measurement (
        <productname>PostgreSQL</productname>
        tables (or, possibly, foreign tables).  It is possible to specify a
        tablespace and storage parameters for each partition separately.
-       By default, each column in a partition inherits the compression method
-       from parent table's column, however a different compression method can be
-       set for each partition.
       </para>
 
       <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 51a7a977a5..a4b297340f 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -997,10 +997,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
-      This sets the compression method for a column.  The supported compression
-      methods are <literal>pglz</literal> and <literal>lz4</literal>.
-      <literal>lz4</literal> is available only if <literal>--with-lz4</literal>
-      was used when building <productname>PostgreSQL</productname>. The default
+      The <literal>COMPRESSION</literal> clause sets the compression method
+      for a column.  Compression is supported only for variable-width data
+      types, and is used only for columns whose storage type is main or
+      extended. (See <xref linkend="sql-altertable"/> for information on
+      column storage types.) Setting this property for a partitioned table
+      has no direct effect, because such tables have no storage of their own,
+      but the configured value is inherited by newly-created partitions.
+      The supported compression methods are <literal>pglz</literal> and
+      <literal>lz4</literal>.  <literal>lz4</literal> is available only if
+      <literal>--with-lz4</literal> was used when building
+      <productname>PostgreSQL</productname>. The default
       is <literal>pglz</literal>.
      </para>
     </listitem>
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index b78d49167b..95d5b1c12a 100644
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -477,8 +477,8 @@ toast_get_compression_oid(struct varlena *attr)
 			return InvalidOid;
 
 		/*
-		 * Just fetch the toast compress header to know the compression method
-		 * in the compressed data.
+		 * Fetch just enough of the value to examine the compression header,
+		 * so that we can find out the compression method.
 		 */
 		attr = toast_fetch_datum_slice(attr, 0, VARHDRSZ_COMPRESS);
 	}
@@ -503,7 +503,6 @@ toast_get_compression_handler(struct varlena *attr)
 
 	cmid = TOAST_COMPRESS_METHOD(attr);
 
-	/* Get the handler routines for the compression method */
 	switch (cmid)
 	{
 		case PGLZ_COMPRESSION_ID:
diff --git a/src/backend/access/compression/compress_lz4.c b/src/backend/access/compression/compress_lz4.c
index 1856cf7df7..3079eff7eb 100644
--- a/src/backend/access/compression/compress_lz4.c
+++ b/src/backend/access/compression/compress_lz4.c
@@ -23,7 +23,7 @@
 /*
  * lz4_cmcompress - compression routine for lz4 compression method
  *
- * Compresses source into dest using the default strategy. Returns the
+ * Compresses source into dest using the LZ4 defaults. Returns the
  * compressed varlena, or NULL if compression fails.
  */
 static struct varlena *
@@ -42,8 +42,8 @@ lz4_cmcompress(const struct varlena *value)
 	valsize = VARSIZE_ANY_EXHDR(value);
 
 	/*
-	 * Get maximum size of the compressed data that lz4 compression may output
-	 * and allocate the memory for holding the compressed data and the header.
+	 * Figure out the maximum possible size of the LZ4 output, add the bytes
+	 * that will be needed for varlena overhead, and allocate that amount.
 	 */
 	max_size = LZ4_compressBound(valsize);
 	tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESS);
@@ -83,10 +83,10 @@ lz4_cmdecompress(const struct varlena *value)
 	int32		rawsize;
 	struct varlena *result;
 
-	/* allocate memory for holding the uncompressed data */
+	/* allocate memory for the uncompressed data */
 	result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ);
 
-	/* decompress data using lz4 routine */
+	/* decompress the data */
 	rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESS,
 								  VARDATA(result),
 								  VARSIZE(value) - VARHDRSZ_COMPRESS,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f77deee399..920d9dd0d5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2117,7 +2117,7 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
 		TupleTableSlot *newslot = *outslot;
 
 		/*
-		 * If the called has passed an invalid slot then create a new slot.
+		 * If the caller has passed an invalid slot then create a new slot.
 		 * Otherwise, just clear the existing tuple from the slot.  This slot
 		 * should be stored by the caller so that it can be reused for
 		 * decompressing the subsequent tuples.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 18e8ecfd90..d8483c36b3 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1183,8 +1183,8 @@ typedef struct ModifyTableState
 	TupleTableSlot *mt_root_tuple_slot;
 
 	/*
-	 * Slot for storing the modified tuple, incase the target attribute's
-	 * compression method doesn't match with the source table.
+	 * Slot for storing the modified tuple, in case the target attribute's
+	 * compression method doesn't match that of the source table.
 	 */
 	TupleTableSlot *mt_decompress_tuple_slot;
 
-- 
2.17.0


--m51xatjYGsM+13rf
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v24-0006-alter-table-set-compression.patch"



^ permalink  raw  reply  [nested|flat] 46+ messages in thread

* [PATCH v24 5/7] fixups.patch
@ 2021-02-10 21:56  Robert Haas <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: Robert Haas @ 2021-02-10 21:56 UTC (permalink / raw)

---
 doc/src/sgml/ddl.sgml                         |  3 ---
 doc/src/sgml/ref/create_table.sgml            | 15 +++++++++++----
 src/backend/access/common/detoast.c           |  5 ++---
 src/backend/access/compression/compress_lz4.c | 10 +++++-----
 src/backend/executor/nodeModifyTable.c        |  2 +-
 src/include/nodes/execnodes.h                 |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 4d7ed698b9..1e9a4625cc 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3762,9 +3762,6 @@ CREATE TABLE measurement (
        <productname>PostgreSQL</productname>
        tables (or, possibly, foreign tables).  It is possible to specify a
        tablespace and storage parameters for each partition separately.
-       By default, each column in a partition inherits the compression method
-       from parent table's column, however a different compression method can be
-       set for each partition.
       </para>
 
       <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 51a7a977a5..a4b297340f 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -997,10 +997,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
-      This sets the compression method for a column.  The supported compression
-      methods are <literal>pglz</literal> and <literal>lz4</literal>.
-      <literal>lz4</literal> is available only if <literal>--with-lz4</literal>
-      was used when building <productname>PostgreSQL</productname>. The default
+      The <literal>COMPRESSION</literal> clause sets the compression method
+      for a column.  Compression is supported only for variable-width data
+      types, and is used only for columns whose storage type is main or
+      extended. (See <xref linkend="sql-altertable"/> for information on
+      column storage types.) Setting this property for a partitioned table
+      has no direct effect, because such tables have no storage of their own,
+      but the configured value is inherited by newly-created partitions.
+      The supported compression methods are <literal>pglz</literal> and
+      <literal>lz4</literal>.  <literal>lz4</literal> is available only if
+      <literal>--with-lz4</literal> was used when building
+      <productname>PostgreSQL</productname>. The default
       is <literal>pglz</literal>.
      </para>
     </listitem>
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index b78d49167b..95d5b1c12a 100644
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -477,8 +477,8 @@ toast_get_compression_oid(struct varlena *attr)
 			return InvalidOid;
 
 		/*
-		 * Just fetch the toast compress header to know the compression method
-		 * in the compressed data.
+		 * Fetch just enough of the value to examine the compression header,
+		 * so that we can find out the compression method.
 		 */
 		attr = toast_fetch_datum_slice(attr, 0, VARHDRSZ_COMPRESS);
 	}
@@ -503,7 +503,6 @@ toast_get_compression_handler(struct varlena *attr)
 
 	cmid = TOAST_COMPRESS_METHOD(attr);
 
-	/* Get the handler routines for the compression method */
 	switch (cmid)
 	{
 		case PGLZ_COMPRESSION_ID:
diff --git a/src/backend/access/compression/compress_lz4.c b/src/backend/access/compression/compress_lz4.c
index 1856cf7df7..3079eff7eb 100644
--- a/src/backend/access/compression/compress_lz4.c
+++ b/src/backend/access/compression/compress_lz4.c
@@ -23,7 +23,7 @@
 /*
  * lz4_cmcompress - compression routine for lz4 compression method
  *
- * Compresses source into dest using the default strategy. Returns the
+ * Compresses source into dest using the LZ4 defaults. Returns the
  * compressed varlena, or NULL if compression fails.
  */
 static struct varlena *
@@ -42,8 +42,8 @@ lz4_cmcompress(const struct varlena *value)
 	valsize = VARSIZE_ANY_EXHDR(value);
 
 	/*
-	 * Get maximum size of the compressed data that lz4 compression may output
-	 * and allocate the memory for holding the compressed data and the header.
+	 * Figure out the maximum possible size of the LZ4 output, add the bytes
+	 * that will be needed for varlena overhead, and allocate that amount.
 	 */
 	max_size = LZ4_compressBound(valsize);
 	tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESS);
@@ -83,10 +83,10 @@ lz4_cmdecompress(const struct varlena *value)
 	int32		rawsize;
 	struct varlena *result;
 
-	/* allocate memory for holding the uncompressed data */
+	/* allocate memory for the uncompressed data */
 	result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ);
 
-	/* decompress data using lz4 routine */
+	/* decompress the data */
 	rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESS,
 								  VARDATA(result),
 								  VARSIZE(value) - VARHDRSZ_COMPRESS,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f77deee399..920d9dd0d5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2117,7 +2117,7 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
 		TupleTableSlot *newslot = *outslot;
 
 		/*
-		 * If the called has passed an invalid slot then create a new slot.
+		 * If the caller has passed an invalid slot then create a new slot.
 		 * Otherwise, just clear the existing tuple from the slot.  This slot
 		 * should be stored by the caller so that it can be reused for
 		 * decompressing the subsequent tuples.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 18e8ecfd90..d8483c36b3 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1183,8 +1183,8 @@ typedef struct ModifyTableState
 	TupleTableSlot *mt_root_tuple_slot;
 
 	/*
-	 * Slot for storing the modified tuple, incase the target attribute's
-	 * compression method doesn't match with the source table.
+	 * Slot for storing the modified tuple, in case the target attribute's
+	 * compression method doesn't match that of the source table.
 	 */
 	TupleTableSlot *mt_decompress_tuple_slot;
 
-- 
2.17.0


--YZ5djTAD1cGYuMQK
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v24-0006-alter-table-set-compression.patch"



^ permalink  raw  reply  [nested|flat] 46+ messages in thread

* [PATCH v24 05/10] fixups.patch
@ 2021-02-10 21:56  Robert Haas <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: Robert Haas @ 2021-02-10 21:56 UTC (permalink / raw)

---
 doc/src/sgml/ddl.sgml                         |  3 ---
 doc/src/sgml/ref/create_table.sgml            | 15 +++++++++++----
 src/backend/access/common/detoast.c           |  5 ++---
 src/backend/access/compression/compress_lz4.c | 10 +++++-----
 src/backend/executor/nodeModifyTable.c        |  2 +-
 src/include/nodes/execnodes.h                 |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 4d7ed698b9..1e9a4625cc 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3762,9 +3762,6 @@ CREATE TABLE measurement (
        <productname>PostgreSQL</productname>
        tables (or, possibly, foreign tables).  It is possible to specify a
        tablespace and storage parameters for each partition separately.
-       By default, each column in a partition inherits the compression method
-       from parent table's column, however a different compression method can be
-       set for each partition.
       </para>
 
       <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 51a7a977a5..a4b297340f 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -997,10 +997,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
-      This sets the compression method for a column.  The supported compression
-      methods are <literal>pglz</literal> and <literal>lz4</literal>.
-      <literal>lz4</literal> is available only if <literal>--with-lz4</literal>
-      was used when building <productname>PostgreSQL</productname>. The default
+      The <literal>COMPRESSION</literal> clause sets the compression method
+      for a column.  Compression is supported only for variable-width data
+      types, and is used only for columns whose storage type is main or
+      extended. (See <xref linkend="sql-altertable"/> for information on
+      column storage types.) Setting this property for a partitioned table
+      has no direct effect, because such tables have no storage of their own,
+      but the configured value is inherited by newly-created partitions.
+      The supported compression methods are <literal>pglz</literal> and
+      <literal>lz4</literal>.  <literal>lz4</literal> is available only if
+      <literal>--with-lz4</literal> was used when building
+      <productname>PostgreSQL</productname>. The default
       is <literal>pglz</literal>.
      </para>
     </listitem>
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index b78d49167b..95d5b1c12a 100644
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -477,8 +477,8 @@ toast_get_compression_oid(struct varlena *attr)
 			return InvalidOid;
 
 		/*
-		 * Just fetch the toast compress header to know the compression method
-		 * in the compressed data.
+		 * Fetch just enough of the value to examine the compression header,
+		 * so that we can find out the compression method.
 		 */
 		attr = toast_fetch_datum_slice(attr, 0, VARHDRSZ_COMPRESS);
 	}
@@ -503,7 +503,6 @@ toast_get_compression_handler(struct varlena *attr)
 
 	cmid = TOAST_COMPRESS_METHOD(attr);
 
-	/* Get the handler routines for the compression method */
 	switch (cmid)
 	{
 		case PGLZ_COMPRESSION_ID:
diff --git a/src/backend/access/compression/compress_lz4.c b/src/backend/access/compression/compress_lz4.c
index 1856cf7df7..3079eff7eb 100644
--- a/src/backend/access/compression/compress_lz4.c
+++ b/src/backend/access/compression/compress_lz4.c
@@ -23,7 +23,7 @@
 /*
  * lz4_cmcompress - compression routine for lz4 compression method
  *
- * Compresses source into dest using the default strategy. Returns the
+ * Compresses source into dest using the LZ4 defaults. Returns the
  * compressed varlena, or NULL if compression fails.
  */
 static struct varlena *
@@ -42,8 +42,8 @@ lz4_cmcompress(const struct varlena *value)
 	valsize = VARSIZE_ANY_EXHDR(value);
 
 	/*
-	 * Get maximum size of the compressed data that lz4 compression may output
-	 * and allocate the memory for holding the compressed data and the header.
+	 * Figure out the maximum possible size of the LZ4 output, add the bytes
+	 * that will be needed for varlena overhead, and allocate that amount.
 	 */
 	max_size = LZ4_compressBound(valsize);
 	tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESS);
@@ -83,10 +83,10 @@ lz4_cmdecompress(const struct varlena *value)
 	int32		rawsize;
 	struct varlena *result;
 
-	/* allocate memory for holding the uncompressed data */
+	/* allocate memory for the uncompressed data */
 	result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ);
 
-	/* decompress data using lz4 routine */
+	/* decompress the data */
 	rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESS,
 								  VARDATA(result),
 								  VARSIZE(value) - VARHDRSZ_COMPRESS,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f77deee399..920d9dd0d5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2117,7 +2117,7 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
 		TupleTableSlot *newslot = *outslot;
 
 		/*
-		 * If the called has passed an invalid slot then create a new slot.
+		 * If the caller has passed an invalid slot then create a new slot.
 		 * Otherwise, just clear the existing tuple from the slot.  This slot
 		 * should be stored by the caller so that it can be reused for
 		 * decompressing the subsequent tuples.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 18e8ecfd90..d8483c36b3 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1183,8 +1183,8 @@ typedef struct ModifyTableState
 	TupleTableSlot *mt_root_tuple_slot;
 
 	/*
-	 * Slot for storing the modified tuple, incase the target attribute's
-	 * compression method doesn't match with the source table.
+	 * Slot for storing the modified tuple, in case the target attribute's
+	 * compression method doesn't match that of the source table.
 	 */
 	TupleTableSlot *mt_decompress_tuple_slot;
 
-- 
2.17.0


--m51xatjYGsM+13rf
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v24-0006-alter-table-set-compression.patch"



^ permalink  raw  reply  [nested|flat] 46+ messages in thread

* [PATCH v24 5/7] fixups.patch
@ 2021-02-10 21:56  Robert Haas <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: Robert Haas @ 2021-02-10 21:56 UTC (permalink / raw)

---
 doc/src/sgml/ddl.sgml                         |  3 ---
 doc/src/sgml/ref/create_table.sgml            | 15 +++++++++++----
 src/backend/access/common/detoast.c           |  5 ++---
 src/backend/access/compression/compress_lz4.c | 10 +++++-----
 src/backend/executor/nodeModifyTable.c        |  2 +-
 src/include/nodes/execnodes.h                 |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 4d7ed698b9..1e9a4625cc 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3762,9 +3762,6 @@ CREATE TABLE measurement (
        <productname>PostgreSQL</productname>
        tables (or, possibly, foreign tables).  It is possible to specify a
        tablespace and storage parameters for each partition separately.
-       By default, each column in a partition inherits the compression method
-       from parent table's column, however a different compression method can be
-       set for each partition.
       </para>
 
       <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 51a7a977a5..a4b297340f 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -997,10 +997,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
-      This sets the compression method for a column.  The supported compression
-      methods are <literal>pglz</literal> and <literal>lz4</literal>.
-      <literal>lz4</literal> is available only if <literal>--with-lz4</literal>
-      was used when building <productname>PostgreSQL</productname>. The default
+      The <literal>COMPRESSION</literal> clause sets the compression method
+      for a column.  Compression is supported only for variable-width data
+      types, and is used only for columns whose storage type is main or
+      extended. (See <xref linkend="sql-altertable"/> for information on
+      column storage types.) Setting this property for a partitioned table
+      has no direct effect, because such tables have no storage of their own,
+      but the configured value is inherited by newly-created partitions.
+      The supported compression methods are <literal>pglz</literal> and
+      <literal>lz4</literal>.  <literal>lz4</literal> is available only if
+      <literal>--with-lz4</literal> was used when building
+      <productname>PostgreSQL</productname>. The default
       is <literal>pglz</literal>.
      </para>
     </listitem>
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index b78d49167b..95d5b1c12a 100644
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -477,8 +477,8 @@ toast_get_compression_oid(struct varlena *attr)
 			return InvalidOid;
 
 		/*
-		 * Just fetch the toast compress header to know the compression method
-		 * in the compressed data.
+		 * Fetch just enough of the value to examine the compression header,
+		 * so that we can find out the compression method.
 		 */
 		attr = toast_fetch_datum_slice(attr, 0, VARHDRSZ_COMPRESS);
 	}
@@ -503,7 +503,6 @@ toast_get_compression_handler(struct varlena *attr)
 
 	cmid = TOAST_COMPRESS_METHOD(attr);
 
-	/* Get the handler routines for the compression method */
 	switch (cmid)
 	{
 		case PGLZ_COMPRESSION_ID:
diff --git a/src/backend/access/compression/compress_lz4.c b/src/backend/access/compression/compress_lz4.c
index 1856cf7df7..3079eff7eb 100644
--- a/src/backend/access/compression/compress_lz4.c
+++ b/src/backend/access/compression/compress_lz4.c
@@ -23,7 +23,7 @@
 /*
  * lz4_cmcompress - compression routine for lz4 compression method
  *
- * Compresses source into dest using the default strategy. Returns the
+ * Compresses source into dest using the LZ4 defaults. Returns the
  * compressed varlena, or NULL if compression fails.
  */
 static struct varlena *
@@ -42,8 +42,8 @@ lz4_cmcompress(const struct varlena *value)
 	valsize = VARSIZE_ANY_EXHDR(value);
 
 	/*
-	 * Get maximum size of the compressed data that lz4 compression may output
-	 * and allocate the memory for holding the compressed data and the header.
+	 * Figure out the maximum possible size of the LZ4 output, add the bytes
+	 * that will be needed for varlena overhead, and allocate that amount.
 	 */
 	max_size = LZ4_compressBound(valsize);
 	tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESS);
@@ -83,10 +83,10 @@ lz4_cmdecompress(const struct varlena *value)
 	int32		rawsize;
 	struct varlena *result;
 
-	/* allocate memory for holding the uncompressed data */
+	/* allocate memory for the uncompressed data */
 	result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ);
 
-	/* decompress data using lz4 routine */
+	/* decompress the data */
 	rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESS,
 								  VARDATA(result),
 								  VARSIZE(value) - VARHDRSZ_COMPRESS,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f77deee399..920d9dd0d5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2117,7 +2117,7 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
 		TupleTableSlot *newslot = *outslot;
 
 		/*
-		 * If the called has passed an invalid slot then create a new slot.
+		 * If the caller has passed an invalid slot then create a new slot.
 		 * Otherwise, just clear the existing tuple from the slot.  This slot
 		 * should be stored by the caller so that it can be reused for
 		 * decompressing the subsequent tuples.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 18e8ecfd90..d8483c36b3 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1183,8 +1183,8 @@ typedef struct ModifyTableState
 	TupleTableSlot *mt_root_tuple_slot;
 
 	/*
-	 * Slot for storing the modified tuple, incase the target attribute's
-	 * compression method doesn't match with the source table.
+	 * Slot for storing the modified tuple, in case the target attribute's
+	 * compression method doesn't match that of the source table.
 	 */
 	TupleTableSlot *mt_decompress_tuple_slot;
 
-- 
2.17.0


--YZ5djTAD1cGYuMQK
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v24-0006-alter-table-set-compression.patch"



^ permalink  raw  reply  [nested|flat] 46+ messages in thread

* [PATCH v24 05/10] fixups.patch
@ 2021-02-10 21:56  Robert Haas <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: Robert Haas @ 2021-02-10 21:56 UTC (permalink / raw)

---
 doc/src/sgml/ddl.sgml                         |  3 ---
 doc/src/sgml/ref/create_table.sgml            | 15 +++++++++++----
 src/backend/access/common/detoast.c           |  5 ++---
 src/backend/access/compression/compress_lz4.c | 10 +++++-----
 src/backend/executor/nodeModifyTable.c        |  2 +-
 src/include/nodes/execnodes.h                 |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 4d7ed698b9..1e9a4625cc 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3762,9 +3762,6 @@ CREATE TABLE measurement (
        <productname>PostgreSQL</productname>
        tables (or, possibly, foreign tables).  It is possible to specify a
        tablespace and storage parameters for each partition separately.
-       By default, each column in a partition inherits the compression method
-       from parent table's column, however a different compression method can be
-       set for each partition.
       </para>
 
       <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 51a7a977a5..a4b297340f 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -997,10 +997,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
-      This sets the compression method for a column.  The supported compression
-      methods are <literal>pglz</literal> and <literal>lz4</literal>.
-      <literal>lz4</literal> is available only if <literal>--with-lz4</literal>
-      was used when building <productname>PostgreSQL</productname>. The default
+      The <literal>COMPRESSION</literal> clause sets the compression method
+      for a column.  Compression is supported only for variable-width data
+      types, and is used only for columns whose storage type is main or
+      extended. (See <xref linkend="sql-altertable"/> for information on
+      column storage types.) Setting this property for a partitioned table
+      has no direct effect, because such tables have no storage of their own,
+      but the configured value is inherited by newly-created partitions.
+      The supported compression methods are <literal>pglz</literal> and
+      <literal>lz4</literal>.  <literal>lz4</literal> is available only if
+      <literal>--with-lz4</literal> was used when building
+      <productname>PostgreSQL</productname>. The default
       is <literal>pglz</literal>.
      </para>
     </listitem>
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index b78d49167b..95d5b1c12a 100644
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -477,8 +477,8 @@ toast_get_compression_oid(struct varlena *attr)
 			return InvalidOid;
 
 		/*
-		 * Just fetch the toast compress header to know the compression method
-		 * in the compressed data.
+		 * Fetch just enough of the value to examine the compression header,
+		 * so that we can find out the compression method.
 		 */
 		attr = toast_fetch_datum_slice(attr, 0, VARHDRSZ_COMPRESS);
 	}
@@ -503,7 +503,6 @@ toast_get_compression_handler(struct varlena *attr)
 
 	cmid = TOAST_COMPRESS_METHOD(attr);
 
-	/* Get the handler routines for the compression method */
 	switch (cmid)
 	{
 		case PGLZ_COMPRESSION_ID:
diff --git a/src/backend/access/compression/compress_lz4.c b/src/backend/access/compression/compress_lz4.c
index 1856cf7df7..3079eff7eb 100644
--- a/src/backend/access/compression/compress_lz4.c
+++ b/src/backend/access/compression/compress_lz4.c
@@ -23,7 +23,7 @@
 /*
  * lz4_cmcompress - compression routine for lz4 compression method
  *
- * Compresses source into dest using the default strategy. Returns the
+ * Compresses source into dest using the LZ4 defaults. Returns the
  * compressed varlena, or NULL if compression fails.
  */
 static struct varlena *
@@ -42,8 +42,8 @@ lz4_cmcompress(const struct varlena *value)
 	valsize = VARSIZE_ANY_EXHDR(value);
 
 	/*
-	 * Get maximum size of the compressed data that lz4 compression may output
-	 * and allocate the memory for holding the compressed data and the header.
+	 * Figure out the maximum possible size of the LZ4 output, add the bytes
+	 * that will be needed for varlena overhead, and allocate that amount.
 	 */
 	max_size = LZ4_compressBound(valsize);
 	tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESS);
@@ -83,10 +83,10 @@ lz4_cmdecompress(const struct varlena *value)
 	int32		rawsize;
 	struct varlena *result;
 
-	/* allocate memory for holding the uncompressed data */
+	/* allocate memory for the uncompressed data */
 	result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ);
 
-	/* decompress data using lz4 routine */
+	/* decompress the data */
 	rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESS,
 								  VARDATA(result),
 								  VARSIZE(value) - VARHDRSZ_COMPRESS,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f77deee399..920d9dd0d5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2117,7 +2117,7 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
 		TupleTableSlot *newslot = *outslot;
 
 		/*
-		 * If the called has passed an invalid slot then create a new slot.
+		 * If the caller has passed an invalid slot then create a new slot.
 		 * Otherwise, just clear the existing tuple from the slot.  This slot
 		 * should be stored by the caller so that it can be reused for
 		 * decompressing the subsequent tuples.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 18e8ecfd90..d8483c36b3 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1183,8 +1183,8 @@ typedef struct ModifyTableState
 	TupleTableSlot *mt_root_tuple_slot;
 
 	/*
-	 * Slot for storing the modified tuple, incase the target attribute's
-	 * compression method doesn't match with the source table.
+	 * Slot for storing the modified tuple, in case the target attribute's
+	 * compression method doesn't match that of the source table.
 	 */
 	TupleTableSlot *mt_decompress_tuple_slot;
 
-- 
2.17.0


--m51xatjYGsM+13rf
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v24-0006-alter-table-set-compression.patch"



^ permalink  raw  reply  [nested|flat] 46+ messages in thread

* [PATCH v24 5/7] fixups.patch
@ 2021-02-10 21:56  Robert Haas <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: Robert Haas @ 2021-02-10 21:56 UTC (permalink / raw)

---
 doc/src/sgml/ddl.sgml                         |  3 ---
 doc/src/sgml/ref/create_table.sgml            | 15 +++++++++++----
 src/backend/access/common/detoast.c           |  5 ++---
 src/backend/access/compression/compress_lz4.c | 10 +++++-----
 src/backend/executor/nodeModifyTable.c        |  2 +-
 src/include/nodes/execnodes.h                 |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 4d7ed698b9..1e9a4625cc 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3762,9 +3762,6 @@ CREATE TABLE measurement (
        <productname>PostgreSQL</productname>
        tables (or, possibly, foreign tables).  It is possible to specify a
        tablespace and storage parameters for each partition separately.
-       By default, each column in a partition inherits the compression method
-       from parent table's column, however a different compression method can be
-       set for each partition.
       </para>
 
       <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 51a7a977a5..a4b297340f 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -997,10 +997,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
-      This sets the compression method for a column.  The supported compression
-      methods are <literal>pglz</literal> and <literal>lz4</literal>.
-      <literal>lz4</literal> is available only if <literal>--with-lz4</literal>
-      was used when building <productname>PostgreSQL</productname>. The default
+      The <literal>COMPRESSION</literal> clause sets the compression method
+      for a column.  Compression is supported only for variable-width data
+      types, and is used only for columns whose storage type is main or
+      extended. (See <xref linkend="sql-altertable"/> for information on
+      column storage types.) Setting this property for a partitioned table
+      has no direct effect, because such tables have no storage of their own,
+      but the configured value is inherited by newly-created partitions.
+      The supported compression methods are <literal>pglz</literal> and
+      <literal>lz4</literal>.  <literal>lz4</literal> is available only if
+      <literal>--with-lz4</literal> was used when building
+      <productname>PostgreSQL</productname>. The default
       is <literal>pglz</literal>.
      </para>
     </listitem>
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index b78d49167b..95d5b1c12a 100644
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -477,8 +477,8 @@ toast_get_compression_oid(struct varlena *attr)
 			return InvalidOid;
 
 		/*
-		 * Just fetch the toast compress header to know the compression method
-		 * in the compressed data.
+		 * Fetch just enough of the value to examine the compression header,
+		 * so that we can find out the compression method.
 		 */
 		attr = toast_fetch_datum_slice(attr, 0, VARHDRSZ_COMPRESS);
 	}
@@ -503,7 +503,6 @@ toast_get_compression_handler(struct varlena *attr)
 
 	cmid = TOAST_COMPRESS_METHOD(attr);
 
-	/* Get the handler routines for the compression method */
 	switch (cmid)
 	{
 		case PGLZ_COMPRESSION_ID:
diff --git a/src/backend/access/compression/compress_lz4.c b/src/backend/access/compression/compress_lz4.c
index 1856cf7df7..3079eff7eb 100644
--- a/src/backend/access/compression/compress_lz4.c
+++ b/src/backend/access/compression/compress_lz4.c
@@ -23,7 +23,7 @@
 /*
  * lz4_cmcompress - compression routine for lz4 compression method
  *
- * Compresses source into dest using the default strategy. Returns the
+ * Compresses source into dest using the LZ4 defaults. Returns the
  * compressed varlena, or NULL if compression fails.
  */
 static struct varlena *
@@ -42,8 +42,8 @@ lz4_cmcompress(const struct varlena *value)
 	valsize = VARSIZE_ANY_EXHDR(value);
 
 	/*
-	 * Get maximum size of the compressed data that lz4 compression may output
-	 * and allocate the memory for holding the compressed data and the header.
+	 * Figure out the maximum possible size of the LZ4 output, add the bytes
+	 * that will be needed for varlena overhead, and allocate that amount.
 	 */
 	max_size = LZ4_compressBound(valsize);
 	tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESS);
@@ -83,10 +83,10 @@ lz4_cmdecompress(const struct varlena *value)
 	int32		rawsize;
 	struct varlena *result;
 
-	/* allocate memory for holding the uncompressed data */
+	/* allocate memory for the uncompressed data */
 	result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ);
 
-	/* decompress data using lz4 routine */
+	/* decompress the data */
 	rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESS,
 								  VARDATA(result),
 								  VARSIZE(value) - VARHDRSZ_COMPRESS,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f77deee399..920d9dd0d5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2117,7 +2117,7 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
 		TupleTableSlot *newslot = *outslot;
 
 		/*
-		 * If the called has passed an invalid slot then create a new slot.
+		 * If the caller has passed an invalid slot then create a new slot.
 		 * Otherwise, just clear the existing tuple from the slot.  This slot
 		 * should be stored by the caller so that it can be reused for
 		 * decompressing the subsequent tuples.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 18e8ecfd90..d8483c36b3 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1183,8 +1183,8 @@ typedef struct ModifyTableState
 	TupleTableSlot *mt_root_tuple_slot;
 
 	/*
-	 * Slot for storing the modified tuple, incase the target attribute's
-	 * compression method doesn't match with the source table.
+	 * Slot for storing the modified tuple, in case the target attribute's
+	 * compression method doesn't match that of the source table.
 	 */
 	TupleTableSlot *mt_decompress_tuple_slot;
 
-- 
2.17.0


--YZ5djTAD1cGYuMQK
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v24-0006-alter-table-set-compression.patch"



^ permalink  raw  reply  [nested|flat] 46+ messages in thread

* [PATCH v24 05/10] fixups.patch
@ 2021-02-10 21:56  Robert Haas <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: Robert Haas @ 2021-02-10 21:56 UTC (permalink / raw)

---
 doc/src/sgml/ddl.sgml                         |  3 ---
 doc/src/sgml/ref/create_table.sgml            | 15 +++++++++++----
 src/backend/access/common/detoast.c           |  5 ++---
 src/backend/access/compression/compress_lz4.c | 10 +++++-----
 src/backend/executor/nodeModifyTable.c        |  2 +-
 src/include/nodes/execnodes.h                 |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 4d7ed698b9..1e9a4625cc 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3762,9 +3762,6 @@ CREATE TABLE measurement (
        <productname>PostgreSQL</productname>
        tables (or, possibly, foreign tables).  It is possible to specify a
        tablespace and storage parameters for each partition separately.
-       By default, each column in a partition inherits the compression method
-       from parent table's column, however a different compression method can be
-       set for each partition.
       </para>
 
       <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 51a7a977a5..a4b297340f 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -997,10 +997,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
-      This sets the compression method for a column.  The supported compression
-      methods are <literal>pglz</literal> and <literal>lz4</literal>.
-      <literal>lz4</literal> is available only if <literal>--with-lz4</literal>
-      was used when building <productname>PostgreSQL</productname>. The default
+      The <literal>COMPRESSION</literal> clause sets the compression method
+      for a column.  Compression is supported only for variable-width data
+      types, and is used only for columns whose storage type is main or
+      extended. (See <xref linkend="sql-altertable"/> for information on
+      column storage types.) Setting this property for a partitioned table
+      has no direct effect, because such tables have no storage of their own,
+      but the configured value is inherited by newly-created partitions.
+      The supported compression methods are <literal>pglz</literal> and
+      <literal>lz4</literal>.  <literal>lz4</literal> is available only if
+      <literal>--with-lz4</literal> was used when building
+      <productname>PostgreSQL</productname>. The default
       is <literal>pglz</literal>.
      </para>
     </listitem>
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index b78d49167b..95d5b1c12a 100644
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -477,8 +477,8 @@ toast_get_compression_oid(struct varlena *attr)
 			return InvalidOid;
 
 		/*
-		 * Just fetch the toast compress header to know the compression method
-		 * in the compressed data.
+		 * Fetch just enough of the value to examine the compression header,
+		 * so that we can find out the compression method.
 		 */
 		attr = toast_fetch_datum_slice(attr, 0, VARHDRSZ_COMPRESS);
 	}
@@ -503,7 +503,6 @@ toast_get_compression_handler(struct varlena *attr)
 
 	cmid = TOAST_COMPRESS_METHOD(attr);
 
-	/* Get the handler routines for the compression method */
 	switch (cmid)
 	{
 		case PGLZ_COMPRESSION_ID:
diff --git a/src/backend/access/compression/compress_lz4.c b/src/backend/access/compression/compress_lz4.c
index 1856cf7df7..3079eff7eb 100644
--- a/src/backend/access/compression/compress_lz4.c
+++ b/src/backend/access/compression/compress_lz4.c
@@ -23,7 +23,7 @@
 /*
  * lz4_cmcompress - compression routine for lz4 compression method
  *
- * Compresses source into dest using the default strategy. Returns the
+ * Compresses source into dest using the LZ4 defaults. Returns the
  * compressed varlena, or NULL if compression fails.
  */
 static struct varlena *
@@ -42,8 +42,8 @@ lz4_cmcompress(const struct varlena *value)
 	valsize = VARSIZE_ANY_EXHDR(value);
 
 	/*
-	 * Get maximum size of the compressed data that lz4 compression may output
-	 * and allocate the memory for holding the compressed data and the header.
+	 * Figure out the maximum possible size of the LZ4 output, add the bytes
+	 * that will be needed for varlena overhead, and allocate that amount.
 	 */
 	max_size = LZ4_compressBound(valsize);
 	tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESS);
@@ -83,10 +83,10 @@ lz4_cmdecompress(const struct varlena *value)
 	int32		rawsize;
 	struct varlena *result;
 
-	/* allocate memory for holding the uncompressed data */
+	/* allocate memory for the uncompressed data */
 	result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ);
 
-	/* decompress data using lz4 routine */
+	/* decompress the data */
 	rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESS,
 								  VARDATA(result),
 								  VARSIZE(value) - VARHDRSZ_COMPRESS,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f77deee399..920d9dd0d5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2117,7 +2117,7 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
 		TupleTableSlot *newslot = *outslot;
 
 		/*
-		 * If the called has passed an invalid slot then create a new slot.
+		 * If the caller has passed an invalid slot then create a new slot.
 		 * Otherwise, just clear the existing tuple from the slot.  This slot
 		 * should be stored by the caller so that it can be reused for
 		 * decompressing the subsequent tuples.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 18e8ecfd90..d8483c36b3 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1183,8 +1183,8 @@ typedef struct ModifyTableState
 	TupleTableSlot *mt_root_tuple_slot;
 
 	/*
-	 * Slot for storing the modified tuple, incase the target attribute's
-	 * compression method doesn't match with the source table.
+	 * Slot for storing the modified tuple, in case the target attribute's
+	 * compression method doesn't match that of the source table.
 	 */
 	TupleTableSlot *mt_decompress_tuple_slot;
 
-- 
2.17.0


--m51xatjYGsM+13rf
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v24-0006-alter-table-set-compression.patch"



^ permalink  raw  reply  [nested|flat] 46+ messages in thread

* [PATCH v24 5/7] fixups.patch
@ 2021-02-10 21:56  Robert Haas <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: Robert Haas @ 2021-02-10 21:56 UTC (permalink / raw)

---
 doc/src/sgml/ddl.sgml                         |  3 ---
 doc/src/sgml/ref/create_table.sgml            | 15 +++++++++++----
 src/backend/access/common/detoast.c           |  5 ++---
 src/backend/access/compression/compress_lz4.c | 10 +++++-----
 src/backend/executor/nodeModifyTable.c        |  2 +-
 src/include/nodes/execnodes.h                 |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 4d7ed698b9..1e9a4625cc 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3762,9 +3762,6 @@ CREATE TABLE measurement (
        <productname>PostgreSQL</productname>
        tables (or, possibly, foreign tables).  It is possible to specify a
        tablespace and storage parameters for each partition separately.
-       By default, each column in a partition inherits the compression method
-       from parent table's column, however a different compression method can be
-       set for each partition.
       </para>
 
       <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 51a7a977a5..a4b297340f 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -997,10 +997,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
-      This sets the compression method for a column.  The supported compression
-      methods are <literal>pglz</literal> and <literal>lz4</literal>.
-      <literal>lz4</literal> is available only if <literal>--with-lz4</literal>
-      was used when building <productname>PostgreSQL</productname>. The default
+      The <literal>COMPRESSION</literal> clause sets the compression method
+      for a column.  Compression is supported only for variable-width data
+      types, and is used only for columns whose storage type is main or
+      extended. (See <xref linkend="sql-altertable"/> for information on
+      column storage types.) Setting this property for a partitioned table
+      has no direct effect, because such tables have no storage of their own,
+      but the configured value is inherited by newly-created partitions.
+      The supported compression methods are <literal>pglz</literal> and
+      <literal>lz4</literal>.  <literal>lz4</literal> is available only if
+      <literal>--with-lz4</literal> was used when building
+      <productname>PostgreSQL</productname>. The default
       is <literal>pglz</literal>.
      </para>
     </listitem>
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index b78d49167b..95d5b1c12a 100644
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -477,8 +477,8 @@ toast_get_compression_oid(struct varlena *attr)
 			return InvalidOid;
 
 		/*
-		 * Just fetch the toast compress header to know the compression method
-		 * in the compressed data.
+		 * Fetch just enough of the value to examine the compression header,
+		 * so that we can find out the compression method.
 		 */
 		attr = toast_fetch_datum_slice(attr, 0, VARHDRSZ_COMPRESS);
 	}
@@ -503,7 +503,6 @@ toast_get_compression_handler(struct varlena *attr)
 
 	cmid = TOAST_COMPRESS_METHOD(attr);
 
-	/* Get the handler routines for the compression method */
 	switch (cmid)
 	{
 		case PGLZ_COMPRESSION_ID:
diff --git a/src/backend/access/compression/compress_lz4.c b/src/backend/access/compression/compress_lz4.c
index 1856cf7df7..3079eff7eb 100644
--- a/src/backend/access/compression/compress_lz4.c
+++ b/src/backend/access/compression/compress_lz4.c
@@ -23,7 +23,7 @@
 /*
  * lz4_cmcompress - compression routine for lz4 compression method
  *
- * Compresses source into dest using the default strategy. Returns the
+ * Compresses source into dest using the LZ4 defaults. Returns the
  * compressed varlena, or NULL if compression fails.
  */
 static struct varlena *
@@ -42,8 +42,8 @@ lz4_cmcompress(const struct varlena *value)
 	valsize = VARSIZE_ANY_EXHDR(value);
 
 	/*
-	 * Get maximum size of the compressed data that lz4 compression may output
-	 * and allocate the memory for holding the compressed data and the header.
+	 * Figure out the maximum possible size of the LZ4 output, add the bytes
+	 * that will be needed for varlena overhead, and allocate that amount.
 	 */
 	max_size = LZ4_compressBound(valsize);
 	tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESS);
@@ -83,10 +83,10 @@ lz4_cmdecompress(const struct varlena *value)
 	int32		rawsize;
 	struct varlena *result;
 
-	/* allocate memory for holding the uncompressed data */
+	/* allocate memory for the uncompressed data */
 	result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ);
 
-	/* decompress data using lz4 routine */
+	/* decompress the data */
 	rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESS,
 								  VARDATA(result),
 								  VARSIZE(value) - VARHDRSZ_COMPRESS,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f77deee399..920d9dd0d5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2117,7 +2117,7 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
 		TupleTableSlot *newslot = *outslot;
 
 		/*
-		 * If the called has passed an invalid slot then create a new slot.
+		 * If the caller has passed an invalid slot then create a new slot.
 		 * Otherwise, just clear the existing tuple from the slot.  This slot
 		 * should be stored by the caller so that it can be reused for
 		 * decompressing the subsequent tuples.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 18e8ecfd90..d8483c36b3 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1183,8 +1183,8 @@ typedef struct ModifyTableState
 	TupleTableSlot *mt_root_tuple_slot;
 
 	/*
-	 * Slot for storing the modified tuple, incase the target attribute's
-	 * compression method doesn't match with the source table.
+	 * Slot for storing the modified tuple, in case the target attribute's
+	 * compression method doesn't match that of the source table.
 	 */
 	TupleTableSlot *mt_decompress_tuple_slot;
 
-- 
2.17.0


--YZ5djTAD1cGYuMQK
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v24-0006-alter-table-set-compression.patch"



^ permalink  raw  reply  [nested|flat] 46+ messages in thread

* [PATCH v24 05/10] fixups.patch
@ 2021-02-10 21:56  Robert Haas <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: Robert Haas @ 2021-02-10 21:56 UTC (permalink / raw)

---
 doc/src/sgml/ddl.sgml                         |  3 ---
 doc/src/sgml/ref/create_table.sgml            | 15 +++++++++++----
 src/backend/access/common/detoast.c           |  5 ++---
 src/backend/access/compression/compress_lz4.c | 10 +++++-----
 src/backend/executor/nodeModifyTable.c        |  2 +-
 src/include/nodes/execnodes.h                 |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 4d7ed698b9..1e9a4625cc 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3762,9 +3762,6 @@ CREATE TABLE measurement (
        <productname>PostgreSQL</productname>
        tables (or, possibly, foreign tables).  It is possible to specify a
        tablespace and storage parameters for each partition separately.
-       By default, each column in a partition inherits the compression method
-       from parent table's column, however a different compression method can be
-       set for each partition.
       </para>
 
       <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 51a7a977a5..a4b297340f 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -997,10 +997,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
-      This sets the compression method for a column.  The supported compression
-      methods are <literal>pglz</literal> and <literal>lz4</literal>.
-      <literal>lz4</literal> is available only if <literal>--with-lz4</literal>
-      was used when building <productname>PostgreSQL</productname>. The default
+      The <literal>COMPRESSION</literal> clause sets the compression method
+      for a column.  Compression is supported only for variable-width data
+      types, and is used only for columns whose storage type is main or
+      extended. (See <xref linkend="sql-altertable"/> for information on
+      column storage types.) Setting this property for a partitioned table
+      has no direct effect, because such tables have no storage of their own,
+      but the configured value is inherited by newly-created partitions.
+      The supported compression methods are <literal>pglz</literal> and
+      <literal>lz4</literal>.  <literal>lz4</literal> is available only if
+      <literal>--with-lz4</literal> was used when building
+      <productname>PostgreSQL</productname>. The default
       is <literal>pglz</literal>.
      </para>
     </listitem>
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index b78d49167b..95d5b1c12a 100644
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -477,8 +477,8 @@ toast_get_compression_oid(struct varlena *attr)
 			return InvalidOid;
 
 		/*
-		 * Just fetch the toast compress header to know the compression method
-		 * in the compressed data.
+		 * Fetch just enough of the value to examine the compression header,
+		 * so that we can find out the compression method.
 		 */
 		attr = toast_fetch_datum_slice(attr, 0, VARHDRSZ_COMPRESS);
 	}
@@ -503,7 +503,6 @@ toast_get_compression_handler(struct varlena *attr)
 
 	cmid = TOAST_COMPRESS_METHOD(attr);
 
-	/* Get the handler routines for the compression method */
 	switch (cmid)
 	{
 		case PGLZ_COMPRESSION_ID:
diff --git a/src/backend/access/compression/compress_lz4.c b/src/backend/access/compression/compress_lz4.c
index 1856cf7df7..3079eff7eb 100644
--- a/src/backend/access/compression/compress_lz4.c
+++ b/src/backend/access/compression/compress_lz4.c
@@ -23,7 +23,7 @@
 /*
  * lz4_cmcompress - compression routine for lz4 compression method
  *
- * Compresses source into dest using the default strategy. Returns the
+ * Compresses source into dest using the LZ4 defaults. Returns the
  * compressed varlena, or NULL if compression fails.
  */
 static struct varlena *
@@ -42,8 +42,8 @@ lz4_cmcompress(const struct varlena *value)
 	valsize = VARSIZE_ANY_EXHDR(value);
 
 	/*
-	 * Get maximum size of the compressed data that lz4 compression may output
-	 * and allocate the memory for holding the compressed data and the header.
+	 * Figure out the maximum possible size of the LZ4 output, add the bytes
+	 * that will be needed for varlena overhead, and allocate that amount.
 	 */
 	max_size = LZ4_compressBound(valsize);
 	tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESS);
@@ -83,10 +83,10 @@ lz4_cmdecompress(const struct varlena *value)
 	int32		rawsize;
 	struct varlena *result;
 
-	/* allocate memory for holding the uncompressed data */
+	/* allocate memory for the uncompressed data */
 	result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ);
 
-	/* decompress data using lz4 routine */
+	/* decompress the data */
 	rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESS,
 								  VARDATA(result),
 								  VARSIZE(value) - VARHDRSZ_COMPRESS,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f77deee399..920d9dd0d5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2117,7 +2117,7 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
 		TupleTableSlot *newslot = *outslot;
 
 		/*
-		 * If the called has passed an invalid slot then create a new slot.
+		 * If the caller has passed an invalid slot then create a new slot.
 		 * Otherwise, just clear the existing tuple from the slot.  This slot
 		 * should be stored by the caller so that it can be reused for
 		 * decompressing the subsequent tuples.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 18e8ecfd90..d8483c36b3 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1183,8 +1183,8 @@ typedef struct ModifyTableState
 	TupleTableSlot *mt_root_tuple_slot;
 
 	/*
-	 * Slot for storing the modified tuple, incase the target attribute's
-	 * compression method doesn't match with the source table.
+	 * Slot for storing the modified tuple, in case the target attribute's
+	 * compression method doesn't match that of the source table.
 	 */
 	TupleTableSlot *mt_decompress_tuple_slot;
 
-- 
2.17.0


--m51xatjYGsM+13rf
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v24-0006-alter-table-set-compression.patch"



^ permalink  raw  reply  [nested|flat] 46+ messages in thread

* [PATCH v24 5/7] fixups.patch
@ 2021-02-10 21:56  Robert Haas <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: Robert Haas @ 2021-02-10 21:56 UTC (permalink / raw)

---
 doc/src/sgml/ddl.sgml                         |  3 ---
 doc/src/sgml/ref/create_table.sgml            | 15 +++++++++++----
 src/backend/access/common/detoast.c           |  5 ++---
 src/backend/access/compression/compress_lz4.c | 10 +++++-----
 src/backend/executor/nodeModifyTable.c        |  2 +-
 src/include/nodes/execnodes.h                 |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 4d7ed698b9..1e9a4625cc 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3762,9 +3762,6 @@ CREATE TABLE measurement (
        <productname>PostgreSQL</productname>
        tables (or, possibly, foreign tables).  It is possible to specify a
        tablespace and storage parameters for each partition separately.
-       By default, each column in a partition inherits the compression method
-       from parent table's column, however a different compression method can be
-       set for each partition.
       </para>
 
       <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 51a7a977a5..a4b297340f 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -997,10 +997,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
-      This sets the compression method for a column.  The supported compression
-      methods are <literal>pglz</literal> and <literal>lz4</literal>.
-      <literal>lz4</literal> is available only if <literal>--with-lz4</literal>
-      was used when building <productname>PostgreSQL</productname>. The default
+      The <literal>COMPRESSION</literal> clause sets the compression method
+      for a column.  Compression is supported only for variable-width data
+      types, and is used only for columns whose storage type is main or
+      extended. (See <xref linkend="sql-altertable"/> for information on
+      column storage types.) Setting this property for a partitioned table
+      has no direct effect, because such tables have no storage of their own,
+      but the configured value is inherited by newly-created partitions.
+      The supported compression methods are <literal>pglz</literal> and
+      <literal>lz4</literal>.  <literal>lz4</literal> is available only if
+      <literal>--with-lz4</literal> was used when building
+      <productname>PostgreSQL</productname>. The default
       is <literal>pglz</literal>.
      </para>
     </listitem>
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index b78d49167b..95d5b1c12a 100644
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -477,8 +477,8 @@ toast_get_compression_oid(struct varlena *attr)
 			return InvalidOid;
 
 		/*
-		 * Just fetch the toast compress header to know the compression method
-		 * in the compressed data.
+		 * Fetch just enough of the value to examine the compression header,
+		 * so that we can find out the compression method.
 		 */
 		attr = toast_fetch_datum_slice(attr, 0, VARHDRSZ_COMPRESS);
 	}
@@ -503,7 +503,6 @@ toast_get_compression_handler(struct varlena *attr)
 
 	cmid = TOAST_COMPRESS_METHOD(attr);
 
-	/* Get the handler routines for the compression method */
 	switch (cmid)
 	{
 		case PGLZ_COMPRESSION_ID:
diff --git a/src/backend/access/compression/compress_lz4.c b/src/backend/access/compression/compress_lz4.c
index 1856cf7df7..3079eff7eb 100644
--- a/src/backend/access/compression/compress_lz4.c
+++ b/src/backend/access/compression/compress_lz4.c
@@ -23,7 +23,7 @@
 /*
  * lz4_cmcompress - compression routine for lz4 compression method
  *
- * Compresses source into dest using the default strategy. Returns the
+ * Compresses source into dest using the LZ4 defaults. Returns the
  * compressed varlena, or NULL if compression fails.
  */
 static struct varlena *
@@ -42,8 +42,8 @@ lz4_cmcompress(const struct varlena *value)
 	valsize = VARSIZE_ANY_EXHDR(value);
 
 	/*
-	 * Get maximum size of the compressed data that lz4 compression may output
-	 * and allocate the memory for holding the compressed data and the header.
+	 * Figure out the maximum possible size of the LZ4 output, add the bytes
+	 * that will be needed for varlena overhead, and allocate that amount.
 	 */
 	max_size = LZ4_compressBound(valsize);
 	tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESS);
@@ -83,10 +83,10 @@ lz4_cmdecompress(const struct varlena *value)
 	int32		rawsize;
 	struct varlena *result;
 
-	/* allocate memory for holding the uncompressed data */
+	/* allocate memory for the uncompressed data */
 	result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ);
 
-	/* decompress data using lz4 routine */
+	/* decompress the data */
 	rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESS,
 								  VARDATA(result),
 								  VARSIZE(value) - VARHDRSZ_COMPRESS,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f77deee399..920d9dd0d5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2117,7 +2117,7 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
 		TupleTableSlot *newslot = *outslot;
 
 		/*
-		 * If the called has passed an invalid slot then create a new slot.
+		 * If the caller has passed an invalid slot then create a new slot.
 		 * Otherwise, just clear the existing tuple from the slot.  This slot
 		 * should be stored by the caller so that it can be reused for
 		 * decompressing the subsequent tuples.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 18e8ecfd90..d8483c36b3 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1183,8 +1183,8 @@ typedef struct ModifyTableState
 	TupleTableSlot *mt_root_tuple_slot;
 
 	/*
-	 * Slot for storing the modified tuple, incase the target attribute's
-	 * compression method doesn't match with the source table.
+	 * Slot for storing the modified tuple, in case the target attribute's
+	 * compression method doesn't match that of the source table.
 	 */
 	TupleTableSlot *mt_decompress_tuple_slot;
 
-- 
2.17.0


--YZ5djTAD1cGYuMQK
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v24-0006-alter-table-set-compression.patch"



^ permalink  raw  reply  [nested|flat] 46+ messages in thread

* [PATCH v24 05/10] fixups.patch
@ 2021-02-10 21:56  Robert Haas <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: Robert Haas @ 2021-02-10 21:56 UTC (permalink / raw)

---
 doc/src/sgml/ddl.sgml                         |  3 ---
 doc/src/sgml/ref/create_table.sgml            | 15 +++++++++++----
 src/backend/access/common/detoast.c           |  5 ++---
 src/backend/access/compression/compress_lz4.c | 10 +++++-----
 src/backend/executor/nodeModifyTable.c        |  2 +-
 src/include/nodes/execnodes.h                 |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 4d7ed698b9..1e9a4625cc 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3762,9 +3762,6 @@ CREATE TABLE measurement (
        <productname>PostgreSQL</productname>
        tables (or, possibly, foreign tables).  It is possible to specify a
        tablespace and storage parameters for each partition separately.
-       By default, each column in a partition inherits the compression method
-       from parent table's column, however a different compression method can be
-       set for each partition.
       </para>
 
       <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 51a7a977a5..a4b297340f 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -997,10 +997,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
-      This sets the compression method for a column.  The supported compression
-      methods are <literal>pglz</literal> and <literal>lz4</literal>.
-      <literal>lz4</literal> is available only if <literal>--with-lz4</literal>
-      was used when building <productname>PostgreSQL</productname>. The default
+      The <literal>COMPRESSION</literal> clause sets the compression method
+      for a column.  Compression is supported only for variable-width data
+      types, and is used only for columns whose storage type is main or
+      extended. (See <xref linkend="sql-altertable"/> for information on
+      column storage types.) Setting this property for a partitioned table
+      has no direct effect, because such tables have no storage of their own,
+      but the configured value is inherited by newly-created partitions.
+      The supported compression methods are <literal>pglz</literal> and
+      <literal>lz4</literal>.  <literal>lz4</literal> is available only if
+      <literal>--with-lz4</literal> was used when building
+      <productname>PostgreSQL</productname>. The default
       is <literal>pglz</literal>.
      </para>
     </listitem>
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index b78d49167b..95d5b1c12a 100644
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -477,8 +477,8 @@ toast_get_compression_oid(struct varlena *attr)
 			return InvalidOid;
 
 		/*
-		 * Just fetch the toast compress header to know the compression method
-		 * in the compressed data.
+		 * Fetch just enough of the value to examine the compression header,
+		 * so that we can find out the compression method.
 		 */
 		attr = toast_fetch_datum_slice(attr, 0, VARHDRSZ_COMPRESS);
 	}
@@ -503,7 +503,6 @@ toast_get_compression_handler(struct varlena *attr)
 
 	cmid = TOAST_COMPRESS_METHOD(attr);
 
-	/* Get the handler routines for the compression method */
 	switch (cmid)
 	{
 		case PGLZ_COMPRESSION_ID:
diff --git a/src/backend/access/compression/compress_lz4.c b/src/backend/access/compression/compress_lz4.c
index 1856cf7df7..3079eff7eb 100644
--- a/src/backend/access/compression/compress_lz4.c
+++ b/src/backend/access/compression/compress_lz4.c
@@ -23,7 +23,7 @@
 /*
  * lz4_cmcompress - compression routine for lz4 compression method
  *
- * Compresses source into dest using the default strategy. Returns the
+ * Compresses source into dest using the LZ4 defaults. Returns the
  * compressed varlena, or NULL if compression fails.
  */
 static struct varlena *
@@ -42,8 +42,8 @@ lz4_cmcompress(const struct varlena *value)
 	valsize = VARSIZE_ANY_EXHDR(value);
 
 	/*
-	 * Get maximum size of the compressed data that lz4 compression may output
-	 * and allocate the memory for holding the compressed data and the header.
+	 * Figure out the maximum possible size of the LZ4 output, add the bytes
+	 * that will be needed for varlena overhead, and allocate that amount.
 	 */
 	max_size = LZ4_compressBound(valsize);
 	tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESS);
@@ -83,10 +83,10 @@ lz4_cmdecompress(const struct varlena *value)
 	int32		rawsize;
 	struct varlena *result;
 
-	/* allocate memory for holding the uncompressed data */
+	/* allocate memory for the uncompressed data */
 	result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ);
 
-	/* decompress data using lz4 routine */
+	/* decompress the data */
 	rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESS,
 								  VARDATA(result),
 								  VARSIZE(value) - VARHDRSZ_COMPRESS,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f77deee399..920d9dd0d5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2117,7 +2117,7 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
 		TupleTableSlot *newslot = *outslot;
 
 		/*
-		 * If the called has passed an invalid slot then create a new slot.
+		 * If the caller has passed an invalid slot then create a new slot.
 		 * Otherwise, just clear the existing tuple from the slot.  This slot
 		 * should be stored by the caller so that it can be reused for
 		 * decompressing the subsequent tuples.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 18e8ecfd90..d8483c36b3 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1183,8 +1183,8 @@ typedef struct ModifyTableState
 	TupleTableSlot *mt_root_tuple_slot;
 
 	/*
-	 * Slot for storing the modified tuple, incase the target attribute's
-	 * compression method doesn't match with the source table.
+	 * Slot for storing the modified tuple, in case the target attribute's
+	 * compression method doesn't match that of the source table.
 	 */
 	TupleTableSlot *mt_decompress_tuple_slot;
 
-- 
2.17.0


--m51xatjYGsM+13rf
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v24-0006-alter-table-set-compression.patch"



^ permalink  raw  reply  [nested|flat] 46+ messages in thread

* [PATCH v24 5/7] fixups.patch
@ 2021-02-10 21:56  Robert Haas <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: Robert Haas @ 2021-02-10 21:56 UTC (permalink / raw)

---
 doc/src/sgml/ddl.sgml                         |  3 ---
 doc/src/sgml/ref/create_table.sgml            | 15 +++++++++++----
 src/backend/access/common/detoast.c           |  5 ++---
 src/backend/access/compression/compress_lz4.c | 10 +++++-----
 src/backend/executor/nodeModifyTable.c        |  2 +-
 src/include/nodes/execnodes.h                 |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 4d7ed698b9..1e9a4625cc 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3762,9 +3762,6 @@ CREATE TABLE measurement (
        <productname>PostgreSQL</productname>
        tables (or, possibly, foreign tables).  It is possible to specify a
        tablespace and storage parameters for each partition separately.
-       By default, each column in a partition inherits the compression method
-       from parent table's column, however a different compression method can be
-       set for each partition.
       </para>
 
       <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 51a7a977a5..a4b297340f 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -997,10 +997,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
-      This sets the compression method for a column.  The supported compression
-      methods are <literal>pglz</literal> and <literal>lz4</literal>.
-      <literal>lz4</literal> is available only if <literal>--with-lz4</literal>
-      was used when building <productname>PostgreSQL</productname>. The default
+      The <literal>COMPRESSION</literal> clause sets the compression method
+      for a column.  Compression is supported only for variable-width data
+      types, and is used only for columns whose storage type is main or
+      extended. (See <xref linkend="sql-altertable"/> for information on
+      column storage types.) Setting this property for a partitioned table
+      has no direct effect, because such tables have no storage of their own,
+      but the configured value is inherited by newly-created partitions.
+      The supported compression methods are <literal>pglz</literal> and
+      <literal>lz4</literal>.  <literal>lz4</literal> is available only if
+      <literal>--with-lz4</literal> was used when building
+      <productname>PostgreSQL</productname>. The default
       is <literal>pglz</literal>.
      </para>
     </listitem>
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index b78d49167b..95d5b1c12a 100644
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -477,8 +477,8 @@ toast_get_compression_oid(struct varlena *attr)
 			return InvalidOid;
 
 		/*
-		 * Just fetch the toast compress header to know the compression method
-		 * in the compressed data.
+		 * Fetch just enough of the value to examine the compression header,
+		 * so that we can find out the compression method.
 		 */
 		attr = toast_fetch_datum_slice(attr, 0, VARHDRSZ_COMPRESS);
 	}
@@ -503,7 +503,6 @@ toast_get_compression_handler(struct varlena *attr)
 
 	cmid = TOAST_COMPRESS_METHOD(attr);
 
-	/* Get the handler routines for the compression method */
 	switch (cmid)
 	{
 		case PGLZ_COMPRESSION_ID:
diff --git a/src/backend/access/compression/compress_lz4.c b/src/backend/access/compression/compress_lz4.c
index 1856cf7df7..3079eff7eb 100644
--- a/src/backend/access/compression/compress_lz4.c
+++ b/src/backend/access/compression/compress_lz4.c
@@ -23,7 +23,7 @@
 /*
  * lz4_cmcompress - compression routine for lz4 compression method
  *
- * Compresses source into dest using the default strategy. Returns the
+ * Compresses source into dest using the LZ4 defaults. Returns the
  * compressed varlena, or NULL if compression fails.
  */
 static struct varlena *
@@ -42,8 +42,8 @@ lz4_cmcompress(const struct varlena *value)
 	valsize = VARSIZE_ANY_EXHDR(value);
 
 	/*
-	 * Get maximum size of the compressed data that lz4 compression may output
-	 * and allocate the memory for holding the compressed data and the header.
+	 * Figure out the maximum possible size of the LZ4 output, add the bytes
+	 * that will be needed for varlena overhead, and allocate that amount.
 	 */
 	max_size = LZ4_compressBound(valsize);
 	tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESS);
@@ -83,10 +83,10 @@ lz4_cmdecompress(const struct varlena *value)
 	int32		rawsize;
 	struct varlena *result;
 
-	/* allocate memory for holding the uncompressed data */
+	/* allocate memory for the uncompressed data */
 	result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ);
 
-	/* decompress data using lz4 routine */
+	/* decompress the data */
 	rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESS,
 								  VARDATA(result),
 								  VARSIZE(value) - VARHDRSZ_COMPRESS,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f77deee399..920d9dd0d5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2117,7 +2117,7 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
 		TupleTableSlot *newslot = *outslot;
 
 		/*
-		 * If the called has passed an invalid slot then create a new slot.
+		 * If the caller has passed an invalid slot then create a new slot.
 		 * Otherwise, just clear the existing tuple from the slot.  This slot
 		 * should be stored by the caller so that it can be reused for
 		 * decompressing the subsequent tuples.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 18e8ecfd90..d8483c36b3 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1183,8 +1183,8 @@ typedef struct ModifyTableState
 	TupleTableSlot *mt_root_tuple_slot;
 
 	/*
-	 * Slot for storing the modified tuple, incase the target attribute's
-	 * compression method doesn't match with the source table.
+	 * Slot for storing the modified tuple, in case the target attribute's
+	 * compression method doesn't match that of the source table.
 	 */
 	TupleTableSlot *mt_decompress_tuple_slot;
 
-- 
2.17.0


--YZ5djTAD1cGYuMQK
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v24-0006-alter-table-set-compression.patch"



^ permalink  raw  reply  [nested|flat] 46+ messages in thread

* [PATCH v24 05/10] fixups.patch
@ 2021-02-10 21:56  Robert Haas <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: Robert Haas @ 2021-02-10 21:56 UTC (permalink / raw)

---
 doc/src/sgml/ddl.sgml                         |  3 ---
 doc/src/sgml/ref/create_table.sgml            | 15 +++++++++++----
 src/backend/access/common/detoast.c           |  5 ++---
 src/backend/access/compression/compress_lz4.c | 10 +++++-----
 src/backend/executor/nodeModifyTable.c        |  2 +-
 src/include/nodes/execnodes.h                 |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 4d7ed698b9..1e9a4625cc 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3762,9 +3762,6 @@ CREATE TABLE measurement (
        <productname>PostgreSQL</productname>
        tables (or, possibly, foreign tables).  It is possible to specify a
        tablespace and storage parameters for each partition separately.
-       By default, each column in a partition inherits the compression method
-       from parent table's column, however a different compression method can be
-       set for each partition.
       </para>
 
       <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 51a7a977a5..a4b297340f 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -997,10 +997,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
-      This sets the compression method for a column.  The supported compression
-      methods are <literal>pglz</literal> and <literal>lz4</literal>.
-      <literal>lz4</literal> is available only if <literal>--with-lz4</literal>
-      was used when building <productname>PostgreSQL</productname>. The default
+      The <literal>COMPRESSION</literal> clause sets the compression method
+      for a column.  Compression is supported only for variable-width data
+      types, and is used only for columns whose storage type is main or
+      extended. (See <xref linkend="sql-altertable"/> for information on
+      column storage types.) Setting this property for a partitioned table
+      has no direct effect, because such tables have no storage of their own,
+      but the configured value is inherited by newly-created partitions.
+      The supported compression methods are <literal>pglz</literal> and
+      <literal>lz4</literal>.  <literal>lz4</literal> is available only if
+      <literal>--with-lz4</literal> was used when building
+      <productname>PostgreSQL</productname>. The default
       is <literal>pglz</literal>.
      </para>
     </listitem>
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index b78d49167b..95d5b1c12a 100644
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -477,8 +477,8 @@ toast_get_compression_oid(struct varlena *attr)
 			return InvalidOid;
 
 		/*
-		 * Just fetch the toast compress header to know the compression method
-		 * in the compressed data.
+		 * Fetch just enough of the value to examine the compression header,
+		 * so that we can find out the compression method.
 		 */
 		attr = toast_fetch_datum_slice(attr, 0, VARHDRSZ_COMPRESS);
 	}
@@ -503,7 +503,6 @@ toast_get_compression_handler(struct varlena *attr)
 
 	cmid = TOAST_COMPRESS_METHOD(attr);
 
-	/* Get the handler routines for the compression method */
 	switch (cmid)
 	{
 		case PGLZ_COMPRESSION_ID:
diff --git a/src/backend/access/compression/compress_lz4.c b/src/backend/access/compression/compress_lz4.c
index 1856cf7df7..3079eff7eb 100644
--- a/src/backend/access/compression/compress_lz4.c
+++ b/src/backend/access/compression/compress_lz4.c
@@ -23,7 +23,7 @@
 /*
  * lz4_cmcompress - compression routine for lz4 compression method
  *
- * Compresses source into dest using the default strategy. Returns the
+ * Compresses source into dest using the LZ4 defaults. Returns the
  * compressed varlena, or NULL if compression fails.
  */
 static struct varlena *
@@ -42,8 +42,8 @@ lz4_cmcompress(const struct varlena *value)
 	valsize = VARSIZE_ANY_EXHDR(value);
 
 	/*
-	 * Get maximum size of the compressed data that lz4 compression may output
-	 * and allocate the memory for holding the compressed data and the header.
+	 * Figure out the maximum possible size of the LZ4 output, add the bytes
+	 * that will be needed for varlena overhead, and allocate that amount.
 	 */
 	max_size = LZ4_compressBound(valsize);
 	tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESS);
@@ -83,10 +83,10 @@ lz4_cmdecompress(const struct varlena *value)
 	int32		rawsize;
 	struct varlena *result;
 
-	/* allocate memory for holding the uncompressed data */
+	/* allocate memory for the uncompressed data */
 	result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ);
 
-	/* decompress data using lz4 routine */
+	/* decompress the data */
 	rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESS,
 								  VARDATA(result),
 								  VARSIZE(value) - VARHDRSZ_COMPRESS,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f77deee399..920d9dd0d5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2117,7 +2117,7 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
 		TupleTableSlot *newslot = *outslot;
 
 		/*
-		 * If the called has passed an invalid slot then create a new slot.
+		 * If the caller has passed an invalid slot then create a new slot.
 		 * Otherwise, just clear the existing tuple from the slot.  This slot
 		 * should be stored by the caller so that it can be reused for
 		 * decompressing the subsequent tuples.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 18e8ecfd90..d8483c36b3 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1183,8 +1183,8 @@ typedef struct ModifyTableState
 	TupleTableSlot *mt_root_tuple_slot;
 
 	/*
-	 * Slot for storing the modified tuple, incase the target attribute's
-	 * compression method doesn't match with the source table.
+	 * Slot for storing the modified tuple, in case the target attribute's
+	 * compression method doesn't match that of the source table.
 	 */
 	TupleTableSlot *mt_decompress_tuple_slot;
 
-- 
2.17.0


--m51xatjYGsM+13rf
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v24-0006-alter-table-set-compression.patch"



^ permalink  raw  reply  [nested|flat] 46+ messages in thread

* [PATCH v24 5/7] fixups.patch
@ 2021-02-10 21:56  Robert Haas <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: Robert Haas @ 2021-02-10 21:56 UTC (permalink / raw)

---
 doc/src/sgml/ddl.sgml                         |  3 ---
 doc/src/sgml/ref/create_table.sgml            | 15 +++++++++++----
 src/backend/access/common/detoast.c           |  5 ++---
 src/backend/access/compression/compress_lz4.c | 10 +++++-----
 src/backend/executor/nodeModifyTable.c        |  2 +-
 src/include/nodes/execnodes.h                 |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 4d7ed698b9..1e9a4625cc 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3762,9 +3762,6 @@ CREATE TABLE measurement (
        <productname>PostgreSQL</productname>
        tables (or, possibly, foreign tables).  It is possible to specify a
        tablespace and storage parameters for each partition separately.
-       By default, each column in a partition inherits the compression method
-       from parent table's column, however a different compression method can be
-       set for each partition.
       </para>
 
       <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 51a7a977a5..a4b297340f 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -997,10 +997,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
-      This sets the compression method for a column.  The supported compression
-      methods are <literal>pglz</literal> and <literal>lz4</literal>.
-      <literal>lz4</literal> is available only if <literal>--with-lz4</literal>
-      was used when building <productname>PostgreSQL</productname>. The default
+      The <literal>COMPRESSION</literal> clause sets the compression method
+      for a column.  Compression is supported only for variable-width data
+      types, and is used only for columns whose storage type is main or
+      extended. (See <xref linkend="sql-altertable"/> for information on
+      column storage types.) Setting this property for a partitioned table
+      has no direct effect, because such tables have no storage of their own,
+      but the configured value is inherited by newly-created partitions.
+      The supported compression methods are <literal>pglz</literal> and
+      <literal>lz4</literal>.  <literal>lz4</literal> is available only if
+      <literal>--with-lz4</literal> was used when building
+      <productname>PostgreSQL</productname>. The default
       is <literal>pglz</literal>.
      </para>
     </listitem>
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index b78d49167b..95d5b1c12a 100644
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -477,8 +477,8 @@ toast_get_compression_oid(struct varlena *attr)
 			return InvalidOid;
 
 		/*
-		 * Just fetch the toast compress header to know the compression method
-		 * in the compressed data.
+		 * Fetch just enough of the value to examine the compression header,
+		 * so that we can find out the compression method.
 		 */
 		attr = toast_fetch_datum_slice(attr, 0, VARHDRSZ_COMPRESS);
 	}
@@ -503,7 +503,6 @@ toast_get_compression_handler(struct varlena *attr)
 
 	cmid = TOAST_COMPRESS_METHOD(attr);
 
-	/* Get the handler routines for the compression method */
 	switch (cmid)
 	{
 		case PGLZ_COMPRESSION_ID:
diff --git a/src/backend/access/compression/compress_lz4.c b/src/backend/access/compression/compress_lz4.c
index 1856cf7df7..3079eff7eb 100644
--- a/src/backend/access/compression/compress_lz4.c
+++ b/src/backend/access/compression/compress_lz4.c
@@ -23,7 +23,7 @@
 /*
  * lz4_cmcompress - compression routine for lz4 compression method
  *
- * Compresses source into dest using the default strategy. Returns the
+ * Compresses source into dest using the LZ4 defaults. Returns the
  * compressed varlena, or NULL if compression fails.
  */
 static struct varlena *
@@ -42,8 +42,8 @@ lz4_cmcompress(const struct varlena *value)
 	valsize = VARSIZE_ANY_EXHDR(value);
 
 	/*
-	 * Get maximum size of the compressed data that lz4 compression may output
-	 * and allocate the memory for holding the compressed data and the header.
+	 * Figure out the maximum possible size of the LZ4 output, add the bytes
+	 * that will be needed for varlena overhead, and allocate that amount.
 	 */
 	max_size = LZ4_compressBound(valsize);
 	tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESS);
@@ -83,10 +83,10 @@ lz4_cmdecompress(const struct varlena *value)
 	int32		rawsize;
 	struct varlena *result;
 
-	/* allocate memory for holding the uncompressed data */
+	/* allocate memory for the uncompressed data */
 	result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ);
 
-	/* decompress data using lz4 routine */
+	/* decompress the data */
 	rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESS,
 								  VARDATA(result),
 								  VARSIZE(value) - VARHDRSZ_COMPRESS,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f77deee399..920d9dd0d5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2117,7 +2117,7 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
 		TupleTableSlot *newslot = *outslot;
 
 		/*
-		 * If the called has passed an invalid slot then create a new slot.
+		 * If the caller has passed an invalid slot then create a new slot.
 		 * Otherwise, just clear the existing tuple from the slot.  This slot
 		 * should be stored by the caller so that it can be reused for
 		 * decompressing the subsequent tuples.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 18e8ecfd90..d8483c36b3 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1183,8 +1183,8 @@ typedef struct ModifyTableState
 	TupleTableSlot *mt_root_tuple_slot;
 
 	/*
-	 * Slot for storing the modified tuple, incase the target attribute's
-	 * compression method doesn't match with the source table.
+	 * Slot for storing the modified tuple, in case the target attribute's
+	 * compression method doesn't match that of the source table.
 	 */
 	TupleTableSlot *mt_decompress_tuple_slot;
 
-- 
2.17.0


--YZ5djTAD1cGYuMQK
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v24-0006-alter-table-set-compression.patch"



^ permalink  raw  reply  [nested|flat] 46+ messages in thread

* [PATCH v24 05/10] fixups.patch
@ 2021-02-10 21:56  Robert Haas <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: Robert Haas @ 2021-02-10 21:56 UTC (permalink / raw)

---
 doc/src/sgml/ddl.sgml                         |  3 ---
 doc/src/sgml/ref/create_table.sgml            | 15 +++++++++++----
 src/backend/access/common/detoast.c           |  5 ++---
 src/backend/access/compression/compress_lz4.c | 10 +++++-----
 src/backend/executor/nodeModifyTable.c        |  2 +-
 src/include/nodes/execnodes.h                 |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 4d7ed698b9..1e9a4625cc 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3762,9 +3762,6 @@ CREATE TABLE measurement (
        <productname>PostgreSQL</productname>
        tables (or, possibly, foreign tables).  It is possible to specify a
        tablespace and storage parameters for each partition separately.
-       By default, each column in a partition inherits the compression method
-       from parent table's column, however a different compression method can be
-       set for each partition.
       </para>
 
       <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 51a7a977a5..a4b297340f 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -997,10 +997,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
-      This sets the compression method for a column.  The supported compression
-      methods are <literal>pglz</literal> and <literal>lz4</literal>.
-      <literal>lz4</literal> is available only if <literal>--with-lz4</literal>
-      was used when building <productname>PostgreSQL</productname>. The default
+      The <literal>COMPRESSION</literal> clause sets the compression method
+      for a column.  Compression is supported only for variable-width data
+      types, and is used only for columns whose storage type is main or
+      extended. (See <xref linkend="sql-altertable"/> for information on
+      column storage types.) Setting this property for a partitioned table
+      has no direct effect, because such tables have no storage of their own,
+      but the configured value is inherited by newly-created partitions.
+      The supported compression methods are <literal>pglz</literal> and
+      <literal>lz4</literal>.  <literal>lz4</literal> is available only if
+      <literal>--with-lz4</literal> was used when building
+      <productname>PostgreSQL</productname>. The default
       is <literal>pglz</literal>.
      </para>
     </listitem>
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index b78d49167b..95d5b1c12a 100644
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -477,8 +477,8 @@ toast_get_compression_oid(struct varlena *attr)
 			return InvalidOid;
 
 		/*
-		 * Just fetch the toast compress header to know the compression method
-		 * in the compressed data.
+		 * Fetch just enough of the value to examine the compression header,
+		 * so that we can find out the compression method.
 		 */
 		attr = toast_fetch_datum_slice(attr, 0, VARHDRSZ_COMPRESS);
 	}
@@ -503,7 +503,6 @@ toast_get_compression_handler(struct varlena *attr)
 
 	cmid = TOAST_COMPRESS_METHOD(attr);
 
-	/* Get the handler routines for the compression method */
 	switch (cmid)
 	{
 		case PGLZ_COMPRESSION_ID:
diff --git a/src/backend/access/compression/compress_lz4.c b/src/backend/access/compression/compress_lz4.c
index 1856cf7df7..3079eff7eb 100644
--- a/src/backend/access/compression/compress_lz4.c
+++ b/src/backend/access/compression/compress_lz4.c
@@ -23,7 +23,7 @@
 /*
  * lz4_cmcompress - compression routine for lz4 compression method
  *
- * Compresses source into dest using the default strategy. Returns the
+ * Compresses source into dest using the LZ4 defaults. Returns the
  * compressed varlena, or NULL if compression fails.
  */
 static struct varlena *
@@ -42,8 +42,8 @@ lz4_cmcompress(const struct varlena *value)
 	valsize = VARSIZE_ANY_EXHDR(value);
 
 	/*
-	 * Get maximum size of the compressed data that lz4 compression may output
-	 * and allocate the memory for holding the compressed data and the header.
+	 * Figure out the maximum possible size of the LZ4 output, add the bytes
+	 * that will be needed for varlena overhead, and allocate that amount.
 	 */
 	max_size = LZ4_compressBound(valsize);
 	tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESS);
@@ -83,10 +83,10 @@ lz4_cmdecompress(const struct varlena *value)
 	int32		rawsize;
 	struct varlena *result;
 
-	/* allocate memory for holding the uncompressed data */
+	/* allocate memory for the uncompressed data */
 	result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ);
 
-	/* decompress data using lz4 routine */
+	/* decompress the data */
 	rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESS,
 								  VARDATA(result),
 								  VARSIZE(value) - VARHDRSZ_COMPRESS,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f77deee399..920d9dd0d5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2117,7 +2117,7 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
 		TupleTableSlot *newslot = *outslot;
 
 		/*
-		 * If the called has passed an invalid slot then create a new slot.
+		 * If the caller has passed an invalid slot then create a new slot.
 		 * Otherwise, just clear the existing tuple from the slot.  This slot
 		 * should be stored by the caller so that it can be reused for
 		 * decompressing the subsequent tuples.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 18e8ecfd90..d8483c36b3 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1183,8 +1183,8 @@ typedef struct ModifyTableState
 	TupleTableSlot *mt_root_tuple_slot;
 
 	/*
-	 * Slot for storing the modified tuple, incase the target attribute's
-	 * compression method doesn't match with the source table.
+	 * Slot for storing the modified tuple, in case the target attribute's
+	 * compression method doesn't match that of the source table.
 	 */
 	TupleTableSlot *mt_decompress_tuple_slot;
 
-- 
2.17.0


--m51xatjYGsM+13rf
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v24-0006-alter-table-set-compression.patch"



^ permalink  raw  reply  [nested|flat] 46+ messages in thread

* [PATCH v24 5/7] fixups.patch
@ 2021-02-10 21:56  Robert Haas <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: Robert Haas @ 2021-02-10 21:56 UTC (permalink / raw)

---
 doc/src/sgml/ddl.sgml                         |  3 ---
 doc/src/sgml/ref/create_table.sgml            | 15 +++++++++++----
 src/backend/access/common/detoast.c           |  5 ++---
 src/backend/access/compression/compress_lz4.c | 10 +++++-----
 src/backend/executor/nodeModifyTable.c        |  2 +-
 src/include/nodes/execnodes.h                 |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 4d7ed698b9..1e9a4625cc 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3762,9 +3762,6 @@ CREATE TABLE measurement (
        <productname>PostgreSQL</productname>
        tables (or, possibly, foreign tables).  It is possible to specify a
        tablespace and storage parameters for each partition separately.
-       By default, each column in a partition inherits the compression method
-       from parent table's column, however a different compression method can be
-       set for each partition.
       </para>
 
       <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 51a7a977a5..a4b297340f 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -997,10 +997,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
-      This sets the compression method for a column.  The supported compression
-      methods are <literal>pglz</literal> and <literal>lz4</literal>.
-      <literal>lz4</literal> is available only if <literal>--with-lz4</literal>
-      was used when building <productname>PostgreSQL</productname>. The default
+      The <literal>COMPRESSION</literal> clause sets the compression method
+      for a column.  Compression is supported only for variable-width data
+      types, and is used only for columns whose storage type is main or
+      extended. (See <xref linkend="sql-altertable"/> for information on
+      column storage types.) Setting this property for a partitioned table
+      has no direct effect, because such tables have no storage of their own,
+      but the configured value is inherited by newly-created partitions.
+      The supported compression methods are <literal>pglz</literal> and
+      <literal>lz4</literal>.  <literal>lz4</literal> is available only if
+      <literal>--with-lz4</literal> was used when building
+      <productname>PostgreSQL</productname>. The default
       is <literal>pglz</literal>.
      </para>
     </listitem>
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index b78d49167b..95d5b1c12a 100644
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -477,8 +477,8 @@ toast_get_compression_oid(struct varlena *attr)
 			return InvalidOid;
 
 		/*
-		 * Just fetch the toast compress header to know the compression method
-		 * in the compressed data.
+		 * Fetch just enough of the value to examine the compression header,
+		 * so that we can find out the compression method.
 		 */
 		attr = toast_fetch_datum_slice(attr, 0, VARHDRSZ_COMPRESS);
 	}
@@ -503,7 +503,6 @@ toast_get_compression_handler(struct varlena *attr)
 
 	cmid = TOAST_COMPRESS_METHOD(attr);
 
-	/* Get the handler routines for the compression method */
 	switch (cmid)
 	{
 		case PGLZ_COMPRESSION_ID:
diff --git a/src/backend/access/compression/compress_lz4.c b/src/backend/access/compression/compress_lz4.c
index 1856cf7df7..3079eff7eb 100644
--- a/src/backend/access/compression/compress_lz4.c
+++ b/src/backend/access/compression/compress_lz4.c
@@ -23,7 +23,7 @@
 /*
  * lz4_cmcompress - compression routine for lz4 compression method
  *
- * Compresses source into dest using the default strategy. Returns the
+ * Compresses source into dest using the LZ4 defaults. Returns the
  * compressed varlena, or NULL if compression fails.
  */
 static struct varlena *
@@ -42,8 +42,8 @@ lz4_cmcompress(const struct varlena *value)
 	valsize = VARSIZE_ANY_EXHDR(value);
 
 	/*
-	 * Get maximum size of the compressed data that lz4 compression may output
-	 * and allocate the memory for holding the compressed data and the header.
+	 * Figure out the maximum possible size of the LZ4 output, add the bytes
+	 * that will be needed for varlena overhead, and allocate that amount.
 	 */
 	max_size = LZ4_compressBound(valsize);
 	tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESS);
@@ -83,10 +83,10 @@ lz4_cmdecompress(const struct varlena *value)
 	int32		rawsize;
 	struct varlena *result;
 
-	/* allocate memory for holding the uncompressed data */
+	/* allocate memory for the uncompressed data */
 	result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ);
 
-	/* decompress data using lz4 routine */
+	/* decompress the data */
 	rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESS,
 								  VARDATA(result),
 								  VARSIZE(value) - VARHDRSZ_COMPRESS,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f77deee399..920d9dd0d5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2117,7 +2117,7 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
 		TupleTableSlot *newslot = *outslot;
 
 		/*
-		 * If the called has passed an invalid slot then create a new slot.
+		 * If the caller has passed an invalid slot then create a new slot.
 		 * Otherwise, just clear the existing tuple from the slot.  This slot
 		 * should be stored by the caller so that it can be reused for
 		 * decompressing the subsequent tuples.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 18e8ecfd90..d8483c36b3 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1183,8 +1183,8 @@ typedef struct ModifyTableState
 	TupleTableSlot *mt_root_tuple_slot;
 
 	/*
-	 * Slot for storing the modified tuple, incase the target attribute's
-	 * compression method doesn't match with the source table.
+	 * Slot for storing the modified tuple, in case the target attribute's
+	 * compression method doesn't match that of the source table.
 	 */
 	TupleTableSlot *mt_decompress_tuple_slot;
 
-- 
2.17.0


--YZ5djTAD1cGYuMQK
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v24-0006-alter-table-set-compression.patch"



^ permalink  raw  reply  [nested|flat] 46+ messages in thread

* [PATCH v24 05/10] fixups.patch
@ 2021-02-10 21:56  Robert Haas <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: Robert Haas @ 2021-02-10 21:56 UTC (permalink / raw)

---
 doc/src/sgml/ddl.sgml                         |  3 ---
 doc/src/sgml/ref/create_table.sgml            | 15 +++++++++++----
 src/backend/access/common/detoast.c           |  5 ++---
 src/backend/access/compression/compress_lz4.c | 10 +++++-----
 src/backend/executor/nodeModifyTable.c        |  2 +-
 src/include/nodes/execnodes.h                 |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 4d7ed698b9..1e9a4625cc 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3762,9 +3762,6 @@ CREATE TABLE measurement (
        <productname>PostgreSQL</productname>
        tables (or, possibly, foreign tables).  It is possible to specify a
        tablespace and storage parameters for each partition separately.
-       By default, each column in a partition inherits the compression method
-       from parent table's column, however a different compression method can be
-       set for each partition.
       </para>
 
       <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 51a7a977a5..a4b297340f 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -997,10 +997,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
-      This sets the compression method for a column.  The supported compression
-      methods are <literal>pglz</literal> and <literal>lz4</literal>.
-      <literal>lz4</literal> is available only if <literal>--with-lz4</literal>
-      was used when building <productname>PostgreSQL</productname>. The default
+      The <literal>COMPRESSION</literal> clause sets the compression method
+      for a column.  Compression is supported only for variable-width data
+      types, and is used only for columns whose storage type is main or
+      extended. (See <xref linkend="sql-altertable"/> for information on
+      column storage types.) Setting this property for a partitioned table
+      has no direct effect, because such tables have no storage of their own,
+      but the configured value is inherited by newly-created partitions.
+      The supported compression methods are <literal>pglz</literal> and
+      <literal>lz4</literal>.  <literal>lz4</literal> is available only if
+      <literal>--with-lz4</literal> was used when building
+      <productname>PostgreSQL</productname>. The default
       is <literal>pglz</literal>.
      </para>
     </listitem>
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index b78d49167b..95d5b1c12a 100644
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -477,8 +477,8 @@ toast_get_compression_oid(struct varlena *attr)
 			return InvalidOid;
 
 		/*
-		 * Just fetch the toast compress header to know the compression method
-		 * in the compressed data.
+		 * Fetch just enough of the value to examine the compression header,
+		 * so that we can find out the compression method.
 		 */
 		attr = toast_fetch_datum_slice(attr, 0, VARHDRSZ_COMPRESS);
 	}
@@ -503,7 +503,6 @@ toast_get_compression_handler(struct varlena *attr)
 
 	cmid = TOAST_COMPRESS_METHOD(attr);
 
-	/* Get the handler routines for the compression method */
 	switch (cmid)
 	{
 		case PGLZ_COMPRESSION_ID:
diff --git a/src/backend/access/compression/compress_lz4.c b/src/backend/access/compression/compress_lz4.c
index 1856cf7df7..3079eff7eb 100644
--- a/src/backend/access/compression/compress_lz4.c
+++ b/src/backend/access/compression/compress_lz4.c
@@ -23,7 +23,7 @@
 /*
  * lz4_cmcompress - compression routine for lz4 compression method
  *
- * Compresses source into dest using the default strategy. Returns the
+ * Compresses source into dest using the LZ4 defaults. Returns the
  * compressed varlena, or NULL if compression fails.
  */
 static struct varlena *
@@ -42,8 +42,8 @@ lz4_cmcompress(const struct varlena *value)
 	valsize = VARSIZE_ANY_EXHDR(value);
 
 	/*
-	 * Get maximum size of the compressed data that lz4 compression may output
-	 * and allocate the memory for holding the compressed data and the header.
+	 * Figure out the maximum possible size of the LZ4 output, add the bytes
+	 * that will be needed for varlena overhead, and allocate that amount.
 	 */
 	max_size = LZ4_compressBound(valsize);
 	tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESS);
@@ -83,10 +83,10 @@ lz4_cmdecompress(const struct varlena *value)
 	int32		rawsize;
 	struct varlena *result;
 
-	/* allocate memory for holding the uncompressed data */
+	/* allocate memory for the uncompressed data */
 	result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ);
 
-	/* decompress data using lz4 routine */
+	/* decompress the data */
 	rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESS,
 								  VARDATA(result),
 								  VARSIZE(value) - VARHDRSZ_COMPRESS,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f77deee399..920d9dd0d5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2117,7 +2117,7 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
 		TupleTableSlot *newslot = *outslot;
 
 		/*
-		 * If the called has passed an invalid slot then create a new slot.
+		 * If the caller has passed an invalid slot then create a new slot.
 		 * Otherwise, just clear the existing tuple from the slot.  This slot
 		 * should be stored by the caller so that it can be reused for
 		 * decompressing the subsequent tuples.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 18e8ecfd90..d8483c36b3 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1183,8 +1183,8 @@ typedef struct ModifyTableState
 	TupleTableSlot *mt_root_tuple_slot;
 
 	/*
-	 * Slot for storing the modified tuple, incase the target attribute's
-	 * compression method doesn't match with the source table.
+	 * Slot for storing the modified tuple, in case the target attribute's
+	 * compression method doesn't match that of the source table.
 	 */
 	TupleTableSlot *mt_decompress_tuple_slot;
 
-- 
2.17.0


--m51xatjYGsM+13rf
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v24-0006-alter-table-set-compression.patch"



^ permalink  raw  reply  [nested|flat] 46+ messages in thread

* [PATCH v24 5/7] fixups.patch
@ 2021-02-10 21:56  Robert Haas <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: Robert Haas @ 2021-02-10 21:56 UTC (permalink / raw)

---
 doc/src/sgml/ddl.sgml                         |  3 ---
 doc/src/sgml/ref/create_table.sgml            | 15 +++++++++++----
 src/backend/access/common/detoast.c           |  5 ++---
 src/backend/access/compression/compress_lz4.c | 10 +++++-----
 src/backend/executor/nodeModifyTable.c        |  2 +-
 src/include/nodes/execnodes.h                 |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 4d7ed698b9..1e9a4625cc 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3762,9 +3762,6 @@ CREATE TABLE measurement (
        <productname>PostgreSQL</productname>
        tables (or, possibly, foreign tables).  It is possible to specify a
        tablespace and storage parameters for each partition separately.
-       By default, each column in a partition inherits the compression method
-       from parent table's column, however a different compression method can be
-       set for each partition.
       </para>
 
       <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 51a7a977a5..a4b297340f 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -997,10 +997,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
-      This sets the compression method for a column.  The supported compression
-      methods are <literal>pglz</literal> and <literal>lz4</literal>.
-      <literal>lz4</literal> is available only if <literal>--with-lz4</literal>
-      was used when building <productname>PostgreSQL</productname>. The default
+      The <literal>COMPRESSION</literal> clause sets the compression method
+      for a column.  Compression is supported only for variable-width data
+      types, and is used only for columns whose storage type is main or
+      extended. (See <xref linkend="sql-altertable"/> for information on
+      column storage types.) Setting this property for a partitioned table
+      has no direct effect, because such tables have no storage of their own,
+      but the configured value is inherited by newly-created partitions.
+      The supported compression methods are <literal>pglz</literal> and
+      <literal>lz4</literal>.  <literal>lz4</literal> is available only if
+      <literal>--with-lz4</literal> was used when building
+      <productname>PostgreSQL</productname>. The default
       is <literal>pglz</literal>.
      </para>
     </listitem>
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index b78d49167b..95d5b1c12a 100644
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -477,8 +477,8 @@ toast_get_compression_oid(struct varlena *attr)
 			return InvalidOid;
 
 		/*
-		 * Just fetch the toast compress header to know the compression method
-		 * in the compressed data.
+		 * Fetch just enough of the value to examine the compression header,
+		 * so that we can find out the compression method.
 		 */
 		attr = toast_fetch_datum_slice(attr, 0, VARHDRSZ_COMPRESS);
 	}
@@ -503,7 +503,6 @@ toast_get_compression_handler(struct varlena *attr)
 
 	cmid = TOAST_COMPRESS_METHOD(attr);
 
-	/* Get the handler routines for the compression method */
 	switch (cmid)
 	{
 		case PGLZ_COMPRESSION_ID:
diff --git a/src/backend/access/compression/compress_lz4.c b/src/backend/access/compression/compress_lz4.c
index 1856cf7df7..3079eff7eb 100644
--- a/src/backend/access/compression/compress_lz4.c
+++ b/src/backend/access/compression/compress_lz4.c
@@ -23,7 +23,7 @@
 /*
  * lz4_cmcompress - compression routine for lz4 compression method
  *
- * Compresses source into dest using the default strategy. Returns the
+ * Compresses source into dest using the LZ4 defaults. Returns the
  * compressed varlena, or NULL if compression fails.
  */
 static struct varlena *
@@ -42,8 +42,8 @@ lz4_cmcompress(const struct varlena *value)
 	valsize = VARSIZE_ANY_EXHDR(value);
 
 	/*
-	 * Get maximum size of the compressed data that lz4 compression may output
-	 * and allocate the memory for holding the compressed data and the header.
+	 * Figure out the maximum possible size of the LZ4 output, add the bytes
+	 * that will be needed for varlena overhead, and allocate that amount.
 	 */
 	max_size = LZ4_compressBound(valsize);
 	tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESS);
@@ -83,10 +83,10 @@ lz4_cmdecompress(const struct varlena *value)
 	int32		rawsize;
 	struct varlena *result;
 
-	/* allocate memory for holding the uncompressed data */
+	/* allocate memory for the uncompressed data */
 	result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ);
 
-	/* decompress data using lz4 routine */
+	/* decompress the data */
 	rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESS,
 								  VARDATA(result),
 								  VARSIZE(value) - VARHDRSZ_COMPRESS,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f77deee399..920d9dd0d5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2117,7 +2117,7 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
 		TupleTableSlot *newslot = *outslot;
 
 		/*
-		 * If the called has passed an invalid slot then create a new slot.
+		 * If the caller has passed an invalid slot then create a new slot.
 		 * Otherwise, just clear the existing tuple from the slot.  This slot
 		 * should be stored by the caller so that it can be reused for
 		 * decompressing the subsequent tuples.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 18e8ecfd90..d8483c36b3 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1183,8 +1183,8 @@ typedef struct ModifyTableState
 	TupleTableSlot *mt_root_tuple_slot;
 
 	/*
-	 * Slot for storing the modified tuple, incase the target attribute's
-	 * compression method doesn't match with the source table.
+	 * Slot for storing the modified tuple, in case the target attribute's
+	 * compression method doesn't match that of the source table.
 	 */
 	TupleTableSlot *mt_decompress_tuple_slot;
 
-- 
2.17.0


--YZ5djTAD1cGYuMQK
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v24-0006-alter-table-set-compression.patch"



^ permalink  raw  reply  [nested|flat] 46+ messages in thread

* [PATCH v24 05/10] fixups.patch
@ 2021-02-10 21:56  Robert Haas <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: Robert Haas @ 2021-02-10 21:56 UTC (permalink / raw)

---
 doc/src/sgml/ddl.sgml                         |  3 ---
 doc/src/sgml/ref/create_table.sgml            | 15 +++++++++++----
 src/backend/access/common/detoast.c           |  5 ++---
 src/backend/access/compression/compress_lz4.c | 10 +++++-----
 src/backend/executor/nodeModifyTable.c        |  2 +-
 src/include/nodes/execnodes.h                 |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 4d7ed698b9..1e9a4625cc 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3762,9 +3762,6 @@ CREATE TABLE measurement (
        <productname>PostgreSQL</productname>
        tables (or, possibly, foreign tables).  It is possible to specify a
        tablespace and storage parameters for each partition separately.
-       By default, each column in a partition inherits the compression method
-       from parent table's column, however a different compression method can be
-       set for each partition.
       </para>
 
       <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 51a7a977a5..a4b297340f 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -997,10 +997,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
-      This sets the compression method for a column.  The supported compression
-      methods are <literal>pglz</literal> and <literal>lz4</literal>.
-      <literal>lz4</literal> is available only if <literal>--with-lz4</literal>
-      was used when building <productname>PostgreSQL</productname>. The default
+      The <literal>COMPRESSION</literal> clause sets the compression method
+      for a column.  Compression is supported only for variable-width data
+      types, and is used only for columns whose storage type is main or
+      extended. (See <xref linkend="sql-altertable"/> for information on
+      column storage types.) Setting this property for a partitioned table
+      has no direct effect, because such tables have no storage of their own,
+      but the configured value is inherited by newly-created partitions.
+      The supported compression methods are <literal>pglz</literal> and
+      <literal>lz4</literal>.  <literal>lz4</literal> is available only if
+      <literal>--with-lz4</literal> was used when building
+      <productname>PostgreSQL</productname>. The default
       is <literal>pglz</literal>.
      </para>
     </listitem>
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index b78d49167b..95d5b1c12a 100644
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -477,8 +477,8 @@ toast_get_compression_oid(struct varlena *attr)
 			return InvalidOid;
 
 		/*
-		 * Just fetch the toast compress header to know the compression method
-		 * in the compressed data.
+		 * Fetch just enough of the value to examine the compression header,
+		 * so that we can find out the compression method.
 		 */
 		attr = toast_fetch_datum_slice(attr, 0, VARHDRSZ_COMPRESS);
 	}
@@ -503,7 +503,6 @@ toast_get_compression_handler(struct varlena *attr)
 
 	cmid = TOAST_COMPRESS_METHOD(attr);
 
-	/* Get the handler routines for the compression method */
 	switch (cmid)
 	{
 		case PGLZ_COMPRESSION_ID:
diff --git a/src/backend/access/compression/compress_lz4.c b/src/backend/access/compression/compress_lz4.c
index 1856cf7df7..3079eff7eb 100644
--- a/src/backend/access/compression/compress_lz4.c
+++ b/src/backend/access/compression/compress_lz4.c
@@ -23,7 +23,7 @@
 /*
  * lz4_cmcompress - compression routine for lz4 compression method
  *
- * Compresses source into dest using the default strategy. Returns the
+ * Compresses source into dest using the LZ4 defaults. Returns the
  * compressed varlena, or NULL if compression fails.
  */
 static struct varlena *
@@ -42,8 +42,8 @@ lz4_cmcompress(const struct varlena *value)
 	valsize = VARSIZE_ANY_EXHDR(value);
 
 	/*
-	 * Get maximum size of the compressed data that lz4 compression may output
-	 * and allocate the memory for holding the compressed data and the header.
+	 * Figure out the maximum possible size of the LZ4 output, add the bytes
+	 * that will be needed for varlena overhead, and allocate that amount.
 	 */
 	max_size = LZ4_compressBound(valsize);
 	tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESS);
@@ -83,10 +83,10 @@ lz4_cmdecompress(const struct varlena *value)
 	int32		rawsize;
 	struct varlena *result;
 
-	/* allocate memory for holding the uncompressed data */
+	/* allocate memory for the uncompressed data */
 	result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ);
 
-	/* decompress data using lz4 routine */
+	/* decompress the data */
 	rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESS,
 								  VARDATA(result),
 								  VARSIZE(value) - VARHDRSZ_COMPRESS,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f77deee399..920d9dd0d5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2117,7 +2117,7 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
 		TupleTableSlot *newslot = *outslot;
 
 		/*
-		 * If the called has passed an invalid slot then create a new slot.
+		 * If the caller has passed an invalid slot then create a new slot.
 		 * Otherwise, just clear the existing tuple from the slot.  This slot
 		 * should be stored by the caller so that it can be reused for
 		 * decompressing the subsequent tuples.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 18e8ecfd90..d8483c36b3 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1183,8 +1183,8 @@ typedef struct ModifyTableState
 	TupleTableSlot *mt_root_tuple_slot;
 
 	/*
-	 * Slot for storing the modified tuple, incase the target attribute's
-	 * compression method doesn't match with the source table.
+	 * Slot for storing the modified tuple, in case the target attribute's
+	 * compression method doesn't match that of the source table.
 	 */
 	TupleTableSlot *mt_decompress_tuple_slot;
 
-- 
2.17.0


--m51xatjYGsM+13rf
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v24-0006-alter-table-set-compression.patch"



^ permalink  raw  reply  [nested|flat] 46+ messages in thread

* [PATCH v24 5/7] fixups.patch
@ 2021-02-10 21:56  Robert Haas <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: Robert Haas @ 2021-02-10 21:56 UTC (permalink / raw)

---
 doc/src/sgml/ddl.sgml                         |  3 ---
 doc/src/sgml/ref/create_table.sgml            | 15 +++++++++++----
 src/backend/access/common/detoast.c           |  5 ++---
 src/backend/access/compression/compress_lz4.c | 10 +++++-----
 src/backend/executor/nodeModifyTable.c        |  2 +-
 src/include/nodes/execnodes.h                 |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 4d7ed698b9..1e9a4625cc 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3762,9 +3762,6 @@ CREATE TABLE measurement (
        <productname>PostgreSQL</productname>
        tables (or, possibly, foreign tables).  It is possible to specify a
        tablespace and storage parameters for each partition separately.
-       By default, each column in a partition inherits the compression method
-       from parent table's column, however a different compression method can be
-       set for each partition.
       </para>
 
       <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 51a7a977a5..a4b297340f 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -997,10 +997,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
-      This sets the compression method for a column.  The supported compression
-      methods are <literal>pglz</literal> and <literal>lz4</literal>.
-      <literal>lz4</literal> is available only if <literal>--with-lz4</literal>
-      was used when building <productname>PostgreSQL</productname>. The default
+      The <literal>COMPRESSION</literal> clause sets the compression method
+      for a column.  Compression is supported only for variable-width data
+      types, and is used only for columns whose storage type is main or
+      extended. (See <xref linkend="sql-altertable"/> for information on
+      column storage types.) Setting this property for a partitioned table
+      has no direct effect, because such tables have no storage of their own,
+      but the configured value is inherited by newly-created partitions.
+      The supported compression methods are <literal>pglz</literal> and
+      <literal>lz4</literal>.  <literal>lz4</literal> is available only if
+      <literal>--with-lz4</literal> was used when building
+      <productname>PostgreSQL</productname>. The default
       is <literal>pglz</literal>.
      </para>
     </listitem>
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index b78d49167b..95d5b1c12a 100644
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -477,8 +477,8 @@ toast_get_compression_oid(struct varlena *attr)
 			return InvalidOid;
 
 		/*
-		 * Just fetch the toast compress header to know the compression method
-		 * in the compressed data.
+		 * Fetch just enough of the value to examine the compression header,
+		 * so that we can find out the compression method.
 		 */
 		attr = toast_fetch_datum_slice(attr, 0, VARHDRSZ_COMPRESS);
 	}
@@ -503,7 +503,6 @@ toast_get_compression_handler(struct varlena *attr)
 
 	cmid = TOAST_COMPRESS_METHOD(attr);
 
-	/* Get the handler routines for the compression method */
 	switch (cmid)
 	{
 		case PGLZ_COMPRESSION_ID:
diff --git a/src/backend/access/compression/compress_lz4.c b/src/backend/access/compression/compress_lz4.c
index 1856cf7df7..3079eff7eb 100644
--- a/src/backend/access/compression/compress_lz4.c
+++ b/src/backend/access/compression/compress_lz4.c
@@ -23,7 +23,7 @@
 /*
  * lz4_cmcompress - compression routine for lz4 compression method
  *
- * Compresses source into dest using the default strategy. Returns the
+ * Compresses source into dest using the LZ4 defaults. Returns the
  * compressed varlena, or NULL if compression fails.
  */
 static struct varlena *
@@ -42,8 +42,8 @@ lz4_cmcompress(const struct varlena *value)
 	valsize = VARSIZE_ANY_EXHDR(value);
 
 	/*
-	 * Get maximum size of the compressed data that lz4 compression may output
-	 * and allocate the memory for holding the compressed data and the header.
+	 * Figure out the maximum possible size of the LZ4 output, add the bytes
+	 * that will be needed for varlena overhead, and allocate that amount.
 	 */
 	max_size = LZ4_compressBound(valsize);
 	tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESS);
@@ -83,10 +83,10 @@ lz4_cmdecompress(const struct varlena *value)
 	int32		rawsize;
 	struct varlena *result;
 
-	/* allocate memory for holding the uncompressed data */
+	/* allocate memory for the uncompressed data */
 	result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ);
 
-	/* decompress data using lz4 routine */
+	/* decompress the data */
 	rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESS,
 								  VARDATA(result),
 								  VARSIZE(value) - VARHDRSZ_COMPRESS,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f77deee399..920d9dd0d5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2117,7 +2117,7 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
 		TupleTableSlot *newslot = *outslot;
 
 		/*
-		 * If the called has passed an invalid slot then create a new slot.
+		 * If the caller has passed an invalid slot then create a new slot.
 		 * Otherwise, just clear the existing tuple from the slot.  This slot
 		 * should be stored by the caller so that it can be reused for
 		 * decompressing the subsequent tuples.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 18e8ecfd90..d8483c36b3 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1183,8 +1183,8 @@ typedef struct ModifyTableState
 	TupleTableSlot *mt_root_tuple_slot;
 
 	/*
-	 * Slot for storing the modified tuple, incase the target attribute's
-	 * compression method doesn't match with the source table.
+	 * Slot for storing the modified tuple, in case the target attribute's
+	 * compression method doesn't match that of the source table.
 	 */
 	TupleTableSlot *mt_decompress_tuple_slot;
 
-- 
2.17.0


--YZ5djTAD1cGYuMQK
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v24-0006-alter-table-set-compression.patch"



^ permalink  raw  reply  [nested|flat] 46+ messages in thread

* [PATCH v24 05/10] fixups.patch
@ 2021-02-10 21:56  Robert Haas <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: Robert Haas @ 2021-02-10 21:56 UTC (permalink / raw)

---
 doc/src/sgml/ddl.sgml                         |  3 ---
 doc/src/sgml/ref/create_table.sgml            | 15 +++++++++++----
 src/backend/access/common/detoast.c           |  5 ++---
 src/backend/access/compression/compress_lz4.c | 10 +++++-----
 src/backend/executor/nodeModifyTable.c        |  2 +-
 src/include/nodes/execnodes.h                 |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 4d7ed698b9..1e9a4625cc 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3762,9 +3762,6 @@ CREATE TABLE measurement (
        <productname>PostgreSQL</productname>
        tables (or, possibly, foreign tables).  It is possible to specify a
        tablespace and storage parameters for each partition separately.
-       By default, each column in a partition inherits the compression method
-       from parent table's column, however a different compression method can be
-       set for each partition.
       </para>
 
       <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 51a7a977a5..a4b297340f 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -997,10 +997,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
-      This sets the compression method for a column.  The supported compression
-      methods are <literal>pglz</literal> and <literal>lz4</literal>.
-      <literal>lz4</literal> is available only if <literal>--with-lz4</literal>
-      was used when building <productname>PostgreSQL</productname>. The default
+      The <literal>COMPRESSION</literal> clause sets the compression method
+      for a column.  Compression is supported only for variable-width data
+      types, and is used only for columns whose storage type is main or
+      extended. (See <xref linkend="sql-altertable"/> for information on
+      column storage types.) Setting this property for a partitioned table
+      has no direct effect, because such tables have no storage of their own,
+      but the configured value is inherited by newly-created partitions.
+      The supported compression methods are <literal>pglz</literal> and
+      <literal>lz4</literal>.  <literal>lz4</literal> is available only if
+      <literal>--with-lz4</literal> was used when building
+      <productname>PostgreSQL</productname>. The default
       is <literal>pglz</literal>.
      </para>
     </listitem>
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index b78d49167b..95d5b1c12a 100644
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -477,8 +477,8 @@ toast_get_compression_oid(struct varlena *attr)
 			return InvalidOid;
 
 		/*
-		 * Just fetch the toast compress header to know the compression method
-		 * in the compressed data.
+		 * Fetch just enough of the value to examine the compression header,
+		 * so that we can find out the compression method.
 		 */
 		attr = toast_fetch_datum_slice(attr, 0, VARHDRSZ_COMPRESS);
 	}
@@ -503,7 +503,6 @@ toast_get_compression_handler(struct varlena *attr)
 
 	cmid = TOAST_COMPRESS_METHOD(attr);
 
-	/* Get the handler routines for the compression method */
 	switch (cmid)
 	{
 		case PGLZ_COMPRESSION_ID:
diff --git a/src/backend/access/compression/compress_lz4.c b/src/backend/access/compression/compress_lz4.c
index 1856cf7df7..3079eff7eb 100644
--- a/src/backend/access/compression/compress_lz4.c
+++ b/src/backend/access/compression/compress_lz4.c
@@ -23,7 +23,7 @@
 /*
  * lz4_cmcompress - compression routine for lz4 compression method
  *
- * Compresses source into dest using the default strategy. Returns the
+ * Compresses source into dest using the LZ4 defaults. Returns the
  * compressed varlena, or NULL if compression fails.
  */
 static struct varlena *
@@ -42,8 +42,8 @@ lz4_cmcompress(const struct varlena *value)
 	valsize = VARSIZE_ANY_EXHDR(value);
 
 	/*
-	 * Get maximum size of the compressed data that lz4 compression may output
-	 * and allocate the memory for holding the compressed data and the header.
+	 * Figure out the maximum possible size of the LZ4 output, add the bytes
+	 * that will be needed for varlena overhead, and allocate that amount.
 	 */
 	max_size = LZ4_compressBound(valsize);
 	tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESS);
@@ -83,10 +83,10 @@ lz4_cmdecompress(const struct varlena *value)
 	int32		rawsize;
 	struct varlena *result;
 
-	/* allocate memory for holding the uncompressed data */
+	/* allocate memory for the uncompressed data */
 	result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ);
 
-	/* decompress data using lz4 routine */
+	/* decompress the data */
 	rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESS,
 								  VARDATA(result),
 								  VARSIZE(value) - VARHDRSZ_COMPRESS,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f77deee399..920d9dd0d5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2117,7 +2117,7 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
 		TupleTableSlot *newslot = *outslot;
 
 		/*
-		 * If the called has passed an invalid slot then create a new slot.
+		 * If the caller has passed an invalid slot then create a new slot.
 		 * Otherwise, just clear the existing tuple from the slot.  This slot
 		 * should be stored by the caller so that it can be reused for
 		 * decompressing the subsequent tuples.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 18e8ecfd90..d8483c36b3 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1183,8 +1183,8 @@ typedef struct ModifyTableState
 	TupleTableSlot *mt_root_tuple_slot;
 
 	/*
-	 * Slot for storing the modified tuple, incase the target attribute's
-	 * compression method doesn't match with the source table.
+	 * Slot for storing the modified tuple, in case the target attribute's
+	 * compression method doesn't match that of the source table.
 	 */
 	TupleTableSlot *mt_decompress_tuple_slot;
 
-- 
2.17.0


--m51xatjYGsM+13rf
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v24-0006-alter-table-set-compression.patch"



^ permalink  raw  reply  [nested|flat] 46+ messages in thread

* [PATCH v24 5/7] fixups.patch
@ 2021-02-10 21:56  Robert Haas <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: Robert Haas @ 2021-02-10 21:56 UTC (permalink / raw)

---
 doc/src/sgml/ddl.sgml                         |  3 ---
 doc/src/sgml/ref/create_table.sgml            | 15 +++++++++++----
 src/backend/access/common/detoast.c           |  5 ++---
 src/backend/access/compression/compress_lz4.c | 10 +++++-----
 src/backend/executor/nodeModifyTable.c        |  2 +-
 src/include/nodes/execnodes.h                 |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 4d7ed698b9..1e9a4625cc 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3762,9 +3762,6 @@ CREATE TABLE measurement (
        <productname>PostgreSQL</productname>
        tables (or, possibly, foreign tables).  It is possible to specify a
        tablespace and storage parameters for each partition separately.
-       By default, each column in a partition inherits the compression method
-       from parent table's column, however a different compression method can be
-       set for each partition.
       </para>
 
       <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 51a7a977a5..a4b297340f 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -997,10 +997,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
-      This sets the compression method for a column.  The supported compression
-      methods are <literal>pglz</literal> and <literal>lz4</literal>.
-      <literal>lz4</literal> is available only if <literal>--with-lz4</literal>
-      was used when building <productname>PostgreSQL</productname>. The default
+      The <literal>COMPRESSION</literal> clause sets the compression method
+      for a column.  Compression is supported only for variable-width data
+      types, and is used only for columns whose storage type is main or
+      extended. (See <xref linkend="sql-altertable"/> for information on
+      column storage types.) Setting this property for a partitioned table
+      has no direct effect, because such tables have no storage of their own,
+      but the configured value is inherited by newly-created partitions.
+      The supported compression methods are <literal>pglz</literal> and
+      <literal>lz4</literal>.  <literal>lz4</literal> is available only if
+      <literal>--with-lz4</literal> was used when building
+      <productname>PostgreSQL</productname>. The default
       is <literal>pglz</literal>.
      </para>
     </listitem>
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index b78d49167b..95d5b1c12a 100644
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -477,8 +477,8 @@ toast_get_compression_oid(struct varlena *attr)
 			return InvalidOid;
 
 		/*
-		 * Just fetch the toast compress header to know the compression method
-		 * in the compressed data.
+		 * Fetch just enough of the value to examine the compression header,
+		 * so that we can find out the compression method.
 		 */
 		attr = toast_fetch_datum_slice(attr, 0, VARHDRSZ_COMPRESS);
 	}
@@ -503,7 +503,6 @@ toast_get_compression_handler(struct varlena *attr)
 
 	cmid = TOAST_COMPRESS_METHOD(attr);
 
-	/* Get the handler routines for the compression method */
 	switch (cmid)
 	{
 		case PGLZ_COMPRESSION_ID:
diff --git a/src/backend/access/compression/compress_lz4.c b/src/backend/access/compression/compress_lz4.c
index 1856cf7df7..3079eff7eb 100644
--- a/src/backend/access/compression/compress_lz4.c
+++ b/src/backend/access/compression/compress_lz4.c
@@ -23,7 +23,7 @@
 /*
  * lz4_cmcompress - compression routine for lz4 compression method
  *
- * Compresses source into dest using the default strategy. Returns the
+ * Compresses source into dest using the LZ4 defaults. Returns the
  * compressed varlena, or NULL if compression fails.
  */
 static struct varlena *
@@ -42,8 +42,8 @@ lz4_cmcompress(const struct varlena *value)
 	valsize = VARSIZE_ANY_EXHDR(value);
 
 	/*
-	 * Get maximum size of the compressed data that lz4 compression may output
-	 * and allocate the memory for holding the compressed data and the header.
+	 * Figure out the maximum possible size of the LZ4 output, add the bytes
+	 * that will be needed for varlena overhead, and allocate that amount.
 	 */
 	max_size = LZ4_compressBound(valsize);
 	tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESS);
@@ -83,10 +83,10 @@ lz4_cmdecompress(const struct varlena *value)
 	int32		rawsize;
 	struct varlena *result;
 
-	/* allocate memory for holding the uncompressed data */
+	/* allocate memory for the uncompressed data */
 	result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ);
 
-	/* decompress data using lz4 routine */
+	/* decompress the data */
 	rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESS,
 								  VARDATA(result),
 								  VARSIZE(value) - VARHDRSZ_COMPRESS,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f77deee399..920d9dd0d5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2117,7 +2117,7 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
 		TupleTableSlot *newslot = *outslot;
 
 		/*
-		 * If the called has passed an invalid slot then create a new slot.
+		 * If the caller has passed an invalid slot then create a new slot.
 		 * Otherwise, just clear the existing tuple from the slot.  This slot
 		 * should be stored by the caller so that it can be reused for
 		 * decompressing the subsequent tuples.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 18e8ecfd90..d8483c36b3 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1183,8 +1183,8 @@ typedef struct ModifyTableState
 	TupleTableSlot *mt_root_tuple_slot;
 
 	/*
-	 * Slot for storing the modified tuple, incase the target attribute's
-	 * compression method doesn't match with the source table.
+	 * Slot for storing the modified tuple, in case the target attribute's
+	 * compression method doesn't match that of the source table.
 	 */
 	TupleTableSlot *mt_decompress_tuple_slot;
 
-- 
2.17.0


--YZ5djTAD1cGYuMQK
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v24-0006-alter-table-set-compression.patch"



^ permalink  raw  reply  [nested|flat] 46+ messages in thread

* [PATCH v24 05/10] fixups.patch
@ 2021-02-10 21:56  Robert Haas <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: Robert Haas @ 2021-02-10 21:56 UTC (permalink / raw)

---
 doc/src/sgml/ddl.sgml                         |  3 ---
 doc/src/sgml/ref/create_table.sgml            | 15 +++++++++++----
 src/backend/access/common/detoast.c           |  5 ++---
 src/backend/access/compression/compress_lz4.c | 10 +++++-----
 src/backend/executor/nodeModifyTable.c        |  2 +-
 src/include/nodes/execnodes.h                 |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 4d7ed698b9..1e9a4625cc 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3762,9 +3762,6 @@ CREATE TABLE measurement (
        <productname>PostgreSQL</productname>
        tables (or, possibly, foreign tables).  It is possible to specify a
        tablespace and storage parameters for each partition separately.
-       By default, each column in a partition inherits the compression method
-       from parent table's column, however a different compression method can be
-       set for each partition.
       </para>
 
       <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 51a7a977a5..a4b297340f 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -997,10 +997,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
-      This sets the compression method for a column.  The supported compression
-      methods are <literal>pglz</literal> and <literal>lz4</literal>.
-      <literal>lz4</literal> is available only if <literal>--with-lz4</literal>
-      was used when building <productname>PostgreSQL</productname>. The default
+      The <literal>COMPRESSION</literal> clause sets the compression method
+      for a column.  Compression is supported only for variable-width data
+      types, and is used only for columns whose storage type is main or
+      extended. (See <xref linkend="sql-altertable"/> for information on
+      column storage types.) Setting this property for a partitioned table
+      has no direct effect, because such tables have no storage of their own,
+      but the configured value is inherited by newly-created partitions.
+      The supported compression methods are <literal>pglz</literal> and
+      <literal>lz4</literal>.  <literal>lz4</literal> is available only if
+      <literal>--with-lz4</literal> was used when building
+      <productname>PostgreSQL</productname>. The default
       is <literal>pglz</literal>.
      </para>
     </listitem>
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index b78d49167b..95d5b1c12a 100644
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -477,8 +477,8 @@ toast_get_compression_oid(struct varlena *attr)
 			return InvalidOid;
 
 		/*
-		 * Just fetch the toast compress header to know the compression method
-		 * in the compressed data.
+		 * Fetch just enough of the value to examine the compression header,
+		 * so that we can find out the compression method.
 		 */
 		attr = toast_fetch_datum_slice(attr, 0, VARHDRSZ_COMPRESS);
 	}
@@ -503,7 +503,6 @@ toast_get_compression_handler(struct varlena *attr)
 
 	cmid = TOAST_COMPRESS_METHOD(attr);
 
-	/* Get the handler routines for the compression method */
 	switch (cmid)
 	{
 		case PGLZ_COMPRESSION_ID:
diff --git a/src/backend/access/compression/compress_lz4.c b/src/backend/access/compression/compress_lz4.c
index 1856cf7df7..3079eff7eb 100644
--- a/src/backend/access/compression/compress_lz4.c
+++ b/src/backend/access/compression/compress_lz4.c
@@ -23,7 +23,7 @@
 /*
  * lz4_cmcompress - compression routine for lz4 compression method
  *
- * Compresses source into dest using the default strategy. Returns the
+ * Compresses source into dest using the LZ4 defaults. Returns the
  * compressed varlena, or NULL if compression fails.
  */
 static struct varlena *
@@ -42,8 +42,8 @@ lz4_cmcompress(const struct varlena *value)
 	valsize = VARSIZE_ANY_EXHDR(value);
 
 	/*
-	 * Get maximum size of the compressed data that lz4 compression may output
-	 * and allocate the memory for holding the compressed data and the header.
+	 * Figure out the maximum possible size of the LZ4 output, add the bytes
+	 * that will be needed for varlena overhead, and allocate that amount.
 	 */
 	max_size = LZ4_compressBound(valsize);
 	tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESS);
@@ -83,10 +83,10 @@ lz4_cmdecompress(const struct varlena *value)
 	int32		rawsize;
 	struct varlena *result;
 
-	/* allocate memory for holding the uncompressed data */
+	/* allocate memory for the uncompressed data */
 	result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ);
 
-	/* decompress data using lz4 routine */
+	/* decompress the data */
 	rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESS,
 								  VARDATA(result),
 								  VARSIZE(value) - VARHDRSZ_COMPRESS,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f77deee399..920d9dd0d5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2117,7 +2117,7 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
 		TupleTableSlot *newslot = *outslot;
 
 		/*
-		 * If the called has passed an invalid slot then create a new slot.
+		 * If the caller has passed an invalid slot then create a new slot.
 		 * Otherwise, just clear the existing tuple from the slot.  This slot
 		 * should be stored by the caller so that it can be reused for
 		 * decompressing the subsequent tuples.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 18e8ecfd90..d8483c36b3 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1183,8 +1183,8 @@ typedef struct ModifyTableState
 	TupleTableSlot *mt_root_tuple_slot;
 
 	/*
-	 * Slot for storing the modified tuple, incase the target attribute's
-	 * compression method doesn't match with the source table.
+	 * Slot for storing the modified tuple, in case the target attribute's
+	 * compression method doesn't match that of the source table.
 	 */
 	TupleTableSlot *mt_decompress_tuple_slot;
 
-- 
2.17.0


--m51xatjYGsM+13rf
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v24-0006-alter-table-set-compression.patch"



^ permalink  raw  reply  [nested|flat] 46+ messages in thread

* [PATCH v24 5/7] fixups.patch
@ 2021-02-10 21:56  Robert Haas <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: Robert Haas @ 2021-02-10 21:56 UTC (permalink / raw)

---
 doc/src/sgml/ddl.sgml                         |  3 ---
 doc/src/sgml/ref/create_table.sgml            | 15 +++++++++++----
 src/backend/access/common/detoast.c           |  5 ++---
 src/backend/access/compression/compress_lz4.c | 10 +++++-----
 src/backend/executor/nodeModifyTable.c        |  2 +-
 src/include/nodes/execnodes.h                 |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 4d7ed698b9..1e9a4625cc 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3762,9 +3762,6 @@ CREATE TABLE measurement (
        <productname>PostgreSQL</productname>
        tables (or, possibly, foreign tables).  It is possible to specify a
        tablespace and storage parameters for each partition separately.
-       By default, each column in a partition inherits the compression method
-       from parent table's column, however a different compression method can be
-       set for each partition.
       </para>
 
       <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 51a7a977a5..a4b297340f 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -997,10 +997,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
-      This sets the compression method for a column.  The supported compression
-      methods are <literal>pglz</literal> and <literal>lz4</literal>.
-      <literal>lz4</literal> is available only if <literal>--with-lz4</literal>
-      was used when building <productname>PostgreSQL</productname>. The default
+      The <literal>COMPRESSION</literal> clause sets the compression method
+      for a column.  Compression is supported only for variable-width data
+      types, and is used only for columns whose storage type is main or
+      extended. (See <xref linkend="sql-altertable"/> for information on
+      column storage types.) Setting this property for a partitioned table
+      has no direct effect, because such tables have no storage of their own,
+      but the configured value is inherited by newly-created partitions.
+      The supported compression methods are <literal>pglz</literal> and
+      <literal>lz4</literal>.  <literal>lz4</literal> is available only if
+      <literal>--with-lz4</literal> was used when building
+      <productname>PostgreSQL</productname>. The default
       is <literal>pglz</literal>.
      </para>
     </listitem>
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index b78d49167b..95d5b1c12a 100644
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -477,8 +477,8 @@ toast_get_compression_oid(struct varlena *attr)
 			return InvalidOid;
 
 		/*
-		 * Just fetch the toast compress header to know the compression method
-		 * in the compressed data.
+		 * Fetch just enough of the value to examine the compression header,
+		 * so that we can find out the compression method.
 		 */
 		attr = toast_fetch_datum_slice(attr, 0, VARHDRSZ_COMPRESS);
 	}
@@ -503,7 +503,6 @@ toast_get_compression_handler(struct varlena *attr)
 
 	cmid = TOAST_COMPRESS_METHOD(attr);
 
-	/* Get the handler routines for the compression method */
 	switch (cmid)
 	{
 		case PGLZ_COMPRESSION_ID:
diff --git a/src/backend/access/compression/compress_lz4.c b/src/backend/access/compression/compress_lz4.c
index 1856cf7df7..3079eff7eb 100644
--- a/src/backend/access/compression/compress_lz4.c
+++ b/src/backend/access/compression/compress_lz4.c
@@ -23,7 +23,7 @@
 /*
  * lz4_cmcompress - compression routine for lz4 compression method
  *
- * Compresses source into dest using the default strategy. Returns the
+ * Compresses source into dest using the LZ4 defaults. Returns the
  * compressed varlena, or NULL if compression fails.
  */
 static struct varlena *
@@ -42,8 +42,8 @@ lz4_cmcompress(const struct varlena *value)
 	valsize = VARSIZE_ANY_EXHDR(value);
 
 	/*
-	 * Get maximum size of the compressed data that lz4 compression may output
-	 * and allocate the memory for holding the compressed data and the header.
+	 * Figure out the maximum possible size of the LZ4 output, add the bytes
+	 * that will be needed for varlena overhead, and allocate that amount.
 	 */
 	max_size = LZ4_compressBound(valsize);
 	tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESS);
@@ -83,10 +83,10 @@ lz4_cmdecompress(const struct varlena *value)
 	int32		rawsize;
 	struct varlena *result;
 
-	/* allocate memory for holding the uncompressed data */
+	/* allocate memory for the uncompressed data */
 	result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ);
 
-	/* decompress data using lz4 routine */
+	/* decompress the data */
 	rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESS,
 								  VARDATA(result),
 								  VARSIZE(value) - VARHDRSZ_COMPRESS,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f77deee399..920d9dd0d5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2117,7 +2117,7 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
 		TupleTableSlot *newslot = *outslot;
 
 		/*
-		 * If the called has passed an invalid slot then create a new slot.
+		 * If the caller has passed an invalid slot then create a new slot.
 		 * Otherwise, just clear the existing tuple from the slot.  This slot
 		 * should be stored by the caller so that it can be reused for
 		 * decompressing the subsequent tuples.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 18e8ecfd90..d8483c36b3 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1183,8 +1183,8 @@ typedef struct ModifyTableState
 	TupleTableSlot *mt_root_tuple_slot;
 
 	/*
-	 * Slot for storing the modified tuple, incase the target attribute's
-	 * compression method doesn't match with the source table.
+	 * Slot for storing the modified tuple, in case the target attribute's
+	 * compression method doesn't match that of the source table.
 	 */
 	TupleTableSlot *mt_decompress_tuple_slot;
 
-- 
2.17.0


--YZ5djTAD1cGYuMQK
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v24-0006-alter-table-set-compression.patch"



^ permalink  raw  reply  [nested|flat] 46+ messages in thread

* [PATCH v24 05/10] fixups.patch
@ 2021-02-10 21:56  Robert Haas <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: Robert Haas @ 2021-02-10 21:56 UTC (permalink / raw)

---
 doc/src/sgml/ddl.sgml                         |  3 ---
 doc/src/sgml/ref/create_table.sgml            | 15 +++++++++++----
 src/backend/access/common/detoast.c           |  5 ++---
 src/backend/access/compression/compress_lz4.c | 10 +++++-----
 src/backend/executor/nodeModifyTable.c        |  2 +-
 src/include/nodes/execnodes.h                 |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 4d7ed698b9..1e9a4625cc 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3762,9 +3762,6 @@ CREATE TABLE measurement (
        <productname>PostgreSQL</productname>
        tables (or, possibly, foreign tables).  It is possible to specify a
        tablespace and storage parameters for each partition separately.
-       By default, each column in a partition inherits the compression method
-       from parent table's column, however a different compression method can be
-       set for each partition.
       </para>
 
       <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 51a7a977a5..a4b297340f 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -997,10 +997,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
-      This sets the compression method for a column.  The supported compression
-      methods are <literal>pglz</literal> and <literal>lz4</literal>.
-      <literal>lz4</literal> is available only if <literal>--with-lz4</literal>
-      was used when building <productname>PostgreSQL</productname>. The default
+      The <literal>COMPRESSION</literal> clause sets the compression method
+      for a column.  Compression is supported only for variable-width data
+      types, and is used only for columns whose storage type is main or
+      extended. (See <xref linkend="sql-altertable"/> for information on
+      column storage types.) Setting this property for a partitioned table
+      has no direct effect, because such tables have no storage of their own,
+      but the configured value is inherited by newly-created partitions.
+      The supported compression methods are <literal>pglz</literal> and
+      <literal>lz4</literal>.  <literal>lz4</literal> is available only if
+      <literal>--with-lz4</literal> was used when building
+      <productname>PostgreSQL</productname>. The default
       is <literal>pglz</literal>.
      </para>
     </listitem>
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index b78d49167b..95d5b1c12a 100644
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -477,8 +477,8 @@ toast_get_compression_oid(struct varlena *attr)
 			return InvalidOid;
 
 		/*
-		 * Just fetch the toast compress header to know the compression method
-		 * in the compressed data.
+		 * Fetch just enough of the value to examine the compression header,
+		 * so that we can find out the compression method.
 		 */
 		attr = toast_fetch_datum_slice(attr, 0, VARHDRSZ_COMPRESS);
 	}
@@ -503,7 +503,6 @@ toast_get_compression_handler(struct varlena *attr)
 
 	cmid = TOAST_COMPRESS_METHOD(attr);
 
-	/* Get the handler routines for the compression method */
 	switch (cmid)
 	{
 		case PGLZ_COMPRESSION_ID:
diff --git a/src/backend/access/compression/compress_lz4.c b/src/backend/access/compression/compress_lz4.c
index 1856cf7df7..3079eff7eb 100644
--- a/src/backend/access/compression/compress_lz4.c
+++ b/src/backend/access/compression/compress_lz4.c
@@ -23,7 +23,7 @@
 /*
  * lz4_cmcompress - compression routine for lz4 compression method
  *
- * Compresses source into dest using the default strategy. Returns the
+ * Compresses source into dest using the LZ4 defaults. Returns the
  * compressed varlena, or NULL if compression fails.
  */
 static struct varlena *
@@ -42,8 +42,8 @@ lz4_cmcompress(const struct varlena *value)
 	valsize = VARSIZE_ANY_EXHDR(value);
 
 	/*
-	 * Get maximum size of the compressed data that lz4 compression may output
-	 * and allocate the memory for holding the compressed data and the header.
+	 * Figure out the maximum possible size of the LZ4 output, add the bytes
+	 * that will be needed for varlena overhead, and allocate that amount.
 	 */
 	max_size = LZ4_compressBound(valsize);
 	tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESS);
@@ -83,10 +83,10 @@ lz4_cmdecompress(const struct varlena *value)
 	int32		rawsize;
 	struct varlena *result;
 
-	/* allocate memory for holding the uncompressed data */
+	/* allocate memory for the uncompressed data */
 	result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ);
 
-	/* decompress data using lz4 routine */
+	/* decompress the data */
 	rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESS,
 								  VARDATA(result),
 								  VARSIZE(value) - VARHDRSZ_COMPRESS,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f77deee399..920d9dd0d5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2117,7 +2117,7 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
 		TupleTableSlot *newslot = *outslot;
 
 		/*
-		 * If the called has passed an invalid slot then create a new slot.
+		 * If the caller has passed an invalid slot then create a new slot.
 		 * Otherwise, just clear the existing tuple from the slot.  This slot
 		 * should be stored by the caller so that it can be reused for
 		 * decompressing the subsequent tuples.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 18e8ecfd90..d8483c36b3 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1183,8 +1183,8 @@ typedef struct ModifyTableState
 	TupleTableSlot *mt_root_tuple_slot;
 
 	/*
-	 * Slot for storing the modified tuple, incase the target attribute's
-	 * compression method doesn't match with the source table.
+	 * Slot for storing the modified tuple, in case the target attribute's
+	 * compression method doesn't match that of the source table.
 	 */
 	TupleTableSlot *mt_decompress_tuple_slot;
 
-- 
2.17.0


--m51xatjYGsM+13rf
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v24-0006-alter-table-set-compression.patch"



^ permalink  raw  reply  [nested|flat] 46+ messages in thread

* [PATCH v24 5/7] fixups.patch
@ 2021-02-10 21:56  Robert Haas <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: Robert Haas @ 2021-02-10 21:56 UTC (permalink / raw)

---
 doc/src/sgml/ddl.sgml                         |  3 ---
 doc/src/sgml/ref/create_table.sgml            | 15 +++++++++++----
 src/backend/access/common/detoast.c           |  5 ++---
 src/backend/access/compression/compress_lz4.c | 10 +++++-----
 src/backend/executor/nodeModifyTable.c        |  2 +-
 src/include/nodes/execnodes.h                 |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 4d7ed698b9..1e9a4625cc 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3762,9 +3762,6 @@ CREATE TABLE measurement (
        <productname>PostgreSQL</productname>
        tables (or, possibly, foreign tables).  It is possible to specify a
        tablespace and storage parameters for each partition separately.
-       By default, each column in a partition inherits the compression method
-       from parent table's column, however a different compression method can be
-       set for each partition.
       </para>
 
       <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 51a7a977a5..a4b297340f 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -997,10 +997,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
-      This sets the compression method for a column.  The supported compression
-      methods are <literal>pglz</literal> and <literal>lz4</literal>.
-      <literal>lz4</literal> is available only if <literal>--with-lz4</literal>
-      was used when building <productname>PostgreSQL</productname>. The default
+      The <literal>COMPRESSION</literal> clause sets the compression method
+      for a column.  Compression is supported only for variable-width data
+      types, and is used only for columns whose storage type is main or
+      extended. (See <xref linkend="sql-altertable"/> for information on
+      column storage types.) Setting this property for a partitioned table
+      has no direct effect, because such tables have no storage of their own,
+      but the configured value is inherited by newly-created partitions.
+      The supported compression methods are <literal>pglz</literal> and
+      <literal>lz4</literal>.  <literal>lz4</literal> is available only if
+      <literal>--with-lz4</literal> was used when building
+      <productname>PostgreSQL</productname>. The default
       is <literal>pglz</literal>.
      </para>
     </listitem>
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index b78d49167b..95d5b1c12a 100644
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -477,8 +477,8 @@ toast_get_compression_oid(struct varlena *attr)
 			return InvalidOid;
 
 		/*
-		 * Just fetch the toast compress header to know the compression method
-		 * in the compressed data.
+		 * Fetch just enough of the value to examine the compression header,
+		 * so that we can find out the compression method.
 		 */
 		attr = toast_fetch_datum_slice(attr, 0, VARHDRSZ_COMPRESS);
 	}
@@ -503,7 +503,6 @@ toast_get_compression_handler(struct varlena *attr)
 
 	cmid = TOAST_COMPRESS_METHOD(attr);
 
-	/* Get the handler routines for the compression method */
 	switch (cmid)
 	{
 		case PGLZ_COMPRESSION_ID:
diff --git a/src/backend/access/compression/compress_lz4.c b/src/backend/access/compression/compress_lz4.c
index 1856cf7df7..3079eff7eb 100644
--- a/src/backend/access/compression/compress_lz4.c
+++ b/src/backend/access/compression/compress_lz4.c
@@ -23,7 +23,7 @@
 /*
  * lz4_cmcompress - compression routine for lz4 compression method
  *
- * Compresses source into dest using the default strategy. Returns the
+ * Compresses source into dest using the LZ4 defaults. Returns the
  * compressed varlena, or NULL if compression fails.
  */
 static struct varlena *
@@ -42,8 +42,8 @@ lz4_cmcompress(const struct varlena *value)
 	valsize = VARSIZE_ANY_EXHDR(value);
 
 	/*
-	 * Get maximum size of the compressed data that lz4 compression may output
-	 * and allocate the memory for holding the compressed data and the header.
+	 * Figure out the maximum possible size of the LZ4 output, add the bytes
+	 * that will be needed for varlena overhead, and allocate that amount.
 	 */
 	max_size = LZ4_compressBound(valsize);
 	tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESS);
@@ -83,10 +83,10 @@ lz4_cmdecompress(const struct varlena *value)
 	int32		rawsize;
 	struct varlena *result;
 
-	/* allocate memory for holding the uncompressed data */
+	/* allocate memory for the uncompressed data */
 	result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ);
 
-	/* decompress data using lz4 routine */
+	/* decompress the data */
 	rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESS,
 								  VARDATA(result),
 								  VARSIZE(value) - VARHDRSZ_COMPRESS,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f77deee399..920d9dd0d5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2117,7 +2117,7 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
 		TupleTableSlot *newslot = *outslot;
 
 		/*
-		 * If the called has passed an invalid slot then create a new slot.
+		 * If the caller has passed an invalid slot then create a new slot.
 		 * Otherwise, just clear the existing tuple from the slot.  This slot
 		 * should be stored by the caller so that it can be reused for
 		 * decompressing the subsequent tuples.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 18e8ecfd90..d8483c36b3 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1183,8 +1183,8 @@ typedef struct ModifyTableState
 	TupleTableSlot *mt_root_tuple_slot;
 
 	/*
-	 * Slot for storing the modified tuple, incase the target attribute's
-	 * compression method doesn't match with the source table.
+	 * Slot for storing the modified tuple, in case the target attribute's
+	 * compression method doesn't match that of the source table.
 	 */
 	TupleTableSlot *mt_decompress_tuple_slot;
 
-- 
2.17.0


--YZ5djTAD1cGYuMQK
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v24-0006-alter-table-set-compression.patch"



^ permalink  raw  reply  [nested|flat] 46+ messages in thread

* [PATCH v24 05/10] fixups.patch
@ 2021-02-10 21:56  Robert Haas <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: Robert Haas @ 2021-02-10 21:56 UTC (permalink / raw)

---
 doc/src/sgml/ddl.sgml                         |  3 ---
 doc/src/sgml/ref/create_table.sgml            | 15 +++++++++++----
 src/backend/access/common/detoast.c           |  5 ++---
 src/backend/access/compression/compress_lz4.c | 10 +++++-----
 src/backend/executor/nodeModifyTable.c        |  2 +-
 src/include/nodes/execnodes.h                 |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 4d7ed698b9..1e9a4625cc 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3762,9 +3762,6 @@ CREATE TABLE measurement (
        <productname>PostgreSQL</productname>
        tables (or, possibly, foreign tables).  It is possible to specify a
        tablespace and storage parameters for each partition separately.
-       By default, each column in a partition inherits the compression method
-       from parent table's column, however a different compression method can be
-       set for each partition.
       </para>
 
       <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 51a7a977a5..a4b297340f 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -997,10 +997,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
-      This sets the compression method for a column.  The supported compression
-      methods are <literal>pglz</literal> and <literal>lz4</literal>.
-      <literal>lz4</literal> is available only if <literal>--with-lz4</literal>
-      was used when building <productname>PostgreSQL</productname>. The default
+      The <literal>COMPRESSION</literal> clause sets the compression method
+      for a column.  Compression is supported only for variable-width data
+      types, and is used only for columns whose storage type is main or
+      extended. (See <xref linkend="sql-altertable"/> for information on
+      column storage types.) Setting this property for a partitioned table
+      has no direct effect, because such tables have no storage of their own,
+      but the configured value is inherited by newly-created partitions.
+      The supported compression methods are <literal>pglz</literal> and
+      <literal>lz4</literal>.  <literal>lz4</literal> is available only if
+      <literal>--with-lz4</literal> was used when building
+      <productname>PostgreSQL</productname>. The default
       is <literal>pglz</literal>.
      </para>
     </listitem>
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index b78d49167b..95d5b1c12a 100644
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -477,8 +477,8 @@ toast_get_compression_oid(struct varlena *attr)
 			return InvalidOid;
 
 		/*
-		 * Just fetch the toast compress header to know the compression method
-		 * in the compressed data.
+		 * Fetch just enough of the value to examine the compression header,
+		 * so that we can find out the compression method.
 		 */
 		attr = toast_fetch_datum_slice(attr, 0, VARHDRSZ_COMPRESS);
 	}
@@ -503,7 +503,6 @@ toast_get_compression_handler(struct varlena *attr)
 
 	cmid = TOAST_COMPRESS_METHOD(attr);
 
-	/* Get the handler routines for the compression method */
 	switch (cmid)
 	{
 		case PGLZ_COMPRESSION_ID:
diff --git a/src/backend/access/compression/compress_lz4.c b/src/backend/access/compression/compress_lz4.c
index 1856cf7df7..3079eff7eb 100644
--- a/src/backend/access/compression/compress_lz4.c
+++ b/src/backend/access/compression/compress_lz4.c
@@ -23,7 +23,7 @@
 /*
  * lz4_cmcompress - compression routine for lz4 compression method
  *
- * Compresses source into dest using the default strategy. Returns the
+ * Compresses source into dest using the LZ4 defaults. Returns the
  * compressed varlena, or NULL if compression fails.
  */
 static struct varlena *
@@ -42,8 +42,8 @@ lz4_cmcompress(const struct varlena *value)
 	valsize = VARSIZE_ANY_EXHDR(value);
 
 	/*
-	 * Get maximum size of the compressed data that lz4 compression may output
-	 * and allocate the memory for holding the compressed data and the header.
+	 * Figure out the maximum possible size of the LZ4 output, add the bytes
+	 * that will be needed for varlena overhead, and allocate that amount.
 	 */
 	max_size = LZ4_compressBound(valsize);
 	tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESS);
@@ -83,10 +83,10 @@ lz4_cmdecompress(const struct varlena *value)
 	int32		rawsize;
 	struct varlena *result;
 
-	/* allocate memory for holding the uncompressed data */
+	/* allocate memory for the uncompressed data */
 	result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ);
 
-	/* decompress data using lz4 routine */
+	/* decompress the data */
 	rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESS,
 								  VARDATA(result),
 								  VARSIZE(value) - VARHDRSZ_COMPRESS,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f77deee399..920d9dd0d5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2117,7 +2117,7 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
 		TupleTableSlot *newslot = *outslot;
 
 		/*
-		 * If the called has passed an invalid slot then create a new slot.
+		 * If the caller has passed an invalid slot then create a new slot.
 		 * Otherwise, just clear the existing tuple from the slot.  This slot
 		 * should be stored by the caller so that it can be reused for
 		 * decompressing the subsequent tuples.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 18e8ecfd90..d8483c36b3 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1183,8 +1183,8 @@ typedef struct ModifyTableState
 	TupleTableSlot *mt_root_tuple_slot;
 
 	/*
-	 * Slot for storing the modified tuple, incase the target attribute's
-	 * compression method doesn't match with the source table.
+	 * Slot for storing the modified tuple, in case the target attribute's
+	 * compression method doesn't match that of the source table.
 	 */
 	TupleTableSlot *mt_decompress_tuple_slot;
 
-- 
2.17.0


--m51xatjYGsM+13rf
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v24-0006-alter-table-set-compression.patch"



^ permalink  raw  reply  [nested|flat] 46+ messages in thread

* [PATCH v24 5/7] fixups.patch
@ 2021-02-10 21:56  Robert Haas <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: Robert Haas @ 2021-02-10 21:56 UTC (permalink / raw)

---
 doc/src/sgml/ddl.sgml                         |  3 ---
 doc/src/sgml/ref/create_table.sgml            | 15 +++++++++++----
 src/backend/access/common/detoast.c           |  5 ++---
 src/backend/access/compression/compress_lz4.c | 10 +++++-----
 src/backend/executor/nodeModifyTable.c        |  2 +-
 src/include/nodes/execnodes.h                 |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 4d7ed698b9..1e9a4625cc 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3762,9 +3762,6 @@ CREATE TABLE measurement (
        <productname>PostgreSQL</productname>
        tables (or, possibly, foreign tables).  It is possible to specify a
        tablespace and storage parameters for each partition separately.
-       By default, each column in a partition inherits the compression method
-       from parent table's column, however a different compression method can be
-       set for each partition.
       </para>
 
       <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 51a7a977a5..a4b297340f 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -997,10 +997,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
-      This sets the compression method for a column.  The supported compression
-      methods are <literal>pglz</literal> and <literal>lz4</literal>.
-      <literal>lz4</literal> is available only if <literal>--with-lz4</literal>
-      was used when building <productname>PostgreSQL</productname>. The default
+      The <literal>COMPRESSION</literal> clause sets the compression method
+      for a column.  Compression is supported only for variable-width data
+      types, and is used only for columns whose storage type is main or
+      extended. (See <xref linkend="sql-altertable"/> for information on
+      column storage types.) Setting this property for a partitioned table
+      has no direct effect, because such tables have no storage of their own,
+      but the configured value is inherited by newly-created partitions.
+      The supported compression methods are <literal>pglz</literal> and
+      <literal>lz4</literal>.  <literal>lz4</literal> is available only if
+      <literal>--with-lz4</literal> was used when building
+      <productname>PostgreSQL</productname>. The default
       is <literal>pglz</literal>.
      </para>
     </listitem>
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index b78d49167b..95d5b1c12a 100644
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -477,8 +477,8 @@ toast_get_compression_oid(struct varlena *attr)
 			return InvalidOid;
 
 		/*
-		 * Just fetch the toast compress header to know the compression method
-		 * in the compressed data.
+		 * Fetch just enough of the value to examine the compression header,
+		 * so that we can find out the compression method.
 		 */
 		attr = toast_fetch_datum_slice(attr, 0, VARHDRSZ_COMPRESS);
 	}
@@ -503,7 +503,6 @@ toast_get_compression_handler(struct varlena *attr)
 
 	cmid = TOAST_COMPRESS_METHOD(attr);
 
-	/* Get the handler routines for the compression method */
 	switch (cmid)
 	{
 		case PGLZ_COMPRESSION_ID:
diff --git a/src/backend/access/compression/compress_lz4.c b/src/backend/access/compression/compress_lz4.c
index 1856cf7df7..3079eff7eb 100644
--- a/src/backend/access/compression/compress_lz4.c
+++ b/src/backend/access/compression/compress_lz4.c
@@ -23,7 +23,7 @@
 /*
  * lz4_cmcompress - compression routine for lz4 compression method
  *
- * Compresses source into dest using the default strategy. Returns the
+ * Compresses source into dest using the LZ4 defaults. Returns the
  * compressed varlena, or NULL if compression fails.
  */
 static struct varlena *
@@ -42,8 +42,8 @@ lz4_cmcompress(const struct varlena *value)
 	valsize = VARSIZE_ANY_EXHDR(value);
 
 	/*
-	 * Get maximum size of the compressed data that lz4 compression may output
-	 * and allocate the memory for holding the compressed data and the header.
+	 * Figure out the maximum possible size of the LZ4 output, add the bytes
+	 * that will be needed for varlena overhead, and allocate that amount.
 	 */
 	max_size = LZ4_compressBound(valsize);
 	tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESS);
@@ -83,10 +83,10 @@ lz4_cmdecompress(const struct varlena *value)
 	int32		rawsize;
 	struct varlena *result;
 
-	/* allocate memory for holding the uncompressed data */
+	/* allocate memory for the uncompressed data */
 	result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ);
 
-	/* decompress data using lz4 routine */
+	/* decompress the data */
 	rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESS,
 								  VARDATA(result),
 								  VARSIZE(value) - VARHDRSZ_COMPRESS,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f77deee399..920d9dd0d5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2117,7 +2117,7 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
 		TupleTableSlot *newslot = *outslot;
 
 		/*
-		 * If the called has passed an invalid slot then create a new slot.
+		 * If the caller has passed an invalid slot then create a new slot.
 		 * Otherwise, just clear the existing tuple from the slot.  This slot
 		 * should be stored by the caller so that it can be reused for
 		 * decompressing the subsequent tuples.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 18e8ecfd90..d8483c36b3 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1183,8 +1183,8 @@ typedef struct ModifyTableState
 	TupleTableSlot *mt_root_tuple_slot;
 
 	/*
-	 * Slot for storing the modified tuple, incase the target attribute's
-	 * compression method doesn't match with the source table.
+	 * Slot for storing the modified tuple, in case the target attribute's
+	 * compression method doesn't match that of the source table.
 	 */
 	TupleTableSlot *mt_decompress_tuple_slot;
 
-- 
2.17.0


--YZ5djTAD1cGYuMQK
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v24-0006-alter-table-set-compression.patch"



^ permalink  raw  reply  [nested|flat] 46+ messages in thread

* [PATCH v24 05/10] fixups.patch
@ 2021-02-10 21:56  Robert Haas <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: Robert Haas @ 2021-02-10 21:56 UTC (permalink / raw)

---
 doc/src/sgml/ddl.sgml                         |  3 ---
 doc/src/sgml/ref/create_table.sgml            | 15 +++++++++++----
 src/backend/access/common/detoast.c           |  5 ++---
 src/backend/access/compression/compress_lz4.c | 10 +++++-----
 src/backend/executor/nodeModifyTable.c        |  2 +-
 src/include/nodes/execnodes.h                 |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 4d7ed698b9..1e9a4625cc 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3762,9 +3762,6 @@ CREATE TABLE measurement (
        <productname>PostgreSQL</productname>
        tables (or, possibly, foreign tables).  It is possible to specify a
        tablespace and storage parameters for each partition separately.
-       By default, each column in a partition inherits the compression method
-       from parent table's column, however a different compression method can be
-       set for each partition.
       </para>
 
       <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 51a7a977a5..a4b297340f 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -997,10 +997,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
-      This sets the compression method for a column.  The supported compression
-      methods are <literal>pglz</literal> and <literal>lz4</literal>.
-      <literal>lz4</literal> is available only if <literal>--with-lz4</literal>
-      was used when building <productname>PostgreSQL</productname>. The default
+      The <literal>COMPRESSION</literal> clause sets the compression method
+      for a column.  Compression is supported only for variable-width data
+      types, and is used only for columns whose storage type is main or
+      extended. (See <xref linkend="sql-altertable"/> for information on
+      column storage types.) Setting this property for a partitioned table
+      has no direct effect, because such tables have no storage of their own,
+      but the configured value is inherited by newly-created partitions.
+      The supported compression methods are <literal>pglz</literal> and
+      <literal>lz4</literal>.  <literal>lz4</literal> is available only if
+      <literal>--with-lz4</literal> was used when building
+      <productname>PostgreSQL</productname>. The default
       is <literal>pglz</literal>.
      </para>
     </listitem>
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index b78d49167b..95d5b1c12a 100644
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -477,8 +477,8 @@ toast_get_compression_oid(struct varlena *attr)
 			return InvalidOid;
 
 		/*
-		 * Just fetch the toast compress header to know the compression method
-		 * in the compressed data.
+		 * Fetch just enough of the value to examine the compression header,
+		 * so that we can find out the compression method.
 		 */
 		attr = toast_fetch_datum_slice(attr, 0, VARHDRSZ_COMPRESS);
 	}
@@ -503,7 +503,6 @@ toast_get_compression_handler(struct varlena *attr)
 
 	cmid = TOAST_COMPRESS_METHOD(attr);
 
-	/* Get the handler routines for the compression method */
 	switch (cmid)
 	{
 		case PGLZ_COMPRESSION_ID:
diff --git a/src/backend/access/compression/compress_lz4.c b/src/backend/access/compression/compress_lz4.c
index 1856cf7df7..3079eff7eb 100644
--- a/src/backend/access/compression/compress_lz4.c
+++ b/src/backend/access/compression/compress_lz4.c
@@ -23,7 +23,7 @@
 /*
  * lz4_cmcompress - compression routine for lz4 compression method
  *
- * Compresses source into dest using the default strategy. Returns the
+ * Compresses source into dest using the LZ4 defaults. Returns the
  * compressed varlena, or NULL if compression fails.
  */
 static struct varlena *
@@ -42,8 +42,8 @@ lz4_cmcompress(const struct varlena *value)
 	valsize = VARSIZE_ANY_EXHDR(value);
 
 	/*
-	 * Get maximum size of the compressed data that lz4 compression may output
-	 * and allocate the memory for holding the compressed data and the header.
+	 * Figure out the maximum possible size of the LZ4 output, add the bytes
+	 * that will be needed for varlena overhead, and allocate that amount.
 	 */
 	max_size = LZ4_compressBound(valsize);
 	tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESS);
@@ -83,10 +83,10 @@ lz4_cmdecompress(const struct varlena *value)
 	int32		rawsize;
 	struct varlena *result;
 
-	/* allocate memory for holding the uncompressed data */
+	/* allocate memory for the uncompressed data */
 	result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ);
 
-	/* decompress data using lz4 routine */
+	/* decompress the data */
 	rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESS,
 								  VARDATA(result),
 								  VARSIZE(value) - VARHDRSZ_COMPRESS,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f77deee399..920d9dd0d5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2117,7 +2117,7 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
 		TupleTableSlot *newslot = *outslot;
 
 		/*
-		 * If the called has passed an invalid slot then create a new slot.
+		 * If the caller has passed an invalid slot then create a new slot.
 		 * Otherwise, just clear the existing tuple from the slot.  This slot
 		 * should be stored by the caller so that it can be reused for
 		 * decompressing the subsequent tuples.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 18e8ecfd90..d8483c36b3 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1183,8 +1183,8 @@ typedef struct ModifyTableState
 	TupleTableSlot *mt_root_tuple_slot;
 
 	/*
-	 * Slot for storing the modified tuple, incase the target attribute's
-	 * compression method doesn't match with the source table.
+	 * Slot for storing the modified tuple, in case the target attribute's
+	 * compression method doesn't match that of the source table.
 	 */
 	TupleTableSlot *mt_decompress_tuple_slot;
 
-- 
2.17.0


--m51xatjYGsM+13rf
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v24-0006-alter-table-set-compression.patch"



^ permalink  raw  reply  [nested|flat] 46+ messages in thread

* [PATCH v24 5/7] fixups.patch
@ 2021-02-10 21:56  Robert Haas <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: Robert Haas @ 2021-02-10 21:56 UTC (permalink / raw)

---
 doc/src/sgml/ddl.sgml                         |  3 ---
 doc/src/sgml/ref/create_table.sgml            | 15 +++++++++++----
 src/backend/access/common/detoast.c           |  5 ++---
 src/backend/access/compression/compress_lz4.c | 10 +++++-----
 src/backend/executor/nodeModifyTable.c        |  2 +-
 src/include/nodes/execnodes.h                 |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 4d7ed698b9..1e9a4625cc 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3762,9 +3762,6 @@ CREATE TABLE measurement (
        <productname>PostgreSQL</productname>
        tables (or, possibly, foreign tables).  It is possible to specify a
        tablespace and storage parameters for each partition separately.
-       By default, each column in a partition inherits the compression method
-       from parent table's column, however a different compression method can be
-       set for each partition.
       </para>
 
       <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 51a7a977a5..a4b297340f 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -997,10 +997,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
-      This sets the compression method for a column.  The supported compression
-      methods are <literal>pglz</literal> and <literal>lz4</literal>.
-      <literal>lz4</literal> is available only if <literal>--with-lz4</literal>
-      was used when building <productname>PostgreSQL</productname>. The default
+      The <literal>COMPRESSION</literal> clause sets the compression method
+      for a column.  Compression is supported only for variable-width data
+      types, and is used only for columns whose storage type is main or
+      extended. (See <xref linkend="sql-altertable"/> for information on
+      column storage types.) Setting this property for a partitioned table
+      has no direct effect, because such tables have no storage of their own,
+      but the configured value is inherited by newly-created partitions.
+      The supported compression methods are <literal>pglz</literal> and
+      <literal>lz4</literal>.  <literal>lz4</literal> is available only if
+      <literal>--with-lz4</literal> was used when building
+      <productname>PostgreSQL</productname>. The default
       is <literal>pglz</literal>.
      </para>
     </listitem>
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index b78d49167b..95d5b1c12a 100644
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -477,8 +477,8 @@ toast_get_compression_oid(struct varlena *attr)
 			return InvalidOid;
 
 		/*
-		 * Just fetch the toast compress header to know the compression method
-		 * in the compressed data.
+		 * Fetch just enough of the value to examine the compression header,
+		 * so that we can find out the compression method.
 		 */
 		attr = toast_fetch_datum_slice(attr, 0, VARHDRSZ_COMPRESS);
 	}
@@ -503,7 +503,6 @@ toast_get_compression_handler(struct varlena *attr)
 
 	cmid = TOAST_COMPRESS_METHOD(attr);
 
-	/* Get the handler routines for the compression method */
 	switch (cmid)
 	{
 		case PGLZ_COMPRESSION_ID:
diff --git a/src/backend/access/compression/compress_lz4.c b/src/backend/access/compression/compress_lz4.c
index 1856cf7df7..3079eff7eb 100644
--- a/src/backend/access/compression/compress_lz4.c
+++ b/src/backend/access/compression/compress_lz4.c
@@ -23,7 +23,7 @@
 /*
  * lz4_cmcompress - compression routine for lz4 compression method
  *
- * Compresses source into dest using the default strategy. Returns the
+ * Compresses source into dest using the LZ4 defaults. Returns the
  * compressed varlena, or NULL if compression fails.
  */
 static struct varlena *
@@ -42,8 +42,8 @@ lz4_cmcompress(const struct varlena *value)
 	valsize = VARSIZE_ANY_EXHDR(value);
 
 	/*
-	 * Get maximum size of the compressed data that lz4 compression may output
-	 * and allocate the memory for holding the compressed data and the header.
+	 * Figure out the maximum possible size of the LZ4 output, add the bytes
+	 * that will be needed for varlena overhead, and allocate that amount.
 	 */
 	max_size = LZ4_compressBound(valsize);
 	tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESS);
@@ -83,10 +83,10 @@ lz4_cmdecompress(const struct varlena *value)
 	int32		rawsize;
 	struct varlena *result;
 
-	/* allocate memory for holding the uncompressed data */
+	/* allocate memory for the uncompressed data */
 	result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ);
 
-	/* decompress data using lz4 routine */
+	/* decompress the data */
 	rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESS,
 								  VARDATA(result),
 								  VARSIZE(value) - VARHDRSZ_COMPRESS,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f77deee399..920d9dd0d5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2117,7 +2117,7 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
 		TupleTableSlot *newslot = *outslot;
 
 		/*
-		 * If the called has passed an invalid slot then create a new slot.
+		 * If the caller has passed an invalid slot then create a new slot.
 		 * Otherwise, just clear the existing tuple from the slot.  This slot
 		 * should be stored by the caller so that it can be reused for
 		 * decompressing the subsequent tuples.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 18e8ecfd90..d8483c36b3 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1183,8 +1183,8 @@ typedef struct ModifyTableState
 	TupleTableSlot *mt_root_tuple_slot;
 
 	/*
-	 * Slot for storing the modified tuple, incase the target attribute's
-	 * compression method doesn't match with the source table.
+	 * Slot for storing the modified tuple, in case the target attribute's
+	 * compression method doesn't match that of the source table.
 	 */
 	TupleTableSlot *mt_decompress_tuple_slot;
 
-- 
2.17.0


--YZ5djTAD1cGYuMQK
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v24-0006-alter-table-set-compression.patch"



^ permalink  raw  reply  [nested|flat] 46+ messages in thread

* [PATCH v24 05/10] fixups.patch
@ 2021-02-10 21:56  Robert Haas <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: Robert Haas @ 2021-02-10 21:56 UTC (permalink / raw)

---
 doc/src/sgml/ddl.sgml                         |  3 ---
 doc/src/sgml/ref/create_table.sgml            | 15 +++++++++++----
 src/backend/access/common/detoast.c           |  5 ++---
 src/backend/access/compression/compress_lz4.c | 10 +++++-----
 src/backend/executor/nodeModifyTable.c        |  2 +-
 src/include/nodes/execnodes.h                 |  4 ++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 4d7ed698b9..1e9a4625cc 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -3762,9 +3762,6 @@ CREATE TABLE measurement (
        <productname>PostgreSQL</productname>
        tables (or, possibly, foreign tables).  It is possible to specify a
        tablespace and storage parameters for each partition separately.
-       By default, each column in a partition inherits the compression method
-       from parent table's column, however a different compression method can be
-       set for each partition.
       </para>
 
       <para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 51a7a977a5..a4b297340f 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -997,10 +997,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
-      This sets the compression method for a column.  The supported compression
-      methods are <literal>pglz</literal> and <literal>lz4</literal>.
-      <literal>lz4</literal> is available only if <literal>--with-lz4</literal>
-      was used when building <productname>PostgreSQL</productname>. The default
+      The <literal>COMPRESSION</literal> clause sets the compression method
+      for a column.  Compression is supported only for variable-width data
+      types, and is used only for columns whose storage type is main or
+      extended. (See <xref linkend="sql-altertable"/> for information on
+      column storage types.) Setting this property for a partitioned table
+      has no direct effect, because such tables have no storage of their own,
+      but the configured value is inherited by newly-created partitions.
+      The supported compression methods are <literal>pglz</literal> and
+      <literal>lz4</literal>.  <literal>lz4</literal> is available only if
+      <literal>--with-lz4</literal> was used when building
+      <productname>PostgreSQL</productname>. The default
       is <literal>pglz</literal>.
      </para>
     </listitem>
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c
index b78d49167b..95d5b1c12a 100644
--- a/src/backend/access/common/detoast.c
+++ b/src/backend/access/common/detoast.c
@@ -477,8 +477,8 @@ toast_get_compression_oid(struct varlena *attr)
 			return InvalidOid;
 
 		/*
-		 * Just fetch the toast compress header to know the compression method
-		 * in the compressed data.
+		 * Fetch just enough of the value to examine the compression header,
+		 * so that we can find out the compression method.
 		 */
 		attr = toast_fetch_datum_slice(attr, 0, VARHDRSZ_COMPRESS);
 	}
@@ -503,7 +503,6 @@ toast_get_compression_handler(struct varlena *attr)
 
 	cmid = TOAST_COMPRESS_METHOD(attr);
 
-	/* Get the handler routines for the compression method */
 	switch (cmid)
 	{
 		case PGLZ_COMPRESSION_ID:
diff --git a/src/backend/access/compression/compress_lz4.c b/src/backend/access/compression/compress_lz4.c
index 1856cf7df7..3079eff7eb 100644
--- a/src/backend/access/compression/compress_lz4.c
+++ b/src/backend/access/compression/compress_lz4.c
@@ -23,7 +23,7 @@
 /*
  * lz4_cmcompress - compression routine for lz4 compression method
  *
- * Compresses source into dest using the default strategy. Returns the
+ * Compresses source into dest using the LZ4 defaults. Returns the
  * compressed varlena, or NULL if compression fails.
  */
 static struct varlena *
@@ -42,8 +42,8 @@ lz4_cmcompress(const struct varlena *value)
 	valsize = VARSIZE_ANY_EXHDR(value);
 
 	/*
-	 * Get maximum size of the compressed data that lz4 compression may output
-	 * and allocate the memory for holding the compressed data and the header.
+	 * Figure out the maximum possible size of the LZ4 output, add the bytes
+	 * that will be needed for varlena overhead, and allocate that amount.
 	 */
 	max_size = LZ4_compressBound(valsize);
 	tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESS);
@@ -83,10 +83,10 @@ lz4_cmdecompress(const struct varlena *value)
 	int32		rawsize;
 	struct varlena *result;
 
-	/* allocate memory for holding the uncompressed data */
+	/* allocate memory for the uncompressed data */
 	result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ);
 
-	/* decompress data using lz4 routine */
+	/* decompress the data */
 	rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESS,
 								  VARDATA(result),
 								  VARSIZE(value) - VARHDRSZ_COMPRESS,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f77deee399..920d9dd0d5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2117,7 +2117,7 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
 		TupleTableSlot *newslot = *outslot;
 
 		/*
-		 * If the called has passed an invalid slot then create a new slot.
+		 * If the caller has passed an invalid slot then create a new slot.
 		 * Otherwise, just clear the existing tuple from the slot.  This slot
 		 * should be stored by the caller so that it can be reused for
 		 * decompressing the subsequent tuples.
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 18e8ecfd90..d8483c36b3 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1183,8 +1183,8 @@ typedef struct ModifyTableState
 	TupleTableSlot *mt_root_tuple_slot;
 
 	/*
-	 * Slot for storing the modified tuple, incase the target attribute's
-	 * compression method doesn't match with the source table.
+	 * Slot for storing the modified tuple, in case the target attribute's
+	 * compression method doesn't match that of the source table.
 	 */
 	TupleTableSlot *mt_decompress_tuple_slot;
 
-- 
2.17.0


--m51xatjYGsM+13rf
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v24-0006-alter-table-set-compression.patch"



^ permalink  raw  reply  [nested|flat] 46+ messages in thread

* Re: [PATCH} Move instrumentation structs
@ 2026-01-12 20:24  David Rowley <[email protected]>
  0 siblings, 0 replies; 46+ messages in thread

From: David Rowley @ 2026-01-12 20:24 UTC (permalink / raw)
  To: Álvaro Herrera <[email protected]>; +Cc: Mario González Troncoso <[email protected]>; Chao Li <[email protected]>; pgsql-hackers

On Tue, 6 Jan 2026 at 03:39, Álvaro Herrera <[email protected]> wrote:
> I also happened to notice an old typo "its" which should be "it's" in
> tuplesort.c while reading your patch.

There's a bit of conflicting opinion going on here with the changes
made in 128897b101e0.

"false when it's value for in-memory space"

I think the differing opinions depend on what you fill in the missing
words with in the badly written English. If you read "value" as "the
value", then "it's" is correct. Whereas if you read it as "value is",
then "its" is correct. I assume you didn't read it the same way as
John did.

Maybe worth fixing this up to prevent this from being continually
changed and changed back.

How about:

-       bool            isMaxSpaceDisk; /* true when maxSpace is value
for on-disk
-                                                                *
space, false when it's value for in-memory
-                                                                * space */
+       bool            isMaxSpaceDisk; /* true when the maxSpace
value tracking is
+                                                                *
on-disk space, false means it's tracking
+                                                                *
memory space */

David






^ permalink  raw  reply  [nested|flat] 46+ messages in thread


end of thread, other threads:[~2026-01-12 20:24 UTC | newest]

Thread overview: 46+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-02-10 21:56 [PATCH v24 05/10] fixups.patch Robert Haas <[email protected]>
2021-02-10 21:56 [PATCH v24 5/7] fixups.patch Robert Haas <[email protected]>
2021-02-10 21:56 [PATCH v24 5/7] fixups.patch Robert Haas <[email protected]>
2021-02-10 21:56 [PATCH v24 5/7] fixups.patch Robert Haas <[email protected]>
2021-02-10 21:56 [PATCH v24 05/10] fixups.patch Robert Haas <[email protected]>
2021-02-10 21:56 [PATCH v24 05/10] fixups.patch Robert Haas <[email protected]>
2021-02-10 21:56 [PATCH v24 05/10] fixups.patch Robert Haas <[email protected]>
2021-02-10 21:56 [PATCH v24 05/10] fixups.patch Robert Haas <[email protected]>
2021-02-10 21:56 [PATCH v24 05/10] fixups.patch Robert Haas <[email protected]>
2021-02-10 21:56 [PATCH v24 5/7] fixups.patch Robert Haas <[email protected]>
2021-02-10 21:56 [PATCH v24 05/10] fixups.patch Robert Haas <[email protected]>
2021-02-10 21:56 [PATCH v24 5/7] fixups.patch Robert Haas <[email protected]>
2021-02-10 21:56 [PATCH v24 05/10] fixups.patch Robert Haas <[email protected]>
2021-02-10 21:56 [PATCH 06/12] fixups.patch Robert Haas <[email protected]>
2021-02-10 21:56 [PATCH v24 05/10] fixups.patch Robert Haas <[email protected]>
2021-02-10 21:56 [PATCH v24 5/7] fixups.patch Robert Haas <[email protected]>
2021-02-10 21:56 [PATCH v24 5/7] fixups.patch Robert Haas <[email protected]>
2021-02-10 21:56 [PATCH v24 05/10] fixups.patch Robert Haas <[email protected]>
2021-02-10 21:56 [PATCH v24 5/7] fixups.patch Robert Haas <[email protected]>
2021-02-10 21:56 [PATCH v24 5/7] fixups.patch Robert Haas <[email protected]>
2021-02-10 21:56 [PATCH v24 5/7] fixups.patch Robert Haas <[email protected]>
2021-02-10 21:56 [PATCH v24 05/10] fixups.patch Robert Haas <[email protected]>
2021-02-10 21:56 [PATCH v24 5/7] fixups.patch Robert Haas <[email protected]>
2021-02-10 21:56 [PATCH v24 5/7] fixups.patch Robert Haas <[email protected]>
2021-02-10 21:56 [PATCH v24 05/10] fixups.patch Robert Haas <[email protected]>
2021-02-10 21:56 [PATCH v24 5/7] fixups.patch Robert Haas <[email protected]>
2021-02-10 21:56 [PATCH v24 5/7] fixups.patch Robert Haas <[email protected]>
2021-02-10 21:56 [PATCH v24 5/7] fixups.patch Robert Haas <[email protected]>
2021-02-10 21:56 [PATCH v24 05/10] fixups.patch Robert Haas <[email protected]>
2021-02-10 21:56 [PATCH v24 5/7] fixups.patch Robert Haas <[email protected]>
2021-02-10 21:56 [PATCH v24 05/10] fixups.patch Robert Haas <[email protected]>
2021-02-10 21:56 [PATCH v24 5/7] fixups.patch Robert Haas <[email protected]>
2021-02-10 21:56 [PATCH v24 05/10] fixups.patch Robert Haas <[email protected]>
2021-02-10 21:56 [PATCH v24 05/10] fixups.patch Robert Haas <[email protected]>
2021-02-10 21:56 [PATCH v24 5/7] fixups.patch Robert Haas <[email protected]>
2021-02-10 21:56 [PATCH v24 05/10] fixups.patch Robert Haas <[email protected]>
2021-02-10 21:56 [PATCH v24 5/7] fixups.patch Robert Haas <[email protected]>
2021-02-10 21:56 [PATCH v24 05/10] fixups.patch Robert Haas <[email protected]>
2021-02-10 21:56 [PATCH v24 05/10] fixups.patch Robert Haas <[email protected]>
2021-02-10 21:56 [PATCH v24 5/7] fixups.patch Robert Haas <[email protected]>
2021-02-10 21:56 [PATCH v24 05/10] fixups.patch Robert Haas <[email protected]>
2021-02-10 21:56 [PATCH v24 5/7] fixups.patch Robert Haas <[email protected]>
2021-02-10 21:56 [PATCH v24 05/10] fixups.patch Robert Haas <[email protected]>
2021-02-10 21:56 [PATCH v24 05/10] fixups.patch Robert Haas <[email protected]>
2021-02-10 21:56 [PATCH v24 5/7] fixups.patch Robert Haas <[email protected]>
2026-01-12 20:24 Re: [PATCH} Move instrumentation structs David Rowley <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox