summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorKeith Bostic <keith@wiredtiger.com>2014-08-28 11:44:17 -0400
committerKeith Bostic <keith@wiredtiger.com>2014-08-28 11:44:17 -0400
commit4dfe69d261b0126b7d2299936de508f6bdc71975 (patch)
tree96c3181058c4c50163438a2e5f9425cd385bce67 /examples
parent12e2d716e04b471c27866325bf79e2d778ce3129 (diff)
downloadmongo-4dfe69d261b0126b7d2299936de508f6bdc71975.tar.gz
More documentation changes: explicit calls to begin_transaction and
commit_transaction no longer reset cursors, remove wording talking about copying a key and re-positioning the cursor after a transaction boundary. Fix up the sample code to match the new semantics.
Diffstat (limited to 'examples')
-rw-r--r--examples/c/ex_all.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/examples/c/ex_all.c b/examples/c/ex_all.c
index 1b4b5c76498..a612044aeb8 100644
--- a/examples/c/ex_all.c
+++ b/examples/c/ex_all.c
@@ -677,14 +677,15 @@ transaction_ops(WT_CONNECTION *conn, WT_SESSION *session)
int ret;
/*! [transaction commit/rollback] */
- ret =
- session->open_cursor(session, "table:mytable", NULL, NULL, &cursor);
- ret = session->begin_transaction(session, NULL);
/*
* Cursors may be opened before or after the transaction begins, and in
* either case, subsequent operations are included in the transaction.
- * The begin_transaction call resets all open cursors.
+ * Opening cursors before the transaction begins allows applications to
+ * cache cursors and use them for multiple operations.
*/
+ ret =
+ session->open_cursor(session, "table:mytable", NULL, NULL, &cursor);
+ ret = session->begin_transaction(session, NULL);
cursor->set_key(cursor, "key");
cursor->set_value(cursor, "value");
@@ -692,18 +693,21 @@ transaction_ops(WT_CONNECTION *conn, WT_SESSION *session)
case 0: /* Update success */
ret = session->commit_transaction(session, NULL);
/*
- * The commit_transaction call resets all open cursors.
- * If commit_transaction fails, the transaction was rolled-back.
+ * If commit_transaction succeeds, cursors remain positioned; if
+ * commit_transaction fails, the transaction was rolled-back and
+ * and all cursors are reset.
*/
break;
case WT_DEADLOCK: /* Update conflict */
default: /* Other error */
ret = session->rollback_transaction(session, NULL);
- /* The rollback_transaction call resets all open cursors. */
+ /* The rollback_transaction call resets all cursors. */
break;
}
- /* Cursors remain open and may be used for multiple transactions. */
+ /*
+ * Cursors remain open and may be used for multiple transactions.
+ */
/*! [transaction commit/rollback] */
ret = cursor->close(cursor);