DF_FILE_REUSE_DELETED
See Also: Get_Attribute, Set_Attribute
Controls the reuse or non-reuse of space occupied by deleted records in a table.
Level
Table
Supported by
All Drivers
Type
Enumeration list, permanent
Access
Read / Write
Values
DF_FILE_DELETED_NOREUSEDF_FILE_DELETED_REUSE
Remarks
When a record is deleted from an Embedded Database table, the space it occupied is not released. Instead, the record is marked as deleted. The DF_FILE_REUSE_DELETED attribute indicates how this space is treated when new records are added to the table.
- A value of
DF_FILE_DELETED_NOREUSEindicates deleted space will never be reused. - A value of
DF_FILE_DELETED_REUSEindicates the space will be reused.
This attribute is part of the basic set of attributes that must be supported by all drivers. However, it does not make sense in some back ends. That is why the Pervasive.SQL and DataFlex SQL Drivers will return DF_FILE_DELETED_REUSE for every table accessed.
This attribute can only be set inside a Structure_Start ... Structure_End operation.
In order to reclaim the space occupied by deleted records, an Embedded Database table maintains a so-called free list. This is a single linked list. When a table has its reuse attribute set to "no reuse," the list will not be maintained. When the attribute value is changed from "no reuse" to reuse on a table that has deleted space, this space will not be added to the free list. The free list will be maintained from that point on. Deleted space can be added to the free list by the repair wizard.
It is expected that this attribute will always be set to reuse the deleted space. The only reason not to reuse the deleted space is if the record number has a meaning and should never be assigned twice. Having record numbers that have a meaning, such as using Recnum relations, is a strongly discouraged technique.
Example Procedure
Procedure ShowNoReuse
Handle hTable
String sTable
Integer iReuse
Integer iNumTables
Move 0 To hTable
Move 0 To iNumTables
Repeat
Get_Attribute DF_FILE_NEXT_USED Of hTable To hTable
If (hTable > 0) Begin
Open hTable
Get_Attribute DF_FILE_REUSE_DELETED Of hTable To iReuse
If (iReuse = DF_FILE_DELETED_NOREUSE) Begin
Increment iNumTables
If (iNumTables = 1) ;
Showln "List of tables that do not reuse delete space:"
Get_Attribute DF_FILE_LOGICAL_NAME Of hTable To sTable
Showln " " sTable
End
Close hTable
End
Until (hTable = 0)
If (iNumTables = 0) ;
Showln "All tables reuse deleted space."
Else Begin
Showln "You may want to switch the reuse deleted space setting for " (If(iNumTables > 1, "these tables.", "this table."))
Showln "To reclaim already deleted space run the repair wizard."
End
End_Procedure // ShowNoReuse
The sample procedure above checks all tables in the file list. If a table is not reusing deleted space, this is reported.