[Commits] Rev 2859: Merge MWL#121-125 DS-MRR improvements in file:///home/psergey/dev2/maria-5.3-mwl128-dsmrr-cpk-r2/

Sergey Petrunya psergey at askmonty.org
Mon Nov 22 16:08:26 EET 2010


At file:///home/psergey/dev2/maria-5.3-mwl128-dsmrr-cpk-r2/

------------------------------------------------------------
revno: 2859
revision-id: psergey at askmonty.org-20101122140822-p4b0f5nffs4wo9c4
parent: psergey at askmonty.org-20101115015945-pebxy8a1sqw18rki
committer: Sergey Petrunya <psergey at askmonty.org>
branch nick: maria-5.3-mwl128-dsmrr-cpk-r2
timestamp: Mon 2010-11-22 17:08:22 +0300
message:
  Merge MWL#121-125 DS-MRR improvements 
  - Address Monty's review feedback, part 1
=== modified file 'mysql-test/t/subselect_sj2.test'
--- a/mysql-test/t/subselect_sj2.test	2010-10-03 20:37:30 +0000
+++ b/mysql-test/t/subselect_sj2.test	2010-11-22 14:08:22 +0000
@@ -586,7 +586,6 @@
   --echo # Not anymore:
   --echo # The following query gives wrong result due to Bug#49129
 }
-
 select * from t0 where t0.a in 
   (select t1.a from t1, t2 where t2.a=t0.a and t1.b=t2.b);
 

=== modified file 'sql/multi_range_read.cc'
--- a/sql/multi_range_read.cc	2010-11-09 16:02:08 +0000
+++ b/sql/multi_range_read.cc	2010-11-22 14:08:22 +0000
@@ -341,14 +341,14 @@
     DBUG_RETURN(HA_ERR_END_OF_FILE);
   }
 
-  while (1)
+  for(;;)
   {
     bool have_record= FALSE;
     if (scanning_key_val_iter)
     {
       if ((res= kv_it.get_next()))
       {
-        kv_it.close();
+        kv_it.close_();
         scanning_key_val_iter= FALSE;
         if ((res != HA_ERR_KEY_NOT_FOUND && res != HA_ERR_END_OF_FILE))
           DBUG_RETURN(res);
@@ -439,24 +439,22 @@
     }
     
     /* Put key, or {key, range_id} pair into the buffer */
-    if (keypar.use_key_pointers)
-      key_ptr=(uchar*) &cur_range.start_key.key;
-    else
-      key_ptr=(uchar*) cur_range.start_key.key;
+    key_ptr= (keypar.use_key_pointers)? (uchar*)&cur_range.start_key.key : 
+                                        (uchar*)cur_range.start_key.key;
 
     key_buffer->write();
   }
-
-  bool no_more_keys= test(res);
+  
+  /* Force get_next() to start with kv_it.init() call: */
   scanning_key_val_iter= FALSE;
 
-  if (no_more_keys && (!know_key_tuple_params || key_buffer->is_empty()))
+  if (test(res) && (!know_key_tuple_params || key_buffer->is_empty()))
     DBUG_RETURN(HA_ERR_END_OF_FILE);
 
   key_buffer->sort((key_buffer->type() == Lifo_buffer::FORWARD)? 
                      (qsort2_cmp)Mrr_ordered_index_reader::key_tuple_cmp_reverse : 
                      (qsort2_cmp)Mrr_ordered_index_reader::key_tuple_cmp, 
-                   (void*)this);
+                   this);
   DBUG_RETURN(0);
 }
 
@@ -558,7 +556,7 @@
   if (index_reader_exhausted)
     DBUG_RETURN(HA_ERR_END_OF_FILE);
 
-  while ((res= refill_from_key_buffer() == HA_ERR_END_OF_FILE))
+  while ((res= refill_from_key_buffer()) == HA_ERR_END_OF_FILE)
   {
     if ((res= index_reader->refill_buffer()))
     {
@@ -603,11 +601,16 @@
     res= index_reader->get_next(&range_info);
 
     if (res)
+    {
+      if (res != HA_ERR_END_OF_FILE)
+        DBUG_RETURN(res);
+      index_reader_exhausted= TRUE;     
       break;
+    }
+
+    index_reader->position();
 
     /* Put rowid, or {rowid, range_id} pair into the buffer */
-    index_reader->position();
-
     rowid_buffer->write();
   }
    
@@ -658,7 +661,7 @@
     }
   }
 
