diff -Narup ./047_mariadb-10.0.15-child_partition_pruning2/sql/ha_partition.cc ./048_mariadb-10.0.15-vp_partition/sql/ha_partition.cc
--- ./047_mariadb-10.0.15-child_partition_pruning2/sql/ha_partition.cc	2014-11-29 17:10:53.063397158 +0900
+++ ./048_mariadb-10.0.15-vp_partition/sql/ha_partition.cc	2014-11-29 18:38:57.122394767 +0900
@@ -4301,6 +4301,7 @@ int ha_partition::write_row(uchar * buf)
   sql_mode_t saved_sql_mode= thd->variables.sql_mode;
   bool saved_auto_inc_field_not_null= table->auto_increment_field_not_null;
   DBUG_ENTER("ha_partition::write_row");
+  DBUG_PRINT("info", ("partition this=%p", this));
 
   /*
     If we have an auto_increment column and we are writing a changed row
@@ -4374,6 +4375,7 @@ int ha_partition::write_row(uchar * buf)
   }
   m_last_part= part_id;
   DBUG_PRINT("info", ("Insert in partition %d", part_id));
+  DBUG_PRINT("info", ("partition m_last_part=%d", m_last_part));
   start_part_bulk_insert(thd, part_id);
 
   tmp_disable_binlog(thd); /* Do not replicate the low-level changes. */
