Version 3.1.1
WT_EXTENSION_API Struct Reference

Table of WiredTiger extension methods. More...

Public Attributes

int(* err_printf )(WT_EXTENSION_API *wt_api, WT_SESSION *session, const char *fmt,...)
 Insert an error message into the WiredTiger error stream. More...
 
int(* msg_printf )(WT_EXTENSION_API *, WT_SESSION *session, const char *fmt,...)
 Insert a message into the WiredTiger message stream. More...
 
const char *(* strerror )(WT_EXTENSION_API *, WT_SESSION *session, int error)
 Return information about an error as a string. More...
 
int(* map_windows_error )(WT_EXTENSION_API *wt_api, WT_SESSION *session, uint32_t windows_error)
 Map a Windows system error code to a POSIX 1003.1/ANSI C error. More...
 
void *(* scr_alloc )(WT_EXTENSION_API *wt_api, WT_SESSION *session, size_t bytes)
 Allocate short-term use scratch memory. More...
 
void(* scr_free )(WT_EXTENSION_API *, WT_SESSION *session, void *ref)
 Free short-term use scratch memory. More...
 
int(* collator_config )(WT_EXTENSION_API *wt_api, WT_SESSION *session, const char *uri, WT_CONFIG_ARG *config, WT_COLLATOR **collatorp, int *ownp)
 Configure the extension collator method. More...
 
int(* collate )(WT_EXTENSION_API *wt_api, WT_SESSION *session, WT_COLLATOR *collator, WT_ITEM *first, WT_ITEM *second, int *cmp)
 The extension collator method. More...
 
int(* config_get )(WT_EXTENSION_API *wt_api, WT_SESSION *session, WT_CONFIG_ARG *config, const char *key, WT_CONFIG_ITEM *value)
 Return the value of a configuration key. More...
 
int(* config_get_string )(WT_EXTENSION_API *wt_api, WT_SESSION *session, const char *config, const char *key, WT_CONFIG_ITEM *value)
 Return the value of a configuration key from a string. More...
 
int(* config_parser_open )(WT_EXTENSION_API *wt_api, WT_SESSION *session, const char *config, size_t len, WT_CONFIG_PARSER **config_parserp)
 Create a handle that can be used to parse or create configuration strings compatible with WiredTiger APIs. More...
 
int(* config_parser_open_arg )(WT_EXTENSION_API *wt_api, WT_SESSION *session, WT_CONFIG_ARG *config, WT_CONFIG_PARSER **config_parserp)
 Create a handle that can be used to parse or create configuration strings compatible with WiredTiger APIs. More...
 
int(* metadata_insert )(WT_EXTENSION_API *wt_api, WT_SESSION *session, const char *key, const char *value)
 Insert a row into the metadata if it does not already exist. More...
 
int(* metadata_remove )(WT_EXTENSION_API *wt_api, WT_SESSION *session, const char *key)
 Remove a row from the metadata. More...
 
int(* metadata_search )(WT_EXTENSION_API *wt_api, WT_SESSION *session, const char *key, char **valuep)
 Return a row from the metadata. More...
 
int(* metadata_update )(WT_EXTENSION_API *wt_api, WT_SESSION *session, const char *key, const char *value)
 Update a row in the metadata by either inserting a new record or updating an existing record. More...
 
int(* struct_pack )(WT_EXTENSION_API *wt_api, WT_SESSION *session, void *buffer, size_t size, const char *format,...)
 Pack a structure into a buffer. More...
 
int(* struct_size )(WT_EXTENSION_API *wt_api, WT_SESSION *session, size_t *sizep, const char *format,...)
 Calculate the size required to pack a structure. More...
 
int(* struct_unpack )(WT_EXTENSION_API *wt_api, WT_SESSION *session, const void *buffer, size_t size, const char *format,...)
 Unpack a structure from a buffer. More...
 
int(* pack_start )(WT_EXTENSION_API *wt_api, WT_SESSION *session, const char *format, void *buffer, size_t size, WT_PACK_STREAM **psp)
 Start a packing operation into a buffer. More...
 
int(* unpack_start )(WT_EXTENSION_API *wt_api, WT_SESSION *session, const char *format, const void *buffer, size_t size, WT_PACK_STREAM **psp)
 Start an unpacking operation from a buffer. More...
 
