Commit 9b23f805 authored by Jan Lindström's avatar Jan Lindström

MDEV-10535: ALTER TABLE causes standalone/wsrep cluster crash

When checking is any of the renamed columns part of the
columns for new indexes we accessed NULL pointer if checked
column used on index was added on same statement. Additionally,
we tried to check too many indexes, added_index_count
is enough here.
parent b3df257c
......@@ -135,3 +135,53 @@ child CREATE TABLE `child` (
CONSTRAINT `child_ibfk_1` FOREIGN KEY (`c`) REFERENCES `parent` (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
DROP TABLE child, parent;
CREATE TABLE IF NOT EXISTS ticket (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
mask VARCHAR(16) DEFAULT '' NOT NULL,
subject VARCHAR(255) DEFAULT '' NOT NULL,
is_closed TINYINT(1) UNSIGNED DEFAULT 0 NOT NULL,
is_deleted TINYINT(1) UNSIGNED DEFAULT 0 NOT NULL,
team_id INT UNSIGNED DEFAULT 0 NOT NULL,
category_id INT UNSIGNED DEFAULT 0 NOT NULL,
first_message_id INT UNSIGNED DEFAULT 0 NOT NULL,
created_date INT UNSIGNED,
updated_date INT UNSIGNED,
due_date INT UNSIGNED,
first_wrote_address_id INT UNSIGNED NOT NULL DEFAULT 0,
last_wrote_address_id INT UNSIGNED NOT NULL DEFAULT 0,
spam_score DECIMAL(4,4) NOT NULL DEFAULT 0,
spam_training VARCHAR(1) NOT NULL DEFAULT '',
interesting_words VARCHAR(255) NOT NULL DEFAULT '',
next_action VARCHAR(255) NOT NULL DEFAULT '',
PRIMARY KEY (id)
) ENGINE=InnoDB;
ALTER TABLE ticket
CHANGE COLUMN team_id group_id INT UNSIGNED NOT NULL DEFAULT 0,
CHANGE COLUMN category_id bucket_id INT UNSIGNED NOT NULL DEFAULT 0,
ADD COLUMN org_id INT UNSIGNED NOT NULL DEFAULT 0,
ADD INDEX org_id (org_id);
SHOW CREATE TABLE ticket;
Table Create Table
ticket CREATE TABLE `ticket` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`mask` varchar(16) NOT NULL DEFAULT '',
`subject` varchar(255) NOT NULL DEFAULT '',
`is_closed` tinyint(1) unsigned NOT NULL DEFAULT '0',
`is_deleted` tinyint(1) unsigned NOT NULL DEFAULT '0',
`group_id` int(10) unsigned NOT NULL DEFAULT '0',
`bucket_id` int(10) unsigned NOT NULL DEFAULT '0',
`first_message_id` int(10) unsigned NOT NULL DEFAULT '0',
`created_date` int(10) unsigned DEFAULT NULL,
`updated_date` int(10) unsigned DEFAULT NULL,
`due_date` int(10) unsigned DEFAULT NULL,
`first_wrote_address_id` int(10) unsigned NOT NULL DEFAULT '0',
`last_wrote_address_id` int(10) unsigned NOT NULL DEFAULT '0',
`spam_score` decimal(4,4) NOT NULL DEFAULT '0.0000',
`spam_training` varchar(1) NOT NULL DEFAULT '',
`interesting_words` varchar(255) NOT NULL DEFAULT '',
`next_action` varchar(255) NOT NULL DEFAULT '',
`org_id` int(10) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `org_id` (`org_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
DROP TABLE ticket;
......@@ -138,3 +138,36 @@ SHOW CREATE TABLE child;
DROP TABLE child, parent;
#
# MDEV-10535: ALTER TABLE causes standalone/wsrep cluster crash
#
CREATE TABLE IF NOT EXISTS ticket (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
mask VARCHAR(16) DEFAULT '' NOT NULL,
subject VARCHAR(255) DEFAULT '' NOT NULL,
is_closed TINYINT(1) UNSIGNED DEFAULT 0 NOT NULL,
is_deleted TINYINT(1) UNSIGNED DEFAULT 0 NOT NULL,
team_id INT UNSIGNED DEFAULT 0 NOT NULL,
category_id INT UNSIGNED DEFAULT 0 NOT NULL,
first_message_id INT UNSIGNED DEFAULT 0 NOT NULL,
created_date INT UNSIGNED,
updated_date INT UNSIGNED,
due_date INT UNSIGNED,
first_wrote_address_id INT UNSIGNED NOT NULL DEFAULT 0,
last_wrote_address_id INT UNSIGNED NOT NULL DEFAULT 0,
spam_score DECIMAL(4,4) NOT NULL DEFAULT 0,
spam_training VARCHAR(1) NOT NULL DEFAULT '',
interesting_words VARCHAR(255) NOT NULL DEFAULT '',
next_action VARCHAR(255) NOT NULL DEFAULT '',
PRIMARY KEY (id)
) ENGINE=InnoDB;
ALTER TABLE ticket
CHANGE COLUMN team_id group_id INT UNSIGNED NOT NULL DEFAULT 0,
CHANGE COLUMN category_id bucket_id INT UNSIGNED NOT NULL DEFAULT 0,
ADD COLUMN org_id INT UNSIGNED NOT NULL DEFAULT 0,
ADD INDEX org_id (org_id);
SHOW CREATE TABLE ticket;
DROP TABLE ticket;
......@@ -229,7 +229,7 @@ innobase_need_rebuild(
& Alter_inplace_info::ADD_INDEX) ||
(ha_alter_info->handler_flags
& Alter_inplace_info::ADD_FOREIGN_KEY))) {
for (ulint i = 0; i < ha_alter_info->key_count; i++) {
for (ulint i = 0; i < ha_alter_info->index_add_count; i++) {
const KEY* key = &ha_alter_info->key_info_buffer[
ha_alter_info->index_add_buffer[i]];
......@@ -240,7 +240,7 @@ innobase_need_rebuild(
/* Field used on added index is renamed on
this same alter table. We need table
rebuild. */
if (field->flags & FIELD_IS_RENAMED) {
if (field && field->flags & FIELD_IS_RENAMED) {
return (true);
}
}
......
......@@ -229,7 +229,7 @@ innobase_need_rebuild(
& Alter_inplace_info::ADD_INDEX) ||
(ha_alter_info->handler_flags
& Alter_inplace_info::ADD_FOREIGN_KEY))) {
for (ulint i = 0; i < ha_alter_info->key_count; i++) {
for (ulint i = 0; i < ha_alter_info->index_add_count; i++) {
const KEY* key = &ha_alter_info->key_info_buffer[
ha_alter_info->index_add_buffer[i]];
......@@ -240,7 +240,7 @@ innobase_need_rebuild(
/* Field used on added index is renamed on
this same alter table. We need table
rebuild. */
if (field->flags & FIELD_IS_RENAMED) {
if (field && field->flags & FIELD_IS_RENAMED) {
return (true);
}
}
......
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