[Bizgres-general] Re: Latest bitmap patch results. (tuple offset out of range)

Mark Kirkwood markir at paradise.net.nz
Wed Feb 1 10:41:50 GMT 2006


Jie Zhang wrote:
> Mark,
> 
> 
>>
>>To rule the 'I did something silly' type of error, I changed bitmap.h to 
>>use 32-bit words, and after a rebuild and re-initialize, these errors do 
>>*not* appear. After a change back to 8-bit words, the errors come back :-(
>>
>>
>>I did wonder about alignment of uint8 (which is really unsigned char) on 
>>this platform (FreeBSD/x86), however it is 1 byte... any ideas?
>>
> 
> 
> This is a bug. The problem is because the code incorrectly handles the first bunch of consecutive zeros in a bitmap when the number of these zeros are greater than (2^(word_size))*word_size.
> 
> A patch (on top of 01/15 patch) is attached.
> 

Excellent - fixes it for me! Good timing, I was just about to seriously
read up on the bitmap insertion/creation process to try to figure this
out - don't need to now :-)

Note that here is something funny about your mailer (suspect tabs ->
spaces conversion), I couldn't apply the patch as attached, so redid it
(attached for completeness).

Cheers

Mark

-------------- next part --------------
*** src/backend/access/bitmap/bitmaputil.c.orig	Wed Feb  1 23:07:51 2006
--- src/backend/access/bitmap/bitmaputil.c	Wed Feb  1 23:11:37 2006
***************
*** 49,59 ****
  
  	else
  	{
  		bmitem->bm_last_compword = 
! 			BM_MAKE_FILL_WORD
! 				(0,(currTidNumber-1)/BM_HRL_WORD_SIZE);
  		bmitem->bm_last_word = LITERAL_ALL_ZERO;
  		bmitem->bm_last_two_headerbits = 2;
  	}
  
  	return bmitem;
--- 49,74 ----
  
  	else
  	{
+ 		uint32		numOfTotalFillWords;
+ 		BM_HRL_WORD	numOfFillWords;
+ 		uint32		loopNo = 0;
+ 
+ 		numOfTotalFillWords = (currTidNumber-1)/BM_HRL_WORD_SIZE;
+ 
+ 		numOfFillWords =
+ 			(numOfTotalFillWords >= MAX_FILL_LENGTH) ? MAX_FILL_LENGTH :
+ 			numOfTotalFillWords;
+ 
  		bmitem->bm_last_compword = 
! 			BM_MAKE_FILL_WORD (0, numOfFillWords);
  		bmitem->bm_last_word = LITERAL_ALL_ZERO;
  		bmitem->bm_last_two_headerbits = 2;
+ 
+ 		/* If number of zeros is too much for one word, then
+ 			we set bm_last_setbit so that the remaining zeros can
+ 			be handled outside. */
+ 		if (numOfTotalFillWords > numOfFillWords)
+ 			bmitem->bm_last_setbit = numOfFillWords*BM_HRL_WORD_SIZE;
  	}
  
  	return bmitem;



More information about the Bizgres-general mailing list