X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fzebraapi.c;h=2a43bc90edcf26aeaa919fa390ae57a6916ff281;hb=ff239404c4969d04388c7af260c5c7c11e82fd67;hp=0ff088076e3d76c848506eb8e4a8b1664a63b476;hpb=fc9684841bbfad0b625e7365b99bae7b7df737df;p=idzebra-moved-to-github.git diff --git a/index/zebraapi.c b/index/zebraapi.c index 0ff0880..2a43bc9 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.95 2003-03-26 00:02:05 adam Exp $ + Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003 Index Data Aps This file is part of the Zebra server. @@ -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); } @@ -1136,8 +1136,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 +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; @@ -1416,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++; @@ -1439,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; @@ -1770,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; @@ -1787,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; @@ -1808,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; }