Version 1.1.5
WT_CONNECTION Struct Reference

A connection to a WiredTiger database. More...

List of all members.

Public Member Functions

int load_extension (WT_CONNECTION *connection, const char *path, const char *config)
 Load an extension.
int add_cursor_type (WT_CONNECTION *connection, const char *prefix, WT_CURSOR_TYPE *ctype, const char *config)
 Add a new type of cursor.
int add_collator (WT_CONNECTION *connection, const char *name, WT_COLLATOR *collator, const char *config)
 Add a custom collation function.
int add_compressor (WT_CONNECTION *connection, const char *name, WT_COMPRESSOR *compressor, const char *config)
 Add a compression function.
int add_extractor (WT_CONNECTION *connection, const char *name, WT_EXTRACTOR *extractor, const char *config)
 Add a custom extractor for index keys or column groups.
int close (WT_CONNECTION *connection, const char *config)
 Close a connection.
const char * get_home (WT_CONNECTION *connection)
 The home directory of the connection.
int is_new (WT_CONNECTION *connection)
 Return if opening this handle created the database.
int open_session (WT_CONNECTION *connection, WT_EVENT_HANDLER *errhandler, const char *config, WT_SESSION **sessionp)
 Open a session.

Detailed Description

A connection to a WiredTiger database.

The connection may be opened within the same address space as the caller or accessed over a socket connection.

Most applications will open a single connection to a database for each process. The first process to open a connection to a database will access the database in its own address space. Subsequent connections (if allowed) will communicate with the first process over a socket connection to perform their operations.

Examples:
ex_access.c, ex_all.c, ex_call_center.c, ex_config.c, ex_cursor.c, ex_extending.c, ex_hello.c, ex_pack.c, ex_schema.c, ex_stat.c, ex_thread.c, and ex_transaction.c.

Member Function Documentation

int WT_CONNECTION::add_collator ( WT_CONNECTION connection,
const char *  name,
WT_COLLATOR collator,
const char *  config 
)

Add a custom collation function.

Not yet supported in WiredTiger.

The application must first implement the WT_COLLATOR interface and then register the implementation with WiredTiger:

        static WT_COLLATOR my_collator = { my_compare };
        ret = conn->add_collator(conn, "my_collator", &my_collator, NULL);
Parameters:
connectionthe connection handle
namethe name of the collation to be used in calls to WT_SESSION::create
collatorthe application-supplied collation handler
configConfiguration string, see Configuration Strings. No values currently permitted.
Returns:
zero on success and a non-zero error code on failure. See Error Returns for details.
Examples:
ex_all.c, and ex_extending.c.
int WT_CONNECTION::add_compressor ( WT_CONNECTION connection,
const char *  name,
WT_COMPRESSOR compressor,
const char *  config 
)

Add a compression function.

The application must first implement the WT_COMPRESSOR interface and then register the implementation with WiredTiger:

        static WT_COMPRESSOR my_compressor = {
            my_compress, my_decompress, my_pre_size };
        ret = conn->add_compressor(conn, "my_compress", &my_compressor, NULL);
Parameters:
connectionthe connection handle
namethe name of the compression function to be used in calls to WT_SESSION::create
compressorthe application-supplied compression handler
configConfiguration string, see Configuration Strings. No values currently permitted.
Returns:
zero on success and a non-zero error code on failure. See Error Returns for details.
Examples:
ex_all.c.
int WT_CONNECTION::add_cursor_type ( WT_CONNECTION connection,
const char *  prefix,
WT_CURSOR_TYPE ctype,
const char *  config 
)

Add a new type of cursor.

Not yet supported in WiredTiger.

The application must first implement the WT_CURSOR_TYPE interface and then register the implementation with WiredTiger:

        static WT_CURSOR_TYPE my_ctype = { my_cursor_size, my_init_cursor };
        ret = conn->add_cursor_type(conn, NULL, &my_ctype, NULL);
