diff --git a/harbour/ChangeLog b/harbour/ChangeLog index a719d1b887..1524458087 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,8 @@ +2001-07-17 18:35 GMT+3 Alexander Kresin + * source/rdd/dbfntx1.c + * Fixed few bugs, reported by John M. S. Chiang, + partially fixed seeking while SET DELETED ON state + 2001-07-17 00:25 UTC+1 JFL (mafact) * harbour/include/hbclass.ch ! Change NO_OO_ERR to HB_CLS_NO_OO_ERR diff --git a/harbour/source/rdd/dbfntx/dbfntx1.c b/harbour/source/rdd/dbfntx/dbfntx1.c index 29faca3763..6f419f5cca 100644 --- a/harbour/source/rdd/dbfntx/dbfntx1.c +++ b/harbour/source/rdd/dbfntx/dbfntx1.c @@ -56,6 +56,7 @@ #include "hbvm.h" #include "hbstack.h" #include "rddsys.ch" +#include "hbset.h" #include "hbapierr.h" #include "hbapilng.h" #include "hbrddntx.h" @@ -88,6 +89,7 @@ static int maxLevel = 0; static LPKEYINFO hb_ntxKeyNew( LPKEYINFO pKeyFrom ); static void hb_ntxKeyFree( LPKEYINFO pKey ); static LONG hb_ntxTagKeyFind( LPTAGINFO pTag, LPKEYINFO pKey, BOOL* result ); +static BOOL ntxIsDeleted( NTXAREAP pArea, LONG ulRecNo ); static int hb_ntxTagFindCurrentKey( LPPAGEINFO pPage, LONG lBlock, LPKEYINFO pKey, BOOL bExact, BOOL lSeek, int level ); static USHORT hb_ntxPageFindCurrentKey( LPPAGEINFO pPage, ULONG ulRecno ); static void hb_ntxGetCurrentKey( LPTAGINFO pTag, LPKEYINFO pKey ); @@ -271,7 +273,8 @@ static int hb_ntxTagFindCurrentKey( LPPAGEINFO pPage, LONG lBlock, LPKEYINFO pKe if( k <= 0 ) /* pKey <= p */ { - if( k == 0 && !lSeek && (ULONG)p->Xtra != pPage->TagParent->Owner->Owner->ulRecNo ) + if( ( k == 0 && !lSeek && (ULONG)p->Xtra != pPage->TagParent->Owner->Owner->ulRecNo ) + || ( hb_set.HB_SET_DELETED && ntxIsDeleted( pPage->TagParent->Owner->Owner, p->Xtra ) ) ) k = 1; if( k <= 0 ) { @@ -325,6 +328,18 @@ static int hb_ntxTagFindCurrentKey( LPPAGEINFO pPage, LONG lBlock, LPKEYINFO pKe return k; } +static BOOL ntxIsDeleted( NTXAREAP pArea, LONG ulRecNo ) +{ + + BOOL lDeleted; + + if( SELF_GOTO( ( AREAP ) pArea,ulRecNo ) == SUCCESS && + SUPER_DELETED( ( AREAP ) pArea,&lDeleted ) == SUCCESS ) + return lDeleted; + else + return FALSE; +} + static USHORT hb_ntxPageFindCurrentKey( LPPAGEINFO pPage, ULONG ulRecno ) { int i; @@ -1990,6 +2005,8 @@ static ERRCODE ntxGoBottom( NTXAREAP pArea ) { HB_TRACE(HB_TR_DEBUG, ("ntxGoBottom(%p)", pArea)); + if( SELF_GOCOLD( ( AREAP ) pArea ) == FAILURE ) + return FAILURE; if ( !pArea->lpCurIndex || !pArea->lpNtxIndex ) SUPER_GOBOTTOM( ( AREAP ) pArea ); else @@ -2022,6 +2039,8 @@ static ERRCODE ntxGoTop( NTXAREAP pArea ) { HB_TRACE(HB_TR_DEBUG, ("ntxGoTop(%p)", pArea)); + if( SELF_GOCOLD( ( AREAP ) pArea ) == FAILURE ) + return FAILURE; if ( !pArea->lpCurIndex || !pArea->lpNtxIndex ) SUPER_GOTOP( ( AREAP ) pArea ); else @@ -2043,6 +2062,8 @@ static ERRCODE ntxSeek( NTXAREAP pArea, BOOL bSoftSeek, PHB_ITEM pKey, BOOL bFin BOOL result; HB_TRACE(HB_TR_DEBUG, ("ntxSeek(%p, %d, %p, %d)", pArea, bSoftSeek, pKey, bFindLast)); + if( SELF_GOCOLD( ( AREAP ) pArea ) == FAILURE ) + return FAILURE; if ( ! pArea->lpCurIndex ) { pError = hb_errNew(); @@ -2136,6 +2157,8 @@ static ERRCODE ntxSkipRaw( NTXAREAP pArea, LONG lToSkip ) { HB_TRACE(HB_TR_DEBUG, ("ntxSkipRaw(%p, %ld)", pArea, lToSkip)); + if( SELF_GOCOLD( ( AREAP ) pArea ) == FAILURE ) + return FAILURE; if ( ! pArea->lpCurIndex ) SUPER_SKIPRAW( ( AREAP ) pArea, lToSkip ); else @@ -2602,6 +2625,7 @@ static ERRCODE ntxOrderCreate( NTXAREAP pArea, LPDBORDERCREATEINFO pOrderInfo ) hb_fsWrite( pIndex->DiskFile, emptyBuffer, 250 ); } + pIndex->CompoundTag->TagBlock = hb_fsSeek( pIndex->DiskFile, 0, SEEK_END ) - 1024; SELF_ORDSETCOND( ( AREAP ) pArea, NULL ); return SELF_GOTOP( ( AREAP ) pArea ); }