1 /* OpenLDAP WiredTiger backend */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2002-2017 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>
37 WT_CURSOR **saved_cursor,
47 Debug( LDAP_DEBUG_TRACE, "=> key_read\n", 0, 0, 0 );
52 cursor->set_key(cursor, &key, 0);
53 rc = cursor->search_near(cursor, &exact);
55 Debug( LDAP_DEBUG_ANY,
56 LDAP_XSTRING(wt_key_read)
57 ": search_near failed: %s (%d)\n",
58 wiredtiger_strerror(rc), rc, 0 );
63 rc = cursor->get_key(cursor, &key2, &id);
65 Debug( LDAP_DEBUG_ANY,
66 LDAP_XSTRING(wt_key_read)
67 ": get_key failed: %s (%d)\n",
68 wiredtiger_strerror(rc), rc, 0 );
72 if (key.size != key2.size || memcmp(key.data, key2.data, key.size)) {
74 rc = cursor->next(cursor);
84 wt_idl_append_one(ids, id);
85 rc = cursor->next(cursor);
88 if (rc == WT_NOTFOUND ) {
93 if( rc != LDAP_SUCCESS ) {
94 Debug( LDAP_DEBUG_TRACE, "<= wt_key_read: failed (%d)\n",
97 Debug( LDAP_DEBUG_TRACE, "<= wt_key_read %ld candidates\n",
98 (long) WT_IDL_N(ids), 0, 0 );
104 /* Add or remove stuff from index files */
117 Debug( LDAP_DEBUG_TRACE, "=> key_change(%s,%lx)\n",
118 op == SLAP_INDEX_ADD_OP ? "ADD":"DELETE", (long) id, 0 );
121 cursor->set_key(cursor, &item, id);
122 cursor->set_value(cursor, NULL);
124 if (op == SLAP_INDEX_ADD_OP) {
126 rc = cursor->insert(cursor);
127 if ( rc == WT_DUPLICATE_KEY ) rc = 0;
130 rc = cursor->remove(cursor);
131 if ( rc == WT_NOTFOUND ) rc = 0;
134 Debug( LDAP_DEBUG_ANY,
135 LDAP_XSTRING(wt_key_change)
136 ": error: %s (%d)\n",
137 wiredtiger_strerror(rc), rc, 0);
141 Debug( LDAP_DEBUG_TRACE, "<= key_change %d\n", rc, 0, 0 );
148 * indent-tabs-mode: t