List:Maria Storage Engine« Previous MessageNext Message »
From:Michael Widenius Date:October 4 2008 4:35pm
Subject:bzr commit into MySQL/Maria:mysql-maria branch (monty:2671) Bug#39227
View as plain text  
#At bzr+ssh://bk-internal.mysql.com/bzrroot/server/mysql-maria/

 2671 Michael Widenius	2008-10-04
      Fix for Bug#39227 Maria: crash with ALTER TABLE PARTITION
modified:
  mysql-test/r/maria.result
  mysql-test/t/maria.test
  sql/ha_partition.cc
  sql/ha_partition.h

per-file messages:
  mysql-test/r/maria.result
    Added test case
  mysql-test/t/maria.test
    Added test case
  sql/ha_partition.cc
    Send HA_EXTRA_PREPARE_FOR_DROP to the engine for tables that are going to be dropped
  sql/ha_partition.h
    Added prototype for prepare_for_drop()
=== modified file 'mysql-test/r/maria.result'
--- a/mysql-test/r/maria.result	2008-09-26 13:49:51 +0000
+++ b/mysql-test/r/maria.result	2008-10-04 16:35:21 +0000
@@ -2284,3 +2284,8 @@ insert into v1 (f1) values (3) on duplic
 insert into v1 (f1) values (3) on duplicate key update f1= f3 + 10;
 drop table t1,t2;
 drop view v1;
+create table t1 (s1 int);
+insert into t1 values (1);
+alter table t1 partition by list (s1) (partition p1 values in (2));
+ERROR HY000: Table has no partition for value 1
+drop table t1;

=== modified file 'mysql-test/t/maria.test'
--- a/mysql-test/t/maria.test	2008-09-26 13:49:51 +0000
+++ b/mysql-test/t/maria.test	2008-10-04 16:35:21 +0000
@@ -1575,3 +1575,13 @@ insert into v1 (f1) values (3) on duplic
 insert into v1 (f1) values (3) on duplicate key update f1= f3 + 10;
 drop table t1,t2;
 drop view v1;
+
+#
+# Bug #39227 Maria: crash with ALTER TABLE PARTITION
+#
+
+create table t1 (s1 int);
+insert into t1 values (1);
+--error ER_NO_PARTITION_FOR_GIVEN_VALUE
+alter table t1 partition by list (s1) (partition p1 values in (2));
+drop table t1;

=== modified file 'sql/ha_partition.cc'
--- a/sql/ha_partition.cc	2008-06-28 12:45:15 +0000
+++ b/sql/ha_partition.cc	2008-10-04 16:35:21 +0000
@@ -4950,12 +4950,13 @@ int ha_partition::extra(enum ha_extra_fu
   /* Category 3), used by MyISAM handlers */
   case HA_EXTRA_PREPARE_FOR_RENAME:
     DBUG_RETURN(prepare_for_rename());
+  case HA_EXTRA_PREPARE_FOR_DROP:
+    DBUG_RETURN(prepare_for_drop());
   case HA_EXTRA_NORMAL:
   case HA_EXTRA_QUICK:
   case HA_EXTRA_NO_READCHECK:
   case HA_EXTRA_PREPARE_FOR_UPDATE:
   case HA_EXTRA_FORCE_REOPEN:
-  case HA_EXTRA_PREPARE_FOR_DROP:
   case HA_EXTRA_FLUSH_CACHE:
   {
     if (m_myisam)
@@ -5104,7 +5105,7 @@ void ha_partition::prepare_extra_cache(u
 
 
 /*
-  Prepares our new and reorged handlers for rename or delete
+  Prepares our new and reorged handlers for rename
 
   SYNOPSIS
     prepare_for_delete()
@@ -5134,6 +5135,37 @@ int ha_partition::prepare_for_rename()
   DBUG_RETURN(loop_extra(HA_EXTRA_PREPARE_FOR_RENAME));
 }
 
+
+/**
+  Send extra call to all files that will be droped based on reorg
+
+  SYNOPSIS
+    prepare_for_drop()
+
+  RETURN VALUE
+    >0                    Error code
+    0                     Success
+*/
+
+int ha_partition::prepare_for_drop()
+{
+  int result= 0, tmp;
+  handler **file;
+  DBUG_ENTER("ha_partition::prepare_for_drop()");
+  
+  /* If alter table */
+  if (m_new_file != NULL)
+  {
+    /* Signal drop for all parts that will be dropped */
+    for (file= m_reorged_file; *file; file++)
+      if ((tmp= (*file)->extra(HA_EXTRA_PREPARE_FOR_DROP)))
+        result= tmp;   
+    DBUG_RETURN(result);   
+  }
+  DBUG_RETURN(loop_extra(HA_EXTRA_PREPARE_FOR_DROP));
+}
+
+
 /*
   Call extra on all partitions
 
@@ -5153,8 +5185,8 @@ int ha_partition::loop_extra(enum ha_ext
   DBUG_ENTER("ha_partition::loop_extra()");
   
   /* 
-    TODO, 5.2: this is where you could possibly add optimisations to add the bitmap
-    _if_ a SELECT.
+    TODO, 5.2: this is where you could possibly add optimisations to add the
+    bitmap _if_ a SELECT.
   */
   for (file= m_file; *file; file++)
   {

=== modified file 'sql/ha_partition.h'
--- a/sql/ha_partition.h	2008-05-29 18:39:25 +0000
+++ b/sql/ha_partition.h	2008-10-04 16:35:21 +0000
@@ -212,6 +212,7 @@ public:
   virtual void change_table_ptr(TABLE *table_arg, TABLE_SHARE *share);
 private:
   int prepare_for_rename();
+  int prepare_for_drop();
   int copy_partitions(ulonglong *copied, ulonglong *deleted);
   void cleanup_new_partition(uint part_count);
   int prepare_new_partition(TABLE *table, HA_CREATE_INFO *create_info,

Thread
bzr commit into MySQL/Maria:mysql-maria branch (monty:2671) Bug#39227Michael Widenius4 Oct