int(* pack_close )(WT_EXTENSION_API *wt_api, WT_PACK_STREAM *ps, size_t *usedp)
 Close a packing stream. More...
 
int(* pack_item )(WT_EXTENSION_API *wt_api, WT_PACK_STREAM *ps, WT_ITEM *item)
 Pack an item into a packing stream. More...
 
int(* pack_int )(WT_EXTENSION_API *wt_api, WT_PACK_STREAM *ps, int64_t i)
 Pack a signed integer into a packing stream. More...
 
int(* pack_str )(WT_EXTENSION_API *wt_api, WT_PACK_STREAM *ps, const char *s)
 Pack a string into a packing stream. More...
 
int(* pack_uint )(WT_EXTENSION_API *wt_api, WT_PACK_STREAM *ps, uint64_t u)
 Pack an unsigned integer into a packing stream. More...
 
int(* unpack_item )(WT_EXTENSION_API *wt_api, WT_PACK_STREAM *ps, WT_ITEM *item)
 Unpack an item from a packing stream. More...
 
int(* unpack_int )(WT_EXTENSION_API *wt_api, WT_PACK_STREAM *ps, int64_t *ip)
 Unpack a signed integer from a packing stream. More...
 
int(* unpack_str )(WT_EXTENSION_API *wt_api, WT_PACK_STREAM *ps, const char **sp)
 Unpack a string from a packing stream. More...
 
int(* unpack_uint )(WT_EXTENSION_API *wt_api, WT_PACK_STREAM *ps, uint64_t *up)
 Unpack an unsigned integer from a packing stream. More...
 
uint64_t(* transaction_id )(WT_EXTENSION_API *wt_api, WT_SESSION *session)
 Return the current transaction ID. More...
 
int(* transaction_isolation_level )(WT_EXTENSION_API *wt_api, WT_SESSION *session)
 Return the current transaction's isolation level; returns one of WT_TXN_ISO_READ_COMMITTED, WT_TXN_ISO_READ_UNCOMMITTED, or WT_TXN_ISO_SNAPSHOT. More...
 
int(* transaction_notify )(WT_EXTENSION_API *wt_api, WT_SESSION *session, WT_TXN_NOTIFY *notify)
 Request notification of transaction resolution by specifying a function to be called when the session's current transaction is either committed or rolled back. More...
 
uint64_t(* transaction_oldest )(WT_EXTENSION_API *wt_api)
 Return the oldest transaction ID not yet visible to a running transaction. More...
 
int(* transaction_visible )(WT_EXTENSION_API *wt_api, WT_SESSION *session, uint64_t transaction_id)
 Return if the current transaction can see the given transaction ID. More...
 
const char *(* version )(int *majorp, int *minorp, int *patchp)
 Get version information. More...
 

Detailed Description

Table of WiredTiger extension methods.

This structure is used to provide a set of WiredTiger methods to extension modules without needing to link the modules with the WiredTiger library.

The extension methods may be used both by modules that are linked with the WiredTiger library (for example, a data source configured using the WT_CONNECTION::add_data_source method), and by modules not linked with the WiredTiger library (for example, a compression module configured using the WT_CONNECTION::add_compressor method).

To use these functions:

#include <wiredtiger_ext.h>
static WT_EXTENSION_API *wt_api;
static void
my_data_source_init(WT_CONNECTION *connection)
{
wt_api = connection->get_extension_api(connection);
}

The following code is from the sample compression module, where compression extension functions are configured in the extension's entry point:

/* Local compressor structure. */
typedef struct {
WT_COMPRESSOR compressor; /* Must come first */
WT_EXTENSION_API *wt_api; /* Extension API */
unsigned long nop_calls; /* Count of calls */
} NOP_COMPRESSOR;
/*
* wiredtiger_extension_init --
* A simple shared library compression example.
*/
int
{
NOP_COMPRESSOR *nop_compressor;
(void)config; /* Unused parameters */
if ((nop_compressor = calloc(1, sizeof(NOP_COMPRESSOR))) == NULL)
return (errno);
/*
* Allocate a local compressor structure, with a WT_COMPRESSOR structure
* as the first field, allowing us to treat references to either type of
* structure as a reference to the other type.
*
* Heap memory (not static), because it can support multiple databases.
*/
nop_compressor->compressor.compress = nop_compress;
nop_compressor->compressor.compress_raw = NULL;
nop_compressor->compressor.decompress = nop_decompress;
nop_compressor->compressor.pre_size = nop_pre_size;
nop_compressor->compressor.terminate = nop_terminate;
nop_compressor->wt_api = connection->get_extension_api(connection);
/* Load the compressor */
return (connection->add_compressor(
connection, "nop", (WT_COMPRESSOR *)nop_compressor, NULL));
}
Examples:
ex_encrypt.c, ex_file_system.c, nop_encrypt.c, and rotn_encrypt.c.

