X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fseshigh.c;h=73d443ab8e02cd7913dada69b3844259e48c751a;hb=7b43d0bb4e3c154246bdaba51b78e9861fd3bd97;hp=88dc83394a7271a058beb5666c11414ded4976c1;hpb=84d7b06c13daa609e93f353e655c4b02f936d65c;p=yaz-moved-to-github.git diff --git a/src/seshigh.c b/src/seshigh.c index 88dc833..73d443a 100644 --- a/src/seshigh.c +++ b/src/seshigh.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2005, Index Data ApS * See the file LICENSE for details. * - * $Id: seshigh.c,v 1.53 2005-04-22 08:27:58 adam Exp $ + * $Id: seshigh.c,v 1.57 2005-06-13 10:27:00 adam Exp $ */ /** * \file seshigh.c @@ -713,11 +713,7 @@ static void srw_bend_search(association *assoc, request *req, *http_code = 200; yaz_log(log_requestdetail, "Got SRW SearchRetrieveRequest"); srw_bend_init(assoc, &srw_res->diagnostics, &srw_res->num_diagnostics); - if (srw_req->sort_type != Z_SRW_sort_type_none) - yaz_add_srw_diagnostic(assoc->encode, &srw_res->diagnostics, - &srw_res->num_diagnostics, - YAZ_SRW_SORT_UNSUPP, 0); - else if (srw_res->num_diagnostics == 0 && assoc->init) + if (srw_res->num_diagnostics == 0 && assoc->init) { bend_search_rr rr; rr.setname = "default"; @@ -725,6 +721,7 @@ static void srw_bend_search(association *assoc, request *req, rr.num_bases = 1; rr.basenames = &srw_req->database; rr.referenceId = 0; + rr.srw_sortKeys = 0; rr.query = (Z_Query *) odr_malloc (assoc->decode, sizeof(*rr.query)); rr.query->u.type_1 = 0; @@ -794,6 +791,9 @@ static void srw_bend_search(association *assoc, request *req, rr.decode = assoc->decode; rr.print = assoc->print; rr.request = req; + if ( srw_req->sort.sortKeys ) + rr.srw_sortKeys = odr_strdup(assoc->encode, + srw_req->sort.sortKeys ); rr.association = assoc; rr.fd = 0; rr.hits = 0; @@ -851,25 +851,25 @@ static void srw_bend_search(association *assoc, request *req, number * sizeof(*srw_res->records)); for (i = 0; irecords[j].recordPacking = packing; - srw_res->records[j].recordData_buf = 0; - yaz_log(YLOG_DEBUG, "srw_bend_fetch %d", i+start); - errcode = srw_bend_fetch(assoc, i+start, srw_req, - srw_res->records + j); - if (errcode) - { - yaz_add_srw_diagnostic(assoc->encode, - &srw_res->diagnostics, - &srw_res->num_diagnostics, - yaz_diag_bib1_to_srw (errcode), - rr.errstring); - - break; - } - if (srw_res->records[j].recordData_buf) - j++; + int errcode; + + srw_res->records[j].recordPacking = packing; + srw_res->records[j].recordData_buf = 0; + yaz_log(YLOG_DEBUG, "srw_bend_fetch %d", i+start); + errcode = srw_bend_fetch(assoc, i+start, srw_req, + srw_res->records + j); + if (errcode) + { + yaz_add_srw_diagnostic(assoc->encode, + &srw_res->diagnostics, + &srw_res->num_diagnostics, + yaz_diag_bib1_to_srw (errcode), + rr.errstring); + + break; + } + if (srw_res->records[j].recordData_buf) + j++; } srw_res->num_records = j; if (!j) @@ -1764,7 +1764,7 @@ static Z_APDU *process_initRequest(association *assoc, request *reqb) assoc->init->implementation_name, odr_prepend(assoc->encode, "GFS", resp->implementationName)); - version = odr_strdup(assoc->encode, "$Revision: 1.53 $"); + version = odr_strdup(assoc->encode, "$Revision: 1.57 $"); if (strlen(version) > 10) /* check for unexpanded CVS strings */ version[strlen(version)-2] = '\0'; resp->implementationVersion = odr_prepend(assoc->encode, @@ -1897,6 +1897,9 @@ static Z_Records *pack_records(association *a, char *setname, int start, freq.referenceId = referenceId; freq.schema = 0; (*a->init->bend_fetch)(a->backend, &freq); + + *next = freq.last_in_set ? 0 : recno + 1; + /* backend should be able to signal whether error is system-wide or only pertaining to current record */ if (freq.errcode) @@ -1921,9 +1924,13 @@ static Z_Records *pack_records(association *a, char *setname, int start, surrogatediagrec(a, freq.basename, freq.errcode, freq.errstring); reclist->num_records++; - *next = freq.last_in_set ? 0 : recno + 1; continue; } + if (freq.record == 0) /* no error and no record ? */ + { + *next = 0; /* signal end-of-set and stop */ + break; + } if (freq.len >= 0) this_length = freq.len; else @@ -1950,7 +1957,6 @@ static Z_Records *pack_records(association *a, char *setname, int start, reclist->records[reclist->num_records] = surrogatediagrec(a, freq.basename, 16, 0); reclist->num_records++; - *next = freq.last_in_set ? 0 : recno + 1; dumped_records += this_length; continue; } @@ -1962,7 +1968,6 @@ static Z_Records *pack_records(association *a, char *setname, int start, reclist->records[reclist->num_records] = surrogatediagrec(a, freq.basename, 17, 0); reclist->num_records++; - *next = freq.last_in_set ? 0 : recno + 1; dumped_records += this_length; continue; } @@ -1988,7 +1993,6 @@ static Z_Records *pack_records(association *a, char *setname, int start, return 0; reclist->records[reclist->num_records] = thisrec; reclist->num_records++; - *next = freq.last_in_set ? 0 : recno + 1; } *num = reclist->num_records; return records; @@ -2007,6 +2011,7 @@ static Z_APDU *process_searchRequest(association *assoc, request *reqb, bsrr->association = assoc; bsrr->referenceId = req->referenceId; save_referenceId (reqb, bsrr->referenceId); + bsrr->srw_sortKeys = 0; yaz_log (log_requestdetail, "ResultSet '%s'", req->resultSetName); if (req->databaseNames) @@ -2340,9 +2345,9 @@ static Z_APDU *process_scanRequest(association *assoc, request *reqb, int *fd) for (i = 0; i < req->num_databaseNames; i++) yaz_log (log_requestdetail, "Database '%s'", req->databaseNames[i]); } - yaz_log(log_requestdetail, "pos %d step %d entries %d", - *req->preferredPositionInResponse, *res->stepSize, - *req->numberOfTermsRequested); + bsrr->scanClause = 0; + bsrr->errcode = 0; + bsrr->errstring = 0; bsrr->num_bases = req->num_databaseNames; bsrr->basenames = req->databaseNames; bsrr->num_entries = *req->numberOfTermsRequested; @@ -2474,7 +2479,8 @@ static Z_APDU *process_scanRequest(association *assoc, request *reqb, int *fd) wrbuf_printf(wr, "Partial"); wrbuf_printf(wr, " %d+%d %d ", - *req->preferredPositionInResponse, + (req->preferredPositionInResponse ? + *req->preferredPositionInResponse : 1), *req->numberOfTermsRequested, (res->stepSize ? *res->stepSize : 0)); wrbuf_scan_term(wr, req->termListAndStartPoint,