Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8121ab8

Browse files
author
Amit Kapila
committed
Cosmetic improvements for faster column addition.
Changed the name of few structure members for the sake of clarity and removed spurious whitespace. Reported-by: Amit Kapila Author: Amit Kapila, based on suggestion by Andrew Dunstan Reviewed-by: Alvaro Herrera Discussion: https://postgr.es/m/CAA4eK1K2znsFpC+NQ9A4vxT4uDxADN4RmvHX0L6Y=aHVo9gB4Q@mail.gmail.com
1 parent f49a80c commit 8121ab8

File tree

4 files changed

+26
-28
lines changed

4 files changed

+26
-28
lines changed

src/backend/access/common/heaptuple.c

+10-11
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@ getmissingattr(TupleDesc tupleDesc,
100100

101101
attrmiss = tupleDesc->constr->missing + (attnum - 1);
102102

103-
if (attrmiss->ammissingPresent)
103+
if (attrmiss->am_present)
104104
{
105105
*isnull = false;
106-
return attrmiss->ammissing;
106+
return attrmiss->am_value;
107107
}
108108
}
109109

@@ -142,9 +142,8 @@ slot_getmissingattrs(TupleTableSlot *slot, int startAttNum, int lastAttNum)
142142
missattnum < lastAttNum;
143143
missattnum++)
144144
{
145-
slot->tts_values[missattnum] = attrmiss[missattnum].ammissing;
146-
slot->tts_isnull[missattnum] =
147-
!attrmiss[missattnum].ammissingPresent;
145+
slot->tts_values[missattnum] = attrmiss[missattnum].am_value;
146+
slot->tts_isnull[missattnum] = !attrmiss[missattnum].am_present;
148147
}
149148
}
150149
}
@@ -822,7 +821,7 @@ expand_tuple(HeapTuple *targetHeapTuple,
822821
firstmissingnum < natts;
823822
firstmissingnum++)
824823
{
825-
if (attrmiss[firstmissingnum].ammissingPresent)
824+
if (attrmiss[firstmissingnum].am_present)
826825
break;
827826
}
828827

@@ -844,18 +843,18 @@ expand_tuple(HeapTuple *targetHeapTuple,
844843
attnum < natts;
845844
attnum++)
846845
{
847-
if (attrmiss[attnum].ammissingPresent)
846+
if (attrmiss[attnum].am_present)
848847
{
849848
Form_pg_attribute att = TupleDescAttr(tupleDesc, attnum);
850849

851850
targetDataLen = att_align_datum(targetDataLen,
852851
att->attalign,
853852
att->attlen,
854-
attrmiss[attnum].ammissing);
853+
attrmiss[attnum].am_value);
855854

856855
targetDataLen = att_addlength_pointer(targetDataLen,
857856
att->attlen,
858-
attrmiss[attnum].ammissing);
857+
attrmiss[attnum].am_value);
859858
}
860859
else
861860
{
@@ -981,14 +980,14 @@ expand_tuple(HeapTuple *targetHeapTuple,
981980

982981
Form_pg_attribute attr = TupleDescAttr(tupleDesc, attnum);
983982

984-
if (attrmiss && attrmiss[attnum].ammissingPresent)
983+
if (attrmiss && attrmiss[attnum].am_present)
985984
{
986985
fill_val(attr,
987986
nullBits ? &nullBits : NULL,
988987
&bitMask,
989988
&targetData,
990989
infoMask,
991-
attrmiss[attnum].ammissing,
990+
attrmiss[attnum].am_value,
992991
false);
993992
}
994993
else

src/backend/access/common/tupdesc.c

+9-9
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,13 @@ CreateTupleDescCopyConstr(TupleDesc tupdesc)
185185
memcpy(cpy->missing, constr->missing, tupdesc->natts * sizeof(AttrMissing));
186186
for (i = tupdesc->natts - 1; i >= 0; i--)
187187
{
188-
if (constr->missing[i].ammissingPresent)
188+
if (constr->missing[i].am_present)
189189
{
190190
Form_pg_attribute attr = TupleDescAttr(tupdesc, i);
191191

192-
cpy->missing[i].ammissing = datumCopy(constr->missing[i].ammissing,
193-
attr->attbyval,
194-
attr->attlen);
192+
cpy->missing[i].am_value = datumCopy(constr->missing[i].am_value,
193+
attr->attbyval,
194+
attr->attlen);
195195
}
196196
}
197197
}
@@ -337,9 +337,9 @@ FreeTupleDesc(TupleDesc tupdesc)
337337

338338
for (i = tupdesc->natts - 1; i >= 0; i--)
339339
{
340-
if (attrmiss[i].ammissingPresent
340+
if (attrmiss[i].am_present
341341
&& !TupleDescAttr(tupdesc, i)->attbyval)
342-
pfree(DatumGetPointer(attrmiss[i].ammissing));
342+
pfree(DatumGetPointer(attrmiss[i].am_value));
343343
}
344344
pfree(attrmiss);
345345
}
@@ -512,13 +512,13 @@ equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2)
512512
AttrMissing *missval1 = constr1->missing + i;
513513
AttrMissing *missval2 = constr2->missing + i;
514514

515-
if (missval1->ammissingPresent != missval2->ammissingPresent)
515+
if (missval1->am_present != missval2->am_present)
516516
return false;
517-
if (missval1->ammissingPresent)
517+
if (missval1->am_present)
518518
{
519519
Form_pg_attribute missatt1 = TupleDescAttr(tupdesc1, i);
520520

521-
if (!datumIsEqual(missval1->ammissing, missval2->ammissing,
521+
if (!datumIsEqual(missval1->am_value, missval2->am_value,
522522
missatt1->attbyval, missatt1->attlen))
523523
return false;
524524
}

src/backend/utils/cache/relcache.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -614,18 +614,18 @@ RelationBuildTupleDesc(Relation relation)
614614
if (attp->attbyval)
615615
{
616616
/* for copy by val just copy the datum direct */
617-
attrmiss[attnum - 1].ammissing = missval;
617+
attrmiss[attnum - 1].am_value = missval;
618618
}
619619
else
620620
{
621621
/* otherwise copy in the correct context */
622622
oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
623-
attrmiss[attnum - 1].ammissing = datumCopy(missval,
624-
attp->attbyval,
625-
attp->attlen);
623+
attrmiss[attnum - 1].am_value = datumCopy(missval,
624+
attp->attbyval,
625+
attp->attlen);
626626
MemoryContextSwitchTo(oldcxt);
627627
}
628-
attrmiss[attnum - 1].ammissingPresent = true;
628+
attrmiss[attnum - 1].am_present = true;
629629
}
630630
}
631631
need--;

src/include/access/tupdesc_details.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@
1919
* Structure used to represent value to be used when the attribute is not
2020
* present at all in a tuple, i.e. when the column was created after the tuple
2121
*/
22-
2322
typedef struct attrMissing
2423
{
25-
bool ammissingPresent; /* true if non-NULL missing value exists */
26-
Datum ammissing; /* value when attribute is missing */
24+
bool am_present; /* true if non-NULL missing value exists */
25+
Datum am_value; /* value when attribute is missing */
2726
} AttrMissing;
2827

2928
#endif /* TUPDESC_DETAILS_H */

0 commit comments

Comments
 (0)