projects
/
idzebra-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Prevent zebra_clean from deleting files for uncommited trans.
[idzebra-moved-to-github.git]
/
index
/
zebraapi.c
diff --git
a/index/zebraapi.c
b/index/zebraapi.c
index
ed5fd81
..
09c0e1a
100644
(file)
--- a/
index/zebraapi.c
+++ b/
index/zebraapi.c
@@
-1,4
+1,4
@@
-/* $Id: zebraapi.c,v 1.254 2007-04-16 21:54:37 adam Exp $
+/* $Id: zebraapi.c,v 1.267 2007-12-18 13:41:27 adam Exp $
Copyright (C) 1995-2007
Index Data ApS
Copyright (C) 1995-2007
Index Data ApS
@@
-99,6
+99,12
@@
static struct zebra_register *zebra_register_open(ZebraService zs,
const char *reg_path);
static void zebra_register_close(ZebraService zs, struct zebra_register *reg);
const char *reg_path);
static void zebra_register_close(ZebraService zs, struct zebra_register *reg);
+const char *zebra_get_encoding(ZebraHandle zh)
+{
+ assert(zh && zh->session_res);
+ return res_get_def(zh->session_res, "encoding", "ISO-8859-1");
+}
+
ZebraHandle zebra_open(ZebraService zs, Res res)
{
ZebraHandle zh;
ZebraHandle zebra_open(ZebraService zs, Res res)
{
ZebraHandle zh;
@@
-147,7
+153,7
@@
ZebraHandle zebra_open(ZebraService zs, Res res)
zh->break_handler_func = 0;
zh->break_handler_data = 0;
zh->break_handler_func = 0;
zh->break_handler_data = 0;
- default_encoding = res_get_def(zh->session_res, "encoding", "ISO-8859-1");
+ default_encoding = zebra_get_encoding(zh);
zh->iconv_to_utf8 =
yaz_iconv_open ("UTF-8", default_encoding);
zh->iconv_to_utf8 =
yaz_iconv_open ("UTF-8", default_encoding);
@@
-186,6
+192,8
@@
ZebraService zebra_start(const char *configName)
ZebraService zebra_start_res(const char *configName, Res def_res, Res over_res)
{
Res res;
ZebraService zebra_start_res(const char *configName, Res def_res, Res over_res)
{
Res res;
+ char version_str[16];
+ char system_str[80];
zebra_flock_init();
zebra_flock_init();
@@
-195,7
+203,9
@@
ZebraService zebra_start_res(const char *configName, Res def_res, Res over_res)
log_level_initialized = 1;
}
log_level_initialized = 1;
}
- yaz_log(YLOG_LOG, "zebra_start %s %s", ZEBRAVER,
+ zebra_get_version(version_str, system_str);
+
+ yaz_log(YLOG_LOG, "zebra_start %s %s", version_str,
configName ? configName : "");
if ((res = res_open(def_res, over_res)))
configName ? configName : "");
if ((res = res_open(def_res, over_res)))
@@
-409,10
+419,9
@@
struct zebra_register *zebra_register_open(ZebraService zs, const char *name,
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");
{
const char *index_fname = res_get_def(res, "index", "default.idx");
- if (index_fname && *index_fname)
+ if (index_fname && *index_fname && strcmp(index_fname, "none"))
{
if (zebra_maps_read_file(reg->zebra_maps, index_fname) != ZEBRA_OK)
ret = ZEBRA_FAIL;
{
if (zebra_maps_read_file(reg->zebra_maps, index_fname) != ZEBRA_OK)
ret = ZEBRA_FAIL;
@@
-1076,7
+1085,7
@@
ZEBRA_RES zebra_search_RPN(ZebraHandle zh, ODR o, Z_RPNQuery *query,
ZEBRA_RES zebra_records_retrieve(ZebraHandle zh, ODR stream,
const char *setname,
Z_RecordComposition *comp,
ZEBRA_RES zebra_records_retrieve(ZebraHandle zh, ODR stream,
const char *setname,
Z_RecordComposition *comp,
- const int *input_format, int num_recs,
+ const Odr_oid *input_format, int num_recs,
ZebraRetrievalRecord *recs)
{
ZebraMetaRecord *poset;
ZebraRetrievalRecord *recs)
{
ZebraMetaRecord *poset;
@@
-1138,8
+1147,8
@@
ZEBRA_RES zebra_records_retrieve(ZebraHandle zh, ODR stream,
hit_snippet);
#endif
recs[i].errCode =
hit_snippet);
#endif
recs[i].errCode =
- zebra_record_fetch(zh, poset[i].sysno, poset[i].score,
- hit_snippet,
+ zebra_record_fetch(zh, setname,
+ poset[i].sysno, poset[i].score,
stream, input_format, comp,
&recs[i].format, &buf, &len,
&recs[i].base, &recs[i].errString);
stream, input_format, comp,
&recs[i].format, &buf, &len,
&recs[i].base, &recs[i].errString);
@@
-1189,7
+1198,7
@@
ZEBRA_RES zebra_scan_PQF(ZebraHandle zh, ODR stream, const char *query,
{
YAZ_PQF_Parser pqf_parser = yaz_pqf_create ();
Z_AttributesPlusTerm *zapt;
{
YAZ_PQF_Parser pqf_parser = yaz_pqf_create ();
Z_AttributesPlusTerm *zapt;
- int *attributeSet;
+ Odr_oid *attributeSet;
ZEBRA_RES res;
if (!(zapt = yaz_pqf_scan(pqf_parser, stream, &attributeSet, query)))
ZEBRA_RES res;
if (!(zapt = yaz_pqf_scan(pqf_parser, stream, &attributeSet, query)))
@@
-1208,14
+1217,13
@@
ZEBRA_RES zebra_scan_PQF(ZebraHandle zh, ODR stream, const char *query,
}
ZEBRA_RES zebra_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
}
ZEBRA_RES zebra_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
- const int *attributeset,
+ const Odr_oid *attributeset,
int *position,
int *num_entries, ZebraScanEntry **entries,
int *is_partial,
const char *setname)
{
ZEBRA_RES res;
int *position,
int *num_entries, ZebraScanEntry **entries,
int *is_partial,
const char *setname)
{
ZEBRA_RES res;
- RSET limit_rset = 0;
ZEBRA_CHECK_HANDLE(zh);
ZEBRA_CHECK_HANDLE(zh);
@@
-1233,21
+1241,10
@@
ZEBRA_RES zebra_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
*num_entries = 0;
return ZEBRA_FAIL;
}
*num_entries = 0;
return ZEBRA_FAIL;
}
- if (setname)
- {
- limit_rset = resultSetRef(zh, setname);
- if (!limit_rset)
- {
- zebra_setError(zh,
- YAZ_BIB1_SPECIFIED_RESULT_SET_DOES_NOT_EXIST,
- setname);
- zebra_end_read (zh);
- return ZEBRA_FAIL;
- }
- }
+
res = rpn_scan(zh, stream, zapt, attributeset,
zh->num_basenames, zh->basenames, position,
res = rpn_scan(zh, stream, zapt, attributeset,
zh->num_basenames, zh->basenames, position,
- num_entries, entries, is_partial, limit_rset);
+ num_entries, entries, is_partial, setname);
zebra_end_read(zh);
return res;
}
zebra_end_read(zh);
return res;
}
@@
-1281,8
+1278,7
@@
int zebra_deleteResultSet(ZebraHandle zh, int function,
{
int i, status;
ASSERTZH;
{
int i, status;
ASSERTZH;
- assert(statuses);
- yaz_log(log_level, "zebra_deleteResultSet n=%d",num_setnames);
+ yaz_log(log_level, "zebra_deleteResultSet n=%d", num_setnames);
if (zebra_begin_read(zh))
return Z_DeleteStatus_systemProblemAtTarget;
if (zebra_begin_read(zh))
return Z_DeleteStatus_systemProblemAtTarget;
@@
-1516,11
+1512,12
@@
ZEBRA_RES zebra_create_database (ZebraHandle zh, const char *db)
return zebra_end_trans (zh);
}
return zebra_end_trans (zh);
}
-int zebra_string_norm(ZebraHandle zh, unsigned reg_id,
+int zebra_string_norm(ZebraHandle zh, const char *index_type,
const char *input_str, int input_len,
char *output_str, int output_len)
{
WRBUF wrbuf;
const char *input_str, int input_len,
char *output_str, int output_len)
{
WRBUF wrbuf;
+ zebra_map_t zm = zebra_map_get(zh->reg->zebra_maps, index_type);
ASSERTZH;
assert(input_str);
assert(output_str);
ASSERTZH;
assert(input_str);
assert(output_str);
@@
-1528,8
+1525,7
@@
int zebra_string_norm(ZebraHandle zh, unsigned reg_id,
if (!zh->reg->zebra_maps)
return -1;
if (!zh->reg->zebra_maps)
return -1;
- wrbuf = zebra_replace(zh->reg->zebra_maps, reg_id, "",
- input_str, input_len);
+ wrbuf = zebra_replace(zm, "", input_str, input_len);
if (!wrbuf)
return -2;
if (wrbuf_len(wrbuf) >= output_len)
if (!wrbuf)
return -2;
if (wrbuf_len(wrbuf) >= output_len)
@@
-1557,7
+1553,7
@@
static void zebra_set_state (ZebraHandle zh, int val, int seqno)
long p = getpid();
FILE *f;
ASSERTZH;
long p = getpid();
FILE *f;
ASSERTZH;
- yaz_log(log_level, "zebra_set_state v=%d seq=%d", val, seqno);
+ yaz_log(log_level, "zebra_set_state v=%c 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);
@@
-1909,14
+1905,12
@@
ZEBRA_RES zebra_end_transaction (ZebraHandle zh, ZebraTransactionStatus *status)
if (val != 'd')
{
BFiles bfs = bfs_create (rval, zh->path_reg);
if (val != 'd')
{
BFiles bfs = bfs_create (rval, zh->path_reg);
- yaz_log (YLOG_DEBUG, "deleting shadow val=%c", val);
bf_commitClean (bfs, rval);
bfs_destroy (bfs);
}
if (!rval)
seqno++;
zebra_set_state (zh, 'o', seqno);
bf_commitClean (bfs, rval);
bfs_destroy (bfs);
}
if (!rval)
seqno++;
zebra_set_state (zh, 'o', seqno);
-
zebra_unlock (zh->lock_shadow);
zebra_unlock (zh->lock_normal);
zebra_unlock (zh->lock_shadow);
zebra_unlock (zh->lock_normal);
@@
-1972,6
+1966,7
@@
static ZEBRA_RES zebra_commit_ex(ZebraHandle zh, int clean_only)
ASSERTZH;
ASSERTZH;
+ yaz_log(log_level, "zebra_commit_ex clean_only=%d", clean_only);
zebra_select_default_database(zh);
if (!zh->res)
{
zebra_select_default_database(zh);
if (!zh->res)
{
@@
-2003,6
+1998,11
@@
static ZEBRA_RES zebra_commit_ex(ZebraHandle zh, int clean_only)
yaz_log(YLOG_WARN, "previous transaction didn't reach commit");
clean_only = 1;
}
yaz_log(YLOG_WARN, "previous transaction didn't reach commit");
clean_only = 1;
}
+ else if (val == 'c')
+ {
+ /* commit has started. We can not remove it anymore */
+ clean_only = 0;
+ }
if (rval && *rval)
bf_cache (bfs, rval);
if (rval && *rval)
bf_cache (bfs, rval);
@@
-2014,7
+2014,7
@@
static ZEBRA_RES zebra_commit_ex(ZebraHandle zh, int clean_only)
{
zebra_set_state(zh, 'c', seqno);
{
zebra_set_state(zh, 'c', seqno);
- yaz_log(YLOG_DEBUG, "commit start");
+ yaz_log(log_level, "commit start");
if (bf_commitExec (bfs))
res = ZEBRA_FAIL;
}
if (bf_commitExec (bfs))
res = ZEBRA_FAIL;
}