Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2e8b6bf

Browse files
committed
Rename some toasting functions based on whether they are heap-specific.
The old names for the attribute-detoasting functions names includedthe word "heap," which seems outdated now that the heap is only one ofpotentially many table access methods.On the other hand, toast_insert_or_update and toast_delete areheap-specific, so rename them by adding "heap_" as a prefix.Not all of the work of making the TOAST system fully accessible to AMsother than the heap is done yet, but there seems to be little harm ingetting this renaming out of the way now. Commit8b94dab already divided up thefunctions among various files partially according to whether it wasintended that they should be heap-specific or AM-agnostic, so this isjust 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
1 parent61aa9f5 commit2e8b6bf

File tree

14 files changed

+58
-57
lines changed

14 files changed

+58
-57
lines changed

‎src/backend/access/common/detoast.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static struct varlena *toast_decompress_datum(struct varlena *attr);
3030
staticstructvarlena*toast_decompress_datum_slice(structvarlena*attr,int32slicelength);
3131

3232
/* ----------
33-
*heap_tuple_fetch_attr -
33+
*detoast_external_attr -
3434
*
3535
*Public entry point to get back a toasted value from
3636
*external source (possibly still in compressed format).
@@ -42,7 +42,7 @@ static struct varlena *toast_decompress_datum_slice(struct varlena *attr, int32
4242
* ----------
4343
*/
4444
structvarlena*
45-
heap_tuple_fetch_attr(structvarlena*attr)
45+
detoast_external_attr(structvarlena*attr)
4646
{
4747
structvarlena*result;
4848

@@ -68,7 +68,7 @@ heap_tuple_fetch_attr(struct varlena *attr)
6868

6969
/* recurse if value is still external in some other way */
7070
if (VARATT_IS_EXTERNAL(attr))
71-
returnheap_tuple_fetch_attr(attr);
71+
returndetoast_external_attr(attr);
7272

7373
/*
7474
* Copy into the caller's memory context, in case caller tries to
@@ -103,7 +103,7 @@ heap_tuple_fetch_attr(struct varlena *attr)
103103

104104

105105
/* ----------
106-
*heap_tuple_untoast_attr -
106+
*detoast_attr -
107107
*
108108
*Public entry point to get back a toasted value from compression
109109
*or external storage. The result is always non-extended varlena form.
@@ -113,7 +113,7 @@ heap_tuple_fetch_attr(struct varlena *attr)
113113
* ----------
114114
*/
115115
structvarlena*
116-
heap_tuple_untoast_attr(structvarlena*attr)
116+
detoast_attr(structvarlena*attr)
117117
{
118118
if (VARATT_IS_EXTERNAL_ONDISK(attr))
119119
{
@@ -144,7 +144,7 @@ heap_tuple_untoast_attr(struct varlena *attr)
144144
Assert(!VARATT_IS_EXTERNAL_INDIRECT(attr));
145145

146146
/* recurse in case value is still extended in some other way */
147-
attr=heap_tuple_untoast_attr(attr);
147+
attr=detoast_attr(attr);
148148

149149
/* if it isn't, we'd better copy it */
150150
if (attr== (structvarlena*)redirect.pointer)
@@ -161,7 +161,7 @@ heap_tuple_untoast_attr(struct varlena *attr)
161161
/*
162162
* This is an expanded-object pointer --- get flat format
163163
*/
164-
attr=heap_tuple_fetch_attr(attr);
164+
attr=detoast_external_attr(attr);
165165
/* flatteners are not allowed to produce compressed/short output */
166166
Assert(!VARATT_IS_EXTENDED(attr));
167167
}
@@ -192,7 +192,7 @@ heap_tuple_untoast_attr(struct varlena *attr)
192192

193193

194194
/* ----------
195-
*heap_tuple_untoast_attr_slice -
195+
*detoast_attr_slice -
196196
*
197197
*Public entry point to get back part of a toasted value
198198
*from compression or external storage.
@@ -201,7 +201,7 @@ heap_tuple_untoast_attr(struct varlena *attr)
201201
* ----------
202202
*/
203203
structvarlena*
204-
heap_tuple_untoast_attr_slice(structvarlena*attr,
204+
detoast_attr_slice(structvarlena*attr,
205205
int32sliceoffset,int32slicelength)
206206
{
207207
structvarlena*preslice;
@@ -253,13 +253,13 @@ heap_tuple_untoast_attr_slice(struct varlena *attr,
253253
/* nested indirect Datums aren't allowed */
254254
Assert(!VARATT_IS_EXTERNAL_INDIRECT(redirect.pointer));
255255

256-
returnheap_tuple_untoast_attr_slice(redirect.pointer,
256+
returndetoast_attr_slice(redirect.pointer,
257257
sliceoffset,slicelength);
258258
}
259259
elseif (VARATT_IS_EXTERNAL_EXPANDED(attr))
260260
{
261-
/* pass it off toheap_tuple_fetch_attr to flatten */
262-
preslice=heap_tuple_fetch_attr(attr);
261+
/* pass it off todetoast_external_attr to flatten */
262+
preslice=detoast_external_attr(attr);
263263
}
264264
else
265265
preslice=attr;
@@ -771,7 +771,7 @@ toast_decompress_datum(struct varlena *attr)
771771
* toast_decompress_datum_slice -
772772
*
773773
* Decompress the front of a compressed version of a varlena datum.
774-
* offset handling happens inheap_tuple_untoast_attr_slice.
774+
* offset handling happens indetoast_attr_slice.
775775
* Here we just decompress a slice from the front.
776776
*/
777777
staticstructvarlena*

‎src/backend/access/common/indextuple.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ index_form_tuple(TupleDesc tupleDescriptor,
8989
if (VARATT_IS_EXTERNAL(DatumGetPointer(values[i])))
9090
{
9191
untoasted_values[i]=
92-
PointerGetDatum(heap_tuple_fetch_attr((structvarlena*)
92+
PointerGetDatum(detoast_external_attr((structvarlena*)
9393
DatumGetPointer(values[i])));
9494
untoasted_free[i]= true;
9595
}

‎src/backend/access/heap/heapam.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2085,7 +2085,7 @@ heap_prepare_insert(Relation relation, HeapTuple tup, TransactionId xid,
20852085
returntup;
20862086
}
20872087
elseif (HeapTupleHasExternal(tup)||tup->t_len>TOAST_TUPLE_THRESHOLD)
2088-
returntoast_insert_or_update(relation,tup,NULL,options);
2088+
returnheap_toast_insert_or_update(relation,tup,NULL,options);
20892089
else
20902090
returntup;
20912091
}
@@ -2809,7 +2809,7 @@ heap_delete(Relation relation, ItemPointer tid,
28092809
Assert(!HeapTupleHasExternal(&tp));
28102810
}
28112811
elseif (HeapTupleHasExternal(&tp))
2812-
toast_delete(relation,&tp, false);
2812+
heap_toast_delete(relation,&tp, false);
28132813

28142814
/*
28152815
* Mark tuple for invalidation from system caches at next command
@@ -3504,7 +3504,7 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
35043504
if (need_toast)
35053505
{
35063506
/* Note we always use WAL and FSM during updates */
3507-
heaptup=toast_insert_or_update(relation,newtup,&oldtup,0);
3507+
heaptup=heap_toast_insert_or_update(relation,newtup,&oldtup,0);
35083508
newtupsize=MAXALIGN(heaptup->t_len);
35093509
}
35103510
else
@@ -5673,7 +5673,7 @@ heap_abort_speculative(Relation relation, ItemPointer tid)
56735673
if (HeapTupleHasExternal(&tp))
56745674
{
56755675
Assert(!IsToastRelation(relation));
5676-
toast_delete(relation,&tp, true);
5676+
heap_toast_delete(relation,&tp, true);
56775677
}
56785678

56795679
/*

‎src/backend/access/heap/heaptoast.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
*
1313
*
1414
* INTERFACE ROUTINES
15-
*toast_insert_or_update -
15+
*heap_toast_insert_or_update -
1616
*Try to make a given tuple fit into one page by compressing
1717
*or moving off attributes
1818
*
19-
*toast_delete -
19+
*heap_toast_delete -
2020
*Reclaim toast storage when a tuple is deleted
2121
*
2222
*-------------------------------------------------------------------------
@@ -32,13 +32,13 @@
3232

3333

3434
/* ----------
35-
*toast_delete -
35+
*heap_toast_delete -
3636
*
3737
*Cascaded delete toast-entries on DELETE
3838
* ----------
3939
*/
4040
void
41-
toast_delete(Relationrel,HeapTupleoldtup,boolis_speculative)
41+
heap_toast_delete(Relationrel,HeapTupleoldtup,boolis_speculative)
4242
{
4343
TupleDesctupleDesc;
4444
Datumtoast_values[MaxHeapAttributeNumber];
@@ -73,7 +73,7 @@ toast_delete(Relation rel, HeapTuple oldtup, bool is_speculative)
7373

7474

7575
/* ----------
76-
*toast_insert_or_update -
76+
*heap_toast_insert_or_update -
7777
*
7878
*Delete no-longer-used toast-entries and create new ones to
7979
*make the new tuple fit on INSERT or UPDATE
@@ -91,8 +91,8 @@ toast_delete(Relation rel, HeapTuple oldtup, bool is_speculative)
9191
* ----------
9292
*/
9393
HeapTuple
94-
toast_insert_or_update(Relationrel,HeapTuplenewtup,HeapTupleoldtup,
95-
intoptions)
94+
heap_toast_insert_or_update(Relationrel,HeapTuplenewtup,HeapTupleoldtup,
95+
intoptions)
9696
{
9797
HeapTupleresult_tuple;
9898
TupleDesctupleDesc;
@@ -369,7 +369,7 @@ toast_flatten_tuple(HeapTuple tup, TupleDesc tupleDesc)
369369
new_value= (structvarlena*)DatumGetPointer(toast_values[i]);
370370
if (VARATT_IS_EXTERNAL(new_value))
371371
{
372-
new_value=heap_tuple_fetch_attr(new_value);
372+
new_value=detoast_external_attr(new_value);
373373
toast_values[i]=PointerGetDatum(new_value);
374374
toast_free[i]= true;
375375
}
@@ -484,7 +484,7 @@ toast_flatten_tuple_to_datum(HeapTupleHeader tup,
484484
if (VARATT_IS_EXTERNAL(new_value)||
485485
VARATT_IS_COMPRESSED(new_value))
486486
{
487-
new_value=heap_tuple_untoast_attr(new_value);
487+
new_value=detoast_attr(new_value);
488488
toast_values[i]=PointerGetDatum(new_value);
489489
toast_free[i]= true;
490490
}
@@ -494,7 +494,8 @@ toast_flatten_tuple_to_datum(HeapTupleHeader tup,
494494
/*
495495
* Calculate the new size of the tuple.
496496
*
497-
* This should match the reconstruction code in toast_insert_or_update.
497+
* This should match the reconstruction code in
498+
* heap_toast_insert_or_update.
498499
*/
499500
new_header_len=SizeofHeapTupleHeader;
500501
if (has_nulls)
@@ -583,7 +584,7 @@ toast_build_flattened_tuple(TupleDesc tupleDesc,
583584
new_value= (structvarlena*)DatumGetPointer(new_values[i]);
584585
if (VARATT_IS_EXTERNAL(new_value))
585586
{
586-
new_value=heap_tuple_fetch_attr(new_value);
587+
new_value=detoast_external_attr(new_value);
587588
new_values[i]=PointerGetDatum(new_value);
588589
freeable_values[num_to_free++]= (Pointer)new_value;
589590
}

‎src/backend/access/heap/rewriteheap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -664,8 +664,8 @@ raw_heap_insert(RewriteState state, HeapTuple tup)
664664
*/
665665
options |=HEAP_INSERT_NO_LOGICAL;
666666

667-
heaptup=toast_insert_or_update(state->rs_new_rel,tup,NULL,
668-
options);
667+
heaptup=heap_toast_insert_or_update(state->rs_new_rel,tup,NULL,
668+
options);
669669
}
670670
else
671671
heaptup=tup;

‎src/backend/access/table/toast_helper.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,9 @@ toast_tuple_init(ToastTupleContext *ttc)
135135
{
136136
ttc->ttc_attr[i].tai_oldexternal=new_value;
137137
if (att->attstorage=='p')
138-
new_value=heap_tuple_untoast_attr(new_value);
138+
new_value=detoast_attr(new_value);
139139
else
140-
new_value=heap_tuple_fetch_attr(new_value);
140+
new_value=detoast_external_attr(new_value);
141141
ttc->ttc_values[i]=PointerGetDatum(new_value);
142142
ttc->ttc_attr[i].tai_colflags |=TOASTCOL_NEEDS_FREE;
143143
ttc->ttc_flags |= (TOAST_NEEDS_CHANGE |TOAST_NEEDS_FREE);

‎src/backend/executor/tstoreReceiver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ tstoreReceiveSlot_detoast(TupleTableSlot *slot, DestReceiver *self)
133133
{
134134
if (VARATT_IS_EXTERNAL(DatumGetPointer(val)))
135135
{
136-
val=PointerGetDatum(heap_tuple_fetch_attr((structvarlena*)
136+
val=PointerGetDatum(detoast_external_attr((structvarlena*)
137137
DatumGetPointer(val)));
138138
myState->tofree[nfree++]=val;
139139
}

‎src/backend/storage/large_object/inv_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ getdatafield(Form_pg_largeobject tuple,
180180
if (VARATT_IS_EXTENDED(datafield))
181181
{
182182
datafield= (bytea*)
183-
heap_tuple_untoast_attr((structvarlena*)datafield);
183+
detoast_attr((structvarlena*)datafield);
184184
freeit= true;
185185
}
186186
len=VARSIZE(datafield)-VARHDRSZ;

‎src/backend/utils/adt/expandedrecord.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,7 +1159,7 @@ expanded_record_set_field_internal(ExpandedRecordHeader *erh, int fnumber,
11591159
{
11601160
/* Detoasting should be done in short-lived context. */
11611161
oldcxt=MemoryContextSwitchTo(get_short_term_cxt(erh));
1162-
newValue=PointerGetDatum(heap_tuple_fetch_attr((structvarlena*)DatumGetPointer(newValue)));
1162+
newValue=PointerGetDatum(detoast_external_attr((structvarlena*)DatumGetPointer(newValue)));
11631163
MemoryContextSwitchTo(oldcxt);
11641164
}
11651165
else
@@ -1305,7 +1305,7 @@ expanded_record_set_fields(ExpandedRecordHeader *erh,
13051305
if (expand_external)
13061306
{
13071307
/* Detoast as requested while copying the value */
1308-
newValue=PointerGetDatum(heap_tuple_fetch_attr((structvarlena*)DatumGetPointer(newValue)));
1308+
newValue=PointerGetDatum(detoast_external_attr((structvarlena*)DatumGetPointer(newValue)));
13091309
}
13101310
else
13111311
{

‎src/backend/utils/fmgr/fmgr.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1739,7 +1739,7 @@ struct varlena *
17391739
pg_detoast_datum(structvarlena*datum)
17401740
{
17411741
if (VARATT_IS_EXTENDED(datum))
1742-
returnheap_tuple_untoast_attr(datum);
1742+
returndetoast_attr(datum);
17431743
else
17441744
returndatum;
17451745
}
@@ -1748,7 +1748,7 @@ struct varlena *
17481748
pg_detoast_datum_copy(structvarlena*datum)
17491749
{
17501750
if (VARATT_IS_EXTENDED(datum))
1751-
returnheap_tuple_untoast_attr(datum);
1751+
returndetoast_attr(datum);
17521752
else
17531753
{
17541754
/* Make a modifiable copy of the varlena object */
@@ -1764,14 +1764,14 @@ struct varlena *
17641764
pg_detoast_datum_slice(structvarlena*datum,int32first,int32count)
17651765
{
17661766
/* Only get the specified portion from the toast rel */
1767-
returnheap_tuple_untoast_attr_slice(datum,first,count);
1767+
returndetoast_attr_slice(datum,first,count);
17681768
}
17691769

17701770
structvarlena*
17711771
pg_detoast_datum_packed(structvarlena*datum)
17721772
{
17731773
if (VARATT_IS_COMPRESSED(datum)||VARATT_IS_EXTERNAL(datum))
1774-
returnheap_tuple_untoast_attr(datum);
1774+
returndetoast_attr(datum);
17751775
else
17761776
returndatum;
17771777
}

‎src/include/access/detoast.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,34 +44,34 @@ do { \
4444
#defineINDIRECT_POINTER_SIZE (VARHDRSZ_EXTERNAL + sizeof(varatt_indirect))
4545

4646
/* ----------
47-
*heap_tuple_fetch_attr() -
47+
*detoast_external_attr() -
4848
*
4949
*Fetches an external stored attribute from the toast
5050
*relation. Does NOT decompress it, if stored external
5151
*in compressed format.
5252
* ----------
5353
*/
54-
externstructvarlena*heap_tuple_fetch_attr(structvarlena*attr);
54+
externstructvarlena*detoast_external_attr(structvarlena*attr);
5555

5656
/* ----------
57-
*heap_tuple_untoast_attr() -
57+
*detoast_attr() -
5858
*
5959
*Fully detoasts one attribute, fetching and/or decompressing
6060
*it as needed.
6161
* ----------
6262
*/
63-
externstructvarlena*heap_tuple_untoast_attr(structvarlena*attr);
63+
externstructvarlena*detoast_attr(structvarlena*attr);
6464

6565
/* ----------
66-
*heap_tuple_untoast_attr_slice() -
66+
*detoast_attr_slice() -
6767
*
6868
*Fetches only the specified portion of an attribute.
6969
*(Handles all cases for attribute storage)
7070
* ----------
7171
*/
72-
externstructvarlena*heap_tuple_untoast_attr_slice(structvarlena*attr,
73-
int32sliceoffset,
74-
int32slicelength);
72+
externstructvarlena*detoast_attr_slice(structvarlena*attr,
73+
int32sliceoffset,
74+
int32slicelength);
7575

7676
/* ----------
7777
* toast_raw_datum_size -

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp