Report 'too many characters in search..'
authorAdam Dickmeiss <adam@indexdata.dk>
Tue, 1 Nov 2011 13:03:14 +0000 (14:03 +0100)
committerAdam Dickmeiss <adam@indexdata.dk>
Tue, 1 Nov 2011 13:04:54 +0000 (14:04 +0100)
Make proper diagnostic for too many characters in search
term. And make a test case for it.

index/zaptterm.c
test/api/test_search.c

index 7c83e2f..425dfa3 100644 (file)
@@ -50,9 +50,13 @@ ZEBRA_RES zapt_term_to_utf8(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
                         &outbuf, &outleft);
             if (ret == (size_t)(-1))
             {
+                int iconv_error = yaz_iconv_error(zh->iconv_to_utf8);
+
                 ret = yaz_iconv(zh->iconv_to_utf8, 0, 0, 0, 0);
                zebra_setError(
-                   zh, 
+                   zh,
+                    iconv_error == YAZ_ICONV_E2BIG ?
+                    YAZ_BIB1_TOO_MANY_CHARS_IN_SEARCH_STATEMENT :
                    YAZ_BIB1_QUERY_TERM_INCLUDES_CHARS_THAT_DO_NOT_TRANSLATE_INTO_,
                    0);
                 return ZEBRA_FAIL;
index 423f76c..51b405e 100644 (file)
@@ -59,6 +59,17 @@ const char *myrec[] = {
         " <date>2107-09-19 00:00:00</date>\n"
         "</test_search>\n"
         ,
+        "<gils>\n"
+        "<title>"
+        "1234567890" "1234567890""1234567890""1234567890""1234567890"
+        "1234567890" "1234567890""1234567890""1234567890""1234567890"
+        "1234567890" "1234567890""1234567890""1234567890""1234567890"
+        "1234567890" "1234567890""1234567890""1234567890""1234567890"
+        "1234567890" "1234567890""1234567890""1234567890""1234567890"
+        "12345"
+        "</title>"
+        "</gils>"
+        ,
        0} ;
        
 static void tst(int argc, char **argv)
@@ -157,14 +168,36 @@ static void tst(int argc, char **argv)
 
     /* string relations, < */
     YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=1 0", 0));
-    YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=1 my", 0));
+    YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=1 my", 1));
 
     /* string relations, <= */
-    YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=2 my", 3));
-    YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=2 mn", 0));
+    YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=2 my", 4));
+    YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=2 mn", 1));
 
     /* = */
     YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=3 my", 3));
+    YAZ_CHECK(
+        tl_query(zh, 
+                 "@attr 1=4 @attr 2=3 "
+                 "1234567890" "1234567890""1234567890""1234567890""1234567890"
+                 "1234567890" "1234567890""1234567890""1234567890""1234567890"
+                 "1234567890" "1234567890""1234567890""1234567890""1234567890"
+                 "1234567890" "1234567890""1234567890""1234567890""1234567890"
+                 "1234567890" "1234567890""1234567890""1234567890""1234567890"
+                 "12345"
+                 , 1));
+    
+    YAZ_CHECK(
+        tl_query_x(zh, 
+                   "@attr 1=4 @attr 2=3 "
+                   "1234567890" "1234567890""1234567890""1234567890""1234567890"
+                   "1234567890" "1234567890""1234567890""1234567890""1234567890"
+                   "1234567890" "1234567890""1234567890""1234567890""1234567890"
+                   "1234567890" "1234567890""1234567890""1234567890""1234567890"
+                   "1234567890" "1234567890""1234567890""1234567890""1234567890"
+                   "123456"
+                   , 0, 11));
+    
 
     /* string relations, >= */
     YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=4 x", 2));
@@ -177,8 +210,8 @@ static void tst(int argc, char **argv)
     YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=5 title", 2));
 
     /* always-matches relation */
-    YAZ_CHECK(tl_query(zh, "@attr 1=_ALLRECORDS @attr 2=103 {ym}", 5));
-    YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=103 {x my}", 4));
+    YAZ_CHECK(tl_query(zh, "@attr 1=_ALLRECORDS @attr 2=103 {ym}", 6));
+    YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=103 {x my}", 5));
     YAZ_CHECK(tl_query_x(zh, "@attr 1=1 @attr 2=103 {x my}", 0, 114));
 
     /* and searches */