]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Improve type handling of varlena structures
authorMichael Paquier <michael@paquier.xyz>
Tue, 10 Feb 2026 22:33:24 +0000 (07:33 +0900)
committerMichael Paquier <michael@paquier.xyz>
Tue, 10 Feb 2026 22:33:24 +0000 (07:33 +0900)
This commit changes the definition of varlena to a typedef, so as it
becomes possible to remove "struct" markers from various declarations in
the code base.  Historically, "struct" markers are not the project style
for variable declarations, so this update simplifies the code and makes
it more consistent across the board.

This change has an impact on the following structures, simplifying
declarations using them:
- varlena
- varatt_indirect
- varatt_external

This cleanup has come up in a different path set that played with
TOAST and varatt.h, independently worth doing on its own.

Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Reviewed-by: Andreas Karlsson <andreas@proxel.se>
Reviewed-by: Shinya Kato <shinya11.kato@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/aW8xvVbovdhyI4yo@paquier.xyz

35 files changed:
contrib/amcheck/verify_heapam.c
contrib/btree_gist/btree_utils_var.c
contrib/pageinspect/heapfuncs.c
doc/src/sgml/storage.sgml
src/backend/access/brin/brin_tuple.c
src/backend/access/common/detoast.c
src/backend/access/common/indextuple.c
src/backend/access/common/toast_compression.c
src/backend/access/common/toast_internals.c
src/backend/access/hash/hashfunc.c
src/backend/access/heap/heapam.c
src/backend/access/heap/heaptoast.c
src/backend/access/table/toast_helper.c
src/backend/executor/tstoreReceiver.c
src/backend/replication/logical/reorderbuffer.c
src/backend/storage/large_object/inv_api.c
src/backend/utils/adt/datum.c
src/backend/utils/adt/expandedrecord.c
src/backend/utils/adt/rowtypes.c
src/backend/utils/adt/varlena.c
src/backend/utils/fmgr/fmgr.c
src/include/access/detoast.h
src/include/access/heaptoast.h
src/include/access/tableam.h
src/include/access/toast_compression.h
src/include/access/toast_helper.h
src/include/access/toast_internals.h
src/include/c.h
src/include/fmgr.h
src/include/utils/varbit.h
src/include/utils/xml.h
src/include/varatt.h
src/pl/plpgsql/src/pl_exec.c
src/test/regress/regress.c
src/tools/pgindent/typedefs.list

index 30c2f583173167b7d9d4001d24a910ad873f2943..31e19fbc69775764dbb406aaf7dff441d82e23c4 100644 (file)
@@ -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
index f6ba1c0c82583489375f7277b073dc362a65a8b5..e1945cf808f1dc72a392527fa3af92b285a24ddd 100644 (file)
@@ -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;
@@ -294,7 +294,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);
index 2f0dfff175ab78525c739ff641d3f593f5d0a651..8e31632ce0e0afc0abac9aa524b2f97ae337e5c4 100644 (file)
@@ -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);
index 02ddfda834a2ef51fda7efa6a7ffeffce2e1ae29..6b6377503bf6aa80c5895a0f24dffd4e549fd81b 100644 (file)
@@ -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"/>).
index 706387e36d6428c29012a0cff1804c1e570e17e6..69c233c62eb4779bd9c5600634983605a66b5f61 100644 (file)
@@ -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;
                        }
index 7bef01bb5f352301edfebaceee1cd024555be7d6..a6c1f3a734b2aab61283eee44d43e741e84509de 100644 (file)
 #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);
 
index d7c8c53fd8d13021c6591a4622abb31631559389..d6350201e015df9590d2345b134896c09621cc1d 100644 (file)
@@ -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;
                }
