mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Fixed alter online table for Aria tables
fill_alter_table() always thought that index was changed because of of a wrong check of block_size. Some engines had code to correct this that should not be needed, Aria didn't and because of this some online operations didn't work. This code fixes the comparision of block_size to only compare if it's set.
This commit is contained in:
@ -2043,6 +2043,84 @@ t1 CREATE TABLE `t1` (
|
||||
KEY `b` (`b`(1000))
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 KEY_BLOCK_SIZE=8192
|
||||
drop table t1;
|
||||
create table t1 (a int not null, b varchar(512), key (a), key(b));
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) NOT NULL,
|
||||
`b` varchar(512) DEFAULT NULL,
|
||||
KEY `a` (`a`),
|
||||
KEY `b` (`b`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
alter table t1 key_block_size=2048;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) NOT NULL,
|
||||
`b` varchar(512) DEFAULT NULL,
|
||||
KEY `a` (`a`) KEY_BLOCK_SIZE=1024,
|
||||
KEY `b` (`b`) KEY_BLOCK_SIZE=3072
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 KEY_BLOCK_SIZE=2048
|
||||
alter table t1 add c int, add key (c);
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) NOT NULL,
|
||||
`b` varchar(512) DEFAULT NULL,
|
||||
`c` int(11) DEFAULT NULL,
|
||||
KEY `a` (`a`) KEY_BLOCK_SIZE=1024,
|
||||
KEY `b` (`b`) KEY_BLOCK_SIZE=4096,
|
||||
KEY `c` (`c`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 KEY_BLOCK_SIZE=2048
|
||||
alter table t1 key_block_size=4096;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) NOT NULL,
|
||||
`b` varchar(512) DEFAULT NULL,
|
||||
`c` int(11) DEFAULT NULL,
|
||||
KEY `a` (`a`) KEY_BLOCK_SIZE=1024,
|
||||
KEY `b` (`b`),
|
||||
KEY `c` (`c`) KEY_BLOCK_SIZE=2048
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 KEY_BLOCK_SIZE=4096
|
||||
alter table t1 key_block_size=0;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) NOT NULL,
|
||||
`b` varchar(512) DEFAULT NULL,
|
||||
`c` int(11) DEFAULT NULL,
|
||||
KEY `a` (`a`) KEY_BLOCK_SIZE=1024,
|
||||
KEY `b` (`b`) KEY_BLOCK_SIZE=4096,
|
||||
KEY `c` (`c`) KEY_BLOCK_SIZE=2048
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
alter table t1 add d int, add key (d);
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) NOT NULL,
|
||||
`b` varchar(512) DEFAULT NULL,
|
||||
`c` int(11) DEFAULT NULL,
|
||||
`d` int(11) DEFAULT NULL,
|
||||
KEY `a` (`a`) KEY_BLOCK_SIZE=1024,
|
||||
KEY `b` (`b`) KEY_BLOCK_SIZE=4096,
|
||||
KEY `c` (`c`) KEY_BLOCK_SIZE=2048,
|
||||
KEY `d` (`d`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
alter table t1 key_block_size=8192;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) NOT NULL,
|
||||
`b` varchar(512) DEFAULT NULL,
|
||||
`c` int(11) DEFAULT NULL,
|
||||
`d` int(11) DEFAULT NULL,
|
||||
KEY `a` (`a`) KEY_BLOCK_SIZE=1024,
|
||||
KEY `b` (`b`) KEY_BLOCK_SIZE=4096,
|
||||
KEY `c` (`c`) KEY_BLOCK_SIZE=2048,
|
||||
KEY `d` (`d`) KEY_BLOCK_SIZE=1024
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 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 1000 bytes
|
||||
|
@ -1904,7 +1904,28 @@ t1 CREATE TABLE `t1` (
|
||||
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=4096;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) NOT NULL,
|
||||
`b` varchar(2048) DEFAULT NULL,
|
||||
`c` int(11) DEFAULT NULL,
|
||||
KEY `a` (`a`) 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=4096
|
||||
alter table t1 key_block_size=0;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) NOT NULL,
|
||||
`b` varchar(2048) DEFAULT NULL,
|
||||
`c` int(11) DEFAULT NULL,
|
||||
KEY `a` (`a`) 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
|
||||
alter table t1 add d int, add key (d);
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
|
@ -1166,7 +1166,10 @@ alter table t1 key_block_size=2048;
|
||||
show create table t1;
|
||||
alter table t1 add c int, add key (c);
|
||||
show create table t1;
|
||||
alter table t1 key_block_size=4096;
|
||||
show create table t1;
|
||||
alter table t1 key_block_size=0;
|
||||
show create table t1;
|
||||
alter table t1 add d int, add key (d);
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
|
@ -1266,6 +1266,22 @@ create table t1 (a int not null, b varchar(2048), key (a), key(b)) key_block_siz
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
|
||||
create table t1 (a int not null, b varchar(512), key (a), key(b));
|
||||
show create table t1;
|
||||
alter table t1 key_block_size=2048;
|
||||
show create table t1;
|
||||
alter table t1 add c int, add key (c);
|
||||
show create table t1;
|
||||
alter table t1 key_block_size=4096;
|
||||
show create table t1;
|
||||
alter table t1 key_block_size=0;
|
||||
show create table t1;
|
||||
alter table t1 add d int, add key (d);
|
||||
show create table t1;
|
||||
alter table t1 key_block_size=8192;
|
||||
show create table t1;
|
||||
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;
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
@ -1274,7 +1290,6 @@ create table t1 (a int not null, b int, key (a) key_block_size=1024, key(b) key_
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
|
||||
|
||||
# Test limits and errors of key_block_size
|
||||
|
||||
create table t1 (a int not null, key `a` (a) key_block_size=512);
|
||||
|
@ -68,7 +68,7 @@ static handlerton *installed_htons[128];
|
||||
#define BITMAP_STACKBUF_SIZE (128/8)
|
||||
|
||||
KEY_CREATE_INFO default_key_create_info=
|
||||
{ HA_KEY_ALG_UNDEF, 0, {NullS, 0}, {NullS, 0}, true };
|
||||
{ HA_KEY_ALG_UNDEF, 0, 0, {NullS, 0}, {NullS, 0}, true };
|
||||
|
||||
/* number of entries in handlertons[] */
|
||||
ulong total_ha= 0;
|
||||
|
@ -2347,6 +2347,7 @@ typedef struct st_key_create_information
|
||||
{
|
||||
enum ha_key_alg algorithm;
|
||||
ulong block_size;
|
||||
uint flags; /* HA_USE.. flags */
|
||||
LEX_CSTRING parser_name;
|
||||
LEX_CSTRING comment;
|
||||
/**
|
||||
|
@ -3847,7 +3847,17 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
|
||||
key->key_create_info.block_size :
|
||||
create_info->key_block_size);
|
||||
|
||||
if (key_info->block_size)
|
||||
/*
|
||||
Remember block_size for the future if the block size was given
|
||||
either for key or table and it was given for the key during
|
||||
create/alter table or we have an active key_block_size for the
|
||||
table.
|
||||
The idea is that table specific key_block_size > 0 will only affect
|
||||
new keys and old keys will remember their original value.
|
||||
*/
|
||||
if (key_info->block_size &&
|
||||
((key->key_create_info.flags & HA_USES_BLOCK_SIZE) ||
|
||||
create_info->key_block_size))
|
||||
key_info->flags|= HA_USES_BLOCK_SIZE;
|
||||
|
||||
List_iterator<Key_part_spec> cols(key->columns), cols2(key->columns);
|
||||
@ -8408,8 +8418,12 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
|
||||
LEX_CSTRING tmp_name;
|
||||
bzero((char*) &key_create_info, sizeof(key_create_info));
|
||||
key_create_info.algorithm= key_info->algorithm;
|
||||
if (key_info->flags & HA_USES_BLOCK_SIZE)
|
||||
/*
|
||||
We copy block size directly as some engines, like Area, sets this
|
||||
automatically
|
||||
*/
|
||||
key_create_info.block_size= key_info->block_size;
|
||||
key_create_info.flags= key_info->flags; // HA_USE_BLOCK_SIZE
|
||||
if (key_info->flags & HA_USES_PARSER)
|
||||
key_create_info.parser_name= *plugin_name(key_info->parser);
|
||||
if (key_info->flags & HA_USES_COMMENT)
|
||||
|
@ -69,6 +69,7 @@
|
||||
#include "sql_sequence.h"
|
||||
#include "sql_tvc.h"
|
||||
#include "vers_utils.h"
|
||||
#include "my_base.h"
|
||||
|
||||
/* this is to get the bison compilation windows warnings out */
|
||||
#ifdef _MSC_VER
|
||||
@ -7518,7 +7519,10 @@ key_using_alg:
|
||||
|
||||
all_key_opt:
|
||||
KEY_BLOCK_SIZE opt_equal ulong_num
|
||||
{ Lex->last_key->key_create_info.block_size= $3; }
|
||||
{
|
||||
Lex->last_key->key_create_info.block_size= $3;
|
||||
Lex->last_key->key_create_info.flags|= HA_USES_BLOCK_SIZE;
|
||||
}
|
||||
| COMMENT_SYM TEXT_STRING_sys
|
||||
{ Lex->last_key->key_create_info.comment= $2; }
|
||||
| IDENT_sys equal TEXT_STRING_sys
|
||||
|
@ -7351,7 +7351,10 @@ key_using_alg:
|
||||
|
||||
all_key_opt:
|
||||
KEY_BLOCK_SIZE opt_equal ulong_num
|
||||
{ Lex->last_key->key_create_info.block_size= $3; }
|
||||
{
|
||||
Lex->create_info.used_fields|= HA_USES_BLOCK_SIZE;
|
||||
Lex->create_info.key_block_size= $3;
|
||||
}
|
||||
| COMMENT_SYM TEXT_STRING_sys
|
||||
{ Lex->last_key->key_create_info.comment= $2; }
|
||||
| IDENT_sys equal TEXT_STRING_sys
|
||||
|
Reference in New Issue
Block a user