List:Commits« Previous MessageNext Message »
From:Patrick Galbraith Date:January 20 2006 6:28pm
Subject:bk commit into 5.1 tree (patg:1.2083)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of patg. When patg 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
  1.2083 06/01/20 10:28:14 patg@stripped +4 -0
  WL# 2986
  
  Post review fixes

  sql/opt_range.cc
    1.194 06/01/20 10:28:10 patg@stripped +15 -1
    WL# 2986
    
    added bitmap_clear_all to prune_partitions prior to setting bitmap.

  sql/ha_partition.h
    1.12 06/01/20 10:28:10 patg@stripped +0 -1
    WL# 2986
    
    Post review changes, removed m_current_partition_index in leiu of using
    m_part_spec.start_part

  sql/ha_partition.cc
    1.26 06/01/20 10:28:10 patg@stripped +122 -124
    WL# 2986
    
    Post review changes
    
    removed m_current_partition_index instead using m_part_spec.start_part
    also changed bitmap_clear_all to bitmap_set_all in reset, fixes UPDATE/DELETE

  mysql-test/r/partition_pruning.result
    1.4 06/01/20 10:28:10 patg@stripped +31 -31
    WL# 2986
    
    New results due to changes in output of explain

# 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:	patg
# Host:	govinda.patg.net
# Root:	/home/patg/mysql-build/mysql-5.1-wl2986

--- 1.193/sql/opt_range.cc	2006-01-17 00:24:50 -08:00
+++ 1.194/sql/opt_range.cc	2006-01-20 10:28:10 -08:00
@@ -2317,7 +2317,9 @@
 
   thd->no_errors=1;				// Don't warn about NULL
   thd->mem_root=&alloc;
-  
+
+  bitmap_clear_all(&part_info->used_partitions);
+
   prune_param.key= prune_param.range_param.key_parts;
   SEL_TREE *tree;
   SEL_ARG *arg;
@@ -2435,7 +2437,10 @@
 static void mark_full_partition_used_no_parts(partition_info* part_info,
                                               uint32 part_id)
 {
+  DBUG_ENTER("mark_full_partition_used_no_parts");
+  DBUG_PRINT("enter", ("Mark partition %u as used", part_id));
   bitmap_set_bit(&part_info->used_partitions, part_id);
+  DBUG_VOID_RETURN;
 }
 
 
@@ -2445,8 +2450,14 @@
 {
   uint32 start= part_id * part_info->no_subparts;
   uint32 end=   start + part_info->no_subparts; 
+  DBUG_ENTER("mark_full_partition_used_with_parts");
+
   for (; start != end; start++)
+  {
+    DBUG_PRINT("info", ("1:Mark subpartition %u as used", start));
     bitmap_set_bit(&part_info->used_partitions, start);
+  }
+  DBUG_VOID_RETURN;
 }
 
 /* See comment in PART_PRUNE_PARAM::part_num_to_part_id about what this is */
@@ -2738,6 +2749,9 @@
         for (uint32 num= ppar->start_part_num; num != ppar->end_part_num; 
              num++)
         {
+          uint part_id= (ppar->part_num_to_part_id(ppar, num) *
+                         part_info->no_subparts) + subpart_id;
+          DBUG_PRINT("info", ("2:Mark subpartition %u as used", part_id));
           bitmap_set_bit(&part_info->used_partitions,
                          ppar->part_num_to_part_id(ppar, num) * 
                          part_info->no_subparts + subpart_id);

--- 1.25/sql/ha_partition.cc	2006-01-19 13:07:59 -08:00
+++ 1.26/sql/ha_partition.cc	2006-01-20 10:28:10 -08:00
@@ -239,7 +239,6 @@
   m_top_entry= NO_CURRENT_PART_ID;
   m_rec_length= 0;
   m_last_part= 0;
-  m_current_partition_index= MY_BIT_NONE;
   m_rec0= 0;
   m_curr_key_info= 0;
   /*
@@ -2054,7 +2053,6 @@
     Don't know the size of the underlying storage engine, invent a number of
     bytes allocated for error message if allocation fails
   */
-  alloc_len= 128;
   do
   {
     part_elem= part_it++;
@@ -2199,11 +2197,11 @@
 
 int ha_partition::open(const char *name, int mode, uint test_if_locked)
 {
-  char name_buff[FN_REFLEN];
   char *name_buffer_ptr= m_name_buffer_ptr;
   int error;
-  uint alloc_len,i, j, part_num_counter= 0;
+  uint alloc_len;
   handler **file;
+  char name_buff[FN_REFLEN];
   DBUG_ENTER("ha_partition::open");
 
   ref_length= 0;
@@ -2277,8 +2275,6 @@
                          0, key_rec_cmp, (void*)this)))
     goto err_handler;
 
