From cab0ac043896bc95349ae4ccc10b58251e0b526e Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Fri, 21 Jan 2005 13:23:25 +0000 Subject: [PATCH] Fixed bug #253: Setting group.database not honored. --- index/main.c | 10 +++++----- index/zebraapi.c | 12 +++++++++++- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/index/main.c b/index/main.c index 52a7ab0..c435b21 100644 --- a/index/main.c +++ b/index/main.c @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.122 2005-01-16 23:14:57 adam Exp $ +/* $Id: main.c,v 1.123 2005-01-21 13:23:25 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -59,7 +59,7 @@ int main (int argc, char **argv) char *configName = 0; int nsections = 0; int enable_commit = 1; - char *database = "Default"; + char *database = 0; Res res = res_open(0, 0, 0); int trans_started=0; @@ -135,10 +135,10 @@ int main (int argc, char **argv) zebra_shadow_enable (zh, enable_commit); } - if (zebra_select_database (zh, database)) + if (database && zebra_select_database (zh, database)) { yaz_log(YLOG_FATAL, "Could not select database %s errCode=%d", - database, zebra_errCode(zh) ); + database, zebra_errCode(zh) ); exit (1); } if (!strcmp (arg, "update")) @@ -228,7 +228,7 @@ int main (int argc, char **argv) else if (ret == 'V') { printf("Zebra %s %s\n", ZEBRAVER, ZEBRADATE); - printf(" (C) 1994-2004, Index Data ApS\n"); + printf(" (C) 1994-2005, Index Data ApS\n"); #ifdef WIN32 #ifdef _DEBUG printf(" WIN32 Debug\n"); diff --git a/index/zebraapi.c b/index/zebraapi.c index 0ca84e6..4e08308 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -1,4 +1,4 @@ -/* $Id: zebraapi.c,v 1.147 2005-01-15 19:56:54 adam Exp $ +/* $Id: zebraapi.c,v 1.148 2005-01-21 13:23:25 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -1402,6 +1402,16 @@ 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); + } + if (!zh->res) + { zh->errCode = 2; zh->errString = "zebra_begin_trans: no database selected"; return -1; -- 1.7.10.4