Member Data Documentation

◆ collate

int(* WT_EXTENSION_API::collate) (WT_EXTENSION_API *wt_api, WT_SESSION *session, WT_COLLATOR *collator, WT_ITEM *first, WT_ITEM *second, int *cmp)

The extension collator method.

Parameters
wt_apithe extension handle
sessionthe session handle (or NULL if none available)
collatorthe collator (or NULL if none available)
firstfirst item
secondsecond item
[out]cmpset less than 0 if first collates less than second, set equal to 0 if first collates equally to second, set greater than 0 if first collates greater than second
Returns
zero on success and a non-zero error code on failure. See Error handling for details.
WT_ITEM first, second;
int cmp;
first.data = key1;
first.size = key1_len;
second.data = key2;
second.size = key2_len;
error_check(wt_api->collate(
wt_api, session, collator, &first, &second, &cmp));
if (cmp == 0)
printf("key1 collates identically to key2\n");
else if (cmp < 0)
printf("key1 collates less than key2\n");
else
printf("key1 collates greater than key2\n");

◆ collator_config

int(* WT_EXTENSION_API::collator_config) (WT_EXTENSION_API *wt_api, WT_SESSION *session, const char *uri, WT_CONFIG_ARG *config, WT_COLLATOR **collatorp, int *ownp)

Configure the extension collator method.

Parameters
wt_apithe extension handle
sessionthe session handle (or NULL if none available)
urithe URI of the handle being configured
configthe configuration information passed to an application
collatorpthe selector collator, if any
ownpset if the collator terminate method should be called when no longer needed
Returns
zero on success and a non-zero error code on failure. See Error handling for details.
WT_COLLATOR *collator;
int collator_owned;
/*
* Configure the appropriate collator.
*/
error_check(wt_api->collator_config(wt_api, session,
"dsrc:", config, &collator, &collator_owned));

◆ config_get

int(* WT_EXTENSION_API::config_get) (WT_EXTENSION_API *wt_api, WT_SESSION *session, WT_CONFIG_ARG *config, const char *key, WT_CONFIG_ITEM *value)

Return the value of a configuration key.

Parameters
wt_apithe extension handle
sessionthe session handle (or NULL if none available)
configthe configuration information passed to an application
keyconfiguration key string
valuethe returned value
Returns
zero on success and a non-zero error code on failure. See Error handling for details.
const char *my_data_source_key;
/*
* Retrieve the value of the string type configuration string
* "key_format".
*/
error_check(wt_api->config_get(
wt_api, session, config, "key_format", &v));
/*
* Values returned from WT_EXTENSION_API::config in the str field are
* not nul-terminated; the associated length must be used instead.
*/
if (v.len == 1 && v.str[0] == 'r')
my_data_source_key = "recno";
else
my_data_source_key = "bytestring";
Examples:
ex_encrypt.c, and rotn_encrypt.c.

◆ config_get_string

int(* WT_EXTENSION_API::config_get_string) (WT_EXTENSION_API *wt_api, WT_SESSION *session, const char *config, const char *key, WT_CONFIG_ITEM *value)

Return the value of a configuration key from a string.

Parameters
wt_apithe extension handle
sessionthe session handle (or NULL if none available)
configthe configuration string
keyconfiguration key string
valuethe returned value
Returns
zero on success and a non-zero error code on failure. See Error handling for details.
const char *my_data_source_key;
/*
* Retrieve the value of the string type configuration string
* "key_format".
*/
error_check(wt_api->config_get(
wt_api, session, config, "key_format", &v));
/*
* Values returned from WT_EXTENSION_API::config in the str field are
* not nul-terminated; the associated length must be used instead.
*/
if (v.len == 1 && v.str[0] == 'r')
my_data_source_key = "recno";
else
my_data_source_key = "bytestring";