-
-
   /*
     Some handlers update statistics as part of the open call. This will in
     some cases corrupt the statistics of the partition handler and thus
@@ -2316,7 +2312,6 @@
 int ha_partition::close(void)
 {
   bool first= TRUE;
-  int i;
   handler **file;
   DBUG_ENTER("ha_partition::close");
 
@@ -2500,7 +2495,6 @@
 
 int ha_partition::start_stmt(THD *thd, thr_lock_type lock_type)
 {
-  int i= 0;
   int error= 0;
   handler **file;
   DBUG_ENTER("ha_partition::start_stmt");
@@ -2893,15 +2887,26 @@
 {
   int error;
   uint i= 0;
+  uint part_id;
   handler **file;
   DBUG_ENTER("ha_partition::rnd_init");
 
   include_partition_fields_in_used_fields();
   
+  /* Now we see what the index of our first important partition is */
+  DBUG_PRINT("info", ("m_part_info->used_partitions 0x%x",
+             *(uint32*)m_part_info->used_partitions.bitmap));
+  part_id = bitmap_get_first_set(&(m_part_info->used_partitions));
+  DBUG_PRINT("info", ("m_part_spec.start_part %d", part_id));
+
+  if (MY_BIT_NONE == part_id)
+    goto err1;
+
   /*
-    we are going to be scanning through rnd_next so we should eliminate as many
-    of the partitions as possible.
+    We have a partition and we are scanning with rnd_next
+    so we bump our cache
   */
+  DBUG_PRINT("info", ("rnd_init on partition %d", part_id));
   if (scan)
   {
     /*
@@ -2909,47 +2914,36 @@
       is already in use
     */
     rnd_end();
-    partition_scan_set_up(rec_buf(0), FALSE);
+    late_extra_cache(part_id);
+    if ((error= m_file[part_id]->ha_rnd_init(scan)))
+      goto err;
   }
-
-  /* now we see what the index of our first important partition is */
-  DBUG_PRINT("info", ("m_part_info->used_partitions %lx", m_part_info->used_partitions.bitmap));
-  m_current_partition_index = bitmap_get_first_set(&(m_part_info->used_partitions));
-  DBUG_PRINT("info", ("m_current_partition_index %d", m_current_partition_index));
-  if (MY_BIT_NONE == m_current_partition_index)
-  {
-    /*
-      The set of partitions to scan is empty. We return success and return
-      end of file on first rnd_next.
-    */
-    DBUG_RETURN(0);
-  }
-
-  /* we have a partition and we are scanning with rnd_next so we bump our cache */
-  if (scan)
-    late_extra_cache(m_current_partition_index);
-
-  DBUG_PRINT("info", ("rnd_init on partition %d", m_current_partition_index));
-
-  for (i= m_current_partition_index; i < m_tot_parts; i++)
+  else
   {
-    if (_bitmap_is_set(&(m_part_info->used_partitions), i))
-      if ((error= m_file[i]->ha_rnd_init(scan)))
-        goto err;
-    if (scan)
-      break;
+    for (i= part_id; i < m_tot_parts; i++)
+    {
+      if (_bitmap_is_set(&(m_part_info->used_partitions), i))
+      {
+        if ((error= m_file[i]->ha_rnd_init(scan)))
+          goto err;
+      }
+    }
   }
