More diagnostics in log.
[yaz-moved-to-github.git] / server / seshigh.c
index 4cb1d35..5806a15 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (c) 1995-2001, Index Data
  * See the file LICENSE for details.
  *
- * $Id: seshigh.c,v 1.120 2001-10-05 14:43:22 adam Exp $
+ * $Id: seshigh.c,v 1.123 2002-01-17 21:03:36 adam Exp $
  */
 
 /*
@@ -741,13 +741,8 @@ static Z_APDU *process_initRequest(association *assoc, request *reqb)
 
 static void set_addinfo (Z_DefaultDiagFormat *dr, char *addinfo, ODR odr)
 {
-#if ASN_COMPILED
     dr->which = Z_DefaultDiagFormat_v2Addinfo;
     dr->u.v2Addinfo = odr_strdup (odr, addinfo ? addinfo : "");
-#else
-    dr->which = Z_DiagForm_v2AddInfo;
-    dr->addinfo = odr_strdup (odr, addinfo ? addinfo : "");
-#endif
 }
 
 /*
@@ -763,16 +758,10 @@ static Z_Records *diagrec(association *assoc, int error, char *addinfo)
     Z_DefaultDiagFormat *dr = (Z_DefaultDiagFormat *)
        odr_malloc (assoc->encode, sizeof(*dr));
 
-    yaz_log(LOG_DEBUG, "Diagnostic: %d -- %s", error, addinfo ? addinfo :
-       "NULL");
+    yaz_log(LOG_LOG, "[%d] %s %s%s", error, diagbib1_str(error),
+        addinfo ? " -- " : "", addinfo ? addinfo : "", error);
     rec->which = Z_Records_NSD;
-#if ASN_COMPILED
     rec->u.nonSurrogateDiagnostic = dr;
-#else
-    rec->u.nonSurrogateDiagnostic = drec;
-    drec->which = Z_DiagRec_defaultFormat;
-    drec->u.defaultFormat = dr;
-#endif
     dr->diagnosticSetId =
        yaz_oidval_to_z3950oid (assoc->encode, CLASS_DIAGSET, VAL_BIB1);
     dr->condition = err;
@@ -831,13 +820,8 @@ static Z_DiagRecs *diagrecs(association *assoc, int error, char *addinfo)
        yaz_oidval_to_z3950oid (assoc->encode, CLASS_DIAGSET, VAL_BIB1);
     rec->condition = err;
 
-#ifdef ASN_COMPILED
     rec->which = Z_DefaultDiagFormat_v2Addinfo;
     rec->u.v2Addinfo = odr_strdup (assoc->encode, addinfo ? addinfo : "");
-#else
-    rec->which = Z_DiagForm_v2AddInfo;
-    rec->addinfo = odr_strdup (assoc->encode, addinfo ? addinfo : "");
-#endif
     return recs;
 }
 
@@ -863,7 +847,7 @@ static Z_Records *pack_records(association *a, char *setname, int start,
     *num = 0;
     *next = 0;
 
-    yaz_log(LOG_LOG, "Request to pack %d+%d", start, toget);
+    yaz_log(LOG_LOG, "Request to pack %d+%d+%s", start, toget, setname);
     yaz_log(LOG_DEBUG, "pms=%d, mrs=%d", a->preferredMessageSize,
        a->maximumRecordSize);
     for (recno = start; reclist->num_records < toget; recno++)
@@ -902,7 +886,15 @@ static Z_Records *pack_records(association *a, char *setname, int start,
        {
            if (!freq.surrogate_flag)
            {
+               char s[20];
                *pres = Z_PRES_FAILURE;
+               /* for 'present request out of range',
+                   set addinfo to record position if not set */
+               if (freq.errcode == 13 && freq.errstring == 0)
+               {
+                   sprintf (s, "%d", recno);
+                   freq.errstring = s;
+               }
                return diagrec(a, freq.errcode, freq.errstring);
            }
            reclist->records[reclist->num_records] =
@@ -1023,28 +1015,6 @@ static Z_APDU *process_searchRequest(association *assoc, request *reqb,
        if (!bsrr->request)
            return 0;
     }
-#if 0
-    else
-    {
-       bend_searchrequest bsrq;
-       bend_searchresult *bsrt;
-
-       bsrq.setname = req->resultSetName;
-       bsrq.replace_set = *req->replaceIndicator;
-       bsrq.num_bases = req->num_databaseNames;
-       bsrq.basenames = req->databaseNames;
-       bsrq.query = req->query;
-        bsrq.referenceId = req->referenceId;
-       bsrq.stream = assoc->encode;
-       bsrq.decode = assoc->decode;
-       bsrq.print = assoc->print;
-       if (!(bsrt = bend_search (assoc->backend, &bsrq, fd)))
-           return 0;
-       bsrr->hits = bsrt->hits;
-       bsrr->errcode = bsrt->errcode;
-       bsrr->errstring = bsrt->errstring;
-    }
-#endif
     return response_searchRequest(assoc, reqb, bsrr, fd);
 }
 
@@ -1096,6 +1066,8 @@ static Z_APDU *response_searchRequest(association *assoc, request *reqb,
         int *presst = odr_intdup(assoc->encode, 0);
        Z_RecordComposition comp, *compp = 0;
 
+        yaz_log (LOG_LOG, "resultCount: %d", bsrt->hits);
+
        resp->records = 0;
        resp->resultCount = &bsrt->hits;
 
@@ -1390,13 +1362,8 @@ static Z_APDU *process_sortRequest(association *assoc, request *reqb,
 
     yaz_log(LOG_LOG, "Got SortRequest.");
 
-#ifdef ASN_COMPILED
     bsrr->num_input_setnames = req->num_inputResultSetNames;
     bsrr->input_setnames = req->inputResultSetNames;
-#else
-    bsrr->num_input_setnames = req->inputResultSetNames->num_strings;
-    bsrr->input_setnames = req->inputResultSetNames->strings;
-#endif
     bsrr->referenceId = req->referenceId;
     bsrr->output_setname = req->sortedResultSetName;
     bsrr->sort_sequence = req->sortSequence;
@@ -1415,18 +1382,12 @@ static Z_APDU *process_sortRequest(association *assoc, request *reqb,
     if (bsrr->errcode)
     {
        Z_DiagRecs *dr = diagrecs (assoc, bsrr->errcode, bsrr->errstring);
-#ifdef ASN_COMPILED
        res->diagnostics = dr->diagRecs;
        res->num_diagnostics = dr->num_diagRecs;
-#else
-       res->diagnostics = dr;
-#endif
     }
     else
     {
-#ifdef ASN_COMPILED
        res->num_diagnostics = 0;
-#endif
        res->diagnostics = 0;
     }
     res->otherInfo = 0;