X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fseshigh.c;h=68ff2fa104499e063d8d7681d2bb147fdeb78636;hb=db93359f0cbf9a1e9dc81ea05f7b8662f843ae3d;hp=a91c70a15b2533d0cbb17f522d36cfbd043c8c31;hpb=2ede0bb278b22c8ce1cdd48e9a11a5924d433763;p=yaz-moved-to-github.git diff --git a/src/seshigh.c b/src/seshigh.c index a91c70a..68ff2fa 100644 --- a/src/seshigh.c +++ b/src/seshigh.c @@ -1,8 +1,8 @@ /* - * Copyright (C) 1995-2006, Index Data ApS + * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * - * $Id: seshigh.c,v 1.106 2006-12-06 21:35:58 adam Exp $ + * $Id: seshigh.c,v 1.112 2007-03-19 14:40:07 adam Exp $ */ /** * \file seshigh.c @@ -309,7 +309,7 @@ int ir_read(IOCHAN h, int event) if (conn->io_pending & CS_WANT_WRITE) assoc->cs_get_mask |= EVENT_OUTPUT; iochan_setflag(h, assoc->cs_get_mask); - return 1; + return 0; } /* we got a complete PDU. Let's decode it */ yaz_log(YLOG_DEBUG, "Got PDU, %d bytes: lead=%02X %02X %02X", res, @@ -612,7 +612,8 @@ static int retrieve_fetch(association *assoc, bend_fetch_rr *rr) else if (r == 1 || r == 3) { const char *details = input_schema; - rr->errcode = YAZ_BIB1_ELEMENT_SET_NAMES_UNSUPP; + rr->errcode = + YAZ_BIB1_SPECIFIED_ELEMENT_SET_NAME_NOT_VALID_FOR_SPECIFIED_; if (details) rr->errstring = odr_strdup(rr->stream, details); return -1; @@ -662,7 +663,7 @@ static int retrieve_fetch(association *assoc, bend_fetch_rr *rr) rr->record = odr_malloc(rr->stream, rr->len); memcpy(rr->record, wrbuf_buf(output_record), rr->len); } - wrbuf_free(output_record, 1); + wrbuf_destroy(output_record); } if (match_syntax) { @@ -676,6 +677,7 @@ static int retrieve_fetch(association *assoc, bend_fetch_rr *rr) #else (*assoc->init->bend_fetch)(assoc->backend, rr); #endif + return 0; } static int srw_bend_fetch(association *assoc, int pos, @@ -884,6 +886,8 @@ static void srw_bend_search(association *assoc, request *req, rr.srw_sortKeys = 0; rr.srw_setname = 0; rr.srw_setnameIdleTime = 0; + rr.estimated_hit_count = 0; + rr.partial_resultset = 0; rr.query = (Z_Query *) odr_malloc (assoc->decode, sizeof(*rr.query)); rr.query->u.type_1 = 0; @@ -1105,6 +1109,15 @@ static void srw_bend_search(association *assoc, request *req, srw_res->records = 0; } } + if (rr.estimated_hit_count || rr.partial_resultset) + { + yaz_add_srw_diagnostic( + assoc->encode, + &srw_res->diagnostics, + &srw_res->num_diagnostics, + YAZ_SRW_RESULT_SET_CREATED_WITH_VALID_PARTIAL_RESULTS_AVAILABLE, + 0); + } } } } @@ -1143,8 +1156,8 @@ static void srw_bend_search(association *assoc, request *req, srw_res->resultSetId : "-"), (srw_req->startRecord ? *srw_req->startRecord : 1), srw_res->num_records); - yaz_log(log_request, "%s %s: %s", wrbuf_buf(wr), querytype, querystr); - wrbuf_free(wr, 1); + yaz_log(log_request, "%s %s: %s", wrbuf_cstr(wr), querytype, querystr); + wrbuf_destroy(wr); } } @@ -1421,8 +1434,8 @@ static void srw_bend_scan(association *assoc, request *req, *srw_req->maximumTerms : 1)); /* there is no step size in SRU/W ??? */ wrbuf_printf(wr, "%s: %s ", querytype, querystr); - yaz_log(log_request, "%s ", wrbuf_buf(wr) ); - wrbuf_free(wr, 1); + yaz_log(log_request, "%s ", wrbuf_cstr(wr) ); + wrbuf_destroy(wr); } } @@ -2351,7 +2364,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.106 $"); + version = odr_strdup(assoc->encode, "$Revision: 1.112 $"); if (strlen(version) > 10) /* check for unexpanded CVS strings */ version[strlen(version)-2] = '\0'; resp->implementationVersion = odr_prepend(assoc->encode, @@ -2414,8 +2427,8 @@ static Z_APDU *process_initRequest(association *assoc, request *reqb) (req->implementationVersion ? req->implementationVersion : "-") ); - yaz_log(log_request, "%s", wrbuf_buf(wr)); - wrbuf_free(wr, 1); + yaz_log(log_request, "%s", wrbuf_cstr(wr)); + wrbuf_destroy(wr); } return apdu; } @@ -2634,13 +2647,15 @@ static Z_APDU *process_searchRequest(association *assoc, request *reqb, bsrr->srw_sortKeys = 0; bsrr->srw_setname = 0; bsrr->srw_setnameIdleTime = 0; + bsrr->estimated_hit_count = 0; + bsrr->partial_resultset = 0; yaz_log (log_requestdetail, "ResultSet '%s'", req->resultSetName); if (req->databaseNames) { int i; for (i = 0; i < req->num_databaseNames; i++) - yaz_log (log_requestdetail, "Database '%s'", req->databaseNames[i]); + yaz_log(log_requestdetail, "Database '%s'", req->databaseNames[i]); } yaz_log_zquery_level(log_requestdetail,req->query); @@ -2702,10 +2717,9 @@ static Z_APDU *response_searchRequest(association *assoc, request *reqb, Z_SearchResponse *resp = (Z_SearchResponse *) odr_malloc (assoc->encode, sizeof(*resp)); int *nulint = odr_intdup (assoc->encode, 0); - bool_t *sr = odr_intdup(assoc->encode, 1); int *next = odr_intdup(assoc->encode, 0); int *none = odr_intdup(assoc->encode, Z_SearchResponse_none); - int returnedrecs=0; + int returnedrecs = 0; apdu->which = Z_APDU_searchResponse; apdu->u.searchResponse = resp; @@ -2730,8 +2744,8 @@ static Z_APDU *response_searchRequest(association *assoc, request *reqb, } else { + bool_t *sr = odr_intdup(assoc->encode, 1); int *toget = odr_intdup(assoc->encode, 0); - int *presst = odr_intdup(assoc->encode, 0); Z_RecordComposition comp, *compp = 0; yaz_log (log_requestdetail, "resultCount: %d", bsrt->hits); @@ -2762,6 +2776,7 @@ static Z_APDU *response_searchRequest(association *assoc, request *reqb, { oident *prefformat; oid_value form; + int *presst = odr_intdup(assoc->encode, 0); if (!(prefformat = oid_getentbyoid(req->preferredRecordSyntax))) form = VAL_NONE; @@ -2804,9 +2819,6 @@ static Z_APDU *response_searchRequest(association *assoc, request *reqb, return 0; resp->numberOfRecordsReturned = toget; returnedrecs = *toget; - resp->nextResultSetPosition = next; - resp->searchStatus = sr; - resp->resultSetStatus = 0; resp->presentStatus = presst; } else @@ -2814,11 +2826,21 @@ static Z_APDU *response_searchRequest(association *assoc, request *reqb, if (*resp->resultCount) *next = 1; resp->numberOfRecordsReturned = nulint; - resp->nextResultSetPosition = next; - resp->searchStatus = sr; - resp->resultSetStatus = 0; resp->presentStatus = 0; } + resp->nextResultSetPosition = next; + resp->searchStatus = sr; + resp->resultSetStatus = 0; + if (bsrt->estimated_hit_count) + { + resp->resultSetStatus = odr_intdup(assoc->encode, + Z_SearchResponse_estimate); + } + else if (bsrt->partial_resultset) + { + resp->resultSetStatus = odr_intdup(assoc->encode, + Z_SearchResponse_subset); + } } resp->additionalSearchInfo = bsrt->search_info; @@ -2842,8 +2864,8 @@ static Z_APDU *response_searchRequest(association *assoc, request *reqb, req->resultSetName, returnedrecs); yaz_query_to_wrbuf(wr, req->query); - yaz_log(log_request, "Search %s", wrbuf_buf(wr)); - wrbuf_free(wr, 1); + yaz_log(log_request, "Search %s", wrbuf_cstr(wr)); + wrbuf_destroy(wr); } return apdu; } @@ -2947,8 +2969,8 @@ static Z_APDU *process_presentRequest(association *assoc, request *reqb, wrbuf_printf(wr, " %s %d+%d ", req->resultSetId, *req->resultSetStartPoint, *req->numberOfRecordsRequested); - yaz_log(log_request, "%s", wrbuf_buf(wr) ); - wrbuf_free(wr, 1); + yaz_log(log_request, "%s", wrbuf_cstr(wr) ); + wrbuf_destroy(wr); } if (!resp->records) return 0; @@ -3165,8 +3187,8 @@ static Z_APDU *process_scanRequest(association *assoc, request *reqb, int *fd) yaz_scan_to_wrbuf(wr, req->termListAndStartPoint, bsrr->attributeset); - yaz_log(log_request, "%s", wrbuf_buf(wr) ); - wrbuf_free(wr, 1); + yaz_log(log_request, "%s", wrbuf_cstr(wr) ); + wrbuf_destroy(wr); } return apdu; } @@ -3242,8 +3264,8 @@ static Z_APDU *process_sortRequest(association *assoc, request *reqb, } wrbuf_printf(wr, ")->%s ",req->sortedResultSetName); - yaz_log(log_request, "%s", wrbuf_buf(wr) ); - wrbuf_free(wr, 1); + yaz_log(log_request, "%s", wrbuf_cstr(wr) ); + wrbuf_destroy(wr); } return apdu; } @@ -3326,8 +3348,8 @@ static Z_APDU *process_deleteRequest(association *assoc, request *reqb, wrbuf_printf(wr, "OK -"); for (i = 0; inum_resultSetList; i++) wrbuf_printf(wr, " %s ", req->resultSetList[i]); - yaz_log(log_request, "%s", wrbuf_buf(wr) ); - wrbuf_free(wr, 1); + yaz_log(log_request, "%s", wrbuf_cstr(wr) ); + wrbuf_destroy(wr); } return apdu; } @@ -3513,8 +3535,8 @@ static Z_APDU *process_ESRequest(association *assoc, request *reqb, int *fd) { WRBUF wr = wrbuf_alloc(); wrbuf_diags(wr, resp->num_diagnostics, resp->diagnostics); - yaz_log(log_request, "EsRequest %s", wrbuf_buf(wr) ); - wrbuf_free(wr, 1); + yaz_log(log_request, "EsRequest %s", wrbuf_cstr(wr) ); + wrbuf_destroy(wr); } }