Product Documentation

c-treeDB API API for C

Previous Topic

Next Topic

Table Properties

c-treeDB API tables have a number of properties that can be set when the table is created or with "set" and "get" functions.

Table Name

The table name is a read-only property that can't be changed once the table is created. Use ctdbGetTableName() to retrieve the table name.

Table Path

The table path property is set to NULL by default. If this property is not changed prior to calling ctdbCreateTable(), the table is created in the same directory as the database. Call ctdbSetTablePath() to change the table path property. ctdbGetTablePath() retrieves the current table path.

Table File Extension

The table data file extension defaults to “.dat”. The default data file extension can be changed with ctdbSetTableExtension(). ctdbGetTableExtension() retrieves the current data file extension for the table.

Index File Extension

The table index file extension defaults to “.idx”. The default index file extension can be changed with ctdbSetIndexExtension(). ctdbGetIndexExtension() retrieves the current index file extension for the table.

Data File Extent Size

The data file extent is the default size by which the data file is extended when necessary. This value is 0 bytes by default. If there is a need to change it, use ctdbSetTableDefaultDataExtentSize(). To retrieve the data default extent size, use ctdbGetTableDefaultDataExtentSize().

Index File Extent Size

The index file extent is the default size by which the index file is extended when necessary. This value is 0 byte by default. If there is a need to change it, use ctdbSetTableDefaultIndexExtentSize(). To retrieve the index default extent size, use ctdbGetTableDefaultIndexExtentSize().

Table Password

By default tables do not have a password (i.e.. the password property is set to NULL). If a table is to be created with a password, change this property with a call to ctdbSetTablePassword() before creating the table with a call to ctdbCreateTable(). Use ctdbSetTablePassword() to set the password and ctdbGetTablePassword() to retrieve it.

Table Group ID

The group ID can be used to manage table permissions for multiple users. By default, no group ID settings are specified for c-treeDB API tables (i.e., the default group ID value is NULL). If a table is to be created with a group ID, set the value of this property before creating the table with a call to ctdbCreateTable(). To set a group ID, use ctdbSetTableGroupid() and ctdbGetTableGroupid() to retrieve it.

Table Permission Mask

The permission mask is set at file creation and specifies a permission mask that determines the kind of access that users may acquire on subsequent opens. For more information, see Table Permission Mask.

Number of Fields

The “number of fields” property indicates the total number of fields defined for a table. The value takes into consideration only user defined fields and does not include any hidden fields that exist for the table. Use ctdbGetTableFieldCount() to retrieve the number of fields associated with a table.

Number of Indexes

The “number of indexes” property indicates the total number of indexes defined for a table. The value takes into consideration only user defined indexes and does not include the RECBYT or ROWID indexes. Use ctdbGetTableIndexCount() to retrieve the number of indexes associated with a table.

Field Padding

The field padding property sets the table pad and field delimiter characters c-treeDB API uses to pad fixed-length string fields. For more information, see Field Padding.

Update Create Mode

The update table create mode property changes the table create mode after the table has been created. For more information, see Update Create Mode.

Previous Topic

Next Topic

Update Create Mode

Use the update table create mode property to change the table create mode after the table has been created. Use ctdbUpdateCreateMode() to change the table create mode. You can only update the create mode if the table was opened in exclusive mode.

/* update the table create mode */

if (ctdbUpdateCreateMode(hTable, CTCREATE_TRNLOG) != CTDBRET_OK)

printf("Update create mode failed\n');

ctdbUpdateCreateMode() changes critical file mode attributes such as the level of transaction control. No check is made to determine if the mode change will damage data. No check is made if the new mode is valid. Use this function with caution as data may be lost. For instance, changing a data file from transaction processing to no transaction processing makes automatic recovery unavailable.

The mode parameter passed to ctdbUpdateCreateMode() represents the new table create mode. It must be perfectly formed, as it will replace the current table create mode. Use ctdbGetTableCreateMode() to retrieve the current create mode and apply the changes on a fully qualified create mode. Update only the following create table modes:

  • CTCREATE_PREIMG
  • CTCREATE_TRNLOG
  • CTCREATE_WRITETHRU
  • CTCREATE_CHECKLOCK
  • CTCREATE_CHECKREAD
  • CTCREATE_HUGEFILE

Previous Topic

Next Topic

Table Permission Mask

The permission mask is set at file creation and specifies a permission mask that determines the kind of access that users may acquire on subsequent opens. The mask is comprised of three components: owner permissions, group permissions and world permissions. With this structure, you are able to allow different users different levels of access to the file. The default permission mask is set to (OPF_ALL | GPF_READ | GPF_WRITE | WPF_READ | WPF_WRITE). To set the table permissions, use ctdbSetTablePermission(). To retrieve the values, use ctdbGetTablePermission().

Valid permission mask values are:

c-treeDB API
Permission Constant

c-treeDB API .NET
Permission Constant


Explanation

OPF_READ

O_READ

owner read permission

OPF_WRITE

O_WRITE

owner write/update permission

OPF_DEF

O_DEF

owner file definition permission

OPF_DELETE

O_DELETE

owner file deletion permission

OPF_ALL

O_ALL

owner granted all permissions

OPF_NOPASS

O_NOPASS

owner grants read only without password

GPF_NONE

G_NONE

group access denied

GPF_READ

G_READ

group read permission

GPF_WRITE

G_WRITE

group write/update permission

GPF_DEF

G_DEF

group file definition permission

GPF_DELETE

G_DELETE

group file deletion permission

GPF_NOPASS

G_NOPASS

group read only access without password

WPF_NONE

W_NONE

world access denied

WPF_READ

W_READ

world read permission

WPF_WRITE

W_WRITE

world write/update permission

WPF_DEF

W_DEF

world file definition permission

WPF_DELETE

W_DELETE

world file deletion permission

WPF_NOPASS

W_NOPASS

world read only access without password

Previous Topic

Next Topic

Field Padding

By default the c-treeDB API API pads fixed-length string fields CT_CHARS (CT_FSTRING), CT_FPSTRING, CT_F2STRING, and CT_F4STRING with NULL ('\0') bytes. The field padding property sets the table pad and field delimiter characters to allow proper target key formation. This property allows the c-treeDB API API to operate on files created using the FairCom DB ISAM and Low-Level APIs using a fixed string padding strategy that is different from the c-treeDB API API default.

Use ctdbSetPadChar() to set the pad and field delimiter characters and ctdbGetPadChar() to retrieve the current pad and field delimiter characters.

/* set the table pad and delimiter characters to spaces */

if (ctdbSetPadChar(hTable, ' ', ' ') != CTDBRET_OK)

printf('Set pad characters failed\n");

The most common strategies for padding fixed string fields are:

  • Pad with NULLs: pad character is '\0' and field delimiter is '\0'
  • Pad with spaces: pad character is ' ' and field delimiter is ' '
  • Pad with spaces and terminate with NULL: pad character is ' ' and field delimiter is '\0'

TOCIndex