aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2023-10-31 09:10:35 -0400
committerBruce Momjian <bruce@momjian.us>2023-10-31 09:10:35 -0400
commit350bd6bdc19dc53467ec2013c86fd4466c0f43af (patch)
tree9baeea7687fa489e6c102670f27aebbd5d11ce08 /src
parenta98f01c933ec566c43d92b87a1e90467fed6217e (diff)
downloadpostgresql-350bd6bdc19dc53467ec2013c86fd4466c0f43af.tar.gz
postgresql-350bd6bdc19dc53467ec2013c86fd4466c0f43af.zip
doc: 1-byte varlena headers can be used for user PLAIN storage
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
Diffstat (limited to 'src')
-rw-r--r--src/backend/access/common/heaptuple.c11
-rw-r--r--src/backend/utils/adt/rangetypes.c3
2 files changed, 12 insertions, 2 deletions
diff --git a/src/backend/access/common/heaptuple.c b/src/backend/access/common/heaptuple.c
index ef246c901e7..6bedbdf07ff 100644
--- a/src/backend/access/common/heaptuple.c
+++ b/src/backend/access/common/heaptuple.c
@@ -68,7 +68,16 @@
#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 */
diff --git a/src/backend/utils/adt/rangetypes.c b/src/backend/utils/adt/rangetypes.c
index d65e5625c73..24bad529239 100644
--- a/src/backend/utils/adt/rangetypes.c
+++ b/src/backend/utils/adt/rangetypes.c
@@ -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? */