3279 Mattias Jonsson 2011-01-26 [merge]
merge of bug 47902 and (null-merge) of bug 57924.
bug#57924 does not occur in 5.5, so I reverted the 5.1 specific
code and used the errors from 5.5 instead in the tests
modified:
client/mysqltest.cc
mysql-test/r/partition_error.result
mysql-test/t/partition_error.test
3278 Jon Olav Hauglid 2011-01-26
Bug #42230 during add index, cannot do queries on storage engines
that implement add_index
The problem was that ALTER TABLE blocked reads on an InnoDB table
while adding a secondary index, even if this was not needed. It is
only needed for the final step where the .frm file is updated.
The reason queries were blocked, was that ALTER TABLE upgraded the
metadata lock from MDL_SHARED_NO_WRITE (which blocks writes) to
MDL_EXCLUSIVE (which blocks all accesses) before index creation.
The way the server handles index creation, is that storage engines
publish their capabilities to the server and the server determines
which of the following three ways this can be handled: 1) build a
new version of the table; 2) change the existing table but with
exclusive metadata lock; 3) change the existing table but without
metadata lock upgrade.
For InnoDB and secondary index creation, option 3) should have been
selected. However this failed for two reasons. First, InnoDB did
not publish this capability properly.
Second, the ALTER TABLE code failed to made proper use of the
information supplied by the storage engine. A variable
need_lock_for_indexes was set accordingly, but was not later used.
This patch fixes this problem by only doing metadata lock upgrade
before index creation/deletion if this variable has been set.
This patch also changes some of the related terminology used
in the code. Specifically the use of "fast" and "online" with
respect to ALTER TABLE. "Fast" was used to indicate that an
ALTER TABLE operation could be done without involving a
temporary table. "Fast" has been renamed "in-place" to more
accurately describe the behavior.
"Online" meant that the operation could be done without taking
a table lock. However, in the current implementation writes
are always prohibited during ALTER TABLE and an exclusive
metadata lock is held while updating the .frm, so ALTER TABLE
is not completely online. This patch replaces "online" with
"in-place", with additional comments indicating if concurrent
reads are allowed during index creation/deletion or not.
An important part of this update of terminology is renaming
of the handler flags used by handlers to indicate if index
creation/deletion can be done in-place and if concurrent reads
are allowed. For example, the HA_ONLINE_ADD_INDEX_NO_WRITES
flag has been renamed to HA_INPLACE_ADD_INDEX_NO_READ_WRITE,
while HA_ONLINE_ADD_INDEX is now HA_INPLACE_ADD_INDEX_NO_WRITE.
Note that this is a rename to clarify current behavior, the
flag values have not changed and no flags have been removed or
added.
Test case added to innodb_mysql_sync.test.
modified:
mysql-test/r/innodb_mysql_sync.result
mysql-test/t/innodb_mysql_sync.test
sql/ha_partition.cc
sql/handler.h
sql/sql_table.cc
storage/innobase/handler/ha_innodb.cc
=== modified file 'client/mysqltest.cc'
--- a/client/mysqltest.cc 2011-01-18 10:21:37 +0000
+++ b/client/mysqltest.cc 2011-01-26 18:33:53 +0000
@@ -7555,8 +7555,12 @@ void run_query_stmt(MYSQL *mysql, struct
mysql_free_result(res); /* Free normal result set with meta data */
- /* Clear prepare warnings */
- dynstr_set(&ds_prepare_warnings, NULL);
+ /*
+ Clear prepare warnings if there are execute warnings,
+ since they are probably duplicated.
+ */
+ if (ds_execute_warnings.length || mysql->warning_count)
+ dynstr_set(&ds_prepare_warnings, NULL);
}
else
{
=== modified file 'mysql-test/r/partition_error.result'
--- a/mysql-test/r/partition_error.result 2011-01-10 14:08:31 +0000
+++ b/mysql-test/r/partition_error.result 2011-01-26 18:33:53 +0000
@@ -1,5 +1,18 @@
drop table if exists t1, t2;
#
+# Bug#57924: crash when creating partitioned table with
+# multiple columns in the partition key
+#
+CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a,b))
+PARTITION BY KEY(a, b, a);
+ERROR HY000: Duplicate partition field name 'a'
+CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a,b))
+PARTITION BY KEY(A, b);
+DROP TABLE t1;
+CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a,b))
+PARTITION BY KEY(a, b, A);
+ERROR HY000: Duplicate partition field name 'a'
+#
# Bug#54483: valgrind errors when making warnings for multiline inserts
# into partition
#
=== modified file 'mysql-test/t/partition_error.test'
--- a/mysql-test/t/partition_error.test 2011-01-10 14:08:31 +0000
+++ b/mysql-test/t/partition_error.test 2011-01-26 18:33:53 +0000
@@ -11,6 +11,21 @@ drop table if exists t1, t2;
let $MYSQLD_DATADIR= `SELECT @@datadir`;
--echo #
+--echo # Bug#57924: crash when creating partitioned table with
+--echo # multiple columns in the partition key
+--echo #
+--error ER_SAME_NAME_PARTITION_FIELD
+CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a,b))
+PARTITION BY KEY(a, b, a);
+CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a,b))
+PARTITION BY KEY(A, b);
+DROP TABLE t1;
+--error ER_SAME_NAME_PARTITION_FIELD
+CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a,b))
+PARTITION BY KEY(a, b, A);
+
+
+--echo #
--echo # Bug#54483: valgrind errors when making warnings for multiline inserts
--echo # into partition
--echo #
@@ -670,7 +685,6 @@ PARTITION BY HASH (TIME_TO_SEC(a));
CREATE TABLE t1 (a INT)
PARTITION BY HASH (TIME_TO_SEC(a));
-
--echo #
--echo # Bug#50036: Inconsistent errors when using TIMESTAMP
--echo # columns/expressions
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-5.5 branch (mattias.jonsson:3278 to 3279) | Mattias Jonsson | 26 Jan |