Microsoft KB Archive/814131

= Data reliability enhancements in Visual FoxPro 8.0 =

Article ID: 814131

Article Last Modified on 9/8/2005

-

APPLIES TO


 * Microsoft Visual FoxPro 8.0 Professional Edition

-



SUMMARY
This article lists data reliability enhancements that are introduced in Visual FoxPro 8.0. The following is a list of enhancements that are intended to prevent possible table corruption when tables are updated:
 * Integrity checks when table is opened.
 * Integrity checks when data is inserted or appended.
 * Trapping table operations that cause the table to exceed the 2 gigabytes (GB) maximum file size.



Detection of header record count corruption
In earlier versions of Visual FoxPro, records that are added in transactions may be lost if the table is corrupted in such a way that the table header record count does not match the number of records in the physical table file. Visual FoxPro 8.0 adds a mechanism to test for this condition when the table is opened by using the use command or at the begin transaction and end transaction commands. Because this validation requires locking the table header, you may see a decrease in performance in multi-user scenarios where file contention is high. This behavior is configurable, and the default is to check at use, at begin transaction, and at end transaction.

When this corruption is detected at use, you may receive error message 2091:

Table &quot;name&quot; has become corrupted. The table will need to be repaired before you use it again.

You may receive this error message when you open tables in Visual FoxPro 8.0 that, in earlier versions, open without error.

When this corruption is detected at begin transaction or end transaction, you may receive error message 2065:

Table &quot;name&quot; has a file length / record count inconsistency that will not allow this transaction to be committed. Please open the table exclusively and PACK it.

You may receive this error message when you add records to tables in Visual FoxPro 8.0 that, in earlier versions, allow records to be added without error.

You can set this behavior with the set tablevalidate command. set tablevalidate does not have repair functionality; it performs only integrity checks as specified by nLevel.

The syntax is set tablevalidate to nLevel where nLevel is one of the folllowing values:

To repair a table that might have this type of corruption, run the following commands:
 * set tablevalidate to 0
 * use exclusive
 * lcColumnName = Substr(Sys(2015),1,10)
 * alter table 
 * add column (lcColumnName) c(1)
 * alter table 
 * drop column (lcColumnName)
 * use set tablevalidate to 3

Important Any records whose physical record number is greater than the header record count are removed when you execute this code. Also, back up your table files before you perform any table structure manipulation. Be sure to back up your table files (.dbf, .fpt, and .cdx) before you follow these steps.
 * To copy the table to another table, use the copy to command. (See Note after next point.)
 * To remove all records from the original table, use zap, then use append from to copy all the records from the copied table back to the original table.
 * Note In the case of copy to or pack, you lose all records where the physical record number exceeds the header record count.

Error message when table size exceeds 2 GB
A problem occurs when an insert or an append operation causes a table (or .dbf) file to exceed the 2-GB maximum file size. The problem causes the following error:  In earlier versions of Visual FoxPro, trying to open a table in such a state causes error 15, and you receive the following error message:

Not a table.

 In Visual FoxPro 8.0, the action that would have caused the table to exceed the maximum file size, causes error 1190, and you receive the following error message:

File &quot;name&quot; is too large.



