-/* $Id: zebraapi.c,v 1.206 2006-03-26 14:17:01 adam Exp $
+/* $Id: zebraapi.c,v 1.210 2006-03-31 15:58:04 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
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)");
- reg->dh = data1_createx (DATA1_FLAG_XML);
+ reg->dh = data1_create();
if (!reg->dh)
{
xfree(reg->name);
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)
+ reg->zebra_maps =
+ zebra_maps_open(res, reg_path, profilePath);
+ if (!reg->zebra_maps)
{
recTypes_destroy(reg->recTypes);
bfs_destroy(reg->bfs);
xfree(reg);
return 0;
}
-
reg->rank_classes = NULL;
reg->key_buf = 0;
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");
ret = ZEBRA_FAIL;
}
}
- if (reg->records)
+ if (ret == ZEBRA_OK)
{
reg->zei = zebraExplain_open(reg->records, reg->dh,
res, rw, reg,
{
if (action == 1) /* fail if insert */
{
- zebra_end_trans(zh);
+ if (zebra_end_trans(zh) != ZEBRA_OK)
+ yaz_log(YLOG_WARN, "zebra_end_trans failed");
zebra_setError(zh, YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED,
"Cannot insert record: already exist");
return ZEBRA_FAIL;
{
if (action == 2 || action == 3) /* fail if delete or update */
{
- zebra_end_trans(zh);
+ if (zebra_end_trans(zh) != ZEBRA_OK)
+ yaz_log(YLOG_WARN, "zebra_end_trans failed");
zebra_setError(zh, YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED,
"Cannot delete/update record: does not exist");
return ZEBRA_FAIL;
{
dict_delete_ord(zh->reg->matchDict, db_ord, recid_z);
}
- zebra_end_trans(zh);
+ if (zebra_end_trans(zh) != ZEBRA_OK)
+ {
+ yaz_log(YLOG_WARN, "zebra_end_trans failed");
+ res = ZEBRA_FAIL;
+ }
return res;
}
"drop database only supported for isam:b");
ret = ZEBRA_FAIL;
}
- zebra_end_trans (zh);
+ if (zebra_end_trans (zh) != ZEBRA_OK)
+ {
+ yaz_log(YLOG_WARN, "zebra_end_trans failed");
+ ret = ZEBRA_FAIL;
+ }
return ret;
}
if (zebraExplain_newDatabase (zh->reg->zei, db, 0
/* explainDatabase */))
{
- zebra_end_trans (zh);
+ if (zebra_end_trans (zh) != ZEBRA_OK)
+ {
+ yaz_log(YLOG_WARN, "zebra_end_trans failed");
+ }
zebra_setError(zh, YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED, db);
return ZEBRA_FAIL;
}
match, fname,
0,
0); /* allow_update */
- zebra_end_trans(zh);
+ if (zebra_end_trans(zh) != ZEBRA_OK)
+ {
+ yaz_log(YLOG_WARN, "zebra_end_trans failed");
+ res = ZEBRA_FAIL;
+ }
return res;
}
match, fname,
force_update,
1); /* allow_update */
- zebra_end_trans(zh);
+ if (zebra_end_trans(zh) != ZEBRA_OK)
+ {
+ yaz_log(YLOG_WARN, "zebra_end_trans failed");
+ res = ZEBRA_FAIL;
+ }
return res;
}
match,fname,
force_update,
1); /* allow_update */
- zebra_end_trans(zh);
+ if (zebra_end_trans(zh) != ZEBRA_OK)
+ {
+ yaz_log(YLOG_WARN, "zebra_end_trans failed");
+ res = ZEBRA_FAIL;
+ }
return res;
}