List:Internals« Previous MessageNext Message »
From:Lu Jingdong Date:January 4 2008 7:33am
Subject:Patch for bug #33429
View as plain text  
I did some test and server crashed.

mysql> CREATE TABLE t (id int unsigned) ENGINE=InnoDB  PARTITION BY RANGE (id)
    ->           (PARTITION p0 VALUES LESS THAN (10) ENGINE = InnoDB,
    ->            PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = InnoDB);
Query OK, 0 rows affected (0.06 sec)

mysql> alter table t add partition (partition p2 values less than (100));
Query OK, 0 rows affected (0.10 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> show create table t\G
ERROR 2013 (HY000): Lost connection to MySQL server during query

I think we should make sure that MAXVALUE is used in last partition definition. Otherwise
it will get an error result from the function of "partition_info::check_range_constants"
if we use "unsigned int" type during executing the "alter table ... add partition ..."
operation. I give a patch and test result as following.

The patch:
--- sql/sql_partition.cc.orig   2008-01-04 11:06:08.000000000 +0800
+++ sql/sql_partition.cc        2008-01-04 13:53:51.786227232 +0800
@@ -4313,6 +4313,11 @@
       {
         DBUG_RETURN(TRUE);
       }
+      if (tab_part_info->defined_max_value)
+      {
+        my_error(ER_PARTITION_MAXVALUE_ERROR, MYF(0));
+        DBUG_RETURN(TRUE);
+      }
 /*
 Handling of on-line cases:

Test result:
mysql> CREATE TABLE `t` (
    ->        `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
    ->        `lastcomment` int(10) unsigned NOT NULL DEFAULT '0',
    ->        PRIMARY KEY (`id`)
    ->      ) ENGINE=InnoDB AUTO_INCREMENT=88134 DEFAULT CHARSET=utf8 /*!50100
PARTITION
BY
    -> RANGE (id)
    ->      (PARTITION p0 VALUES LESS THAN (88134) ENGINE = InnoDB, PARTITION p1 VALUES
LESS
    -> THAN
    ->      (96695) ENGINE = InnoDB, PARTITION p2 VALUES LESS THAN MAXVALUE ENGINE =
InnoDB)
    -> */;
Query OK, 0 rows affected (0.08 sec)

mysql>
mysql> ALTER TABLE `t` DROP PARTITION p1;
Query OK, 0 rows affected (0.08 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> ALTER TABLE `t` ADD PARTITION (PARTITION p1 VALUES LESS THAN (179721));
ERROR 1478 (HY000): MAXVALUE can only be used in last partition definition

mysql> SELECT COUNT(id) FROM t;
+-----------+
| COUNT(id) |
+-----------+
|         0 |
+-----------+
1 row in set (0.06 sec)

Thread
Patch for bug #33429Lu Jingdong4 Jan