Product Documentation

FairCom ISAM for C

Previous Topic

Next Topic

Data Record Positions

Data record positions are absolute byte offsets from the beginning of the data file, where the first byte of the file is at offset zero. For fixed record length data files, the byte offsets corresponding to the beginning of each record are guaranteed to be a multiple of the record length specified for the data file at the time of creation. Therefore, a data record position in a fixed record length data file can be converted to a relative record number by dividing the data record position by the record length.

Buffer Regions

As a reminder, many c-tree functions require you to pass a pointer to a buffer area where either a data record or key value will be written. c-tree has no way to determine if the area in which it will write the requested information is actually large enough to contain the information. If it is not, c-tree will contaminate data and/or executable code. CAREFULLY review all areas used as buffers to ensure that they are sufficiently large.

Fixed-Length Data Record Delete Flag

FairCom DB uses the first byte of fixed-length data records for a delete flag. When a fixed-length data record is deleted, because of a call to either DeleteRecord() or ReleaseData(), the first byte is set to 0xff. The rebuild and compact utilities check this first byte to determine if a record is active or deleted. Also, whenever a record is about to be reused by NewData(), which is automatically called by AddRecord(), the first byte is checked to be sure that an active record is not about to be reused by mistake.

It is not necessary to reserve this byte if your application stores only ASCII characters in the first byte; however, you should not store binary data in the first byte or set the first field in your DODA to a binary or numeric type.

To protect against this error, c-tree checks the beginning of records for certain values. AddRecord() and ReWriteRecord() return FBEG_ERR (553) if a record begins with either a delete flag (0xFF) or a resource mark (0xFEFE). This capability can be disabled:

  • For non-server applications, disable the check by compiling with NO_ctBEHAV_CHECKFIX defined.

For client/server applications, the configuration keyword COMPATIBILITY NO_CHECKFIX turns off this check.

Resource Records in Fixed-Length Files

Resource records embedded in fixed-length data files have a first byte of 0xFEFE. See Resources for more details.

TOCIndex