C API Functions A

ctdbAbort

Abort a transaction.

Declaration

CTDBRET ctdbAbort(CTHANDLE Handle)

  • Handle [in] the session handle. Any handle will work, but you save a tiny bit of CPU by using the session handle.

Description

ctdbAbort() aborts a transaction initiated with ctdbBegin() and releases all locks, both session-wide record locks (automatically acquired as a result of calling ctdbLock() and then reading a record from a table file), and manually-locked records (acquired by calling ctdbLockRecord() on an individual record). Locks acquired both inside and outside the transaction are released. This function also disables (turns off) session-wide record locking. Note that these lock-related behaviors can be changed from the default by calling ctdbSetKeepLock().

Returns

ctdbAbort() returns CTDBRET_OK if successful, or the c-tree error code on failure. Common causes of abort errors are calling ctdbAbort() twice in a row or calling ctdbAbort() after a successful call to ctdbCommit() or calling ctdbAbort() without calling ctdbBegin() first to start a transaction. Extreme circumstances, like the failure of computer hardware, can cause calls to ctdbCommit() and ctdbAbort() to fail. In situations like this, a common approach is to log an error and exit.

Example


ctdbBegin(pSession);

if (ctdbCreateTable(tHandle1,"table1",CTCREATE_NORMAL) == CTDBRET_OK)

       ctdbCommit(pSession);

else

       ctdbAbort(pSession);

 

See also

ctdbBegin(), ctdbClearSavePoint(), ctdbCommit(), ctdbRestoreSavePoint(), ctdbSetKeepLock(), ctdbSetSingleSavePoint(), Locking

ctdbAddCriteria

Adds a new criteria to the given CTResultSet handle

Declaration

CTHANDLE ctdbAddCriteria(CTHANDLE Handle, CTHANDLE FieldHandle,
    pTEXT LowValue, pTEXT HighValue, NINT CriteriaOp)

Parameters:

  • Handle [IN] - Result Set handle.
  • FieldHandle [IN] - Field handle.
  • LowValue [IN] - Low Criteria Value.
  • HighValue [IN] - High Criteria Value. If operator requires only one criteria value, only the LowValue will be used (this one will be ignored).
  • CriteriaOp [IN] - Criteria Operator. Can be CTIX_EQ, CTIX_NE, CTIX_GT, CTIX_GE, CTIX_LE, CTIX_LT, CTIX_BET, CTIX_BET_IE, CTIX_BET_EI, CTIX_BET_EE, or CTIX_NOTBET.

Description

The result set handle is allocated with ctdbAllocateResultSet() for a specific table handle, and then it is possible to add one or more criteria with ctdbAddCriteria(). The criteria have a field to be checked against the table handle that owns the result set, one or two values (depending on the comparison operator) and the operator to be used. The operator can be on of: CTIX_EQ, CTIX_NE, CTIX_GT, CTIX_GE, CTIX_LE, CTIX_LT, CTIX_BET, CTIX_BET_IE, CTIX_BET_EI, CTIX_BET_EE or CTIX_NOTBET. When the result set has all the criteria added, it can be turned on or off (ctdbResultSetOnOff()) for any record handle that is allocated for the same table handle that owns the result set.

Limitations

  • A result set can't be turned on for a record that is already filtered. And when a record has a result set turned on, it is not possible to add any other filter. This limitation may be relaxed in the future.
  • When a result set is changed (ctdbAddCriteria(), ctdbRemoveCriteria() and ctdbUpdateCriteria()), it must be re-applied to the record handle (ctdbResultSetOnOff()) to have these changed take effect..

Returns

A CTResultSetCri handle. NULL otherwise.

Example

   CTHANDLE hResSet;
   CTHANDLE hResSetCri;
 
/* Allocate a Result Set for Table */
if (!(hResSet = ctdbAllocateResultSet( hTable, "resSet1" )))
    Handle_Error("Test_ResultSet1(); ctdbAllocateResultSet()");

/* Add a new criteria for the Result Set just allocated */
if (!(hResSetCri = ctdbAddCriteria( hResSet, hField0, "1002", NULL, CTIX_EQ )))
    Handle_Error("Test_ResultSet1(); ctdbAddCriteria()");

/* Turn on the Result Set for the current record handle */
if (ctdbResultSetOnOff( hResSet, hRecord, YES, YES, CTLOC_NONE ) != CTDBRET_OK)
    Handle_Error("Test_ResultSet1(); ctdbResultSetOnOff()");

/* Display records on the Result Set */
Display_Records(hRecord);

/* Release Result Set handle */
ctdbFreeResultSet( hResSet );

See also

ctdbAddDatabase

Add an existing database to a session.

Declaration

CTDBRET ctdbAddDatabase(CTHANDLE Handle, pTEXT Name, pTEXT Path)

Description

ctdbAddDatabase() adds an existing database to the present session dictionary. Use the Path parameter to specify where the database dictionary file is on disk. If Path is left empty, FairCom DB API will attempt to locate the file in the Server directory (client/server) or in the execution directory (standalone).

  • Handle [in] the session handle.
  • Name [in] the database name.
  • Path [in] the database path.

Returns

ctdbAddDatabase() returns CTDBRET_OK on success, or a FairCom DB API error code on failure.

Example


eRet = ctdbAddDatabase(hSession, "my_database", "");

if (eRet != CTDBRET_OK)

{

      if (eRet == CTDBRET_NOTFOUND)

      {

           printf("\n\nTable not found at the path.\n");

      }

      else

      {

           printf("ctdbAddDatabase returned error code %d\n", eRet);

      }

}

 

See also

ctdbAddTable(), ctdbDropDatabase(), ctdbDropTable()

ctdbAddField

Add a new field to table

Declaration

CTHANDLE ctdbAddField(CTHANDLE Handle, pTEXT FieldName,

                      CTDBTYPE FieldType, VRLEN FieldLength)

Description

ctdbAddField() adds a new field to the end of a table. Fields added with this function are sequentially-numbered, starting with field number zero. If the table has no fields, the first field added will be field number zero. If the table has five fields already (numbered zero to four), the next field added by this function will be field number five.

