1 /* OpenLDAP WiredTiger backend */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2002-2018 The OpenLDAP Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in the file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
17 * This work was developed by HAMANO Tsukasa <hamano@osstech.co.jp>
18 * based on back-bdb for inclusion in OpenLDAP Software.
19 * WiredTiger is a product of MongoDB Inc.
25 #include <ac/string.h>
29 int wt_next_id(BackendDB *be, ID *out){
30 struct wt_info *wi = (struct wt_info *) be->be_private;
31 *out = __sync_add_and_fetch(&wi->wi_lastid, 1);
35 int wt_last_id( BackendDB *be, WT_SESSION *session, ID *out )
41 rc = session->open_cursor(session, WT_TABLE_ID2ENTRY, NULL, NULL, &cursor);
43 Debug( LDAP_DEBUG_ANY,
44 LDAP_XSTRING(wt_last_id)
45 ": open_cursor failed: %s (%d)\n",
46 wiredtiger_strerror(rc), rc, 0 );
50 rc = cursor->prev(cursor);
53 rc = cursor->get_key(cursor, &id);
55 Debug( LDAP_DEBUG_ANY,
56 LDAP_XSTRING(wt_last_id)
57 ": get_key failed: %s (%d)\n",
58 wiredtiger_strerror(rc), rc, 0 );
68 Debug( LDAP_DEBUG_ANY,
69 LDAP_XSTRING(wt_last_id)
70 ": prev failed: %s (%d)\n",
71 wiredtiger_strerror(rc), rc, 0 );
74 rc = cursor->close(cursor);
76 Debug( LDAP_DEBUG_ANY,
77 LDAP_XSTRING(wt_last_id)
78 ": close failed: %s (%d)\n",
79 wiredtiger_strerror(rc), rc, 0 );