($INBOX_DIR/description missing)  
help / color / mirror / Atom feed
[PATCH 06/12] fixups.patch
47+ messages / 3 participants
[nested] [flat]

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

* Named Operators
@ 2023-01-12 09:16 Gurjeet Singh <[email protected]>
  2023-01-12 09:48 ` Re: Named Operators Matthias van de Meent <[email protected]>
  0 siblings, 1 reply; 47+ messages in thread

From: Gurjeet Singh @ 2023-01-12 09:16 UTC (permalink / raw)
  To: pgsql-hackers

Technically correct name of this feature would be Readable Names for
Operators, or Pronounceable Names for Operators. But I'd like to call
it Named Operators.

With this patch in place, the users can name the operators as
:some_pronounceable_name: instead of having to choose from the special
characters like #^&@. For example, users will be able to create and
use operators like:

    select
        expr1 :distance:     expr2,
        expr3 :contains_all: expr4,
        expr5 :contains_any: expr6
        expr7 :contains_exactly_two_of: expr8
    from mytable;

instead of being forced to use these:

    select
        expr1 <#> expr2,
        expr3 ?&  expr4,
        expr5 ?|  expr6
        expr7 ??!! expr8 -- ¯\_(ツ)_/¯
    from mytable;

    I think Named Operators will significantly improve the readability
of queries.

    After a little trial-an-error, it was easy to develop the scan.l
rules to implement this feature, without flex barfing. The hard part
has been convincing myself that this is a safe implementation, even
though there are no regressions in `make check`. I am unsure of this
implementation's compatibility with the SQL Spec, and I'm not able to
envision problems with its interaction with some current or potential
feature of Postgres. So I'd really appreciate feedback from someone
who is conversant with the SQL Spec.

    If the colon character being used as a delimiter poses a
challenge, other good candidates for the delimiter seem to be one of
~^` Although I haven't tested any of these to see if they cause a
regression. The colon character is be preferable for the delimiter,
since it is already used in the typecast :: operator.

    I tried to strip the delimiters/colons from the name right in the
scanner, primarily because that would allow the identifier part of the
name to be as long as NAMEDATALEN-1, just like other identifiers
Postgres allows. Added benefit of stripping delimiters was that the
rest of the code, and catalogs/storage won't have to see the
delimiters.  But stripping the delimiters made the code brittle; some
places in code now had to be taught different handling depending on
whether the operator name was coming from the user command, or from
the catalogs. I had to special-case code in pg_dump, as well. To share
code with frontends like pg_dump, I had to place code in src/common/.
I was still not able to address some obvious bugs.

    By retaining the delimiters : in the name, the code became much
simpler; pg_dump support came for free! The bugs became a non-issue.
To see how much code and complexity was reduced, one can see this
commit [1]. The downside of retaining the delimiters is that the
identifier part of the name can be no more than NAMEDATALEN-3 in
length.

    Because of the minimal changes to the scanner rules, and no
changes in the grammar, I don't think there's any impact on precedence
and associativity rules of the operators. I'd be happy to learn
otherwise.

    Here's a rudimentary test case to demonstrate the feature:

create operator :add_point: (function = box_add, leftarg = box,
rightarg = point);
create table test(a box);
insert into test values('((0,0),(1,1))'), ('((0,0),(2,1))');
select a as original, a :add_point: '(1,1)' as modified from test;
drop operator :add_point:(box, point);

    Feedback will be much appreciated!

[1]: Commit: Don't strip the delimiters
https://github.com/gurjeet/postgres/commit/62d11a578e5325c32109bb2a55a624d0d89d4b7e

[2]: Git branch named_operators
https://github.com/gurjeet/postgres/tree/named_operators

Best regards,
Gurjeet
http://Gurje.et


Attachments:

  [application/octet-stream] named_operators.patch (5.0K, ../../CABwTF4VVuacLV+coERacdDxUXg5tDMHZxvgH5+ek0UZvoq386g@mail.gmail.com/2-named_operators.patch)
  download | inline diff:
