Re: [PATCHES] Last infomask bit

2007-01-09 Thread Bruce Momjian

Patch applied.  Thanks.

I added a comment about the unused bits in the header file.

---



Heikki Linnakangas wrote:
 Hi,
 
 We're running out of infomask bits in the tuple header. I bumped into 
 this as I tried to apply both the phantom command ids patch, and the HOT 
 patch simultaneously. They both require one infomask bit, so they 
 conflicted.
 
 This has been discussed before; I think the best approach is to use the 
 extra bits available in t_natts field. Here's a patch that doesn't do 
 anything interesting in itself, but it renames the t_natts field to 
 t_infomask2, with 11 bits reserved for the number of attributes and the 
 other 5 bits available for future use. All references to the old t_natts 
 field are replaced with a HeapTupleHeaderGetNatts accessor macro.
 
 I believe it would actually be even better to combine the t_natts and 
 t_infomask fields to a single 32-bit infomask field. I refrained from 
 doing that for now because it would've required shifting all the 
 existing infomask flags.
 
 Naturally, there's no point applying this before we actually need more 
 infobits, but it's good to be prepared.
 
 -- 
Heikki Linnakangas
EnterpriseDB   http://www.enterprisedb.com

[ text/x-patch is unsupported, treating like TEXT/PLAIN ]

 Index: src/backend/access/common/heaptuple.c
 ===
 RCS file: 
 /home/hlinnaka/pgcvsrepository/pgsql/src/backend/access/common/heaptuple.c,v
 retrieving revision 1.112
 diff -c -r1.112 heaptuple.c
 *** src/backend/access/common/heaptuple.c 23 Nov 2006 05:27:18 -  
 1.112
 --- src/backend/access/common/heaptuple.c 5 Jan 2007 13:11:10 -
 ***
 *** 295,301 
   bool
   heap_attisnull(HeapTuple tup, int attnum)
   {
 ! if (attnum  (int) tup-t_data-t_natts)
   return true;
   
   if (attnum  0)
 --- 295,301 
   bool
   heap_attisnull(HeapTuple tup, int attnum)
   {
 ! if (attnum  (int) HeapTupleHeaderGetNatts(tup-t_data))
   return true;
   
   if (attnum  0)
 ***
 *** 474,479 
 --- 474,480 
   {
   int j = 1;
   longoff;
 + int natts = HeapTupleHeaderGetNatts(tup);
   
   /*
* need to set cache for some atts
 ***
 *** 488,494 
   
   for (; j = attnum ||
   /* Can we compute more?  We will probably need them */
 !  (j  tup-t_natts 
 att[j]-attcacheoff == -1 
 (HeapTupleNoNulls(tuple) || !att_isnull(j, bp)) 
 (HeapTupleAllFixed(tuple) || att[j]-attlen  0)); 
 j++)
 --- 489,495 
   
   for (; j = attnum ||
   /* Can we compute more?  We will probably need them */
 !  (j  natts 
 att[j]-attcacheoff == -1 
 (HeapTupleNoNulls(tuple) || !att_isnull(j, bp)) 
 (HeapTupleAllFixed(tuple) || att[j]-attlen  0)); 
 j++)
 ***
 *** 739,745 
   HeapTupleHeaderSetTypeId(td, tupleDescriptor-tdtypeid);
   HeapTupleHeaderSetTypMod(td, tupleDescriptor-tdtypmod);
   
 ! td-t_natts = numberOfAttributes;
   td-t_hoff = hoff;
   
   if (tupleDescriptor-tdhasoid)  /* else leave infomask = 0 */
 --- 740,746 
   HeapTupleHeaderSetTypeId(td, tupleDescriptor-tdtypeid);
   HeapTupleHeaderSetTypMod(td, tupleDescriptor-tdtypmod);
   
 ! HeapTupleHeaderSetNatts(td, numberOfAttributes);
   td-t_hoff = hoff;
   
   if (tupleDescriptor-tdhasoid)  /* else leave infomask = 0 */
 ***
 *** 846,852 
   HeapTupleHeaderSetTypeId(td, tupleDescriptor-tdtypeid);
   HeapTupleHeaderSetTypMod(td, tupleDescriptor-tdtypmod);
   
 ! td-t_natts = numberOfAttributes;
   td-t_hoff = hoff;
   
   if (tupleDescriptor-tdhasoid)  /* else leave infomask = 0 */
 --- 847,853 
   HeapTupleHeaderSetTypeId(td, tupleDescriptor-tdtypeid);
   HeapTupleHeaderSetTypMod(td, tupleDescriptor-tdtypmod);
   
 ! HeapTupleHeaderSetNatts(td, numberOfAttributes);
   td-t_hoff = hoff;
   
   if (tupleDescriptor-tdhasoid)  /* else leave infomask = 0 */
 ***
 *** 1035,1041 
   bits8  *bp = tup-t_bits;   /* ptr to null bitmap in tuple 
 */
   boolslow = false;   /* can we use/set attcacheoff? */
   
 ! natts = tup-t_natts;
   
   /*
* In inheritance situations, it is possible that the given tuple 
 actually
 --- 1036,1042 
   bits8  *bp = tup-t_bits;   /* ptr to null bitmap in tuple 
 */
   boolslow = false;   /* can we use/set attcacheoff? */
   
 ! natts = HeapTupleHeaderGetNatts(tup);
   

Re: [PATCHES] Last infomask bit

2007-01-09 Thread Tom Lane
Bruce Momjian [EMAIL PROTECTED] writes:
 Patch applied.  Thanks.
 I added a comment about the unused bits in the header file.

Has anyone bothered to measure the overhead added by having to mask to
fetch or store the natts value?  This is not a zero-cost improvement.

regards, tom lane

---(end of broadcast)---
TIP 2: Don't 'kill -9' the postmaster


Re: [PATCHES] Last infomask bit

2007-01-05 Thread Tom Lane
Heikki Linnakangas [EMAIL PROTECTED] writes:
  I believe it would actually be even better to combine the t_natts and 
 t_infomask fields to a single 32-bit infomask field.

That's not happening, because the alignment is wrong ...unless maybe
we switch this field to fall before t_ctid, but that would screw up
the MinimalTuple hack.

regards, tom lane

---(end of broadcast)---
TIP 5: don't forget to increase your free space map settings