-  m_scan_value= scan ? 1 : 0;
+  m_scan_value= scan;
+  m_part_spec.start_part= part_id;
+  m_part_spec.end_part= m_tot_parts - 1;
   DBUG_PRINT("info", ("m_scan_value=%d", m_scan_value));
   DBUG_RETURN(0);
 
 err:
-  while (i >= m_current_partition_index)
+  while ((int)--i >= (int)part_id)
   {
     if (_bitmap_is_set(&(m_part_info->used_partitions), i))
-	  m_file[i--]->ha_rnd_end();
+	  m_file[i]->ha_rnd_end();
   }
-  m_scan_value= scan ? 2 : 0;
+err1:
+  m_scan_value= 2;
+  m_part_spec.start_part= NO_CURRENT_PART_ID;
   DBUG_RETURN(error);
 }
 
@@ -2973,10 +2967,10 @@
   case 2:                                       // Error
     break;
   case 1:
-    if (MY_BIT_NONE != m_current_partition_index)         // Table scan
+    if (NO_CURRENT_PART_ID != m_part_spec.start_part)         // Table scan
     {
-      late_extra_no_cache(m_current_partition_index);
-      m_file[m_current_partition_index]->ha_rnd_end();
+      late_extra_no_cache(m_part_spec.start_part);
+      m_file[m_part_spec.start_part]->ha_rnd_end();
     }
     break;
   case 0:
@@ -2989,6 +2983,7 @@
     break;
   }
   m_scan_value= 2;
+  m_part_spec.start_part= NO_CURRENT_PART_ID;
   DBUG_RETURN(0);
 }
 
@@ -3017,11 +3012,10 @@
 {
   handler *file;
   int result= HA_ERR_END_OF_FILE;
+  uint part_id= m_part_spec.start_part;
   DBUG_ENTER("ha_partition::rnd_next");
-  DBUG_PRINT("info", ("m_scan_value %d", m_scan_value));
 
-
-  if (MY_BIT_NONE == m_current_partition_index)
+  if (NO_CURRENT_PART_ID == part_id)
   {
     /*
       The original set of partitions to scan was empty and thus we report
@@ -3031,13 +3025,15 @@
   }
   
   DBUG_ASSERT(m_scan_value == 1);
-  file= m_file[m_current_partition_index];
+  file= m_file[part_id];
   
   while (TRUE)
   {
     int result= file->rnd_next(buf);
     if (!result)
     {
+      m_last_part= part_id;
+      m_part_spec.start_part= part_id;
       table->status= 0;
       DBUG_RETURN(0);
     }
@@ -3050,31 +3046,30 @@
       break;                                  // Return error
 
     /* End current partition */
-    late_extra_no_cache(m_current_partition_index);
-    DBUG_PRINT("info", ("rnd_end on partition %d", m_current_partition_index));
+    late_extra_no_cache(part_id);
+    DBUG_PRINT("info", ("rnd_end on partition %d", part_id));
     if ((result= file->ha_rnd_end()))
       break;
     
     /* Shift to next partition */
-    while (++m_current_partition_index < m_tot_parts &&
-           !bitmap_is_set(&(m_part_info->used_partitions), m_current_partition_index))
-    {
-    }
-    if (m_current_partition_index >= m_tot_parts)
+    while (++part_id < m_tot_parts &&
+           !bitmap_is_set(&(m_part_info->used_partitions), part_id))
+      ;
+    if (part_id >= m_tot_parts)
     {
       result= HA_ERR_END_OF_FILE;
       break;
     }
-    file= m_file[m_current_partition_index];
-    DBUG_PRINT("info", ("rnd_init on partition %d", m_current_partition_index));
+    file= m_file[part_id];
+    DBUG_PRINT("info", ("rnd_init on partition %d",
+               part_id));
     if ((result= file->ha_rnd_init(1)))
       break;
-    late_extra_cache(m_current_partition_index);
+    late_extra_cache(part_id);
   }
 
 end:
-  m_current_partition_index= MY_BIT_NONE;
-  m_part_spec.start_part= NO_CURRENT_PART_ID;  //TODO: should be removed
+  m_part_spec.start_part= NO_CURRENT_PART_ID;
   table->status= STATUS_NOT_FOUND;
   DBUG_RETURN(result);
 }
