X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;ds=sidebyside;f=index%2Fzebraapi.c;h=8c49ad379927d9028d400cce0417c08d73d10e5c;hb=0cac58c528d39e9838a4ee6e3f76bc5ca6bd30bf;hp=9f5135f880e3c80f8f2663accb5099a2f37107cf;hpb=b9d6210c039df8f2832ac0cee7be1e6dc1833a2f;p=idzebra-moved-to-github.git diff --git a/index/zebraapi.c b/index/zebraapi.c index 9f5135f..8c49ad3 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -1,4 +1,4 @@ -/* $Id: zebraapi.c,v 1.150 2005-01-21 19:07:25 adam Exp $ +/* $Id: zebraapi.c,v 1.154 2005-03-09 12:14:42 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -681,6 +681,21 @@ void map_basenames_func (void *vp, const char *name, const char *value) } } +int zebra_select_default_database(ZebraHandle zh) +{ + if (!zh->res) + { + /* no database has been selected - so we select based on + resource setting (including group) + */ + const char *group = res_get(zh->service->global_res, "group"); + const char *v = res_get_prefix(zh->service->global_res, + "database", group, "Default"); + zebra_select_database(zh, v); + } + return 0; +} + void map_basenames (ZebraHandle zh, ODR stream, int *num_bases, char ***basenames) { @@ -694,6 +709,7 @@ void map_basenames (ZebraHandle zh, ODR stream, zh->errCode = 0; info.zh = zh; + info.num_bases = *num_bases; info.basenames = *basenames; info.new_num_max = 128; @@ -807,7 +823,7 @@ int zebra_select_databases (ZebraHandle zh, int num_bases, } int zebra_search_RPN (ZebraHandle zh, ODR o, - Z_RPNQuery *query, const char *setname, int *hits) + Z_RPNQuery *query, const char *setname, zint *hits) { const char *max; zint maxhits; @@ -991,7 +1007,7 @@ int zebra_deleteResultSet(ZebraHandle zh, int function, int i, status; ASSERTZH; assert(statuses); - yaz_log(log_level, "zebra_deleleResultSet n=%d",num_setnames); + yaz_log(log_level, "zebra_deleteResultSet n=%d",num_setnames); zh->errCode = 0; if (zebra_begin_read(zh)) return Z_DeleteStatus_systemProblemAtTarget; @@ -1400,16 +1416,7 @@ static void read_res_for_transaction(ZebraHandle zh) int zebra_begin_trans (ZebraHandle zh, int rw) { ASSERTZH; - if (!zh->res) - { - /* no database has been selected - so we select based on - resource setting (including group) - */ - const char *group = res_get(zh->service->global_res, "group"); - const char *v = res_get_prefix(zh->service->global_res, - "database", group, "Default"); - zebra_select_database(zh, v); - } + zebra_select_default_database(zh); if (!zh->res) { zh->errCode = 2; @@ -1680,10 +1687,10 @@ int zebra_end_transaction (ZebraHandle zh, ZebraTransactionStatus *status) zh->records_processed, zh->records_inserted, zh->records_updated, zh->records_deleted); - status->processed = zh->records_processed; - status->inserted = zh->records_inserted; - status->updated = zh->records_updated; - status->deleted = zh->records_deleted; + status->processed = (int) zh->records_processed; + status->inserted = (int) zh->records_inserted; + status->updated = (int) zh->records_updated; + status->deleted = (int) zh->records_deleted; zebra_get_state (zh, &val, &seqno); if (val != 'd') @@ -1752,6 +1759,7 @@ static int zebra_commit_ex (ZebraHandle zh, int clean_only) ASSERTZH; zh->errCode = 0; + zebra_select_default_database(zh); if (!zh->res) { zh->errCode = 109; @@ -1825,6 +1833,7 @@ int zebra_init (ZebraHandle zh) yaz_log(log_level, "zebra_init"); zh->errCode = 0; + zebra_select_default_database(zh); if (!zh->res) { zh->errCode = 109; @@ -1832,8 +1841,7 @@ int zebra_init (ZebraHandle zh) } rval = res_get (zh->res, "shadow"); - bfs = bfs_create (res_get (zh->service->global_res, "register"), - zh->path_reg); + bfs = bfs_create (res_get (zh->res, "register"), zh->path_reg); if (!bfs) return -1; if (rval && *rval) @@ -2083,9 +2091,9 @@ int zebra_delete_record (ZebraHandle zh, */ int zebra_search_PQF (ZebraHandle zh, const char *pqf_query, - const char *setname, int *numhits) + const char *setname, zint *numhits) { - int hits = 0; + zint hits = 0; int res = -1; Z_RPNQuery *query; ODR odr = odr_createmem(ODR_ENCODE); @@ -2104,7 +2112,7 @@ int zebra_search_PQF (ZebraHandle zh, const char *pqf_query, odr_destroy(odr); - yaz_log(log_level, "Hits: %d",hits); + yaz_log(log_level, "Hits: " ZINT_FORMAT, hits); if (numhits) *numhits = hits;