Use ctdbInsField() and ctdbInsFieldByName() to insert a field in a table in a specified position. Use ctdbDelField() and ctdbDelFieldByName() to delete fields from the table. Note that ctdbAddField() does the field handle allocation, so no explicit "alloc" calls need to be made on the field handles. Field handle deallocation is automatically handled by ctdbCloseTable() and ctdbCloseAll(). After the segments, indexes, and fields have been defined, the table can be created or altered with ctdbCreateTable() or ctdbAlterTable().

  • pTable [in] - The table handle.
  • FieldName [in] - The field name.
  • FieldType [in] - The field type. Available types are listed in the left-hand column ("FairCom DB API Field Type") of the "Field Types" table in in FairCom DB API definitions.
  • FieldLength [in] - The maximum length of CHAR, VARCHAR, BINARY, and VARBINARY fields (64K bytes max). The maximum length of LVARCHAR, LVARBINARY fields (2GB max, or set to 0 for "2GB"). This parameter is ignored for all other field types (the non-array-like types).

    Note that FieldLength [in] must account for the underlying data type. For example, for a string field allowing up to 256 bytes of application data, the following field length needs to be specified:

    CT_FSTRING (fixed length string) length = 256
    CT_STRING (null terminated string) length = 257 
    CT_2STRING (2 byte length prefix) length = 258  
    CT_4STRING (4 byte length prefix) length = 260

Returns

ctdbAddField returns a newly-allocated field handle on success, or NULL on failure.

Example

 

pMyTable = ctdbAllocTable(pMyDatabase);

pMyField0 = ctdbAddField(pMyTable, "Name", CT_FSTRING, 32);  /* Field #0 */

pMyField1 = ctdbAddField(pMyTable, "Balance", CT_SFLOAT, 4); /* Field #1 */

pMyIndex = ctdbAddIndex(pMyTable, "iName", CTINDEX_FIXED, NO, NO);

pMyIseg = ctdbAddSegment(pMyIndex, pMyField0, 2);

RetVal = ctdbCreateTable(pMyTable,"Table1",CTCREATE_NORMAL);

 

See also

ctdbAllocTable(), ctdbInsField(), ctdbInsFieldByName(), ctdbDelField(), ctdbDelFieldByName(), ctdbMoveField(), ctdbCreateTable(), ctdbAlterTable()

ctdbAddFTI

Add a new Full-Text Search index to a table.

 

ctdbAddFTIField

Add a new field to a Full-Text Search index.

 

ctdbAddFTIFieldByName

Add a new field to an FTS index.

ctdbAddIndex

Add a new index to a table.

Declaration

CTHANDLE ctdbAddIndex(CTHANDLE Handle, cpTEXT name, CTDBKEY key_type,

                      CTBOOL AllowDuplicates, CTBOOL NullFlag)

Description

ctdbAddIndex() adds a new index to a table. An index makes record seeking faster and more efficient, and provides a convenient way to sort a table. Since an index file resides in the same folder as its table, it is not necessary to specify a path when adding an index to a table. After adding an index to a table with this function, add one or more segments to the index, using the ctdbAddSegment___() functions.

Use ctdbDelIndex() to delete indexes from a table.

Use ctdbGetIndexKeyType() to retrieve the key type of an index. ctdbAddIndex() does the allocation of the index handle. Index handle deallocation is automatically handled by ctdbCloseTable() and ctdbCloseAll(). After the segments, indexes, and fields have been defined, the table can be created or altered by calling ctdbCreateTable() or ctdbAlterTable().

  • Handle [in] the table handle.
  • name [in] the name of the new index.
  • key_type [in] the index key type. Allowed index key types are listed in Index Key Types.
  • AllowDuplicates [in] the indication if the index allows duplicate keys (YES or NO are the valid values).
  • NullFlag [in] the indication if the index allows null keys (YES or NO are the valid values).

Background Load on Index Creation

Background key loading can improve performance when adding new indexes. A new background loading mode can be OR-d in with an existing key mode from a ctdbAddIndex (ctdbAddIndex, ctdbAddIndex)() call indicating initial index loading must be done in the background.

Once ctdbAddIndex() is called, ctdbAlterTable() initiates the changes to the file and begins the load once the new index is successfully created.

Check the status of index loading with the new ctdbCheckIndexBackgroundLoad() (ctdbCheckIndexBackgroundLoad, ctdbCheckIndexBackgroundLoad) API, useful for monitoring index loading on tables.

Example

This example demonstrates using a background index load option.

ctdbAddIndex(hTable, "test541_i1", CTINDEX_FIXED| CTINDEX_BCKLOAD, YES, NO)

ctdbAlterTable() will fail if a CTINDEX_BCKLOAD is added and it does not have a filename associated (i.e. ctdbSetIndexFilename() has not been called on the index) or ctdbAlterTable() needs to perform any operation other than adding new CTINDEX_BCKLOAD indexes. If the preconditions are met, ctdbAlterTable() is executed without opening the file in exclusive mode and the background load is immediately started.

The new ctdbCheckIndexBackgroundLoad() (ctdbCheckIndexBackgroundLoad, ctdbCheckIndexBackgroundLoad) function can be used to monitor the status of the index loading on tables.

Example

 

pMyField0 = ctdbAddField(pMyTable, "Name"   , CT_FSTRING,32);

pMyField1 = ctdbAddField(pMyTable, "Balance", CT_SFLOAT, 4);

pMyIndex = ctdbAddIndex(pMyTable, "iName", CTINDEX_FIXED,NO,NO);

pMyIseg = ctdbAddSegment(pMyIndex, pMyField0, 2);

RetVal = ctdbCreateTable(pMyTable,"Table1",CTCREATE_NORMAL);

 

Returns

ctdbAddIndex() returns the index handle on success, or NULL on failure.

See also

ctdbAllocTable(), ctdbDelIndex(), ctdbGetIndexKeyType(), ctdbCreateTable(), ctdbAlterTable(), ctdbSetIndexName()

NAV (FairCom DB API) API Variable Length Keys with Compression

ctdbAddJSONSegment

Add a new index segment on a JSON field.

Declaration

CTHANDLE ctdbAddJSONSegment(CTHANDLE Handle, CTHANDLE FieldHandle, pTEXT key, CTDBTYPE type, VRLEN size);

Description

  • Handle [IN] - Index handle
  • FieldHandle [IN] - Index segment field handle (JSON field)
  • key [IN] - JSON key name that is being indexed
  • type [IN] - c-tree data type of key value
  • size [IN] - key segment length

Returns

Return the segment handle on success or NULL on failure.

