Shows how to extend WiredTiger with a custom file-system implementation.
#include <test_util.h>
static void
allocate_file_system_lock(pthread_rwlock_t *lockp)
{
error_check(pthread_rwlock_init(lockp, NULL));
}
static void
destroy_file_system_lock(pthread_rwlock_t *lockp)
{
error_check(pthread_rwlock_destroy(lockp));
}
static void
lock_file_system(pthread_rwlock_t *lockp)
{
error_check(pthread_rwlock_wrlock(lockp));
}
static void
unlock_file_system(pthread_rwlock_t *lockp)
{
error_check(pthread_rwlock_unlock(lockp));
}
typedef struct {
pthread_rwlock_t lock;
int opened_file_count;
int opened_unique_file_count;
int closed_file_count;
int read_ops;
int write_ops;
TAILQ_HEAD(demo_file_handle_qh, demo_file_handle) fileq;
} DEMO_FILE_SYSTEM;
typedef struct demo_file_handle {
DEMO_FILE_SYSTEM *demo_fs;
TAILQ_ENTRY(demo_file_handle) q;
uint32_t ref;
char *buf;
size_t bufsize;
size_t size;
} DEMO_FILE_HANDLE;
#ifdef _WIN32
__declspec(dllexport)
#endif
static int demo_fs_open(
static int demo_fs_directory_list(
static int demo_handle_remove(
WT_SESSION *, DEMO_FILE_HANDLE *);
static DEMO_FILE_HANDLE *demo_handle_search(
WT_FILE_SYSTEM *,
const char *);
#define DEMO_FILE_SIZE_INCREMENT 32768
static bool
byte_string_match(const char *str, const char *bytes, size_t len)
{
return (strncmp(str, bytes, len) == 0 && (str)[(len)] == '\0');
}
int
{
DEMO_FILE_SYSTEM *demo_fs;
int ret = 0;
if ((demo_fs = calloc(1, sizeof(DEMO_FILE_SYSTEM))) == NULL) {
wtext, NULL,
"demo_file_system_create: %s", wtext->
strerror(wtext, NULL, ENOMEM));
return (ENOMEM);
}
demo_fs->wtext = wtext;
(void)wtext->
err_printf(wtext, NULL,
"WT_EXTENSION_API.config_parser_open: config: %s",
goto err;
}
printf("Custom file system configuration\n");
while ((ret = config_parser->
next(config_parser, &k, &v)) == 0) {
if (byte_string_match(
"config_string", k.
str, k.
len)) {
printf(
"\t"
"key %.*s=\"%.*s\"\n",
continue;
}
if (byte_string_match(
"config_value", k.
str, k.
len)) {
printf(
"\t"
"key %.*s=%" PRId64 "\n",
continue;
}
ret = EINVAL;
"WT_CONFIG_PARSER.next: unexpected configuration "
"information: %.*s=%.*s: %s",
goto err;
}
wtext, NULL,
"WT_CONFIG_PARSER.next: config: %s", wtext->
strerror(wtext, NULL, ret));
goto err;
}
if ((ret = config_parser->
close(config_parser)) != 0) {
wtext, NULL,
"WT_CONFIG_PARSER.close: config: %s", wtext->
strerror(wtext, NULL, ret));
goto err;
}
allocate_file_system_lock(&demo_fs->lock);
file_system->
fs_size = demo_fs_size;
wtext, NULL,
"WT_CONNECTION.set_file_system: %s", wtext->
strerror(wtext, NULL, ret));
goto err;
}
return (0);
err:
free(demo_fs);
exit(1);
}
static int
{
DEMO_FILE_HANDLE *demo_fh;
DEMO_FILE_SYSTEM *demo_fs;
int ret = 0;
(void)file_type;
(void)flags;
*file_handlep = NULL;
demo_fs = (DEMO_FILE_SYSTEM *)file_system;
demo_fh = NULL;
wtext = demo_fs->wtext;
lock_file_system(&demo_fs->lock);
++demo_fs->opened_file_count;
demo_fh = demo_handle_search(file_system, name);
if (demo_fh != NULL) {
if (demo_fh->ref != 0) {
(void)wtext->
err_printf(wtext, session,
"demo_fs_open: %s: file already open", name);
ret = EBUSY;
goto err;
}
demo_fh->ref = 1;
unlock_file_system(&demo_fs->lock);
return (0);
}
if ((demo_fh = calloc(1, sizeof(DEMO_FILE_HANDLE))) == NULL) {
ret = ENOMEM;
goto err;
}
demo_fh->demo_fs = demo_fs;
demo_fh->ref = 1;
if ((demo_fh->buf = calloc(1, DEMO_FILE_SIZE_INCREMENT)) == NULL) {
ret = ENOMEM;
goto err;
}
demo_fh->bufsize = DEMO_FILE_SIZE_INCREMENT;
demo_fh->size = 0;
if ((file_handle->
name = strdup(name)) == NULL) {
ret = ENOMEM;
goto err;
}
file_handle->
close = demo_file_close;
file_handle->
fh_lock = demo_file_lock;
file_handle->
fh_read = demo_file_read;
file_handle->
fh_size = demo_file_size;
file_handle->
fh_sync = demo_file_sync;
file_handle->
fh_write = demo_file_write;
TAILQ_INSERT_HEAD(&demo_fs->fileq, demo_fh, q);
++demo_fs->opened_unique_file_count;
*file_handlep = file_handle;
if (0) {
err:
free(demo_fh->buf);
free(demo_fh);
}
unlock_file_system(&demo_fs->lock);
return (ret);
}
static int
const char *prefix, char ***dirlistp, uint32_t *countp)
{
DEMO_FILE_HANDLE *demo_fh;
DEMO_FILE_SYSTEM *demo_fs;
size_t len, prefix_len;
uint32_t allocated, count;
int ret = 0;
char *name, **entries;
void *p;
(void)session;
demo_fs = (DEMO_FILE_SYSTEM *)file_system;
*dirlistp = NULL;
*countp = 0;
entries = NULL;
allocated = count = 0;
len = strlen(directory);
prefix_len = prefix == NULL ? 0 : strlen(prefix);
lock_file_system(&demo_fs->lock);
TAILQ_FOREACH (demo_fh, &demo_fs->fileq, q) {
name = demo_fh->iface.name;
if (strncmp(name, directory, len) != 0 ||
(prefix != NULL && strncmp(name, prefix, prefix_len) != 0))
continue;
if (count >= allocated) {
p = realloc(entries, (allocated + 10) * sizeof(*entries));
if (p == NULL) {
ret = ENOMEM;
goto err;
}
entries = p;
memset(entries + allocated * sizeof(*entries), 0, 10 * sizeof(*entries));
allocated += 10;
}
entries[count++] = strdup(name);
}
*dirlistp = entries;
*countp = count;
err:
unlock_file_system(&demo_fs->lock);
if (ret == 0)
return (0);
if (entries != NULL) {
while (count > 0)
free(entries[--count]);
free(entries);
}
return (ret);
}
static int
demo_fs_directory_list_free(
{
(void)file_system;
(void)session;
if (dirlist != NULL) {
while (count > 0)
free(dirlist[--count]);
free(dirlist);
}
return (0);
}
static int
{
DEMO_FILE_SYSTEM *demo_fs;
(void)session;
demo_fs = (DEMO_FILE_SYSTEM *)file_system;
lock_file_system(&demo_fs->lock);
*existp = demo_handle_search(file_system, name) != NULL;
unlock_file_system(&demo_fs->lock);
return (0);
}
static int
{
DEMO_FILE_SYSTEM *demo_fs;
DEMO_FILE_HANDLE *demo_fh;
int ret = 0;
(void)session;
(void)flags;
demo_fs = (DEMO_FILE_SYSTEM *)file_system;
ret = ENOENT;
lock_file_system(&demo_fs->lock);
if ((demo_fh = demo_handle_search(file_system, name)) != NULL)
ret = demo_handle_remove(session, demo_fh);
unlock_file_system(&demo_fs->lock);
return (ret);
}
static int
uint32_t flags)
{
DEMO_FILE_HANDLE *demo_fh;
DEMO_FILE_SYSTEM *demo_fs;
char *copy;
int ret = 0;
(void)session;
(void)flags;
demo_fs = (DEMO_FILE_SYSTEM *)file_system;
lock_file_system(&demo_fs->lock);
if ((demo_fh = demo_handle_search(file_system, from)) == NULL)
ret = ENOENT;
else if ((copy = strdup(to)) == NULL)
ret = ENOMEM;
else {
free(demo_fh->iface.name);
demo_fh->iface.name = copy;
}
unlock_file_system(&demo_fs->lock);
return (ret);
}
static int
{
DEMO_FILE_SYSTEM *demo_fs;
DEMO_FILE_HANDLE *demo_fh;
int ret = 0;
demo_fs = (DEMO_FILE_SYSTEM *)file_system;
ret = ENOENT;
lock_file_system(&demo_fs->lock);
if ((demo_fh = demo_handle_search(file_system, name)) != NULL) {
unlock_file_system(&demo_fs->lock);
} else {
unlock_file_system(&demo_fs->lock);
}
return (ret);
}
static int
{
DEMO_FILE_HANDLE *demo_fh, *demo_fh_tmp;
DEMO_FILE_SYSTEM *demo_fs;
int ret = 0, tret;
demo_fs = (DEMO_FILE_SYSTEM *)file_system;
TAILQ_FOREACH_SAFE(demo_fh, &demo_fs->fileq, q, demo_fh_tmp)
if ((tret = demo_handle_remove(session, demo_fh)) != 0 && ret == 0)
ret = tret;
printf("Custom file system\n");
printf("\t%d unique file opens\n", demo_fs->opened_unique_file_count);
printf("\t%d files opened\n", demo_fs->opened_file_count);
printf("\t%d files closed\n", demo_fs->closed_file_count);
printf("\t%d reads, %d writes\n", demo_fs->read_ops, demo_fs->write_ops);
destroy_file_system_lock(&demo_fs->lock);
free(demo_fs);
return (ret);
}
static int
{
DEMO_FILE_HANDLE *demo_fh;
DEMO_FILE_SYSTEM *demo_fs;
(void)session;
demo_fh = (DEMO_FILE_HANDLE *)file_handle;
demo_fs = demo_fh->demo_fs;
lock_file_system(&demo_fs->lock);
if (--demo_fh->ref == 0)
++demo_fs->closed_file_count;
unlock_file_system(&demo_fs->lock);
return (0);
}
static int
{
(void)file_handle;
(void)session;
(void)lock;
return (0);
}
static int
demo_file_read(
{
DEMO_FILE_HANDLE *demo_fh;
DEMO_FILE_SYSTEM *demo_fs;
size_t off;
int ret = 0;
demo_fh = (DEMO_FILE_HANDLE *)file_handle;
demo_fs = demo_fh->demo_fs;
wtext = demo_fs->wtext;
off = (size_t)offset;
lock_file_system(&demo_fs->lock);
++demo_fs->read_ops;
if (off < demo_fh->size) {
if (len > demo_fh->size - off)
len = demo_fh->size - off;
memcpy(buf, (uint8_t *)demo_fh->buf + off, len);
} else
ret = EIO;
unlock_file_system(&demo_fs->lock);
if (ret == 0)
return (0);
"%s: handle-read: failed to read %zu bytes at offset %zu: %s", demo_fh->iface.name, len, off,
return (ret);
}
static int
{
DEMO_FILE_HANDLE *demo_fh;
DEMO_FILE_SYSTEM *demo_fs;
(void)session;
demo_fh = (DEMO_FILE_HANDLE *)file_handle;
demo_fs = demo_fh->demo_fs;
lock_file_system(&demo_fs->lock);
*sizep = (wt_off_t)demo_fh->size;
unlock_file_system(&demo_fs->lock);
return (0);
}
static int
{
(void)file_handle;
(void)session;
return (0);
}
static int
demo_buffer_resize(
WT_SESSION *session, DEMO_FILE_HANDLE *demo_fh, wt_off_t offset)
{
DEMO_FILE_SYSTEM *demo_fs;
size_t off;
void *p;
demo_fs = demo_fh->demo_fs;
wtext = demo_fs->wtext;
off = (size_t)offset;
if (demo_fh->bufsize >= off)
return (0);
if ((p = realloc(demo_fh->buf, off)) == NULL) {
(void)wtext->
err_printf(wtext, session,
"%s: failed to resize buffer", demo_fh->iface.name,
return (ENOMEM);
}
memset((uint8_t *)p + demo_fh->bufsize, 0, off - demo_fh->bufsize);
demo_fh->buf = p;
demo_fh->bufsize = off;
return (0);
}
static int
{
DEMO_FILE_HANDLE *demo_fh;
DEMO_FILE_SYSTEM *demo_fs;
int ret = 0;
demo_fh = (DEMO_FILE_HANDLE *)file_handle;
demo_fs = demo_fh->demo_fs;
lock_file_system(&demo_fs->lock);
if ((ret = demo_buffer_resize(session, demo_fh, offset)) == 0)
demo_fh->size = (size_t)offset;
unlock_file_system(&demo_fs->lock);
return (ret);
}
static int
demo_file_write(
{
DEMO_FILE_HANDLE *demo_fh;
DEMO_FILE_SYSTEM *demo_fs;
size_t off;
int ret = 0;
demo_fh = (DEMO_FILE_HANDLE *)file_handle;
demo_fs = demo_fh->demo_fs;
wtext = demo_fs->wtext;
off = (size_t)offset;
lock_file_system(&demo_fs->lock);
++demo_fs->write_ops;
if ((ret = demo_buffer_resize(
session, demo_fh, offset + (wt_off_t)(len + DEMO_FILE_SIZE_INCREMENT))) == 0) {
memcpy((uint8_t *)demo_fh->buf + off, buf, len);
if (off + len > demo_fh->size)
demo_fh->size = off + len;
}
unlock_file_system(&demo_fs->lock);
if (ret == 0)
return (0);
"%s: handle-write: failed to write %zu bytes at offset %zu: %s", demo_fh->iface.name, len,
off, wtext->
strerror(wtext, NULL, ret));
return (ret);
}
static int
demo_handle_remove(
WT_SESSION *session, DEMO_FILE_HANDLE *demo_fh)
{
DEMO_FILE_SYSTEM *demo_fs;
demo_fs = demo_fh->demo_fs;
wtext = demo_fs->wtext;
if (demo_fh->ref != 0) {
(void)wtext->
err_printf(wtext, session,
"demo_handle_remove: %s: file is currently open",
demo_fh->iface.name, wtext->
strerror(wtext, NULL, EBUSY));
return (EBUSY);
}
TAILQ_REMOVE(&demo_fs->fileq, demo_fh, q);
free(demo_fh->buf);
free(demo_fh->iface.name);
free(demo_fh);
return (0);
}
static DEMO_FILE_HANDLE *
{
DEMO_FILE_HANDLE *demo_fh;
DEMO_FILE_SYSTEM *demo_fs;
demo_fs = (DEMO_FILE_SYSTEM *)file_system;
TAILQ_FOREACH (demo_fh, &demo_fs->fileq, q)
if (strcmp(demo_fh->iface.name, name) == 0)
break;
return (demo_fh);
}
static const char *home;
int
main(void)
{
const char *key, *open_config, *uri;
int i;
int ret = 0;
char kbuf[64];
if (getenv("WIREDTIGER_HOME") == NULL) {
home = "WT_HOME";
ret = system("rm -rf WT_HOME && mkdir WT_HOME");
} else
home = NULL;
open_config =
"create,log=(enabled=true),extensions=(local={entry=demo_file_system_create,early_load=true,"
"config={config_string=\"demo-file-system\",config_value=37}})";
fprintf(stderr, "Error connecting to %s: %s\n", home == NULL ? "." : home,
return (EXIT_FAILURE);
}
if ((ret = conn->
open_session(conn, NULL, NULL, &session)) != 0) {
return (EXIT_FAILURE);
}
uri = "table:fs";
if ((ret = session->
create(session, uri,
"key_format=S,value_format=S")) != 0) {
return (EXIT_FAILURE);
}
if ((ret = session->
open_cursor(session, uri, NULL, NULL, &cursor)) != 0) {
return (EXIT_FAILURE);
}
for (i = 0; i < 1000; ++i) {
(void)snprintf(kbuf, sizeof(kbuf), "%010d KEY -----", i);
if ((ret = cursor->
insert(cursor)) != 0) {
return (EXIT_FAILURE);
}
}
if ((ret = cursor->
close(cursor)) != 0) {
return (EXIT_FAILURE);
}
if ((ret = session->
open_cursor(session, uri, NULL, NULL, &cursor)) != 0) {
return (EXIT_FAILURE);
}
for (i = 0; i < 1000; ++i) {
if ((ret = cursor->
next(cursor)) != 0) {
return (EXIT_FAILURE);
}
(void)snprintf(kbuf, sizeof(kbuf), "%010d KEY -----", i);
if ((ret = cursor->
get_key(cursor, &key)) != 0) {
return (EXIT_FAILURE);
}
if (strcmp(kbuf, key) != 0) {
fprintf(stderr, "Key mismatch: %s, %s\n", kbuf, key);
return (EXIT_FAILURE);
}
}
fprintf(
return (EXIT_FAILURE);
}
if ((ret = conn->
close(conn, NULL)) != 0) {
fprintf(stderr, "Error closing connection to %s: %s\n", home == NULL ? "." : home,
return (EXIT_FAILURE);
}
return (EXIT_SUCCESS);
}
int(* fh_map_discard)(WT_FILE_HANDLE *file_handle, WT_SESSION *session, void *map, size_t length, void *mapped_cookie)
Unmap part of a memory mapped file, based on the POSIX 1003.1 standard madvise.
Definition wiredtiger.in:5129
int(* fs_exist)(WT_FILE_SYSTEM *file_system, WT_SESSION *session, const char *name, bool *existp)
Return if the named file system object exists.
Definition wiredtiger.in:4876
int(* fs_remove)(WT_FILE_SYSTEM *file_system, WT_SESSION *session, const char *name, uint32_t flags)
Remove a named file system object.
Definition wiredtiger.in:4927
int(* fh_size)(WT_FILE_HANDLE *file_handle, WT_SESSION *session, wt_off_t *sizep)
Return the size of a file.
Definition wiredtiger.in:5192
int(* fh_extend_nolock)(WT_FILE_HANDLE *file_handle, WT_SESSION *session, wt_off_t offset)
Extend the file.
Definition wiredtiger.in:5076
int(* fs_size)(WT_FILE_SYSTEM *file_system, WT_SESSION *session, const char *name, wt_off_t *sizep)
Return the size of a named file system object.
Definition wiredtiger.in:4957
int(* fh_map_preload)(WT_FILE_HANDLE *file_handle, WT_SESSION *session, const void *map, size_t length, void *mapped_cookie)
Preload part of a memory mapped file, based on the POSIX 1003.1 standard madvise.
Definition wiredtiger.in:5148
int(* fs_rename)(WT_FILE_SYSTEM *file_system, WT_SESSION *session, const char *from, const char *to, uint32_t flags)
Rename a named file system object.
Definition wiredtiger.in:4944
int(* fs_directory_list)(WT_FILE_SYSTEM *file_system, WT_SESSION *session, const char *directory, const char *prefix, char ***dirlist, uint32_t *countp)
Return a list of file names for the named directory.
Definition wiredtiger.in:4840
int(* fh_advise)(WT_FILE_HANDLE *file_handle, WT_SESSION *session, wt_off_t offset, wt_off_t len, int advice)
Indicate expected future use of file ranges, based on the POSIX 1003.1 standard fadvise.
Definition wiredtiger.in:5026
const char *(* strerror)(WT_EXTENSION_API *, WT_SESSION *session, int error)
Return information about an error as a string.
Definition wiredtiger_ext.h:100
int(* fh_lock)(WT_FILE_HANDLE *file_handle, WT_SESSION *session, bool lock)
Lock/unlock a file from the perspective of other processes running in the system, where necessary.
Definition wiredtiger.in:5089
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
int(* fs_open_file)(WT_FILE_SYSTEM *file_system, WT_SESSION *session, const char *name, WT_FS_OPEN_FILE_TYPE file_type, uint32_t flags, WT_FILE_HANDLE **file_handlep)
Open a handle for a named file system object.
Definition wiredtiger.in:4910
int(* fs_directory_list_free)(WT_FILE_SYSTEM *file_system, WT_SESSION *session, char **dirlist, uint32_t count)
Free memory allocated by WT_FILE_SYSTEM::directory_list.
Definition wiredtiger.in:4863
int(* fh_unmap)(WT_FILE_HANDLE *file_handle, WT_SESSION *session, void *mapped_region, size_t length, void *mapped_cookie)
Unmap a memory mapped file, based on the POSIX 1003.1 standard munmap.
Definition wiredtiger.in:5166
int(* close)(WT_FILE_HANDLE *file_handle, WT_SESSION *session)
Close a file handle.
Definition wiredtiger.in:5008
int(* fh_truncate)(WT_FILE_HANDLE *file_handle, WT_SESSION *session, wt_off_t offset)
Truncate the file.
Definition wiredtiger.in:5238
int(* fh_extend)(WT_FILE_HANDLE *file_handle, WT_SESSION *session, wt_off_t offset)
Extend the file.
Definition wiredtiger.in:5051
int(* fh_write)(WT_FILE_HANDLE *file_handle, WT_SESSION *session, wt_off_t offset, size_t length, const void *buf)
Write to a file, based on the POSIX 1003.1 standard pwrite.
Definition wiredtiger.in:5255
char * name
The name of the file, set by WT_FILE_SYSTEM::fs_open_file.
Definition wiredtiger.in:4997
int(* fh_read)(WT_FILE_HANDLE *file_handle, WT_SESSION *session, wt_off_t offset, size_t len, void *buf)
Read from a file, based on the POSIX 1003.1 standard pread.
Definition wiredtiger.in:5180
int(* fh_sync_nowait)(WT_FILE_HANDLE *file_handle, WT_SESSION *session)
Schedule the outstanding file writes required for durability and return immediately.
Definition wiredtiger.in:5221
int(* fh_sync)(WT_FILE_HANDLE *file_handle, WT_SESSION *session)
Make outstanding file writes durable and do not return until writes are complete.
Definition wiredtiger.in:5207
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 WiredTi...
Definition wiredtiger_ext.h:225
int(* fh_map)(WT_FILE_HANDLE *file_handle, WT_SESSION *session, void **mapped_regionp, size_t *lengthp, void **mapped_cookiep)
Map a file into memory, based on the POSIX 1003.1 standard mmap.
Definition wiredtiger.in:5110
int(* terminate)(WT_FILE_SYSTEM *file_system, WT_SESSION *session)
A callback performed when the file system is closed and will no longer be accessed by the WiredTiger ...
Definition wiredtiger.in:4970
struct WT_CONFIG_ARG WT_CONFIG_ARG
A configuration object passed to some extension interfaces.
Definition wiredtiger.in:4204
WT_FS_OPEN_FILE_TYPE
WT_FILE_SYSTEM::open_file file types.
Definition wiredtiger.in:4761
Table of WiredTiger extension methods.
Definition wiredtiger_ext.h:58
A file handle implementation returned by WT_FILE_SYSTEM::fs_open_file.
Definition wiredtiger.in:4988
The interface implemented by applications to provide a custom file system implementation.
Definition wiredtiger.in:4824
#define WT_NOTFOUND
Item not found.
Definition wiredtiger.in:4140
const char * wiredtiger_strerror(int error)
Return information about a WiredTiger error as a string (see WT_SESSION::strerror for a thread-safe A...
int wiredtiger_open(const char *home, WT_EVENT_HANDLER *event_handler, const char *config, WT_CONNECTION **connectionp)
Open a connection to a database.
The configuration information returned by the WiredTiger configuration parsing functions in the WT_EX...
Definition wiredtiger.in:3827
int64_t val
The numeric value of a configuration boolean or integer.
Definition wiredtiger.in:3853
const char * str
The value of a configuration string.
Definition wiredtiger.in:3838
size_t len
The number of bytes in the value referenced by str.
Definition wiredtiger.in:3841
A handle that can be used to search and traverse configuration strings compatible with the WiredTiger...
Definition wiredtiger.in:3959
int next(WT_CONFIG_PARSER *config_parser, WT_CONFIG_ITEM *key, WT_CONFIG_ITEM *value)
Return the next key/value pair.
int close(WT_CONFIG_PARSER *config_parser)
Close the configuration scanner releasing any resources.
A connection to a WiredTiger database.
Definition wiredtiger.in:2106
WT_EXTENSION_API * get_extension_api(WT_CONNECTION *wt_conn)
Return a reference to the WiredTiger extension functions.
int set_file_system(WT_CONNECTION *connection, WT_FILE_SYSTEM *fs, const char *config)
Configure a custom file system.
int open_session(WT_CONNECTION *connection, WT_EVENT_HANDLER *event_handler, const char *config, WT_SESSION **sessionp)
int close(WT_CONNECTION *connection, const char *config)
A WT_CURSOR handle is the interface to a cursor.
Definition wiredtiger.in:199
int next(WT_CURSOR *cursor)
Return the next record.
void set_value(WT_CURSOR *cursor,...)
Set the value for the next operation.
int insert(WT_CURSOR *cursor)
Insert a record and optionally update an existing record.
void set_key(WT_CURSOR *cursor,...)
Set the key for the next operation.
int close(WT_CURSOR *cursor)
Close the cursor.
int get_key(WT_CURSOR *cursor,...)
Get the key for the current record.
All data operations are performed in the context of a WT_SESSION.
Definition wiredtiger.in:822
int create(WT_SESSION *session, const char *name, const char *config)
int open_cursor(WT_SESSION *session, const char *uri, WT_CURSOR *to_dup, const char *config, WT_CURSOR **cursorp)