summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
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);