Product Documentation

c-treeDB API API for C

Previous Topic

Next Topic

Null field support

The c-treeDB API record manager API implements the underlying support for null fields, but does not enforce it. If a table was created with null field support, the record manager will set or clear the null bit flag for fields, but there is no check to see if null fields are allowed or not.

When a record buffer is cleared by calling ctdbClearRecord(), all fields are marked as null fields. As you update the field contents by calling ctdbSetFieldAs() functions, the null field for the respective field is cleared indicating that the field contains data.

A specific field can be cleared, and its null field flag is set, by calling ctdbClearField(). Call ctdbIsNullField() to check if a field null flag is set or not.

/* if a field 0 is not null, clear the field */

if (ctdbIsNullField(hRecord, 0)

ctdbClearField(hRecord, 0);

The c-treeDB API null flag controls the NOT NULL property of a column. Setting this to column has no effect on individual record null values: it is NOT enforced at the c-treeDB API layer. This attribute only applies to the FairCom DB SQL layer for constraint on values. It is useful to set this flag in c-tree data files before SQL import such that the property is maintained.