See Also: Get_Attribute, Set_Attribute
Specifies the locking type to be used on the table.
Table
All Drivers
Enumeration list, permanent
Read / Write
DF_LOCK_TYPE_NONE, DF_LOCK_TYPE_FILE, DF_LOCK_TYPE_RECORD
If a table’s DF_FILE_LOCK_TYPE attribute has a value of DF_LOCK_TYPE_NONE, then no locking will be done for it. Using this value causes the value of the DF_FILE_MULTIUSER attribute to be set to DF_FILE_USER_SINGLE. A value of DF_LOCK_TYPE_FILE indicates locking will be done at the table level, and a value of DF_LOCK_TYPE_RECORD indicates that locking will be done at the record level.
Note that setting a table’s lock type to DF_LOCK_TYPE_NONE can result in data corruption. It is only safe to do if the table is never ever updated (no records are created, updated or deleted) or the application updating the table is doing so in true single user mode (only one process is accessing the table). Since locking is an expensive operation, this setting was used to tune performance. This is no longer needed for applications that use DataDictionary or DataSet objects. These objects use smart file mode to ensure only those tables that are actually updated are locked.
The DF_FILE_LOCK_NONE attribute value is left over from the time when there where single user/process operating systems. Modern operating systems allow multiple processes to run simultaneously. When two (or more) processes access a table at the same time, they are in fact using the table in a multi user fashion which requires a form of locking.
For the Embedded Database, the locking type must be set to either DF_LOCK_TYPE_FILE or DF_LOCK_TYPE_NONE. The locking type DF_LOCK_TYPE_NONE can only be used with applications that do not use DataSets or Data Dictionaries.
For Pervasive.SQL, the DF_FILE_LOCK_TYPE attribute cannot be set. It is possible to set the lock type to no locking, table locking or record locking but not on a table by table basis. The lock type is a global setting for the DataFlex Pervasive.SQL Driver. It can be set using the DFBTR_SET_TRANSACTION_TYPE command. The value returned for the attribute depends on what was passed to the DFBTR_SET_TRANSACTION_TYPE command in the following way:
Pervasive.SQL lock type |
Attribute value |
DFBTRTT_NONE |
DF_LOCK_TYPE_NONE |
DFBTRTT_EXCLUSIVE |
DF_LOCK_TYPE_FILE |
DFBTRTT_CONCURRENT |
DF_LOCK_TYPE_RECORD |
For tables accessed through the DataFlex SQL Drivers the DF_FILE_LOCK_TYPE attribute an attempt to set the attribute will be ignored. It will always return the value DF_LOCK_TYPE_RECORD.
This attribute can only be set inside a Structure_Start ... Structure_End operation. We expect this attribute will very rarely be set. The default value will be used in most cases.
Procedure ShowPotentialProblemTables
Handle hTable
Integer iLockType
String sTable
Integer iDangerous
Move 0 To hTable
Move 0 To iDangerous
Repeat
Get_Attribute DF_FILE_NEXT_USED of hTable To hTable
If (hTable > 0) Begin
Open hTable
Get_Attribute DF_FILE_LOCK_TYPE Of hTable To iLockType
Get_Attribute DF_FILE_LOGICAL_NAME of hTable To sTable
If (iLockType = DF_LOCK_TYPE_NONE) Begin
Showln "DANGER! Table " sTable " will not be locked!"
Increment iDangerous
End
Close hTable
End
Until (hTable = 0)
If (iDangerous = 0) ;
Showln "All tables in the filelist will be properly locked."
End_Procedure // ShowPotentialProblemTables
The sample procedure above will check every table in the filelist for its lock type setting. When tables exists that have their lock type set to DF_LOCK_TYPE_NONE these will be reported as potential problem tables.