mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 10:14:19 +01:00
Fixed lp:905716 "Assertion `page->size <= share->max_index_block_size'"
The issue was that Aria allowed too long keys to be created (so that the internal buffer was not big enough to hold the whole key). Key lengths is now limited to HA_MAX_KEY_LENGTH (1000), as for MyISAM. Fixed failure in "_ma_apply_redo_index: Assertion `new_page_length == 0", as found by buildbot. mysql-test/suite/maria/r/maria.result: Updated results mysql-test/suite/maria/r/maria3.result: Updated results. Added test for bug fix mysql-test/suite/maria/t/maria3.test: Updated results. Added test for bug fix mysql-test/suite/maria/t/optimize.test: Updated test for new max key length storage/maria/ha_maria.cc: Limit key to HA_MAX_KEY_LENGTH. storage/maria/ma_key_recover.c: Limit used page length to max page size (this is in line with the code that writes the entry to the log). This fixes failure in "_ma_apply_redo_index: Assertion `new_page_length == 0", as found by buildbot. storage/maria/ma_search.c: Extra DBUG storage/maria/ma_write.c: Added test to detect errors earlier.
This commit is contained in:
parent
0919edf32d
commit
cf06b29f60
8 changed files with 80 additions and 29 deletions
|
@ -340,14 +340,14 @@ Table Op Msg_type Msg_text
|
|||
test.t1 check status OK
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (a varchar(255), b varchar(255), c varchar(255), d varchar(255), e varchar(255), KEY t1 (a, b, c, d, e));
|
||||
ERROR 42000: Specified key was too long; max key length is 1208 bytes
|
||||
ERROR 42000: Specified key was too long; max key length is 1000 bytes
|
||||
CREATE TABLE t1 (a varchar(32000), unique key(a));
|
||||
ERROR 42000: Specified key was too long; max key length is 1208 bytes
|
||||
ERROR 42000: Specified key was too long; max key length is 1000 bytes
|
||||
CREATE TABLE t1 (a varchar(1), b varchar(1), key (a,b,a,b,a,b,a,b,a,b,a,b,a,b,a,b,a,b,a,b,a,b,a,b,a,b,a,b,a,b,a,b,a,b,a,b));
|
||||
ERROR 42000: Too many key parts specified; max 32 parts allowed
|
||||
CREATE TABLE t1 (a varchar(255), b varchar(255), c varchar(255), d varchar(255), e varchar(255));
|
||||
ALTER TABLE t1 ADD INDEX t1 (a, b, c, d, e);
|
||||
ERROR 42000: Specified key was too long; max key length is 1208 bytes
|
||||
ERROR 42000: Specified key was too long; max key length is 1000 bytes
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a int not null, b int, c int, key(b), key(c), key(a,b), key(c,a));
|
||||
INSERT into t1 values (0, null, 0), (0, null, 1), (0, null, 2), (0, null,3), (1,1,4);
|
||||
|
@ -1551,7 +1551,7 @@ a b
|
|||
drop table t1;
|
||||
create table t1 (v varchar(65530), key(v));
|
||||
Warnings:
|
||||
Warning 1071 Specified key was too long; max key length is 1208 bytes
|
||||
Warning 1071 Specified key was too long; max key length is 1000 bytes
|
||||
drop table if exists t1;
|
||||
create table t1 (v varchar(65536));
|
||||
Warnings:
|
||||
|
@ -1789,34 +1789,34 @@ t1 CREATE TABLE `t1` (
|
|||
drop table t1;
|
||||
create table t1 (a varchar(2048), key `a` (a));
|
||||
Warnings:
|
||||
Warning 1071 Specified key was too long; max key length is 1208 bytes
|
||||
Warning 1071 Specified key was too long; max key length is 1000 bytes
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` varchar(2048) DEFAULT NULL,
|
||||
KEY `a` (`a`(1208))
|
||||
KEY `a` (`a`(1000))
|
||||
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=0
|
||||
drop table t1;
|
||||
create table t1 (a varchar(2048), key `a` (a) key_block_size=1024);
|
||||
Warnings:
|
||||
Warning 1071 Specified key was too long; max key length is 1208 bytes
|
||||
Warning 1071 Specified key was too long; max key length is 1000 bytes
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` varchar(2048) DEFAULT NULL,
|
||||
KEY `a` (`a`(1208)) KEY_BLOCK_SIZE=8192
|
||||
KEY `a` (`a`(1000)) KEY_BLOCK_SIZE=8192
|
||||
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=0
|
||||
drop table t1;
|
||||
create table t1 (a int not null, b varchar(2048), key (a), key(b)) key_block_size=1024;
|
||||
Warnings:
|
||||
Warning 1071 Specified key was too long; max key length is 1208 bytes
|
||||
Warning 1071 Specified key was too long; max key length is 1000 bytes
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) NOT NULL,
|
||||
`b` varchar(2048) DEFAULT NULL,
|
||||
KEY `a` (`a`) KEY_BLOCK_SIZE=8192,
|
||||
KEY `b` (`b`(1208)) KEY_BLOCK_SIZE=8192
|
||||
KEY `b` (`b`(1000)) KEY_BLOCK_SIZE=8192
|
||||
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=0 KEY_BLOCK_SIZE=1024
|
||||
alter table t1 key_block_size=2048;
|
||||
show create table t1;
|
||||
|
@ -1825,7 +1825,7 @@ t1 CREATE TABLE `t1` (
|
|||
`a` int(11) NOT NULL,
|
||||
`b` varchar(2048) DEFAULT NULL,
|
||||
KEY `a` (`a`) KEY_BLOCK_SIZE=8192,
|
||||
KEY `b` (`b`(1208)) KEY_BLOCK_SIZE=8192
|
||||
KEY `b` (`b`(1000)) KEY_BLOCK_SIZE=8192
|
||||
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=0 KEY_BLOCK_SIZE=2048
|
||||
alter table t1 add c int, add key (c);
|
||||
show create table t1;
|
||||
|
@ -1835,7 +1835,7 @@ t1 CREATE TABLE `t1` (
|
|||
`b` varchar(2048) DEFAULT NULL,
|
||||
`c` int(11) DEFAULT NULL,
|
||||
KEY `a` (`a`) KEY_BLOCK_SIZE=8192,
|
||||
KEY `b` (`b`(1208)) KEY_BLOCK_SIZE=8192,
|
||||
KEY `b` (`b`(1000)) KEY_BLOCK_SIZE=8192,
|
||||
KEY `c` (`c`) KEY_BLOCK_SIZE=8192
|
||||
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=0 KEY_BLOCK_SIZE=2048
|
||||
alter table t1 key_block_size=0;
|
||||
|
@ -1848,33 +1848,33 @@ t1 CREATE TABLE `t1` (
|
|||
`c` int(11) DEFAULT NULL,
|
||||
`d` int(11) DEFAULT NULL,
|
||||
KEY `a` (`a`) KEY_BLOCK_SIZE=8192,
|
||||
KEY `b` (`b`(1208)) KEY_BLOCK_SIZE=8192,
|
||||
KEY `b` (`b`(1000)) KEY_BLOCK_SIZE=8192,
|
||||
KEY `c` (`c`) KEY_BLOCK_SIZE=8192,
|
||||
KEY `d` (`d`)
|
||||
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=0
|
||||
drop table t1;
|
||||
create table t1 (a int not null, b varchar(2048), key (a), key(b)) key_block_size=8192;
|
||||
Warnings:
|
||||
Warning 1071 Specified key was too long; max key length is 1208 bytes
|
||||
Warning 1071 Specified key was too long; max key length is 1000 bytes
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) NOT NULL,
|
||||
`b` varchar(2048) DEFAULT NULL,
|
||||
KEY `a` (`a`),
|
||||
KEY `b` (`b`(1208))
|
||||
KEY `b` (`b`(1000))
|
||||
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=0 KEY_BLOCK_SIZE=8192
|
||||
drop table t1;
|
||||
create table t1 (a int not null, b varchar(2048), key (a) key_block_size=1024, key(b)) key_block_size=8192;
|
||||
Warnings:
|
||||
Warning 1071 Specified key was too long; max key length is 1208 bytes
|
||||
Warning 1071 Specified key was too long; max key length is 1000 bytes
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) NOT NULL,
|
||||
`b` varchar(2048) DEFAULT NULL,
|
||||
KEY `a` (`a`),
|
||||
KEY `b` (`b`(1208))
|
||||
KEY `b` (`b`(1000))
|
||||
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=0 KEY_BLOCK_SIZE=8192
|
||||
drop table t1;
|
||||
create table t1 (a int not null, b int, key (a) key_block_size=1024, key(b) key_block_size=8192) key_block_size=16384;
|
||||
|
@ -1897,12 +1897,12 @@ t1 CREATE TABLE `t1` (
|
|||
drop table t1;
|
||||
create table t1 (a varchar(2048), key `a` (a) key_block_size=1000000000000000000);
|
||||
Warnings:
|
||||
Warning 1071 Specified key was too long; max key length is 1208 bytes
|
||||
Warning 1071 Specified key was too long; max key length is 1000 bytes
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` varchar(2048) DEFAULT NULL,
|
||||
KEY `a` (`a`(1208)) KEY_BLOCK_SIZE=8192
|
||||
KEY `a` (`a`(1000)) KEY_BLOCK_SIZE=8192
|
||||
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=0
|
||||
drop table t1;
|
||||
create table t1 (a int not null, key `a` (a) key_block_size=1025);
|
||||
|
|
|
@ -17,12 +17,12 @@ t1 CREATE TABLE `t1` (
|
|||
drop table t1;
|
||||
create table t1 (a varchar(2048), key `a` (a) key_block_size=1000000000000000000);
|
||||
Warnings:
|
||||
Warning 1071 Specified key was too long; max key length is 1208 bytes
|
||||
Warning 1071 Specified key was too long; max key length is 1000 bytes
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` varchar(2048) DEFAULT NULL,
|
||||
KEY `a` (`a`(1208)) KEY_BLOCK_SIZE=8192
|
||||
KEY `a` (`a`(1000)) KEY_BLOCK_SIZE=8192
|
||||
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=0
|
||||
drop table t1;
|
||||
create table t1 (a int not null, key `a` (a) key_block_size=1025);
|
||||
|
@ -645,3 +645,26 @@ a b c d e f g h i j
|
|||
1 A B C D 1 M H
|
||||
2 Abcdefghi E F G 2 N H
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1 ( a VARCHAR(800),KEY(a) )
|
||||
ENGINE=Aria DEFAULT CHARACTER SET latin1;
|
||||
INSERT INTO t1 VALUES
|
||||
(REPEAT('abc ',200)), (REPEAT('def ',200)),
|
||||
(REPEAT('ghi ',200)), (REPEAT('jkl ',200));
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
CHECK TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
ALTER TABLE t1 MODIFY a VARCHAR(800) CHARSET `ucs2`;
|
||||
Warnings:
|
||||
Warning 1071 Specified key was too long; max key length is 1000 bytes
|
||||
Warning 1071 Specified key was too long; max key length is 1000 bytes
|
||||
CHECK TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
SHOW CREATE table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` varchar(800) CHARACTER SET ucs2 DEFAULT NULL,
|
||||
KEY `a` (`a`(500))
|
||||
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
|
||||
DROP TABLE t1;
|
||||
|
|
|
@ -554,9 +554,28 @@ INSERT INTO t2 VALUES (1,'M','','H'),
|
|||
SELECT * FROM t1, t2 WHERE a = g ORDER BY b;
|
||||
drop table t1,t2;
|
||||
|
||||
|
||||
# End of 5.1 tests
|
||||
|
||||
#
|
||||
# bug#905716: Assertion `page->size <= share->max_index_block_size'
|
||||
#
|
||||
|
||||
CREATE TABLE t1 ( a VARCHAR(800),KEY(a) )
|
||||
ENGINE=Aria DEFAULT CHARACTER SET latin1;
|
||||
INSERT INTO t1 VALUES
|
||||
(REPEAT('abc ',200)), (REPEAT('def ',200)),
|
||||
(REPEAT('ghi ',200)), (REPEAT('jkl ',200));
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
# check table is not needed to reproduce the problem,
|
||||
# but shows that by this time the table appears to be okay.
|
||||
CHECK TABLE t1;
|
||||
ALTER TABLE t1 MODIFY a VARCHAR(800) CHARSET `ucs2`;
|
||||
CHECK TABLE t1;
|
||||
SHOW CREATE table t1;
|
||||
DROP TABLE t1;
|
||||
|
||||
# End of 5.2 tests
|
||||
|
||||
--disable_result_log
|
||||
--disable_query_log
|
||||
eval set global storage_engine=$default_engine,
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -888,8 +888,11 @@ double ha_maria::scan_time()
|
|||
splitting algorithms depends on this. (With only one key on a page
|
||||
we also can't use any compression, which may make the index file much
|
||||
larger)
|
||||
We use HA_MAX_KEY_BUFF as this is a stack restriction imposed by the
|
||||
handler interface.
|
||||
We use HA_MAX_KEY_LENGTH as this is a stack restriction imposed by the
|
||||
handler interface. If we want to increase this, we have also to
|
||||
increase HA_MARIA_KEY_BUFF and MARIA_MAX_KEY_BUFF as the buffer needs
|
||||
to take be able to store the extra lenght bytes that is part of the stored
|
||||
key.
|
||||
|
||||
We also need to reserve place for a record pointer (8) and 3 bytes
|
||||
per key segment to store the length of the segment + possible null bytes.
|
||||
|
@ -900,7 +903,7 @@ double ha_maria::scan_time()
|
|||
uint ha_maria::max_supported_key_length() const
|
||||
{
|
||||
uint tmp= (maria_max_key_length() - 8 - HA_MAX_KEY_SEG*3);
|
||||
return min(HA_MAX_KEY_BUFF, tmp);
|
||||
return min(HA_MAX_KEY_LENGTH, tmp);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2948,7 +2951,7 @@ void ha_maria::get_auto_increment(ulonglong offset, ulonglong increment,
|
|||
{
|
||||
ulonglong nr;
|
||||
int error;
|
||||
uchar key[HA_MAX_KEY_LENGTH];
|
||||
uchar key[MARIA_MAX_KEY_BUFF];
|
||||
|
||||
if (!table->s->next_number_key_offset)
|
||||
{ // Autoincrement at key-start
|
||||
|
|
|
@ -1107,7 +1107,7 @@ uint _ma_apply_redo_index(MARIA_HA *info,
|
|||
DBUG_PRINT("redo", ("org_page_length: %u new_page_length: %u",
|
||||
uint2korr(header), uint2korr(header+2)));
|
||||
DBUG_ASSERT(uint2korr(header) == page_length);
|
||||
new_page_length= uint2korr(header+2);
|
||||
new_page_length= min(uint2korr(header+2), max_page_size);
|
||||
header+= 4;
|
||||
break;
|
||||
case KEY_OP_MAX_PAGELENGTH:
|
||||
|
|
|
@ -1383,6 +1383,10 @@ uint _ma_get_binary_pack_key(MARIA_KEY *int_key, uint page_flag, uint nod_flag,
|
|||
memcpy(key, from, length + nod_flag);
|
||||
*page_pos= from + length + nod_flag;
|
||||
|
||||
#ifdef USEFUL_FOR_DEBUGGING
|
||||
DBUG_DUMP("key", int_key->data,
|
||||
(uint) (int_key->data_length + int_key->ref_length));
|
||||
#endif
|
||||
DBUG_RETURN(int_key->data_length + int_key->ref_length);
|
||||
}
|
||||
|
||||
|
|
|
@ -715,6 +715,8 @@ static int w_search(register MARIA_HA *info, uint32 comp_flag, MARIA_KEY *key,
|
|||
{
|
||||
error= _ma_insert(info, key, &page, keypos, keybuff,
|
||||
father_page, father_keypos, insert_last);
|
||||
if (error < 0)
|
||||
goto err;
|
||||
page_mark_changed(info, &page);
|
||||
if (_ma_write_keypage(&page, PAGECACHE_LOCK_LEFT_WRITELOCKED,
|
||||
DFLT_INIT_HITS))
|
||||
|
|
Loading…
Add table
Reference in a new issue