Product Documentation

c-treeDB API API for C

Previous Topic

Next Topic

ctdbRemoveTable

Removes any c-tree table.

Declaration

CTDBRET ctdbDECL ctdbRemoveTable(CTHANDLE Handle);

  • Handle is a table handle.

Description

The ctdbRemoveTable() function allows any table data file and its associated index files to be deleted from disk, including tables that are not members of a database / not created in a CTSESSION_CTDB or CTSESSION_SQL session. This function is intended for CTSESSION_CTREE tables, which are not a part of a database.

If the table was opened under a database handle, the table is closed and ctdbDeleteTable() is called. The handle must be active.

If the table was opened under a database handle, meaning that the provided table handle is "active", this function closes that table and then calls ctdbDeleteTable() to delete the files. If the table handle is not active, the table is opened exclusive by this function and then deleted. In this case, you must first set the path, file extension, and password for the table handle before calling ctdbRemoveTable(). See ctdbSetTablePath(), ctdbSetTableExtension(), and ctdbSetTablePassword(). Note that it is simpler to delete the table and index files using ctdbDeleteTable(), so use that function if you can.

V11.5 and Later

In V11.5 and later, ctdbRemoveTable() expects the table handle to have the path, password, file extension, and name information. A non-active table handle does not have this information. (Close and create clean up and deactivate the table handle.) While the path, password and file extensions can be set by the c-treeDB API API, there is no function to set the name. As a result, ctdbRemoveTable() does not work on non-active tables and could have failed with various errors.

This function will now fail immediately and return error CTDBRET_NOTACTIVE (4012) if the table handle is not active.

ctdbRemoveTable() deletes a c-tree data file and associated index files from disk. If the table was opened under a database handle, the table is closed and ctdbDeleteTable() is called. The handle must be active.

Compatibility Change: This modification is a change in behavior.

Return

Value

Symbolic Constant

Explanation

0

CTDBRET_OK

ctdbRemoveTable() returns CTDBRET_OK on success or c-treeDB API SDK error code on failure.

 

CTDBRET_NOTACTIVE

If the table is not active, ctdbRemoveTable() returns this error and fails immediately.

See c-treeDB API Errors and Return Values for a complete listing of valid c-treeDB APIerror codes and return values.

Example


/* delete a c-treeDB API table */

if (ctdbRemoveTable(MyHandle) != CTDBRET_OK)

printf("ctdbRemoveTable Failed!\n");

See also

ctdbDeleteTable()

TOCIndex