@@ -4404,6 +4406,7 @@ int ha_partition::pre_write_row(uchar * 
   uchar *rec0= m_rec0;
 #endif
   DBUG_ENTER("ha_partition::pre_write_row");
+  DBUG_PRINT("info", ("partition this=%p", this));
   DBUG_ASSERT(buf == m_rec0);
 
   /* If we have a timestamp column, update it to the current time */
@@ -4479,6 +4482,7 @@ int ha_partition::pre_write_row(uchar * 
   }
   m_last_part= part_id;
   DBUG_PRINT("info", ("Insert in partition %d", part_id));
+  DBUG_PRINT("info", ("partition m_last_part=%d", m_last_part));
   start_part_bulk_insert(thd, part_id);
 
   tmp_disable_binlog(thd); /* Do not replicate the low-level changes. */
@@ -4528,6 +4532,7 @@ int ha_partition::update_row(const uchar
   int error= 0;
   longlong func_value;
   DBUG_ENTER("ha_partition::update_row");
+  DBUG_PRINT("info", ("partition this=%p", this));
   m_err_rec= NULL;
 
   // Need to read partition-related columns, to locate the row's partition:
@@ -4566,11 +4571,14 @@ int ha_partition::update_row(const uchar
   */
   if (old_part_id != m_last_part)
   {
+    DBUG_PRINT("info", ("partition old_part_id=%d", old_part_id));
+    DBUG_PRINT("info", ("partition m_last_part=%d", m_last_part));
     m_err_rec= old_data;
     DBUG_RETURN(HA_ERR_ROW_IN_WRONG_PARTITION);
   }
 
   m_last_part= new_part_id;
+  DBUG_PRINT("info", ("partition m_last_part=%d", m_last_part));
   start_part_bulk_insert(thd, new_part_id);
   if (new_part_id == old_part_id)
   {
@@ -4678,6 +4686,7 @@ int ha_partition::delete_row(const uchar
   int error;
   THD *thd= ha_thd();
   DBUG_ENTER("ha_partition::delete_row");
+  DBUG_PRINT("info", ("partition this=%p", this));
   m_err_rec= NULL;
 
   DBUG_ASSERT(bitmap_is_subset(&m_part_info->full_part_field_set,
@@ -4719,6 +4728,7 @@ int ha_partition::delete_row(const uchar
   }
 
   m_last_part= part_id;
+  DBUG_PRINT("info", ("partition m_last_part=%d", m_last_part));
   tmp_disable_binlog(thd);
   error= m_file[part_id]->ha_delete_row(buf);
   reenable_binlog(thd);
@@ -5059,6 +5069,7 @@ int ha_partition::rnd_init(bool scan)
   uint i= 0;
   uint32 part_id;
   DBUG_ENTER("ha_partition::rnd_init");
+  DBUG_PRINT("info", ("partition this=%p", this));
 
   /*
     For operations that may need to change data, we may need to extend
@@ -5075,7 +5086,10 @@ int ha_partition::rnd_init(bool scan)
     */
     if (bitmap_is_overlapping(&m_part_info->full_part_field_set,
                               table->write_set))
+    {
+      DBUG_PRINT("info", ("partition set full bitmap"));
       bitmap_set_all(table->read_set);
+    }
     else
     {
       /*
@@ -5084,6 +5098,7 @@ int ha_partition::rnd_init(bool scan)
         fields of the partition functions are read such that we can
         calculate the partition id to place updated and deleted records.
       */
+      DBUG_PRINT("info", ("partition set part_field bitmap"));
       bitmap_union(table->read_set, &m_part_info->full_part_field_set);
     }
   }
@@ -5168,6 +5183,7 @@ int ha_partition::pre_rnd_init(bool scan
   uint i= 0;
   uint32 part_id;
   DBUG_ENTER("ha_partition::pre_rnd_init");
+  DBUG_PRINT("info", ("partition this=%p", this));
 
   /*
     For operations that may need to change data, we may need to extend
@@ -5184,7 +5200,10 @@ int ha_partition::pre_rnd_init(bool scan
     */
     if (bitmap_is_overlapping(&m_part_info->full_part_field_set,
                               table->write_set))
+    {
+      DBUG_PRINT("info", ("partition set full bitmap"));
       bitmap_set_all(table->read_set);
+    }
     else
     {
       /*
@@ -5193,6 +5212,7 @@ int ha_partition::pre_rnd_init(bool scan
         fields of the partition functions are read such that we can
         calculate the partition id to place updated and deleted records.
       */
+      DBUG_PRINT("info", ("partition set part_field bitmap"));
       bitmap_union(table->read_set, &m_part_info->full_part_field_set);
     }
   }
@@ -5382,6 +5402,7 @@ int ha_partition::rnd_next(uchar *buf)
   int result= HA_ERR_END_OF_FILE, error;
   uint part_id= m_part_spec.start_part;
   DBUG_ENTER("ha_partition::rnd_next");
+  DBUG_PRINT("info", ("partition this=%p", this));
 
   /* upper level will increment this once again at end of call */
   decrement_statistics(&SSV::ha_read_rnd_next_count);
@@ -5423,6 +5444,7 @@ int ha_partition::rnd_next(uchar *buf)
     if (!result)
     {
       m_last_part= part_id;
+      DBUG_PRINT("info", ("partition m_last_part=%d", m_last_part));
       m_part_spec.start_part= part_id;
       table->status= 0;
       DBUG_RETURN(0);
@@ -5453,6 +5475,7 @@ int ha_partition::rnd_next(uchar *buf)
       break;
     }
     m_last_part= part_id;
+    DBUG_PRINT("info", ("partition m_last_part=%d", m_last_part));
     m_part_spec.start_part= part_id;
     file= m_file[part_id];
     DBUG_PRINT("info", ("rnd_init on partition %d", part_id));
@@ -5540,6 +5563,7 @@ int ha_partition::rnd_pos(uchar * buf, u
   uint part_id;
   handler *file;
   DBUG_ENTER("ha_partition::rnd_pos");
+  DBUG_PRINT("info", ("partition this=%p", this));
   decrement_statistics(&SSV::ha_read_rnd_count);
 
   part_id= uint2korr((const uchar *) pos);
@@ -5547,6 +5571,7 @@ int ha_partition::rnd_pos(uchar * buf, u
   file= m_file[part_id];
   DBUG_ASSERT(bitmap_is_set(&(m_part_info->read_partitions), part_id));
   m_last_part= part_id;
+  DBUG_PRINT("info", ("partition m_last_part=%d", m_last_part));
   DBUG_RETURN(file->ha_rnd_pos(buf, (pos + PARTITION_BYTES_IN_POS)));
 }
 
@@ -5710,6 +5735,7 @@ int ha_partition::index_init(uint inx, b
   int error= 0;
   uint i;
   DBUG_ENTER("ha_partition::index_init");
+  DBUG_PRINT("info", ("partition this=%p", this));
 
   DBUG_PRINT("info", ("inx %u sorted %u", inx, sorted));
   active_index= inx;
@@ -5745,8 +5771,24 @@ int ha_partition::index_init(uint inx, b
     calculate the partition id to place updated and deleted records.
     But this is required for operations that may need to change data only.
   */
+/*
   if (get_lock_type() == F_WRLCK)
     bitmap_union(table->read_set, &m_part_info->full_part_field_set);
+*/
+  if (get_lock_type() == F_WRLCK)
+  {
+    if (bitmap_is_overlapping(&m_part_info->full_part_field_set,
+                              table->write_set))
+    {
+      DBUG_PRINT("info", ("partition set full bitmap"));
+      bitmap_set_all(table->read_set);
+    }
+    else
+    {
+      DBUG_PRINT("info", ("partition set part_field bitmap"));
+      bitmap_union(table->read_set, &m_part_info->full_part_field_set);
+    }
+  }
   if (sorted)
   {
     /*
@@ -6046,6 +6088,7 @@ int ha_partition::index_read_map(uchar *
                                  enum ha_rkey_function find_flag)
 {
   DBUG_ENTER("ha_partition::index_read_map");
+  DBUG_PRINT("info", ("partition this=%p", this));
   decrement_statistics(&SSV::ha_read_key_count);
   end_range= 0;
   m_index_scan_type= partition_index_read;
@@ -6318,6 +6361,7 @@ int ha_partition::index_read_idx_map(uch
 {
   int error= HA_ERR_KEY_NOT_FOUND;
   DBUG_ENTER("ha_partition::index_read_idx_map");
+  DBUG_PRINT("info", ("partition this=%p", this));
 
   if (find_flag == HA_READ_KEY_EXACT)
   {
@@ -6352,7 +6396,10 @@ int ha_partition::index_read_idx_map(uch
         break;
     }
     if (part <= m_part_spec.end_part)
+    {
       m_last_part= part;
+      DBUG_PRINT("info", ("partition m_last_part=%d", m_last_part));
+    }
   }
   else
   {
@@ -7148,7 +7195,10 @@ int ha_partition::ft_init()
     */
     if (bitmap_is_overlapping(&m_part_info->full_part_field_set,
                               table->write_set))
+    {
+      DBUG_PRINT("info", ("partition set full bitmap"));
       bitmap_set_all(table->read_set);
+    }
     else
     {
       /*
@@ -7157,6 +7207,7 @@ int ha_partition::ft_init()
         fields of the partition functions are read such that we can
         calculate the partition id to place updated and deleted records.
       */
+      DBUG_PRINT("info", ("partition set part_field bitmap"));
       bitmap_union(table->read_set, &m_part_info->full_part_field_set);
     }
   }
@@ -7233,7 +7284,10 @@ int ha_partition::pre_ft_init()
     */
     if (bitmap_is_overlapping(&m_part_info->full_part_field_set,
                               table->write_set))
+    {
+      DBUG_PRINT("info", ("partition set full bitmap"));
       bitmap_set_all(table->read_set);
+    }
     else
     {
       /*
@@ -7242,6 +7296,7 @@ int ha_partition::pre_ft_init()
         fields of the partition functions are read such that we can
         calculate the partition id to place updated and deleted records.
       */
+      DBUG_PRINT("info", ("partition set part_field bitmap"));
       bitmap_union(table->read_set, &m_part_info->full_part_field_set);
     }
   }
@@ -7483,6 +7538,7 @@ int ha_partition::ft_read(
     if (!result)
     {
       m_last_part= part_id;
+      DBUG_PRINT("info", ("partition m_last_part=%d", m_last_part));
       m_part_spec.start_part= part_id;
       table->status= 0;
       DBUG_RETURN(0);
@@ -7511,6 +7567,7 @@ int ha_partition::ft_read(
       break;
     }
     m_last_part= part_id;
+    DBUG_PRINT("info", ("partition m_last_part=%d", m_last_part));
     m_part_spec.start_part= part_id;
     file= m_file[part_id];
     DBUG_PRINT("info", ("ft_init on partition %d", part_id));
@@ -7829,6 +7886,7 @@ int ha_partition::handle_unordered_next(
   handler *file;
   int error;
   DBUG_ENTER("ha_partition::handle_unordered_next");
+  DBUG_PRINT("info", ("partition this=%p", this));
 
   if (m_part_spec.start_part >= m_tot_parts)
   {
@@ -7849,6 +7907,7 @@ int ha_partition::handle_unordered_next(
       &m_range_info[m_part_spec.start_part])))
     {
       m_last_part= m_part_spec.start_part;
+      DBUG_PRINT("info", ("partition m_last_part=%d", m_last_part));
       DBUG_RETURN(0);
     }
   }
@@ -7857,6 +7916,7 @@ int ha_partition::handle_unordered_next(
     if (!(error= file->read_range_next()))
     {
       m_last_part= m_part_spec.start_part;
+      DBUG_PRINT("info", ("partition m_last_part=%d", m_last_part));
       DBUG_RETURN(0);
     }
   }
@@ -7866,6 +7926,7 @@ int ha_partition::handle_unordered_next(
                                           m_start_key.length)))
     {
       m_last_part= m_part_spec.start_part;
+      DBUG_PRINT("info", ("partition m_last_part=%d", m_last_part));
       DBUG_RETURN(0);
     }
   }
@@ -7874,6 +7935,7 @@ int ha_partition::handle_unordered_next(
     if (!(error= file->ha_index_next(buf)))
     {
       m_last_part= m_part_spec.start_part;
+      DBUG_PRINT("info", ("partition m_last_part=%d", m_last_part));
       DBUG_RETURN(0);                           // Row was in range
     }
   }
@@ -7909,6 +7971,7 @@ int ha_partition::handle_unordered_scan_
   uint i= m_part_spec.start_part;
   int saved_error= HA_ERR_END_OF_FILE;
   DBUG_ENTER("ha_partition::handle_unordered_scan_next_partition");
+  DBUG_PRINT("info", ("partition this=%p", this));
 
   if (i)
     i= bitmap_get_next_set(&m_part_info->read_partitions, i - 1);
@@ -7966,6 +8029,7 @@ int ha_partition::handle_unordered_scan_
     if (!error)
     {
       m_last_part= i;
+      DBUG_PRINT("info", ("partition m_last_part=%d", m_last_part));
       DBUG_RETURN(0);
     }
     if ((error != HA_ERR_END_OF_FILE) && (error != HA_ERR_KEY_NOT_FOUND))
@@ -8022,6 +8086,7 @@ int ha_partition::handle_ordered_index_s
   uchar *part_rec_buf_ptr= m_ordered_rec_buffer;
   int saved_error= HA_ERR_END_OF_FILE;
   DBUG_ENTER("ha_partition::handle_ordered_index_scan");
+  DBUG_PRINT("info", ("partition this=%p", this));
 
   if (!bulk_access_executing)
   {
@@ -8237,12 +8302,16 @@ void ha_partition::return_top_record(uch
   uint part_id;
   uchar *key_buffer= queue_top(&m_queue);
   uchar *rec_buffer= key_buffer + PARTITION_BYTES_IN_POS;
+  DBUG_ENTER("ha_partition::return_top_record");
+  DBUG_PRINT("info", ("partition this=%p", this));
 
   part_id= uint2korr(key_buffer);
   memcpy(buf, rec_buffer, m_rec_length);
   m_last_part= part_id;
+  DBUG_PRINT("info", ("partition m_last_part=%d", m_last_part));
   m_top_entry= part_id;
   m_file[part_id]->return_record_by_parent();
+  DBUG_VOID_RETURN;
 }
 
 
@@ -10288,6 +10357,8 @@ void ha_partition::print_error(int error
     {
       DBUG_ASSERT(0);
       m_last_part= 0;
+      DBUG_PRINT("info", ("partition m_last_part=%d", m_last_part));
+      DBUG_PRINT("info", ("partition m_last_part=%p", &m_last_part));
     }
     m_file[m_last_part]->print_error(error, errflag);
   }
@@ -12193,6 +12264,33 @@ TABLE_LIST *ha_partition::get_next_globa
 #endif
 
 
+#ifdef HANDLER_HAS_CHECK_AND_SET_BITMAP_FOR_UPDATE
+void ha_partition::check_and_set_bitmap_for_update(bool rnd)
+{
+  handler **file;
+  DBUG_ENTER("ha_partition::check_and_set_bitmap_for_update");
+  DBUG_PRINT("info",("partition this=%p", this));
+  for (file= m_file; *file; file++)
+  {
+    (*file)->check_and_set_bitmap_for_update(rnd);
+  }
+
+  if (bitmap_is_overlapping(&m_part_info->full_part_field_set,
+                            table->write_set))
+  {
+    DBUG_PRINT("info", ("partition set full bitmap"));
+    bitmap_set_all(table->read_set);
+  }
+  else
+  {
+    DBUG_PRINT("info", ("partition set part_field bitmap"));
+    bitmap_union(table->read_set, &m_part_info->full_part_field_set);
+  }
+  DBUG_VOID_RETURN;
+}
+#endif
+
+
 #ifdef HA_CAN_BULK_ACCESS
 PARTITION_BULK_ACCESS_INFO *ha_partition::create_bulk_access_info()
 {
diff -Narup ./047_mariadb-10.0.15-child_partition_pruning2/sql/ha_partition.h ./048_mariadb-10.0.15-vp_partition/sql/ha_partition.h
--- ./047_mariadb-10.0.15-child_partition_pruning2/sql/ha_partition.h	2014-11-29 17:09:32.633563161 +0900
+++ ./048_mariadb-10.0.15-vp_partition/sql/ha_partition.h	2014-11-29 18:38:57.122394767 +0900
@@ -1431,6 +1431,9 @@ public:
 #ifdef HANDLER_HAS_GET_NEXT_GLOBAL_FOR_CHILD
     virtual TABLE_LIST *get_next_global_for_child();
 #endif
+#ifdef HANDLER_HAS_CHECK_AND_SET_BITMAP_FOR_UPDATE
+    virtual void check_and_set_bitmap_for_update(bool rnd);
+#endif
 
     private:
     int handle_opt_partitions(THD *thd, HA_CHECK_OPT *check_opt, uint flags);
diff -Narup ./047_mariadb-10.0.15-child_partition_pruning2/sql/handler.h ./048_mariadb-10.0.15-vp_partition/sql/handler.h
--- ./047_mariadb-10.0.15-child_partition_pruning2/sql/handler.h	2014-11-29 18:38:48.690796804 +0900
+++ ./048_mariadb-10.0.15-vp_partition/sql/handler.h	2014-11-29 18:38:57.124795369 +0900
@@ -46,6 +46,7 @@
 #define HANDLER_HAS_DIRECT_AGGREGATE
 #define HANDLER_HAS_PRUNE_PARTITIONS_FOR_CHILD
 #define HANDLER_HAS_GET_NEXT_GLOBAL_FOR_CHILD
+#define HANDLER_HAS_CHECK_AND_SET_BITMAP_FOR_UPDATE
 #define INFO_KIND_UPDATE_FIELDS 101
 #define INFO_KIND_UPDATE_VALUES 102
 #define INFO_KIND_FORCE_LIMIT_BEGIN 103
@@ -3542,6 +3543,7 @@ public:
  { return FALSE; }
  virtual TABLE_LIST *get_next_global_for_child()
  { return NULL; }
+ virtual void check_and_set_bitmap_for_update(bool rnd) { return; };
 
  /**
    Push down an index condition to the handler.
