Hi all, "struct" markers are not the style of the project for variable declarations, and we have been historically applying these for various declarations in the code for varlena, varatt_external and varatt_indirect, so I would like to propose the attached patch to clean up all this code.
This has been extracted from a larger patch I have sent a couple of months ago, worth a cleanup of its own now that I am looking at it again. For reference, this has also been proposed by Tom here (see around 0003, but the varlena bits are my own): https://www.postgresql.org/message-id/[email protected] This cleanup leads to the attached, with the CI not complaining. That will also help me a bit for the other patch sets I have been playing with related to TOAST. Thoughts or comments? -- Michael
From d6cba5121457b25c66de73e344abdab8090b7e0e Mon Sep 17 00:00:00 2001 From: Michael Paquier <[email protected]> Date: Tue, 20 Jan 2026 16:40:39 +0900 Subject: [PATCH] Remove varlena structs --- src/include/access/detoast.h | 12 +-- src/include/access/heaptoast.h | 2 +- src/include/access/tableam.h | 4 +- src/include/access/toast_compression.h | 18 ++-- src/include/access/toast_helper.h | 2 +- src/include/access/toast_internals.h | 2 +- src/include/c.h | 14 +-- src/include/fmgr.h | 20 ++-- src/include/utils/varbit.h | 2 +- src/include/utils/xml.h | 2 +- src/include/varatt.h | 24 ++--- src/backend/access/brin/brin_tuple.c | 2 +- src/backend/access/common/detoast.c | 102 +++++++++--------- src/backend/access/common/indextuple.c | 2 +- src/backend/access/common/toast_compression.c | 54 +++++----- src/backend/access/common/toast_internals.c | 22 ++-- src/backend/access/hash/hashfunc.c | 4 +- src/backend/access/heap/heapam.c | 2 +- src/backend/access/heap/heaptoast.c | 14 +-- src/backend/access/table/toast_helper.c | 10 +- src/backend/executor/tstoreReceiver.c | 2 +- .../replication/logical/reorderbuffer.c | 22 ++-- src/backend/storage/large_object/inv_api.c | 2 +- src/backend/utils/adt/datum.c | 12 +-- src/backend/utils/adt/expandedrecord.c | 4 +- src/backend/utils/adt/rowtypes.c | 4 +- src/backend/utils/adt/varlena.c | 10 +- src/backend/utils/fmgr/fmgr.c | 18 ++-- src/test/regress/regress.c | 12 +-- doc/src/sgml/storage.sgml | 2 +- contrib/amcheck/verify_heapam.c | 8 +- contrib/btree_gist/btree_utils_var.c | 4 +- contrib/pageinspect/heapfuncs.c | 2 +- src/pl/plpgsql/src/pl_exec.c | 2 +- src/tools/pgindent/typedefs.list | 3 + 35 files changed, 212 insertions(+), 209 deletions(-) diff --git a/src/include/access/detoast.h b/src/include/access/detoast.h index 6db3a29191ee..fbd98181a3a1 100644 --- a/src/include/access/detoast.h +++ b/src/include/access/detoast.h @@ -14,7 +14,7 @@ /* * Macro to fetch the possibly-unaligned contents of an EXTERNAL datum - * into a local "struct varatt_external" toast pointer. This should be + * into a local "varatt_external" toast pointer. This should be * just a memcpy, but some versions of gcc seem to produce broken code * that assumes the datum contents are aligned. Introducing an explicit * intermediate "varattrib_1b_e *" variable seems to fix it. @@ -41,7 +41,7 @@ do { \ * in compressed format. * ---------- */ -extern struct varlena *detoast_external_attr(struct varlena *attr); +extern varlena *detoast_external_attr(varlena *attr); /* ---------- * detoast_attr() - @@ -50,7 +50,7 @@ extern struct varlena *detoast_external_attr(struct varlena *attr); * it as needed. * ---------- */ -extern struct varlena *detoast_attr(struct varlena *attr); +extern varlena *detoast_attr(varlena *attr); /* ---------- * detoast_attr_slice() - @@ -59,9 +59,9 @@ extern struct varlena *detoast_attr(struct varlena *attr); * (Handles all cases for attribute storage) * ---------- */ -extern struct varlena *detoast_attr_slice(struct varlena *attr, - int32 sliceoffset, - int32 slicelength); +extern varlena *detoast_attr_slice(varlena *attr, + int32 sliceoffset, + int32 slicelength); /* ---------- * toast_raw_datum_size - diff --git a/src/include/access/heaptoast.h b/src/include/access/heaptoast.h index 21baa0834b75..725c0ce75544 100644 --- a/src/include/access/heaptoast.h +++ b/src/include/access/heaptoast.h @@ -144,6 +144,6 @@ extern HeapTuple toast_build_flattened_tuple(TupleDesc tupleDesc, */ extern void heap_fetch_toast_slice(Relation toastrel, Oid valueid, int32 attrsize, int32 sliceoffset, - int32 slicelength, struct varlena *result); + int32 slicelength, varlena *result); #endif /* HEAPTOAST_H */ diff --git a/src/include/access/tableam.h b/src/include/access/tableam.h index e2ec5289d4da..fc5f3fc6e21e 100644 --- a/src/include/access/tableam.h +++ b/src/include/access/tableam.h @@ -750,7 +750,7 @@ typedef struct TableAmRoutine int32 attrsize, int32 sliceoffset, int32 slicelength, - struct varlena *result); + varlena *result); /* ------------------------------------------------------------------------ @@ -1894,7 +1894,7 @@ table_relation_toast_am(Relation rel) static inline void table_relation_fetch_toast_slice(Relation toastrel, Oid valueid, int32 attrsize, int32 sliceoffset, - int32 slicelength, struct varlena *result) + int32 slicelength, varlena *result) { toastrel->rd_tableam->relation_fetch_toast_slice(toastrel, valueid, attrsize, diff --git a/src/include/access/toast_compression.h b/src/include/access/toast_compression.h index 4b42f7a047f7..5f3ffa9ab2d4 100644 --- a/src/include/access/toast_compression.h +++ b/src/include/access/toast_compression.h @@ -54,19 +54,19 @@ typedef enum ToastCompressionId /* pglz compression/decompression routines */ -extern struct varlena *pglz_compress_datum(const struct varlena *value); -extern struct varlena *pglz_decompress_datum(const struct varlena *value); -extern struct varlena *pglz_decompress_datum_slice(const struct varlena *value, - int32 slicelength); +extern varlena *pglz_compress_datum(const varlena *value); +extern varlena *pglz_decompress_datum(const varlena *value); +extern varlena *pglz_decompress_datum_slice(const varlena *value, + int32 slicelength); /* lz4 compression/decompression routines */ -extern struct varlena *lz4_compress_datum(const struct varlena *value); -extern struct varlena *lz4_decompress_datum(const struct varlena *value); -extern struct varlena *lz4_decompress_datum_slice(const struct varlena *value, - int32 slicelength); +extern varlena *lz4_compress_datum(const varlena *value); +extern varlena *lz4_decompress_datum(const varlena *value); +extern varlena *lz4_decompress_datum_slice(const varlena *value, + int32 slicelength); /* other stuff */ -extern ToastCompressionId toast_get_compression_id(struct varlena *attr); +extern ToastCompressionId toast_get_compression_id(varlena *attr); extern char CompressionNameToMethod(const char *compression); extern const char *GetCompressionMethodName(char method); diff --git a/src/include/access/toast_helper.h b/src/include/access/toast_helper.h index 9bd6bfaffe55..e8ecb995cb32 100644 --- a/src/include/access/toast_helper.h +++ b/src/include/access/toast_helper.h @@ -29,7 +29,7 @@ */ typedef struct { - struct varlena *tai_oldexternal; + varlena *tai_oldexternal; int32 tai_size; uint8 tai_colflags; char tai_compression; diff --git a/src/include/access/toast_internals.h b/src/include/access/toast_internals.h index 75690e0bc823..d382db342620 100644 --- a/src/include/access/toast_internals.h +++ b/src/include/access/toast_internals.h @@ -50,7 +50,7 @@ extern Oid toast_get_valid_index(Oid toastoid, LOCKMODE lock); extern void toast_delete_datum(Relation rel, Datum value, bool is_speculative); extern Datum toast_save_datum(Relation rel, Datum value, - struct varlena *oldexternal, int options); + varlena *oldexternal, int options); extern int toast_open_indexes(Relation toastrel, LOCKMODE lock, diff --git a/src/include/c.h b/src/include/c.h index 7136102e5ff2..37ace0097ded 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -689,7 +689,7 @@ typedef uint64 Oid8; #define OID8_MAX UINT64_MAX /* ---------------- - * Variable-length datatypes all share the 'struct varlena' header. + * Variable-length datatypes all share the 'varlena' header. * * NOTE: for TOASTable types, this is an oversimplification, since the value * may be compressed or moved out-of-line. However datatype-specific routines @@ -702,11 +702,11 @@ typedef uint64 Oid8; * See varatt.h for details of the TOASTed form. * ---------------- */ -struct varlena +typedef struct varlena { char vl_len_[4]; /* Do not touch this field directly! */ char vl_dat[FLEXIBLE_ARRAY_MEMBER]; /* Data content is here */ -}; +} varlena; #define VARHDRSZ ((int32) sizeof(int32)) @@ -715,10 +715,10 @@ struct varlena * There is no terminating null or anything like that --- the data length is * always VARSIZE_ANY_EXHDR(ptr). */ -typedef struct varlena bytea; -typedef struct varlena text; -typedef struct varlena BpChar; /* blank-padded char, ie SQL char(n) */ -typedef struct varlena VarChar; /* var-length char, ie SQL varchar(n) */ +typedef varlena bytea; +typedef varlena text; +typedef varlena BpChar; /* blank-padded char, ie SQL char(n) */ +typedef varlena VarChar; /* var-length char, ie SQL varchar(n) */ /* * Specialized array types. These are physically laid out just the same diff --git a/src/include/fmgr.h b/src/include/fmgr.h index eabbc78b2801..10d02bdb79fa 100644 --- a/src/include/fmgr.h +++ b/src/include/fmgr.h @@ -231,22 +231,22 @@ extern void fmgr_symbol(Oid functionId, char **mod, char **fn); * Note: it'd be nice if these could be macros, but I see no way to do that * without evaluating the arguments multiple times, which is NOT acceptable. */ -extern struct varlena *pg_detoast_datum(struct varlena *datum); -extern struct varlena *pg_detoast_datum_copy(struct varlena *datum); -extern struct varlena *pg_detoast_datum_slice(struct varlena *datum, - int32 first, int32 count); -extern struct varlena *pg_detoast_datum_packed(struct varlena *datum); +extern varlena *pg_detoast_datum(varlena *datum); +extern varlena *pg_detoast_datum_copy(varlena *datum); +extern varlena *pg_detoast_datum_slice(varlena *datum, + int32 first, int32 count); +extern varlena *pg_detoast_datum_packed(varlena *datum); #define PG_DETOAST_DATUM(datum) \ - pg_detoast_datum((struct varlena *) DatumGetPointer(datum)) + pg_detoast_datum((varlena *) DatumGetPointer(datum)) #define PG_DETOAST_DATUM_COPY(datum) \ - pg_detoast_datum_copy((struct varlena *) DatumGetPointer(datum)) + pg_detoast_datum_copy((varlena *) DatumGetPointer(datum)) #define PG_DETOAST_DATUM_SLICE(datum,f,c) \ - pg_detoast_datum_slice((struct varlena *) DatumGetPointer(datum), \ + pg_detoast_datum_slice((varlena *) DatumGetPointer(datum), \ (int32) (f), (int32) (c)) /* WARNING -- unaligned pointer */ #define PG_DETOAST_DATUM_PACKED(datum) \ - pg_detoast_datum_packed((struct varlena *) DatumGetPointer(datum)) + pg_detoast_datum_packed((varlena *) DatumGetPointer(datum)) /* * Support for cleaning up detoasted copies of inputs. This must only @@ -283,7 +283,7 @@ extern struct varlena *pg_detoast_datum_packed(struct varlena *datum); #define PG_GETARG_FLOAT8(n) DatumGetFloat8(PG_GETARG_DATUM(n)) #define PG_GETARG_INT64(n) DatumGetInt64(PG_GETARG_DATUM(n)) /* use this if you want the raw, possibly-toasted input datum: */ -#define PG_GETARG_RAW_VARLENA_P(n) ((struct varlena *) PG_GETARG_POINTER(n)) +#define PG_GETARG_RAW_VARLENA_P(n) ((varlena *) PG_GETARG_POINTER(n)) /* use this if you want the input datum de-toasted: */ #define PG_GETARG_VARLENA_P(n) PG_DETOAST_DATUM(PG_GETARG_DATUM(n)) /* and this if you can handle 1-byte-header datums: */ diff --git a/src/include/utils/varbit.h b/src/include/utils/varbit.h index 82be976f5c50..20cb14d75b0c 100644 --- a/src/include/utils/varbit.h +++ b/src/include/utils/varbit.h @@ -20,7 +20,7 @@ #include "fmgr.h" /* - * Modeled on struct varlena from c.h, but data type is bits8. + * Modeled on varlena from c.h, but data type is bits8. * * Caution: if bit_len is not a multiple of BITS_PER_BYTE, the low-order * bits of the last byte of bit_dat[] are unused and MUST be zeroes. diff --git a/src/include/utils/xml.h b/src/include/utils/xml.h index 03acb255449c..023fdeb45313 100644 --- a/src/include/utils/xml.h +++ b/src/include/utils/xml.h @@ -20,7 +20,7 @@ #include "nodes/execnodes.h" #include "nodes/primnodes.h" -typedef struct varlena xmltype; +typedef varlena xmltype; typedef enum { diff --git a/src/include/varatt.h b/src/include/varatt.h index eccd3ca04d66..a0136206d65e 100644 --- a/src/include/varatt.h +++ b/src/include/varatt.h @@ -16,7 +16,7 @@ #define VARATT_H /* - * struct varatt_external is a traditional "TOAST pointer", that is, the + * varatt_external is a traditional "TOAST pointer", that is, the * information needed to fetch a Datum stored out-of-line in a TOAST table. * The data is compressed if and only if the external size stored in * va_extinfo is less than va_rawsize - VARHDRSZ. @@ -36,7 +36,7 @@ typedef struct varatt_external * compression method */ Oid va_valueid; /* Unique ID of value within TOAST table */ Oid va_toastrelid; /* RelID of TOAST table containing it */ -} varatt_external; +} varatt_external; /* * These macros define the "saved size" portion of va_extinfo. Its remaining @@ -46,27 +46,27 @@ typedef struct varatt_external #define VARLENA_EXTSIZE_MASK ((1U << VARLENA_EXTSIZE_BITS) - 1) /* - * struct varatt_indirect is a "TOAST pointer" representing an out-of-line + * varatt_indirect is a "TOAST pointer" representing an out-of-line * Datum that's stored in memory, not in an external toast relation. * The creator of such a Datum is entirely responsible that the referenced * storage survives for as long as referencing pointer Datums can exist. * - * Note that just as for struct varatt_external, this struct is stored + * Note that just as for varatt_external, this struct is stored * unaligned within any containing tuple. */ typedef struct varatt_indirect { - struct varlena *pointer; /* Pointer to in-memory varlena */ -} varatt_indirect; + varlena *pointer; /* Pointer to in-memory varlena */ +} varatt_indirect; /* - * struct varatt_expanded is a "TOAST pointer" representing an out-of-line + * varatt_expanded is a "TOAST pointer" representing an out-of-line * Datum that is stored in memory, in some type-specific, not necessarily * physically contiguous format that is convenient for computation not * storage. APIs for this, in particular the definition of struct * ExpandedObjectHeader, are in src/include/utils/expandeddatum.h. * - * Note that just as for struct varatt_external, this struct is stored + * Note that just as for varatt_external, this struct is stored * unaligned within any containing tuple. */ typedef struct ExpandedObjectHeader ExpandedObjectHeader; @@ -502,15 +502,15 @@ VARDATA_COMPRESSED_GET_COMPRESS_METHOD(const void *PTR) return ((varattrib_4b *) PTR)->va_compressed.va_tcinfo >> VARLENA_EXTSIZE_BITS; } -/* Same for external Datums; but note argument is a struct varatt_external */ +/* Same for external Datums; but note argument is a varatt_external */ static inline Size -VARATT_EXTERNAL_GET_EXTSIZE(struct varatt_external toast_pointer) +VARATT_EXTERNAL_GET_EXTSIZE(varatt_external toast_pointer) { return toast_pointer.va_extinfo & VARLENA_EXTSIZE_MASK; } static inline uint32 -VARATT_EXTERNAL_GET_COMPRESS_METHOD(struct varatt_external toast_pointer) +VARATT_EXTERNAL_GET_COMPRESS_METHOD(varatt_external toast_pointer) { return toast_pointer.va_extinfo >> VARLENA_EXTSIZE_BITS; } @@ -533,7 +533,7 @@ VARATT_EXTERNAL_GET_COMPRESS_METHOD(struct varatt_external toast_pointer) * actually saves space, so we expect either equality or less-than. */ static inline bool -VARATT_EXTERNAL_IS_COMPRESSED(struct varatt_external toast_pointer) +VARATT_EXTERNAL_IS_COMPRESSED(varatt_external toast_pointer) { return VARATT_EXTERNAL_GET_EXTSIZE(toast_pointer) < (Size) (toast_pointer.va_rawsize - VARHDRSZ); diff --git a/src/backend/access/brin/brin_tuple.c b/src/backend/access/brin/brin_tuple.c index 706387e36d64..69c233c62eb4 100644 --- a/src/backend/access/brin/brin_tuple.c +++ b/src/backend/access/brin/brin_tuple.c @@ -206,7 +206,7 @@ brin_form_tuple(BrinDesc *brdesc, BlockNumber blkno, BrinMemTuple *tuple, */ if (VARATT_IS_EXTERNAL(DatumGetPointer(value))) { - value = PointerGetDatum(detoast_external_attr((struct varlena *) + value = PointerGetDatum(detoast_external_attr((varlena *) DatumGetPointer(value))); free_value = true; } diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c index 7bef01bb5f35..a6c1f3a734b2 100644 --- a/src/backend/access/common/detoast.c +++ b/src/backend/access/common/detoast.c @@ -22,12 +22,12 @@ #include "utils/expandeddatum.h" #include "utils/rel.h" -static struct varlena *toast_fetch_datum(struct varlena *attr); -static struct varlena *toast_fetch_datum_slice(struct varlena *attr, - int32 sliceoffset, - int32 slicelength); -static struct varlena *toast_decompress_datum(struct varlena *attr); -static struct varlena *toast_decompress_datum_slice(struct varlena *attr, int32 slicelength); +static varlena *toast_fetch_datum(varlena *attr); +static varlena *toast_fetch_datum_slice(varlena *attr, + int32 sliceoffset, + int32 slicelength); +static varlena *toast_decompress_datum(varlena *attr); +static varlena *toast_decompress_datum_slice(varlena *attr, int32 slicelength); /* ---------- * detoast_external_attr - @@ -41,10 +41,10 @@ static struct varlena *toast_decompress_datum_slice(struct varlena *attr, int32 * EXTERNAL datum, the result will be a pfree'able chunk. * ---------- */ -struct varlena * -detoast_external_attr(struct varlena *attr) +varlena * +detoast_external_attr(varlena *attr) { - struct varlena *result; + varlena *result; if (VARATT_IS_EXTERNAL_ONDISK(attr)) { @@ -58,10 +58,10 @@ detoast_external_attr(struct varlena *attr) /* * This is an indirect pointer --- dereference it */ - struct varatt_indirect redirect; + varatt_indirect redirect; VARATT_EXTERNAL_GET_POINTER(redirect, attr); - attr = (struct varlena *) redirect.pointer; + attr = (varlena *) redirect.pointer; /* nested indirect Datums aren't allowed */ Assert(!VARATT_IS_EXTERNAL_INDIRECT(attr)); @@ -74,7 +74,7 @@ detoast_external_attr(struct varlena *attr) * Copy into the caller's memory context, in case caller tries to * pfree the result. */ - result = (struct varlena *) palloc(VARSIZE_ANY(attr)); + result = (varlena *) palloc(VARSIZE_ANY(attr)); memcpy(result, attr, VARSIZE_ANY(attr)); } else if (VARATT_IS_EXTERNAL_EXPANDED(attr)) @@ -87,7 +87,7 @@ detoast_external_attr(struct varlena *attr) eoh = DatumGetEOHP(PointerGetDatum(attr)); resultsize = EOH_get_flat_size(eoh); - result = (struct varlena *) palloc(resultsize); + result = (varlena *) palloc(resultsize); EOH_flatten_into(eoh, result, resultsize); } else @@ -112,8 +112,8 @@ detoast_external_attr(struct varlena *attr) * datum, the result will be a pfree'able chunk. * ---------- */ -struct varlena * -detoast_attr(struct varlena *attr) +varlena * +detoast_attr(varlena *attr) { if (VARATT_IS_EXTERNAL_ONDISK(attr)) { @@ -124,7 +124,7 @@ detoast_attr(struct varlena *attr) /* If it's compressed, decompress it */ if (VARATT_IS_COMPRESSED(attr)) { - struct varlena *tmp = attr; + varlena *tmp = attr; attr = toast_decompress_datum(tmp); pfree(tmp); @@ -135,10 +135,10 @@ detoast_attr(struct varlena *attr) /* * This is an indirect pointer --- dereference it */ - struct varatt_indirect redirect; + varatt_indirect redirect; VARATT_EXTERNAL_GET_POINTER(redirect, attr); - attr = (struct varlena *) redirect.pointer; + attr = (varlena *) redirect.pointer; /* nested indirect Datums aren't allowed */ Assert(!VARATT_IS_EXTERNAL_INDIRECT(attr)); @@ -147,11 +147,11 @@ detoast_attr(struct varlena *attr) attr = detoast_attr(attr); /* if it isn't, we'd better copy it */ - if (attr == (struct varlena *) redirect.pointer) + if (attr == (varlena *) redirect.pointer) { - struct varlena *result; + varlena *result; - result = (struct varlena *) palloc(VARSIZE_ANY(attr)); + result = (varlena *) palloc(VARSIZE_ANY(attr)); memcpy(result, attr, VARSIZE_ANY(attr)); attr = result; } @@ -179,9 +179,9 @@ detoast_attr(struct varlena *attr) */ Size data_size = VARSIZE_SHORT(attr) - VARHDRSZ_SHORT; Size new_size = data_size + VARHDRSZ; - struct varlena *new_attr; + varlena *new_attr; - new_attr = (struct varlena *) palloc(new_size); + new_attr = (varlena *) palloc(new_size); SET_VARSIZE(new_attr, new_size); memcpy(VARDATA(new_attr), VARDATA_SHORT(attr), data_size); attr = new_attr; @@ -201,12 +201,12 @@ detoast_attr(struct varlena *attr) * If slicelength < 0, return everything beyond sliceoffset * ---------- */ -struct varlena * -detoast_attr_slice(struct varlena *attr, +varlena * +detoast_attr_slice(varlena *attr, int32 sliceoffset, int32 slicelength) { - struct varlena *preslice; - struct varlena *result; + varlena *preslice; + varlena *result; char *attrdata; int32 slicelimit; int32 attrsize; @@ -225,7 +225,7 @@ detoast_attr_slice(struct varlena *attr, if (VARATT_IS_EXTERNAL_ONDISK(attr)) { - struct varatt_external toast_pointer; + varatt_external toast_pointer; VARATT_EXTERNAL_GET_POINTER(toast_pointer, attr); @@ -266,7 +266,7 @@ detoast_attr_slice(struct varlena *attr, } else if (VARATT_IS_EXTERNAL_INDIRECT(attr)) { - struct varatt_indirect redirect; + varatt_indirect redirect; VARATT_EXTERNAL_GET_POINTER(redirect, attr); @@ -288,7 +288,7 @@ detoast_attr_slice(struct varlena *attr, if (VARATT_IS_COMPRESSED(preslice)) { - struct varlena *tmp = preslice; + varlena *tmp = preslice; /* Decompress enough to encompass the slice and the offset */ if (slicelimit >= 0) @@ -321,7 +321,7 @@ detoast_attr_slice(struct varlena *attr, else if (slicelength < 0 || slicelimit > attrsize) slicelength = attrsize - sliceoffset; - result = (struct varlena *) palloc(slicelength + VARHDRSZ); + result = (varlena *) palloc(slicelength + VARHDRSZ); SET_VARSIZE(result, slicelength + VARHDRSZ); memcpy(VARDATA(result), attrdata + sliceoffset, slicelength); @@ -339,12 +339,12 @@ detoast_attr_slice(struct varlena *attr, * in the toast relation * ---------- */ -static struct varlena * -toast_fetch_datum(struct varlena *attr) +static varlena * +toast_fetch_datum(varlena *attr) { Relation toastrel; - struct varlena *result; - struct varatt_external toast_pointer; + varlena *result; + varatt_external toast_pointer; int32 attrsize; if (!VARATT_IS_EXTERNAL_ONDISK(attr)) @@ -355,7 +355,7 @@ toast_fetch_datum(struct varlena *attr) attrsize = VARATT_EXTERNAL_GET_EXTSIZE(toast_pointer); - result = (struct varlena *) palloc(attrsize + VARHDRSZ); + result = (varlena *) palloc(attrsize + VARHDRSZ); if (VARATT_EXTERNAL_IS_COMPRESSED(toast_pointer)) SET_VARSIZE_COMPRESSED(result, attrsize + VARHDRSZ); @@ -392,13 +392,13 @@ toast_fetch_datum(struct varlena *attr) * has to be a prefix, i.e. sliceoffset has to be 0). * ---------- */ -static struct varlena * -toast_fetch_datum_slice(struct varlena *attr, int32 sliceoffset, +static varlena * +toast_fetch_datum_slice(varlena *attr, int32 sliceoffset, int32 slicelength) { Relation toastrel; - struct varlena *result; - struct varatt_external toast_pointer; + varlena *result; + varatt_external toast_pointer; int32 attrsize; if (!VARATT_IS_EXTERNAL_ONDISK(attr)) @@ -438,7 +438,7 @@ toast_fetch_datum_slice(struct varlena *attr, int32 sliceoffset, if (((sliceoffset + slicelength) > attrsize) || slicelength < 0) slicelength = attrsize - sliceoffset; - result = (struct varlena *) palloc(slicelength + VARHDRSZ); + result = (varlena *) palloc(slicelength + VARHDRSZ); if (VARATT_EXTERNAL_IS_COMPRESSED(toast_pointer)) SET_VARSIZE_COMPRESSED(result, slicelength + VARHDRSZ); @@ -467,8 +467,8 @@ toast_fetch_datum_slice(struct varlena *attr, int32 sliceoffset, * * Decompress a compressed version of a varlena datum */ -static struct varlena * -toast_decompress_datum(struct varlena *attr) +static varlena * +toast_decompress_datum(varlena *attr) { ToastCompressionId cmid; @@ -499,8 +499,8 @@ toast_decompress_datum(struct varlena *attr) * offset handling happens in detoast_attr_slice. * Here we just decompress a slice from the front. */ -static struct varlena * -toast_decompress_datum_slice(struct varlena *attr, int32 slicelength) +static varlena * +toast_decompress_datum_slice(varlena *attr, int32 slicelength) { ToastCompressionId cmid; @@ -544,20 +544,20 @@ toast_decompress_datum_slice(struct varlena *attr, int32 slicelength) Size toast_raw_datum_size(Datum value) { - struct varlena *attr = (struct varlena *) DatumGetPointer(value); + varlena *attr = (varlena *) DatumGetPointer(value); Size result; if (VARATT_IS_EXTERNAL_ONDISK(attr)) { /* va_rawsize is the size of the original datum -- including header */ - struct varatt_external toast_pointer; + varatt_external toast_pointer; VARATT_EXTERNAL_GET_POINTER(toast_pointer, attr); result = toast_pointer.va_rawsize; } else if (VARATT_IS_EXTERNAL_INDIRECT(attr)) { - struct varatt_indirect toast_pointer; + varatt_indirect toast_pointer; VARATT_EXTERNAL_GET_POINTER(toast_pointer, attr); @@ -600,7 +600,7 @@ toast_raw_datum_size(Datum value) Size toast_datum_size(Datum value) { - struct varlena *attr = (struct varlena *) DatumGetPointer(value); + varlena *attr = (varlena *) DatumGetPointer(value); Size result; if (VARATT_IS_EXTERNAL_ONDISK(attr)) @@ -610,14 +610,14 @@ toast_datum_size(Datum value) * compressed or not. We do not count the size of the toast pointer * ... should we? */ - struct varatt_external toast_pointer; + varatt_external toast_pointer; VARATT_EXTERNAL_GET_POINTER(toast_pointer, attr); result = VARATT_EXTERNAL_GET_EXTSIZE(toast_pointer); } else if (VARATT_IS_EXTERNAL_INDIRECT(attr)) { - struct varatt_indirect toast_pointer; + varatt_indirect toast_pointer; VARATT_EXTERNAL_GET_POINTER(toast_pointer, attr); diff --git a/src/backend/access/common/indextuple.c b/src/backend/access/common/indextuple.c index d7c8c53fd8d1..d6350201e015 100644 --- a/src/backend/access/common/indextuple.c +++ b/src/backend/access/common/indextuple.c @@ -108,7 +108,7 @@ index_form_tuple_context(TupleDesc tupleDescriptor, if (VARATT_IS_EXTERNAL(DatumGetPointer(values[i]))) { untoasted_values[i] = - PointerGetDatum(detoast_external_attr((struct varlena *) + PointerGetDatum(detoast_external_attr((varlena *) DatumGetPointer(values[i]))); untoasted_free[i] = true; } diff --git a/src/backend/access/common/toast_compression.c b/src/backend/access/common/toast_compression.c index 1336328cc0b5..6668ecbc3306 100644 --- a/src/backend/access/common/toast_compression.c +++ b/src/backend/access/common/toast_compression.c @@ -36,12 +36,12 @@ int default_toast_compression = TOAST_PGLZ_COMPRESSION; * * Returns the compressed varlena, or NULL if compression fails. */ -struct varlena * -pglz_compress_datum(const struct varlena *value) +varlena * +pglz_compress_datum(const varlena *value) { int32 valsize, len; - struct varlena *tmp = NULL; + varlena *tmp = NULL; valsize = VARSIZE_ANY_EXHDR(value); @@ -57,8 +57,8 @@ pglz_compress_datum(const struct varlena *value) * Figure out the maximum possible size of the pglz output, add the bytes * that will be needed for varlena overhead, and allocate that amount. */ - tmp = (struct varlena *) palloc(PGLZ_MAX_OUTPUT(valsize) + - VARHDRSZ_COMPRESSED); + tmp = (varlena *) palloc(PGLZ_MAX_OUTPUT(valsize) + + VARHDRSZ_COMPRESSED); len = pglz_compress(VARDATA_ANY(value), valsize, @@ -78,14 +78,14 @@ pglz_compress_datum(const struct varlena *value) /* * Decompress a varlena that was compressed using PGLZ. */ -struct varlena * -pglz_decompress_datum(const struct varlena *value) +varlena * +pglz_decompress_datum(const varlena *value) { - struct varlena *result; + varlena *result; int32 rawsize; /* allocate memory for the uncompressed data */ - result = (struct varlena *) palloc(VARDATA_COMPRESSED_GET_EXTSIZE(value) + VARHDRSZ); + result = (varlena *) palloc(VARDATA_COMPRESSED_GET_EXTSIZE(value) + VARHDRSZ); /* decompress the data */ rawsize = pglz_decompress((char *) value + VARHDRSZ_COMPRESSED, @@ -105,15 +105,15 @@ pglz_decompress_datum(const struct varlena *value) /* * Decompress part of a varlena that was compressed using PGLZ. */ -struct varlena * -pglz_decompress_datum_slice(const struct varlena *value, +varlena * +pglz_decompress_datum_slice(const varlena *value, int32 slicelength) { - struct varlena *result; + varlena *result; int32 rawsize; /* allocate memory for the uncompressed data */ - result = (struct varlena *) palloc(slicelength + VARHDRSZ); + result = (varlena *) palloc(slicelength + VARHDRSZ); /* decompress the data */ rawsize = pglz_decompress((char *) value + VARHDRSZ_COMPRESSED, @@ -135,8 +135,8 @@ pglz_decompress_datum_slice(const struct varlena *value, * * Returns the compressed varlena, or NULL if compression fails. */ -struct varlena * -lz4_compress_datum(const struct varlena *value) +varlena * +lz4_compress_datum(const varlena *value) { #ifndef USE_LZ4 NO_COMPRESSION_SUPPORT("lz4"); @@ -145,7 +145,7 @@ lz4_compress_datum(const struct varlena *value) int32 valsize; int32 len; int32 max_size; - struct varlena *tmp = NULL; + varlena *tmp = NULL; valsize = VARSIZE_ANY_EXHDR(value); @@ -154,7 +154,7 @@ lz4_compress_datum(const struct varlena *value) * that will be needed for varlena overhead, and allocate that amount. */ max_size = LZ4_compressBound(valsize); - tmp = (struct varlena *) palloc(max_size + VARHDRSZ_COMPRESSED); + tmp = (varlena *) palloc(max_size + VARHDRSZ_COMPRESSED); len = LZ4_compress_default(VARDATA_ANY(value), (char *) tmp + VARHDRSZ_COMPRESSED, @@ -178,18 +178,18 @@ lz4_compress_datum(const struct varlena *value) /* * Decompress a varlena that was compressed using LZ4. */ -struct varlena * -lz4_decompress_datum(const struct varlena *value) +varlena * +lz4_decompress_datum(const varlena *value) { #ifndef USE_LZ4 NO_COMPRESSION_SUPPORT("lz4"); return NULL; /* keep compiler quiet */ #else int32 rawsize; - struct varlena *result; + varlena *result; /* allocate memory for the uncompressed data */ - result = (struct varlena *) palloc(VARDATA_COMPRESSED_GET_EXTSIZE(value) + VARHDRSZ); + result = (varlena *) palloc(VARDATA_COMPRESSED_GET_EXTSIZE(value) + VARHDRSZ); /* decompress the data */ rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESSED, @@ -211,22 +211,22 @@ lz4_decompress_datum(const struct varlena *value) /* * Decompress part of a varlena that was compressed using LZ4. */ -struct varlena * -lz4_decompress_datum_slice(const struct varlena *value, int32 slicelength) +varlena * +lz4_decompress_datum_slice(const varlena *value, int32 slicelength) { #ifndef USE_LZ4 NO_COMPRESSION_SUPPORT("lz4"); return NULL; /* keep compiler quiet */ #else int32 rawsize; - struct varlena *result; + varlena *result; /* slice decompression not supported prior to 1.8.3 */ if (LZ4_versionNumber() < 10803) return lz4_decompress_datum(value); /* allocate memory for the uncompressed data */ - result = (struct varlena *) palloc(slicelength + VARHDRSZ); + result = (varlena *) palloc(slicelength + VARHDRSZ); /* decompress the data */ rawsize = LZ4_decompress_safe_partial((char *) value + VARHDRSZ_COMPRESSED, @@ -251,7 +251,7 @@ lz4_decompress_datum_slice(const struct varlena *value, int32 slicelength) * Returns TOAST_INVALID_COMPRESSION_ID if the varlena is not compressed. */ ToastCompressionId -toast_get_compression_id(struct varlena *attr) +toast_get_compression_id(varlena *attr) { ToastCompressionId cmid = TOAST_INVALID_COMPRESSION_ID; @@ -262,7 +262,7 @@ toast_get_compression_id(struct varlena *attr) */ if (VARATT_IS_EXTERNAL_ONDISK(attr)) { - struct varatt_external toast_pointer; + varatt_external toast_pointer; VARATT_EXTERNAL_GET_POINTER(toast_pointer, attr); diff --git a/src/backend/access/common/toast_internals.c b/src/backend/access/common/toast_internals.c index 6836786fd056..4d0da07135e8 100644 --- a/src/backend/access/common/toast_internals.c +++ b/src/backend/access/common/toast_internals.c @@ -45,7 +45,7 @@ static bool toastid_valueid_exists(Oid toastrelid, Oid valueid); Datum toast_compress_datum(Datum value, char cmethod) { - struct varlena *tmp = NULL; + varlena *tmp = NULL; int32 valsize; ToastCompressionId cmid = TOAST_INVALID_COMPRESSION_ID; @@ -64,11 +64,11 @@ toast_compress_datum(Datum value, char cmethod) switch (cmethod) { case TOAST_PGLZ_COMPRESSION: - tmp = pglz_compress_datum((const struct varlena *) DatumGetPointer(value)); + tmp = pglz_compress_datum((const varlena *) DatumGetPointer(value)); cmid = TOAST_PGLZ_COMPRESSION_ID; break; case TOAST_LZ4_COMPRESSION: - tmp = lz4_compress_datum((const struct varlena *) DatumGetPointer(value)); + tmp = lz4_compress_datum((const varlena *) DatumGetPointer(value)); cmid = TOAST_LZ4_COMPRESSION_ID; break; default: @@ -117,14 +117,14 @@ toast_compress_datum(Datum value, char cmethod) */ Datum toast_save_datum(Relation rel, Datum value, - struct varlena *oldexternal, int options) + varlena *oldexternal, int options) { Relation toastrel; Relation *toastidxs; TupleDesc toasttupDesc; CommandId mycid = GetCurrentCommandId(true); - struct varlena *result; - struct varatt_external toast_pointer; + varlena *result; + varatt_external toast_pointer; int32 chunk_seq = 0; char *data_p; int32 data_todo; @@ -225,7 +225,7 @@ toast_save_datum(Relation rel, Datum value, toast_pointer.va_valueid = InvalidOid; if (oldexternal != NULL) { - struct varatt_external old_toast_pointer; + varatt_external old_toast_pointer; Assert(VARATT_IS_EXTERNAL_ONDISK(oldexternal)); /* Must copy to access aligned fields */ @@ -287,7 +287,7 @@ toast_save_datum(Relation rel, Datum value, bool t_isnull[3] = {0}; union { - alignas(int32) struct varlena hdr; + alignas(int32) varlena hdr; /* this is to make the union big enough for a chunk: */ char data[TOAST_MAX_CHUNK_SIZE + VARHDRSZ]; } chunk_data; @@ -359,7 +359,7 @@ toast_save_datum(Relation rel, Datum value, /* * Create the TOAST pointer value that we'll return */ - result = (struct varlena *) palloc(TOAST_POINTER_SIZE); + result = (varlena *) palloc(TOAST_POINTER_SIZE); SET_VARTAG_EXTERNAL(result, VARTAG_ONDISK); memcpy(VARDATA_EXTERNAL(result), &toast_pointer, sizeof(toast_pointer)); @@ -375,8 +375,8 @@ toast_save_datum(Relation rel, Datum value, void toast_delete_datum(Relation rel, Datum value, bool is_speculative) { - struct varlena *attr = (struct varlena *) DatumGetPointer(value); - struct varatt_external toast_pointer; + varlena *attr = (varlena *) DatumGetPointer(value); + varatt_external toast_pointer; Relation toastrel; Relation *toastidxs; ScanKeyData toastkey; diff --git a/src/backend/access/hash/hashfunc.c b/src/backend/access/hash/hashfunc.c index 83bda209c425..82d740ae8497 100644 --- a/src/backend/access/hash/hashfunc.c +++ b/src/backend/access/hash/hashfunc.c @@ -385,7 +385,7 @@ hashtextextended(PG_FUNCTION_ARGS) Datum hashvarlena(PG_FUNCTION_ARGS) { - struct varlena *key = PG_GETARG_VARLENA_PP(0); + varlena *key = PG_GETARG_VARLENA_PP(0); Datum result; result = hash_any((unsigned char *) VARDATA_ANY(key), @@ -400,7 +400,7 @@ hashvarlena(PG_FUNCTION_ARGS) Datum hashvarlenaextended(PG_FUNCTION_ARGS) { - struct varlena *key = PG_GETARG_VARLENA_PP(0); + varlena *key = PG_GETARG_VARLENA_PP(0); Datum result; result = hash_any_extended((unsigned char *) VARDATA_ANY(key), diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c index f30a56ecf553..e522f133a2f8 100644 --- a/src/backend/access/heap/heapam.c +++ b/src/backend/access/heap/heapam.c @@ -4544,7 +4544,7 @@ HeapDetermineColumnsInfo(Relation relation, * Check if the old tuple's attribute is stored externally and is a * member of external_cols. */ - if (VARATT_IS_EXTERNAL((struct varlena *) DatumGetPointer(value1)) && + if (VARATT_IS_EXTERNAL((varlena *) DatumGetPointer(value1)) && bms_is_member(attidx, external_cols)) *has_external = true; } diff --git a/src/backend/access/heap/heaptoast.c b/src/backend/access/heap/heaptoast.c index e28fe47a4498..f91b21c85056 100644 --- a/src/backend/access/heap/heaptoast.c +++ b/src/backend/access/heap/heaptoast.c @@ -371,9 +371,9 @@ toast_flatten_tuple(HeapTuple tup, TupleDesc tupleDesc) */ if (!toast_isnull[i] && TupleDescCompactAttr(tupleDesc, i)->attlen == -1) { - struct varlena *new_value; + varlena *new_value; - new_value = (struct varlena *) DatumGetPointer(toast_values[i]); + new_value = (varlena *) DatumGetPointer(toast_values[i]); if (VARATT_IS_EXTERNAL(new_value)) { new_value = detoast_external_attr(new_value); @@ -485,9 +485,9 @@ toast_flatten_tuple_to_datum(HeapTupleHeader tup, has_nulls = true; else if (TupleDescCompactAttr(tupleDesc, i)->attlen == -1) { - struct varlena *new_value; + varlena *new_value; - new_value = (struct varlena *) DatumGetPointer(toast_values[i]); + new_value = (varlena *) DatumGetPointer(toast_values[i]); if (VARATT_IS_EXTERNAL(new_value) || VARATT_IS_COMPRESSED(new_value)) { @@ -586,9 +586,9 @@ toast_build_flattened_tuple(TupleDesc tupleDesc, */ if (!isnull[i] && TupleDescCompactAttr(tupleDesc, i)->attlen == -1) { - struct varlena *new_value; + varlena *new_value; - new_value = (struct varlena *) DatumGetPointer(new_values[i]); + new_value = (varlena *) DatumGetPointer(new_values[i]); if (VARATT_IS_EXTERNAL(new_value)) { new_value = detoast_external_attr(new_value); @@ -625,7 +625,7 @@ toast_build_flattened_tuple(TupleDesc tupleDesc, void heap_fetch_toast_slice(Relation toastrel, Oid valueid, int32 attrsize, int32 sliceoffset, int32 slicelength, - struct varlena *result) + varlena *result) { Relation *toastidxs; ScanKeyData toastkey[3]; diff --git a/src/backend/access/table/toast_helper.c b/src/backend/access/table/toast_helper.c index d8a604a0b3e2..0d792a60ca0f 100644 --- a/src/backend/access/table/toast_helper.c +++ b/src/backend/access/table/toast_helper.c @@ -49,8 +49,8 @@ toast_tuple_init(ToastTupleContext *ttc) for (i = 0; i < numAttrs; i++) { Form_pg_attribute att = TupleDescAttr(tupleDesc, i); - struct varlena *old_value; - struct varlena *new_value; + varlena *old_value; + varlena *new_value; ttc->ttc_attr[i].tai_colflags = 0; ttc->ttc_attr[i].tai_oldexternal = NULL; @@ -62,9 +62,9 @@ toast_tuple_init(ToastTupleContext *ttc) * For UPDATE get the old and new values of this attribute */ old_value = - (struct varlena *) DatumGetPointer(ttc->ttc_oldvalues[i]); + (varlena *) DatumGetPointer(ttc->ttc_oldvalues[i]); new_value = - (struct varlena *) DatumGetPointer(ttc->ttc_values[i]); + (varlena *) DatumGetPointer(ttc->ttc_values[i]); /* * If the old value is stored on disk, check if it has changed so @@ -102,7 +102,7 @@ toast_tuple_init(ToastTupleContext *ttc) /* * For INSERT simply get the new value */ - new_value = (struct varlena *) DatumGetPointer(ttc->ttc_values[i]); + new_value = (varlena *) DatumGetPointer(ttc->ttc_values[i]); } /* diff --git a/src/backend/executor/tstoreReceiver.c b/src/backend/executor/tstoreReceiver.c index 2ce96b694022..8531d4ca4321 100644 --- a/src/backend/executor/tstoreReceiver.c +++ b/src/backend/executor/tstoreReceiver.c @@ -161,7 +161,7 @@ tstoreReceiveSlot_detoast(TupleTableSlot *slot, DestReceiver *self) { if (VARATT_IS_EXTERNAL(DatumGetPointer(val))) { - val = PointerGetDatum(detoast_external_attr((struct varlena *) + val = PointerGetDatum(detoast_external_attr((varlena *) DatumGetPointer(val))); myState->tofree[nfree++] = val; } diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c index a0293f6ec7c5..fe0df3686a31 100644 --- a/src/backend/replication/logical/reorderbuffer.c +++ b/src/backend/replication/logical/reorderbuffer.c @@ -182,8 +182,8 @@ typedef struct ReorderBufferToastEnt Size num_chunks; /* number of chunks we've already seen */ Size size; /* combined size of chunks seen */ dlist_head chunks; /* linked list of chunks */ - struct varlena *reconstructed; /* reconstructed varlena now pointed to in - * main tup */ + varlena *reconstructed; /* reconstructed varlena now pointed to in + * main tup */ } ReorderBufferToastEnt; /* Disk serialization support datastructures */ @@ -5133,13 +5133,13 @@ ReorderBufferToastReplace(ReorderBuffer *rb, ReorderBufferTXN *txn, { CompactAttribute *attr = TupleDescCompactAttr(desc, natt); ReorderBufferToastEnt *ent; - struct varlena *varlena; + varlena *varlena_pointer; /* va_rawsize is the size of the original datum -- including header */ - struct varatt_external toast_pointer; - struct varatt_indirect redirect_pointer; - struct varlena *new_datum = NULL; - struct varlena *reconstructed; + varatt_external toast_pointer; + varatt_indirect redirect_pointer; + varlena *new_datum = NULL; + varlena *reconstructed; dlist_iter it; Size data_done = 0; @@ -5155,13 +5155,13 @@ ReorderBufferToastReplace(ReorderBuffer *rb, ReorderBufferTXN *txn, continue; /* ok, we know we have a toast datum */ - varlena = (struct varlena *) DatumGetPointer(attrs[natt]); + varlena_pointer = (varlena *) DatumGetPointer(attrs[natt]); /* no need to do anything if the tuple isn't external */ - if (!VARATT_IS_EXTERNAL(varlena)) + if (!VARATT_IS_EXTERNAL(varlena_pointer)) continue; - VARATT_EXTERNAL_GET_POINTER(toast_pointer, varlena); + VARATT_EXTERNAL_GET_POINTER(toast_pointer, varlena_pointer); /* * Check whether the toast tuple changed, replace if so. @@ -5175,7 +5175,7 @@ ReorderBufferToastReplace(ReorderBuffer *rb, ReorderBufferTXN *txn, continue; new_datum = - (struct varlena *) palloc0(INDIRECT_POINTER_SIZE); + (varlena *) palloc0(INDIRECT_POINTER_SIZE); free[natt] = true; diff --git a/src/backend/storage/large_object/inv_api.c b/src/backend/storage/large_object/inv_api.c index 466c1a856cb3..a3cce496c20b 100644 --- a/src/backend/storage/large_object/inv_api.c +++ b/src/backend/storage/large_object/inv_api.c @@ -142,7 +142,7 @@ getdatafield(Form_pg_largeobject tuple, if (VARATT_IS_EXTENDED(datafield)) { datafield = (bytea *) - detoast_attr((struct varlena *) datafield); + detoast_attr((varlena *) datafield); freeit = true; } len = VARSIZE(datafield) - VARHDRSZ; diff --git a/src/backend/utils/adt/datum.c b/src/backend/utils/adt/datum.c index e2472cd14443..01081c12407b 100644 --- a/src/backend/utils/adt/datum.c +++ b/src/backend/utils/adt/datum.c @@ -26,7 +26,7 @@ * The number of significant bytes are always equal to the typlen. * * C) if a type is not "byVal" and has typlen == -1, - * then the "Datum" always points to a "struct varlena". + * then the "Datum" always points to a "varlena". * This varlena structure has information about the actual length of this * particular instance of the type and about its value. * @@ -82,7 +82,7 @@ datumGetSize(Datum value, bool typByVal, int typLen) else if (typLen == -1) { /* It is a varlena datatype */ - struct varlena *s = (struct varlena *) DatumGetPointer(value); + varlena *s = (varlena *) DatumGetPointer(value); if (!s) ereport(ERROR, @@ -138,7 +138,7 @@ datumCopy(Datum value, bool typByVal, int typLen) else if (typLen == -1) { /* It is a varlena datatype */ - struct varlena *vl = (struct varlena *) DatumGetPointer(value); + varlena *vl = (varlena *) DatumGetPointer(value); if (VARATT_IS_EXTERNAL_EXPANDED(vl)) { @@ -288,8 +288,8 @@ datum_image_eq(Datum value1, Datum value2, bool typByVal, int typLen) result = false; else { - struct varlena *arg1val; - struct varlena *arg2val; + varlena *arg1val; + varlena *arg2val; arg1val = PG_DETOAST_DATUM_PACKED(value1); arg2val = PG_DETOAST_DATUM_PACKED(value2); @@ -346,7 +346,7 @@ datum_image_hash(Datum value, bool typByVal, int typLen) result = hash_bytes((unsigned char *) DatumGetPointer(value), typLen); else if (typLen == -1) { - struct varlena *val; + varlena *val; len = toast_raw_datum_size(value); diff --git a/src/backend/utils/adt/expandedrecord.c b/src/backend/utils/adt/expandedrecord.c index d21ef9d8c082..123792aa725e 100644 --- a/src/backend/utils/adt/expandedrecord.c +++ b/src/backend/utils/adt/expandedrecord.c @@ -1159,7 +1159,7 @@ expanded_record_set_field_internal(ExpandedRecordHeader *erh, int fnumber, { /* Detoasting should be done in short-lived context. */ oldcxt = MemoryContextSwitchTo(get_short_term_cxt(erh)); - newValue = PointerGetDatum(detoast_external_attr((struct varlena *) DatumGetPointer(newValue))); + newValue = PointerGetDatum(detoast_external_attr((varlena *) DatumGetPointer(newValue))); MemoryContextSwitchTo(oldcxt); } else @@ -1305,7 +1305,7 @@ expanded_record_set_fields(ExpandedRecordHeader *erh, if (expand_external) { /* Detoast as requested while copying the value */ - newValue = PointerGetDatum(detoast_external_attr((struct varlena *) DatumGetPointer(newValue))); + newValue = PointerGetDatum(detoast_external_attr((varlena *) DatumGetPointer(newValue))); } else { diff --git a/src/backend/utils/adt/rowtypes.c b/src/backend/utils/adt/rowtypes.c index db67e86e7603..e4eb7111ee73 100644 --- a/src/backend/utils/adt/rowtypes.c +++ b/src/backend/utils/adt/rowtypes.c @@ -1515,8 +1515,8 @@ record_image_cmp(FunctionCallInfo fcinfo) { Size len1, len2; - struct varlena *arg1val; - struct varlena *arg2val; + varlena *arg1val; + varlena *arg2val; len1 = toast_raw_datum_size(values1[i1]); len2 = toast_raw_datum_size(values2[i2]); diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c index c80191f0a224..6fd675b35771 100644 --- a/src/backend/utils/adt/varlena.c +++ b/src/backend/utils/adt/varlena.c @@ -42,7 +42,7 @@ #include "utils/sortsupport.h" #include "utils/varlena.h" -typedef struct varlena VarString; +typedef varlena VarString; /* * State for text_position_* functions. @@ -4165,7 +4165,7 @@ pg_column_compression(PG_FUNCTION_ARGS) PG_RETURN_NULL(); /* get the compression method id stored in the compressed varlena */ - cmid = toast_get_compression_id((struct varlena *) + cmid = toast_get_compression_id((varlena *) DatumGetPointer(PG_GETARG_DATUM(0))); if (cmid == TOAST_INVALID_COMPRESSION_ID) PG_RETURN_NULL(); @@ -4194,8 +4194,8 @@ Datum pg_column_toast_chunk_id(PG_FUNCTION_ARGS) { int typlen; - struct varlena *attr; - struct varatt_external toast_pointer; + varlena *attr; + varatt_external toast_pointer; /* On first call, get the input type's typlen, and save at *fn_extra */ if (fcinfo->flinfo->fn_extra == NULL) @@ -4217,7 +4217,7 @@ pg_column_toast_chunk_id(PG_FUNCTION_ARGS) if (typlen != -1) PG_RETURN_NULL(); - attr = (struct varlena *) DatumGetPointer(PG_GETARG_DATUM(0)); + attr = (varlena *) DatumGetPointer(PG_GETARG_DATUM(0)); if (!VARATT_IS_EXTERNAL_ONDISK(attr)) PG_RETURN_NULL(); diff --git a/src/backend/utils/fmgr/fmgr.c b/src/backend/utils/fmgr/fmgr.c index 05984e7ef269..4e26df7c63a0 100644 --- a/src/backend/utils/fmgr/fmgr.c +++ b/src/backend/utils/fmgr/fmgr.c @@ -1793,8 +1793,8 @@ OidSendFunctionCall(Oid functionId, Datum val) *------------------------------------------------------------------------- */ -struct varlena * -pg_detoast_datum(struct varlena *datum) +varlena * +pg_detoast_datum(varlena *datum) { if (VARATT_IS_EXTENDED(datum)) return detoast_attr(datum); @@ -1802,8 +1802,8 @@ pg_detoast_datum(struct varlena *datum) return datum; } -struct varlena * -pg_detoast_datum_copy(struct varlena *datum) +varlena * +pg_detoast_datum_copy(varlena *datum) { if (VARATT_IS_EXTENDED(datum)) return detoast_attr(datum); @@ -1811,22 +1811,22 @@ pg_detoast_datum_copy(struct varlena *datum) { /* Make a modifiable copy of the varlena object */ Size len = VARSIZE(datum); - struct varlena *result = (struct varlena *) palloc(len); + varlena *result = (varlena *) palloc(len); memcpy(result, datum, len); return result; } } -struct varlena * -pg_detoast_datum_slice(struct varlena *datum, int32 first, int32 count) +varlena * +pg_detoast_datum_slice(varlena *datum, int32 first, int32 count) { /* Only get the specified portion from the toast rel */ return detoast_attr_slice(datum, first, count); } -struct varlena * -pg_detoast_datum_packed(struct varlena *datum) +varlena * +pg_detoast_datum_packed(varlena *datum) { if (VARATT_IS_COMPRESSED(datum) || VARATT_IS_EXTERNAL(datum)) return detoast_attr(datum); diff --git a/src/test/regress/regress.c b/src/test/regress/regress.c index ce5f5f9eb196..5b56fdc90556 100644 --- a/src/test/regress/regress.c +++ b/src/test/regress/regress.c @@ -376,9 +376,9 @@ make_tuple_indirect(PG_FUNCTION_ARGS) for (i = 0; i < ncolumns; i++) { - struct varlena *attr; - struct varlena *new_attr; - struct varatt_indirect redirect_pointer; + varlena *attr; + varlena *new_attr; + varatt_indirect redirect_pointer; /* only work on existing, not-null varlenas */ if (TupleDescAttr(tupdesc, i)->attisdropped || @@ -387,7 +387,7 @@ make_tuple_indirect(PG_FUNCTION_ARGS) TupleDescAttr(tupdesc, i)->attstorage == TYPSTORAGE_PLAIN) continue; - attr = (struct varlena *) DatumGetPointer(values[i]); + attr = (varlena *) DatumGetPointer(values[i]); /* don't recursively indirect */ if (VARATT_IS_EXTERNAL_INDIRECT(attr)) @@ -398,14 +398,14 @@ make_tuple_indirect(PG_FUNCTION_ARGS) attr = detoast_external_attr(attr); else { - struct varlena *oldattr = attr; + varlena *oldattr = attr; attr = palloc0(VARSIZE_ANY(oldattr)); memcpy(attr, oldattr, VARSIZE_ANY(oldattr)); } /* build indirection Datum */ - new_attr = (struct varlena *) palloc0(INDIRECT_POINTER_SIZE); + new_attr = (varlena *) palloc0(INDIRECT_POINTER_SIZE); redirect_pointer.pointer = attr; SET_VARTAG_EXTERNAL(new_attr, VARTAG_INDIRECT); memcpy(VARDATA_EXTERNAL(new_attr), &redirect_pointer, diff --git a/doc/src/sgml/storage.sgml b/doc/src/sgml/storage.sgml index 02ddfda834a2..6b6377503bf6 100644 --- a/doc/src/sgml/storage.sgml +++ b/doc/src/sgml/storage.sgml @@ -1068,7 +1068,7 @@ data. Empty in ordinary tables.</entry> fixed width field, then all the bytes are simply placed. If it's a variable length field (attlen = -1) then it's a bit more complicated. All variable-length data types share the common header structure - <type>struct varlena</type>, which includes the total length of the stored + <type>varlena</type>, which includes the total length of the stored value and some flag bits. Depending on the flags, the data can be either inline or in a <acronym>TOAST</acronym> table; it might be compressed, too (see <xref linkend="storage-toast"/>). diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c index 30c2f5831731..31e19fbc6977 100644 --- a/contrib/amcheck/verify_heapam.c +++ b/contrib/amcheck/verify_heapam.c @@ -73,7 +73,7 @@ typedef enum SkipPages */ typedef struct ToastedAttribute { - struct varatt_external toast_pointer; + varatt_external toast_pointer; BlockNumber blkno; /* block in main table */ OffsetNumber offnum; /* offset in main table */ AttrNumber attnum; /* attribute in main table */ @@ -1660,11 +1660,11 @@ static bool check_tuple_attribute(HeapCheckContext *ctx) { Datum attdatum; - struct varlena *attr; + varlena *attr; char *tp; /* pointer to the tuple data */ uint16 infomask; CompactAttribute *thisatt; - struct varatt_external toast_pointer; + varatt_external toast_pointer; infomask = ctx->tuphdr->t_infomask; thisatt = TupleDescCompactAttr(RelationGetDescr(ctx->rel), ctx->attnum); @@ -1754,7 +1754,7 @@ check_tuple_attribute(HeapCheckContext *ctx) * We go further, because we need to check if the toast datum is corrupt. */ - attr = (struct varlena *) DatumGetPointer(attdatum); + attr = (varlena *) DatumGetPointer(attdatum); /* * Now we follow the logic of detoast_external_attr(), with the same diff --git a/contrib/btree_gist/btree_utils_var.c b/contrib/btree_gist/btree_utils_var.c index 6847e4e54d5a..3d39e6f3cfe1 100644 --- a/contrib/btree_gist/btree_utils_var.c +++ b/contrib/btree_gist/btree_utils_var.c @@ -70,7 +70,7 @@ gbt_var_key_readable(const GBT_VARKEY *k) * Create a leaf-entry to store in the index, from a single Datum. */ static GBT_VARKEY * -gbt_var_key_from_datum(const struct varlena *u) +gbt_var_key_from_datum(const varlena *u) { int32 lowersize = VARSIZE(u); GBT_VARKEY *r; @@ -283,7 +283,7 @@ gbt_var_compress(GISTENTRY *entry, const gbtree_vinfo *tinfo) if (entry->leafkey) { - struct varlena *leaf = PG_DETOAST_DATUM(entry->key); + varlena *leaf = PG_DETOAST_DATUM(entry->key); GBT_VARKEY *r; r = gbt_var_key_from_datum(leaf); diff --git a/contrib/pageinspect/heapfuncs.c b/contrib/pageinspect/heapfuncs.c index 1cf0b44e731c..f39b1b8daca7 100644 --- a/contrib/pageinspect/heapfuncs.c +++ b/contrib/pageinspect/heapfuncs.c @@ -396,7 +396,7 @@ tuple_data_split_internal(Oid relid, char *tupdata, errmsg("unexpected end of tuple data"))); if (attr->attlen == -1 && do_detoast) - attr_data = pg_detoast_datum_copy((struct varlena *) (tupdata + off)); + attr_data = pg_detoast_datum_copy((varlena *) (tupdata + off)); else { attr_data = (bytea *) palloc(len + VARHDRSZ); diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c index 75325117ec93..f80264e184ea 100644 --- a/src/pl/plpgsql/src/pl_exec.c +++ b/src/pl/plpgsql/src/pl_exec.c @@ -8818,7 +8818,7 @@ assign_simple_var(PLpgSQL_execstate *estate, PLpgSQL_var *var, * pain, but there's little choice. */ oldcxt = MemoryContextSwitchTo(get_eval_mcontext(estate)); - detoasted = PointerGetDatum(detoast_external_attr((struct varlena *) DatumGetPointer(newvalue))); + detoasted = PointerGetDatum(detoast_external_attr((varlena *) DatumGetPointer(newvalue))); MemoryContextSwitchTo(oldcxt); /* Now's a good time to not leak the input value if it's freeable */ if (freeable) diff --git a/src/tools/pgindent/typedefs.list b/src/tools/pgindent/typedefs.list index 3f3a888fd0ec..783919d35200 100644 --- a/src/tools/pgindent/typedefs.list +++ b/src/tools/pgindent/typedefs.list @@ -4260,9 +4260,12 @@ va_list vacuumingOptions validate_string_relopt varatt_expanded +varatt_external +varatt_indirect varattrib_1b varattrib_1b_e varattrib_4b +varlena vartag_external vbits verifier_context -- 2.51.0
signature.asc
Description: PGP signature