Parameters:
connectionthe connection handle
prefixthe prefix for location strings passed to WT_SESSION::open_cursor
ctypethe application-supplied code to manage cursors of this type
configConfiguration string, see Configuration Strings. No values currently permitted.
Returns:
zero on success and a non-zero error code on failure. See Error Returns for details.
Examples:
ex_all.c.
int WT_CONNECTION::add_extractor ( WT_CONNECTION connection,
const char *  name,
WT_EXTRACTOR extractor,
const char *  config 
)

Add a custom extractor for index keys or column groups.

Not yet supported in WiredTiger.

The application must first implement the WT_EXTRACTOR interface and then register the implementation with WiredTiger:

        static WT_EXTRACTOR my_extractor;
        my_extractor.extract = my_extract;
        ret = conn->add_extractor(conn, "my_extractor", &my_extractor, NULL);
Parameters:
connectionthe connection handle
namethe name of the extractor to be used in calls to WT_SESSION::create
extractorthe application-supplied extractor
configConfiguration string, see Configuration Strings. No values currently permitted.
Returns:
zero on success and a non-zero error code on failure. See Error Returns for details.
Examples:
ex_all.c.
int WT_CONNECTION::close ( WT_CONNECTION connection,
const char *  config 
)

Close a connection.

Any open sessions will be closed.

        ret = conn->close(conn, NULL);
Parameters:
connectionthe connection handle
configConfiguration string, see Configuration Strings. No values currently permitted.
Returns:
zero on success and a non-zero error code on failure. See Error Returns for details.
Examples:
ex_access.c, ex_all.c, ex_call_center.c, ex_config.c, ex_cursor.c, ex_extending.c, ex_hello.c, ex_pack.c, ex_schema.c, ex_stat.c, ex_thread.c, and ex_transaction.c.
const char* WT_CONNECTION::get_home ( WT_CONNECTION connection)

The home directory of the connection.

        printf("The database home is %s\n", conn->get_home(conn));
Parameters:
connectionthe connection handle
Returns:
a pointer to a string naming the home directory
Examples:
ex_all.c.
int WT_CONNECTION::is_new ( WT_CONNECTION connection)

Return if opening this handle created the database.

        if (conn->is_new(conn)) {
                /* First time initialization. */
        }
Parameters:
connectionthe connection handle
Returns:
false (zero) if the connection existed before the call to wiredtiger_open, true (non-zero) if it was created by opening this handle.
Examples:
ex_all.c.
int WT_CONNECTION::load_extension ( WT_CONNECTION connection,
const char *  path,
const char *  config 
)

Load an extension.

        ret = conn->load_extension(conn, "my_extension.dll", NULL);
Parameters:
connectionthe connection handle
paththe filename of the extension module
configConfiguration string, see Configuration Strings. Permitted values:
NameEffectValues
entrythe entry point of the extension.a string; default wiredtiger_extension_init.
prefixa prefix for all names registered by this extension (e.g., to make namespaces distinct or during upgrades.a string; default empty.
Returns:
zero on success and a non-zero error code on failure. See Error Returns for details.
Examples:
ex_all.c.
int WT_CONNECTION::open_session ( WT_CONNECTION connection,
WT_EVENT_HANDLER errhandler,
const char *  config,
WT_SESSION **  sessionp 
)

Open a session.

        WT_SESSION *session;
        ret = conn->open_session(conn, NULL, NULL, &session);
Parameters:
connectionthe connection handle
errhandlerAn error handler. If NULL, the connection's error handler is used
configConfiguration string, see Configuration Strings. No values currently permitted.
sessionpthe new session handle
Returns:
zero on success and a non-zero error code on failure. See Error Returns for details.
Examples:
ex_access.c, ex_all.c, ex_call_center.c, ex_config.c, ex_cursor.c, ex_extending.c, ex_hello.c, ex_pack.c, ex_schema.c, ex_stat.c, ex_thread.c, and ex_transaction.c.