mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-23852 alter table rename column to uppercase doesn't work
Case-sensitive compare to detect column name case change in inplace alter rename.
This commit is contained in:
@ -3322,5 +3322,28 @@ Note 1176 Key 'x' doesn't exist in table 't1'
|
|||||||
unlock tables;
|
unlock tables;
|
||||||
drop table t1;
|
drop table t1;
|
||||||
#
|
#
|
||||||
|
# MDEV-23852 alter table rename column to uppercase doesn't work
|
||||||
|
#
|
||||||
|
create table t1 (abc int);
|
||||||
|
alter table t1 rename column abc to Abc, algorithm=copy;
|
||||||
|
show create table t1;
|
||||||
|
Table Create Table
|
||||||
|
t1 CREATE TABLE `t1` (
|
||||||
|
`Abc` int(11) DEFAULT NULL
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||||
|
alter table t1 rename column abc to ABc, algorithm=inplace;
|
||||||
|
show create table t1;
|
||||||
|
Table Create Table
|
||||||
|
t1 CREATE TABLE `t1` (
|
||||||
|
`ABc` int(11) DEFAULT NULL
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||||
|
alter table t1 rename column abc to ABC;
|
||||||
|
show create table t1;
|
||||||
|
Table Create Table
|
||||||
|
t1 CREATE TABLE `t1` (
|
||||||
|
`ABC` int(11) DEFAULT NULL
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||||
|
drop table t1;
|
||||||
|
#
|
||||||
# End of 10.5 tests
|
# End of 10.5 tests
|
||||||
#
|
#
|
||||||
|
@ -2529,6 +2529,18 @@ alter table t1 rename key if exists x to xx;
|
|||||||
unlock tables;
|
unlock tables;
|
||||||
drop table t1;
|
drop table t1;
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-23852 alter table rename column to uppercase doesn't work
|
||||||
|
--echo #
|
||||||
|
create table t1 (abc int);
|
||||||
|
alter table t1 rename column abc to Abc, algorithm=copy;
|
||||||
|
show create table t1;
|
||||||
|
alter table t1 rename column abc to ABc, algorithm=inplace;
|
||||||
|
show create table t1;
|
||||||
|
alter table t1 rename column abc to ABC;
|
||||||
|
show create table t1;
|
||||||
|
drop table t1;
|
||||||
|
|
||||||
--echo #
|
--echo #
|
||||||
--echo # End of 10.5 tests
|
--echo # End of 10.5 tests
|
||||||
--echo #
|
--echo #
|
||||||
|
@ -738,7 +738,7 @@ Table Create Table
|
|||||||
t2 CREATE TABLE `t2` (
|
t2 CREATE TABLE `t2` (
|
||||||
`C2` int(11) DEFAULT NULL,
|
`C2` int(11) DEFAULT NULL,
|
||||||
KEY `c2` (`C2`),
|
KEY `c2` (`C2`),
|
||||||
CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`c2`) REFERENCES `t1` (`c1`)
|
CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`C2`) REFERENCES `t1` (`C1`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||||
ALTER TABLE t1 CHANGE COLUMN C1 c5 INT;
|
ALTER TABLE t1 CHANGE COLUMN C1 c5 INT;
|
||||||
ALTER TABLE t2 CHANGE COLUMN C2 c6 INT;
|
ALTER TABLE t2 CHANGE COLUMN C2 c6 INT;
|
||||||
@ -785,7 +785,7 @@ SELECT C.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS C INNER JOIN
|
|||||||
INFORMATION_SCHEMA.INNODB_SYS_TABLES T ON C.TABLE_ID=T.TABLE_ID
|
INFORMATION_SCHEMA.INNODB_SYS_TABLES T ON C.TABLE_ID=T.TABLE_ID
|
||||||
WHERE T.NAME='test/t1';
|
WHERE T.NAME='test/t1';
|
||||||
NAME
|
NAME
|
||||||
a
|
A
|
||||||
b
|
b
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
# different FOREIGN KEY cases
|
# different FOREIGN KEY cases
|
||||||
@ -842,27 +842,27 @@ t2 CREATE TABLE `t2` (
|
|||||||
KEY `bb` (`BB`),
|
KEY `bb` (`BB`),
|
||||||
KEY `CC` (`CC`),
|
KEY `CC` (`CC`),
|
||||||
KEY `DD` (`DD`),
|
KEY `DD` (`DD`),
|
||||||
CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`aa`) REFERENCES `t1` (`a`),
|
CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`AA`) REFERENCES `t1` (`A`),
|
||||||
CONSTRAINT `t2_ibfk_2` FOREIGN KEY (`bb`) REFERENCES `t1` (`b`),
|
CONSTRAINT `t2_ibfk_2` FOREIGN KEY (`BB`) REFERENCES `t1` (`B`),
|
||||||
CONSTRAINT `t2_ibfk_3` FOREIGN KEY (`cc`) REFERENCES `t1` (`c`),
|
CONSTRAINT `t2_ibfk_3` FOREIGN KEY (`CC`) REFERENCES `t1` (`C`),
|
||||||
CONSTRAINT `t2_ibfk_4` FOREIGN KEY (`dd`) REFERENCES `t1` (`d`)
|
CONSTRAINT `t2_ibfk_4` FOREIGN KEY (`DD`) REFERENCES `t1` (`D`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||||
DELETE FROM t1 WHERE a=1;
|
DELETE FROM t1 WHERE a=1;
|
||||||
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`aa`) REFERENCES `t1` (`a`))
|
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`AA`) REFERENCES `t1` (`A`))
|
||||||
DELETE FROM t1 WHERE A=1;
|
DELETE FROM t1 WHERE A=1;
|
||||||
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`aa`) REFERENCES `t1` (`a`))
|
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`AA`) REFERENCES `t1` (`A`))
|
||||||
DELETE FROM t1 WHERE b=1;
|
DELETE FROM t1 WHERE b=1;
|
||||||
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`aa`) REFERENCES `t1` (`a`))
|
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`AA`) REFERENCES `t1` (`A`))
|
||||||
DELETE FROM t1 WHERE B=1;
|
DELETE FROM t1 WHERE B=1;
|
||||||
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`aa`) REFERENCES `t1` (`a`))
|
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`AA`) REFERENCES `t1` (`A`))
|
||||||
DELETE FROM t1 WHERE c=1;
|
DELETE FROM t1 WHERE c=1;
|
||||||
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`aa`) REFERENCES `t1` (`a`))
|
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`AA`) REFERENCES `t1` (`A`))
|
||||||
DELETE FROM t1 WHERE C=1;
|
DELETE FROM t1 WHERE C=1;
|
||||||
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`aa`) REFERENCES `t1` (`a`))
|
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`AA`) REFERENCES `t1` (`A`))
|
||||||
DELETE FROM t1 WHERE d=1;
|
DELETE FROM t1 WHERE d=1;
|
||||||
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`aa`) REFERENCES `t1` (`a`))
|
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`AA`) REFERENCES `t1` (`A`))
|
||||||
DELETE FROM t1 WHERE D=1;
|
DELETE FROM t1 WHERE D=1;
|
||||||
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`aa`) REFERENCES `t1` (`a`))
|
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`AA`) REFERENCES `t1` (`A`))
|
||||||
DROP TABLE t2, t1;
|
DROP TABLE t2, t1;
|
||||||
# virtual columns case too
|
# virtual columns case too
|
||||||
CREATE TABLE t1 (a INT, b INT GENERATED ALWAYS AS (a) VIRTUAL) ENGINE = InnoDB;
|
CREATE TABLE t1 (a INT, b INT GENERATED ALWAYS AS (a) VIRTUAL) ENGINE = InnoDB;
|
||||||
@ -877,7 +877,7 @@ SELECT C.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS C INNER JOIN
|
|||||||
INFORMATION_SCHEMA.INNODB_SYS_TABLES T ON C.TABLE_ID=T.TABLE_ID
|
INFORMATION_SCHEMA.INNODB_SYS_TABLES T ON C.TABLE_ID=T.TABLE_ID
|
||||||
WHERE T.NAME='test/t1';
|
WHERE T.NAME='test/t1';
|
||||||
NAME
|
NAME
|
||||||
a
|
A
|
||||||
b
|
b
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
# and an MDEV-18041 regression related to indexes prefixes
|
# and an MDEV-18041 regression related to indexes prefixes
|
||||||
|
@ -7171,9 +7171,8 @@ static bool fill_alter_inplace_info(THD *thd, TABLE *table, bool varchar,
|
|||||||
ha_alter_info->handler_flags|= ALTER_STORED_COLUMN_TYPE;
|
ha_alter_info->handler_flags|= ALTER_STORED_COLUMN_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if field was renamed */
|
/* Check if field was renamed (case-sensitive for detecting case change) */
|
||||||
if (lex_string_cmp(system_charset_info, &field->field_name,
|
if (cmp(&field->field_name, &new_field->field_name))
|
||||||
&new_field->field_name))
|
|
||||||
{
|
{
|
||||||
field->flags|= FIELD_IS_RENAMED;
|
field->flags|= FIELD_IS_RENAMED;
|
||||||
ha_alter_info->handler_flags|= ALTER_COLUMN_NAME;
|
ha_alter_info->handler_flags|= ALTER_COLUMN_NAME;
|
||||||
|
Reference in New Issue
Block a user