zebraExplain_flush (zh->reg->zei, zh);
extract_flushWriteKeys (zh, 1 /* final */);
zebraExplain_flush (zh->reg->zei, zh);
extract_flushWriteKeys (zh, 1 /* final */);
const char *passwd_plain = 0;
const char *passwd_encrypt = 0;
const char *dbaccess = 0;
const char *passwd_plain = 0;
const char *passwd_encrypt = 0;
const char *dbaccess = 0;
data1_set_tabroot (reg->dh, reg_path);
reg->recTypes = recTypes_init (zs->record_classes, reg->dh);
data1_set_tabroot (reg->dh, reg_path);
reg->recTypes = recTypes_init (zs->record_classes, reg->dh);
- reg->zebra_maps = zebra_maps_open (res, reg_path);
+ if ((reg->zebra_maps = zebra_maps_open (res, reg_path)) == 0)
+ {
+ recTypes_destroy(reg->recTypes);
+ bfs_destroy(reg->bfs);
+ data1_destroy(reg->dh);
+ xfree(reg->name);
+ xfree(reg);
+ return 0;
+ }
+
if (!(reg->records = rec_open (reg->bfs, rw, record_compression)))
{
yaz_log (YLOG_WARN, "rec_open failed");
if (!(reg->records = rec_open (reg->bfs, rw, record_compression)))
{
yaz_log (YLOG_WARN, "rec_open failed");
if (!(reg->dict = dict_open_res (reg->bfs, FNAME_DICT, 40, rw, 0, res)))
{
yaz_log (YLOG_WARN, "dict_open failed");
if (!(reg->dict = dict_open_res (reg->bfs, FNAME_DICT, 40, rw, 0, res)))
{
yaz_log (YLOG_WARN, "dict_open failed");
}
if (!(reg->sortIdx = sortIdx_open (reg->bfs, rw)))
{
yaz_log (YLOG_WARN, "sortIdx_open failed");
}
if (!(reg->sortIdx = sortIdx_open (reg->bfs, rw)))
{
yaz_log (YLOG_WARN, "sortIdx_open failed");
}
if (res_get_match (res, "isam", "s", ISAM_DEFAULT))
{
}
if (res_get_match (res, "isam", "s", ISAM_DEFAULT))
{
key_isams_m(res, &isams_m))))
{
yaz_log (YLOG_WARN, "isams_open failed");
key_isams_m(res, &isams_m))))
{
yaz_log (YLOG_WARN, "isams_open failed");
}
}
if (res_get_match (res, "isam", "c", ISAM_DEFAULT))
}
}
if (res_get_match (res, "isam", "c", ISAM_DEFAULT))
rw, key_isamc_m(res, &isamc_m))))
{
yaz_log (YLOG_WARN, "isamc_open failed");
rw, key_isamc_m(res, &isamc_m))))
{
yaz_log (YLOG_WARN, "isamc_open failed");
}
}
if (res_get_match (res, "isam", "b", ISAM_DEFAULT))
}
}
if (res_get_match (res, "isam", "b", ISAM_DEFAULT))
rw, key_isamc_m(res, &isamc_m), 0)))
{
yaz_log (YLOG_WARN, "isamb_open failed");
rw, key_isamc_m(res, &isamc_m), 0)))
{
yaz_log (YLOG_WARN, "isamb_open failed");
}
}
if (res_get_match (res, "isam", "bc", ISAM_DEFAULT))
}
}
if (res_get_match (res, "isam", "bc", ISAM_DEFAULT))
rw, key_isamc_m(res, &isamc_m), 1)))
{
yaz_log (YLOG_WARN, "isamb_open failed");
rw, key_isamc_m(res, &isamc_m), 1)))
{
yaz_log (YLOG_WARN, "isamb_open failed");
}
}
if (res_get_match (res, "isam", "null", ISAM_DEFAULT))
}
}
if (res_get_match (res, "isam", "null", ISAM_DEFAULT))
rw, key_isamc_m(res, &isamc_m), -1)))
{
yaz_log (YLOG_WARN, "isamb_open failed");
rw, key_isamc_m(res, &isamc_m), -1)))
{
yaz_log (YLOG_WARN, "isamb_open failed");
- if (reg->records)
- {
- zebraExplain_close (reg->zei);
- dict_close (reg->dict);
- if (reg->matchDict)
- dict_close (reg->matchDict);
- sortIdx_close (reg->sortIdx);
- if (reg->isams)
- isams_close (reg->isams);
- if (reg->isamc)
- isamc_close (reg->isamc);
- if (reg->isamb)
- isamb_close (reg->isamb);
- rec_close (®->records);
- }
+
+ zebraExplain_close (reg->zei);
+ dict_close (reg->dict);
+ if (reg->matchDict)
+ dict_close (reg->matchDict);
+ sortIdx_close (reg->sortIdx);
+ if (reg->isams)
+ isams_close (reg->isams);
+ if (reg->isamc)
+ isamc_close (reg->isamc);
+ if (reg->isamb)
+ isamb_close (reg->isamb);
+ rec_close (®->records);
resultSetDestroy (zh, -1, 0, 0);
if (zh->reg)
resultSetDestroy (zh, -1, 0, 0);
if (zh->reg)
res_set (zh->res, "lockDir", zh->path_reg);
sprintf (fname, "norm.%s.LCK", zh->reg_name);
zh->lock_normal =
res_set (zh->res, "lockDir", zh->path_reg);
sprintf (fname, "norm.%s.LCK", zh->reg_name);
zh->lock_normal =
- zebra_lock_create (res_get(zh->res, "lockDir"), fname, 0);
+ zebra_lock_create (res_get(zh->res, "lockDir"), fname);
- zebra_lock_create (res_get(zh->res, "lockDir"), fname, 0);
+ zebra_lock_create (res_get(zh->res, "lockDir"), fname);
if (zebra_begin_read(zh) == ZEBRA_FAIL)
return ZEBRA_FAIL;
res = resultSetSort(zh, stream->mem, num_input_setnames, input_setnames,
if (zebra_begin_read(zh) == ZEBRA_FAIL)
return ZEBRA_FAIL;
res = resultSetSort(zh, stream->mem, num_input_setnames, input_setnames,
if (zebra_select_database(zh, database) == ZEBRA_FAIL)
return ZEBRA_FAIL;
return zebra_begin_trans(zh, 1);
if (zebra_select_database(zh, database) == ZEBRA_FAIL)
return ZEBRA_FAIL;
return zebra_begin_trans(zh, 1);
-ZEBRA_RES zebra_admin_exchange_record (ZebraHandle zh,
- const char *rec_buf,
- size_t rec_len,
- const char *recid_buf, size_t recid_len,
- int action)
+ZEBRA_RES zebra_admin_exchange_record(ZebraHandle zh,
+ const char *rec_buf,
+ size_t rec_len,
+ const char *recid_buf, size_t recid_len,
+ int action)
/* 1 = insert. Fail it already exists */
/* 2 = replace. Fail it does not exist */
/* 3 = delete. Fail if does not exist */
/* 1 = insert. Fail it already exists */
/* 2 = replace. Fail it does not exist */
/* 3 = delete. Fail if does not exist */
ASSERTZH;
assert(action>0 && action <=4);
assert(rec_buf);
yaz_log(log_level, "zebra_admin_exchange_record ac=%d", action);
ASSERTZH;
assert(action>0 && action <=4);
assert(rec_buf);
yaz_log(log_level, "zebra_admin_exchange_record ac=%d", action);
- rinfo = dict_lookup (zh->reg->matchDict, recid_z);
+ db_ord = zebraExplain_get_database_ord(zh->reg->zei);
+ rinfo = dict_lookup_ord(zh->reg->matchDict, db_ord, recid_z);
- dict_insert (zh->reg->matchDict, recid_z, sizeof(sysno), &sysno);
+ dict_insert_ord(zh->reg->matchDict, db_ord, recid_z,
+ sizeof(sysno), &sysno);
ZEBRA_RES ret = ZEBRA_OK;
ASSERTZH;
yaz_log(log_level, "zebra_drop_database %s", db);
ZEBRA_RES ret = ZEBRA_OK;
ASSERTZH;
yaz_log(log_level, "zebra_drop_database %s", db);
+ db_ord = zebraExplain_get_database_ord(zh->reg->zei);
+ dict_delete_subtree_ord(zh->reg->matchDict, db_ord,
+ 0 /* handle */, 0 /* func */);
zebraExplain_trav_ord(zh->reg->zei, zh, delete_SU_handle);
zebraExplain_removeDatabase(zh->reg->zei, zh);
}
else
{
yaz_log(YLOG_WARN, "drop database only supported for isam:b");
zebraExplain_trav_ord(zh->reg->zei, zh, delete_SU_handle);
zebraExplain_removeDatabase(zh->reg->zei, zh);
}
else
{
yaz_log(YLOG_WARN, "drop database only supported for isam:b");
if (!zh->reg->zebra_maps)
return -1;
wrbuf = zebra_replace(zh->reg->zebra_maps, reg_id, "",
if (!zh->reg->zebra_maps)
return -1;
wrbuf = zebra_replace(zh->reg->zebra_maps, reg_id, "",
FILE *f;
ASSERTZH;
yaz_log(log_level, "zebra_set_state v=%d seq=%d", val, seqno);
FILE *f;
ASSERTZH;
yaz_log(log_level, "zebra_set_state v=%d seq=%d", val, seqno);
sprintf (state_fname, "state.%s.LCK", zh->reg_name);
fname = zebra_mk_fname (res_get(zh->res, "lockDir"), state_fname);
sprintf (state_fname, "state.%s.LCK", zh->reg_name);
fname = zebra_mk_fname (res_get(zh->res, "lockDir"), state_fname);
sprintf (state_fname, "state.%s.LCK", zh->reg_name);
fname = zebra_mk_fname (res_get(zh->res, "lockDir"), state_fname);
f = fopen (fname, "r");
sprintf (state_fname, "state.%s.LCK", zh->reg_name);
fname = zebra_mk_fname (res_get(zh->res, "lockDir"), state_fname);
f = fopen (fname, "r");
yaz_log (YLOG_WARN, "previous transaction didn't reach commit");
bf_commitClean (bfs, rval);
bfs_destroy (bfs);
yaz_log (YLOG_WARN, "previous transaction didn't reach commit");
bf_commitClean (bfs, rval);
bfs_destroy (bfs);
yaz_log (log_level, "updating %s", path);
repositoryUpdate (zh, path);
yaz_log (log_level, "updating %s", path);
repositoryUpdate (zh, path);
yaz_log (log_level, "deleting %s", path);
repositoryDelete (zh, path);
yaz_log (log_level, "deleting %s", path);
repositoryDelete (zh, path);
}
rval = res_get (zh->res, "shadow");
if (!rval)
{
yaz_log (YLOG_WARN, "Cannot perform commit - No shadow area defined");
}
rval = res_get (zh->res, "shadow");
if (!rval)
{
yaz_log (YLOG_WARN, "Cannot perform commit - No shadow area defined");
assert(name);
assert(value);
yaz_log(log_level, "zebra_set_resource %s:%s", name, value);
assert(name);
assert(value);
yaz_log(log_level, "zebra_set_resource %s:%s", name, value);
yaz_log(log_level, "zebra_get_resource %s:%s", name, v);
return v;
}
yaz_log(log_level, "zebra_get_resource %s:%s", name, v);
return v;
}
int zebra_add_record(ZebraHandle zh,
const char *buf, int buf_size)
{
int zebra_add_record(ZebraHandle zh,
const char *buf, int buf_size)
{
- SYSNO sysno = 0;
- return zebra_update_record(zh, 0, &sysno, 0, 0, buf, buf_size, 0);
+ return zebra_update_record(zh, 0, 0 /* sysno */, 0, 0, buf, buf_size, 0);
- yaz_log(log_level, "zebra_update_record sysno=" ZINT_FORMAT, *sysno);
+ yaz_log(log_level, "zebra_update_record");
+ if (sysno)
+ yaz_log(log_level, " sysno=" ZINT_FORMAT, *sysno);
+void zebra_lock_prefix (Res res, char *path)
+{
+ const char *lock_dir = res_get_def (res, "lockDir", "");
+
+ strcpy (path, lock_dir);
+ if (*path && path[strlen(path)-1] != '/')
+ strcat (path, "/");
+}
+