From 4dfe69d261b0126b7d2299936de508f6bdc71975 Mon Sep 17 00:00:00 2001 From: Keith Bostic Date: Thu, 28 Aug 2014 11:44:17 -0400 Subject: 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. --- examples/c/ex_all.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'examples') 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); -- cgit v1.2.1