DF_FILE_INTEGRITY_CHECK
See Also: Get_Attribute, Set_Attribute, DF_HIGH_DATA_INTEGRITY
Indicates whether the file should be integrity-checked during the normal course of operation.
Level
Table
Supported by
The Embedded Database
Type
Boolean, permanent
Access
Read / Write
Values
- True
- False
Remarks
The Embedded Database implements header integrity checking as Cyclic Redundancy Check (CRC) header checking. An Embedded Database table’s data is stored in a disk file with the extension .dat. This disk file is made up of a header, followed by the actual data. When header integrity checking is on, a CRC is computed over the header and is stored in a separate disk file with the extension .hdr.
Every time the header of the table is updated, the .hdr disk file is also updated. When the table is opened, its header is checked against the .hdr information. If the information does not match, an error (DFERR_HEADER_CRC_BAD) is generated.
If the integrity checking results in the DFERR_HEADER_CRC_BAD error, the table can be repaired using Database Builder (Maintenance .. Repair Damaged headers) or by calling the FLEX_GET_REPAIRS_NEEDED and FLEX_REPAIR_FILE pass-through functions via Call_Driver.
This attribute can only be set inside of a Structure_Start ... Structure_End operation.
This attribute is part of the basic set of attributes that must be supported by all drivers. However, it does not make any sense in some back ends. That is why DataFlex SQL Drivers and the DataFlex Pervasive.SQL Driver will return false for every table accessed; trying to set the attribute will be ignored.
Procedure RepairDamagedHeaderTables
Handle hTable
Boolean bCheckOn
String sRoot
Integer iRepairNeeded
Integer iVoid
String sVoid
Move 0 To hTable
Repeat
Get_Attribute DF_FILE_NEXT_USED Of hTable To hTable
If (hTable > 0) Begin
Open hTable
Get_Attribute DF_FILE_INTEGRITY_CHECK Of hTable To bCheckOn
Get_Attribute DF_FILE_ROOT_NAME Of hTable To sRoot
If (bCheckOn) Begin
Call_Driver 0 "DATAFLEX" Function FLEX_GET_REPAIRS_NEEDED Callback 0 ;
Passing sRoot sVoid 0 Result iRepairNeeded
If (iRepairNeeded <> FLEX_HEADER_OK) Begin
Showln sRoot " is being repaired"
Call_Driver 0 "DATAFLEX" Function FLEX_REPAIR_FILE Callback 0 ;
Passing sRoot sVoid 0 Result iVoid
End
Else ;
Showln sRoot " has integrity on, does not need repairing."
End
Else ;
Showln sRoot " does not have integrity on."
End
Until (hTable = 0)
End_Procedure // RepairDamagedHeaderTables
The sample procedure above checks all tables in the file list. If they have integrity checking switched on, it checks if repairs are needed; if so, the table is repaired.