From 70519acca51fda5b335b86505decc2d2f603418b Mon Sep 17 00:00:00 2001 From: Brian Hays Date: Mon, 9 Apr 2001 19:27:12 +0000 Subject: [PATCH] 2001-04-09 12:30 UTC-0800 Brian Hays --- harbour/ChangeLog | 5 +++++ harbour/contrib/rdd_ads/ads1.c | 24 ++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index e3d6c794d0..a12921ed12 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,8 @@ +2001-04-09 12:30 UTC-0800 Brian Hays + * contrib/rdd_ads/ads1.c + * added scope optimization to DBOI_KEYCOUNT + + 2001-04-09 11:50 UTC-0800 Ron Pinkas * include/hberrors.h * source/compiler/hbgenerr.c diff --git a/harbour/contrib/rdd_ads/ads1.c b/harbour/contrib/rdd_ads/ads1.c index 373ea0f6ee..b8cf44f1d7 100644 --- a/harbour/contrib/rdd_ads/ads1.c +++ b/harbour/contrib/rdd_ads/ads1.c @@ -665,7 +665,6 @@ static ERRCODE adsGetValue( ADSAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) UNSIGNED8 szName[ HARBOUR_MAX_RDD_FIELDNAME_LENGTH + 1 ]; UNSIGNED16 pusBufLen = HARBOUR_MAX_RDD_FIELDNAME_LENGTH; UNSIGNED32 pulLength; - BOOL bOnPhantom = FALSE; /* empty record set may have bof true but eof false and recno 0 */ HB_TRACE(HB_TR_DEBUG, ("adsGetValue(%p, %hu, %p)", pArea, uiIndex, pItem)); @@ -1703,10 +1702,31 @@ static ERRCODE adsOrderInfo( ADSAREAP pArea, USHORT uiIndex, LPDBORDERINFO pOrde break; case DBOI_KEYCOUNT : - AdsGetRecordCount( (phIndex ? phIndex : pArea->hTable), ADS_RESPECTFILTERS, &pul32); /* TODO: This count will be wrong if server doesn't know full filter! + TODO: If there are child areas that are not at the top of scope, Skip movement may move them to first related record */ + if ( phIndex ) + { + AdsGetScope ( phIndex, ADS_BOTTOM, aucBuffer, &pusLen); + if ( pusLen ) /* had a scope, walk it. Skips obey filters */ + { + AdsGetRecordNum( pArea->hTable, ADS_IGNOREFILTERS, + (UNSIGNED32 *)&(pArea->ulRecNo) ); + AdsGotoTop ( phIndex ); + AdsAtEOF( pArea->hTable, (UNSIGNED16 *)&(pArea->fEof) ); + + while ( AdsSkip ( phIndex, 1 ) != AE_NO_CURRENT_RECORD && !pArea->fEof ) + { + AdsAtEOF( pArea->hTable, (UNSIGNED16 *)&(pArea->fEof) ); + pul32++; + } + AdsGotoRecord( pArea->hTable, pArea->ulRecNo ); + AdsAtEOF( pArea->hTable, (UNSIGNED16 *)&(pArea->fEof) ); + } + }else + AdsGetRecordCount( pArea->hTable, ADS_RESPECTFILTERS, &pul32); + hb_itemPutNL(pOrderInfo->itmResult, pul32); break;