Consistently use "superuser" instead of "super user"
[pgsql.git] / src / include / access / detoast.h
blob773a02f89ba102cfc42e25b0e30e4ddf75f20dcd
1 /*-------------------------------------------------------------------------
3 * detoast.h
4 * Access to compressed and external varlena values.
6 * Copyright (c) 2000-2021, PostgreSQL Global Development Group
8 * src/include/access/detoast.h
10 *-------------------------------------------------------------------------
12 #ifndef DETOAST_H
13 #define DETOAST_H
16 * Macro to fetch the possibly-unaligned contents of an EXTERNAL datum
17 * into a local "struct varatt_external" toast pointer. This should be
18 * just a memcpy, but some versions of gcc seem to produce broken code
19 * that assumes the datum contents are aligned. Introducing an explicit
20 * intermediate "varattrib_1b_e *" variable seems to fix it.
22 #define VARATT_EXTERNAL_GET_POINTER(toast_pointer, attr) \
23 do { \
24 varattrib_1b_e *attre = (varattrib_1b_e *) (attr); \
25 Assert(VARATT_IS_EXTERNAL(attre)); \
26 Assert(VARSIZE_EXTERNAL(attre) == sizeof(toast_pointer) + VARHDRSZ_EXTERNAL); \
27 memcpy(&(toast_pointer), VARDATA_EXTERNAL(attre), sizeof(toast_pointer)); \
28 } while (0)
30 /* Size of an EXTERNAL datum that contains a standard TOAST pointer */
31 #define TOAST_POINTER_SIZE (VARHDRSZ_EXTERNAL + sizeof(varatt_external))
33 /* Size of an EXTERNAL datum that contains an indirection pointer */
34 #define INDIRECT_POINTER_SIZE (VARHDRSZ_EXTERNAL + sizeof(varatt_indirect))
36 /* ----------
37 * detoast_external_attr() -
39 * Fetches an external stored attribute from the toast
40 * relation. Does NOT decompress it, if stored external
41 * in compressed format.
42 * ----------
44 extern struct varlena *detoast_external_attr(struct varlena *attr);
46 /* ----------
47 * detoast_attr() -
49 * Fully detoasts one attribute, fetching and/or decompressing
50 * it as needed.
51 * ----------
53 extern struct varlena *detoast_attr(struct varlena *attr);
55 /* ----------
56 * detoast_attr_slice() -
58 * Fetches only the specified portion of an attribute.
59 * (Handles all cases for attribute storage)
60 * ----------
62 extern struct varlena *detoast_attr_slice(struct varlena *attr,
63 int32 sliceoffset,
64 int32 slicelength);
66 /* ----------
67 * toast_raw_datum_size -
69 * Return the raw (detoasted) size of a varlena datum
70 * ----------
72 extern Size toast_raw_datum_size(Datum value);
74 /* ----------
75 * toast_datum_size -
77 * Return the storage size of a varlena datum
78 * ----------
80 extern Size toast_datum_size(Datum value);
82 #endif /* DETOAST_H */