2015-12-09 14:22 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)

* include/dbinfo.ch
  * include/hbrdddbf.h
  * src/rdd/dbf1.c
    + added new RDD switch RDDI_SETHEADER
      It allows to define how DBF header is updated in tables which
      will be opened later, i.e.:
         // maximize performance reducing number of DBF header updating
         // header is updated only when table is closed if before new
         // record was added
         hb_rddInfo( RDDI_SETHEADER, DB_SETHEADER_MINIMAL )
      or:
         // update header in the same moment as Clipper and xBase++
         // and store only last two digit from the year for compatibility
         // with old dBase and FoxPro versions
         hb_rddInfo( RDDI_SETHEADER, ;
                     hb_bitOr( DB_SETHEADER_CLIPPER, DB_SETHEADER_YYEAR ) )
         // DB_SETHEADER_CLIPPER
      By default Harbour uses DB_SETHEADER_APPENDSYNC.
      For more information look at comments for DB_SETHEADER_* switches
      in dbinfo.ch
    + added new table switch DBI_SETHEADER
      It has the same meaning as RDDI_SETHEADER but changes the header
      updated mode of already open table by dbInfo() function.

  * src/rtl/filebuf.c
    ! added missing redirection for Configure() method.

  * src/rtl/hbproces.c
    ! fixed sysconf() emulation for OpenWatcom 1.9 and earlier to work with
      _SC_PAGESIZE
This commit is contained in:
Przemysław Czerpak
2015-12-09 14:22:57 +01:00
parent 34775e51bd
commit ea09561adf
6 changed files with 101 additions and 8 deletions

View File

@@ -10,6 +10,38 @@
* Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment
*/
2015-12-09 14:22 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* include/dbinfo.ch
* include/hbrdddbf.h
* src/rdd/dbf1.c
+ added new RDD switch RDDI_SETHEADER
It allows to define how DBF header is updated in tables which
will be opened later, i.e.:
// maximize performance reducing number of DBF header updating
// header is updated only when table is closed if before new
// record was added
hb_rddInfo( RDDI_SETHEADER, DB_SETHEADER_MINIMAL )
or:
// update header in the same moment as Clipper and xBase++
// and store only last two digit from the year for compatibility
// with old dBase and FoxPro versions
hb_rddInfo( RDDI_SETHEADER, ;
hb_bitOr( DB_SETHEADER_CLIPPER, DB_SETHEADER_YYEAR ) )
// DB_SETHEADER_CLIPPER
By default Harbour uses DB_SETHEADER_APPENDSYNC.
For more information look at comments for DB_SETHEADER_* switches
in dbinfo.ch
+ added new table switch DBI_SETHEADER
It has the same meaning as RDDI_SETHEADER but changes the header
updated mode of already open table by dbInfo() function.
* src/rtl/filebuf.c
! added missing redirection for Configure() method.
* src/rtl/hbproces.c
! fixed sysconf() emulation for OpenWatcom 1.9 and earlier to work with
_SC_PAGESIZE
2015-12-05 10:58 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
+ tests/getblock.prg
+ added test code for GET SetGet block for aliased macro variables

View File