diff --git a/src/backend/catalog/pg_operator.c b/src/backend/catalog/pg_operator.c
index 1017f2eed1..c5b8562cb5 100644
--- a/src/backend/catalog/pg_operator.c
+++ b/src/backend/catalog/pg_operator.c
@@ -31,6 +31,7 @@
 #include "catalog/pg_type.h"
 #include "miscadmin.h"
 #include "parser/parse_oper.h"
+#include "parser/scansup.h"
 #include "utils/acl.h"
 #include "utils/builtins.h"
 #include "utils/lsyscache.h"
@@ -79,6 +80,10 @@ validOperatorName(const char *name)
 	if (len == 0 || len >= NAMEDATALEN)
 		return false;
 
+	/* Is this a Named Operator? */
+	if (validNamedOperator(name))
+		return true;
+
 	/* Can't contain any invalid characters */
 	/* Test string here should match op_chars in scan.l */
 	if (strspn(name, "~!@#^&|`?+-*/%<>=") != len)
diff --git a/src/backend/parser/scan.l b/src/backend/parser/scan.l
index db8b0fe8eb..cef1da0305 100644
--- a/src/backend/parser/scan.l
+++ b/src/backend/parser/scan.l
@@ -379,6 +379,15 @@ self			[,()\[\].;\:\+\-\*\/\%\^\<\>\=]
 op_chars		[\~\!\@\#\^\&\|\`\?\+\-\*\/\%\<\>\=]
 operator		{op_chars}+
 
+/*
+ * Named Operators, e.g. :foo:
+ *
+ * {namedopfailed} is an error rule to avoid scanner backup when {namedop}
+ * fails to match its trailing ":".
+ */
+namedop			\:{identifier}\:
+namedopfailed	\:{identifier}
+
 /*
  * Numbers
  *
@@ -768,6 +777,23 @@ other			.
 				}
 <xdolq><<EOF>>	{ yyerror("unterminated dollar-quoted string"); }
 
+{namedop}		{
+					SET_YYLLOC();
+					if (yyleng >= NAMEDATALEN)
+						yyerror("operator name too long");
+					/* XXX Should we support double-quoted, case sensitive names? */
+					yylval->str = downcase_identifier(yytext, yyleng, false, false);
+					return Op;
+				}
+
+{namedopfailed}	{
+					SET_YYLLOC();
+					/* throw back all but the initial ':' */
+					yyless(1);
+					/* and treat it as {self}, since ':' is a member of that set of chars. */
+					return yytext[0];
+				}
+
 {xdstart}		{
 					SET_YYLLOC();
 					BEGIN(xd);
diff --git a/src/backend/parser/scansup.c b/src/backend/parser/scansup.c
index 602108a40f..678d9d0e5c 100644
--- a/src/backend/parser/scansup.c
+++ b/src/backend/parser/scansup.c
@@ -125,3 +125,71 @@ scanner_isspace(char ch)
 		return true;
 	return false;
 }
+
+bool
+validNamedOperator(const char *name)
+{
+	size_t	len = strlen(name);
+	bool	valid_identifier;
+	char   *tmp;
+
+	if (len < 3 || len >= NAMEDATALEN)
+	   return false;
+
+	if (name[0] != ':' || name[len-1] != ':')
+		return false;
+
+	tmp = pstrdup(name);
+
+	// Disregard the delimiters
+	tmp[len-1] = '\0';
+	tmp += 1;
+	valid_identifier = validIdentifier(tmp);
+	tmp -= 1;
+	pfree(tmp);
+
+	return valid_identifier;
+}
+
+/*
+ * Function to resemble the same check as the following lex
+ * rules in scan.l:
+ *
+ * ident_start		[A-Za-z\200-\377_]
+ * ident_cont		[A-Za-z\200-\377_0-9\$]
+ *
+ * Note: this function does not check if the identifier length
+ * is less than NAMEDATALEN.
+ */
+bool
+validIdentifier(const char *name)
+{
+	uint8	c;
+	size_t	i, len = strlen(name);
+
+	// Reject if first character is not part of ident_start
+	c = name[0];
+	if ( !(c == '_'
+		|| (c >='A' && c <= 'Z')
+		|| (c >='a' && c <= 'z')
+		|| (c >= 0200 && c <= 0377)))
+	{
+		return false;
+	}
+
+	// Reject if other characters are not part of ident_cont
+	for (i = 1; i < len; ++i)
+	{
+		c = name[i];
+		if ( !(c == '_' || c == '$'
+			|| (c >='A' && c <= 'Z')
+			|| (c >='a' && c <= 'z')
+			|| (c >='0' && c <= '9')
+			|| (c >= 0200 && c <= 0377)))
+		{
+			return false;
+		}
+	}
+
+	return true;
+}
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index da427f4d4a..0aafb3297e 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -62,6 +62,7 @@
 #include "getopt_long.h"
 #include "libpq/libpq-fs.h"
 #include "parallel.h"