Limitations to JSON Key Segments

  1. A CT_JSON key segment does not support the DSCSEG, ALTSEG, or ENDSEG key segment modes. Attempting to create an index that contains a CT_JSON key segment that includes any of these key segment modes fails with error NSUP_ERR.
  2. CT_JSON key segments that use CT_STRING as the c-tree data type are always padded with null (0x0) bytes. We don't support setting a different key segment padding character on JSON key segments.
  3. A CT_JSON key segment can specify any of the following c-tree data types: CT_BOOL, CT_CHAR, CT_CHARU, CT_INT2, CT_INT2U, CT_INT4, CT_INT4U, CT_INT8, CT_DFLOAT, CT_STRING. Note that CT_INT8U is not supported, because JSON only supports a signed 8-byte integer data type.
  4. Remember that the JSON field indexing behaves as follows: if the JSON data type of the value that is being indexed is not compatible with the underlying c-tree data type specified in the key segment definition, that value is treated as NULL and is not indexed. Some examples:
    • If the value is a string and the c-tree data type is an integer, the value is not indexed.
    • If the value is an integer and the c-tree data type is CT_INT2 but the value is out of range for a signed two-byte integer, the value is not indexed.

 

ctdbAddSegmentByName

Add a new index segment to an index (given the table handle, field name, and index number).

Declaration

CTHANDLE ctdbAddSegmentByName(CTHANDLE Handle, NINT IndexNbr,

                              pTEXT FieldName, CTSEG_MODE SegMode)

Description

ctdbAddSegmentByName() adds a new index segment to an index, specifying the field by giving the table handle and the field name and specifying the index by giving its number. The operation of adding a segment to the index links the specified index with the specified field in the specified table. When a segment is added with this function, the segment is defined based on an individual full field of a table, using what is known as a record schema. In other words, instead of using a byte offset into the record structure and a length, all you need to do is specify the field of interest and what table it’s in. See the FairCom DB documentation for further information on record schemas.

Use ctdbAddSegmentByNbr() to add a new index segment given the field and index number. Use ctdbAddSegment() to add a new index segment given the index handle. Use ctdbAddSegmentEx() to add a new extended index segment.

ctdbAddSegmentByName() does the segment handle allocation. After the segments, indexes, and fields have been defined, the table can be created or altered with ctdbCreateTable() or ctdbAlterTable(). Segment handle deallocation is automatically handled by ctdbCloseTable() and ctdbCloseAll().

  • Handle [in] the table handle.
  • IndexNbr [in] the index number. The first index is number 0.
  • FieldName [in] the field name.
  • SegMode [in] the Index segment mode. The valid values for the segment modes are: CTSEG_SCHSEG, CTSEG_USCHSEG, CTSEG_VSCHSEG, CTSEG_UVSCHSEG, CTSEG_SCHSRL, described in FairCom DB API definitions. If used with a different segment mode, this call will return error 4047, meaning invalid segment mode. ctdbAddSegmentEx() accepts any segment mode.

Returns

ctdbAddSegmentByName() returns the segment handle on success, or NULL on failure

Example


ctdbAddField(pMyTable, "Name", CT_FSTRING, 32);

ctdbAddField(pMyTable, "Balance", CT_SFLOAT, 4);

ctdbAddIndex(pMyTable, "iName", CTINDEX_FIXED, NO, NO);

ctdbAddSegmentByName(pMyTable, 0, "Name", CTSEG_USCHSEG);

RetVal = ctdbCreateTable(pMyTable, "Table1", CTCREATE_NORMAL);


See also

ctdbAddSegmentEx(), ctdbAddSegmentByNbr(), ctdbAddSegment()

ctdbAddSegmentByNbr

Add a new index segment to an index (given the table handle, field number, and index number).

Declaration

CTHANDLE ctdbAddSegmentByNbr(CTHANDLE Handle, NINT IndexNbr,

                             NINT FieldNbr, CTSEG_MODE SegMode)

Description

ctdbAddSegmentByNbr() adds a new index segment to an index, specifying the field by giving the table handle and the field number, and specifying the index by giving the index number.

The operation of adding a segment to an index links the specified index with the specified field in the specified table. When a segment is added with this function, the segment is defined based on an individual full field of a table, using what is known as a record schema. In other words, instead of using a byte offset into the record structure and a length, all you need to do is specify the field of interest and what table it’s in. See the FairCom DB documentation for further information on record schemas.

Use ctdbAddSegmentByName() to add a new index segment given its name. Use ctdbAddSegment() to add a new index segment given the index handle. Use ctdbAddSegmentEx() to add a new extended index segment.

ctdbAddSegmentByNbr() does the segment handle allocation. After the segments, indexes, and fields have been defined, the table can be created or altered with ctdbCreateTable() or ctdbAlterTable(). Segment handle deallocation is automatically handled by ctdbCloseTable() and ctdbCloseAll().

  • Handle [in] the table handle.
  • IndexNbr [in] the index number. The first index is number 0.
  • FieldNbr [in] the field number. The first field is number 0.
  • SegMode [in] the Index segment mode. The valid values for the segment modes are: CTSEG_SCHSEG, CTSEG_USCHSEG, CTSEG_VSCHSEG, CTSEG_UVSCHSEG, CTSEG_SCHSRL, described in FairCom DB API definitions. If used with a different segment mode, this call returns error 4047, invalid segment mode. ctdbAddSegmentEx() accepts any segment mode.

Returns

ctdbAddSegmentByNbr returns the segment handle on success, or NULL on failure

Example


ctdbAddField(pMyTable, "Name", CT_FSTRING, 32);

ctdbAddField(pMyTable, "Balance", CT_SFLOAT, 4);

ctdbAddIndex(pMyTable, "iName", CTINDEX_FIXED, NO, NO);

ctdbAddSegmentByNbr(pMyTable, 0, 0, CTSEG_USCHSEG);

RetVal = ctdbCreateTable(pMyTable, "Table1", CTCREATE_NORMAL);


See also

ctdbAddSegment(), ctdbAddSegmentEx(), ctdbAddSegmentByName()

ctdbAddSegmentEx

Add a new extended index segment to an index, using a byte offset into the record structure and a length.

Declaration

CTHANDLE ctdbAddSegmentEx(CTHANDLE Handle, NINT offset, NINT length,

                          CTSEG_MODE SegMode)

Description

ctdbAddSegmentEx() adds a new extended index segment given the index handle and the segment offset. A segment is extended if it is based on the segment offset. The operation of adding a segment links the index with the field in the table. To add a segment with this function, the segment may be defined based on partial individual fields, using offsets to indicate the segment beginning and extension.

