Implemented bug #588: allrecords search. Using @attr 1=allrecords ""
authorAdam Dickmeiss <adam@indexdata.dk>
Wed, 17 May 2006 17:46:44 +0000 (17:46 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Wed, 17 May 2006 17:46:44 +0000 (17:46 +0000)
matches all records in a database.

NEWS
index/extract.c
index/kinput.c
index/zrpn.c
util/zebramap.c

diff --git a/NEWS b/NEWS
index d4ac9f9..49bb6f8 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,6 @@
+Implemented bug #588: allrecords search. Using @attr 1=allrecords ""
+matches all records in a database.
+
 Zebra reads (non-standard) attribute 10 for RPN queries. The value, when
 specified, is returned as subqueryId in SearchResult-1. It un-specified
 no subqueryId is part of SearchResult-1.
index e06b9ae..de81472 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: extract.c,v 1.212 2006-05-10 14:13:45 adam Exp $
+/* $Id: extract.c,v 1.213 2006-05-17 17:46:45 adam Exp $
    Copyright (C) 1995-2006
    Index Data ApS
 
@@ -88,6 +88,8 @@ static void logRecord (ZebraHandle zh)
     }
 }
 
+static void extract_add_index_string (RecWord *p, const char *str, int length);
+
 static void extract_set_store_data_prepare(struct recExtractCtrl *p);
 
 static void extract_init (struct recExtractCtrl *p, RecWord *w)
@@ -386,6 +388,16 @@ static void init_extractCtrl(ZebraHandle zh, struct recExtractCtrl *ctrl)
     ctrl->flagShowRecords = !zh->m_flag_rw;
 }
 
+static void all_matches_add(struct recExtractCtrl *ctrl)
+{
+    RecWord word;
+    extract_init(ctrl, &word);
+    word.index_name = "allrecords";
+    word.index_type = 'w';
+    word.seqno = 1;
+    extract_add_index_string (&word, "", 0);
+}
+
 static ZEBRA_RES file_extract_record(ZebraHandle zh,
                                     SYSNO *sysno, const char *fname,
                                     int deleteFlag,
@@ -479,8 +491,9 @@ static ZEBRA_RES file_extract_record(ZebraHandle zh,
             }
             return ZEBRA_FAIL;
         }
+        all_matches_add(&extractCtrl);
         if (extractCtrl.match_criteria[0])
-            matchStr = extractCtrl.match_criteria;     
+            matchStr = extractCtrl.match_criteria;
     }
 
     /* if matchStr is set now - we assume it's printable .
@@ -991,6 +1004,8 @@ ZEBRA_RES buffer_extract_record(ZebraHandle zh,
        return ZEBRA_FAIL;
     }
 
+    all_matches_add(&extractCtrl);
+        
     if (extractCtrl.match_criteria[0])
        match_criteria = extractCtrl.match_criteria;
 
@@ -1688,7 +1703,7 @@ void print_rec_keys(ZebraHandle zh, zebra_rec_keys_t reckeys)
     }
 }
 
-void extract_add_index_string (RecWord *p, const char *str, int length)
+void extract_add_index_string(RecWord *p, const char *str, int length)
 {
     struct it_key key;
 
index 899c5d5..1e9e9a5 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: kinput.c,v 1.74 2006-05-10 08:13:22 adam Exp $
+/* $Id: kinput.c,v 1.75 2006-05-17 17:46:45 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -603,7 +603,7 @@ int heap_inpc (struct heap_cread_info *hci, struct heap_info *hi)
         char *dict_info;
 
         strcpy (this_name, hci->cur_name);
-       assert (hci->cur_name[1]);
+       assert (hci->cur_name[0]);
         hi->no_diffs++;
         if ((dict_info = dict_lookup (hi->reg->dict, hci->cur_name)))
         {
@@ -648,7 +648,7 @@ int heap_inp0(struct heap_cread_info *hci, struct heap_info *hi)
        int mode;
 
         strcpy (this_name, hci->cur_name);
-       assert (hci->cur_name[1]);
+       assert (hci->cur_name[0]);
         hi->no_diffs++;
 
        while (heap_cread_item2(hci, &dst, &mode))
@@ -672,7 +672,7 @@ int heap_inpb(struct heap_cread_info *hci, struct heap_info *hi)
         char *dict_info;
 
         strcpy (this_name, hci->cur_name);
-       assert (hci->cur_name[1]);
+       assert (hci->cur_name[0]);
         hi->no_diffs++;
 
 #if 0
@@ -726,7 +726,7 @@ int heap_inps (struct heap_cread_info *hci, struct heap_info *hi)
         char *dict_info;
 
         strcpy (this_name, hci->cur_name);
-       assert (hci->cur_name[1]);
+       assert (hci->cur_name[0]);
         hi->no_diffs++;
         if (!(dict_info = dict_lookup (hi->reg->dict, hci->cur_name)))
         {
index 2a25753..f7ff740 100644 (file)
@@ -1,5 +1,5 @@
-/* $Id: zrpn.c,v 1.212 2006-05-10 08:13:23 adam Exp $
-   Copyright (C) 1995-2005
+/* $Id: zrpn.c,v 1.213 2006-05-17 17:46:45 adam Exp $
+   Copyright (C) 1995-2006
    Index Data ApS
 
 This file is part of the Zebra server.
@@ -969,7 +969,10 @@ static int string_relation(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
         break;
     case 3:
     case 102:
+    case 103:
     case -1:
+        if (!**term_sub)
+            return 1;
         yaz_log(log_level_rpn, "Relation =");
         if (!term_100(zh->reg->zebra_maps, reg_type, term_sub,
                       term_component, space_split, term_dst))
@@ -1568,7 +1571,9 @@ static ZEBRA_RES term_list_trunc(ZebraHandle zh,
     struct grep_info grep_info;
     const char *termp = termz;
     int alloc_sets = 0;
+    int empty_term = *termz ? 0 : 1;
 
+    empty_term = 0;
     *num_result_sets = 0;
     *term_dst = 0;
     if (grep_info_prepare(zh, zapt, &grep_info, reg_type) == ZEBRA_FAIL)
@@ -1606,6 +1611,11 @@ static ZEBRA_RES term_list_trunc(ZebraHandle zh,
        if ((*result_sets)[*num_result_sets] == 0)
            break;
        (*num_result_sets)++;
+
+        if (empty_term)
+            break;
+        if (!*termp)
+            break;
     }
     grep_info_delete(&grep_info);
     return ZEBRA_OK;
@@ -2411,6 +2421,15 @@ static ZEBRA_RES rpn_search_APT(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
                                     num_bases, basenames, rset_nmem,
                                     rset, kc);
     }
+    else if (!strcmp(search_type, "always"))
+    {
+        *termz = '\0';
+        res = rpn_search_APT_phrase(zh, zapt, termz, attributeSet, stream,
+                                    reg_id, complete_flag, rank_type,
+                                    xpath_use,
+                                    num_bases, basenames, rset_nmem,
+                                    rset, kc);
+    }
     else
     {
        zebra_setError(zh, YAZ_BIB1_UNSUPP_STRUCTURE_ATTRIBUTE, 0);
index 06b2605..d2ac8f9 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: zebramap.c,v 1.47 2006-05-10 08:13:46 adam Exp $
+/* $Id: zebramap.c,v 1.48 2006-05-17 17:46:45 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -439,6 +439,7 @@ int zebra_maps_attr(ZebraMaps zms, Z_AttributesPlusTerm *zapt,
     if (relation_value == 103)
     {
         *search_type = "always";
+       *reg_id = 'w';
         return 0;
     }
     if (*complete_flag)