From 7d3b4ea8bb3f183813849be8446dfa1fddc453a1 Mon Sep 17 00:00:00 2001 From: "Alexander S.Kresin" Date: Thu, 21 Sep 2000 11:27:19 +0000 Subject: [PATCH] 2000-09-21 15:23 GMT+3 Alexander Kresin --- harbour/ChangeLog | 5 ++++ harbour/source/rdd/dbcmd.c | 31 ++++++++++++++------- harbour/source/rdd/workarea.c | 51 ++++++++++++++++++++++++----------- 3 files changed, 62 insertions(+), 25 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 40ba640bfd..61e50fb293 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,8 @@ +2000-09-21 15:23 GMT+3 Alexander Kresin + * source/rdd/workarea.c + * source/rdd/dbcmd.c + * Relations now working for RDD ADS again + 2000-09-21 12:59 GMT+3 Alexander Kresin * source/rdd/workarea.c * source/rdd/dbcmd.c diff --git a/harbour/source/rdd/dbcmd.c b/harbour/source/rdd/dbcmd.c index d9cd369727..06b89e8651 100644 --- a/harbour/source/rdd/dbcmd.c +++ b/harbour/source/rdd/dbcmd.c @@ -242,18 +242,29 @@ static void hb_rddCheck( void ) */ static void hb_rddCloseAll( void ) { + int nCycl = 0; LPAREANODE pAreaNode; - HB_TRACE(HB_TR_DEBUG, ("hb_rddCloseAll()")); - pAreaNode = s_pWorkAreas; - while( pAreaNode ) + while( nCycl < 2 ) { - s_pCurrArea = pAreaNode; - pAreaNode = pAreaNode->pNext; - SELF_CLOSE( ( AREAP ) s_pCurrArea->pArea ); - SELF_RELEASE( ( AREAP ) s_pCurrArea->pArea ); - hb_xfree( s_pCurrArea ); + pAreaNode = s_pWorkAreas; + while( pAreaNode ) + { + s_pCurrArea = pAreaNode; + pAreaNode = pAreaNode->pNext; + if( ( !nCycl && ( ( AREAP ) s_pCurrArea->pArea )->lpdbRelations ) || + ( nCycl && s_pCurrArea->pArea ) ) + { + SELF_CLOSE( ( AREAP ) s_pCurrArea->pArea ); + SELF_RELEASE( ( AREAP ) s_pCurrArea->pArea ); + // hb_xfree( s_pCurrArea->pArea ); + s_pCurrArea->pArea = NULL; + } + if( nCycl == 1 ) + hb_xfree( s_pCurrArea ); + } + nCycl ++; } s_uiCurrArea = 1; @@ -2727,7 +2738,7 @@ HB_FUNC( DBSETRELATION ) s_pArea = NULL; if( hb_pcount() < 2 || ( !( hb_parinfo( 1 ) & HB_IT_NUMERIC ) && - ( hb_parinfo( 1 ) != HB_IT_STRING ) ) || + ( hb_parinfo( 1 ) != HB_IT_STRING ) ) || ( hb_pcount() > 3 && !( hb_parinfo( 4 ) & HB_IT_LOGICAL ) ) ) { hb_errRT_DBCMD( EG_ARG, EDBCMD_REL_BADPARAMETER, NULL, "DBSETRELATION" ); @@ -2888,7 +2899,7 @@ HB_FUNC( __DBARRANGE ) ulSize --; szFieldName[ ulSize ] = 0; } - dbSortInfo.lpdbsItem[ uiCount ].uiField = + dbSortInfo.lpdbsItem[ uiCount ].uiField = hb_rddFieldIndex( ( AREAP ) s_pCurrArea->pArea, szFieldName ); /* Field not found */ diff --git a/harbour/source/rdd/workarea.c b/harbour/source/rdd/workarea.c index 63592f8dca..4cdb860840 100644 --- a/harbour/source/rdd/workarea.c +++ b/harbour/source/rdd/workarea.c @@ -423,7 +423,7 @@ ERRCODE hb_waClose( AREAP pArea ) SELF_CLEARLOCATE( pArea ); if( pArea->uiParents > 0 ) - printf( "\nTODO: hb_waClose()\n" ); + printf( "\nTODO: hb_waClose() %d\n",pArea->uiParents ); ( ( PHB_DYNS ) pArea->atomAlias )->hArea = 0; return SUCCESS; @@ -454,6 +454,9 @@ ERRCODE hb_waNewArea( AREAP pArea ) HB_TRACE(HB_TR_DEBUG, ("hb_waNewArea(%p)", pArea)); pArea->valResult = hb_itemNew( NULL ); + pArea->lpdbRelations = NULL; + pArea->uiParents = 0; + return SUCCESS; } @@ -659,7 +662,7 @@ ERRCODE hb_waSyncChildren( AREAP pArea ) */ ERRCODE hb_waClearRel( AREAP pArea ) { - LPDBRELINFO lpdbRelation; + LPDBRELINFO lpdbRelation, lpdbRelPrev; HB_TRACE(HB_TR_DEBUG, ("hb_waClearRel(%p)", pArea )); @@ -667,19 +670,18 @@ ERRCODE hb_waClearRel( AREAP pArea ) lpdbRelation = pArea->lpdbRelations; while( lpdbRelation ) { - SELF_CHILDEND( pArea, lpdbRelation ); - + SELF_CHILDEND( lpdbRelation->lpaChild, lpdbRelation ); +/* if( lpdbRelation->itmCobExpr ) hb_itemRelease( lpdbRelation->itmCobExpr ); - if( lpdbRelation->abKey ) hb_itemRelease( lpdbRelation->abKey ); - - hb_xfree( lpdbRelation ); - - pArea->lpdbRelations = pArea->lpdbRelations->lpdbriNext; - lpdbRelation = pArea->lpdbRelations; +*/ + lpdbRelPrev = lpdbRelation; + lpdbRelation = lpdbRelation->lpdbriNext; + hb_xfree( lpdbRelPrev ); } + pArea->lpdbRelations = NULL; return SUCCESS; } @@ -728,13 +730,32 @@ ERRCODE hb_waRelText( AREAP pArea, USHORT uiRelNo, void * pExpr ) /* * Set a relation in the parent file. */ -extern ERRCODE hb_waSetRel( AREAP pArea, LPDBRELINFO pRelInfo ) +ERRCODE hb_waSetRel( AREAP pArea, LPDBRELINFO lpdbRelInf ) { - HB_TRACE(HB_TR_DEBUG, ("hb_waSetRel(%p, %p)", pArea, pRelInfo)); - HB_SYMBOL_UNUSED( pArea ); - HB_SYMBOL_UNUSED( pRelInfo ); + LPDBRELINFO lpdbRelations; + + HB_TRACE(HB_TR_DEBUG, ("hb_waSetRel(%p, %p)", pArea, pRelInfo)); + + lpdbRelations = pArea->lpdbRelations; + if( ! lpdbRelations ) + { + pArea->lpdbRelations = ( LPDBRELINFO ) hb_xgrab( sizeof( DBRELINFO ) ); + lpdbRelations = pArea->lpdbRelations; + } + else + { + while( lpdbRelations->lpdbriNext ) + lpdbRelations = lpdbRelations->lpdbriNext; + lpdbRelations->lpdbriNext = ( LPDBRELINFO ) hb_xgrab( sizeof( DBRELINFO ) ); + lpdbRelations = lpdbRelations->lpdbriNext; + } + lpdbRelations->lpaChild = lpdbRelInf->lpaChild; + lpdbRelations->itmCobExpr = lpdbRelInf->itmCobExpr; + lpdbRelations->abKey = lpdbRelInf->abKey; + lpdbRelations->lpdbriNext = lpdbRelInf->lpdbriNext; + + hb_waChildStart( lpdbRelInf->lpaChild,lpdbRelInf ); - printf( "\nTODO: hb_waSetRel()\n" ); return SUCCESS; }