@@ -107,6 +107,7 @@
#define RDDI_DIRTYREAD 44 /* Get/Set index dirty read flag */
#define RDDI_INDEXPAGESIZE 45 /* Get/Set default index page size */
#define RDDI_DECIMALS 46 /* Get/Set default number of decimal places for numeric fields if it's undefined */
#define RDDI_SETHEADER 47 /* DBF header updating modes */
/*
Constants for SELF_ORDINFO ()
@@ -293,6 +294,7 @@
#define DBI_LOCKTEST 146 /* record / file lock test */
#define DBI_CODEPAGE 147 /* Codepage used */
#define DBI_TRANSREC 148 /* Is it destination table of currently processed COPY TO or APPEND FROM operation? */
#define DBI_SETHEADER 149 /* DBF header updating modes */
/* RECORD MAP (RM) support */
#define DBI_RM_SUPPORTED 150 /* has WA RDD record map support? */
@@ -383,4 +385,25 @@
#define DB_DBFLOCK_CL53EXT DB_DBFLOCK_HB32
#endif
/* DBF HEADER UPDATING */
#define DB_SETHEADER_CLOSE 0 /* update in CLOSE method - it always happens if necessary */
#define DB_SETHEADER_COMMIT 1 /* update in FLUSH method */
#define DB_SETHEADER_WRITE 2 /* update in GOCOLD method */
#define DB_SETHEADER_APPEND 0 /* record append sets update header flag (always enabled) */
#define DB_SETHEADER_REPLACE 4 /* record modification sets update header flag */
#define DB_SETHEADER_YYEAR 16 /* store year() % 100 instead of year - 1900 */
/* update in CLOSE after append only */
#define DB_SETHEADER_MINIMAL DB_SETHEADER_CLOSE
/* update in COMMIT and CLOSE after append only */
#define DB_SETHEADER_COMMITSYNC DB_SETHEADER_COMMIT
/* update in GOCOLD after append only - default */
#define DB_SETHEADER_APPENDSYNC DB_SETHEADER_WRITE
/* update in CLOSE after any record modification */
#define DB_SETHEADER_CHANGE ( DB_SETHEADER_CLOSE + DB_SETHEADER_REPLACE )
/* update in COMMIT and CLOSE after any record modification - Cl*pper compatible */
#define DB_SETHEADER_CLIPPER ( DB_SETHEADER_COMMIT + DB_SETHEADER_REPLACE )
/* update in GOCOLD after any record modification */
#define DB_SETHEADER_FULL ( DB_SETHEADER_WRITE + DB_SETHEADER_REPLACE )
#endif /* HB_DBINFO_CH_ */

View File

@@ -143,6 +143,7 @@ typedef struct _DBFDATA
HB_BYTE bMemoType; /* DB_MEMO_FPT */
HB_BYTE bMemoExtType; /* DB_MEMOVER_FLEX */
HB_BYTE bDecimals; /* RDDI_DECIMALS */
HB_USHORT uiSetHeader; /* RDDI_SETHEADER */
HB_USHORT uiDirtyRead; /* HB_IDXREAD_CLEANMASK */
HB_USHORT uiIndexPageSize; /* 0 */
HB_ULONG ulMemoBlockSize; /* 0 */
@@ -207,6 +208,7 @@ typedef struct _DBFAREA
HB_BYTE bMemoType; /* MEMO type used in DBF memo fields */
HB_BYTE bLockType; /* Type of locking shemes */
HB_BYTE bCryptType; /* Type of used encryption */
HB_UINT uiSetHeader; /* DBF header updating modes DBI_SETHEADER */
DBFHEADER dbfHeader; /* DBF header buffer */
HB_USHORT * pFieldOffset; /* Pointer to field offset array */
PHB_DBFFIELDBITS pFieldBits; /* Pointer to extended DBF field info array */

View File

