summaryrefslogtreecommitdiff
path: root/src/backend/access/heap
diff options
context:
space:
mode:
authorRobert Haas2019-10-04 18:24:46 +0000
committerRobert Haas2019-10-04 18:24:46 +0000
commit2e8b6bfa90b252b1e1758364de7deff067d6058a (patch)
tree107b305708ca634a760b52526b94aa1ed459c1c9 /src/backend/access/heap
parent61aa9f544a91f2908e4c7cd549907cdc5b6f1c82 (diff)
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 8b94dab06617ef80a0901ab103ebd8754427ef5a 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
Diffstat (limited to 'src/backend/access/heap')
-rw-r--r--src/backend/access/heap/heapam.c8
-rw-r--r--src/backend/access/heap/heaptoast.c23
-rw-r--r--src/backend/access/heap/rewriteheap.c4
3 files changed, 18 insertions, 17 deletions
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index e9544822bf9..0128bb34ef6 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -2085,7 +2085,7 @@ heap_prepare_insert(Relation relation, HeapTuple tup, TransactionId xid,
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;
}
@@ -2809,7 +2809,7 @@ l1:
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
@@ -3504,7 +3504,7 @@ l2:
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
@@ -5673,7 +5673,7 @@ heap_abort_speculative(Relation relation, ItemPointer tid)
if (HeapTupleHasExternal(&tp))
{
Assert(!IsToastRelation(relation));
- toast_delete(relation, &tp, true);
+ heap_toast_delete(relation, &tp, true);
}
/*
diff --git a/src/backend/access/heap/heaptoast.c b/src/backend/access/heap/heaptoast.c
index fbf9294598a..dcfdee4467d 100644
--- a/src/backend/access/heap/heaptoast.c
+++ b/src/backend/access/heap/heaptoast.c
@@ -12,11 +12,11 @@
*
*
* 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
*
*-------------------------------------------------------------------------
@@ -32,13 +32,13 @@
/* ----------
- * 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];
@@ -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
* make the new tuple fit on INSERT or UPDATE
@@ -91,8 +91,8 @@ toast_delete(Relation rel, HeapTuple oldtup, bool is_speculative)
* ----------
*/
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;
@@ -369,7 +369,7 @@ toast_flatten_tuple(HeapTuple tup, 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;
}
@@ -484,7 +484,7 @@ toast_flatten_tuple_to_datum(HeapTupleHeader tup,
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;
}
@@ -494,7 +494,8 @@ toast_flatten_tuple_to_datum(HeapTupleHeader tup,
/*
* 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)
@@ -583,7 +584,7 @@ toast_build_flattened_tuple(TupleDesc tupleDesc,
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;
}
diff --git a/src/backend/access/heap/rewriteheap.c b/src/backend/access/heap/rewriteheap.c
index 0172a139576..7c98a42b8ba 100644
--- a/src/backend/access/heap/rewriteheap.c
+++ b/src/backend/access/heap/rewriteheap.c
@@ -664,8 +664,8 @@ raw_heap_insert(RewriteState state, HeapTuple tup)
*/
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;