1616 *
1717 *
1818 * IDENTIFICATION
19- * $PostgreSQL: pgsql/src/backend/access/common/heaptuple.c,v 1.113 2007/01/05 22:19:21 momjian Exp $
19+ * $PostgreSQL: pgsql/src/backend/access/common/heaptuple.c,v 1.114 2007/01/09 22:00:59 momjian Exp $
2020 *
2121 *-------------------------------------------------------------------------
2222 */
@@ -295,7 +295,7 @@ DataFill(char *data,
295295bool
296296heap_attisnull (HeapTuple tup ,int attnum )
297297{
298- if (attnum > (int )tup -> t_data -> t_natts )
298+ if (attnum > (int )HeapTupleHeaderGetNatts ( tup -> t_data ) )
299299return true;
300300
301301if (attnum > 0 )
@@ -474,6 +474,7 @@ nocachegetattr(HeapTuple tuple,
474474{
475475int j = 1 ;
476476long off ;
477+ int natts = HeapTupleHeaderGetNatts (tup );
477478
478479/*
479480 * need to set cache for some atts
@@ -488,7 +489,7 @@ nocachegetattr(HeapTuple tuple,
488489
489490for (;j <=attnum ||
490491/* Can we compute more? We will probably need them */
491- (j < tup -> t_natts &&
492+ (j < natts &&
492493att [j ]-> attcacheoff == -1 &&
493494 (HeapTupleNoNulls (tuple )|| !att_isnull (j ,bp ))&&
494495 (HeapTupleAllFixed (tuple )|| att [j ]-> attlen > 0 ));j ++ )
@@ -739,7 +740,7 @@ heap_form_tuple(TupleDesc tupleDescriptor,
739740HeapTupleHeaderSetTypeId (td ,tupleDescriptor -> tdtypeid );
740741HeapTupleHeaderSetTypMod (td ,tupleDescriptor -> tdtypmod );
741742
742- td -> t_natts = numberOfAttributes ;
743+ HeapTupleHeaderSetNatts ( td , numberOfAttributes ) ;
743744td -> t_hoff = hoff ;
744745
745746if (tupleDescriptor -> tdhasoid )/* else leave infomask = 0 */
@@ -846,7 +847,7 @@ heap_formtuple(TupleDesc tupleDescriptor,
846847HeapTupleHeaderSetTypeId (td ,tupleDescriptor -> tdtypeid );
847848HeapTupleHeaderSetTypMod (td ,tupleDescriptor -> tdtypmod );
848849
849- td -> t_natts = numberOfAttributes ;
850+ HeapTupleHeaderSetNatts ( td , numberOfAttributes ) ;
850851td -> t_hoff = hoff ;
851852
852853if (tupleDescriptor -> tdhasoid )/* else leave infomask = 0 */
@@ -1035,7 +1036,7 @@ heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc,
10351036bits8 * bp = tup -> t_bits ;/* ptr to null bitmap in tuple */
10361037bool slow = false;/* can we use/set attcacheoff? */
10371038
1038- natts = tup -> t_natts ;
1039+ natts = HeapTupleHeaderGetNatts ( tup ) ;
10391040
10401041/*
10411042 * In inheritance situations, it is possible that the given tuple actually
@@ -1128,7 +1129,7 @@ heap_deformtuple(HeapTuple tuple,
11281129bits8 * bp = tup -> t_bits ;/* ptr to null bitmap in tuple */
11291130bool slow = false;/* can we use/set attcacheoff? */
11301131
1131- natts = tup -> t_natts ;
1132+ natts = HeapTupleHeaderGetNatts ( tup ) ;
11321133
11331134/*
11341135 * In inheritance situations, it is possible that the given tuple actually
@@ -1335,7 +1336,7 @@ slot_getattr(TupleTableSlot *slot, int attnum, bool *isnull)
13351336 * than the tupdesc.)
13361337 */
13371338tup = tuple -> t_data ;
1338- if (attnum > tup -> t_natts )
1339+ if (attnum > HeapTupleHeaderGetNatts ( tup ) )
13391340{
13401341* isnull = true;
13411342return (Datum )0 ;
@@ -1401,7 +1402,7 @@ slot_getallattrs(TupleTableSlot *slot)
14011402/*
14021403 * load up any slots available from physical tuple
14031404 */
1404- attnum = tuple -> t_data -> t_natts ;
1405+ attnum = HeapTupleHeaderGetNatts ( tuple -> t_data ) ;
14051406attnum = Min (attnum ,tdesc_natts );
14061407
14071408slot_deform_tuple (slot ,attnum );
@@ -1448,7 +1449,7 @@ slot_getsomeattrs(TupleTableSlot *slot, int attnum)
14481449/*
14491450 * load up any slots available from physical tuple
14501451 */
1451- attno = tuple -> t_data -> t_natts ;
1452+ attno = HeapTupleHeaderGetNatts ( tuple -> t_data ) ;
14521453attno = Min (attno ,attnum );
14531454
14541455slot_deform_tuple (slot ,attno );
@@ -1601,7 +1602,7 @@ heap_form_minimal_tuple(TupleDesc tupleDescriptor,
16011602 * And fill in the information.
16021603 */
16031604tuple -> t_len = len ;
1604- tuple -> t_natts = numberOfAttributes ;
1605+ HeapTupleHeaderSetNatts ( tuple , numberOfAttributes ) ;
16051606tuple -> t_hoff = hoff + MINIMAL_TUPLE_OFFSET ;
16061607
16071608if (tupleDescriptor -> tdhasoid )/* else leave infomask = 0 */
@@ -1663,7 +1664,7 @@ heap_tuple_from_minimal_tuple(MinimalTuple mtup)
16631664result -> t_tableOid = InvalidOid ;
16641665result -> t_data = (HeapTupleHeader ) ((char * )result + HEAPTUPLESIZE );
16651666memcpy ((char * )result -> t_data + MINIMAL_TUPLE_OFFSET ,mtup ,mtup -> t_len );
1666- memset (result -> t_data ,0 , offsetof(HeapTupleHeaderData ,t_natts ));
1667+ memset (result -> t_data ,0 , offsetof(HeapTupleHeaderData ,t_infomask2 ));
16671668return result ;
16681669}
16691670
@@ -1729,7 +1730,7 @@ heap_addheader(int natts,/* max domain index */
17291730
17301731/* we don't bother to fill the Datum fields */
17311732
1732- td -> t_natts = natts ;
1733+ HeapTupleHeaderSetNatts ( td , natts ) ;
17331734td -> t_hoff = hoff ;
17341735
17351736if (withoid )/* else leave infomask = 0 */