diff --git a/mysql-test/r/bug53588.result b/mysql-test/r/bug53588.result new file mode 100644 index 0000000..2510ad7 --- /dev/null +++ b/mysql-test/r/bug53588.result @@ -0,0 +1,5 @@ +CREATE TABLE `t` ( +`a` varchar(750) NOT NULL default '', +PRIMARY KEY (`a`) +) ENGINE=BLACKHOLE; +DROP TABLE `t`; diff --git a/mysql-test/t/bug53588.test b/mysql-test/t/bug53588.test new file mode 100644 index 0000000..112e145 --- /dev/null +++ b/mysql-test/t/bug53588.test @@ -0,0 +1,23 @@ +# +# Bug 53588 test case. +# +# Create long enough index (between 1000 and 3500). 1000 is the old value, +# 3500 is innodb value (see ha_innobase::max_supported_key_length()). Without +# the fix the test will fail with "Specified key was too long" error. +# +# For 8.0 the actual key length is counted as a value from statement, +# multiplied by the maximum symbol lenght of the key's charset. +# +--source include/have_blackhole.inc + +# As default test charset is UTF-8 with 4-byte maximum symbol length, the `a` +# key length will be multiplied by 4 (750*4 = 3000) and compared with what +# blackhole storage engine returns from +# ha_blackhole::max_supported_key_length(), that is why we need to reduce +# the initial key length (3000) by 4 times to pass the test. +CREATE TABLE `t` ( + `a` varchar(750) NOT NULL default '', + PRIMARY KEY (`a`) +) ENGINE=BLACKHOLE; + +DROP TABLE `t`; diff --git a/storage/blackhole/ha_blackhole.h b/storage/blackhole/ha_blackhole.h index 4fb22bc..4deadbb 100644 --- a/storage/blackhole/ha_blackhole.h +++ b/storage/blackhole/ha_blackhole.h @@ -19,6 +19,7 @@ #include "my_inttypes.h" #include "table.h" /* TABLE_SHARE */ #include "thr_lock.h" /* THR_LOCK */ +#include "sql_const.h" /* MAX_KEY */ /* Shared structure for correct LOCK operation @@ -65,9 +66,9 @@ public: HA_READ_ORDER | HA_KEYREAD_ONLY); } /* The following defines can be increased if necessary */ -#define BLACKHOLE_MAX_KEY 64 /* Max allowed keys */ +#define BLACKHOLE_MAX_KEY MAX_KEY /* Max allowed keys */ #define BLACKHOLE_MAX_KEY_SEG 16 /* Max segments for key */ -#define BLACKHOLE_MAX_KEY_LENGTH 1000 +#define BLACKHOLE_MAX_KEY_LENGTH 3500 /* Like in InnoDB */ uint max_supported_keys() const { return BLACKHOLE_MAX_KEY; } uint max_supported_key_length() const { return BLACKHOLE_MAX_KEY_LENGTH; } uint max_supported_key_part_length() const { return BLACKHOLE_MAX_KEY_LENGTH; }