index d449613b21f4fce910fa2d803d233bfbfeb49c06..4d00537049ec1c77d4a09a199bc8f5c863b5af95 100644 (file)
@@ -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((const 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((const 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((const 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((const 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);
 
index 6836786fd056a848c4c8d7fc03f9adc081d8c3a1..4d0da07135e8f4041a0e63fab08d6ae674000eea 100644 (file)
@@ -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;
index 036421fc664f31637aefe925ea29fd40def7016e..575342a21b6b06f300dd000d963dc0aeb8539684 100644 (file)
@@ -388,7 +388,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),
@@ -403,7 +403,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),
index 3004964ab7f960ec08bf4eb5324901e5da14b410..ff8500993047d0c230e2e36a7d7dfa0b28a32b7a 100644 (file)
@@ -4535,7 +4535,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;
        }
index 6ddf6c6cf9f745dfdddc7f2f64f5685dfb14c5dd..ba541bd60c9d6a670680fca11e4e283269f52ce5 100644 (file)
@@ -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];
index d8a604a0b3e2015d8d4c27b02133801d020daae9..0d792a60ca0f71a6aa9dac4eed6e79ea9f6c9dd8 100644 (file)
@@ -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]);
                }
 
                /*
index 2ce96b6940221cf226fbbd6c4368f2694350d38a..8531d4ca4321322435eee00fb3d659e4912ba94c 100644 (file)
@@ -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;
                        }
index 2d2a6d5e9e7cc786592c30c553575c49972f2f18..94b2b29945c82b0362a14e4e47c4fd37eb1d4100 100644 (file)
@@ -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;
 
index 466c1a856cb39f51ecd205a3f64d5a0c47a58e91..a3cce496c20be115fef25d41c896a0a3dcfc0bae 100644 (file)
@@ -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;
index cc26bd67a5319232429d2bfd395b0c86f9576575..8832785540f52af2b48a83978e3f6703506f4464 100644 (file)
@@ -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);
 
index d21ef9d8c0823c959e8f79526b245f9f988e7bee..123792aa725ec06f749a10b173e2a96ca28cd274 100644 (file)
@@ -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
                                        {
index db67e86e76035fa86e6c8021e02d270fd259ad92..e4eb7111ee73852b7ebad64d03a6c06e3a575398 100644 (file)
@@ -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]);
index 6bb14620a638b4d68ed63efb71fa8f13100cb72d..dbecd7160d6f4ba99591da24b111ae5dbbbf5db1 100644 (file)
@@ -42,7 +42,7 @@
 #include "utils/sortsupport.h"
 #include "utils/varlena.h"
 
-typedef struct varlena VarString;
+typedef varlena VarString;
 
 /*
  * State for text_position_* functions.
@@ -4179,7 +4179,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();
@@ -4208,8 +4208,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)
@@ -4231,7 +4231,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();
index 05984e7ef26904daefe3dcf825118d51df73a451..4e26df7c63a0c5c5bdd5c682759a34aa8cbe3539 100644 (file)
@@ -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);
index 6db3a29191ee4d837c54098433cfdff13dd87142..fbd98181a3a187c4109322e2605f2cb2bef45dde 100644 (file)
@@ -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 -
index 21baa0834b7514c3fd65e55456162d577221da2a..725c0ce75544da0b20259f4dd41d0231a8f43269 100644 (file)
@@ -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 */
index 7260b7b3d52d71fd449155ec2e0bf8428387ec22..251379016b009c4eb2a21544c370ffa8bb50b142 100644 (file)
@@ -750,7 +750,7 @@ typedef struct TableAmRoutine
                                                                                           int32 attrsize,
                                                                                           int32 sliceoffset,
                                                                                           int32 slicelength,
-                                                                                          struct varlena *result);
+                                                                                          varlena *result);
 
 
        /* ------------------------------------------------------------------------
@@ -1906,7 +1906,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,
index 4b42f7a047f738292e12c4f1bdca5632cef19413..5f3ffa9ab2d46eb7e7383bb9569f336ae42d33ff 100644 (file)
@@ -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);
 
index 9bd6bfaffe55056a240813687a61d6463eadbf54..e8ecb995cb32a3091f5e1f1d670de3a166913a03 100644 (file)
@@ -29,7 +29,7 @@
  */
 typedef struct
 {
-       struct varlena *tai_oldexternal;
+       varlena    *tai_oldexternal;
        int32           tai_size;
        uint8           tai_colflags;
        char            tai_compression;
index 75690e0bc8235522d59489cb92af7b84d2cce5a5..d382db342620f93be7462a7569e92385e0f4294f 100644 (file)
@@ -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,
index 063eac9808c374654baaf8471fbd98a5cdf63db8..3fc09ec1e4a3c06d70bbb0d5c1ac7ab359872389 100644 (file)
@@ -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
index eabbc78b2801fd3f572a68eed91990414cfecc90..10d02bdb79fa4d875181e4100d57fb9989fc3dce 100644 (file)
@@ -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: */
index 82be976f5c50870d1cf8ab480cfb3b7f8f949c46..20cb14d75b0c752627953df9e346f7c0c49114ea 100644 (file)
@@ -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.
index 03acb255449c18e46b699bdc4395b45a9fb17ac5..023fdeb453135fe8f6ad7b73e45b71f70e61a28b 100644 (file)
@@ -20,7 +20,7 @@
 #include "nodes/execnodes.h"
 #include "nodes/primnodes.h"
 
-typedef struct varlena xmltype;
+typedef varlena xmltype;
 
 typedef enum
 {
index fd7d5912f7d3fbd5b3a777571371a90d02bdfbf0..000bdf33b92366883b70298d1fcdf6c20da3b8c3 100644 (file)
@@ -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 ((const 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);
index 75325117ec93c8b881af5b0be48176b87c5edb4e..f80264e184eae163775727161d684ffcfc75d016 100644 (file)
@@ -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)
index bea858f03c19a26b1cb327af89d5cccf6580e70a..96cf30ac925a82327693cc1e958bc91601d87c45 100644 (file)
@@ -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,
index 523977721ea558a7ffa70b75e6f3de98f475ca56..a942d030d2fba241415b887b281dddade1f5edca 100644 (file)
@@ -4270,9 +4270,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