[Commits] Rev 3008: Safety fix for Aria: in lp:maria/5.1

Michael Widenius monty at askmonty.org
Tue Jan 11 12:18:05 EET 2011


At lp:maria/5.1

------------------------------------------------------------
revno: 3008
revision-id: monty at askmonty.org-20110111101803-27t2nwaw26nqki5j
parent: monty at askmonty.org-20110110212240-1lg7dgzku0r4ly1m
committer: Michael Widenius <monty at askmonty.org>
branch nick: maria-5.1
timestamp: Tue 2011-01-11 12:18:03 +0200
message:
  Safety fix for Aria:
  - Set lastinx= ~0 when last_key.keyinfo is set.
-------------- next part --------------
=== modified file 'storage/maria/ma_check.c'
--- a/storage/maria/ma_check.c	2011-01-07 15:58:12 +0000
+++ b/storage/maria/ma_check.c	2011-01-11 10:18:03 +0000
@@ -881,6 +881,7 @@ static int chk_index(HA_CHECK *param, MA
   }
 
   info->last_key.keyinfo= tmp_key.keyinfo= keyinfo;
+  info->lastinx= ~0;                            /* Safety */
   tmp_key.data= tmp_key_buff;
   for ( ;; )
   {
@@ -1134,6 +1135,7 @@ static int check_keys_in_record(HA_CHECK
       {
         (*keyinfo->make_key)(info, &key, keynr, info->lastkey_buff, record,
                              start_recpos, 0);
+        info->last_key.keyinfo= key.keyinfo;
         if (extend)
         {
           /* We don't need to lock the key tree here as we don't allow

=== modified file 'storage/maria/ma_ft_boolean_search.c'
--- a/storage/maria/ma_ft_boolean_search.c	2011-01-10 21:22:40 +0000
+++ b/storage/maria/ma_ft_boolean_search.c	2011-01-11 10:18:03 +0000
@@ -357,6 +357,7 @@ static int _ft2_search(FTB *ftb, FTB_WOR
     ftbw->key_root=info->s->state.key_root[ftb->keynr];
     ftbw->keyinfo=info->s->keyinfo+ftb->keynr;
     info->last_key.keyinfo= key.keyinfo= ftbw->keyinfo;
+    info->lastinx= ~0;                            /* Safety */
     key.data= ftbw->word;
     key.data_length= ftbw->len;
     key.ref_length= 0;
@@ -381,6 +382,7 @@ static int _ft2_search(FTB *ftb, FTB_WOR
     }
 
     info->last_key.keyinfo= key.keyinfo= ftbw->keyinfo;
+    info->lastinx= ~0;                            /* Safety */
     key.data= lastkey_buf;
     key.data_length= USE_WHOLE_KEY;
     key.ref_length= 0;

=== modified file 'storage/maria/ma_rt_index.c'
--- a/storage/maria/ma_rt_index.c	2010-08-09 17:05:42 +0000
+++ b/storage/maria/ma_rt_index.c	2011-01-11 10:18:03 +0000
@@ -134,7 +134,6 @@ static int maria_rtree_find_req(MARIA_HA
         tmp_key.data_length= key_data_length;
 
         info->cur_row.lastpos= _ma_row_pos_from_key(&tmp_key);
-        info->last_key.keyinfo= keyinfo;
         info->last_key.data_length= key_data_length;
         info->last_key.ref_length=  share->base.rec_reflength;
         info->last_key.flag= 0;

=== modified file 'storage/maria/ma_search.c'
--- a/storage/maria/ma_search.c	2011-01-10 21:22:40 +0000
+++ b/storage/maria/ma_search.c	2011-01-11 10:18:03 +0000
@@ -97,6 +97,7 @@ int _ma_search(register MARIA_HA *info,
 
    @note
      Position to row is stored in info->lastpos
+     Last used key is stored in info->last_key
 
    @return
    @retval  0   ok (key found)
@@ -122,6 +123,7 @@ static int _ma_search_no_save(register M
                       (ulong) (pos / info->s->block_size),
                       nextflag, (ulong) info->cur_row.lastpos));
   DBUG_EXECUTE("key", _ma_print_key(DBUG_FILE, key););
+  DBUG_ASSERT(info->last_key.keyinfo == key->keyinfo);
 
   if (pos == HA_OFFSET_ERROR)
   {

=== modified file 'storage/maria/ma_unique.c'
--- a/storage/maria/ma_unique.c	2011-01-10 21:22:40 +0000
+++ b/storage/maria/ma_unique.c	2011-01-11 10:18:03 +0000
@@ -34,6 +34,7 @@ my_bool _ma_check_unique(MARIA_HA *info,
   MARIA_KEYDEF *keyinfo= &info->s->keyinfo[def->key];
   uchar *key_buff= info->lastkey_buff2;
   MARIA_KEY key;
+  int error= 0;
   DBUG_ENTER("_ma_check_unique");
   DBUG_PRINT("enter",("unique_hash: %lu", (ulong) unique_hash));
 
@@ -43,14 +44,19 @@ my_bool _ma_check_unique(MARIA_HA *info,
 
   /* The above changed info->lastkey_buff2. Inform maria_rnext_same(). */
   info->update&= ~HA_STATE_RNEXT_SAME;
+
+  /* Setup that unique key is active key */
   info->last_key.keyinfo= keyinfo;
 
+  /* any key pointer in data is destroyed */
+  info->lastinx= ~0;
+
   DBUG_ASSERT(key.data_length == MARIA_UNIQUE_HASH_LENGTH);
   if (_ma_search(info, &key, SEARCH_FIND, info->s->state.key_root[def->key]))
   {
     info->page_changed=1;                       /* Can't optimize read next */
     info->cur_row.lastpos= lastpos;
-    DBUG_RETURN(0);                             /* No matching rows */
+    goto end;
   }
 
   for (;;)
@@ -64,7 +70,8 @@ my_bool _ma_check_unique(MARIA_HA *info,
       info->page_changed= 1;                    /* Can't optimize read next */
       info->cur_row.lastpos= lastpos;
       DBUG_PRINT("info",("Found duplicate"));
-      DBUG_RETURN(1);                           /* Found identical  */
+      error= 1;                                 /* Found identical  */
+      goto end;
     }
     DBUG_ASSERT(info->last_key.data_length == MARIA_UNIQUE_HASH_LENGTH);
     if (_ma_search_next(info, &info->last_key, SEARCH_BIGGER,
@@ -73,9 +80,12 @@ my_bool _ma_check_unique(MARIA_HA *info,
     {
       info->page_changed= 1;                    /* Can't optimize read next */
       info->cur_row.lastpos= lastpos;
-      DBUG_RETURN(0);                           /* end of tree */
+      break;                                    /* end of tree */
     }
   }
+
+end:
+  DBUG_RETURN(error);
 }
 
 



More information about the commits mailing list