83
83
#define VARLENA_ATT_IS_PACKABLE (att ) \
84
84
((att)->attstorage != TYPSTORAGE_PLAIN)
85
85
86
- /* FormData_pg_attribute.attstorage != TYPSTORAGE_PLAIN and an attlen of -1 */
87
- #define COMPACT_ATTR_IS_PACKABLE (att ) \
88
- ((att)->attlen == -1 && (att)->attispackable)
89
-
90
86
/*
91
87
* Setup for caching pass-by-ref missing attributes in a way that survives
92
88
* tupleDesc destruction.
@@ -151,12 +147,12 @@ Datum
151
147
getmissingattr (TupleDesc tupleDesc ,
152
148
int attnum , bool * isnull )
153
149
{
154
- CompactAttribute * att ;
150
+ Form_pg_attribute att ;
155
151
156
152
Assert (attnum <= tupleDesc -> natts );
157
153
Assert (attnum > 0 );
158
154
159
- att = TupleDescCompactAttr (tupleDesc , attnum - 1 );
155
+ att = TupleDescAttr (tupleDesc , attnum - 1 );
160
156
161
157
if (att -> atthasmissing )
162
158
{
@@ -227,15 +223,15 @@ heap_compute_data_size(TupleDesc tupleDesc,
227
223
for (i = 0 ; i < numberOfAttributes ; i ++ )
228
224
{
229
225
Datum val ;
230
- CompactAttribute * atti ;
226
+ Form_pg_attribute atti ;
231
227
232
228
if (isnull [i ])
233
229
continue ;
234
230
235
231
val = values [i ];
236
- atti = TupleDescCompactAttr (tupleDesc , i );
232
+ atti = TupleDescAttr (tupleDesc , i );
237
233
238
- if (COMPACT_ATTR_IS_PACKABLE (atti ) &&
234
+ if (ATT_IS_PACKABLE (atti ) &&
239
235
VARATT_CAN_MAKE_SHORT (DatumGetPointer (val )))
240
236
{
241
237
/*
@@ -272,7 +268,7 @@ heap_compute_data_size(TupleDesc tupleDesc,
272
268
* Fill in either a data value or a bit in the null bitmask
273
269
*/
274
270
static inline void
275
- fill_val (CompactAttribute * att ,
271
+ fill_val (Form_pg_attribute att ,
276
272
bits8 * * bit ,
277
273
int * bitmask ,
278
274
char * * dataP ,
@@ -353,7 +349,8 @@ fill_val(CompactAttribute *att,
353
349
data_length = VARSIZE_SHORT (val );
354
350
memcpy (data , val , data_length );
355
351
}
356
- else if (att -> attispackable && VARATT_CAN_MAKE_SHORT (val ))
352
+ else if (VARLENA_ATT_IS_PACKABLE (att ) &&
353
+ VARATT_CAN_MAKE_SHORT (val ))
357
354
{
358
355
/* convert to short varlena -- no alignment */
359
356
data_length = VARATT_CONVERTED_SHORT_SIZE (val );
@@ -430,7 +427,7 @@ heap_fill_tuple(TupleDesc tupleDesc,
430
427
431
428
for (i = 0 ; i < numberOfAttributes ; i ++ )
432
429
{
433
- CompactAttribute * attr = TupleDescCompactAttr (tupleDesc , i );
430
+ Form_pg_attribute attr = TupleDescAttr (tupleDesc , i );
434
431
435
432
fill_val (attr ,
436
433
bitP ? & bitP : NULL ,
@@ -464,8 +461,7 @@ heap_attisnull(HeapTuple tup, int attnum, TupleDesc tupleDesc)
464
461
Assert (!tupleDesc || attnum <= tupleDesc -> natts );
465
462
if (attnum > (int ) HeapTupleHeaderGetNatts (tup -> t_data ))
466
463
{
467
- if (tupleDesc &&
468
- TupleDescCompactAttr (tupleDesc , attnum - 1 )-> atthasmissing )
464
+ if (tupleDesc && TupleDescAttr (tupleDesc , attnum - 1 )-> atthasmissing )
469
465
return false;
470
466
else
471
467
return true;
@@ -574,13 +570,13 @@ nocachegetattr(HeapTuple tup,
574
570
575
571
if (!slow )
576
572
{
577
- CompactAttribute * att ;
573
+ Form_pg_attribute att ;
578
574
579
575
/*
580
576
* If we get here, there are no nulls up to and including the target
581
577
* attribute. If we have a cached offset, we can use it.
582
578
*/
583
- att = TupleDescCompactAttr (tupleDesc , attnum );
579
+ att = TupleDescAttr (tupleDesc , attnum );
584
580
if (att -> attcacheoff >= 0 )
585
581
return fetchatt (att , tp + att -> attcacheoff );
586
582
@@ -595,7 +591,7 @@ nocachegetattr(HeapTuple tup,
595
591
596
592
for (j = 0 ; j <= attnum ; j ++ )
597
593
{
598
- if (TupleDescCompactAttr (tupleDesc , j )-> attlen <= 0 )
594
+ if (TupleDescAttr (tupleDesc , j )-> attlen <= 0 )
599
595
{
600
596
slow = true;
601
597
break ;
@@ -618,18 +614,18 @@ nocachegetattr(HeapTuple tup,
618
614
* fixed-width columns, in hope of avoiding future visits to this
619
615
* routine.
620
616
*/
621
- TupleDescCompactAttr (tupleDesc , 0 )-> attcacheoff = 0 ;
617
+ TupleDescAttr (tupleDesc , 0 )-> attcacheoff = 0 ;
622
618
623
619
/* we might have set some offsets in the slow path previously */
624
- while (j < natts && TupleDescCompactAttr (tupleDesc , j )-> attcacheoff > 0 )
620
+ while (j < natts && TupleDescAttr (tupleDesc , j )-> attcacheoff > 0 )
625
621
j ++ ;
626
622
627
- off = TupleDescCompactAttr (tupleDesc , j - 1 )-> attcacheoff +
628
- TupleDescCompactAttr (tupleDesc , j - 1 )-> attlen ;
623
+ off = TupleDescAttr (tupleDesc , j - 1 )-> attcacheoff +
624
+ TupleDescAttr (tupleDesc , j - 1 )-> attlen ;
629
625
630
626
for (; j < natts ; j ++ )
631
627
{
632
- CompactAttribute * att = TupleDescCompactAttr (tupleDesc , j );
628
+ Form_pg_attribute att = TupleDescAttr (tupleDesc , j );
633
629
634
630
if (att -> attlen <= 0 )
635
631
break ;
@@ -643,7 +639,7 @@ nocachegetattr(HeapTuple tup,
643
639
644
640
Assert (j > attnum );
645
641
646
- off = TupleDescCompactAttr (tupleDesc , attnum )-> attcacheoff ;
642
+ off = TupleDescAttr (tupleDesc , attnum )-> attcacheoff ;
647
643
}
648
644
else
649
645
{
@@ -663,7 +659,7 @@ nocachegetattr(HeapTuple tup,
663
659
off = 0 ;
664
660
for (i = 0 ;; i ++ ) /* loop exit is at "break" */
665
661
{
666
- CompactAttribute * att = TupleDescCompactAttr (tupleDesc , i );
662
+ Form_pg_attribute att = TupleDescAttr (tupleDesc , i );
667
663
668
664
if (HeapTupleHasNulls (tup ) && att_isnull (i , bp ))
669
665
{
@@ -711,7 +707,7 @@ nocachegetattr(HeapTuple tup,
711
707
}
712
708
}
713
709
714
- return fetchatt (TupleDescCompactAttr (tupleDesc , attnum ), tp + off );
710
+ return fetchatt (TupleDescAttr (tupleDesc , attnum ), tp + off );
715
711
}
716
712
717
713
/* ----------------
@@ -896,7 +892,7 @@ expand_tuple(HeapTuple *targetHeapTuple,
896
892
{
897
893
if (attrmiss [attnum ].am_present )
898
894
{
899
- CompactAttribute * att = TupleDescCompactAttr (tupleDesc , attnum );
895
+ Form_pg_attribute att = TupleDescAttr (tupleDesc , attnum );
900
896
901
897
targetDataLen = att_align_datum (targetDataLen ,
902
898
att -> attalign ,
@@ -1024,7 +1020,8 @@ expand_tuple(HeapTuple *targetHeapTuple,
1024
1020
/* Now fill in the missing values */
1025
1021
for (attnum = sourceNatts ; attnum < natts ; attnum ++ )
1026
1022
{
1027
- CompactAttribute * attr = TupleDescCompactAttr (tupleDesc , attnum );
1023
+
1024
+ Form_pg_attribute attr = TupleDescAttr (tupleDesc , attnum );
1028
1025
1029
1026
if (attrmiss && attrmiss [attnum ].am_present )
1030
1027
{
@@ -1373,7 +1370,7 @@ heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc,
1373
1370
1374
1371
for (attnum = 0 ; attnum < natts ; attnum ++ )
1375
1372
{
1376
- CompactAttribute * thisatt = TupleDescCompactAttr (tupleDesc , attnum );
1373
+ Form_pg_attribute thisatt = TupleDescAttr (tupleDesc , attnum );
1377
1374
1378
1375
if (hasnulls && att_isnull (attnum , bp ))
1379
1376
{
0 commit comments