static struct varlena *toast_decompress_datum_slice(struct varlena *attr, int32 slicelength);
/* ----------
- * heap_tuple_fetch_attr -
+ * detoast_external_attr -
*
* Public entry point to get back a toasted value from
* external source (possibly still in compressed format).
* ----------
*/
struct varlena *
-heap_tuple_fetch_attr(struct varlena *attr)
+detoast_external_attr(struct varlena *attr)
{
struct varlena *result;
/* recurse if value is still external in some other way */
if (VARATT_IS_EXTERNAL(attr))
- return heap_tuple_fetch_attr(attr);
+ return detoast_external_attr(attr);
/*
* Copy into the caller's memory context, in case caller tries to
/* ----------
- * heap_tuple_untoast_attr -
+ * detoast_attr -
*
* Public entry point to get back a toasted value from compression
* or external storage. The result is always non-extended varlena form.
* ----------
*/
struct varlena *
-heap_tuple_untoast_attr(struct varlena *attr)
+detoast_attr(struct varlena *attr)
{
if (VARATT_IS_EXTERNAL_ONDISK(attr))
{
Assert(!VARATT_IS_EXTERNAL_INDIRECT(attr));
/* recurse in case value is still extended in some other way */
- attr = heap_tuple_untoast_attr(attr);
+ attr = detoast_attr(attr);
/* if it isn't, we'd better copy it */
if (attr == (struct varlena *) redirect.pointer)
/*
* This is an expanded-object pointer --- get flat format
*/
- attr = heap_tuple_fetch_attr(attr);
+ attr = detoast_external_attr(attr);
/* flatteners are not allowed to produce compressed/short output */
Assert(!VARATT_IS_EXTENDED(attr));
}
/* ----------
- * heap_tuple_untoast_attr_slice -
+ * detoast_attr_slice -
*
* Public entry point to get back part of a toasted value
* from compression or external storage.
* ----------
*/
struct varlena *
-heap_tuple_untoast_attr_slice(struct varlena *attr,
+detoast_attr_slice(struct varlena *attr,
int32 sliceoffset, int32 slicelength)
{
struct varlena *preslice;
/* nested indirect Datums aren't allowed */
Assert(!VARATT_IS_EXTERNAL_INDIRECT(redirect.pointer));
- return heap_tuple_untoast_attr_slice(redirect.pointer,
+ return detoast_attr_slice(redirect.pointer,
sliceoffset, slicelength);
}
else if (VARATT_IS_EXTERNAL_EXPANDED(attr))
{
- /* pass it off to heap_tuple_fetch_attr to flatten */
- preslice = heap_tuple_fetch_attr(attr);
+ /* pass it off to detoast_external_attr to flatten */
+ preslice = detoast_external_attr(attr);
}
else
preslice = attr;
* toast_decompress_datum_slice -
*
* Decompress the front of a compressed version of a varlena datum.
- * offset handling happens in heap_tuple_untoast_attr_slice.
+ * offset handling happens in detoast_attr_slice.
* Here we just decompress a slice from the front.
*/
static struct varlena *
if (VARATT_IS_EXTERNAL(DatumGetPointer(values[i])))
{
untoasted_values[i] =
- PointerGetDatum(heap_tuple_fetch_attr((struct varlena *)
+ PointerGetDatum(detoast_external_attr((struct varlena *)
DatumGetPointer(values[i])));
untoasted_free[i] = true;
}
return tup;
}
else if (HeapTupleHasExternal(tup) || tup->t_len > TOAST_TUPLE_THRESHOLD)
- return toast_insert_or_update(relation, tup, NULL, options);
+ return heap_toast_insert_or_update(relation, tup, NULL, options);
else
return tup;
}
Assert(!HeapTupleHasExternal(&tp));
}
else if (HeapTupleHasExternal(&tp))
- toast_delete(relation, &tp, false);
+ heap_toast_delete(relation, &tp, false);
/*
* Mark tuple for invalidation from system caches at next command
if (need_toast)
{
/* Note we always use WAL and FSM during updates */
- heaptup = toast_insert_or_update(relation, newtup, &oldtup, 0);
+ heaptup = heap_toast_insert_or_update(relation, newtup, &oldtup, 0);
newtupsize = MAXALIGN(heaptup->t_len);
}
else
if (HeapTupleHasExternal(&tp))
{
Assert(!IsToastRelation(relation));
- toast_delete(relation, &tp, true);
+ heap_toast_delete(relation, &tp, true);
}
/*
*
*
* INTERFACE ROUTINES
- * toast_insert_or_update -
+ * heap_toast_insert_or_update -
* Try to make a given tuple fit into one page by compressing
* or moving off attributes
*
- * toast_delete -
+ * heap_toast_delete -
* Reclaim toast storage when a tuple is deleted
*
*-------------------------------------------------------------------------
/* ----------
- * toast_delete -
+ * heap_toast_delete -
*
* Cascaded delete toast-entries on DELETE
* ----------
*/
void
-toast_delete(Relation rel, HeapTuple oldtup, bool is_speculative)
+heap_toast_delete(Relation rel, HeapTuple oldtup, bool is_speculative)
{
TupleDesc tupleDesc;
Datum toast_values[MaxHeapAttributeNumber];
/* ----------
- * toast_insert_or_update -
+ * heap_toast_insert_or_update -
*
* Delete no-longer-used toast-entries and create new ones to
* make the new tuple fit on INSERT or UPDATE
* ----------
*/
HeapTuple
-toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup,
- int options)
+heap_toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup,
+ int options)
{
HeapTuple result_tuple;
TupleDesc tupleDesc;
new_value = (struct varlena *) DatumGetPointer(toast_values[i]);
if (VARATT_IS_EXTERNAL(new_value))
{
- new_value = heap_tuple_fetch_attr(new_value);
+ new_value = detoast_external_attr(new_value);
toast_values[i] = PointerGetDatum(new_value);
toast_free[i] = true;
}
if (VARATT_IS_EXTERNAL(new_value) ||
VARATT_IS_COMPRESSED(new_value))
{
- new_value = heap_tuple_untoast_attr(new_value);
+ new_value = detoast_attr(new_value);
toast_values[i] = PointerGetDatum(new_value);
toast_free[i] = true;
}
/*
* Calculate the new size of the tuple.
*
- * This should match the reconstruction code in toast_insert_or_update.
+ * This should match the reconstruction code in
+ * heap_toast_insert_or_update.
*/
new_header_len = SizeofHeapTupleHeader;
if (has_nulls)
new_value = (struct varlena *) DatumGetPointer(new_values[i]);
if (VARATT_IS_EXTERNAL(new_value))
{
- new_value = heap_tuple_fetch_attr(new_value);
+ new_value = detoast_external_attr(new_value);
new_values[i] = PointerGetDatum(new_value);
freeable_values[num_to_free++] = (Pointer) new_value;
}
*/
options |= HEAP_INSERT_NO_LOGICAL;
- heaptup = toast_insert_or_update(state->rs_new_rel, tup, NULL,
- options);
+ heaptup = heap_toast_insert_or_update(state->rs_new_rel, tup, NULL,
+ options);
}
else
heaptup = tup;
{
ttc->ttc_attr[i].tai_oldexternal = new_value;
if (att->attstorage == 'p')
- new_value = heap_tuple_untoast_attr(new_value);
+ new_value = detoast_attr(new_value);
else
- new_value = heap_tuple_fetch_attr(new_value);
+ new_value = detoast_external_attr(new_value);
ttc->ttc_values[i] = PointerGetDatum(new_value);
ttc->ttc_attr[i].tai_colflags |= TOASTCOL_NEEDS_FREE;
ttc->ttc_flags |= (TOAST_NEEDS_CHANGE | TOAST_NEEDS_FREE);
{
if (VARATT_IS_EXTERNAL(DatumGetPointer(val)))
{
- val = PointerGetDatum(heap_tuple_fetch_attr((struct varlena *)
+ val = PointerGetDatum(detoast_external_attr((struct varlena *)
DatumGetPointer(val)));
myState->tofree[nfree++] = val;
}
if (VARATT_IS_EXTENDED(datafield))
{
datafield = (bytea *)
- heap_tuple_untoast_attr((struct varlena *) datafield);
+ detoast_attr((struct varlena *) datafield);
freeit = true;
}
len = VARSIZE(datafield) - VARHDRSZ;
{
/* Detoasting should be done in short-lived context. */
oldcxt = MemoryContextSwitchTo(get_short_term_cxt(erh));
- newValue = PointerGetDatum(heap_tuple_fetch_attr((struct varlena *) DatumGetPointer(newValue)));
+ newValue = PointerGetDatum(detoast_external_attr((struct varlena *) DatumGetPointer(newValue)));
MemoryContextSwitchTo(oldcxt);
}
else
if (expand_external)
{
/* Detoast as requested while copying the value */
- newValue = PointerGetDatum(heap_tuple_fetch_attr((struct varlena *) DatumGetPointer(newValue)));
+ newValue = PointerGetDatum(detoast_external_attr((struct varlena *) DatumGetPointer(newValue)));
}
else
{
pg_detoast_datum(struct varlena *datum)
{
if (VARATT_IS_EXTENDED(datum))
- return heap_tuple_untoast_attr(datum);
+ return detoast_attr(datum);
else
return datum;
}
pg_detoast_datum_copy(struct varlena *datum)
{
if (VARATT_IS_EXTENDED(datum))
- return heap_tuple_untoast_attr(datum);
+ return detoast_attr(datum);
else
{
/* Make a modifiable copy of the varlena object */
pg_detoast_datum_slice(struct varlena *datum, int32 first, int32 count)
{
/* Only get the specified portion from the toast rel */
- return heap_tuple_untoast_attr_slice(datum, first, count);
+ return detoast_attr_slice(datum, first, count);
}
struct varlena *
pg_detoast_datum_packed(struct varlena *datum)
{
if (VARATT_IS_COMPRESSED(datum) || VARATT_IS_EXTERNAL(datum))
- return heap_tuple_untoast_attr(datum);
+ return detoast_attr(datum);
else
return datum;
}
#define INDIRECT_POINTER_SIZE (VARHDRSZ_EXTERNAL + sizeof(varatt_indirect))
/* ----------
- * heap_tuple_fetch_attr() -
+ * detoast_external_attr() -
*
* Fetches an external stored attribute from the toast
* relation. Does NOT decompress it, if stored external
* in compressed format.
* ----------
*/
-extern struct varlena *heap_tuple_fetch_attr(struct varlena *attr);
+extern struct varlena *detoast_external_attr(struct varlena *attr);
/* ----------
- * heap_tuple_untoast_attr() -
+ * detoast_attr() -
*
* Fully detoasts one attribute, fetching and/or decompressing
* it as needed.
* ----------
*/
-extern struct varlena *heap_tuple_untoast_attr(struct varlena *attr);
+extern struct varlena *detoast_attr(struct varlena *attr);
/* ----------
- * heap_tuple_untoast_attr_slice() -
+ * detoast_attr_slice() -
*
* Fetches only the specified portion of an attribute.
* (Handles all cases for attribute storage)
* ----------
*/
-extern struct varlena *heap_tuple_untoast_attr_slice(struct varlena *attr,
- int32 sliceoffset,
- int32 slicelength);
+extern struct varlena *detoast_attr_slice(struct varlena *attr,
+ int32 sliceoffset,
+ int32 slicelength);
/* ----------
* toast_raw_datum_size -
VARHDRSZ)
/* ----------
- * toast_insert_or_update -
+ * heap_toast_insert_or_update -
*
* Called by heap_insert() and heap_update().
* ----------
*/
-extern HeapTuple toast_insert_or_update(Relation rel,
- HeapTuple newtup, HeapTuple oldtup,
- int options);
+extern HeapTuple heap_toast_insert_or_update(Relation rel, HeapTuple newtup,
+ HeapTuple oldtup, int options);
/* ----------
- * toast_delete -
+ * heap_toast_delete -
*
* Called by heap_delete().
* ----------
*/
-extern void toast_delete(Relation rel, HeapTuple oldtup, bool is_speculative);
+extern void heap_toast_delete(Relation rel, HeapTuple oldtup,
+ bool is_speculative);
/* ----------
* toast_flatten_tuple -
* pain, but there's little choice.
*/
oldcxt = MemoryContextSwitchTo(get_eval_mcontext(estate));
- detoasted = PointerGetDatum(heap_tuple_fetch_attr((struct varlena *) DatumGetPointer(newvalue)));
+ detoasted = PointerGetDatum(detoast_external_attr((struct varlena *) DatumGetPointer(newvalue)));
MemoryContextSwitchTo(oldcxt);
/* Now's a good time to not leak the input value if it's freeable */
if (freeable)
/* copy datum, so it still lives later */
if (VARATT_IS_EXTERNAL_ONDISK(attr))
- attr = heap_tuple_fetch_attr(attr);
+ attr = detoast_external_attr(attr);
else
{
struct varlena *oldattr = attr;