@@ -3107,17 +3102,18 @@
 
 void ha_partition::position(const byte *record)
 {
-  handler *file= m_file[m_current_partition_index];
+  handler *file= m_file[m_last_part];
   DBUG_ENTER("ha_partition::position");
 
   file->position(record);
-  //store_part_id_in_pos(ref, m_current_partition_index);
+  int2store(ref, m_last_part);
   memcpy((ref + PARTITION_BYTES_IN_POS), file->ref,
 	 (ref_length - PARTITION_BYTES_IN_POS));
 
 #ifdef SUPPORTING_PARTITION_OVER_DIFFERENT_ENGINES
 #ifdef HAVE_purify
-  bzero(ref + PARTITION_BYTES_IN_POS + ref_length, max_ref_length-ref_length);
+  bzero(ref + PARTITION_BYTES_IN_POS + ref_length,
+        max_ref_length-ref_length);
 #endif /* HAVE_purify */
 #endif
   DBUG_VOID_RETURN;
@@ -3153,8 +3149,7 @@
   part_id= uint2korr((const byte *) pos);
   DBUG_ASSERT(part_id < m_tot_parts);
   file= m_file[part_id];
-  m_current_partition_index= part_id;
-  m_last_part= part_id;  // TODO: remove
+  m_last_part= part_id;
   DBUG_RETURN(file->rnd_pos(buf, (pos + PARTITION_BYTES_IN_POS)));
 }
 
