-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
None
I wrote a test case that isn't behaving as I'd expected. Hopefully this is user error, but I thought I'd check. Here it is:
#include <stdio.h> #include <unistd.h> #include "wiredtiger.h" int main(int argc, char **argv) { WT_CONNECTION *conn; WT_CURSOR *c; WT_SESSION *session1, *session2; char *sess_cfg; int ret; if ((ret = wiredtiger_open( "/tmp/test2", NULL, "create", &conn)) != 0) { fprintf(stderr, "Failed wiredtiger_open: %s\n", wiredtiger_strerror(ret)); return (ret); } sess_cfg = "isolation=read-committed"; if ((ret = conn->open_session(conn, NULL, sess_cfg, &session1)) != 0 || (ret = conn->open_session(conn, NULL, sess_cfg, &session2)) != 0) { fprintf(stderr, "Failed open_session: %s\n", wiredtiger_strerror(ret)); return (ret); } if ((ret = session2->create( session2, "table:t1", "key_format=S,value_format=S")) != 0) { fprintf(stderr, "Failed create table: %s\n", wiredtiger_strerror(ret)); return (ret); } if ((ret = session1->begin_transaction( session1, "isolation=read-committed")) != 0) { fprintf(stderr, "Failed begin transaction: %s\n", wiredtiger_strerror(ret)); return (ret); } if ((ret = session2->open_cursor( session2, "table:t1", NULL, NULL, &c)) != 0) { fprintf(stderr, "Failed open_cursor: %s\n", wiredtiger_strerror(ret)); return (ret); } c->set_key(c, "hi"); c->set_value(c, "there"); if ((ret = c->insert(c)) != 0) { fprintf(stderr, "Failed insert: %s\n", wiredtiger_strerror(ret)); return (ret); } session2->close(session2, NULL); if ((ret = session1->open_cursor( session1, "table:t1", NULL, NULL, &c)) != 0) { fprintf(stderr, "Failed open_cursor: %s\n", wiredtiger_strerror(ret)); return (ret); } c->set_key(c, "hi"); ret = c->search(c); printf("Searched for key, expected WT_NOTFOUND, got: %d\n", ret); session1->close(session1, NULL); conn->close(conn, NULL); return (0); }
Compiled and run with:
$ cd $WT_HOME/build_posix $ gcc -L.libs -lwiredtiger t.c $ rm -rf /tmp/test2 && mkdir -p /tmp/test2 && LD_LIBRARY_PATH=./.libs ./a.out