Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lp-1733049: Blackhole : Specified key was too long; max key length is… #15

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions mysql-test/r/bug53588.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CREATE TABLE `t` (
`a` varchar(750) NOT NULL default '',
PRIMARY KEY (`a`)
) ENGINE=BLACKHOLE;
DROP TABLE `t`;
23 changes: 23 additions & 0 deletions mysql-test/t/bug53588.test
Original file line number Diff line number Diff line change
@@ -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`;
5 changes: 3 additions & 2 deletions storage/blackhole/ha_blackhole.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -65,9 +66,9 @@ class ha_blackhole: public handler
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; }
Expand Down