+#include "common/scansup.h"
 #include "pg_backup_db.h"
 #include "pg_backup_utils.h"
 #include "pg_dump.h"
diff --git a/src/fe_utils/psqlscan.l b/src/fe_utils/psqlscan.l
index ae531ec240..39bacc6738 100644
--- a/src/fe_utils/psqlscan.l
+++ b/src/fe_utils/psqlscan.l
@@ -317,6 +317,15 @@ self			[,()\[\].;\:\+\-\*\/\%\^\<\>\=]
 op_chars		[\~\!\@\#\^\&\|\`\?\+\-\*\/\%\<\>\=]
 operator		{op_chars}+
 
+/*
+ * Named Operators, e.g. :foo:
+ *
+ * {namedopfailed} is an error rule to avoid scanner backup when {namedop}
+ * fails to match its trailing ":".
+ */
+namedop			\:{identifier}\:
+namedopfailed	\:{identifier}
+
 /*
  * Numbers
  *
@@ -570,6 +579,16 @@ other			.
 					ECHO;
 				}
 
+{namedop}		{
+					ECHO;
+				}
+
+{namedopfailed}	{
+					/* throw back all but the initial ':' */
+					yyless(1);
+					ECHO;
+				}
+
 {xdstart}		{
 					BEGIN(xd);
 					ECHO;
diff --git a/src/include/parser/scansup.h b/src/include/parser/scansup.h
index ff65224bf6..0f6aff8b44 100644
--- a/src/include/parser/scansup.h
+++ b/src/include/parser/scansup.h
@@ -24,4 +24,7 @@ extern void truncate_identifier(char *ident, int len, bool warn);
 
 extern bool scanner_isspace(char ch);
 
+extern bool validNamedOperator(const char *name);
+extern bool validIdentifier(const char *name);
+
 #endif							/* SCANSUP_H */


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

* Re: Named Operators
  2023-01-12 09:16 Named Operators Gurjeet Singh <[email protected]>
@ 2023-01-12 09:48 ` Matthias van de Meent <[email protected]>
  0 siblings, 0 replies; 47+ messages in thread

From: Matthias van de Meent @ 2023-01-12 09:48 UTC (permalink / raw)
  To: Gurjeet Singh <[email protected]>; +Cc: pgsql-hackers

On Thu, 12 Jan 2023 at 10:16, Gurjeet Singh <[email protected]> wrote:
>
> Technically correct name of this feature would be Readable Names for
> Operators, or Pronounceable Names for Operators. But I'd like to call
> it Named Operators.
>
> With this patch in place, the users can name the operators as
> :some_pronounceable_name: instead of having to choose from the special
> characters like #^&@.
> [...]
>     I think Named Operators will significantly improve the readability
> of queries.

Couldn't the user better opt to call the functions that implement the
operator directly if they want more legible operations? So, from your
example, `SELECT box_add(a, b)` instead of `SELECT a :add_point: b`?

I'm -1 on the chosen syntax; :name: shadows common variable
substitution patterns including those of psql.

Kind regards,

Matthias van de Meent






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


end of thread, other threads:[~2023-01-12 09:48 UTC | newest]

Thread overview: 47+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
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 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 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 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 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 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 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 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 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]>
2023-01-12 09:16 Named Operators Gurjeet Singh <[email protected]>
2023-01-12 09:48 ` Re: Named Operators Matthias van de Meent <[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