◆ config_parser_open

int(* WT_EXTENSION_API::config_parser_open) (WT_EXTENSION_API *wt_api, WT_SESSION *session, const char *config, size_t len, WT_CONFIG_PARSER **config_parserp)

Create a handle that can be used to parse or create configuration strings compatible with WiredTiger APIs.

This API is outside the scope of a WiredTiger connection handle, since applications may need to generate configuration strings prior to calling wiredtiger_open.

Parameters
sessionthe session handle to be used for error reporting (if NULL, error messages will be written to stderr).
configthe configuration string being parsed. The string must remain valid for the lifetime of the parser handle.
lenthe number of valid bytes in config
[out]config_parserpA pointer to the newly opened handle
Returns
zero on success and a non-zero error code on failure. See Error handling for details.
const char *config_string =
"path=/dev/loop,page_size=1024,log=(archive=true,file_max=20MB)";
NULL, config_string, strlen(config_string), &parser));
error_check(parser->close(parser));

◆ config_parser_open_arg

int(* WT_EXTENSION_API::config_parser_open_arg) (WT_EXTENSION_API *wt_api, WT_SESSION *session, WT_CONFIG_ARG *config, WT_CONFIG_PARSER **config_parserp)

Create a handle that can be used to parse or create configuration strings compatible with WiredTiger APIs.

This API is outside the scope of a WiredTiger connection handle, since applications may need to generate configuration strings prior to calling wiredtiger_open.

Parameters
sessionthe session handle to be used for error reporting (if NULL, error messages will be written to stderr).
configthe configuration string being parsed. The string must remain valid for the lifetime of the parser handle.
lenthe number of valid bytes in config
[out]config_parserpA pointer to the newly opened handle
Returns
zero on success and a non-zero error code on failure. See Error handling for details.
const char *config_string =
"path=/dev/loop,page_size=1024,log=(archive=true,file_max=20MB)";
NULL, config_string, strlen(config_string), &parser));
error_check(parser->close(parser));
Examples:
ex_file_system.c.

◆ err_printf

int(* WT_EXTENSION_API::err_printf) (WT_EXTENSION_API *wt_api, WT_SESSION *session, const char *fmt,...)

Insert an error message into the WiredTiger error stream.

Parameters
wt_apithe extension handle
sessionthe session handle (or NULL if none available)
fmta printf-like format specification
Returns
zero on success and a non-zero error code on failure. See Error handling for details.
(void)wt_api->err_printf(
wt_api, session, "extension error message: %s", msg);
Examples:
ex_file_system.c, nop_encrypt.c, and rotn_encrypt.c.

◆ map_windows_error

int(* WT_EXTENSION_API::map_windows_error) (WT_EXTENSION_API *wt_api, WT_SESSION *session, uint32_t windows_error)

Map a Windows system error code to a POSIX 1003.1/ANSI C error.

Parameters
wt_apithe extension handle
sessionthe session handle (or NULL if none available)
windows_errora Windows system error code
Returns
a string representation of the error
int posix_error =
wt_api->map_windows_error(wt_api, session, ERROR_BAD_COMMAND);

◆ metadata_insert

int(* WT_EXTENSION_API::metadata_insert) (WT_EXTENSION_API *wt_api, WT_SESSION *session, const char *key, const char *value)

Insert a row into the metadata if it does not already exist.

Parameters
wt_apithe extension handle
sessionthe session handle (or NULL if none available)
keyrow key
valuerow value
Returns
zero on success and a non-zero error code on failure. See Error handling for details.
/*
* Insert a new WiredTiger metadata record.
*/
const char *key = "datasource_uri";
const char *value = "data source uri's record";
error_check(wt_api->metadata_insert(wt_api, session, key, value));

◆ metadata_remove

int(* WT_EXTENSION_API::metadata_remove) (WT_EXTENSION_API *wt_api, WT_SESSION *session, const char *key)

Remove a row from the metadata.

Parameters
wt_apithe extension handle
sessionthe session handle (or NULL if none available)
keyrow key
Returns
zero on success and a non-zero error code on failure. See Error handling for details.
/*
* Remove a WiredTiger metadata record.
*/
const char *key = "datasource_uri";
error_check(wt_api->metadata_remove(wt_api, session, key));

