Version 11.3.0
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 the WiredTiger API. 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 the WiredTiger API. More...
 
int(* file_system_get )(WT_EXTENSION_API *wt_api, WT_SESSION *session, WT_FILE_SYSTEM **file_system)
 Get the file system abstraction used by WiredTiger. 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...
 
const char *(* version )(int *majorp, int *minorp, int *patchp)
 Get version information. More...
 
int(* spin_init )(WT_EXTENSION_API *wt_api, WT_EXTENSION_SPINLOCK *spinlock, const char *name)
 Initialize a spinlock. More...
 
void(* spin_destroy )(WT_EXTENSION_API *wt_api, WT_EXTENSION_SPINLOCK *spinlock)
 Destroy a spinlock. More...
 
void(* spin_lock )(WT_EXTENSION_API *wt_api, WT_SESSION *session, WT_EXTENSION_SPINLOCK *spinlock)
 Spin until the lock is acquired. More...
 
void(* spin_unlock )(WT_EXTENSION_API *wt_api, WT_SESSION *session, WT_EXTENSION_SPINLOCK *spinlock)
 Release the spinlock. 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;
int ret;
(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.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 */
if ((ret = connection->add_compressor(
connection, "nop", (WT_COMPRESSOR *)nop_compressor, NULL)) == 0)
return (0);
free(nop_compressor);
return (ret);
}
Examples
ex_encrypt.c, ex_file_system.c, nop_encrypt.c, rotn_encrypt.c, and sodium_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, nop_encrypt.c, rotn_encrypt.c, and sodium_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 the WiredTiger API.

Parameters
wt_apithe extension handle
sessionthe session handle to be used for error reporting
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.

◆ 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 the WiredTiger API.

