Commit 2e8b6bfa authored by Robert Haas's avatar Robert Haas

Rename some toasting functions based on whether they are heap-specific.

The old names for the attribute-detoasting functions names included
the word "heap," which seems outdated now that the heap is only one of
potentially many table access methods.

On the other hand, toast_insert_or_update and toast_delete are
heap-specific, so rename them by adding "heap_" as a prefix.

Not all of the work of making the TOAST system fully accessible to AMs
other than the heap is done yet, but there seems to be little harm in
getting this renaming out of the way now. Commit
8b94dab0 already divided up the
functions among various files partially according to whether it was
intended that they should be heap-specific or AM-agnostic, so this is
just clarifying the division contemplated by that commit.

Patch by me, reviewed and tested by Prabhat Sabu, Thomas Munro,
Andres Freund, and Álvaro Herrera.

Discussion: http://postgr.es/m/CA+TgmoZv-=2iWM4jcw5ZhJeL18HF96+W1yJeYrnGMYdkFFnEpQ@mail.gmail.com
parent 61aa9f54
...@@ -30,7 +30,7 @@ static struct varlena *toast_decompress_datum(struct varlena *attr); ...@@ -30,7 +30,7 @@ static struct varlena *toast_decompress_datum(struct varlena *attr);
static struct varlena *toast_decompress_datum_slice(struct varlena *attr, int32 slicelength); 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 * Public entry point to get back a toasted value from
* external source (possibly still in compressed format). * external source (possibly still in compressed format).
...@@ -42,7 +42,7 @@ static struct varlena *toast_decompress_datum_slice(struct varlena *attr, int32 ...@@ -42,7 +42,7 @@ static struct varlena *toast_decompress_datum_slice(struct varlena *attr, int32
* ---------- * ----------
*/ */
struct varlena * struct varlena *
heap_tuple_fetch_attr(struct varlena *attr) detoast_external_attr(struct varlena *attr)
{ {
struct varlena *result; struct varlena *result;
...@@ -68,7 +68,7 @@ heap_tuple_fetch_attr(struct varlena *attr) ...@@ -68,7 +68,7 @@ heap_tuple_fetch_attr(struct varlena *attr)
/* recurse if value is still external in some other way */ /* recurse if value is still external in some other way */
if (VARATT_IS_EXTERNAL(attr)) 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 * Copy into the caller's memory context, in case caller tries to
...@@ -103,7 +103,7 @@ heap_tuple_fetch_attr(struct varlena *attr) ...@@ -103,7 +103,7 @@ heap_tuple_fetch_attr(struct varlena *attr)
/* ---------- /* ----------
* heap_tuple_untoast_attr - * detoast_attr -
* *
* Public entry point to get back a toasted value from compression * Public entry point to get back a toasted value from compression
* or external storage. The result is always non-extended varlena form. * or external storage. The result is always non-extended varlena form.
...@@ -113,7 +113,7 @@ heap_tuple_fetch_attr(struct varlena *attr) ...@@ -113,7 +113,7 @@ heap_tuple_fetch_attr(struct varlena *attr)
* ---------- * ----------
*/ */
struct varlena * struct varlena *
heap_tuple_untoast_attr(struct varlena *attr) detoast_attr(struct varlena *attr)
{ {
if (VARATT_IS_EXTERNAL_ONDISK(attr)) if (VARATT_IS_EXTERNAL_ONDISK(attr))
{ {
...@@ -144,7 +144,7 @@ heap_tuple_untoast_attr(struct varlena *attr) ...@@ -144,7 +144,7 @@ heap_tuple_untoast_attr(struct varlena *attr)
Assert(!VARATT_IS_EXTERNAL_INDIRECT(attr)); Assert(!VARATT_IS_EXTERNAL_INDIRECT(attr));
/* recurse in case value is still extended in some other way */ /* 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 it isn't, we'd better copy it */
if (attr == (struct varlena *) redirect.pointer) if (attr == (struct varlena *) redirect.pointer)
...@@ -161,7 +161,7 @@ heap_tuple_untoast_attr(struct varlena *attr) ...@@ -161,7 +161,7 @@ heap_tuple_untoast_attr(struct varlena *attr)
/* /*
* This is an expanded-object pointer --- get flat format * 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 */ /* flatteners are not allowed to produce compressed/short output */
Assert(!VARATT_IS_EXTENDED(attr)); Assert(!VARATT_IS_EXTENDED(attr));
} }
...@@ -192,7 +192,7 @@ heap_tuple_untoast_attr(struct varlena *attr) ...@@ -192,7 +192,7 @@ heap_tuple_untoast_attr(struct varlena *attr)
/* ---------- /* ----------
* heap_tuple_untoast_attr_slice - * detoast_attr_slice -
* *
* Public entry point to get back part of a toasted value * Public entry point to get back part of a toasted value
* from compression or external storage. * from compression or external storage.
...@@ -201,7 +201,7 @@ heap_tuple_untoast_attr(struct varlena *attr) ...@@ -201,7 +201,7 @@ heap_tuple_untoast_attr(struct varlena *attr)
* ---------- * ----------
*/ */
struct varlena * struct varlena *
heap_tuple_untoast_attr_slice(struct varlena *attr, detoast_attr_slice(struct varlena *attr,
int32 sliceoffset, int32 slicelength) int32 sliceoffset, int32 slicelength)
{ {
struct varlena *preslice; struct varlena *preslice;
...@@ -253,13 +253,13 @@ heap_tuple_untoast_attr_slice(struct varlena *attr, ...@@ -253,13 +253,13 @@ heap_tuple_untoast_attr_slice(struct varlena *attr,
/* nested indirect Datums aren't allowed */ /* nested indirect Datums aren't allowed */
Assert(!VARATT_IS_EXTERNAL_INDIRECT(redirect.pointer)); Assert(!VARATT_IS_EXTERNAL_INDIRECT(redirect.pointer));
return heap_tuple_untoast_attr_slice(redirect.pointer, return detoast_attr_slice(redirect.pointer,
sliceoffset, slicelength); sliceoffset, slicelength);
} }
else if (VARATT_IS_EXTERNAL_EXPANDED(attr)) else if (VARATT_IS_EXTERNAL_EXPANDED(attr))
{ {
/* pass it off to heap_tuple_fetch_attr to flatten */ /* pass it off to detoast_external_attr to flatten */
preslice = heap_tuple_fetch_attr(attr); preslice = detoast_external_attr(attr);
} }
else else
preslice = attr; preslice = attr;
...@@ -771,7 +771,7 @@ toast_decompress_datum(struct varlena *attr) ...@@ -771,7 +771,7 @@ toast_decompress_datum(struct varlena *attr)
* toast_decompress_datum_slice - * toast_decompress_datum_slice -
* *
* Decompress the front of a compressed version of a varlena datum. * 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. * Here we just decompress a slice from the front.
*/ */
static struct varlena * static struct varlena *
......
...@@ -89,7 +89,7 @@ index_form_tuple(TupleDesc tupleDescriptor, ...@@ -89,7 +89,7 @@ index_form_tuple(TupleDesc tupleDescriptor,
if (VARATT_IS_EXTERNAL(DatumGetPointer(values[i]))) if (VARATT_IS_EXTERNAL(DatumGetPointer(values[i])))
{ {
untoasted_values[i] = untoasted_values[i] =
PointerGetDatum(heap_tuple_fetch_attr((struct varlena *) PointerGetDatum(detoast_external_attr((struct varlena *)
DatumGetPointer(values[i]))); DatumGetPointer(values[i])));
untoasted_free[i] = true; untoasted_free[i] = true;
} }
......
...@@ -2085,7 +2085,7 @@ heap_prepare_insert(Relation relation, HeapTuple tup, TransactionId xid, ...@@ -2085,7 +2085,7 @@ heap_prepare_insert(Relation relation, HeapTuple tup, TransactionId xid,
return tup; return tup;
} }
else if (HeapTupleHasExternal(tup) || tup->t_len > TOAST_TUPLE_THRESHOLD) 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 else
return tup; return tup;
} }
...@@ -2809,7 +2809,7 @@ l1: ...@@ -2809,7 +2809,7 @@ l1:
Assert(!HeapTupleHasExternal(&tp)); Assert(!HeapTupleHasExternal(&tp));
} }
else if (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 * Mark tuple for invalidation from system caches at next command
...@@ -3504,7 +3504,7 @@ l2: ...@@ -3504,7 +3504,7 @@ l2:
if (need_toast) if (need_toast)
{ {
/* Note we always use WAL and FSM during updates */ /* 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); newtupsize = MAXALIGN(heaptup->t_len);
} }
else else
...@@ -5673,7 +5673,7 @@ heap_abort_speculative(Relation relation, ItemPointer tid) ...@@ -5673,7 +5673,7 @@ heap_abort_speculative(Relation relation, ItemPointer tid)
if (HeapTupleHasExternal(&tp)) if (HeapTupleHasExternal(&tp))
{ {
Assert(!IsToastRelation(relation)); Assert(!IsToastRelation(relation));
toast_delete(relation, &tp, true); heap_toast_delete(relation, &tp, true);
} }
/* /*
......
...@@ -12,11 +12,11 @@ ...@@ -12,11 +12,11 @@
* *
* *
* INTERFACE ROUTINES * INTERFACE ROUTINES
* toast_insert_or_update - * heap_toast_insert_or_update -
* Try to make a given tuple fit into one page by compressing * Try to make a given tuple fit into one page by compressing
* or moving off attributes * or moving off attributes
* *
* toast_delete - * heap_toast_delete -
* Reclaim toast storage when a tuple is deleted * Reclaim toast storage when a tuple is deleted
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
...@@ -32,13 +32,13 @@ ...@@ -32,13 +32,13 @@
/* ---------- /* ----------
* toast_delete - * heap_toast_delete -
* *
* Cascaded delete toast-entries on DELETE * Cascaded delete toast-entries on DELETE
* ---------- * ----------
*/ */
void void
toast_delete(Relation rel, HeapTuple oldtup, bool is_speculative) heap_toast_delete(Relation rel, HeapTuple oldtup, bool is_speculative)
{ {
TupleDesc tupleDesc; TupleDesc tupleDesc;
Datum toast_values[MaxHeapAttributeNumber]; Datum toast_values[MaxHeapAttributeNumber];
...@@ -73,7 +73,7 @@ toast_delete(Relation rel, HeapTuple oldtup, bool is_speculative) ...@@ -73,7 +73,7 @@ toast_delete(Relation rel, HeapTuple oldtup, bool is_speculative)
/* ---------- /* ----------
* toast_insert_or_update - * heap_toast_insert_or_update -
* *
* Delete no-longer-used toast-entries and create new ones to * Delete no-longer-used toast-entries and create new ones to
* make the new tuple fit on INSERT or UPDATE * make the new tuple fit on INSERT or UPDATE
...@@ -91,7 +91,7 @@ toast_delete(Relation rel, HeapTuple oldtup, bool is_speculative) ...@@ -91,7 +91,7 @@ toast_delete(Relation rel, HeapTuple oldtup, bool is_speculative)
* ---------- * ----------
*/ */
HeapTuple HeapTuple
toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup, heap_toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup,
int options) int options)
{ {
HeapTuple result_tuple; HeapTuple result_tuple;
...@@ -369,7 +369,7 @@ toast_flatten_tuple(HeapTuple tup, TupleDesc tupleDesc) ...@@ -369,7 +369,7 @@ toast_flatten_tuple(HeapTuple tup, TupleDesc tupleDesc)
new_value = (struct varlena *) DatumGetPointer(toast_values[i]); new_value = (struct varlena *) DatumGetPointer(toast_values[i]);
if (VARATT_IS_EXTERNAL(new_value)) 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_values[i] = PointerGetDatum(new_value);
toast_free[i] = true; toast_free[i] = true;
} }
...@@ -484,7 +484,7 @@ toast_flatten_tuple_to_datum(HeapTupleHeader tup, ...@@ -484,7 +484,7 @@ toast_flatten_tuple_to_datum(HeapTupleHeader tup,
if (VARATT_IS_EXTERNAL(new_value) || if (VARATT_IS_EXTERNAL(new_value) ||
VARATT_IS_COMPRESSED(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_values[i] = PointerGetDatum(new_value);
toast_free[i] = true; toast_free[i] = true;
} }
...@@ -494,7 +494,8 @@ toast_flatten_tuple_to_datum(HeapTupleHeader tup, ...@@ -494,7 +494,8 @@ toast_flatten_tuple_to_datum(HeapTupleHeader tup,
/* /*
* Calculate the new size of the tuple. * 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; new_header_len = SizeofHeapTupleHeader;
if (has_nulls) if (has_nulls)
...@@ -583,7 +584,7 @@ toast_build_flattened_tuple(TupleDesc tupleDesc, ...@@ -583,7 +584,7 @@ toast_build_flattened_tuple(TupleDesc tupleDesc,
new_value = (struct varlena *) DatumGetPointer(new_values[i]); new_value = (struct varlena *) DatumGetPointer(new_values[i]);
if (VARATT_IS_EXTERNAL(new_value)) 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); new_values[i] = PointerGetDatum(new_value);
freeable_values[num_to_free++] = (Pointer) new_value; freeable_values[num_to_free++] = (Pointer) new_value;
} }
......
...@@ -664,7 +664,7 @@ raw_heap_insert(RewriteState state, HeapTuple tup) ...@@ -664,7 +664,7 @@ raw_heap_insert(RewriteState state, HeapTuple tup)
*/ */
options |= HEAP_INSERT_NO_LOGICAL; options |= HEAP_INSERT_NO_LOGICAL;
heaptup = toast_insert_or_update(state->rs_new_rel, tup, NULL, heaptup = heap_toast_insert_or_update(state->rs_new_rel, tup, NULL,
options); options);
} }
else else
......
...@@ -135,9 +135,9 @@ toast_tuple_init(ToastTupleContext *ttc) ...@@ -135,9 +135,9 @@ toast_tuple_init(ToastTupleContext *ttc)
{ {
ttc->ttc_attr[i].tai_oldexternal = new_value; ttc->ttc_attr[i].tai_oldexternal = new_value;
if (att->attstorage == 'p') if (att->attstorage == 'p')
new_value = heap_tuple_untoast_attr(new_value); new_value = detoast_attr(new_value);
else 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_values[i] = PointerGetDatum(new_value);
ttc->ttc_attr[i].tai_colflags |= TOASTCOL_NEEDS_FREE; ttc->ttc_attr[i].tai_colflags |= TOASTCOL_NEEDS_FREE;
ttc->ttc_flags |= (TOAST_NEEDS_CHANGE | TOAST_NEEDS_FREE); ttc->ttc_flags |= (TOAST_NEEDS_CHANGE | TOAST_NEEDS_FREE);
......
...@@ -133,7 +133,7 @@ tstoreReceiveSlot_detoast(TupleTableSlot *slot, DestReceiver *self) ...@@ -133,7 +133,7 @@ tstoreReceiveSlot_detoast(TupleTableSlot *slot, DestReceiver *self)
{ {
if (VARATT_IS_EXTERNAL(DatumGetPointer(val))) if (VARATT_IS_EXTERNAL(DatumGetPointer(val)))
{ {
val = PointerGetDatum(heap_tuple_fetch_attr((struct varlena *) val = PointerGetDatum(detoast_external_attr((struct varlena *)
DatumGetPointer(val))); DatumGetPointer(val)));
myState->tofree[nfree++] = val; myState->tofree[nfree++] = val;
} }
......
...@@ -180,7 +180,7 @@ getdatafield(Form_pg_largeobject tuple, ...@@ -180,7 +180,7 @@ getdatafield(Form_pg_largeobject tuple,
if (VARATT_IS_EXTENDED(datafield)) if (VARATT_IS_EXTENDED(datafield))
{ {
datafield = (bytea *) datafield = (bytea *)
heap_tuple_untoast_attr((struct varlena *) datafield); detoast_attr((struct varlena *) datafield);
freeit = true; freeit = true;
} }
len = VARSIZE(datafield) - VARHDRSZ; len = VARSIZE(datafield) - VARHDRSZ;
......
...@@ -1159,7 +1159,7 @@ expanded_record_set_field_internal(ExpandedRecordHeader *erh, int fnumber, ...@@ -1159,7 +1159,7 @@ expanded_record_set_field_internal(ExpandedRecordHeader *erh, int fnumber,
{ {
/* Detoasting should be done in short-lived context. */ /* Detoasting should be done in short-lived context. */
oldcxt = MemoryContextSwitchTo(get_short_term_cxt(erh)); 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); MemoryContextSwitchTo(oldcxt);
} }
else else
...@@ -1305,7 +1305,7 @@ expanded_record_set_fields(ExpandedRecordHeader *erh, ...@@ -1305,7 +1305,7 @@ expanded_record_set_fields(ExpandedRecordHeader *erh,
if (expand_external) if (expand_external)
{ {
/* Detoast as requested while copying the value */ /* 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 else
{ {
......
...@@ -1739,7 +1739,7 @@ struct varlena * ...@@ -1739,7 +1739,7 @@ struct varlena *
pg_detoast_datum(struct varlena *datum) pg_detoast_datum(struct varlena *datum)
{ {
if (VARATT_IS_EXTENDED(datum)) if (VARATT_IS_EXTENDED(datum))
return heap_tuple_untoast_attr(datum); return detoast_attr(datum);
else else
return datum; return datum;
} }
...@@ -1748,7 +1748,7 @@ struct varlena * ...@@ -1748,7 +1748,7 @@ struct varlena *
pg_detoast_datum_copy(struct varlena *datum) pg_detoast_datum_copy(struct varlena *datum)
{ {
if (VARATT_IS_EXTENDED(datum)) if (VARATT_IS_EXTENDED(datum))
return heap_tuple_untoast_attr(datum); return detoast_attr(datum);
else else
{ {
/* Make a modifiable copy of the varlena object */ /* Make a modifiable copy of the varlena object */
...@@ -1764,14 +1764,14 @@ struct varlena * ...@@ -1764,14 +1764,14 @@ struct varlena *
pg_detoast_datum_slice(struct varlena *datum, int32 first, int32 count) pg_detoast_datum_slice(struct varlena *datum, int32 first, int32 count)
{ {
/* Only get the specified portion from the toast rel */ /* 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 * struct varlena *
pg_detoast_datum_packed(struct varlena *datum) pg_detoast_datum_packed(struct varlena *datum)
{ {
if (VARATT_IS_COMPRESSED(datum) || VARATT_IS_EXTERNAL(datum)) if (VARATT_IS_COMPRESSED(datum) || VARATT_IS_EXTERNAL(datum))
return heap_tuple_untoast_attr(datum); return detoast_attr(datum);
else else
return datum; return datum;
} }
......
...@@ -44,32 +44,32 @@ do { \ ...@@ -44,32 +44,32 @@ do { \
#define INDIRECT_POINTER_SIZE (VARHDRSZ_EXTERNAL + sizeof(varatt_indirect)) #define INDIRECT_POINTER_SIZE (VARHDRSZ_EXTERNAL + sizeof(varatt_indirect))
/* ---------- /* ----------
* heap_tuple_fetch_attr() - * detoast_external_attr() -
* *
* Fetches an external stored attribute from the toast * Fetches an external stored attribute from the toast
* relation. Does NOT decompress it, if stored external * relation. Does NOT decompress it, if stored external
* in compressed format. * 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 * Fully detoasts one attribute, fetching and/or decompressing
* it as needed. * 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. * Fetches only the specified portion of an attribute.
* (Handles all cases for attribute storage) * (Handles all cases for attribute storage)
* ---------- * ----------
*/ */
extern struct varlena *heap_tuple_untoast_attr_slice(struct varlena *attr, extern struct varlena *detoast_attr_slice(struct varlena *attr,
int32 sliceoffset, int32 sliceoffset,
int32 slicelength); int32 slicelength);
......
...@@ -89,22 +89,22 @@ ...@@ -89,22 +89,22 @@
VARHDRSZ) VARHDRSZ)
/* ---------- /* ----------
* toast_insert_or_update - * heap_toast_insert_or_update -
* *
* Called by heap_insert() and heap_update(). * Called by heap_insert() and heap_update().
* ---------- * ----------
*/ */
extern HeapTuple toast_insert_or_update(Relation rel, extern HeapTuple heap_toast_insert_or_update(Relation rel, HeapTuple newtup,
HeapTuple newtup, HeapTuple oldtup, HeapTuple oldtup, int options);
int options);
/* ---------- /* ----------
* toast_delete - * heap_toast_delete -
* *
* Called by heap_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 - * toast_flatten_tuple -
......
...@@ -8344,7 +8344,7 @@ assign_simple_var(PLpgSQL_execstate *estate, PLpgSQL_var *var, ...@@ -8344,7 +8344,7 @@ assign_simple_var(PLpgSQL_execstate *estate, PLpgSQL_var *var,
* pain, but there's little choice. * pain, but there's little choice.
*/ */
oldcxt = MemoryContextSwitchTo(get_eval_mcontext(estate)); 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); MemoryContextSwitchTo(oldcxt);
/* Now's a good time to not leak the input value if it's freeable */ /* Now's a good time to not leak the input value if it's freeable */
if (freeable) if (freeable)
......
...@@ -558,7 +558,7 @@ make_tuple_indirect(PG_FUNCTION_ARGS) ...@@ -558,7 +558,7 @@ make_tuple_indirect(PG_FUNCTION_ARGS)
/* copy datum, so it still lives later */ /* copy datum, so it still lives later */
if (VARATT_IS_EXTERNAL_ONDISK(attr)) if (VARATT_IS_EXTERNAL_ONDISK(attr))
attr = heap_tuple_fetch_attr(attr); attr = detoast_external_attr(attr);
else else
{ {
struct varlena *oldattr = attr; struct varlena *oldattr = attr;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment