Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
doc: 1-byte varlena headers can be used for user PLAIN storage
authorBruce Momjian <bruce@momjian.us>
Tue, 31 Oct 2023 13:10:35 +0000 (09:10 -0400)
committerBruce Momjian <bruce@momjian.us>
Tue, 31 Oct 2023 13:10:35 +0000 (09:10 -0400)
This also updates some C comments.

Reported-by: suchithjn22@gmail.com
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 148fb1b49d966003a9c3971bd6bb34974bf1235c..3ea4e5526df5a054360345dc08ba4ee0072aaaab 100644 (file)
@@ -456,9 +456,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 ef246c901e7171f7cfac80479cdb0e7a7befb8ad..6bedbdf07ffa3500fa3e5835060b230cc653c078 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 != TYPSTORAGE_PLAIN)
 /* Use this if it's already known varlena */
index d65e5625c739a8f6f30be6f4af4d1dfde65de086..24bad52923975084c1134acfe5b7130417cb329d 100644 (file)
@@ -2608,7 +2608,8 @@ range_contains_elem_internal(TypeCacheEntry *typcache, const RangeType *r, Datum
  * 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? */