The default database properties are suitable for most c-treeDB API applications. Advanced developers may need to tune c-treeDB API to meet application requirements.
Database Name
Once the database handle is connected to a database, the database name can be retrieved by calling ctdbGetDatabaseName(). ctdbGetDatabaseName() returns NULL if the database handle is not connected to a database or the database handle is invalid.
/* display the database name */
printf("Database: %s\n", ctdbGetDatabaseName(hDatabase));
Table Count
ctdbGetTableCount() retrieves the number of tables associated with a database, or returns -1 if the database handle is not connected to a database or if the database handle is invalid.
/* display the number of tables in database */
printf("Number of tables: %d\n", ctdbGetTableCount(hDatabase));
Database Path
The database path, by default, is the server directory for client/server applications, or the execution directory for non-server applications. This is where the database dictionary file (which maintains information about the tables associated with the database) is stored on disk. To set a different database path, when the database is being created, just insert the appropriate path as the third parameter in ctdbCreateDatabase(). (See Creating a New Database.) With this information stored in the Session dictionary, the user doesn't need to know where the database dictionary file is located on disk, since it will be automatically retrieved given the database name (ctdbConnect()).
Once the database is successfully connected to a session (via a database handle), the database path can be obtained by calling ctdbGetDatabasePath().
/* display database properties */
void DisplayDatabaseProperties(CTHANDLE hDatabase)
{
printf("Database: %s\n", ctdbGetDatabaseName(hDatabase));
printf( "Path: %s\n", ctdbGetDatabasePath(hDatabase));
printf("Number of tables: %d\n", ctdbGetTableCount(hDatabase));
}