@@ -3198,7 +3193,6 @@
 int ha_partition::index_init(uint inx, bool sorted)
 {
   int error= 0;
-  uint i= 0;
   handler **file;
   DBUG_ENTER("ha_partition::index_init");
 
@@ -3250,7 +3244,7 @@
   do
   {
     int tmp;
-    /* TODO RONM: Change to index_init() when code is stable */
+    /* TODO RONM: Change to index_end() when code is stable */
     if (_bitmap_is_set(&(m_part_info->used_partitions), (file - m_file)))
       if ((tmp= (*file)->ha_index_end()))
         error= tmp;
@@ -3675,7 +3669,10 @@
   if (idx_read_flag)
     get_partition_set(table,buf,active_index,&m_start_key,&m_part_spec);
   else
-    get_partition_set(table, buf, MAX_KEY, 0, &m_part_spec);
+  {
+    m_part_spec.start_part= 0;
+    m_part_spec.end_part= m_tot_parts - 1;
+  }
   if (m_part_spec.start_part > m_part_spec.end_part)
   {
     /*
@@ -3699,7 +3696,19 @@
   {
     /*
       Set m_ordered_scan_ongoing according how the scan should be done
+      Only exact partitions are discovered atm by get_partition_set.
+      Verify this, also bitmap must have at least one bit set otherwise
+      the result from this table is the empty set.
     */
+    uint start_part= bitmap_get_first_set(&(m_part_info->used_partitions));
+    if (start_part == MY_BIT_NONE)
+    {
+      DBUG_PRINT("info", ("scan with no partition to scan"));
+      DBUG_RETURN(HA_ERR_END_OF_FILE);
+    }
+    if (start_part > m_part_spec.start_part)
+      m_part_spec.start_part= start_part;
+    DBUG_ASSERT(m_part_spec.start_part < m_tot_parts);
     m_ordered_scan_ongoing= m_ordered;
   }
   DBUG_ASSERT(m_part_spec.start_part < m_tot_parts &&
@@ -3797,13 +3806,16 @@
   for (i= m_part_spec.start_part; i <= m_part_spec.end_part; i++)
   {
     int error;
-    handler *file= m_file[i];
+    handler *file;
 
+    if (!(_bitmap_is_set(&(m_part_info->used_partitions), i)))
+      continue;
+    file= m_file[i];
     m_part_spec.start_part= i;
     switch (m_index_scan_type) {
-    case partition_index_read:
-      DBUG_PRINT("info", ("index_read on partition %d", i));
-      error= file->index_read(buf, m_start_key.key,
+      case partition_index_read:
+        DBUG_PRINT("info", ("index_read on partition %d", i));
+        error= file->index_read(buf, m_start_key.key,
 			      m_start_key.length,
 			      m_start_key.flag);
       break;
@@ -3872,60 +3884,46 @@
   m_top_entry= NO_CURRENT_PART_ID;
   queue_remove_all(&m_queue);
 
-  /* now we see what the index of our first important partition is */
-  m_current_partition_index = bitmap_get_first_set(&(m_part_info->used_partitions));
-  if (MY_BIT_NONE == m_current_partition_index)
+  DBUG_PRINT("info", ("m_part_spec.start_part %d", m_part_spec.start_part));
+  for (i= m_part_spec.start_part; i <= m_part_spec.end_part; i++)
   {
-    /*
-      The set of partitions to scan is empty. We return success and return
-      end of file on first rnd_next.
-    */
-    DBUG_RETURN(0);
-  }
+    if (!(_bitmap_is_set(&(m_part_info->used_partitions), i)))
+      continue;
+    byte *rec_buf_ptr= rec_buf(i);
+    int error;
+    handler *file= m_file[i];
 
-  DBUG_PRINT("info", ("m_current_partition_index %d", m_current_partition_index));
-  for (i= m_current_partition_index; i <= m_part_spec.end_part; i++)
-  {
-    DBUG_PRINT("info", ("i %d", i));
-    if (_bitmap_is_set(&(m_part_info->used_partitions), i))
+    switch (m_index_scan_type) {
+    case partition_index_read:
+      error= file->index_read(rec_buf_ptr,
+                              m_start_key.key,
+                              m_start_key.length,
+                              m_start_key.flag);
+      reverse_order= FALSE;
+      break;
+    case partition_index_first:
+      error= file->index_first(rec_buf_ptr);
+      reverse_order= FALSE;
+      break;
+    case partition_index_last:
+      error= file->index_last(rec_buf_ptr);
+      reverse_order= TRUE;
+      break;
+    default:
+      DBUG_ASSERT(FALSE);
+      DBUG_RETURN(HA_ERR_END_OF_FILE);
+    }
+    if (!error)
     {
-      byte *rec_buf_ptr= rec_buf(i);
-      int error;
-      handler *file= m_file[i];
-      DBUG_PRINT("info", ("i %d is set", i));
-
-      switch (m_index_scan_type) {
-      case partition_index_read:
-        error= file->index_read(rec_buf_ptr,
-                                m_start_key.key,
-                                m_start_key.length,
-                                m_start_key.flag);
-        reverse_order= FALSE;
-        break;
-      case partition_index_first:
-        error= file->index_first(rec_buf_ptr);
-        reverse_order= FALSE;
-        break;
-      case partition_index_last:
-        error= file->index_last(rec_buf_ptr);
-        reverse_order= TRUE;
-        break;
-      default:
-        DBUG_ASSERT(FALSE);
-        DBUG_RETURN(HA_ERR_END_OF_FILE);
-      }
-      if (!error)
-      {
-        found= TRUE;
-        /*
-          Initialise queue without order first, simply insert
-        */
-        queue_element(&m_queue, j++)= (byte*)queue_buf(i);
-      }
-      else if (error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE)
-      {
-        DBUG_RETURN(error);
-      }
+      found= TRUE;
+      /*
+        Initialise queue without order first, simply insert
+      */
+      queue_element(&m_queue, j++)= (byte*)queue_buf(i);
+    }
+    else if (error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE)
+    {
+      DBUG_RETURN(error);
     }
   }
   if (found)
@@ -4725,7 +4723,7 @@
   handler **file;
   DBUG_ENTER("ha_partition::reset");
   if (m_part_info)
-    bitmap_clear_all(&m_part_info->used_partitions);
+    bitmap_set_all(&m_part_info->used_partitions);
   file= m_file;
   do
   {

--- 1.11/sql/ha_partition.h	2006-01-19 13:07:59 -08:00
+++ 1.12/sql/ha_partition.h	2006-01-20 10:28:10 -08:00
@@ -93,7 +93,6 @@
   uint m_top_entry;                      // Which partition is to
                                          // deliver next result
   uint m_rec_length;                     // Local copy of record length
-  uint m_current_partition_index;          // Index of current partition in bitmap
 
   bool m_ordered;                        // Ordered/Unordered index scan
   bool m_has_transactions;               // Can we support transactions

--- 1.3/mysql-test/r/partition_pruning.result	2005-12-25 23:16:29 -08:00
+++ 1.4/mysql-test/r/partition_pruning.result	2006-01-20 10:28:10 -08:00
@@ -11,10 +11,10 @@
 insert into t1 values (1),(2),(3);
 explain partitions select * from t1 where a=1;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p1	ALL	NULL	NULL	NULL	NULL	3	Using where
+1	SIMPLE	t1	p1	ALL	NULL	NULL	NULL	NULL	2	Using where
 explain partitions select * from t1 where a=2;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0	ALL	NULL	NULL	NULL	NULL	3	Using where
+1	SIMPLE	t1	p0	system	NULL	NULL	NULL	NULL	1	
 explain partitions select * from t1 where a=1 or a=2;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	p0,p1	ALL	NULL	NULL	NULL	NULL	3	Using where
@@ -42,10 +42,10 @@
 insert into t3 values (5),(15);
 explain partitions select * from t3 where a=11;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t3	p1	ALL	NULL	NULL	NULL	NULL	2	Using where
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
 explain partitions select * from t3 where a=10;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t3	p1	ALL	NULL	NULL	NULL	NULL	2	Using where
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
 explain partitions select * from t3 where a=20;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
@@ -59,11 +59,11 @@
 insert into t4 values (10,2), (10,4);
 explain partitions select * from t4 where (a=10 and b=1) or (a=10 and b=2);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t4	p0	ALL	NULL	NULL	NULL	NULL	2	Using where
+1	SIMPLE	t4	p0	system	NULL	NULL	NULL	NULL	1	
 explain partitions select * from t4 
 where (a=10 and b=1) or (a=10 and b=2) or (a=10 and b = 3);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t4	p0	ALL	NULL	NULL	NULL	NULL	2	Using where
+1	SIMPLE	t4	p0	system	NULL	NULL	NULL	NULL	1	
 explain partitions select * from t4 where (a=10 and b=2) or (a=10 and b=3)
 or (a=10 and b = 4);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
@@ -89,25 +89,25 @@
 explain partitions select * from t5
 where (a=10 and b=1) or (a=10 and b=2) or (a=10 and b = 3);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t5	p0_sp0,p0_sp1	ALL	NULL	NULL	NULL	NULL	4	Using where
+1	SIMPLE	t5	p0_sp0,p0_sp1	ALL	NULL	NULL	NULL	NULL	2	Using where
 explain partitions select * from t5 where (a=10 and b=2) or (a=10 and b=3)
 or (a=10 and b = 4);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t5	p0_sp0,p0_sp1,p1_sp0,p1_sp1	ALL	NULL	NULL	NULL	NULL	4	Using where
 explain partitions select * from t5 where (c=1 and d=1);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t5	p0_sp0,p1_sp0	ALL	NULL	NULL	NULL	NULL	4	Using where
+1	SIMPLE	t5	p0_sp0,p1_sp0	ALL	NULL	NULL	NULL	NULL	2	Using where
 explain partitions select * from t5 where (c=2 and d=1);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t5	p0_sp1,p1_sp1	ALL	NULL	NULL	NULL	NULL	4	Using where
+1	SIMPLE	t5	p0_sp1,p1_sp1	ALL	NULL	NULL	NULL	NULL	2	Using where
 explain partitions select * from t5 where (a=10 and b=2 and c=1 and d=1) or 
 (c=2 and d=1);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t5	p0_sp0,p0_sp1,p1_sp1	ALL	NULL	NULL	NULL	NULL	4	Using where
+1	SIMPLE	t5	p0_sp0,p0_sp1,p1_sp1	ALL	NULL	NULL	NULL	NULL	3	Using where
 explain partitions select * from t5 where (a=10 and b=2 and c=1 and d=1) or 
 (b=2 and c=2 and d=1);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t5	p0_sp0,p0_sp1,p1_sp1	ALL	NULL	NULL	NULL	NULL	4	Using where
+1	SIMPLE	t5	p0_sp0,p0_sp1,p1_sp1	ALL	NULL	NULL	NULL	NULL	3	Using where
 create table t6 (a int not null) partition by LIST(a) (
 partition p1 values in (1),
 partition p3 values in (3),
@@ -121,31 +121,31 @@
 1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
 explain partitions select * from t6 where a <= 1;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t6	p1	ALL	NULL	NULL	NULL	NULL	3	Using where
+1	SIMPLE	t6	p1	system	NULL	NULL	NULL	NULL	1	
 explain partitions select * from t6 where a >  9;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
 explain partitions select * from t6 where a >= 9;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t6	p9	ALL	NULL	NULL	NULL	NULL	3	Using where
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
 explain partitions select * from t6 where a > 0 and a < 5;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t6	p1,p3	ALL	NULL	NULL	NULL	NULL	3	Using where
+1	SIMPLE	t6	p1,p3	ALL	NULL	NULL	NULL	NULL	2	Using where
 explain partitions select * from t6 where a > 5 and a < 12;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t6	p7,p9	ALL	NULL	NULL	NULL	NULL	3	Using where
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
 explain partitions select * from t6 where a > 3 and a < 8 ;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t6	p5,p7	ALL	NULL	NULL	NULL	NULL	3	Using where
+1	SIMPLE	t6	p5,p7	system	NULL	NULL	NULL	NULL	1	
 explain partitions select * from t6 where a >= 0 and a <= 5;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t6	p1,p3,p5	ALL	NULL	NULL	NULL	NULL	3	Using where
 explain partitions select * from t6 where a >= 5 and a <= 12;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t6	p5,p7,p9	ALL	NULL	NULL	NULL	NULL	3	Using where
+1	SIMPLE	t6	p5,p7,p9	system	NULL	NULL	NULL	NULL	1	
 explain partitions select * from t6 where a >= 3 and a <= 8;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t6	p3,p5,p7	ALL	NULL	NULL	NULL	NULL	3	Using where
+1	SIMPLE	t6	p3,p5,p7	ALL	NULL	NULL	NULL	NULL	2	Using where
 explain partitions select * from t6 where a > 3 and a < 5;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
@@ -159,16 +159,16 @@
 insert into t7 values (10),(30),(50);
 explain partitions select * from t7 where a < 5;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t7	p10	ALL	NULL	NULL	NULL	NULL	3	Using where
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
 explain partitions select * from t7 where a < 10;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t7	p10	ALL	NULL	NULL	NULL	NULL	3	Using where
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
 explain partitions select * from t7 where a <= 10;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t7	p10,p30	ALL	NULL	NULL	NULL	NULL	3	Using where
+1	SIMPLE	t7	p10,p30	ALL	NULL	NULL	NULL	NULL	2	Using where
 explain partitions select * from t7 where a = 10;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t7	p30	ALL	NULL	NULL	NULL	NULL	3	Using where
+1	SIMPLE	t7	p30	ALL	NULL	NULL	NULL	NULL	2	Using where
 explain partitions select * from t7 where a < 90;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t7	p10,p30,p50,p70,p90	ALL	NULL	NULL	NULL	NULL	3	Using where
@@ -183,7 +183,7 @@
 1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
 explain partitions select * from t7 where a > 11 and a < 29;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t7	p30	ALL	NULL	NULL	NULL	NULL	3	Using where
+1	SIMPLE	t7	p30	ALL	NULL	NULL	NULL	NULL	2	Using where
 create table t8 (a date not null) partition by RANGE(YEAR(a)) (
 partition p0 values less than (1980),
 partition p1 values less than (1990),
@@ -192,7 +192,7 @@
 insert into t8 values ('1985-05-05'),('1995-05-05');
 explain partitions select * from t8 where a < '1980-02-02';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t8	p0,p1	ALL	NULL	NULL	NULL	NULL	2	Using where
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
 create table t9 (a date not null) partition by RANGE(TO_DAYS(a)) (
 partition p0 values less than (732299), -- 2004-12-19
 partition p1 values less than (732468), -- 2005-06-06
@@ -201,7 +201,7 @@
 insert into t9 values ('2005-05-05'), ('2005-04-04');
 explain partitions select * from t9 where a <  '2004-12-19';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t9	p0	ALL	NULL	NULL	NULL	NULL	2	Using where
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
 explain partitions select * from t9 where a <= '2004-12-19';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t9	p0,p1	ALL	NULL	NULL	NULL	NULL	2	Using where
@@ -224,10 +224,10 @@
 insert into t1 values (1),(2),(3);
 explain partitions select * from t1 where a1 > 3;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p1,p2	ALL	NULL	NULL	NULL	NULL	3	Using where
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
 explain partitions select * from t1 where a1 >= 3;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p1,p2	ALL	NULL	NULL	NULL	NULL	3	Using where
+1	SIMPLE	t1	p1,p2	system	NULL	NULL	NULL	NULL	1	
 explain partitions select * from t1 where a1 < 3 and a1 > 3;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
@@ -242,19 +242,19 @@
 insert into t3 values (1,1),(2,2),(3,3);
 explain partitions select * from t3 where a=2 or b=1;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t3	p0_sp1,p1_sp0,p1_sp1,p1_sp2,p1_sp3,p2_sp1,p3_sp1	ALL	NULL	NULL	NULL	NULL	3	Using where
+1	SIMPLE	t3	p0_sp1,p1_sp0,p1_sp1,p1_sp2,p1_sp3,p2_sp1,p3_sp1	ALL	NULL	NULL	NULL	NULL	2	Using where
 explain partitions select * from t3 where a=4 or b=2;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t3	p0_sp2,p1_sp2,p2_sp2,p3_sp0,p3_sp1,p3_sp2,p3_sp3	ALL	NULL	NULL	NULL	NULL	3	Using where
+1	SIMPLE	t3	p0_sp2,p1_sp2,p2_sp2,p3_sp0,p3_sp1,p3_sp2,p3_sp3	system	NULL	NULL	NULL	NULL	1	
 explain partitions select * from t3 where (a=2 or b=1) and (a=4 or b=2) ;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t3	p1_sp2,p3_sp1	ALL	NULL	NULL	NULL	NULL	3	Using where
+1	SIMPLE	t3	p1_sp2,p3_sp1	system	NULL	NULL	NULL	NULL	1	
 drop table t3;
 create table t1 (a int) partition by hash(a) partitions 2;
 insert into t1 values (1),(2);
 explain partitions select * from t1 where a is null;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0	ALL	NULL	NULL	NULL	NULL	2	Using where
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
 explain partitions select * from t1 where a is not null;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	p0,p1	ALL	NULL	NULL	NULL	NULL	2	Using where
Thread
bk commit into 5.1 tree (patg:1.2083)Patrick Galbraith20 Jan