yaz_log (YLOG_DEBUG, "zebra_register_open rw=%d useshadow=%d p=%p n=%s rp=%s",
rw, useshadow, reg, name, reg_path ? reg_path : "(none)");
yaz_log (YLOG_DEBUG, "zebra_register_open rw=%d useshadow=%d p=%p n=%s rp=%s",
rw, useshadow, reg, name, reg_path ? reg_path : "(none)");
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);
- if ((reg->zebra_maps = zebra_maps_open (res, reg_path)) == 0) {
- /* ### Do we need to destroy reg->recTypes? */
+ reg->zebra_maps =
+ zebra_maps_open(res, reg_path, profilePath);
+ if (!reg->zebra_maps)
+ {
+ recTypes_destroy(reg->recTypes);
if (!strcmp (recordCompression, "bzip2"))
record_compression = REC_COMPRESS_BZIP2;
if (!strcmp (recordCompression, "bzip2"))
record_compression = REC_COMPRESS_BZIP2;
+ if (1)
+ {
+ const char *index_fname = res_get_def(res, "index", "default.idx");
+ if (index_fname && *index_fname)
+ {
+ if (zebra_maps_read_file(reg->zebra_maps, index_fname) != ZEBRA_OK)
+ ret = ZEBRA_FAIL;
+ }
+ }
+
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");
- yaz_log (YLOG_WARN, "Cannot obtain EXPLAIN information");
+ reg->zei = zebraExplain_open(reg->records, reg->dh,
+ res, rw, reg,
+ explain_extract);
+ if (!reg->zei)
+ {
+ yaz_log (YLOG_WARN, "Cannot obtain EXPLAIN information");
+ ret = ZEBRA_FAIL;
+ }
+ }
+
+ if (ret != ZEBRA_OK)
+ {
+ zebra_register_close(zs, reg);
- 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)
{
if (res_get_int(zh->res, "staticrank", &zh->m_staticrank) == ZEBRA_OK)
yaz_log(YLOG_LOG, "static rank set and is %d", zh->m_staticrank);
{
if (res_get_int(zh->res, "staticrank", &zh->m_staticrank) == ZEBRA_OK)
yaz_log(YLOG_LOG, "static rank set and is %d", zh->m_staticrank);
zebra_setError(zh, YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED,
"Cannot insert record: already exist");
return ZEBRA_FAIL;
zebra_setError(zh, YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED,
"Cannot insert record: already exist");
return ZEBRA_FAIL;
zebra_setError(zh, YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED,
"Cannot delete/update record: does not exist");
return ZEBRA_FAIL;
zebra_setError(zh, YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED,
"Cannot delete/update record: does not exist");
return ZEBRA_FAIL;
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);
+
+ zebra_unlock (zh->lock_shadow);
+ zebra_unlock (zh->lock_normal);
+
+ zebra_lock_w(zh->lock_shadow);
+ bf_commitClean (bfs, rval);
+ zebra_unlock (zh->lock_normal);