diff -Narup ./040_mariadb-10.0.15-partition_mrr3/sql/ha_partition.cc ./041_mariadb-10.0.15-vp_handler2/sql/ha_partition.cc
--- ./040_mariadb-10.0.15-partition_mrr3/sql/ha_partition.cc	2014-11-29 17:09:20.602795547 +0900
+++ ./041_mariadb-10.0.15-vp_handler2/sql/ha_partition.cc	2014-11-29 17:09:32.632563697 +0900
@@ -12096,6 +12096,22 @@ bool ha_partition::prune_partitions_for_
 #endif
 
 
+#ifdef HANDLER_HAS_GET_NEXT_GLOBAL_FOR_CHILD
+TABLE_LIST *ha_partition::get_next_global_for_child()
+{
+  handler **file;
+  TABLE_LIST *table_list, *tables= NULL;
+  DBUG_ENTER("ha_partition::get_next_global_for_child");
+  for (file= m_file; *file; file++)
+  {
+    if ((table_list= (*file)->get_next_global_for_child()))
+      tables= table_list;
+  }
+  DBUG_RETURN(tables);
+}
+#endif
+
+
 #ifdef HA_CAN_BULK_ACCESS
 PARTITION_BULK_ACCESS_INFO *ha_partition::create_bulk_access_info()
 {
diff -Narup ./040_mariadb-10.0.15-partition_mrr3/sql/ha_partition.h ./041_mariadb-10.0.15-vp_handler2/sql/ha_partition.h
--- ./040_mariadb-10.0.15-partition_mrr3/sql/ha_partition.h	2014-11-29 17:09:03.934795234 +0900
+++ ./041_mariadb-10.0.15-vp_handler2/sql/ha_partition.h	2014-11-29 17:09:32.633563161 +0900
@@ -1428,6 +1428,9 @@ public:
 #ifdef HANDLER_HAS_PRUNE_PARTITIONS_FOR_CHILD
     virtual bool prune_partitions_for_child(THD *thd, Item *pprune_cond);
 #endif
+#ifdef HANDLER_HAS_GET_NEXT_GLOBAL_FOR_CHILD
+    virtual TABLE_LIST *get_next_global_for_child();
+#endif
 
     private:
     int handle_opt_partitions(THD *thd, HA_CHECK_OPT *check_opt, uint flags);
diff -Narup ./040_mariadb-10.0.15-partition_mrr3/sql/handler.h ./041_mariadb-10.0.15-vp_handler2/sql/handler.h
--- ./040_mariadb-10.0.15-partition_mrr3/sql/handler.h	2014-11-29 17:09:05.973380133 +0900
+++ ./041_mariadb-10.0.15-vp_handler2/sql/handler.h	2014-11-29 17:09:32.634559429 +0900
@@ -45,6 +45,7 @@
 #define HANDLER_HAS_CAN_USE_FOR_AUTO_INC_INIT
 #define HANDLER_HAS_DIRECT_AGGREGATE
 #define HANDLER_HAS_PRUNE_PARTITIONS_FOR_CHILD
+#define HANDLER_HAS_GET_NEXT_GLOBAL_FOR_CHILD
 #define INFO_KIND_UPDATE_FIELDS 101
 #define INFO_KIND_UPDATE_VALUES 102
 #define INFO_KIND_FORCE_LIMIT_BEGIN 103
@@ -3558,6 +3559,8 @@ public:
  virtual Field *field_exchange(Field *field);
  virtual bool prune_partitions_for_child(THD *thd, Item *pprune_cond)
  { return FALSE; }
+ virtual TABLE_LIST *get_next_global_for_child()
+ { return NULL; }
 
  /**
    Push down an index condition to the handler.
diff -Narup ./040_mariadb-10.0.15-partition_mrr3/sql/sql_handler.cc ./041_mariadb-10.0.15-vp_handler2/sql/sql_handler.cc
--- ./040_mariadb-10.0.15-partition_mrr3/sql/sql_handler.cc	2014-11-29 17:07:51.990797352 +0900
+++ ./041_mariadb-10.0.15-vp_handler2/sql/sql_handler.cc	2014-11-29 17:09:32.636562158 +0900
@@ -144,11 +144,13 @@ static void mysql_ha_close_childs(THD *t
 {
   TABLE_LIST *table_list;
   DBUG_ENTER("mysql_ha_close_childs");
+  DBUG_PRINT("info",("tables=%p", tables));
   for (table_list = tables->next_global; table_list;
     table_list = table_list->next_global)
   {
     DBUG_PRINT("info",("table_name %s.%s", table_list->table->s->db.str,
       table_list->table->s->table_name.str));
+    DBUG_PRINT("info",("parent_l=%p", table_list->parent_l));
     if (table_list->parent_l == tables)
     {
       DBUG_PRINT("info",("find child"));
@@ -202,6 +204,8 @@ static void mysql_ha_close_table(SQL_HAN
     }
 
     table->file->ha_index_or_rnd_end();
+    table->pos_in_table_list->next_global=
+      table->file->get_next_global_for_child();
     mysql_ha_close_childs(thd, table->pos_in_table_list);
     table->open_by_handler= 0;
     close_thread_table(thd, &table);
@@ -211,6 +215,8 @@ static void mysql_ha_close_table(SQL_HAN
   {
     /* Must be a temporary table */
     table->file->ha_index_or_rnd_end();
+    table->pos_in_table_list->next_global=
+      table->file->get_next_global_for_child();
     mysql_ha_close_childs(thd, table->pos_in_table_list);
     table->query_id= thd->query_id;
     table->open_by_handler= 0;
@@ -818,7 +824,18 @@ retry:
   {
     int lock_error;
 
+/*
     handler->lock->locks[0]->type= handler->lock->locks[0]->org_type;
+*/
+    THR_LOCK_DATA **pos,**end;
+    for (
+      pos= handler->lock->locks,
+      end= handler->lock->locks + handler->lock->lock_count;
+      pos < end;
+      pos++
+    ) {
+      pos[0]->type= pos[0]->org_type;
+    }
 
     /* save open_tables state */
     TABLE* backup_open_tables= thd->open_tables;
