From e36ede247ef94ca320bdb9d6bbd89119a877726c Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Wed, 12 Nov 2008 00:47:54 +0000 Subject: [PATCH] 2008-11-12 01:48 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/source/rdd/dbfcdx/dbfcdx1.c ! fixed bug in joined leaf pages size calculation which activated error massage enabled by HB_CDX_DBGCODE_EXT macro. Thanks to Saulius for reporting the problem. --- harbour/ChangeLog | 6 ++++++ harbour/source/rdd/dbfcdx/dbfcdx1.c | 27 +++++++++++++++++++++++---- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 9bf07c0d3e..17edfbebaf 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,12 @@ 2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2008-11-12 01:48 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/source/rdd/dbfcdx/dbfcdx1.c + ! fixed bug in joined leaf pages size calculation which activated + error massage enabled by HB_CDX_DBGCODE_EXT macro. + Thanks to Saulius for reporting the problem. + 2008-11-11 21:57 UTC+0100 Viktor Szakats (harbour.01 syenar hu) * source/common/hbverdsp.c * Streamlined the /build information screen. It's now diff --git a/harbour/source/rdd/dbfcdx/dbfcdx1.c b/harbour/source/rdd/dbfcdx/dbfcdx1.c index 4b7ebde2db..dc43305d43 100644 --- a/harbour/source/rdd/dbfcdx/dbfcdx1.c +++ b/harbour/source/rdd/dbfcdx/dbfcdx1.c @@ -1622,6 +1622,26 @@ static ULONG hb_cdxPageGetKeyPage( LPCDXPAGE pPage, int iKey ) ( iKey + 1 ) * ( pPage->TagParent->uiLen + 8 ) - 4 ] ); } +/* + * get number of duplicated keys from key in leaf index page + */ +static SHORT hb_cdxPageGetKeyTrl( LPCDXPAGE pPage, SHORT iKey ) +{ +#ifdef HB_CDX_DBGCODE_EXT + if ( iKey < 0 || iKey >= pPage->iKeys ) + hb_cdxErrInternal( "hb_cdxPageGetKeyTrl: wrong iKey index." ); + if ( ( pPage->PageType & CDX_NODE_LEAF ) == 0 ) + hb_cdxErrInternal( "hb_cdxPageGetKeyTrl: page is not a leaf." ); +#endif + if( pPage->pKeyBuf ) + return pPage->pKeyBuf[ ( iKey + 1 ) * ( pPage->TagParent->uiLen + 6 ) - 1 ]; + else + { + BYTE * ptr = &pPage->node.extNode.keyPool[ ( iKey + 1 ) * pPage->ReqByte - 2 ]; + return ( HB_GET_LE_UINT16( ptr ) >> ( 16 - pPage->TCBits ) ) & pPage->TCMask; + } +} + #if 0 /* * get key from uncompressed page @@ -1847,7 +1867,7 @@ static void hb_cdxPageLeafEncode( LPCDXPAGE pPage, BYTE * pKeyBuf, int iKeys ) pPage->iKeys = iKeys; pPage->fChanged = TRUE; pPage->bufKeyNum = 0; -#ifdef HB_CDX_DBGCODE_EXT_EXT +#ifdef HB_CDX_DBGCODE_EXT { BYTE * pKeyBf = pPage->pKeyBuf; pPage->pKeyBuf = NULL; @@ -2729,8 +2749,7 @@ static int hb_cdxPageKeyLeafBalance( LPCDXPAGE pPage, int iChildRet ) iSize += iLen - 6 - ( j == 0 ? 0 : pPtr[ ( j + 1 ) * iLen - 2 ] ) - pPtr[ ( j + 1 ) * iLen - 1 ]; } pbKey = hb_cdxPageGetKeyVal( lpTmpPage, 0 ); - bMax = ( HB_GET_LE_UINT16( &lpTmpPage->node.extNode.keyPool[ lpTmpPage->ReqByte - 2 ] ) - >> ( 16 - lpTmpPage->TCBits ) ) & lpTmpPage->TCMask; + bMax = hb_cdxPageGetKeyTrl( lpTmpPage, 0 ); #ifdef HB_CDX_PACKTRAIL bMax = iLen - 6 - bMax; #else @@ -2776,7 +2795,7 @@ static int hb_cdxPageKeyLeafBalance( LPCDXPAGE pPage, int iChildRet ) } if ( lpTmpPage->iKeys > 0 ) { - BYTE bDup = 0, bMax; + BYTE bDup = 0; pPtr = &pKeyPool[ iKeys * iLen ]; if ( lpTmpPage->pKeyBuf ) memcpy( pPtr, lpTmpPage->pKeyBuf, lpTmpPage->iKeys * iLen );