Commit 1c554459 authored by Monty's avatar Monty

MDEV-32449 Server crashes in Alter_info::add_stat_drop_index upon CREATE TABLE

Fixed missing initialization of Alter_info()

This could cause crashes in some create table like scenarios
where some generated indexes where automatically dropped.

I also added a test that we do not try to drop from index_stats for
temporary tables.
parent ec277a70
......@@ -3093,3 +3093,31 @@ drop table t1;
#
# End of 10.5 tests
#
#
# MDEV-32449 Server crashes in Alter_info::add_stat_drop_index upon CREATE TABLE
#
CREATE TABLE t1 (
`altcol1` blob DEFAULT '',
KEY `altcol1` (`altcol1`(2300))
) ROW_FORMAT=PAGE, ENGINE=Aria;
ALTER TABLE t1 ADD FOREIGN KEY h (`altcol1`) REFERENCES t1 (`altcol1`) ON UPDATE SET DEFAULT, ALGORITHM=COPY;
Warnings:
Note 1071 Specified key was too long; max key length is 2300 bytes
create or replace table t2 like t1;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`altcol1` blob DEFAULT '',
KEY `altcol1` (`altcol1`(2300)),
KEY `h` (`altcol1`(2300))
) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 ROW_FORMAT=PAGE
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`altcol1` blob DEFAULT '',
KEY `altcol1` (`altcol1`(2300))
) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 ROW_FORMAT=PAGE
drop table t1,t2;
#
# End of 10.6 tests
#
......@@ -2382,3 +2382,21 @@ drop table t1;
--echo #
--echo # End of 10.5 tests
--echo #
--echo #
--echo # MDEV-32449 Server crashes in Alter_info::add_stat_drop_index upon CREATE TABLE
--echo #
CREATE TABLE t1 (
`altcol1` blob DEFAULT '',
KEY `altcol1` (`altcol1`(2300))
) ROW_FORMAT=PAGE, ENGINE=Aria;
ALTER TABLE t1 ADD FOREIGN KEY h (`altcol1`) REFERENCES t1 (`altcol1`) ON UPDATE SET DEFAULT, ALGORITHM=COPY;
create or replace table t2 like t1;
show create table t1;
show create table t2;
drop table t1,t2;
--echo #
--echo # End of 10.6 tests
--echo #
......@@ -199,6 +199,7 @@ class Alter_info
Alter_info() :
flags(0), partition_flags(0),
keys_onoff(LEAVE_AS_IS),
original_table(0),
num_parts(0),
requested_algorithm(ALTER_TABLE_ALGORITHM_NONE),
requested_lock(ALTER_TABLE_LOCK_DEFAULT)
......
......@@ -2898,7 +2898,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
key_iterator.rewind();
while ((key=key_iterator++))
{
if (key->type == Key::IGNORE_KEY)
if (key->type == Key::IGNORE_KEY && !create_info->tmp_table())
{
/* The key was replaced by another key */
if (alter_info->add_stat_drop_index(thd, &key->name))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment