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.
26 wt_ctx_init(struct wt_info *wi)
31 wc = ch_malloc( sizeof( wt_ctx ) );
33 Debug( LDAP_DEBUG_ANY,
34 LDAP_XSTRING(wt_ctx_init)
35 ": cannot allocate memory\n",
40 memset(wc, 0, sizeof(wt_ctx));
43 rc = wi->wi_conn->open_session(wi->wi_conn, NULL, NULL, &wc->session);
45 Debug( LDAP_DEBUG_ANY,
46 LDAP_XSTRING(wt_ctx_session)
47 ": open_session error %s(%d)\n",
48 wiredtiger_strerror(rc), rc, 0 );
56 wt_ctx_free( void *key, void *data )
61 wc->session->close(wc->session, NULL);
68 wt_ctx_get(Operation *op, struct wt_info *wi){
73 rc = ldap_pvt_thread_pool_getkey(op->o_threadctx,
74 wt_ctx_get, &data, NULL );
78 Debug( LDAP_DEBUG_ANY,
80 ": wt_ctx_init failed\n",
84 rc = ldap_pvt_thread_pool_setkey( op->o_threadctx,
85 wt_ctx_get, wc, wt_ctx_free,
88 Debug( LDAP_DEBUG_ANY, "wt_ctx: setkey error(%d)\n",
94 return (wt_ctx *)data;
98 wt_ctx_index_cursor(wt_ctx *wc, struct berval *name, int create)
100 WT_CURSOR *cursor = NULL;
101 WT_SESSION *session = wc->session;
102 char tablename[1024];
105 snprintf(tablename, sizeof(tablename), "table:%s", name->bv_val);
107 rc = session->open_cursor(session, tablename, NULL,
108 "overwrite=false", &cursor);
109 if (rc == ENOENT && create) {
110 rc = session->create(session,
114 "columns=(key, id, none)");
116 Debug( LDAP_DEBUG_ANY,
117 LDAP_XSTRING(indexer) ": table \"%s\": "
118 "cannot create idnex table: %s (%d)\n",
119 tablename, wiredtiger_strerror(rc), rc);
122 rc = session->open_cursor(session, tablename, NULL,
123 "overwrite=false", &cursor);
126 Debug( LDAP_DEBUG_ANY,
127 LDAP_XSTRING(wt_id2entry_put)
128 ": open cursor failed: %s (%d)\n",
129 wiredtiger_strerror(rc), rc, 0 );
138 * indent-tabs-mode: t