Product Documentation

c-treeDB API API for C

Previous Topic

Next Topic


Allocate a new session handle and set the default attributes.


CTHANDLE ctdbAllocSession(CTSESSION_TYPE SessionType)


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 c-treeDB 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 c-treeDB API session and database dictionaries. Table and index creation and modification is significantly easier than CTREE mode.
    • CTSESSION_SQL: allocate a new session using c-treeDB 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().


Return the session handle on success or NULL on failure.



CTHANDLE handle = ctdbAllocSession(ctdbsess); // c-treeDB API session

See also

ctdbAllocDataBase(), ctdbFreeSession()