doc: 1-byte varlena headers can be used for user PLAIN storage
authorBruce Momjian <[email protected]>
Tue, 31 Oct 2023 13:10:34 +0000 (09:10 -0400)
committerBruce Momjian <[email protected]>
Tue, 31 Oct 2023 13:10:34 +0000 (09:10 -0400)
This also updates some C comments.

Reported-by: [email protected]
Discussion: https://postgr.es/m/167336599095.2667301.15497893107226841625@wrigleys.postgresql.org

Author: Laurenz Albe (doc patch)

Backpatch-through: 11

doc/src/sgml/storage.sgml
src/backend/access/common/heaptuple.c
src/backend/utils/adt/rangetypes.c

index 39d90ce753d38539fe1d6a77e62658da1c0bb8d2..c8f9fc3d03f57782fb7e0870a06a0f12b2df80b3 100644 (file)
@@ -444,9 +444,7 @@ for storing <acronym>TOAST</acronym>-able columns on disk:
     <listitem>
      <para>
       <literal>PLAIN</literal> prevents either compression or
-      out-of-line storage; furthermore it disables use of single-byte headers
-      for varlena types.
-      This is the only possible strategy for
+      out-of-line storage.  This is the only possible strategy for
       columns of non-<acronym>TOAST</acronym>-able data types.
      </para>
     </listitem>
index 340fe81a1eb5683f0e75b09bcffc5479f74de37d..30459c19a7b8d144d53a85fc45c8518ae72d02c1 100644 (file)
 #include "utils/memutils.h"
 
 
-/* Does att's datatype allow packing into the 1-byte-header varlena format? */
+/*
+ * Does att's datatype allow packing into the 1-byte-header varlena format?
+ * While functions that use TupleDescAttr() and assign attstorage =
+ * TYPSTORAGE_PLAIN cannot use packed varlena headers, functions that call
+ * TupleDescInitEntry() use typeForm->typstorage (TYPSTORAGE_EXTENDED) and
+ * can use packed varlena headers, e.g.:
+ *     CREATE TABLE test(a VARCHAR(10000) STORAGE PLAIN);
+ *     INSERT INTO test VALUES (repeat('A',10));
+ * This can be verified with pageinspect.
+ */
 #define ATT_IS_PACKABLE(att) \
    ((att)->attlen == -1 && (att)->attstorage != 'p')
 /* Use this if it's already known varlena */
index 558e7becc4ee1917032c2e768a73e341b1dc03e1..71d2ef0a0a7263ad6de2d5511c96dc7c24294aca 100644 (file)
@@ -2383,7 +2383,8 @@ range_contains_elem_internal(TypeCacheEntry *typcache, RangeType *r, Datum val)
  * values into a range object.  They are modeled after heaptuple.c's
  * heap_compute_data_size() and heap_fill_tuple(), but we need not handle
  * null values here.  TYPE_IS_PACKABLE must test the same conditions as
- * heaptuple.c's ATT_IS_PACKABLE macro.
+ * heaptuple.c's ATT_IS_PACKABLE macro.  See the comments thare for more
+ * details.
  */
 
 /* Does datatype allow packing into the 1-byte-header varlena format? */