From: Adam Dickmeiss Date: Wed, 4 Jul 2007 12:07:49 +0000 (+0000) Subject: Loose the query parsing so that Pazpar2 only returns error if _all_ X-Git-Tag: PAZPAR2.1.0.2~89 X-Git-Url: http://git.indexdata.com/?a=commitdiff_plain;h=c7e28063b2365987df7adc35db6786732b8e233f;p=pazpar2-moved-to-github.git Loose the query parsing so that Pazpar2 only returns error if _all_ query conversions fail (rather than _any_). This means targets that do not support some fields are ignored in a search. --- diff --git a/NEWS b/NEWS index e75dc33..f97a246 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,7 @@ +Loose the query parsing so that Pazpar2 only returns error if _all_ +query conversions fail (rather than _any_). This means targets that do +not support some fields are ignored in a search. + --- 1.0.1 2007/07/03 Improved handling of socket timeout for Z39.50 connections. diff --git a/src/logic.c b/src/logic.c index e131fb3..e7f2941 100644 --- a/src/logic.c +++ b/src/logic.c @@ -1,4 +1,4 @@ -/* $Id: logic.c,v 1.47 2007-06-28 09:36:10 adam Exp $ +/* $Id: logic.c,v 1.48 2007-07-04 12:07:49 adam Exp $ Copyright (c) 2006-2007, Index Data. This file is part of Pazpar2. @@ -497,6 +497,8 @@ enum pazpar2_error_code search(struct session *se, const char **addinfo) { int live_channels = 0; + int no_working = 0; + int no_failed = 0; struct client *cl; struct database_criterion *criteria; @@ -528,17 +530,22 @@ enum pazpar2_error_code search(struct session *se, *addinfo = client_get_database(cl)->database->url; return PAZPAR2_CONFIG_TARGET; } - // Query must parse for all targets + // Parse query for target if (client_parse_query(cl, query) < 0) + no_failed++; + else { - *addinfo = "query"; - return PAZPAR2_MALFORMED_PARAMETER_VALUE; + no_working++; + client_prep_connection(cl); } } - for (cl = se->clients; cl; cl = client_next_in_session(cl)) - client_prep_connection(cl); - + // If no queries could be mapped, we signal an error + if (no_working == 0) + { + *addinfo = "query"; + return PAZPAR2_MALFORMED_PARAMETER_VALUE; + } return PAZPAR2_NO_ERROR; }