*/
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 */
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);
* 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
* 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;
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);
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);
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"/>).
*/
if (VARATT_IS_EXTERNAL(DatumGetPointer(value)))
{
- value = PointerGetDatum(detoast_external_attr((struct varlena *)
+ value = PointerGetDatum(detoast_external_attr((varlena *)
DatumGetPointer(value)));
free_value = true;
}
#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 -
* 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))
{
/*
* 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));
* 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))
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
* 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))
{
/* 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);
/*
* 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));
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;
}
*/
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;
* 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;
if (VARATT_IS_EXTERNAL_ONDISK(attr))
{
- struct varatt_external toast_pointer;
+ varatt_external toast_pointer;
VARATT_EXTERNAL_GET_POINTER(toast_pointer, attr);
}
else if (VARATT_IS_EXTERNAL_INDIRECT(attr))
{
- struct varatt_indirect redirect;
+ varatt_indirect redirect;
VARATT_EXTERNAL_GET_POINTER(redirect, 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)
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);
* 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))
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);
* 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))
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);
*
* 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;
* 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;
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);
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))
* 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);
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;
}
*
* 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);
* 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,
/*
* 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,
/*
* 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,
*
* 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");
int32 valsize;
int32 len;
int32 max_size;
- struct varlena *tmp = NULL;
+ varlena *tmp = NULL;
valsize = VARSIZE_ANY_EXHDR(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,
/*
* 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,
/*
* 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,
* 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;
*/
if (VARATT_IS_EXTERNAL_ONDISK(attr))
{
- struct varatt_external toast_pointer;
+ varatt_external toast_pointer;
VARATT_EXTERNAL_GET_POINTER(toast_pointer, attr);
Datum
toast_compress_datum(Datum value, char cmethod)
{
- struct varlena *tmp = NULL;
+ varlena *tmp = NULL;
int32 valsize;
ToastCompressionId cmid = TOAST_INVALID_COMPRESSION_ID;
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:
*/
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;
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 */
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;
/*
* 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));
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;
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),
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),
* 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;
}
*/
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);
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))
{
*/
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);
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];
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;
* 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
/*
* For INSERT simply get the new value
*/
- new_value = (struct varlena *) DatumGetPointer(ttc->ttc_values[i]);
+ new_value = (varlena *) DatumGetPointer(ttc->ttc_values[i]);
}
/*
{
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;
}
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 */
{
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;
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.
continue;
new_datum =
- (struct varlena *) palloc0(INDIRECT_POINTER_SIZE);
+ (varlena *) palloc0(INDIRECT_POINTER_SIZE);
free[natt] = true;
if (VARATT_IS_EXTENDED(datafield))
{
datafield = (bytea *)
- detoast_attr((struct varlena *) datafield);
+ detoast_attr((varlena *) datafield);
freeit = true;
}
len = VARSIZE(datafield) - VARHDRSZ;
* 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.
*
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,
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))
{
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);
result = hash_bytes((unsigned char *) DatumGetPointer(value), typLen);
else if (typLen == -1)
{
- struct varlena *val;
+ varlena *val;
len = toast_raw_datum_size(value);
{
/* 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
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
{
{
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]);
#include "utils/sortsupport.h"
#include "utils/varlena.h"
-typedef struct varlena VarString;
+typedef varlena VarString;
/*
* State for text_position_* functions.
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();
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)
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();
*-------------------------------------------------------------------------
*/
-struct varlena *
-pg_detoast_datum(struct varlena *datum)
+varlena *
+pg_detoast_datum(varlena *datum)
{
if (VARATT_IS_EXTENDED(datum))
return detoast_attr(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);
{
/* 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);
/*
* 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.
* in compressed format.
* ----------
*/
-extern struct varlena *detoast_external_attr(struct varlena *attr);
+extern varlena *detoast_external_attr(varlena *attr);
/* ----------
* detoast_attr() -
* it as needed.
* ----------
*/
-extern struct varlena *detoast_attr(struct varlena *attr);
+extern varlena *detoast_attr(varlena *attr);
/* ----------
* detoast_attr_slice() -
* (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 -
*/
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 */
int32 attrsize,
int32 sliceoffset,
int32 slicelength,
- struct varlena *result);
+ varlena *result);
/* ------------------------------------------------------------------------
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,
/* 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);
*/
typedef struct
{
- struct varlena *tai_oldexternal;
+ varlena *tai_oldexternal;
int32 tai_size;
uint8 tai_colflags;
char tai_compression;
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,
#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
* 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))
* 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
* 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
#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: */
#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.
#include "nodes/execnodes.h"
#include "nodes/primnodes.h"
-typedef struct varlena xmltype;
+typedef varlena xmltype;
typedef enum
{
#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.
* 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
#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;
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;
}
* 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);
* 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)
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 ||
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))
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,
vacuumingOptions
validate_string_relopt
varatt_expanded
+varatt_external
+varatt_indirect
varattrib_1b
varattrib_1b_e
varattrib_4b
+varlena
vartag_external
vbits
verifier_context