X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fzebraapi.c;h=0a35c80c99cac1e0742012b74d7eb36cd4fc78d9;hb=397ed9cc5c2a74c066c2c565d5eef22558f63e27;hp=0ff088076e3d76c848506eb8e4a8b1664a63b476;hpb=fc9684841bbfad0b625e7365b99bae7b7df737df;p=idzebra-moved-to-github.git diff --git a/index/zebraapi.c b/index/zebraapi.c index 0ff0880..0a35c80 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -1,5 +1,5 @@ -/* $Id: zebraapi.c,v 1.88 2003-03-04 23:30:20 adam Exp $ - Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 +/* $Id: zebraapi.c,v 1.96 2003-03-26 16:41:48 adam Exp $ + Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003 Index Data Aps This file is part of the Zebra server. @@ -241,6 +241,7 @@ struct zebra_register *zebra_register_open (ZebraService zs, const char *name, zebraRankInstall (reg, rank1_class); zebraRankInstall (reg, rankzv_class); + zebraRankInstall (reg, rankliv_class); recordCompression = res_get_def (res, "recordCompression", "none"); if (!strcmp (recordCompression, "none")) @@ -753,6 +754,9 @@ void zebra_search_rpn (ZebraHandle zh, ODR decode, ODR stream, if (zebra_begin_read (zh)) return; + + zebra_livcode_transform(zh, query); + resultSetAddRPN (zh, decode, stream, query, zh->num_basenames, zh->basenames, setname); @@ -846,7 +850,7 @@ void zebra_scan (ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt, } rpn_scan (zh, stream, zapt, attributeset, zh->num_basenames, zh->basenames, position, - num_entries, entries, is_partial); + num_entries, entries, is_partial, 0, 0); zebra_end_read (zh); } @@ -1136,8 +1140,14 @@ int zebra_begin_trans (ZebraHandle zh, int rw) (zh->trans_no++); if (zh->trans_w_no) return 0; + if (zh->trans_no != 1) + { + zh->errCode = 2; + zh->errString = "write trans not allowed within read trans"; + return -1; + } zh->trans_w_no = zh->trans_no; - + zh->errCode=0; yaz_log (LOG_LOG, "zebra_begin_trans"); @@ -1383,7 +1393,7 @@ void zebra_repository_show (ZebraHandle zh) repositoryShow (zh); } -int zebra_commit (ZebraHandle zh) +static int zebra_commit_ex (ZebraHandle zh, int clean_only) { int seqno; char val; @@ -1416,13 +1426,18 @@ int zebra_commit (ZebraHandle zh) bf_cache (bfs, rval); if (bf_commitExists (bfs)) { - zebra_set_state (zh, 'c', seqno); - - logf (LOG_LOG, "commit start"); - bf_commitExec (bfs); + if (clean_only) + zebra_set_state (zh, 'd', seqno); + else + { + zebra_set_state (zh, 'c', seqno); + + logf (LOG_LOG, "commit start"); + bf_commitExec (bfs); #ifndef WIN32 - sync (); + sync (); #endif + } logf (LOG_LOG, "commit clean"); bf_commitClean (bfs, rval); seqno++; @@ -1439,6 +1454,16 @@ int zebra_commit (ZebraHandle zh) return 0; } +int zebra_clean (ZebraHandle zh) +{ + return zebra_commit_ex(zh, 1); +} + +int zebra_commit (ZebraHandle zh) +{ + return zebra_commit_ex(zh, 0); +} + int zebra_init (ZebraHandle zh) { const char *rval; @@ -1565,7 +1590,7 @@ void zebra_set_resource(ZebraHandle zh, const char *name, const char *value) } const char *zebra_get_resource(ZebraHandle zh, - const char *name, const char *defaultvalue) + const char *name, const char *defaultvalue) { ASSERTZH; zh->errCode=0; @@ -1770,11 +1795,38 @@ void api_records_retrieve (ZebraHandle zh, ODR stream, If not, and a record is provided, then sysno is got from there */ +int zebra_insert_record (ZebraHandle zh, + struct recordGroup *rGroup, + const char *recordType, + int sysno, const char *match, const char *fname, + const char *buf, int buf_size, + int force_update) // This one is ignored + +{ + int res; + + if (buf_size < 1) buf_size = strlen(buf); + + zebra_begin_trans(zh, 1); + res=bufferExtractRecord (zh, buf, buf_size, rGroup, + 0, // delete_flag + 0, // test_mode, + recordType, + &sysno, + match, fname, + force_update, + 0); // allow_update + zebra_end_trans(zh); + if (res < 0) return (res); + return sysno; +} + int zebra_update_record (ZebraHandle zh, struct recordGroup *rGroup, const char *recordType, int sysno, const char *match, const char *fname, - const char *buf, int buf_size) + const char *buf, int buf_size, + int force_update) { int res; @@ -1787,16 +1839,21 @@ int zebra_update_record (ZebraHandle zh, 0, // test_mode, recordType, &sysno, - match, fname); + match, fname, + force_update, + 1); // allow_update zebra_end_trans(zh); return sysno; } + + int zebra_delete_record (ZebraHandle zh, struct recordGroup *rGroup, const char *recordType, int sysno, const char *match, const char *fname, - const char *buf, int buf_size) + const char *buf, int buf_size, + int force_update) { int res; @@ -1808,7 +1865,9 @@ int zebra_delete_record (ZebraHandle zh, 0, // test_mode, recordType, &sysno, - match,fname); + match,fname, + force_update, + 1); // allow_update zebra_end_trans(zh); return sysno; }