◆ metadata_search

int(* WT_EXTENSION_API::metadata_search) (WT_EXTENSION_API *wt_api, WT_SESSION *session, const char *key, char **valuep)

Return a row from the metadata.

Parameters
wt_apithe extension handle
sessionthe session handle (or NULL if none available)
keyrow key
[out]valuepthe row value
Returns
zero on success and a non-zero error code on failure. See Error handling for details.
/*
* Search for a WiredTiger metadata record.
*/
const char *key = "datasource_uri";
char *value;
error_check(wt_api->metadata_search(wt_api, session, key, &value));
printf("metadata: %s has a value of %s\n", key, value);

◆ metadata_update

int(* WT_EXTENSION_API::metadata_update) (WT_EXTENSION_API *wt_api, WT_SESSION *session, const char *key, const char *value)

Update a row in the metadata by either inserting a new record or updating an existing record.

Parameters
wt_apithe extension handle
sessionthe session handle (or NULL if none available)
keyrow key
valuerow value
Returns
zero on success and a non-zero error code on failure. See Error handling for details.
/*
* Update a WiredTiger metadata record (insert it if it does not yet
* exist, update it if it does).
*/
const char *key = "datasource_uri";
const char *value = "data source uri's record";
error_check(wt_api->metadata_update(wt_api, session, key, value));

◆ msg_printf

int(* WT_EXTENSION_API::msg_printf) (WT_EXTENSION_API *, WT_SESSION *session, const char *fmt,...)

Insert a message into the WiredTiger message stream.

Parameters
wt_apithe extension handle
sessionthe session handle (or NULL if none available)
fmta printf-like format specification
Returns
zero on success and a non-zero error code on failure. See Error handling for details.
(void)wt_api->msg_printf(wt_api, session, "extension message: %s", msg);

◆ pack_close

int(* WT_EXTENSION_API::pack_close) (WT_EXTENSION_API *wt_api, WT_PACK_STREAM *ps, size_t *usedp)

Close a packing stream.

Parameters
psthe packing stream handle
[out]usedpthe number of bytes in the buffer used by the stream
Returns
zero on success and a non-zero error code on failure. See Error handling for details.

◆ pack_int

int(* WT_EXTENSION_API::pack_int) (WT_EXTENSION_API *wt_api, WT_PACK_STREAM *ps, int64_t i)

Pack a signed integer into a packing stream.

Parameters
psthe packing stream handle
ia signed integer to pack
Returns
zero on success and a non-zero error code on failure. See Error handling for details.

◆ pack_item

int(* WT_EXTENSION_API::pack_item) (WT_EXTENSION_API *wt_api, WT_PACK_STREAM *ps, WT_ITEM *item)

Pack an item into a packing stream.

Parameters
psthe packing stream handle
iteman item to pack
Returns
zero on success and a non-zero error code on failure. See Error handling for details.

◆ pack_start

int(* WT_EXTENSION_API::pack_start) (WT_EXTENSION_API *wt_api, WT_SESSION *session, const char *format, void *buffer, size_t size, WT_PACK_STREAM **psp)

Start a packing operation into a buffer.

See wiredtiger_pack_start for details.

Parameters
sessionthe session handle
formatthe data format, see Packing and Unpacking Data
buffera pointer to memory to hold the packed data
sizethe size of the buffer
[out]pspthe new packing stream handle
Returns
zero on success and a non-zero error code on failure. See Error handling for details.

◆ pack_str

int(* WT_EXTENSION_API::pack_str) (WT_EXTENSION_API *wt_api, WT_PACK_STREAM *ps, const char *s)

Pack a string into a packing stream.

Parameters
psthe packing stream handle
sa string to pack
Returns
zero on success and a non-zero error code on failure. See Error handling for details.

◆ pack_uint

int(* WT_EXTENSION_API::pack_uint) (WT_EXTENSION_API *wt_api, WT_PACK_STREAM *ps, uint64_t u)

Pack an unsigned integer into a packing stream.

Parameters
psthe packing stream handle
uan unsigned integer to pack
Returns
zero on success and a non-zero error code on failure. See Error handling for details.

◆ scr_alloc

