From e49372a803bcccf9dce0a7d56d1c1766d225dd32 Mon Sep 17 00:00:00 2001 From: "Alexander S.Kresin" Date: Thu, 17 Jan 2002 18:48:40 +0000 Subject: [PATCH] 2002-01-17 21:50 UTC+0300 Alexander Kresin --- harbour/ChangeLog | 5 +++++ harbour/source/rdd/dbcmd.c | 2 +- harbour/source/rdd/dbfntx/dbfntx1.c | 23 +++++++++++++++-------- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 4450ec5044..019e55f9a7 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -7,6 +7,11 @@ For example: 2002-12-01 23:12 UTC+0100 Foo Bar */ + Time consumed, previously: 11.59 secs + now : 5.06 secs + Environment: 1 GHz, 128 MB, BCC 5.5.1, SimpLex and -DHB_FM_STATISTICS_OFF + + 2002-01-18 17:45 UTC+0300 Alexander Kresin * source/rdd/dbfntx/dbfntx1.c * support of EVAL and EVERY clauses of INDEX ON command implemented diff --git a/harbour/source/rdd/dbcmd.c b/harbour/source/rdd/dbcmd.c index 91cfb0a5c9..f89f8e63b7 100644 --- a/harbour/source/rdd/dbcmd.c +++ b/harbour/source/rdd/dbcmd.c @@ -2318,7 +2318,7 @@ HB_FUNC( ORDCONDSET ) lpdbOrdCondInfo->fCustom = hb_parl( 15 ); lpdbOrdCondInfo->fNoOptimize = hb_parl( 16 ); - if( !lpdbOrdCondInfo->itmCobWhile ) + if( lpdbOrdCondInfo->itmCobWhile ) lpdbOrdCondInfo->fRest = TRUE; if( lpdbOrdCondInfo->lNextCount || lpdbOrdCondInfo->lRecno || lpdbOrdCondInfo->fRest ) lpdbOrdCondInfo->fAll = FALSE; diff --git a/harbour/source/rdd/dbfntx/dbfntx1.c b/harbour/source/rdd/dbfntx/dbfntx1.c index 5d450251de..35cab26117 100644 --- a/harbour/source/rdd/dbfntx/dbfntx1.c +++ b/harbour/source/rdd/dbfntx/dbfntx1.c @@ -1470,11 +1470,14 @@ static void hb_ntxSortKeyAdd( LPTAGINFO pTag, LPNTXSORTINFO pSortInfo, char* szk /* printf( "\n\rhb_ntxSortKeyAdd - 0 ( %s )",szkey ); */ pKeyNew = (LPSORTITEM) ( pSortInfo->sortBuffer + pSortInfo->itemLength * ( ulKeyNo - 1 ) ); - pKeyNew->rec_no = pTag->Owner->Owner->ulRecNo; - pKeyNew->pNext = NULL; - memcpy( pKeyNew->key, szkey, pTag->KeyLength ); + if( szkey ) + { + pKeyNew->rec_no = pTag->Owner->Owner->ulRecNo; + pKeyNew->pNext = NULL; + memcpy( pKeyNew->key, szkey, pTag->KeyLength ); + } - if( ++(pSortInfo->nItems) < 2 && pKeyNew->rec_no < pTag->Owner->Owner->ulRecCount ) + if( szkey && ++(pSortInfo->nItems) < 2 && pKeyNew->rec_no < pTag->Owner->Owner->ulRecCount ) return; if( pSortInfo->nItems == 2 ) @@ -1794,6 +1797,8 @@ static ERRCODE hb_ntxIndexCreate( LPNTXINDEX pIndex ) } } } + if( ulKeyNo < ulRecCount && ulKeyNo%2 ) + hb_ntxSortKeyAdd( pTag, &sortInfo, NULL, ulKeyNo ); pArea->pRecord = pRecordTmp; pArea->fValidBuffer = fValidBuffer; hb_fsSeek( pTag->Owner->DiskFile, 1024, FS_SET ); @@ -2457,9 +2462,10 @@ static ERRCODE ntxOrderCreate( NTXAREAP pArea, LPDBORDERCREATEINFO pOrderInfo ) HB_TRACE(HB_TR_DEBUG, ("ntxOrderCreate(%p, %p)", pArea, pOrderInfo)); - SELF_ORDLSTCLEAR( ( AREAP ) pArea ); if( SELF_GOCOLD( ( AREAP ) pArea ) == FAILURE ) return FAILURE; + if( !pArea->lpdbOrdCondInfo->fAll ) + SELF_ORDLSTCLEAR( ( AREAP ) pArea ); /* If we have a codeblock for the expression, use it */ if( pOrderInfo->itmCobExpr ) @@ -2634,8 +2640,6 @@ static ERRCODE ntxOrderCreate( NTXAREAP pArea, LPDBORDERCREATEINFO pOrderInfo ) pIndex = hb_ntxIndexNew( pArea ); pIndex->IndexName = szFileName; - pArea->lpNtxIndex = pIndex; - pArea->lpCurIndex = pIndex; pTag = hb_ntxTagNew( pIndex, szTagName, pOrderInfo->abExpr->item.asString.value, pKeyExp, bType, (USHORT) uiLen, (USHORT) uiDec, (char *) ( pArea->lpdbOrdCondInfo ? pArea->lpdbOrdCondInfo->abFor : NULL ), pForExp, pArea->lpdbOrdCondInfo ? !pArea->lpdbOrdCondInfo->fDescending : TRUE, @@ -2658,6 +2662,10 @@ static ERRCODE ntxOrderCreate( NTXAREAP pArea, LPDBORDERCREATEINFO pOrderInfo ) { return FAILURE; } + if( pArea->lpdbOrdCondInfo->fAll ) + SELF_ORDLSTCLEAR( ( AREAP ) pArea ); + pArea->lpNtxIndex = pIndex; + pArea->lpCurIndex = pIndex; hb_ntxHeaderSave( pIndex ); { BYTE emptyBuffer[250]; @@ -3076,7 +3084,6 @@ static RDDFUNCS ntxTable = { ntxBof, ntxWhoCares }; - HB_FUNC(_DBFNTX ) { }