1/*-------------------------------------------------------------------------
4 * Helper functions for table AMs implementing compressed or
5 * out-of-line storage of varlena attributes.
7 * Copyright (c) 2000-2025, PostgreSQL Global Development Group
9 * src/include/access/toast_helper.h
11 *-------------------------------------------------------------------------
20 * Information about one column of a tuple being toasted.
22 * NOTE: toast_action[i] can have these values:
23 * ' ' default handling
24 * TYPSTORAGE_PLAIN already processed --- don't touch it
25 * TYPSTORAGE_EXTENDED incompressible, but OK to move off
27 * NOTE: toast_attr[i].tai_size is only made valid for varlena attributes with
28 * toast_action[i] different from TYPSTORAGE_PLAIN.
39 * Information about one tuple being toasted.
44 * Before calling toast_tuple_init, the caller must initialize the
45 * following fields. Each array must have a length equal to
46 * ttc_rel->rd_att->natts. The ttc_oldvalues and ttc_oldisnull fields
47 * should be NULL in the case of an insert.
56 * Before calling toast_tuple_init, the caller should set ttc_attr to
57 * point to an array of ToastAttrInfo structures of a length equal to
58 * ttc_rel->rd_att->natts. The contents of the array need not be
59 * initialized. ttc_flags also does not need to be initialized.
66 * Flags indicating the overall state of a TOAST operation.
68 * TOAST_NEEDS_DELETE_OLD indicates that one or more old TOAST datums need
71 * TOAST_NEEDS_FREE indicates that one or more TOAST values need to be freed.
73 * TOAST_HAS_NULLS indicates that nulls were found in the tuple being toasted.
75 * TOAST_NEEDS_CHANGE indicates that a new tuple needs to built; in other
76 * words, the toaster did something.
78 #define TOAST_NEEDS_DELETE_OLD 0x0001
79 #define TOAST_NEEDS_FREE 0x0002
80 #define TOAST_HAS_NULLS 0x0004
81 #define TOAST_NEEDS_CHANGE 0x0008
84 * Flags indicating the status of a TOAST operation with respect to a
87 * TOASTCOL_NEEDS_DELETE_OLD indicates that the old TOAST datums for this
88 * column need to be deleted.
90 * TOASTCOL_NEEDS_FREE indicates that the value for this column needs to
93 * TOASTCOL_IGNORE indicates that the toaster should not further process
96 * TOASTCOL_INCOMPRESSIBLE indicates that this column has been found to
97 * be incompressible, but could be moved out-of-line.
99 #define TOASTCOL_NEEDS_DELETE_OLD TOAST_NEEDS_DELETE_OLD
100 #define TOASTCOL_NEEDS_FREE TOAST_NEEDS_FREE
101 #define TOASTCOL_IGNORE 0x0010
102 #define TOASTCOL_INCOMPRESSIBLE 0x0020
106 bool for_compression,
114 bool is_speculative);
static Datum values[MAXATTR]
struct varlena * tai_oldexternal
void toast_tuple_init(ToastTupleContext *ttc)
void toast_delete_external(Relation rel, const Datum *values, const bool *isnull, bool is_speculative)
void toast_tuple_try_compression(ToastTupleContext *ttc, int attribute)
void toast_tuple_externalize(ToastTupleContext *ttc, int attribute, int options)
void toast_tuple_cleanup(ToastTupleContext *ttc)
int toast_tuple_find_biggest_attribute(ToastTupleContext *ttc, bool for_compression, bool check_main)