Note: The offset should account for the fields that are created automatically (unless disabled): $DELFLD$ (4 bytes to account for a deleted record), $NULFLD$ (for each user defined field, FairCom DB API uses 1 bit to indicate if a null value in the field is valid - the size will be adjusted to the next byte), and $ROWID$ (8 bytes to account for the automatic auto-increment record - see the discussion on ROWID in Hidden fields). This variation makes it difficult to predict the correct offset of each user defined offset. FairCom strongly recommends the use of the regular functions (ctdbAddSegment(), ctdbAddSegmentByName() or ctdbAddSegmentByNbr()). The use of the extended segments may even prevent the use of advanced FairCom DB API functions like ctdbAlterTable(). If, for any reason, it is mandatory to use this function, try to follow the example below.

ctdbAddSegmentEx() does the segment handle allocation. After the segments, indexes, and fields have been defined, the table can be created or altered with ctdbCreateTable() or ctdbAlterTable(). Segment handle deallocation is automatically handled by ctdbCloseTable() and ctdbCloseAll().

Use ctdbIsExtSegment() to verify if the segment mode is one of the extended modes.

  • Handle [in] - the index handle.
  • offset [in] - the absolute byte offset.
  • length [in] - the segment length in bytes.
  • SegMode [in] - the Index segment mode. The valid values for the segment modes are listed in FairCom DB API definitions. Notice that ctdbAddSegmentEx() does work with Absolute byte offset segments.

Returns

ctdbAddSegmentEx() returns the segment handle on success, or NULL on failure

Example


pMyField0 = ctdbAddField(pMyTable, "Name", CT_FSTRING,32);

pMyField1 = ctdbAddField(pMyTable, "Balance", CT_SFLOAT, 4);

ctdbCreateTable(pMyTable,"Table1",CTCREATE_NORMAL);

ctdbOpenTable(pMyTable1, "MyTable3", CTOPEN_EXCLUSIVE);


pMyRec1 = ctdbAllocRecord(pMyTable1);

ctdbFirstRecord(pMyRec1);

fld_offset = ctdbGetFieldOffset(pMyRec1, 0);


pMyIndex = ctdbAddIndex(pMyTable1, "MyTable2", 0, 1, 1);

pMyIseg = ctdbAddSegmentEx(pMyIndex, fld_offset, 32, CTSEG_UREGSEG);

ctdbAlterTable(pMyTable1, 0);

 

See also

ctdbAllocSegment(), ctdbAddSegment(), ctdbInsSegmentEx(), ctdbAddSegmentByName(), ctdbAddSegmentByNbr(), ctdbGetFieldOffset(), ctdbIsExtSegment()

ctdbAddTable

Add an existing table to a database.

Declaration

CTDBRET ctdbAddTable(CTHANDLE Handle, pTEXT Name, pTEXT Path)

Description

ctdbAddTable() adds an existing table to a database. Use the Path parameter to specify where the table files are on disk. If Path is left empty, FairCom DB API will attempt to locate the files in the Server directory (client/server) or in the execution directory (standalone).

  • Handle [in] - the database handle.
  • Name [in] - the name of the table be added, including the file extension, usually .dat.
  • Path [in] - the table path.

A mirrored table can be added to a FairCom DB API database dictionary by calling the ctdbAddTable() function and specifying the table name and path using the appropriate mirror naming convention:

if (ctdbAddTable(hDatabase, "customer|mirror", "primary_path|mirror_path"))

   printf("ctdbAddTable failed\n");

If a table is created originally without mirroring, it can subsequently be mirrored as follows:

  1. Copy the original table to the mirror location.
  2. Change the ctdbOpenTable() function to use the mirror naming convention.

Returns

ctdbAddTable() returns CTDBRET_OK on success, or the c-tree error code on failure.

Example


CTHANDLE hTable;


eRet = ctdbAddTable(hTable, "custmast", "");

 

See also

ctdbAddTableXtd (ctdbAddTableXtd, ctdbAddTableXtd), ctdbCreateTable, ctdbAllocTable, ctdbDeleteTable, ctdbDropTable, ctdbSetDefaultSqlTableOwner

ctdbAddTableXtd

Add an existing table to a database with additional physical file information.

Declaration

ctdbAddTableXtd( CTHANDLE Handle, pTEXT Name, pTEXT PhysicalName, pTEXT Path )

Description

ctdbAddTableXtd() adds an existing table to a database. Use the Path parameter to specify where the table files are on disk. If Path is left empty, FairCom DB API will attempt to locate the files in the Server directory (client/server) or in the execution directory (standalone).

  • Handle [in] the database handle. As of V12 Handle can be a table handle. If it is a table handle, the database handle is derived from it, and any dictionary mark setting in the table handle is used when adding the table to the dictionary. See ctdbSetTableDictionaryMark() (ctdbSetTableDictionaryMark, ctdbSetTableDictionaryMark)
  • Name [in] the logical name of the table to be added as referenced in the FairCom DB API database.
  • PhysicalName [in] the physical name of the file on disk, including the file extension, usually .dat.
  • Path [in] the table path.

This extended function allows adding a table to a FairCom DB API database specified with a logical and physical table name (the physical table name is the name on disk without extension and path), the logical table name is the one associated with file operations such as ctdbOpenTable().

Note: While multiple files with the same physical names can be added to a FairCom DB API database dictionary, they logical names must still be unique.

A mirrored table can be added to a FairCom DB API database dictionary by calling ctdbAddTable() function and specifying the table name and path using the appropriate mirror naming convention:

if (ctdbAddTable(hDatabase, "customer|mirror", "primary_path|mirror_path"))

   printf("ctdbAddTable failed\n");

If a table is created originally without mirroring, it can subsequently be mirrored as follows:

  1. Copy the original table to the mirror location.
  2. Change the ctdbOpenTable() function to use the mirror naming convention.

Returns

ctdbAddTable() returns CTDBRET_OK on success, or the c-tree error code on failure.

Example


CTHANDLE hTable;


eRet = ctdbAddTable(hTable, "custmast1", "customer.dat" "c:\company1");

eRet = ctdbAddTable(hTable, "custmast2", "customer.dat" "c:\company2");

 

See also

ctdbAddTable(), ctdbCreateTable(), ctdbAllocTable(), ctdbDeleteTable(), ctdbDropTable()

 

ctdbAllocDatabase

Allocate and initialize a new database handle.

Declaration

CTHANDLE ctdbAllocDatabase(CTHANDLE Handle)

Description

ctdbAllocDatabase() allocates memory and initializes a new database handle and associates the handle with the session specified by Handle. Before any operations on a database can take place, the application must allocate a database handle.

  • Handle [in] - the session handle.

