From: Adam Dickmeiss Date: Thu, 20 Dec 2012 10:35:58 +0000 (+0100) Subject: GFS: bail out of fetch if last_in_set is set X-Git-Tag: v4.2.48~11 X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=commitdiff_plain;h=36d8976c55a2681d0057a0c200356a283e897b91;hp=b70c72a5a3914502cbdd17588e74e6c74bd282b6 GFS: bail out of fetch if last_in_set is set Until now, last_in_set, was only used as to indicate that next-result-set-position should be set to zero. http://www.loc.gov/z3950/agency/markup/04.html#Next-result-set-position Based on patch from Ashley Sanders. --- diff --git a/src/seshigh.c b/src/seshigh.c index 2555823..5a6a26f 100644 --- a/src/seshigh.c +++ b/src/seshigh.c @@ -671,7 +671,7 @@ static int retrieve_fetch(association *assoc, bend_fetch_rr *rr) static int srw_bend_fetch(association *assoc, int pos, Z_SRW_searchRetrieveRequest *srw_req, Z_SRW_record *record, - const char **addinfo) + const char **addinfo, int *last_in_set) { bend_fetch_rr rr; ODR o = assoc->encode; @@ -730,6 +730,8 @@ static int srw_bend_fetch(association *assoc, int pos, retrieve_fetch(assoc, &rr); + *last_in_set = rr.last_in_set; + if (rr.errcode && rr.surrogate_flag) { int code = yaz_diag_bib1_to_srw(rr.errcode); @@ -1088,6 +1090,7 @@ static void srw_bend_search(association *assoc, for (i = 0; irecords[j].recordPacking = packing; @@ -1096,7 +1099,7 @@ static void srw_bend_search(association *assoc, yaz_log(YLOG_DEBUG, "srw_bend_fetch %d", i+start); errcode = srw_bend_fetch(assoc, i+start, srw_req, srw_res->records + j, - &addinfo); + &addinfo, &last_in_set); if (errcode) { yaz_add_srw_diagnostic(assoc->encode, @@ -1109,6 +1112,8 @@ static void srw_bend_search(association *assoc, } if (srw_res->records[j].recordData_buf) j++; + if (last_in_set) + break; } srw_res->num_records = j; if (!j) @@ -2595,6 +2600,8 @@ static Z_Records *pack_records(association *a, char *setname, Odr_int start, return 0; reclist->records[reclist->num_records] = thisrec; reclist->num_records++; + if (freq.last_in_set) + break; } *num = reclist->num_records; return records;