void*(* WT_EXTENSION_API::scr_alloc) (WT_EXTENSION_API *wt_api, WT_SESSION *session, size_t bytes)

Allocate short-term use scratch memory.

Parameters
wt_apithe extension handle
sessionthe session handle (or NULL if none available)
bytesthe number of bytes of memory needed
Returns
A valid memory reference on success or NULL on error
void *buffer;
if ((buffer = wt_api->scr_alloc(wt_api, session, 512)) == NULL) {
(void)wt_api->err_printf(wt_api, session,
"buffer allocation: %s",
session->strerror(session, ENOMEM));
return (ENOMEM);
}

◆ scr_free

void(* WT_EXTENSION_API::scr_free) (WT_EXTENSION_API *, WT_SESSION *session, void *ref)

Free short-term use scratch memory.

Parameters
wt_apithe extension handle
sessionthe session handle (or NULL if none available)
refa memory reference returned by WT_EXTENSION_API::scr_alloc
wt_api->scr_free(wt_api, session, buffer);

◆ strerror

const char*(* WT_EXTENSION_API::strerror) (WT_EXTENSION_API *, WT_SESSION *session, int error)

Return information about an error as a string.

(void)wt_api->err_printf(wt_api, session,
"WiredTiger error return: %s",
wt_api->strerror(wt_api, session, ret));
Parameters
wt_apithe extension handle
sessionthe session handle (or NULL if none available)
errora return value from a WiredTiger function
Returns
a string representation of the error
Examples:
ex_file_system.c, nop_encrypt.c, and rotn_encrypt.c.

◆ struct_pack

int(* WT_EXTENSION_API::struct_pack) (WT_EXTENSION_API *wt_api, WT_SESSION *session, void *buffer, size_t size, const char *format,...)

Pack a structure into a buffer.

Deprecated in favor of stream based pack and unpack API. See WT_EXTENSION_API::pack_start for details.

Parameters
wt_apithe extension handle
sessionthe session handle
buffera pointer to a packed byte array
sizethe number of valid bytes in the buffer
formatthe data format, see Packing and Unpacking Data
Returns
zero on success and a non-zero error code on failure. See Error handling for details.

◆ struct_size

int(* WT_EXTENSION_API::struct_size) (WT_EXTENSION_API *wt_api, WT_SESSION *session, size_t *sizep, const char *format,...)

Calculate the size required to pack a structure.

Deprecated in favor of stream based pack and unpack API.

Parameters
wt_apithe extension handle
sessionthe session handle
sizepa location where the number of bytes needed for the matching call to WT_EXTENSION_API::struct_pack is returned
formatthe data format, see Packing and Unpacking Data
Returns
zero on success and a non-zero error code on failure. See Error handling for details.

◆ struct_unpack

int(* WT_EXTENSION_API::struct_unpack) (WT_EXTENSION_API *wt_api, WT_SESSION *session, const void *buffer, size_t size, const char *format,...)

Unpack a structure from a buffer.

Deprecated in favor of stream based pack and unpack API. See WT_EXTENSION_API::unpack_start for details.

Parameters
wt_apithe extension handle
sessionthe session handle
buffera pointer to a packed byte array
sizethe number of valid bytes in the buffer
formatthe data format, see Packing and Unpacking Data
Returns
zero on success and a non-zero error code on failure. See Error handling for details.

◆ transaction_id

uint64_t(* WT_EXTENSION_API::transaction_id) (WT_EXTENSION_API *wt_api, WT_SESSION *session)

Return the current transaction ID.

Parameters
wt_apithe extension handle
sessionthe session handle
Returns
the current transaction ID.
uint64_t transaction_id;
transaction_id = wt_api->transaction_id(wt_api, session);

◆ transaction_isolation_level

int(* WT_EXTENSION_API::transaction_isolation_level) (WT_EXTENSION_API *wt_api, WT_SESSION *session)

Return the current transaction's isolation level; returns one of WT_TXN_ISO_READ_COMMITTED, WT_TXN_ISO_READ_UNCOMMITTED, or WT_TXN_ISO_SNAPSHOT.

Parameters
wt_apithe extension handle
sessionthe session handle
Returns
the current transaction's isolation level.
isolation_level = wt_api->transaction_isolation_level(wt_api, session);
if (isolation_level == WT_TXN_ISO_SNAPSHOT)
is_snapshot_isolation = 1;
else
is_snapshot_isolation = 0;

