diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 2972f14ec0..573ef4dba2 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,8 +1,13 @@ -2000-10-13 11:28 GMT+3 Alexander Kresin - * source/rdd/dbfcdx/dbfcdx1.c - * source/rdd/dbcmd.c - * source/include/hbrddcdx.h - * fixed some warnings, added HB_TRACE_... +2000-10-13 0:33 UTC+0800 Brian Hays + * source/rdd/dbcmd.c + fixed ORDKEY to accept 0 as a parameter (to get current index's key) + * contrib/rdd_ads/ads1.c + * added to adsSkip() a check for skip -1 from EOF. + ADS behavior is to go to TOP if EOF had been reached by GO LASTREC()+1. + Forced to Go Bottom instead, to stay compatible with standard behavior. + * source/rdd/workarea.c + * added a TODO note to review questionable code in hb_waSkipFilter + 2000-10-12 23:50 UTC-0400 David G. Holm * include/hbver.h @@ -204,6 +209,12 @@ *tests/testbrw.prg ! Added call to Configure() method +tion/deletion + calling method Configure(). Method Configure() _has_ to be called when an already added TBColumn + object is changed. + *tests/testbrw.prg + ! Added call to Configure() method + 2000-09-30 22:22 GMT+2 Maurilio Longo *contrib/mysql/tmysql.prg ! fixes / changes to work with tsqlbrw.prg diff --git a/harbour/contrib/rdd_ads/ads1.c b/harbour/contrib/rdd_ads/ads1.c index 9f6aa58a80..b998ff02ad 100644 --- a/harbour/contrib/rdd_ads/ads1.c +++ b/harbour/contrib/rdd_ads/ads1.c @@ -324,7 +324,6 @@ static ERRCODE adsGoTo( ADSAREAP pArea, ULONG ulRecNo ) if( ulRecNo > 0 && ulRecNo <= pArea->ulRecCount ) { - // bh: do we use ulRecno?? pArea->ulRecNo = ulRecNo; pArea->fBof = pArea->fEof = FALSE; AdsGotoRecord( pArea->hTable, ulRecNo ); @@ -437,6 +436,19 @@ static ERRCODE adsSkip( ADSAREAP pArea, LONG lToSkip ) HB_TRACE(HB_TR_DEBUG, ("adsSkip(%p, %ld)", pArea, lToSkip)); +/* -----------------10/11/00 Brian Hays ------------------ + + In ADS, if you GO 0 (as opposed to skipping past lastrec), + it considers the record pointer "unpositioned". + If you then try to skip -1 you end up at Top with BOF True. + (If you skip past lastrec, then skip -1 it works right.) + To fix this we need to trap for a (negative lToSkip .AND. EOF) + and do a GoBottom--but only after letting ads try first and + testing for BOF. We need to avoid our GoBottom hack as much as + possible because with a filter set it could be quite slow. + + --------------------------------------------------*/ + pArea->fTop = pArea->fBottom = FALSE; AdsSkip ( (pArea->hOrdCurrent) ? pArea->hOrdCurrent : pArea->hTable, lToSkip ); @@ -444,8 +456,22 @@ static ERRCODE adsSkip( ADSAREAP pArea, LONG lToSkip ) return SUCCESS; /*bh: dbskip(0) created infinite loop; this should never move the record pointer via skipfilter */ else { + if ( lToSkip < 0 && pArea->fEof ) /* skipped -1 or more from EOF will NOT go to bottom in ads if we went straight to 0! It sets BOF in this case. */ + { + AdsAtBOF( pArea->hTable, (UNSIGNED16 *)&(pArea->fBof) ); + if ( pArea->fBof ) /* might also be true in and empty data set, but this is probably our problem situation so move again */ + { + //pArea->fTop = FALSE; + pArea->fBottom = TRUE; + AdsGotoBottom ( (pArea->hOrdCurrent) ? pArea->hOrdCurrent : pArea->hTable ); + if ( lToSkip < -1 ) + { + AdsSkip ( (pArea->hOrdCurrent) ? pArea->hOrdCurrent : pArea->hTable, (lToSkip + 1) ); + } + } + } hb_adsCheckBofEof( pArea ); - return SUPER_SKIPFILTER( (AREAP)pArea, lToSkip>0 ? 1:-1 ); + return SUPER_SKIPFILTER( (AREAP)pArea, lToSkip>0 ? 1 : -1 ); } } diff --git a/harbour/source/rdd/dbcmd.c b/harbour/source/rdd/dbcmd.c index cf9e90e6d0..71aa3bb048 100644 --- a/harbour/source/rdd/dbcmd.c +++ b/harbour/source/rdd/dbcmd.c @@ -2338,9 +2338,23 @@ HB_FUNC( ORDKEY ) if( s_pCurrArea ) { - pOrderInfo.itmOrder = hb_param( 1, HB_IT_STRING ); - if( !pOrderInfo.itmOrder ) - pOrderInfo.itmOrder = hb_param( 1, HB_IT_NUMERIC ); + if ( ISNUM(1) ) + { + if ( hb_parnl(1) == 0 ) /* if ask for 0, get current order */ + { + pOrderInfo.itmResult = hb_itemPutNI( NULL, 0 ); + pOrderInfo.itmOrder = NULL; /* This is necessary to get the NUMBER back */ + SELF_ORDINFO( ( AREAP ) s_pCurrArea->pArea, DBOI_NUMBER, &pOrderInfo ); + pOrderInfo.itmOrder = hb_param( 1, HB_IT_NUMERIC ); + hb_itemPutNI( pOrderInfo.itmOrder, hb_itemGetNI( pOrderInfo.itmResult ) ); + hb_itemRelease( pOrderInfo.itmResult ); + } + else + pOrderInfo.itmOrder = hb_param( 1, HB_IT_NUMERIC ); + + }else + pOrderInfo.itmOrder = hb_param( 1, HB_IT_STRING ); + pOrderInfo.atomBagName = hb_param( 2, HB_IT_STRING ); if( !pOrderInfo.itmOrder ) { @@ -3095,4 +3109,4 @@ HB_FUNC( DBFILEPUT ) } #endif -#include "rddcpy.c" \ No newline at end of file +#include "rddcpy.c" diff --git a/harbour/source/rdd/workarea.c b/harbour/source/rdd/workarea.c index e20d1ad224..dc7add6778 100644 --- a/harbour/source/rdd/workarea.c +++ b/harbour/source/rdd/workarea.c @@ -169,6 +169,11 @@ ERRCODE hb_waSkipFilter( AREAP pArea, LONG lUpDown ) } if( bOutOfRange ) { + /* + TODO: these calls to SELF_GOTO are redundant; in most cases + we are already at EOF from the skips above, and GO 0 is not necessary. + We should take a closer look at these. --BH + */ if( bTop && lUpDown > 0 ) uiError = SELF_GOTO( pArea, 0 ); else if( bBottom && lUpDown < 0 )