Commit 82196f01 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-11995 ALTER TABLE proceeds despite reporting ER_TOO_LONG_KEY error

automatic shortening of a too-long non-unique key should
be not a warning, but a note. It's a normal optimization,
doesn't affect correctness, and should never be converted to
an error, no matter how strict sql_mode is.
parent 30cbbfbf
......@@ -2387,7 +2387,7 @@ PRIMARY KEY (clipid),
KEY tape(Tape(255))
) CHARACTER SET=utf8mb4;
Warnings:
Warning 1071 Specified key was too long; max key length is 1000 bytes
Note 1071 Specified key was too long; max key length is 1000 bytes
ALTER TABLE t1 ADD mos TINYINT DEFAULT 0 AFTER clipid;
SHOW CREATE TABLE t1;
Table Create Table
......
......@@ -2347,7 +2347,7 @@ PRIMARY KEY (clipid),
KEY tape(Tape(255))
) CHARACTER SET=utf8mb4 ENGINE InnoDB;
Warnings:
Warning 1071 Specified key was too long; max key length is 767 bytes
Note 1071 Specified key was too long; max key length is 767 bytes
ALTER TABLE t1 ADD mos TINYINT DEFAULT 0 AFTER clipid;
SHOW CREATE TABLE t1;
Table Create Table
......
......@@ -2347,7 +2347,7 @@ PRIMARY KEY (clipid),
KEY tape(Tape(255))
) CHARACTER SET=utf8mb4 ENGINE MyISAM;
Warnings:
Warning 1071 Specified key was too long; max key length is 1000 bytes
Note 1071 Specified key was too long; max key length is 1000 bytes
ALTER TABLE t1 ADD mos TINYINT DEFAULT 0 AFTER clipid;
SHOW CREATE TABLE t1;
Table Create Table
......
......@@ -373,7 +373,7 @@ create table t1 (a text, unique (a(2100)));
ERROR 42000: Specified key was too long; max key length is 1000 bytes
create table t1 (a text, key (a(2100)));
Warnings:
Warning 1071 Specified key was too long; max key length is 1000 bytes
Note 1071 Specified key was too long; max key length is 1000 bytes
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
......
set @@sql_mode=strict_trans_tables;
create table t1(a text not null) row_format=dynamic engine=innodb;
create index idx1 on t1(a(3073));
Warnings:
Note 1071 Specified key was too long; max key length is 3072 bytes
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
KEY `idx1` (`a`(3072))
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC
drop table t1;
set @@sql_mode=default;
......@@ -2543,11 +2543,11 @@ Warning 1071 Specified key was too long; max key length is 767 bytes
create table t3 (col1 text, index(col1(768)))
character set = latin1 engine = innodb;
Warnings:
Warning 1071 Specified key was too long; max key length is 767 bytes
Note 1071 Specified key was too long; max key length is 767 bytes
create table t4 (col1 blob, index(col1(768)))
character set = latin1 engine = innodb;
Warnings:
Warning 1071 Specified key was too long; max key length is 767 bytes
Note 1071 Specified key was too long; max key length is 767 bytes
SET GLOBAL innodb_large_prefix=default;
Warnings:
Warning 131 Using innodb_large_prefix is deprecated and the parameter may be removed in future releases. See http://dev.mysql.com/doc/refman/5.7/en/innodb-file-format.html
......
--source include/have_innodb.inc
#
# MDEV-11995 ALTER TABLE proceeds despite reporting ER_TOO_LONG_KEY error
#
set @@sql_mode=strict_trans_tables;
create table t1(a text not null) row_format=dynamic engine=innodb;
create index idx1 on t1(a(3073));
show create table t1;
drop table t1;
set @@sql_mode=default;
......@@ -101,7 +101,7 @@ create index idx1 on worklog5743_1(a2(4000));
Got one of the listed errors
show warnings;
Level Code Message
Error 1071 Specified key was too long; max key length is 767 bytes
Note 1071 Specified key was too long; max key length is 767 bytes
Error 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs
set global innodb_large_prefix=1;
Warnings:
......@@ -110,7 +110,7 @@ create index idx2 on worklog5743_1(a2(4000));
Got one of the listed errors
show warnings;
Level Code Message
Error 1071 Specified key was too long; max key length is 3072 bytes
Note 1071 Specified key was too long; max key length is 3072 bytes
Error 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs
create index idx3 on worklog5743_1(a2(436));
ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs
......@@ -134,10 +134,10 @@ Warning 131 Using innodb_large_prefix is deprecated and the parameter may be rem
SET sql_mode= '';
create index idx1 on worklog5743_2(a2(4000));
Warnings:
Warning 1071 Specified key was too long; max key length is 767 bytes
Note 1071 Specified key was too long; max key length is 767 bytes
show warnings;
Level Code Message
Warning 1071 Specified key was too long; max key length is 767 bytes
Note 1071 Specified key was too long; max key length is 767 bytes
set global innodb_large_prefix=1;
Warnings:
Warning 131 Using innodb_large_prefix is deprecated and the parameter may be removed in future releases. See http://dev.mysql.com/doc/refman/5.7/en/innodb-file-format.html
......@@ -145,7 +145,7 @@ create index idx2 on worklog5743_2(a2(4000));
ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs
show warnings;
Level Code Message
Warning 1071 Specified key was too long; max key length is 3072 bytes
Note 1071 Specified key was too long; max key length is 3072 bytes
Error 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs
create index idx3 on worklog5743_2(a2(948));
ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs
......@@ -168,10 +168,10 @@ Warnings:
Warning 131 Using innodb_large_prefix is deprecated and the parameter may be removed in future releases. See http://dev.mysql.com/doc/refman/5.7/en/innodb-file-format.html
create index idx1 on worklog5743_4(a2(4000));
Warnings:
Warning 1071 Specified key was too long; max key length is 767 bytes
Note 1071 Specified key was too long; max key length is 767 bytes
show warnings;
Level Code Message
Warning 1071 Specified key was too long; max key length is 767 bytes
Note 1071 Specified key was too long; max key length is 767 bytes
set global innodb_large_prefix=1;
Warnings:
Warning 131 Using innodb_large_prefix is deprecated and the parameter may be removed in future releases. See http://dev.mysql.com/doc/refman/5.7/en/innodb-file-format.html
......@@ -179,7 +179,7 @@ create index idx2 on worklog5743_4(a2(4000));
ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs
show warnings;
Level Code Message
Warning 1071 Specified key was too long; max key length is 3072 bytes
Note 1071 Specified key was too long; max key length is 3072 bytes
Error 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs
create index idx3 on worklog5743_4(a2(1972));
ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs
......@@ -202,19 +202,19 @@ Warnings:
Warning 131 Using innodb_large_prefix is deprecated and the parameter may be removed in future releases. See http://dev.mysql.com/doc/refman/5.7/en/innodb-file-format.html
create index idx1 on worklog5743_8(a2(1000));
Warnings:
Warning 1071 Specified key was too long; max key length is 767 bytes
Note 1071 Specified key was too long; max key length is 767 bytes
show warnings;
Level Code Message
Warning 1071 Specified key was too long; max key length is 767 bytes
Note 1071 Specified key was too long; max key length is 767 bytes
set global innodb_large_prefix=1;
Warnings:
Warning 131 Using innodb_large_prefix is deprecated and the parameter may be removed in future releases. See http://dev.mysql.com/doc/refman/5.7/en/innodb-file-format.html
create index idx2 on worklog5743_8(a2(3073));
Warnings:
Warning 1071 Specified key was too long; max key length is 3072 bytes
Note 1071 Specified key was too long; max key length is 3072 bytes
show warnings;
Level Code Message
Warning 1071 Specified key was too long; max key length is 3072 bytes
Note 1071 Specified key was too long; max key length is 3072 bytes
create index idx3 on worklog5743_8(a2(3072));
Warnings:
Note 1831 Duplicate index `idx3`. This is deprecated and will be disallowed in a future release
......@@ -242,19 +242,19 @@ Warnings:
Warning 131 Using innodb_large_prefix is deprecated and the parameter may be removed in future releases. See http://dev.mysql.com/doc/refman/5.7/en/innodb-file-format.html
create index idx1 on worklog5743_16(a2(1000));
Warnings:
Warning 1071 Specified key was too long; max key length is 767 bytes
Note 1071 Specified key was too long; max key length is 767 bytes
show warnings;
Level Code Message
Warning 1071 Specified key was too long; max key length is 767 bytes
Note 1071 Specified key was too long; max key length is 767 bytes
set global innodb_large_prefix=1;
Warnings:
Warning 131 Using innodb_large_prefix is deprecated and the parameter may be removed in future releases. See http://dev.mysql.com/doc/refman/5.7/en/innodb-file-format.html
create index idx2 on worklog5743_16(a2(3073));
Warnings:
Warning 1071 Specified key was too long; max key length is 3072 bytes
Note 1071 Specified key was too long; max key length is 3072 bytes
show warnings;
Level Code Message
Warning 1071 Specified key was too long; max key length is 3072 bytes
Note 1071 Specified key was too long; max key length is 3072 bytes
create index idx3 on worklog5743_16(a2(3072));
Warnings:
Note 1831 Duplicate index `idx3`. This is deprecated and will be disallowed in a future release
......@@ -508,7 +508,7 @@ create table worklog5743(a TEXT not null) ROW_FORMAT=DYNAMIC;
SET sql_mode='';
create index idx1 on worklog5743(a(3073));
Warnings:
Warning 1071 Specified key was too long; max key length is 3072 bytes
Note 1071 Specified key was too long; max key length is 3072 bytes
create index idx2 on worklog5743(a(3072));
Warnings:
Note 1831 Duplicate index `idx2`. This is deprecated and will be disallowed in a future release
......
......@@ -106,7 +106,7 @@ create index idx1 on worklog5743_1(a2(4000));
ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs
show warnings;
Level Code Message
Warning 1071 Specified key was too long; max key length is 767 bytes
Note 1071 Specified key was too long; max key length is 767 bytes
Error 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs
set global innodb_large_prefix=1;
Warnings:
......@@ -115,7 +115,7 @@ create index idx2 on worklog5743_1(a2(4000));
ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs
show warnings;
Level Code Message
Warning 1071 Specified key was too long; max key length is 3072 bytes
Note 1071 Specified key was too long; max key length is 3072 bytes
Error 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs
create index idx3 on worklog5743_1(a2(436));
ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs
......@@ -138,10 +138,10 @@ Warnings:
Warning 131 Using innodb_large_prefix is deprecated and the parameter may be removed in future releases. See http://dev.mysql.com/doc/refman/5.7/en/innodb-file-format.html
create index idx1 on worklog5743_2(a2(4000));
Warnings:
Warning 1071 Specified key was too long; max key length is 767 bytes
Note 1071 Specified key was too long; max key length is 767 bytes
show warnings;
Level Code Message
Warning 1071 Specified key was too long; max key length is 767 bytes
Note 1071 Specified key was too long; max key length is 767 bytes
set global innodb_large_prefix=1;
Warnings:
Warning 131 Using innodb_large_prefix is deprecated and the parameter may be removed in future releases. See http://dev.mysql.com/doc/refman/5.7/en/innodb-file-format.html
......@@ -149,7 +149,7 @@ create index idx2 on worklog5743_2(a2(4000));
ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs
show warnings;
Level Code Message
Warning 1071 Specified key was too long; max key length is 3072 bytes
Note 1071 Specified key was too long; max key length is 3072 bytes
Error 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs
create index idx3 on worklog5743_2(a2(948));
ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs
......@@ -172,10 +172,10 @@ Warnings:
Warning 131 Using innodb_large_prefix is deprecated and the parameter may be removed in future releases. See http://dev.mysql.com/doc/refman/5.7/en/innodb-file-format.html
create index idx1 on worklog5743_4(a2(4000));
Warnings:
Warning 1071 Specified key was too long; max key length is 767 bytes
Note 1071 Specified key was too long; max key length is 767 bytes
show warnings;
Level Code Message
Warning 1071 Specified key was too long; max key length is 767 bytes
Note 1071 Specified key was too long; max key length is 767 bytes
set global innodb_large_prefix=1;
Warnings:
Warning 131 Using innodb_large_prefix is deprecated and the parameter may be removed in future releases. See http://dev.mysql.com/doc/refman/5.7/en/innodb-file-format.html
......@@ -183,7 +183,7 @@ create index idx2 on worklog5743_4(a2(4000));
ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs
show warnings;
Level Code Message
Warning 1071 Specified key was too long; max key length is 3072 bytes
Note 1071 Specified key was too long; max key length is 3072 bytes
Error 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs
create index idx3 on worklog5743_4(a2(1972));
ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs
......@@ -206,19 +206,19 @@ Warnings:
Warning 131 Using innodb_large_prefix is deprecated and the parameter may be removed in future releases. See http://dev.mysql.com/doc/refman/5.7/en/innodb-file-format.html
create index idx1 on worklog5743_8(a2(1000));
Warnings:
Warning 1071 Specified key was too long; max key length is 767 bytes
Note 1071 Specified key was too long; max key length is 767 bytes
show warnings;
Level Code Message
Warning 1071 Specified key was too long; max key length is 767 bytes
Note 1071 Specified key was too long; max key length is 767 bytes
set global innodb_large_prefix=1;
Warnings:
Warning 131 Using innodb_large_prefix is deprecated and the parameter may be removed in future releases. See http://dev.mysql.com/doc/refman/5.7/en/innodb-file-format.html
create index idx2 on worklog5743_8(a2(3073));
Warnings:
Warning 1071 Specified key was too long; max key length is 3072 bytes
Note 1071 Specified key was too long; max key length is 3072 bytes
show warnings;
Level Code Message
Warning 1071 Specified key was too long; max key length is 3072 bytes
Note 1071 Specified key was too long; max key length is 3072 bytes
create index idx3 on worklog5743_8(a2(3072));
Warnings:
Note 1831 Duplicate index `idx3`. This is deprecated and will be disallowed in a future release
......@@ -246,19 +246,19 @@ Warnings:
Warning 131 Using innodb_large_prefix is deprecated and the parameter may be removed in future releases. See http://dev.mysql.com/doc/refman/5.7/en/innodb-file-format.html
create index idx1 on worklog5743_16(a2(1000));
Warnings:
Warning 1071 Specified key was too long; max key length is 767 bytes
Note 1071 Specified key was too long; max key length is 767 bytes
show warnings;
Level Code Message
Warning 1071 Specified key was too long; max key length is 767 bytes
Note 1071 Specified key was too long; max key length is 767 bytes
set global innodb_large_prefix=1;
Warnings:
Warning 131 Using innodb_large_prefix is deprecated and the parameter may be removed in future releases. See http://dev.mysql.com/doc/refman/5.7/en/innodb-file-format.html
create index idx2 on worklog5743_16(a2(3073));
Warnings:
Warning 1071 Specified key was too long; max key length is 3072 bytes
Note 1071 Specified key was too long; max key length is 3072 bytes
show warnings;
Level Code Message
Warning 1071 Specified key was too long; max key length is 3072 bytes
Note 1071 Specified key was too long; max key length is 3072 bytes
create index idx3 on worklog5743_16(a2(3072));
Warnings:
Note 1831 Duplicate index `idx3`. This is deprecated and will be disallowed in a future release
......@@ -510,7 +510,7 @@ create table worklog5743(a TEXT not null) ROW_FORMAT=DYNAMIC;
set statement sql_mode = '' for
create index idx1 on worklog5743(a(3073));
Warnings:
Warning 1071 Specified key was too long; max key length is 3072 bytes
Note 1071 Specified key was too long; max key length is 3072 bytes
create index idx2 on worklog5743(a(3072));
Warnings:
Note 1831 Duplicate index `idx2`. This is deprecated and will be disallowed in a future release
......
......@@ -3949,7 +3949,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
if (key->type == Key::MULTIPLE)
{
/* not a critical problem */
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE,
ER_TOO_LONG_KEY,
ER_THD(thd, ER_TOO_LONG_KEY),
key_part_length);
......
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