From d5279013c7916ab8eec9624150cf3bd2150d38a4 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 30 May 2006 21:43:15 +0000 Subject: [PATCH] Fixed bug #597: Support null missing key for sort. Reject type missingValueData which is unsupported. --- NEWS | 2 ++ index/zsets.c | 30 +++++++++++++++++++++++------- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/NEWS b/NEWS index 5a3cfd8..758124f 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,5 @@ +Fixed bug #597: Support null missing key for sort. + --- 1.3.34 2006/02/23 Fixed bug #465: dup fields in ISO2709 retrieval. diff --git a/index/zsets.c b/index/zsets.c index 6d85123..a045216 100644 --- a/index/zsets.c +++ b/index/zsets.c @@ -1,4 +1,4 @@ -/* $Id: zsets.c,v 1.49.2.5 2006-01-19 13:32:46 adam Exp $ +/* $Id: zsets.c,v 1.49.2.6 2006-05-30 21:43:15 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005 Index Data Aps @@ -492,8 +492,12 @@ void resultSetInsertSort (ZebraHandle zh, ZebraSet sset, sortIdx_sysno (zh->reg->sortIdx, sysno); for (i = 0; ireg->sortIdx, criteria[i].attrUse); - sortIdx_read (zh->reg->sortIdx, this_entry.buf[i]); + memset(this_entry.buf[i], '\0', SORT_IDX_ENTRYSIZE); + if (criteria[i].attrUse != -1) + { + sortIdx_type (zh->reg->sortIdx, criteria[i].attrUse); + sortIdx_read (zh->reg->sortIdx, this_entry.buf[i]); + } } i = sort_info->num_entries; while (--i >= 0) @@ -753,7 +757,14 @@ void resultSetSortSingle (ZebraHandle zh, NMEM nmem, { zh->errCode = 237; return; - } + } + + if (sks->which == Z_SortKeySpec_missingValueData) + { + zh->errCode = 213; + return; + } + sk = sks->sortElement->u.generic; switch (sk->which) { @@ -772,15 +783,20 @@ void resultSetSortSingle (ZebraHandle zh, NMEM nmem, sk->u.sortAttributes, &sort_criteria[i].numerical); yaz_log (LOG_DEBUG, "use value = %d", sort_criteria[i].attrUse); - if (sort_criteria[i].attrUse == -1) + if (sort_criteria[i].attrUse == -1 && sks->which != Z_SortKeySpec_null) { zh->errCode = 116; return; } if (sortIdx_type (zh->reg->sortIdx, sort_criteria[i].attrUse)) { - zh->errCode = 207; - return; + if (sks->which != Z_SortKeySpec_null) + { + zh->errCode = 207; + return; + } + else + sort_criteria[i].attrUse = -1; } break; } -- 1.7.10.4