@@ -2062,7 +2062,7 @@ static HB_ERRCODE hb_dbfFlush( DBFAREAP pArea )
errCode = SELF_GOCOLD( &pArea->area );
if( errCode == HB_SUCCESS )
{
if( pArea->fUpdateHeader )
if( pArea->fUpdateHeader && ( pArea->uiSetHeader & DB_SETHEADER_COMMIT ) != 0 )
errCode = SELF_WRITEDBHEADER( &pArea->area );
}
@@ -2410,6 +2410,8 @@ static HB_ERRCODE hb_dbfGetVarLen( DBFAREAP pArea, HB_USHORT uiIndex, HB_SIZE *
*/
static HB_ERRCODE hb_dbfGoCold( DBFAREAP pArea )
{
HB_ERRCODE errCode = HB_SUCCESS;
HB_TRACE( HB_TR_DEBUG, ( "hb_dbfGoCold(%p)", pArea ) );
if( pArea->fRecordChanged )
@@ -2432,12 +2434,18 @@ static HB_ERRCODE hb_dbfGoCold( DBFAREAP pArea )
/* Write current record */
if( ! hb_dbfWriteRecord( pArea ) )
return HB_FAILURE;
pArea->fUpdateHeader = HB_TRUE;
pArea->fAppend = HB_FALSE;
errCode = HB_FAILURE;
else
{
if( pArea->uiSetHeader & DB_SETHEADER_REPLACE )
pArea->fUpdateHeader = HB_TRUE;
pArea->fAppend = HB_FALSE;
if( pArea->fShared && pArea->fUpdateHeader &&
( pArea->uiSetHeader & DB_SETHEADER_WRITE ) != 0 )
errCode = SELF_WRITEDBHEADER( &pArea->area );
}
}
return HB_SUCCESS;
return errCode;
}
/*
@@ -3772,6 +3780,14 @@ static HB_ERRCODE hb_dbfInfo( DBFAREAP pArea, HB_USHORT uiIndex, PHB_ITEM pItem
}
break;
}
case DBI_SETHEADER:
{
int iMode = hb_itemGetNI( pItem );
hb_itemPutNI( pItem, pArea->uiSetHeader );
if( ( iMode & ~0xFF ) == 0 )
pArea->uiSetHeader = iMode;
break;
}
case DBI_ROLLBACK:
if( pArea->fRecordChanged )
{
@@ -4073,11 +4089,15 @@ static HB_ERRCODE hb_dbfNewArea( DBFAREAP pArea )
pArea->uiDirtyRead = HB_IDXREAD_DEFAULT;
/* Size for deleted records flag */
pArea->uiRecordLen = 1;
/* DBF header update mode */
pArea->uiSetHeader = DB_SETHEADER_APPENDSYNC;
{
PHB_ITEM pItem = hb_itemPutNI( NULL, 0 );
if( SELF_RDDINFO( SELF_RDDNODE( &pArea->area ), RDDI_TABLETYPE, 0, pItem ) == HB_SUCCESS )
pArea->bTableType = ( HB_BYTE ) hb_itemGetNI( pItem );
if( SELF_RDDINFO( SELF_RDDNODE( &pArea->area ), RDDI_SETHEADER, 0, pItem ) == HB_SUCCESS )
pArea->uiSetHeader = ( HB_BYTE ) hb_itemGetNI( pItem );
hb_itemRelease( pItem );
}
@@ -6237,7 +6257,8 @@ static HB_ERRCODE hb_dbfWriteDBHeader( DBFAREAP pArea )
}
hb_dateToday( &iYear, &iMonth, &iDay );
pArea->dbfHeader.bYear = ( HB_BYTE ) ( pArea->bTableType == DB_DBF_STD ?
pArea->dbfHeader.bYear = ( HB_BYTE ) ( pArea->bTableType == DB_DBF_STD &&
( pArea->uiSetHeader & DB_SETHEADER_YYEAR ) == 0 ?
iYear - 1900 : iYear % 100 );
pArea->dbfHeader.bMonth = ( HB_BYTE ) iMonth;
pArea->dbfHeader.bDay = ( HB_BYTE ) iDay;
@@ -6632,6 +6653,15 @@ static HB_ERRCODE hb_dbfRddInfo( LPRDDNODE pRDD, HB_USHORT uiIndex, HB_ULONG ulC
}
break;
}
case RDDI_SETHEADER:
{
int iMode = hb_itemGetNI( pItem );
hb_itemPutNI( pItem, pData->uiSetHeader );
if( ( iMode & ~0xFF ) == 0 )
pData->uiSetHeader = iMode;
break;
}
case RDDI_DIRTYREAD:
{
HB_BOOL fDirty = ( pData->uiDirtyRead == HB_IDXREAD_DIRTYMASK );

View File

@@ -1029,6 +1029,11 @@ static void s_fileposCommit( PHB_FILE pFilePos )
_PHB_FILE->pFuncs->Commit( _PHB_FILE );
}
static HB_BOOL s_fileposConfigure( PHB_FILE pFilePos, int iIndex, PHB_ITEM pValue )
{
return _PHB_FILE->pFuncs->Configure( _PHB_FILE, iIndex, pValue );
}
static HB_FHANDLE s_fileposHandle( PHB_FILE pFilePos )
{
return pFilePos ? _PHB_FILE->pFuncs->Handle( _PHB_FILE ) : FS_ERROR;
@@ -1075,7 +1080,7 @@ static const HB_FILE_FUNCS * s_fileposMethods( void )
s_fileposEof,
s_fileposFlush,
s_fileposCommit,
s_fileConfigure,
s_fileposConfigure,
s_fileposHandle
};

View File

@@ -1594,6 +1594,7 @@ _WCRTLINK long sysconf( int __name )
return 1024;
case _SC_CLK_TCK:
return 100;
case _SC_PAGESIZE:
case /* _SC_PAGE_SIZE */ 30:
return 4096;
}