From: Adam Dickmeiss Date: Thu, 9 Sep 2004 10:43:18 +0000 (+0000) Subject: Avoid using NULL bfs in zebra_init X-Git-Tag: ZEBRA.1.3.20~46 X-Git-Url: http://lists.indexdata.dk/cgi-bin?a=commitdiff_plain;h=4b788ad7e5958879d00aea15931aaa8efc7408c5;p=idzebra-moved-to-github.git Avoid using NULL bfs in zebra_init --- diff --git a/index/zebraapi.c b/index/zebraapi.c index 3e98491..89450e8 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -1,4 +1,4 @@ -/* $Id: zebraapi.c,v 1.122 2004-08-04 09:05:17 adam Exp $ +/* $Id: zebraapi.c,v 1.120.2.1 2004-09-09 10:43:18 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -249,10 +249,6 @@ struct zebra_register *zebra_register_open (ZebraService zs, const char *name, reg->keys.buf_max = 0; reg->keys.buf = 0; -#if IT_KEY_NEW - reg->keys.codec_handle = iscz1_start(); -#endif - reg->sortKeys.buf = 0; reg->sortKeys.buf_max = 0; @@ -263,6 +259,7 @@ struct zebra_register *zebra_register_open (ZebraService zs, const char *name, reg->matchDict = 0; reg->isam = 0; reg->isamc = 0; + reg->isamd = 0; reg->isamb = 0; reg->zei = 0; reg->matchDict = 0; @@ -327,6 +324,17 @@ struct zebra_register *zebra_register_open (ZebraService zs, const char *name, return 0; } } + if (res_get_match (res, "isam", "d", ISAM_DEFAULT)) + { + struct ISAMD_M_s isamd_m; + + if (!(reg->isamd = isamd_open (reg->bfs, FNAME_ISAMD, + rw, key_isamd_m(res, &isamd_m)))) + { + logf (LOG_WARN, "isamd_open"); + return 0; + } + } if (res_get_match (res, "isam", "b", ISAM_DEFAULT)) { struct ISAMC_M_s isamc_m; @@ -416,6 +424,8 @@ static void zebra_register_close (ZebraService zs, struct zebra_register *reg) is_close (reg->isam); if (reg->isamc) isc_close (reg->isamc); + if (reg->isamd) + isamd_close (reg->isamd); if (reg->isamb) isamb_close (reg->isamb); rec_close (®->records); @@ -429,10 +439,6 @@ static void zebra_register_close (ZebraService zs, struct zebra_register *reg) xfree (reg->sortKeys.buf); xfree (reg->keys.buf); -#if IT_KEY_NEW - if (reg->keys.codec_handle) - iscz1_stop(reg->keys.codec_handle); -#endif xfree (reg->key_buf); xfree (reg->name); @@ -1022,7 +1028,7 @@ int zebra_admin_import_end (ZebraHandle zh) int zebra_admin_import_segment (ZebraHandle zh, Z_Segment *segment) { - SYSNO sysno; + int sysno; int i; ASSERTZH; yaz_log(LOG_API,"zebra_admin_import_segment"); @@ -1066,7 +1072,7 @@ int zebra_admin_exchange_record (ZebraHandle zh, /* 3 = delete. Fail if does not exist */ /* 4 = update. Insert/replace */ { - SYSNO sysno = 0; + int sysno = 0; char *rinfo = 0; char recid_z[256]; ASSERTZH; @@ -1727,6 +1733,8 @@ int zebra_init (ZebraHandle zh) bfs = bfs_create (res_get (zh->service->global_res, "register"), zh->path_reg); + if (!bfs) + return -1; if (rval && *rval) bf_cache (bfs, rval); @@ -1942,17 +1950,17 @@ NOTE: Now returns 0 at success and updates sysno, which is an int* int zebra_add_record(ZebraHandle zh, const char *buf, int buf_size) { - SYSNO sysno = 0; + int sysno = 0; return zebra_update_record(zh, 0, &sysno, 0, 0, buf, buf_size, 0); } int zebra_insert_record (ZebraHandle zh, const char *recordType, - SYSNO *sysno, const char *match, const char *fname, + int *sysno, const char *match, const char *fname, const char *buf, int buf_size, int force_update) { int res; - yaz_log(LOG_API,"zebra_insert_record sysno=" ZINT_FORMAT, *sysno); + yaz_log(LOG_API,"zebra_insert_record sysno=%d", *sysno); if (buf_size < 1) buf_size = strlen(buf); @@ -1972,13 +1980,13 @@ int zebra_insert_record (ZebraHandle zh, int zebra_update_record (ZebraHandle zh, const char *recordType, - SYSNO* sysno, const char *match, const char *fname, + int* sysno, const char *match, const char *fname, const char *buf, int buf_size, int force_update) { int res; - yaz_log(LOG_API,"zebra_update_record sysno=" ZINT_FORMAT, *sysno); + yaz_log(LOG_API,"zebra_update_record sysno=%d", *sysno); if (buf_size < 1) buf_size = strlen(buf); @@ -1992,18 +2000,19 @@ int zebra_update_record (ZebraHandle zh, match, fname, force_update, 1); /* allow_update */ + yaz_log(LOG_LOG, "zebra_update_record returned res=%d", res); zebra_end_trans(zh); return res; } int zebra_delete_record (ZebraHandle zh, const char *recordType, - SYSNO *sysno, const char *match, const char *fname, + int *sysno, const char *match, const char *fname, const char *buf, int buf_size, int force_update) { int res; - yaz_log(LOG_API,"zebra_delete_record sysno=" ZINT_FORMAT, *sysno); + yaz_log(LOG_API,"zebra_delete_record sysno=%d", *sysno); if (buf_size < 1) buf_size = strlen(buf);