Parameters
wt_apithe extension handle
sessionthe session handle to be used for error reporting
configthe configuration argument passed to the extension
[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.
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-style 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, rotn_encrypt.c, and sodium_encrypt.c.

◆ file_system_get

int(* WT_EXTENSION_API::file_system_get) (WT_EXTENSION_API *wt_api, WT_SESSION *session, WT_FILE_SYSTEM **file_system)

Get the file system abstraction used by WiredTiger.

Parameters
wt_apithe extension handle
sessionthe session handle (or NULL if none available)
file_systemthe returned file system handle.
Returns
zero on success and a non-zero error code on failure. See Error handling for details. If called from an extension's initialization routine, this may return WT_NOTFOUND if the file system has not yet been established.
/*
* 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));

◆ 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 Unix-style error code
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-style 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);

◆ spin_destroy

void(* WT_EXTENSION_API::spin_destroy) (WT_EXTENSION_API *wt_api, WT_EXTENSION_SPINLOCK *spinlock)

Destroy a spinlock.

Parameters
wt_apithe extension handle
sessionthe session handle
spinlockthe extension spinlock

◆ spin_init

int(* WT_EXTENSION_API::spin_init) (WT_EXTENSION_API *wt_api, WT_EXTENSION_SPINLOCK *spinlock, const char *name)

Initialize a spinlock.

Parameters
wt_apithe extension handle
sessionthe session handle
spinlockthe extension spinlock
namethe name for the spinlock

◆ spin_lock

void(* WT_EXTENSION_API::spin_lock) (WT_EXTENSION_API *wt_api, WT_SESSION *session, WT_EXTENSION_SPINLOCK *spinlock)

Spin until the lock is acquired.

Parameters
wt_apithe extension handle
sessionthe session handle
spinlockthe extension spinlock

◆ spin_unlock

void(* WT_EXTENSION_API::spin_unlock) (WT_EXTENSION_API *wt_api, WT_SESSION *session, WT_EXTENSION_SPINLOCK *spinlock)

Release the spinlock.

Parameters
wt_apithe extension handle
sessionthe session handle
spinlockthe extension spinlock

◆ 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, rotn_encrypt.c, and sodium_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.

◆ 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
WT_EXTENSION_API
Table of WiredTiger extension methods.
Definition: wiredtiger_ext.h:58
WT_COMPRESSOR::compress
int(* compress)(WT_COMPRESSOR *compressor, WT_SESSION *session, uint8_t *src, size_t src_len, uint8_t *dst, size_t dst_len, size_t *result_lenp, int *compression_failed)
Callback to compress a chunk of data.
Definition: wiredtiger.in:4233
WT_EXTENSION_API::metadata_update
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.
Definition: wiredtiger_ext.h:295
WT_ITEM::data
const void * data
The memory reference of the data item.
Definition: wiredtiger.in:99
WT_EXTENSION_API::scr_alloc
void *(* scr_alloc)(WT_EXTENSION_API *wt_api, WT_SESSION *session, size_t bytes)
Allocate short-term use scratch memory.
Definition: wiredtiger_ext.h:124
WT_EXTENSION_API::msg_printf
int(* msg_printf)(WT_EXTENSION_API *, WT_SESSION *session, const char *fmt,...)
Insert a message into the WiredTiger message stream.
Definition: wiredtiger_ext.h:88
WT_ITEM::size
size_t size
The number of bytes in the data item.
Definition: wiredtiger.in:108
WT_EXTENSION_API::metadata_remove
int(* metadata_remove)(WT_EXTENSION_API *wt_api, WT_SESSION *session, const char *key)
Remove a row from the metadata.
Definition: wiredtiger_ext.h:267
WT_COLLATOR
The interface implemented by applications to provide custom ordering of records.
Definition: wiredtiger.in:4142
WT_CONFIG_ARG
struct WT_CONFIG_ARG WT_CONFIG_ARG
Definition: wiredtiger.in:4128
WT_CONNECTION::get_extension_api
WT_EXTENSION_API * get_extension_api(WT_CONNECTION *wt_conn)
Return a reference to the WiredTiger extension functions.
WT_CONFIG_ITEM::str
const char * str
The value of a configuration string.
Definition: wiredtiger.in:3762
WT_EXTENSION_API::strerror
const char *(* strerror)(WT_EXTENSION_API *, WT_SESSION *session, int error)
Return information about an error as a string.
Definition: wiredtiger_ext.h:100
wiredtiger_version
const char * wiredtiger_version(int *majorp, int *minorp, int *patchp)
Get version information.
WT_ITEM
A raw item of data to be managed, including a pointer to the data and a length.
Definition: wiredtiger.in:91
WT_EXTENSION_API::config_get
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.
Definition: wiredtiger_ext.h:184
wiredtiger_extension_init
int wiredtiger_extension_init(WT_CONNECTION *connection, WT_CONFIG_ARG *config)
Entry point to an extension, called when the extension is loaded.
WT_EXTENSION_API::map_windows_error
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.
Definition: wiredtiger_ext.h:112
WT_CONNECTION
A connection to a WiredTiger database.
Definition: wiredtiger.in:2089
WT_EXTENSION_API::scr_free
void(* scr_free)(WT_EXTENSION_API *, WT_SESSION *session, void *ref)
Free short-term use scratch memory.
Definition: wiredtiger_ext.h:135
WT_CONFIG_ITEM::len
size_t len
The number of bytes in the value referenced by str.
Definition: wiredtiger.in:3765
WT_EXTENSION_API::collator_config
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.
Definition: wiredtiger_ext.h:151
WT_CONNECTION::add_compressor
int add_compressor(WT_CONNECTION *connection, const char *name, WT_COMPRESSOR *compressor, const char *config)
Add a compression function.
WT_EXTENSION_API::err_printf
int(* err_printf)(WT_EXTENSION_API *wt_api, WT_SESSION *session, const char *fmt,...)
Insert an error message into the WiredTiger error stream.
Definition: wiredtiger_ext.h:76
WT_COMPRESSOR
The interface implemented by applications to provide custom compression.
Definition: wiredtiger.in:4195
WT_EXTENSION_API::metadata_insert
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.
Definition: wiredtiger_ext.h:254
WT_SESSION::strerror
const char * strerror(WT_SESSION *session, int error)
Return information about an error as a string.
WT_EXTENSION_API::metadata_search
int(* metadata_search)(WT_EXTENSION_API *wt_api, WT_SESSION *session, const char *key, char **valuep)
Return a row from the metadata.
Definition: wiredtiger_ext.h:280
WT_EXTENSION_API::collate
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.
Definition: wiredtiger_ext.h:169
WT_CONFIG_ITEM
The configuration information returned by the WiredTiger configuration parsing functions in the WT_EX...
Definition: wiredtiger.in:3751