The next step in operating on a database is to connect the database handle returned by this function to the desired database (which has been previously added to the session specified by Handle) by calling ctdbConnect(). The database handle is released by calling ctdbFreeDatabase(). Do not release the database handle by calling the C runtime library function free().

Returns

ctdbAllocDatabase returns the database handle on success or NULL on failure.

Example


CTHANDLE hDatabase = ctdbAllocDatabase(hSession);

 

See also

ctdbFreeDatabase(), ctdbAllocSession(), ctdbAllocTable()

 

ctdbAllocRecord

Allocate a new FairCom DB API C API record handle.

Declaration

CTHANDLE ctdbAllocRecord(CTHANDLE Handle)

Description

ctdbAllocRecord() allocates memory and initialize a new record handle. Before any operation on records can take place, the application must allocate a record handle.

  • Handle [in] the table handle.

The record handle is released by calling ctdbFreeRecord(). Do not release the record handle by calling the C runtime library function free.

Returns

ctdbAllocRecord() returns the new allocated handle on success, or NULL on failure.

See also

ctdbAllocTable(), ctdbFreeRecord(), ctdbGetRecordHandle()

 

ctdbAllocSession

Allocate a new session handle and set the default attributes.

Declaration

CTHANDLE ctdbAllocSession(CTSESSION_TYPE SessionType)

Description

ctdbAllocSession() allocates memory and initializes a new session handle, setting the default attributes. Before any operations on a session can take place, the application must allocate a session handle. This function takes one parameter, the session type, and returns the new session handle, or NULL if there is not enough memory to allocate the new handle.

  • SessionType [in] the session type. There are three different session types – see Allocating a Session Handle for a more complete description:
    • CTSESSION_CTREE: For existing ISAM applications that need access to some of the FairCom DB API functionality. This mode allocates a new session for logon to the server only. No session or database dictionary files will be used. Use the session handle to allocate table handles.
    • CTSESSION_CTDB: allocate a new session using FairCom DB API session and database dictionaries. Table and index creation and modification is significantly easier than CTREE mode.
    • CTSESSION_SQL: allocate a new session using FairCom DB API session and database dictionaries. Once logged on a server, if the server is SQL then database creation creates a SQL database. Once connected to a database, if the database is a SQL database and the table is associated with the database, then table and index creation, deletion, and modifications are reflected in SQL system tables.

The session handle is released by calling ctdbFreeSession(). Do not release the session handle by calling the C runtime library function free().

Returns

Return the session handle on success or NULL on failure.

Example


CTSESSION_TYPE ctdbsess=CTSESSION_CTDB;

CTHANDLE handle = ctdbAllocSession(ctdbsess); // FairCom DB API session

 

See also

ctdbAllocDataBase(), ctdbFreeSession()

ctdbAddResource

Add a new resource to a table.

DECLARATION

 CTDBRET ctdbDECL ctdbAddResource(CTHANDLE resource, cpVOID data, VRLEN size);

DESCRIPTION

ctdbAddResource() add a new resource to a table. When adding a Resource to a table, a special variable-length record is written to the table, containing the information from the Resource Data Block. This is done even if a data file uses fixed-length records. Every Resource is identified by a unique combination of a Resource Type and a Resource Number. The Resource Number can optionally be assigned by FairCom DB during the call to ctdbAddResource(). In addition, each Resource can be identified by a Resource Name. The Resource Name is not guaranteed to be unique.

The Resource Type must be a value greater than 65536. 0 through 65536 are reserved for FairCom use. If the Resource Number is a value of CTDB_ASSIGN_RESOURCE_NUMBER (0xffffffff), FairCom DB assigns this Resource the next available Resource Number for this Resource Type in the specified data file. The assigned number can be retrieved by calling ctdbGetResourceNumber() before the resource handle is released. The Resource Name is optional. Names starting with "FC!" or "RD!", are reserved for FairCom use.

Resource is a handle allocated by ctdbAllocResource(). Data is any collection of data that you wish to store as a Resource. It can be a character string, a structure, or any variable type. Size indicates the number of bytes occupied by data.

RETURN

ctdbAddResource() returns CTDBRET_OK on success.

EXAMPLE


/* return CTDB_ASSIGN_RESOURCE_NUMBER on error */

ULONG AddMyResource(CTHANDLE Handle, ULONG type, pTEXT name, cpVOID data, VRLEN size)

{

ULONG number = CTDB_ASSIGN_RESOURCE_NUMBER;

CTHANDLE hRes = ctdbAllocResource(Handle, type, number, name);

CTDBRET eRet;

 

/* check if resource handle was allocated */

if (!hRes)

{

printf("ctdbAllocResource failed with error %d\n", ctdbGetError(Handle));

return number;

}

/* Add the resource */

if ((eRet = ctdbAddResource(hRes, data, size)) != CTDBRET_OK)

{

printf("ctdbAddResource failed with error %d\n", eRet);

ctdbFreeResource(hRes);

return eRet;

}

/* retrieve the assigned resource number */

number = ctdbGetResourceNumber(hRes);

/* release the resource handle */

ctdbFreeResource(hRes);

return number;

}

SEE ALSO

ctdbAllocResource(), ctdbFreeResource(), ctdbDeleteResource(), ctdbUpdateResource(), ctdbFirstResource(), ctdbNextResource(), ctdbFindResource(), ctdbFindResourceByName(), ctdbGetResourceType(), ctdbSetResourceType(), ctdbGetResourceNumber(), ctdbSetResourceNumber(), ctdbGetResourceName(), ctdbSetResourceName(), ctdbGetResourceDataLength(), ctdbGetResourceData(), ctdbSetResourceData(), ctdbIsResourceLocked(), ctdbUnlockResource()

ctdbAddRowIdSegment

Add a new index segment to an index, for the $ROWID$ field of a table.

Declaration

ctdbAddRowIdSegment(CTHANDLE Handle);

Description

This function provides a way to add a new segment to an index, specifying both the index and the table with a single index handle (the Handle parameter). The table is whichever table the index handle is already associated with (via the previous call to ctdbAddIndex()). The field is the $ROWID$ field of the table. This allows a part of the index key to be built from the internal $ROWID$ field value in the table.

Note that this function only works with indexes that are associated with tables that have $ROWID$ support. If you use this function against a table that doesn’t, the subsequent call to ctdbCreateTable() will fail with error CTDBRET_ROWIDSEG, indicating an attempt to create an index with a $ROWID$ reference on a table that has no $ROWID$ support.

Return Values

Value Symbolic Constant Explanation
0 CTDBRET_OK Successful operation.

See c-tree Plus Error Codes for a complete listing of valid c-tree Plus error values.

