X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fzebraapi.c;h=2a43bc90edcf26aeaa919fa390ae57a6916ff281;hb=ff239404c4969d04388c7af260c5c7c11e82fd67;hp=74fa36c048f717e3472efd10c583e05695bf0779;hpb=eb8857cfa2ceaa2635f14888b95d6f71b8def045;p=idzebra-moved-to-github.git diff --git a/index/zebraapi.c b/index/zebraapi.c index 74fa36c..2a43bc9 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -1,4 +1,4 @@ -/* $Id: zebraapi.c,v 1.90 2003-03-05 00:08:04 adam Exp $ +/* $Id: zebraapi.c,v 1.95 2003-03-26 00:02:05 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003 Index Data Aps @@ -846,7 +846,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); } @@ -1389,7 +1389,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; @@ -1422,13 +1422,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++; @@ -1445,6 +1450,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; @@ -1776,11 +1791,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; @@ -1793,16 +1835,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; @@ -1814,7 +1861,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; }