diff options
author | Alex Gorrod <alexg@wiredtiger.com> | 2012-08-14 18:00:35 +1000 |
---|---|---|
committer | Alex Gorrod <alexg@wiredtiger.com> | 2012-08-14 18:00:35 +1000 |
commit | cddb7c9b7892d0f198ab479da16c9a0409ae1e97 (patch) | |
tree | 74e8eb4f31ff21dae15084d9cf00821c7b8975e3 /examples/c | |
parent | d41dd40709bedb19950c1aa43ea25ae9bb0b01f9 (diff) | |
download | mongo-cddb7c9b7892d0f198ab479da16c9a0409ae1e97.tar.gz |
Update doc example to make cursor lifetime more obvious.
Diffstat (limited to 'examples/c')
-rw-r--r-- | examples/c/ex_all.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/examples/c/ex_all.c b/examples/c/ex_all.c index 232bb587418..6c39aaeda20 100644 --- a/examples/c/ex_all.c +++ b/examples/c/ex_all.c @@ -473,13 +473,19 @@ transaction_ops(WT_CONNECTION *conn, WT_SESSION *session) int ret; /*! [simple transaction] */ + ret = session->begin_transaction(session, NULL); ret = session->open_cursor(session, "table:mytable", NULL, NULL, &cursor); - ret = session->begin_transaction(session, NULL); cursor->set_key(cursor, "some-key"); cursor->set_value(cursor, "some-value"); ret = cursor->update(cursor); ret = session->commit_transaction(session, NULL); + + /* + * The cursor position has been reset by the transaction commit, it + * can be used again until the handle is explicitly closed. + */ + ret = cursor->close(cursor); /*! [simple transaction] */ /*! [simple rollback transaction] */ |