diff -Narup ./046_mariadb-10.0.15-sp_general_log/sql/handler.cc ./047_mariadb-10.0.15-child_partition_pruning2/sql/handler.cc
--- ./046_mariadb-10.0.15-sp_general_log/sql/handler.cc	2014-11-29 17:09:04.155796252 +0900
+++ ./047_mariadb-10.0.15-child_partition_pruning2/sql/handler.cc	2014-11-29 18:38:48.686798729 +0900
@@ -6232,32 +6232,72 @@ void handler::unlock_shared_ha_data()
 }
 
 
+int handler::set_top_table_and_fields(TABLE *top_table,
+                                      Field **top_table_field,
+                                      uint top_table_fields)
+{
+  DBUG_ENTER("handler::set_top_table_and_fields");
+  DBUG_PRINT("info",("set_top_table_fields=%s",
+    set_top_table_fields ? "TRUE" : "FALSE"));
+  if (!set_top_table_fields)
+  {
+    set_top_table_fields = TRUE;
+    this->top_table = top_table;
+    this->top_table_field = top_table_field;
+    this->top_table_fields = top_table_fields;
+  }
+  DBUG_RETURN(0);
+}
+
+
+void handler::clear_top_table_fields()
+{
+  DBUG_ENTER("handler::clear_top_table_fields");
+  DBUG_PRINT("info",("set_top_table_fields=%s",
+    set_top_table_fields ? "TRUE" : "FALSE"));
+  if (set_top_table_fields)
+  {
+    set_top_table_fields = FALSE;
+    top_table = NULL;
+    top_table_field = NULL;
+    top_table_fields = 0;
+  }
+  DBUG_VOID_RETURN;
+}
+
+
 Field *handler::get_top_table_field(uint16 field_index)
 {
+  DBUG_ENTER("handler::get_top_table_field");
   Field *field;
+  DBUG_PRINT("info",("set_top_table_fields=%s",
+    set_top_table_fields ? "TRUE" : "FALSE"));
   if (set_top_table_fields)
   {
     field = top_table->field[field_index];
   } else {
     field = table->field[field_index];
   }
-  return field;
+  DBUG_RETURN(field);
 }
 
 
 Field *handler::field_exchange(Field *field)
 {
+  DBUG_ENTER("handler::field_exchange");
+  DBUG_PRINT("info",("set_top_table_fields=%s",
+    set_top_table_fields ? "TRUE" : "FALSE"));
   if (set_top_table_fields)
   {
     if (field->table != top_table)
-      return NULL;
+      DBUG_RETURN(NULL);
     if (!(field = top_table_field[field->field_index]))
-      return NULL;
+      DBUG_RETURN(NULL);
   } else {
     if (field->table != table)
-      return NULL;
+      DBUG_RETURN(NULL);
   }
-  return field;
+  DBUG_RETURN(field);
 }
 
 
diff -Narup ./046_mariadb-10.0.15-sp_general_log/sql/handler.h ./047_mariadb-10.0.15-child_partition_pruning2/sql/handler.h
--- ./046_mariadb-10.0.15-sp_general_log/sql/handler.h	2014-11-29 17:09:32.634559429 +0900
+++ ./047_mariadb-10.0.15-child_partition_pruning2/sql/handler.h	2014-11-29 18:38:48.690796804 +0900
@@ -3534,27 +3534,8 @@ public:
  virtual int info_push(uint info_type, void *info) { return 0; };
  virtual int set_top_table_and_fields(TABLE *top_table,
                                       Field **top_table_field,
-                                      uint top_table_fields)
- {
-   if (!set_top_table_fields)
-   {
-     set_top_table_fields = TRUE;
-     this->top_table = top_table;
-     this->top_table_field = top_table_field;
-     this->top_table_fields = top_table_fields;
-   }
-   return 0;
- }
- virtual void clear_top_table_fields()
- {
-   if (set_top_table_fields)
-   {
-     set_top_table_fields = FALSE;
-     top_table = NULL;
-     top_table_field = NULL;
-     top_table_fields = 0;
-   }
- }
+                                      uint top_table_fields);
+ virtual void clear_top_table_fields();
  virtual Field *get_top_table_field(uint16 field_index);
  virtual Field *field_exchange(Field *field);
  virtual bool prune_partitions_for_child(THD *thd, Item *pprune_cond)
