1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
|
/** BEGIN COPYRIGHT BLOCK
* Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
* Copyright (C) 2005 Red Hat, Inc.
* All rights reserved.
*
* License: GPL (version 3 or any later version).
* See LICENSE for details.
* END COPYRIGHT BLOCK **/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
/* Shim which forwards IDL calls to the appropriate implementation */
#include "back-ldbm.h"
static int idl_new = 0; /* non-zero if we're doing new IDL style */
void idl_old_set_tune(int val);
int idl_old_get_tune(void);
int idl_old_init_private(backend *be, struct attrinfo *a);
int idl_old_release_private(struct attrinfo *a);
size_t idl_old_get_allidslimit(struct attrinfo *a);
IDList *idl_old_fetch(backend *be, dbi_db_t *db, dbi_val_t *key, dbi_txn_t *txn, struct attrinfo *a, int *err);
int idl_old_insert_key(backend *be, dbi_db_t *db, dbi_val_t *key, ID id, dbi_txn_t *txn, struct attrinfo *a, int *disposition);
int idl_old_delete_key(backend *be, dbi_db_t *db, dbi_val_t *key, ID id, dbi_txn_t *txn, struct attrinfo *a);
int idl_old_store_block(backend *be, dbi_db_t *db, dbi_val_t *key, IDList *idl, dbi_txn_t *txn, struct attrinfo *a);
void idl_new_set_tune(int val);
int idl_new_get_tune(void);
int idl_new_init_private(backend *be, struct attrinfo *a);
int idl_new_release_private(struct attrinfo *a);
size_t idl_new_get_allidslimit(struct attrinfo *a, int allidslimit);
IDList *idl_new_fetch(backend *be, dbi_db_t *db, dbi_val_t *key, dbi_txn_t *txn, struct attrinfo *a, int *err, int allidslimit);
int idl_new_insert_key(backend *be, dbi_db_t *db, dbi_val_t *key, ID id, dbi_txn_t *txn, struct attrinfo *a, int *disposition);
int idl_new_delete_key(backend *be, dbi_db_t *db, dbi_val_t *key, ID id, dbi_txn_t *txn, struct attrinfo *a);
int idl_new_store_block(backend *be, dbi_db_t *db, dbi_val_t *key, IDList *idl, dbi_txn_t *txn, struct attrinfo *a);
int
idl_get_idl_new()
{
return idl_new;
}
void
idl_set_tune(int val)
{
/* Catch idl_tune requests to use new idl code */
if (4096 == val) {
idl_new = 1;
} else {
idl_new = 0;
}
if (idl_new) {
idl_new_set_tune(val);
} else {
idl_old_set_tune(val);
}
}
int
idl_get_tune(void)
{
if (idl_new) {
return idl_new_get_tune();
} else {
return idl_old_get_tune();
}
}
int
idl_init_private(backend *be, struct attrinfo *a)
{
if (idl_new) {
return idl_new_init_private(be, a);
} else {
return idl_old_init_private(be, a);
}
}
int
idl_release_private(struct attrinfo *a)
{
if (idl_new) {
return idl_new_release_private(a);
} else {
return idl_old_release_private(a);
}
}
size_t
idl_get_allidslimit(struct attrinfo *a, int allidslimit)
{
if (idl_new) {
return idl_new_get_allidslimit(a, allidslimit);
} else {
return idl_old_get_allidslimit(a);
}
}
IDList *
idl_fetch_ext(backend *be, dbi_db_t *db, dbi_val_t *key, dbi_txn_t *txn, struct attrinfo *a, int *err, int allidslimit)
{
if (idl_new) {
return idl_new_fetch(be, db, key, txn, a, err, allidslimit);
} else {
return idl_old_fetch(be, db, key, txn, a, err);
}
}
IDList *
idl_fetch(backend *be, dbi_db_t *db, dbi_val_t *key, dbi_txn_t *txn, struct attrinfo *a, int *err)
{
return idl_fetch_ext(be, db, key, txn, a, err, 0);
}
int
idl_insert_key(backend *be, dbi_db_t *db, dbi_val_t *key, ID id, back_txn *txn, struct attrinfo *a, int *disposition)
{
dbi_txn_t *db_txn = (txn != NULL) ? txn->back_txn_txn : NULL;
if (txn && txn->back_special_handling_fn) {
index_update_t update;
dbi_val_t data = {0};
update.id = id;
update.a = a;
update.disposition = disposition;
dblayer_value_set_buffer(be, &data, &update, sizeof update);
return txn->back_special_handling_fn(be, BTXNACT_INDEX_ADD, db, key, &data, txn);
}
if (idl_new) {
return idl_new_insert_key(be, db, key, id, db_txn, a, disposition);
} else {
return idl_old_insert_key(be, db, key, id, db_txn, a, disposition);
}
}
int
idl_delete_key(backend *be, dbi_db_t *db, dbi_val_t *key, ID id, back_txn *txn, struct attrinfo *a)
{
dbi_txn_t *db_txn = (txn != NULL) ? txn->back_txn_txn : NULL;
if (txn && txn->back_special_handling_fn) {
index_update_t update;
dbi_val_t data = {0};
update.id = id;
update.a = a;
update.disposition = NULL;
dblayer_value_set_buffer(be, &data, &update, sizeof update);
return txn->back_special_handling_fn(be, BTXNACT_INDEX_DEL, db, key, &data, txn);
}
if (idl_new) {
return idl_new_delete_key(be, db, key, id, db_txn, a);
} else {
return idl_old_delete_key(be, db, key, id, db_txn, a);
}
}
int
idl_store_block(backend *be, dbi_db_t *db, dbi_val_t *key, IDList *idl, dbi_txn_t *txn, struct attrinfo *a)
{
if (idl_new) {
return idl_new_store_block(be, db, key, idl, txn, a);
} else {
return idl_old_store_block(be, db, key, idl, txn, a);
}
}
|