Product Documentation

c-treeDB API API for C

Previous Topic

Next Topic

Session Properties

The default session properties are suitable for most c-treeDB API applications. Advanced developers may need to tune c-treeDB API to meet application requirements. Use ctdbSetSessionParams() to set the following properties:

Property

Description

Default

BUFS

Index file buffers

10

FILS

File structure blocks

32

SECT

Node sectors

32

DBUFS

Data file buffers

10

USERPROF

User profile mask

513

The default USERPROF value of 513 tells single-user, transaction-control applications to remove the auxiliary log files S*.FCS and L*.FCS upon successful termination of the application, and also removes the automatic key transformation. The table below presents the bit values for the USERPROF parameter. They can be combined by OR’ing them together.

The table below present all possible values for the USERPROF parameter. See InitISAMXtd for detailed descriptions.

User Profile Values

Keyword

Value

Explanation

USERPRF_NTKEY

1

Do not perform auto tfrmkey

USERPRF_SAVENV

2

Savenv mode for transactions

USERPRF_NDATA

32

Do not perform auto data - UNIFRMAT conversion

USERPRF_LOCLIB

64

Use a local library: not server

USERPRF_PTHTMP

128

Add tmpname to input path, otherwise use system tmpname

USERPRF_CLRCHK

512

Clear transaction logs

Example


/* setting different user profile before logging on to session */

ctdbSetSessionParam(hSession, USERPROF, (USERPRF_NTKEY | USERPROF_CLRCHK));

if (ctdbLogon(hSession, "FAIRCOMS", "ADMIN", "ADMIN) != CTDBRET_OK)

FatalError("Session logon failed\n");

In This Section

Server, user name and password properties

Active property

Path property

Previous Topic

Next Topic

Server, user name and password properties

Once a session is active, the user may retrieve the server name for the session with ctdbGetServerName(). Retrieve the user name by calling the ctdbGetUserLogonName() function.

Please refer to the example in Active property.

Previous Topic

Next Topic

Active property

A session is active if the user has logged on to a valid session dictionary using ctdbLogon(). To render a session inactive, log off using ctdbLogout(). To verify the status of the session, use ctdbIsActiveSession().

Example


/* if session is active, retrieve the server name and user logon name */

if (ctdbIsActiveSession(hSession))

{

printf("Server name: %s\n", ctdbGetServerName(hSession));

printf("User name : %s\n", ctdbGetUserLogonName(hSession));

}

Previous Topic

Next Topic

Path property

The default path for client/server applications is the server directory, while the default path for non-server applications is the execution directory. If, for any reason, there is the need to modify the location of the session dictionary on the server, the function ctdbSetSessionPath() may be used, before creating and/or logging on to the session. ctdbGetSessionPath() may be used to retrieve the path for an active session. Note that ctdbGetSessionPath() will return an empty result until the default path has been set with a call to ctdbSetSessionPath().

Using this property, it is even possible to have multiple session dictionaries, in separate directories. This is not required, since the concepts of restricting access to different users to diverse tables or databases may be implemented inside a unique session dictionary.

The example below shows how to use the ctdbSetSessionPath() function to create a session dictionary file in a user specified directory, instead of the default directory

Example


CTHANDLE hSession;


hSession = ctdbAllocSession(CTSESSION_CTDB);

if (!hSession)

FatalError("Session handle allocation failed\n");


ctdbSetSessionPath(hSession, "\new\session\dictionary");

if (ctdbCreateSession(hSession, "FAIRCOMS", "ADMIN", "ADMIN") != CTDBRET_OK)

FatalError("Error creating session dictionary file\n");

TOCIndex