diff -Narup ./046_mariadb-10.0.15-sp_general_log/sql/opt_range.cc ./047_mariadb-10.0.15-child_partition_pruning2/sql/opt_range.cc
--- ./046_mariadb-10.0.15-sp_general_log/sql/opt_range.cc	2014-11-29 17:10:14.712795717 +0900
+++ ./047_mariadb-10.0.15-child_partition_pruning2/sql/opt_range.cc	2014-11-29 18:38:48.698795652 +0900
@@ -4881,6 +4881,7 @@ static bool fields_ok_for_partition_inde
 
 static bool create_partition_index_description(PART_PRUNE_PARAM *ppar)
 {
+  DBUG_ENTER("create_partition_index_description");
   RANGE_OPT_PARAM *range_par= &(ppar->range_param);
   partition_info *part_info= ppar->part_info;
   uint used_part_fields, used_subpart_fields;
@@ -4923,14 +4924,14 @@ static bool create_partition_index_descr
                                                            total_parts)) ||
       !(ppar->is_subpart_keypart= (my_bool*)alloc_root(alloc, sizeof(my_bool)*
                                                            total_parts)))
-    return TRUE;
+    DBUG_RETURN(TRUE);
  
   if (ppar->subpart_fields)
   {
     my_bitmap_map *buf;
     uint32 bufsize= bitmap_buffer_size(ppar->part_info->num_subparts);
     if (!(buf= (my_bitmap_map*) alloc_root(alloc, bufsize)))
-      return TRUE;
+      DBUG_RETURN(TRUE);
     my_bitmap_init(&ppar->subparts_bitmap, buf, ppar->part_info->num_subparts,
                 FALSE);
   }
@@ -4949,6 +4950,8 @@ static bool create_partition_index_descr
                          key_part->length, key_part->store_length));
 
     key_part->field=        (*field);
+    DBUG_PRINT("info", ("key_part->field->field_name=%s",
+                         key_part->field->field_name));
     key_part->image_type =  Field::itRAW;
     /* 
       We set keypart flag to 0 here as the only HA_PART_KEY_SEG is checked
@@ -4975,7 +4978,7 @@ static bool create_partition_index_descr
 
   DBUG_EXECUTE("info", print_partitioning_index(range_par->key_parts,
                                                 range_par->key_parts_end););
-  return FALSE;
+  DBUG_RETURN(FALSE);
 }
 
 
@@ -8193,11 +8196,27 @@ get_mm_parts(RANGE_OPT_PARAM *param, CON
       value->used_tables() & ~(param->prev_tables | param->read_tables))
     DBUG_RETURN(0);
   handler *file= key_part->field->table->file;
+  DBUG_PRINT("info",("key_part->field->table->s->db=%s",
+    key_part->field->table->s->db.str));
+  DBUG_PRINT("info",("key_part->field->table->s->table_name=%s",
+    key_part->field->table->s->table_name.str));
+  DBUG_PRINT("info",("field->field_name=%s", field->field_name));
+  Field *child_field = file->field_exchange(field);
+  if (child_field)
+  {
+    DBUG_PRINT("info",("child_field->field_name=%s", child_field->field_name));
   for (; key_part != end ; key_part++)
   {
+    DBUG_PRINT("info",("key_part->field->field_name=%s",
+      key_part->field->field_name));
+    DBUG_PRINT("info",("key_part->field->field_index=%u",
+      key_part->field->field_index));
+/*
     Field *key_field= file->get_top_table_field(key_part->field->field_index);
-
+    DBUG_PRINT("info",("key_field->field_name=%s", key_field->field_name));
     if (field->eq(key_field))
+*/
+    if (child_field->eq(key_part->field))
     {
       DBUG_PRINT("info",("match field"));
       SEL_ARG *sel_arg=0;
@@ -8227,6 +8246,7 @@ get_mm_parts(RANGE_OPT_PARAM *param, CON
       tree->keys_map.set_bit(key_part->key);
     }
   }
+  }
 
   if (tree && tree->merges.is_empty() && tree->keys_map.is_clear_all())
     tree= NULL;
