const char *query, char *res, int len) {
int status;
- const char *addinfo;
+ const char *addinfo = "";
CQL_parser cp = cql_parser_create();
- if (status = cql_transform_error(ct, &addinfo)) {
- logf (LOG_WARN,"Transform error %d %s\n", status, addinfo ? addinfo : "");
+ if (status = cql_parser_string(cp, query)) {
+ cql_parser_destroy(cp);
return (status);
}
- if (status = cql_parser_string(cp, query))
- return (status);
-
- if (status = cql_transform_buf(ct, cql_parser_result(cp), res, len)) {
+ if (cql_transform_buf(ct, cql_parser_result(cp), res, len)) {
+ status = cql_transform_error(ct, &addinfo);
logf (LOG_WARN,"Transform error %d %s\n", status, addinfo ? addinfo : "");
+ cql_parser_destroy(cp);
return (status);
}
+ cql_parser_destroy(cp);
return (0);
}
(RetrievalRecordBuf *) odr_malloc(stream, sizeof(*buf));
res->errCode = ro->records[i].errCode;
- res->errString = ro->records[i].errString;
+ if (ro->records[i].errString) {
+ res->errString = odr_strdup(stream, ro->records[i].errString);
+ } else {
+ res->errString = "";
+ }
res->position = ro->records[i].position;
res->base = ro->records[i].base;
- res->format = ro->records[i].format;
+ res->format = (char *)
+ yaz_z3950_oid_value_to_str(ro->records[i].format, CLASS_RECSYN);
res->buf = buf;
res->buf->len = ro->records[i].len;
res->buf->buf = ro->records[i].buf;
+ res->score = ro->records[i].score;
+ res->sysno = ro->records[i].sysno;
}
recs[i].len = strlen(poset[i].term);
recs[i].buf = poset[i].term;
recs[i].base = poset[i].db;
+ recs[i].sysno = 0;
}
else if (poset[i].sysno)
&recs[i].base);
recs[i].buf = (char *) odr_malloc(stream,recs[i].len);
memcpy(recs[i].buf, b, recs[i].len);
- recs[i].errString = NULL;
+ recs[i].errString = 0; /* Hmmm !!! we should get this */
+ recs[i].sysno = poset[i].sysno;
+ recs[i].score = poset[i].score;
}
else
{
int num_input_setnames = 0;
int sort_status = 0;
Z_SortKeySpecList *sort_sequence = yaz_sort_spec (stream, sort_spec);
-
+ if (!sort_sequence) {
+ logf(LOG_WARN,"invalid sort specs '%s'", sort_spec);
+ zh->errCode = 207;
+ return (-1);
+ }
+
/* we can do this, since the typemap code for char** will
put a NULL at the end of list */
- while (input_setnames[num_input_setnames]) num_input_setnames++;
+ while (input_setnames[num_input_setnames]) num_input_setnames++;
- if (zebra_begin_read (zh))
- return;
-
- resultSetSort (zh, stream->mem, num_input_setnames, input_setnames,
- output_setname, sort_sequence, &sort_status);
-
- zebra_end_read(zh);
- return (sort_status);
+ if (zebra_begin_read (zh))
+ return;
+
+ resultSetSort (zh, stream->mem, num_input_setnames, input_setnames,
+ output_setname, sort_sequence, &sort_status);
+
+ zebra_end_read(zh);
+ return (sort_status);
}