-  while (1)
+  for(;;)
   {
     last_identical_rowid= NULL;
 
@@ -1052,8 +1055,8 @@
     Ok if we got here we need to allocate one part of the buffer 
     for keys and another part for rowids.
   */
-  uint rowid_buf_elem_size= h->ref_length + 
-                            (int)is_mrr_assoc * sizeof(char*);
+  ulonglong rowid_buf_elem_size= h->ref_length + 
+                                 (int)is_mrr_assoc * sizeof(char*);
   
   /*
     Use rec_per_key statistics as a basis to find out how many rowids 
@@ -1070,8 +1073,8 @@
   }
 
   double fraction_for_rowids=
-    ((double) rowid_buf_elem_size / 
-         ((double)rowid_buf_elem_size + key_buff_elem_size));
+    (ulonglong2double(rowid_buf_elem_size) / 
+     (ulonglong2double(rowid_buf_elem_size) + key_buff_elem_size));
 
   size_t bytes_for_rowids= 
     round(fraction_for_rowids * (full_buf_end - full_buf));
@@ -1080,7 +1083,7 @@
 
   if (bytes_for_keys < key_buff_elem_size + 1)
   {
-    uint add= key_buff_elem_size + 1 - bytes_for_keys;
+    ulong add= key_buff_elem_size + 1 - bytes_for_keys;
     bytes_for_keys= key_buff_elem_size + 1;
     bytes_for_rowids -= add;
     DBUG_ASSERT(bytes_for_rowids >=  rowid_buf_elem_size + 1);
@@ -1088,7 +1091,7 @@
 
   if (bytes_for_rowids < rowid_buf_elem_size + 1)
   {
-    uint add= rowid_buf_elem_size + 1 - bytes_for_rowids;
+    ulong add= rowid_buf_elem_size + 1 - bytes_for_rowids;
     bytes_for_rowids= rowid_buf_elem_size + 1;
     bytes_for_keys -= add;
     DBUG_ASSERT(bytes_for_keys >=  key_buff_elem_size + 1);
@@ -1185,7 +1188,7 @@
 
   if (res)
   {
-    close();
+    close_();
     return res;
   }
   get_next_row= FALSE;
@@ -1223,7 +1226,7 @@
 }
 
 
-void Key_value_records_iterator::close()
+void Key_value_records_iterator::close_()
 {
   while (!owner->key_buffer->read() && 
          (cur_index_tuple != last_identical_key_ptr)) {}

=== modified file 'sql/multi_range_read.h'
--- a/sql/multi_range_read.h	2010-11-08 17:37:01 +0000
+++ b/sql/multi_range_read.h	2010-11-22 14:08:22 +0000
@@ -137,7 +137,7 @@
 public:
   int init(Mrr_ordered_index_reader *owner_arg);
   int get_next();
-  void close();
+  void close_();
 };
 
 

=== modified file 'sql/opt_range.cc'
--- a/sql/opt_range.cc	2010-11-01 15:49:59 +0000
+++ b/sql/opt_range.cc	2010-11-22 14:08:22 +0000
@@ -8006,7 +8006,7 @@
 
   quick->mrr_buf_size= thd->variables.mrr_buff_size;
   if (table->file->multi_range_read_info(quick->index, 1, (uint)records,
-                                         uint(-1), 
+                                         ~0, 
                                          &quick->mrr_buf_size,
                                          &quick->mrr_flags, &cost))
     goto err;

=== modified file 'sql/sql_lifo_buffer.h'
--- a/sql/sql_lifo_buffer.h	2010-11-09 16:02:08 +0000
+++ b/sql/sql_lifo_buffer.h	2010-11-22 14:08:22 +0000
@@ -150,7 +150,7 @@
   enum_direction type() { return FORWARD; }
   size_t used_size()
   {
-    return pos - start;
+    return (size_t)(pos - start);
   }
   void reset()
   {
@@ -243,7 +243,7 @@
  
   size_t used_size()
   {
-    return end - pos;
+    return (size_t)(end - pos);
   }
   void reset()
   {



More information about the commits mailing list