summaryrefslogtreecommitdiff
path: root/examples/c/ex_all.c
diff options
context:
space:
mode:
authorAlex Gorrod <alexander.gorrod@mongodb.com>2017-06-27 12:01:10 +1000
committerAlex Gorrod <alexander.gorrod@mongodb.com>2017-06-27 12:01:10 +1000
commit95d911ab246e444192f34dc395652dba2653dd3c (patch)
tree8e7c4692125a841a486607ccfe26e8499bc4c398 /examples/c/ex_all.c
parent19cd4d9be2c0fd980c00bb04bc949970002f5cb2 (diff)
parentd139a5d5be1d7ba94130502b379a61a809e66272 (diff)
downloadmongo-2.9.3.tar.gz
Merge branch 'mongodb-3.6'2.9.3
Diffstat (limited to 'examples/c/ex_all.c')
-rw-r--r--examples/c/ex_all.c45
1 files changed, 44 insertions, 1 deletions
diff --git a/examples/c/ex_all.c b/examples/c/ex_all.c
index 82620673fe1..5e1fa4bbcc5 100644
--- a/examples/c/ex_all.c
+++ b/examples/c/ex_all.c
@@ -1,5 +1,5 @@
/*-
- * Public Domain 2014-2016 MongoDB, Inc.
+ * Public Domain 2014-2017 MongoDB, Inc.
* Public Domain 2008-2014 WiredTiger, Inc.
*
* This is free and unencumbered software released into the public domain.
@@ -299,6 +299,49 @@ cursor_ops(WT_SESSION *session)
}
{
+ /*! [Reserve a record] */
+ const char *key = "some key";
+ ret = session->open_cursor(
+ session, "table:mytable", NULL, NULL, &cursor);
+ cursor->set_key(cursor, key);
+ ret = cursor->reserve(cursor);
+ /*! [Reserve a record] */
+ }
+
+ {
+ /*! [Modify an existing record] */
+ WT_MODIFY entries[3];
+ const char *key = "some key";
+ ret = session->open_cursor(
+ session, "table:mytable", NULL, NULL, &cursor);
+
+ /* Position the cursor. */
+ cursor->set_key(cursor, key);
+ ret = cursor->search(cursor);
+
+ /* Replace 20 bytes starting at byte offset 5. */
+ entries[0].data.data = "some data";
+ entries[0].data.size = strlen(entries[0].data.data);
+ entries[0].offset = 5;
+ entries[0].size = 20;
+
+ /* Insert data at byte offset 40. */
+ entries[1].data.data = "and more data";
+ entries[1].data.size = strlen(entries[1].data.data);
+ entries[1].offset = 40;
+ entries[1].size = 0;
+
+ /* Replace 2 bytes starting at byte offset 10. */
+ entries[2].data.data = "and more data";
+ entries[2].data.size = strlen(entries[2].data.data);
+ entries[2].offset = 10;
+ entries[2].size = 2;
+
+ ret = cursor->modify(cursor, entries, 3);
+ /*! [Modify an existing record] */
+ }
+
+ {
/*! [Update an existing record or insert a new record] */
const char *key = "some key", *value = "some value";
ret = session->open_cursor(