[Commits] Rev 2850: Re-initialization reworked in file:///home/psergey/dev2/maria-5.3-dsmrr-cpk-r5/

Sergey Petrunya psergey at askmonty.org
Mon Nov 1 12:52:15 EET 2010


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

------------------------------------------------------------
revno: 2850
revision-id: psergey at askmonty.org-20101101105210-5w25nuipve6u7naq
parent: psergey at askmonty.org-20101031210434-zxnlp3d0lf14koyb
committer: Sergey Petrunya <psergey at askmonty.org>
branch nick: maria-5.3-dsmrr-cpk-r5
timestamp: Mon 2010-11-01 13:52:10 +0300
message:
  Re-initialization reworked
=== modified file 'sql/multi_range_read.cc'
--- a/sql/multi_range_read.cc	2010-10-31 21:04:34 +0000
+++ b/sql/multi_range_read.cc	2010-11-01 10:52:10 +0000
@@ -332,6 +332,9 @@
 int Mrr_ordered_index_reader::get_next(char **range_info_arg)
 {
   DBUG_ENTER("Mrr_ordered_index_reader::get_next");
+  
+  if (!know_key_tuple_params) /* We're in startup phase */
+    DBUG_RETURN(HA_ERR_END_OF_FILE);
 
   while (1)
   {
@@ -352,7 +355,7 @@
       {
         if (key_buffer->is_empty())
         {
-          if (auto_refill)
+          /*if (auto_refill)
           {
             int res;
             if ((res= refill_buffer()))
@@ -364,6 +367,7 @@
             }
           }
           else
+          */
           {
             /* Buffer refills are managed by somebody else for us */
             index_scan_eof= TRUE;
@@ -521,10 +525,11 @@
   //rowid_buff_elem_size= h->ref_length;
   //if (!(mode & HA_MRR_NO_ASSOCIATION))
   //  rowid_buff_elem_size += sizeof(char*);
-  
-  int res= index_reader->refill_buffer();
-  if (res && res!=HA_ERR_END_OF_FILE)
-    return res;
+
+  index_reader_exhausted= FALSE;
+  ///int res= index_reader->refill_buffer();
+  ///if (res && res!=HA_ERR_END_OF_FILE)
+  ///  return res;
   return 0;
 }
 
@@ -547,13 +552,36 @@
   @retval other  Error
 */
 
+
 int Mrr_ordered_rndpos_reader::refill_buffer()
 {
+  int res;
+  DBUG_ENTER("Mrr_ordered_rndpos_reader::refill_buffer");
+
+  if (index_reader_exhausted)
+    DBUG_RETURN(HA_ERR_END_OF_FILE);
+
+  while ((res= refill2() == HA_ERR_END_OF_FILE))
+  {
+    if ((res= index_reader->refill_buffer()))
+    {
+      if (res == HA_ERR_END_OF_FILE)
+        index_reader_exhausted= TRUE;
+      break;
+    }
+  }
+  DBUG_RETURN(res);
+}
+
+
+/* This one refills without calling index_reader->refill_buffer(). */
+int Mrr_ordered_rndpos_reader::refill2()
+{
   char *range_info;
   uchar **range_info_ptr= (uchar**)&range_info;
   int res;
-  DBUG_ENTER("Mrr_ordered_rndpos_reader::refill_buffer");
-  
+  DBUG_ENTER("Mrr_ordered_rndpos_reader::refill2");
+
   DBUG_ASSERT(rowid_buffer->is_empty());
   index_rowid= index_reader->get_rowid_ptr();
   rowid_buffer->reset();
@@ -563,9 +591,6 @@
 
   last_identical_rowid= NULL;
 
-  if (index_reader->eof())
-    DBUG_RETURN(HA_ERR_END_OF_FILE);
-
   while (rowid_buffer->can_write())
   {
     res= index_reader->get_next(&range_info);
@@ -578,10 +603,6 @@
 
     rowid_buffer->write();
   }
-
-  if (res && res != HA_ERR_END_OF_FILE)
-    DBUG_RETURN(res); 
-
    
   /* Sort the buffer contents by rowid */
   rowid_buffer->sort((qsort2_cmp)rowid_cmp_reverse, (void*)h);
@@ -589,7 +610,7 @@
   rowid_buffer->setup_reading(&rowid, h->ref_length,
                               is_mrr_assoc? (uchar**)&rowids_range_id: NULL,
                               sizeof(void*));
-  DBUG_RETURN((rowid_buffer->is_empty() && res) ? HA_ERR_END_OF_FILE : 0);
+  DBUG_RETURN(rowid_buffer->is_empty()? HA_ERR_END_OF_FILE : 0);
 }
 
 
@@ -630,6 +651,7 @@
 
   while (1)
   {
+#if 0      
     if (rowid_buffer->is_empty()) /* We're out of rowids */
     {
       /* First, finish off the sorted keys we have */ 
@@ -647,12 +669,12 @@
           reader, then refill us.
         */
         // TODO: if key buffer is empty, too, redistribute the buffer space.
-  
         if ((res= index_reader->refill_buffer()) ||
             (res= refill_buffer()))
           return res;
       }
     }
+#endif
    
     last_identical_rowid= NULL;
 
@@ -795,8 +817,8 @@
   
   if (strategy == index_strategy)
   {
-    if (ordered_idx_reader)
-      ordered_idx_reader->auto_refill= TRUE;
+    ///if (ordered_idx_reader)
+    //  ordered_idx_reader->auto_refill= TRUE;
     /* Index strategy serves it all. We don't need two handlers, etc */
     /* Give the buffer to index strategy */
     if ((res= index_strategy->init(h, seq_funcs, seq_init_param, n_ranges,
@@ -815,8 +837,8 @@
     if ((res= setup_two_handlers()))
       DBUG_RETURN(res);
 
-    if (ordered_idx_reader)
-      ordered_idx_reader->auto_refill= FALSE;
+    ///if (ordered_idx_reader)
+    ///  ordered_idx_reader->auto_refill= FALSE;
 
     if ((res= index_strategy->init(h2, seq_funcs, seq_init_param, n_ranges, 
                                    mode, this)) || 
@@ -827,7 +849,7 @@
   }
   
   res= strategy->refill_buffer();
-  if (res && res != HA_ERR_END_OF_FILE)
+  if (res && res != HA_ERR_END_OF_FILE) //psergey-todo: remove EOF check here
     goto error;
 
   /*
@@ -1215,7 +1237,14 @@
 
 int DsMrr_impl::dsmrr_next(char **range_info)
 {
-  return strategy->get_next(range_info);
+  int res;
+  while ((res= strategy->get_next(range_info)) == HA_ERR_END_OF_FILE)
+  {
+    if ((res= strategy->refill_buffer()))
+      break; /* EOF or error */
+  }
+  return res;
+  //return strategy->get_next(range_info);
 }
 
 

=== modified file 'sql/multi_range_read.h'
--- a/sql/multi_range_read.h	2010-10-31 19:00:15 +0000
+++ b/sql/multi_range_read.h	2010-11-01 10:52:10 +0000
@@ -233,7 +233,7 @@
   RANGE_SEQ_IF mrr_funcs;
   range_seq_t mrr_iter;
 
-  bool auto_refill;
+  //bool auto_refill;
 
   bool index_scan_eof;
 
@@ -256,6 +256,7 @@
            Lifo_buffer *buf);
   int get_next(char **range_info);
   int refill_buffer();
+  int refill2();
   void cleanup();
 private:
   handler *h;
@@ -264,6 +265,7 @@
   /* This what we get (rowid, range_info) pairs from */
   Mrr_index_reader *index_reader;
   uchar *index_rowid;
+  bool index_reader_exhausted;
   
   /* TRUE <=> need range association, buffers hold {rowid, range_id} pairs */
   bool is_mrr_assoc;



More information about the commits mailing list