ctdbAddSegment

Add a new index segment to an index (given the index handle and a field handle).

Declaration

CTHANDLE ctdbAddSegment(CTHANDLE Handle, CTHANDLE FieldHandle,

                        CTSEG_MODE SegMode)

Description

ctdbAddSegment() adds a new index segment to an index, specifying both the field and the index by giving their handles. The operation of adding a segment to the index links the specified index with the specified field in its table. When a segment is added with this function, the segment is defined based on an individual full field of a table, using what is known as a record schema. In other words, instead of using a byte offset into the record structure and a length, all you need to provide is a handle to the field of interest. See the FairCom DB documentation for further information on record schemas.

Use ctdbAddSegmentByName() or ctdbAddSegmentByNbr() to add a segment given the index number. Use ctdbAddSegmentEx() to add a new extended index segment, that may use just part of the field as the index segment. Use ctdbInsSegment() to insert a segment in a specified position. Use ctdbDelSegment() to delete a segment from an index.

ctdbAddSegment() does the allocation of the index segment handle. After the segments, indexes, and fields have been defined, the table can be created or altered with ctdbCreateTable() or ctdbAlterTable(). Index segment handle deallocation is automatically handled by ctdbCloseTable() and ctdbCloseAll().

  • Handle [in] - the handle specifying the index which will receive the new segment.
  • FieldHandle [in] - the handle of the table field that will be used to build this segment.
  • SegMode [in] - the Index segment mode. The valid values for the segment modes are: CTSEG_SCHSEG, CTSEG_USCHSEG, CTSEG_VSCHSEG, CTSEG_UVSCHSEG, CTSEG_SCHSRL, described in FairCom DB API definitions. If used with a different segment mode, this call will return error 4047, meaning invalid segment mode. ctdbAddSegmentEx() accepts any segment mode.

Returns

ctdbAddSegment returns the segment handle on success, or NULL on failure.

When used on JSON fields, this function returns an error code of CTDBRET_NOTSUPPORTED.

Example


pMyField0 = ctdbAddField(pMyTable, "Name", CT_FSTRING,32);

pMyField1 = ctdbAddField(pMyTable, "Balance", CT_SFLOAT, 4);

pMyIndex = ctdbAddIndex(pMyTable, "iName", CTINDEX_FIXED,NO,NO);

pMyIseg = ctdbAddSegment(pMyIndex, pMyField0, CTSEG_USCHSEG);

RetVal = ctdbCreateTable(pMyTable,"Table1",CTCREATE_NORMAL);


See also

ctdbAllocSegment(), ctdbAddSegmentByName(), ctdbAddSegmentByNbr(), ctdbAddSegmentEx(), ctdbInsSegment(), ctdbCreateTable(), ctdbAlterTable()

ctdbAddToFieldMask

Add the field to field Mask.

Declaration

CTDBRET ctdbDECL ctdbAddToFieldMask(CTHANDLE Handle, NINT FieldNbr)

Description

  • Handle [IN] - Record handle
  • FieldNbr [IN] - Field number of the field to be add to the list of fields that are exposed


On the first call activates the field Mask. When the field Mask is active only fields in the field Mask can be retrieved, not record write is allowed. It optimizes the client/server communication by reducing the information retrieved from the server.

Returns

Returns CTDBRET_OK if successful, or the c-tree error code on failure.

 

ctdbAllocateResultSet

Declaration

CTHANDLE ctdbAllocateResultSet(CTHANDLE Handle, pTEXT ResSetName);

Parameters:

  • Handle [IN] - Table handle
  • ResSetName [IN] - Result Set name

Description

Allocates a result set for a specific table handle. It is also added to the table result set list for later searching.

After allocating, it is then possible to add one or more criteria using ctdbAddCriteria(). The criteria have a field to be checked against the table handle that owns the result set, one or two values (depending on the comparison operator) and the operator to be used. The operator can be on of: CTIX_EQ, CTIX_NE, CTIX_GT, CTIX_GE, CTIX_LE, CTIX_LT, CTIX_BET, CTIX_BET_IE, CTIX_BET_EI, CTIX_BET_EE or CTIX_NOTBET. When the result set has all the criteria added, it can be turned on or off with ctdbResultSetOnOff() for any record handle that is allocated for the same table handle that owns the result set.

Limitations

  • A result set can't be turned on for a record that is already filtered. And when a record has a result set turned on, it is not possible to add any other filter. This limitation may be relaxed in the future.
  • When a result set is changed (ctdbAddCriteria(), ctdbRemoveCriteria() and ctdbUpdateCriteria()), it must be re-applied to the record handle (ctdbResultSetOnOff()) to have these changed take effect.

Returns

Return a CTResultSet handle on success, or NULL on error.

Example

   CTHANDLE hResSet;
   CTHANDLE hResSetCri;

/* Allocate a Result Set for Table */
if (!(hResSet = ctdbAllocateResultSet( hTable, "resSet1" )))
    Handle_Error("Test_ResultSet1(); ctdbAllocateResultSet()");

/* Add a new criteria for the Result Set just allocated */
if (!(hResSetCri = ctdbAddCriteria( hResSet, hField0, "1002", NULL, CTIX_EQ )))
    Handle_Error("Test_ResultSet1(); ctdbAddCriteria()");

/* Turn on the Result Set for the current record handle */
if (ctdbResultSetOnOff( hResSet, hRecord, YES, YES, CTLOC_NONE ) != CTDBRET_OK)
    Handle_Error("Test_ResultSet1(); ctdbResultSetOnOff()");

/* Display records on the Result Set */
Display_Records(hRecord);

/* Release Result Set handle */
ctdbFreeResultSet( hResSet );

See also

 

ctdbAllocFTI

Allocate memory for a new Full-Text Index handle.

 

ctdbAllocResource

Allocates a new resource handle.

DECLARATION

CTHANDLE ctdbDECL ctdbAllocResource(CTHANDLE Handle, ULONG type, ULONG number, cpTEXT name);

DESCRIPTION

Allocate a new resource handle. Before any operations can be performed on resources, you are required to allocate a resource handle. Resource handles are opaque handles whose contents are not available to the developer. You must use the set of functions provided by FairCom DB API to set and get properties and to perform operations.

  • Handle is a FairCom DB API table handle.
  • type is the resource type. If the resource type is unknown you may set this parameter to zero.
  • number is the resource number. If the resource number is unknown you may set this parameter to zero.
  • name is the resource name. If you do not know this value in advance, you can set this parameter with a NULL or empty string ("").

