Product Documentation

VCL/CLX Developers Guide

Previous Topic

Next Topic

Hidden fields

There are three special fields that are automatically included by c-treeVCL/CLX into the table record definition. c-treeSQL makes extensive use of the null flag and rowid fields:

  • The delete flag ($DELFLD$)
  • The null flag ($NULFLD$)
  • The rowid fields ($ROWID$)

These fields are transparently and automatically handled by c-treeVCL/CLX and can't be handled directly by the field handling methods. There are specific methods that will, in some cases, retrieve data and status information kept by the hidden fields. These fields are also optional and c-treeVCL/CLX will operate correctly with tables that do not possess them. There are also table creation modes allowing developers to create tables without any, or all, of the hidden fields.

The delete flag field is for internal deletion purposes and should not be modified. $DELFLD$ is a CT_ARRAY field of 4 bytes. The only purpose of this field is to keep a place at the beginning of the record to hold c-tree delete flag byte when the record is deleted. Four bytes are used instead of just one byte due for alignment requirements. This is an internal c-treeDB requirement, and should not be modified or touched by the user.

$NULFLD$ is a CT_ARRAY field with the size based on the number of user defined fields for the table. For each user defined field, one bit is reserved in $NULFLD$. The $NULFLD$ field keeps the NUL flag information for each user defined field. If a user field is null, the corresponding bit in $NULFLD$ will be set. When data is written to the field, the corresponding bit is cleared. The user should never modify or verify this field directly, but should use TCtRecord.IsFieldNull() to verify if a field contains null data.

$ROWID$ is a CT_INT8 (64-bit integer) field holding the auto increment value generated by c-tree every time a new record is added to the table. This field is a read-only field that acts as a unique record identifier. Retrieve the rowid using TCtRecord.GetRowid(), or retrieve the record handle given its rowid using TCtRecord.FindRowid(). To know if a table has support for rowid, use the TCtTable property HasRowid().

Note: Record offsets may change for a given variable-length record when a record update to a larger record size than the original record, thus the RECBYT index cannot be used as a unique record identifier.

By default, c-treeVCL/CLX creates the three hidden fields. Tables created with c-tree Plus will not include these fields by default. c-treeDB does not require the fields to operate, but they allow more advanced capabilities. When creating a new table, users may disable the inclusion of the hidden fields by using the create modes CTCREATE_NONULFLD, CTCREATE_NODELFLD, and CTCREATE_NOROWID.

The default table layout is presented below. Note: The first field added by the user is always field 0.

$DELFLD$

$NULFLD$

$ROWID$

user field 0

user field 1

...

user field n

TOCIndex