List:Commits« Previous MessageNext Message »
From:Sergey Vojtovich Date:May 28 2007 8:27am
Subject:bk commit into 5.1 tree (svoj:1.2515) BUG#18839
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of svoj. When svoj does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-05-28 13:27:26+05:00, svoj@stripped +2 -0
  BUG#18839 - return value of parser->parse() is ignored
  
  Check value returned by parser->parse(). Better handle situations
  when it fails.

  storage/myisam/ft_boolean_search.c@stripped, 2007-05-28 13:27:24+05:00, svoj@stripped +31 -20
    Check value returned by parser->parse().

  storage/myisam/ft_nlq_search.c@stripped, 2007-05-28 13:27:24+05:00, svoj@stripped +6 -2
    Check value returned by parser->parse().

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	svoj
# Host:	june.mysql.com
# Root:	/home/svoj/devel/mysql/BUG18839/mysql-5.1-engines

--- 1.107/storage/myisam/ft_boolean_search.c	2007-01-24 21:57:01 +04:00
+++ 1.108/storage/myisam/ft_boolean_search.c	2007-05-28 13:27:24 +05:00
@@ -286,8 +286,8 @@ static int ftb_parse_query_internal(MYSQ
 }
 
 
-static void _ftb_parse_query(FTB *ftb, byte *query, uint len,
-                             struct st_mysql_ftparser *parser)
+static int _ftb_parse_query(FTB *ftb, byte *query, uint len,
+                            struct st_mysql_ftparser *parser)
 {
   MYSQL_FTPARSER_PARAM *param;
   MY_FTB_PARAM ftb_param;
@@ -295,9 +295,9 @@ static void _ftb_parse_query(FTB *ftb, b
   DBUG_ASSERT(parser);
 
   if (ftb->state != UNINITIALIZED)
-    DBUG_VOID_RETURN;
+    DBUG_RETURN(0);
   if (! (param= ftparser_call_initializer(ftb->info, ftb->keynr, 0)))
-    DBUG_VOID_RETURN;
+    DBUG_RETURN(1);
 
   ftb_param.ftb= ftb;
   ftb_param.depth= 0;
@@ -312,8 +312,7 @@ static void _ftb_parse_query(FTB *ftb, b
   param->length= len;
   param->flags= 0;
   param->mode= MYSQL_FTPARSER_FULL_BOOLEAN_INFO;
-  parser->parse(param);
-  DBUG_VOID_RETURN;
+  DBUG_RETURN(parser->parse(param));
 }
 
 
@@ -538,9 +537,10 @@ FT_INFO * ft_init_boolean_search(MI_INFO
   ftbe->phrase= NULL;
   ftbe->document= 0;
   ftb->root=ftbe;
-  _ftb_parse_query(ftb, query, query_len, keynr == NO_SUCH_KEY ?
-                                          &ft_default_parser :
-                                          info->s->keyinfo[keynr].parser);
+  if (unlikely(_ftb_parse_query(ftb, query, query_len,
+                                keynr == NO_SUCH_KEY ? &ft_default_parser :
+                                info->s->keyinfo[keynr].parser)))
+    goto err;
   /*
     Hack: instead of init_queue, we'll use reinit queue to be able
     to alloc queue with alloc_root()
@@ -621,7 +621,7 @@ static int ftb_check_phrase_internal(MYS
   {
     param->mysql_add_word(param, word.pos, word.len, 0);
     if (phrase_param->match)
-      return 1;
+      break;
   }
   return 0;
 }
@@ -639,6 +639,7 @@ static int ftb_check_phrase_internal(MYS
 
   RETURN VALUE
     1 is returned if phrase found, 0 else.
+    -1 is returned if error occurs.
 */
 
 static int _ftb_check_phrase(FTB *ftb, const byte *document, uint len,
@@ -667,12 +668,13 @@ static int _ftb_check_phrase(FTB *ftb, c
   param->length= len;
   param->flags= 0;
   param->mode= MYSQL_FTPARSER_WITH_STOPWORDS;
-  parser->parse(param);
+  if (unlikely(parser->parse(param)))
+    return -1;
   DBUG_RETURN(ftb_param.match ? 1 : 0);
 }
 
 
-static void _ftb_climb_the_tree(FTB *ftb, FTB_WORD *ftbw, FT_SEG_ITERATOR *ftsi_orig)
+static int _ftb_climb_the_tree(FTB *ftb, FTB_WORD *ftbw, FT_SEG_ITERATOR *ftsi_orig)
 {
   FT_SEG_ITERATOR ftsi;
   FTB_EXPR *ftbe;
@@ -704,17 +706,19 @@ static void _ftb_climb_the_tree(FTB *ftb
         weight=ftbe->cur_weight*ftbe->weight;
         if (mode && ftbe->phrase)
         {
-          int not_found=1;
+          int found= 0;
 
           memcpy(&ftsi, ftsi_orig, sizeof(ftsi));
-          while (_mi_ft_segiterator(&ftsi) && not_found)
+          while (_mi_ft_segiterator(&ftsi) && !found)
           {
             if (!ftsi.pos)
               continue;
-            not_found = ! _ftb_check_phrase(ftb, ftsi.pos, ftsi.len,
-                                            ftbe, parser);
+            found= _ftb_check_phrase(ftb, ftsi.pos, ftsi.len, ftbe, parser);
+            if (unlikely(found < 0))
+              return 1;
           }
-          if (not_found) break;
+          if (!found)
+            break;
         } /* ftbe->quot */
       }
       else
@@ -746,6 +750,7 @@ static void _ftb_climb_the_tree(FTB *ftb
       weight*= ftbe->weight;
     }
   }
+  return 0;
 }
 
 
@@ -778,7 +783,11 @@ int ft_boolean_read_next(FT_INFO *ftb, c
   {
     while (curdoc == (ftbw=(FTB_WORD *)queue_top(& ftb->queue))->docid[0])
     {
-      _ftb_climb_the_tree(ftb, ftbw, 0);
+      if (unlikely(_ftb_climb_the_tree(ftb, ftbw, 0)))
+      {
+        my_errno= HA_ERR_OUT_OF_MEM;
+        goto err;
+      }
 
       /* update queue */
       _ft2_search(ftb, ftbw, 0);
@@ -854,7 +863,8 @@ static int ftb_find_relevance_add_word(M
     if (ftbw->docid[1] == ftb->info->lastpos)
       continue;
     ftbw->docid[1]= ftb->info->lastpos;
-     _ftb_climb_the_tree(ftb, ftbw, ftb_param->ftsi);
+    if (unlikely(_ftb_climb_the_tree(ftb, ftbw, ftb_param->ftsi)))
+      return 1;
   }
   return(0);
 }
@@ -926,7 +936,8 @@ float ft_boolean_find_relevance(FT_INFO 
       continue;
     param->doc= (byte *)ftsi.pos;
     param->length= ftsi.len;
-    parser->parse(param);
+    if (unlikely(parser->parse(param)))
+      return 0;
   }
   ftbe=ftb->root;
   if (ftbe->docid[1]==docid && ftbe->cur_weight>0 &&

--- 1.46/storage/myisam/ft_nlq_search.c	2006-12-31 04:06:39 +04:00
+++ 1.47/storage/myisam/ft_nlq_search.c	2007-05-28 13:27:24 +05:00
@@ -257,8 +257,12 @@ FT_INFO *ft_init_nlq_search(MI_INFO *inf
       {
         info->update|= HA_STATE_AKTIV;
         ftparser_param->flags= MYSQL_FTFLAGS_NEED_COPY;
-        _mi_ft_parse(&wtree, info, keynr, record, ftparser_param,
-                     &wtree.mem_root);
+        if (unlikely(_mi_ft_parse(&wtree, info, keynr, record, ftparser_param,
+                                  &wtree.mem_root)))
+        {
+          delete_queue(&best);
+          goto err;
+        }
       }
     }
     delete_queue(&best);
Thread
bk commit into 5.1 tree (svoj:1.2515) BUG#18839Sergey Vojtovich28 May