RETURN

ctdbAllocResource() returns the resource handle on success. Returns NULL if ctdbAllocResource() fails to allocate handle, in which case you should call ctdbGetError() passing the table Handle to obtain the error code.

EXAMPLE

CTDBRET DisplayAllResources(CTHANDLE hTable)

{

CTDBRET eRet;

CTHANDLE hRes = ctdbAllocResource(hTable, 0, 0, NULL);

 

/* check if resource was allocated */

if (!hRes)

return ctdbGetError(hTable);
 

/* get the first resource */

/* note that no resource locks are acquired since we are not changing the resources */

if ((eRet = ctdbFirstResource(hRes, false)) != CTDBRET_OK)

{

ctdbFreeResource(hRes);

return eRet;

}
 

/* get the other resources */

do

{

/* display resource type, number and name */

printf("Resource type: %u, number: %u", ctdbGetResourceType(hRes), ctdbGetResourceNumber(hRes));

if (ctdbGetResourceName(hRes) != NULL)

printf(", name: \"\"\n", ctdbGetResourceName(hRes));

else

printf(", name: NULL"\n");

}

while ((eRet = ctdbNextResource(hRes, false)) != CTDBRET_OK);
 

ctdbFreeResource(hRes);

return eRet;

}

SEE ALSO

ctdbFreeResource(), ctdbAddResource(), ctdbDeleteResource(), ctdbUpdateResource(), ctdbFirstResource(), ctdbNextResource(), ctdbFindResource(), ctdbFindResourceByName(), ctdbGetResourceType(), ctdbSetResourceType(), ctdbGetResourceNumber(), ctdbSetResourceNumber(), ctdbGetResourceName(), ctdbSetResourceName(), ctdbGetResourceDataLength(), ctdbGetResourceData(), ctdbSetResourceData(), ctdbIsResourceLocked(), ctdbUnlockResource()

 

 

ctdbAllocTable

Allocate a new table handle.

Declaration

CTHANDLE ctdbAllocTable(CTHANDLE Handle)

Description

ctdbAllocTable() allocates memory and initializes a new table handle and associates that handle with the database specified by Handle. Before any operation on a table can take place, the application must allocate a table handle.

  • Handle [in] the database handle, previously allocated by calling ctdbAllocDatabase(). Note that this handle does not need to be connected to a database when ctdbAllocTable() is called.

The next step after calling this function is generally to call ctdbOpenTable(). The table handle is released by calling ctdbFreeTable(). Do not release the table handle by calling the C runtime library function free().

Returns

ctdbAllocTable() returns the table handle on success or NULL on failure.

Example


CTSESSION_TYPE ctdbsess=CTSESSION_CTDB;

CTHANDLE hSession = ctdbAllocSession(ctdbsess);

CTHANDLE hDatabase = ctdbAllocDatabase(hSession);

CTHANDLE hTable = ctdbAllocTable(hDatabase);

 

See also

ctdbAllocDatabase(), ctdbFreeTable()

 

ctdbAlterTable

Rebuild existing table based on field, index, and segment changes.

Declaration

CTDBRET ctdbAlterTable(CTHANDLE Handle, NINT Action)

Description

ctdbAlterTable() rebuilds an existing table based on field, index and segment changes.

  • Handle [in] the table handle.
  • Action [in] the alter table action. One or more of the following actions can be selected:
    • CTDB_ALTER_NORMAL: Check for changes before altering.
    • CTDB_ALTER_INDEX: Force rebuild of all indexes.
    • CTDB_ALTER_FULL: Force full table rebuild.
    • CTDB_ALTER_TRUNCATE: Quickly remove all records.
    • CTDB_ALTER_PURGEDUP: OR in with any of the other modes to deal with cases where an alter table is performed on data files with duplicated index information.
    • CTDB_ALTER_KEEPTRAN: Allow tables with different TRANDEP modes (e.g. transaction capable, however, transaction control disabled for performance) to undergo ALTER TABLE. (This is generally an internal FairCom operation for certain table types.)
    • CTDB_ALTER_V8DELFLD: (Supported in V10.3 and later) The table (if re-created) must have the old $DELFLD$ size (CTDB_ALTER_V8DELFLD forces CTCREATE_V8DELFLD during "alter table").
    • CTDB_ALTER_HOT: (Supported in V11.5 and later) A Hot Alter Table will be performed if possible (which requires the file to use the FLEXREC feature and for the changes to the schema to be possible to accomplish using Hot Alter Table). If a Hot Alter Table cannot be performed, ctdbAlterTable() returns error CTDBRET_NOTSUPPORTED.

Unix Note: Due to the non-exclusive nature of Unix, this function can be successfully executed on a file that was opened by several other applications in shared mode. However, although the function succeeds, it may cause havoc for the other applications. This can be prevented by enforcing exclusivity with locks, however, this is not the default mode.

Mirrored Files: The FairCom DB API alter table function will not operate on mirrored tables. If ctdbAlterTable() is called for a mirrored table, nothing is done and it returns error CTDBRET_NOTSUPPORTED.

Existing Indexes: For updating the conditional expression of existing indexes, use ctdbAlterTable() with mode CTDB_ALTER_INDEX.

Returns

ctdbAlterTable() returns CTDBRET_OK if successful, or the c-tree error code on failure.

See also

ctdbCreateTable()

 

ctdbAttachSession

Attaches an already initialized c-tree session to a FairCom DB API session handle.

DECLARATION

CTDBRET ctdbDECL ctdbAttachSession(CTHANDLE Handle, pVOID source, CTATTACH_MODE mode, CTBOOL isTransactionActive);

DESCRIPTION

ctdbAttachSession() attaches an already initialized c-tree ISAM or low-level session to a FairCom DB API session handle. Attached sessions have no information about the server, user name or user password, and these values are set to NULL.

  • Handle is a Session handle allocated by ctdbAllocSession().
  • source is a parameter that points to the session handle or the instance ID string depending on the mode parameter (see mode below).
  • mode is one of the following:

CTATTACH_SESSION - Attach to a FairCom DB API session whose session handle is pointed by the source parameter.

CTATTACH_CTREEID - Attach to a c-tree session whose instance ID string is pointed by the source parameter.

CTATTACH_CURRENT - Attach to the current c-tree instance. Contents of the source parameter is ignored, as the c-tree instance ID is obtained by calling the WCHCTREE() function.

  • isTransactionActive should indicate if a transaction is active or not. Acceptable values are TRUE or FALSE. 

Returns

Value Symbolic Constant Explanation
0 NO_ERROR No error occurred.

See Errors for a complete listing of valid c-tree error values.

EXAMPLE

/* logon to c-tree using ISAM function */
INTISAMX(10, 32, 32, 10, (USERPRF_NTKEY | USERPRF_CLRCHK),"admin","ADMIN","FAIRCOMS");
 
/* attach session to server handle */
if (ctdbAttachSession(hSession,NULL,CTATTACH_CURRENT,FALSE) != CTDBRET_OK)
    printf("ctdbAttachSession failed\n");
 
/*
... do something useful ...
*/
 
/* detach from session */
if (ctdbDetachSession(hSession) != CTDBRET_OK)
    printf("ctdbDetachSession failed\n");
 
/* perform an ISAM logout */
CLISAM();

See Also:
ctdbDetachSession()

 

 

ctdbAttachTable

Attaches a FairCom DB ISAM datno object to a FairCom DB API table handle.

DECLARATION

CTDBRET ctdbAttachTable(CTHANDLE Handle, NINT datno);

DESCRIPTION

ctdbAttachTable() attaches a FairCom DB ISAM datno object to a FairCom DB API table handle. This function is useful if you have opened a data and index file using one of c- tree’s ISAM open functions and need to attach it to a table handle to use some of the advanced FairCom DB API features such as alter table or the record handler. Handle is a table handle and datno is data file number opened with one of the c-tree ISAM open functions.

RETURN

Value Symbolic Constant Explanation
0 NO_ERROR No error occurred.

See Appendix A for a complete listing of valid c-tree Plus error values.

EXAMPLE

CTHANDLE hSession = ctdbAllocSession(CTSESSION_CTREE);

CTHANDLE hTable = ctdbAllocTable(hSession);

CTHANDLE hRecord = ctdbAllocRecord(hTable);

NINT datno, count = 0;


/* logon to c-tree */

ctdbLogon(hSession, SERVER, USER, PASSWD);


/* open the file using c-tree ISAM */

datno = (NINT)OPNRFILX((COUNT) -1, "test309.dat", (COUNT)0, NULL);


/* attach to table */

ctdbAttachTable(hTable, datno);


/* read the records */

if (ctdbFirstRecord(hRecord) == CTDBRET_OK)

do

{

     count++;

}

while (ctdbNextRecord(hRecord) == CTDBRET_OK);


/* cleanup */

ctdbDetachtable(hTable);

ctdbFreeRecord(hRecord);

ctdbFreeTable(hTable);

ctdbLogout(hSession);

ctdbFreeSession(hSession);

 

SEE ALSO

ctdbAttachXtd, ctdbDetach

 

ctdbAttachTableXtd

Attaches a FairCom DB ISAM datno object to a FairCom DB API table handle allowing a DODA and IFIL to be specified.

DECLARATION

CTDBRET ctdbAttachTableXtd(CTHANDLE Handle, NINT datno, NINT nbrfields, pDATOBJ dodaptr, pIFIL ifilptr)

DESCRIPTION

ctdbAttachTableXtd() attaches a FairCom DB ISAM datno object to a FairCom DB API table handle. This function is useful if you have opened a data and index file using one of c-tree’s ISAM open functions and need to attach it to a table handle to use some of the advanced FairCom DB API features such as alter table or the record handler. This extended version allows the user to specify the DODA and IFIL for the table, enabling tables without DODA and/or IFIL to be attached to FairCom DB API.

Handle is a table handle and datno is the data file number. nbrfields is the number of fields described by dodaptr. If nbrfields is zero, it is assumed that the DODA is not supplied and a DODA resource will be read from the table itself. dodaptr pointer to DODA entries for each field in table. If dodaptr is NULL, it is assumed that the DODA is not supplied and a DODA resource will be read from the table itself. ifilptr is a pointer to IFIL structure describing indexes of table. If ifilptr is NULL it is assumed that an IFIL is not supplied and an IFIL resource will be read from the table itself.

RETURN

Value Symbolic Constant Explanation
0 NO_ERROR No error occurred.

See Appendix A for a complete listing of valid c-tree Plus error values.

EXAMPLE

/* DODA */

static DATOBJ doda[] =

{

    {"f1", (pTEXT)0, CT_INT4, 4},

    {"f2", (pTEXT)4, CT_FSTRING, 10}

};


/* IFIL */

static ISEG iseg = {0, 4, 12};

static IIDX iidx = {4, 0, 0, 0, 0, 1, &iseg, "i311x1", NULL, NULL, NULL};

static IFIL ifil = {"test310", -1, 14, 0, 0, 1, 0, 0, &iidx, "f1", "f2", 0};


CTHANDLE hSession = ctdbAllocSession(CTSESSION_CTREE);

CTHANDLE hTable = ctdbAllocTable(hSession);

CTHANDLE hRecord = ctdbAllocRecord(hTable);

NINT datno, count = 0;


/* logon to c-tree */

ctdbLogon(hSession, SERVER, USER, PASSWD);


/* open the file using c-tree ISAM */

datno = (NINT)OPNRFILX((COUNT) -1, "test309.dat", (COUNT)0, NULL);


/* attach to table */

ctdbAttachTableXtd(hTable, datno, doda, &ifil);


/* read the records */

if (ctdbFirstRecord(hRecord) == CTDBRET_OK)

do

{

    count++;

}

while (ctdbNextRecord(hRecord) == CTDBRET_OK);


/* cleanup */

ctdbDetachtable(hTable);

ctdbFreeRecord(hRecord);

ctdbFreeTable(hTable);

ctdbLogout(hSession);

ctdbFreeSession(hSession);

 

SEE ALSO

ctdbAttachTable(), ctdbDetachTable()

 

ctdbBlobAlloc

Allocate a new blob type.

Declaration

pCTBLOB ctdbBlobAlloc(VRLEN size)

Description

ctdbBlobAlloc() allocates a new blob type.

  • size [in] the size in bytes to allocate for the blob data.

The blob is released by calling ctdbBlobFree(). Do not release the blob by calling the C runtime library function free().

Returns

ctdbBlobAlloc() returns the blob pointer, or NULL on failure.

See also

ctdbBlobFree()

 

ctdbBlobFree

Release all resources associated with a blob.

Declaration

void ctdbBlobFree(pCTBLOB pBlob)

Description

ctdbBlobFree releases all resources associated with a blob. ctdbBlobClear clears the blob data.

  • pBlob [in] the blob pointer

Returns

None.

See also

ctdbBlobAlloc(), ctdbBlobClear()