◆ transaction_notify

int(* WT_EXTENSION_API::transaction_notify) (WT_EXTENSION_API *wt_api, WT_SESSION *session, WT_TXN_NOTIFY *notify)

Request notification of transaction resolution by specifying a function to be called when the session's current transaction is either committed or rolled back.

If the transaction is being committed, but the notification function returns an error, the transaction will be rolled back.

Parameters
wt_apithe extension handle
sessionthe session handle
notifya handler for commit or rollback events
Returns
zero on success and a non-zero error code on failure. See Error handling for details.
WT_TXN_NOTIFY handler;
handler.notify = data_source_notify;
error_check(wt_api->transaction_notify(wt_api, session, &handler));

◆ transaction_oldest

uint64_t(* WT_EXTENSION_API::transaction_oldest) (WT_EXTENSION_API *wt_api)

Return the oldest transaction ID not yet visible to a running transaction.

Parameters
wt_apithe extension handle
sessionthe session handle
Returns
the oldest transaction ID not yet visible to a running transaction.
transaction_oldest = wt_api->transaction_oldest(wt_api);

◆ transaction_visible

int(* WT_EXTENSION_API::transaction_visible) (WT_EXTENSION_API *wt_api, WT_SESSION *session, uint64_t transaction_id)

Return if the current transaction can see the given transaction ID.

Parameters
wt_apithe extension handle
sessionthe session handle
transaction_idthe transaction ID
Returns
true (non-zero) if the transaction ID is visible to the current transaction.
is_visible =
wt_api->transaction_visible(wt_api, session, transaction_id);

◆ unpack_int

int(* WT_EXTENSION_API::unpack_int) (WT_EXTENSION_API *wt_api, WT_PACK_STREAM *ps, int64_t *ip)

Unpack a signed integer from a packing stream.

Parameters
psthe packing stream handle
[out]ipthe unpacked signed integer
Returns
zero on success and a non-zero error code on failure. See Error handling for details.

◆ unpack_item

int(* WT_EXTENSION_API::unpack_item) (WT_EXTENSION_API *wt_api, WT_PACK_STREAM *ps, WT_ITEM *item)

Unpack an item from a packing stream.

Parameters
psthe packing stream handle
iteman item to unpack
Returns
zero on success and a non-zero error code on failure. See Error handling for details.

◆ unpack_start

int(* WT_EXTENSION_API::unpack_start) (WT_EXTENSION_API *wt_api, WT_SESSION *session, const char *format, const void *buffer, size_t size, WT_PACK_STREAM **psp)

Start an unpacking operation from a buffer.

See wiredtiger_unpack_start for details.

Parameters
sessionthe session handle
formatthe data format, see Packing and Unpacking Data
buffera pointer to memory holding the packed data
sizethe size of the buffer
[out]pspthe new packing stream handle
Returns
zero on success and a non-zero error code on failure. See Error handling for details.

◆ unpack_str

int(* WT_EXTENSION_API::unpack_str) (WT_EXTENSION_API *wt_api, WT_PACK_STREAM *ps, const char **sp)

Unpack a string from a packing stream.

Parameters
psthe packing stream handle
[out]spthe unpacked string
Returns
zero on success and a non-zero error code on failure. See Error handling for details.

◆ unpack_uint

int(* WT_EXTENSION_API::unpack_uint) (WT_EXTENSION_API *wt_api, WT_PACK_STREAM *ps, uint64_t *up)

Unpack an unsigned integer from a packing stream.

Parameters
psthe packing stream handle
[out]upthe unpacked unsigned integer
Returns
zero on success and a non-zero error code on failure. See Error handling for details.

◆ version

const char*(* WT_EXTENSION_API::version) (int *majorp, int *minorp, int *patchp)

Get version information.

printf("WiredTiger version %s\n", wiredtiger_version(NULL, NULL, NULL));
int major_v, minor_v, patch;
(void)wiredtiger_version(&major_v, &minor_v, &patch);
printf("WiredTiger version is %d, %d (patch %d)\n",
major_v, minor_v, patch);
Parameters
majorpa location where the major version number is returned
minorpa location where the minor version number is returned
patchpa location where the patch version number is returned
Returns
a string representation of the version