Commit 71a61f95 authored by serg@serg.mylan's avatar serg@serg.mylan

Merge bk-internal:/home/bk/mysql-5.0

into serg.mylan:/usr/home/serg/Abk/mysql-5.0
parents 551bdecf 4441b597
...@@ -442,33 +442,33 @@ PS=$ac_cv_path_PS ...@@ -442,33 +442,33 @@ PS=$ac_cv_path_PS
# Linux style # Linux style
if $PS p $$ 2> /dev/null | grep $0 > /dev/null if $PS p $$ 2> /dev/null | grep $0 > /dev/null
then then
FIND_PROC="$PS p \$\$PID | grep \$\$MYSQLD > /dev/null" FIND_PROC="$PS p \$\$PID | grep -v grep | grep \$\$MYSQLD > /dev/null"
# Solaris # Solaris
elif $PS -fp $$ 2> /dev/null | grep $0 > /dev/null elif $PS -fp $$ 2> /dev/null | grep $0 > /dev/null
then then
FIND_PROC="$PS -p \$\$PID | grep \$\$MYSQLD > /dev/null" FIND_PROC="$PS -p \$\$PID | grep -v grep | grep \$\$MYSQLD > /dev/null"
# BSD style # BSD style
elif $PS -uaxww 2> /dev/null | grep $0 > /dev/null elif $PS -uaxww 2> /dev/null | grep $0 > /dev/null
then then
FIND_PROC="$PS -uaxww | grep \$\$MYSQLD | grep \" \$\$PID \" > /dev/null" FIND_PROC="$PS -uaxww | grep -v grep | grep \$\$MYSQLD | grep \" \$\$PID \" > /dev/null"
# SysV style # SysV style
elif $PS -ef 2> /dev/null | grep $0 > /dev/null elif $PS -ef 2> /dev/null | grep $0 > /dev/null
then then
FIND_PROC="$PS -ef | grep \$\$MYSQLD | grep \" \$\$PID \" > /dev/null" FIND_PROC="$PS -ef | grep -v grep | grep \$\$MYSQLD | grep \" \$\$PID \" > /dev/null"
# Do anybody use this? # Do anybody use this?
elif $PS $$ 2> /dev/null | grep $0 > /dev/null elif $PS $$ 2> /dev/null | grep $0 > /dev/null
then then
FIND_PROC="$PS \$\$PID | grep \$\$MYSQLD > /dev/null" FIND_PROC="$PS \$\$PID | grep -v grep | grep \$\$MYSQLD > /dev/null"
else else
case $SYSTEM_TYPE in case $SYSTEM_TYPE in
*freebsd*) *freebsd*)
FIND_PROC="$PS p \$\$PID | grep \$\$MYSQLD > /dev/null" FIND_PROC="$PS p \$\$PID | grep -v grep | grep \$\$MYSQLD > /dev/null"
;; ;;
*darwin*) *darwin*)
FIND_PROC="$PS -uaxww | grep \$\$MYSQLD | grep \" \$\$PID \" > /dev/null" FIND_PROC="$PS -uaxww | grep -v grep | grep \$\$MYSQLD | grep \" \$\$PID \" > /dev/null"
;; ;;
*cygwin*) *cygwin*)
FIND_PROC="$PS -e | grep \$\$MYSQLD | grep \" \$\$PID \" > /dev/null" FIND_PROC="$PS -e | grep -v grep | grep \$\$MYSQLD | grep \" \$\$PID \" > /dev/null"
;; ;;
*netware*) *netware*)
FIND_PROC= FIND_PROC=
......
...@@ -285,13 +285,7 @@ C_MODE_END ...@@ -285,13 +285,7 @@ C_MODE_END
# endif # endif
#endif /* TIME_WITH_SYS_TIME */ #endif /* TIME_WITH_SYS_TIME */
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#if defined(HAVE_OPENSSL) && !defined(__FreeBSD__) && !defined(NeXT) && !defined(__OpenBSD__) && !defined(__APPLE__)
#define crypt unistd_crypt
#endif
#include <unistd.h> #include <unistd.h>
#ifdef HAVE_OPENSSL
#undef crypt
#endif
#endif #endif
#if defined(__cplusplus) && defined(NO_CPLUSPLUS_ALLOCA) #if defined(__cplusplus) && defined(NO_CPLUSPLUS_ALLOCA)
#undef HAVE_ALLOCA #undef HAVE_ALLOCA
......
...@@ -696,3 +696,8 @@ drop table t1; ...@@ -696,3 +696,8 @@ drop table t1;
create table t1 (a int not null, b int not null auto_increment, create table t1 (a int not null, b int not null auto_increment,
primary key(a, b)) engine=heap; primary key(a, b)) engine=heap;
ERROR 42000: Incorrect table definition; there can be only one auto column and it must be defined as a key ERROR 42000: Incorrect table definition; there can be only one auto column and it must be defined as a key
create table t1 (c char(255), primary key(c(90)));
insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
ERROR 23000: Duplicate entry 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl' for key 1
drop table t1;
...@@ -329,3 +329,28 @@ ERROR 42S21: Duplicate column name 'c1' ...@@ -329,3 +329,28 @@ ERROR 42S21: Duplicate column name 'c1'
alter table t1 add key (c1,c1,c2); alter table t1 add key (c1,c1,c2);
ERROR 42S21: Duplicate column name 'c1' ERROR 42S21: Duplicate column name 'c1'
drop table t1; drop table t1;
create table t1 (a varchar(10), b varchar(10), key(a(10),b(10)));
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` varchar(10) default NULL,
`b` varchar(10) default NULL,
KEY `a` (`a`,`b`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
alter table t1 modify b varchar(20);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` varchar(10) default NULL,
`b` varchar(20) default NULL,
KEY `a` (`a`,`b`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
alter table t1 modify a varchar(20);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` varchar(20) default NULL,
`b` varchar(20) default NULL,
KEY `a` (`a`,`b`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
...@@ -126,13 +126,13 @@ Some sample data ...@@ -126,13 +126,13 @@ Some sample data
Some samples Some samples
explain select * from t1 where v like 'This is a test' order by v; explain select * from t1 where v like 'This is a test' order by v;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 257 NULL 3 Using where; Using filesort 1 SIMPLE t1 range v v 258 NULL 3 Using where; Using index
explain select * from t1 where v='This is a test' order by v; explain select * from t1 where v='This is a test' order by v;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v v 257 const 3 Using where 1 SIMPLE t1 ref v v 258 const 3 Using where; Using index
explain select * from t1 where v like 'S%' order by v; explain select * from t1 where v like 'S%' order by v;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 257 NULL 2 Using where; Using filesort 1 SIMPLE t1 range v v 258 NULL 2 Using where; Using index
alter table t1 change v v varchar(256); alter table t1 change v v varchar(256);
select * from t1 where v like 'This is a test' order by v; select * from t1 where v like 'This is a test' order by v;
v v
...@@ -150,13 +150,13 @@ Some sample data ...@@ -150,13 +150,13 @@ Some sample data
Some samples Some samples
explain select * from t1 where v like 'This is a test' order by v; explain select * from t1 where v like 'This is a test' order by v;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 257 NULL 3 Using where; Using filesort 1 SIMPLE t1 range v v 259 NULL 3 Using where; Using index
explain select * from t1 where v='This is a test' order by v; explain select * from t1 where v='This is a test' order by v;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v v 257 const 3 Using where 1 SIMPLE t1 ref v v 259 const 3 Using where; Using index
explain select * from t1 where v like 'S%' order by v; explain select * from t1 where v like 'S%' order by v;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 257 NULL 2 Using where; Using filesort 1 SIMPLE t1 range v v 259 NULL 2 Using where; Using index
alter table t1 change v v varchar(257); alter table t1 change v v varchar(257);
select * from t1 where v like 'This is a test' order by v; select * from t1 where v like 'This is a test' order by v;
v v
...@@ -174,13 +174,13 @@ Some sample data ...@@ -174,13 +174,13 @@ Some sample data
Some samples Some samples
explain select * from t1 where v like 'This is a test' order by v; explain select * from t1 where v like 'This is a test' order by v;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 257 NULL 3 Using where; Using filesort 1 SIMPLE t1 range v v 260 NULL 3 Using where; Using index
explain select * from t1 where v='This is a test' order by v; explain select * from t1 where v='This is a test' order by v;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v v 257 const 3 Using where 1 SIMPLE t1 ref v v 260 const 3 Using where; Using index
explain select * from t1 where v like 'S%' order by v; explain select * from t1 where v like 'S%' order by v;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 257 NULL 2 Using where; Using filesort 1 SIMPLE t1 range v v 260 NULL 2 Using where; Using index
alter table t1 change v v varchar(258); alter table t1 change v v varchar(258);
select * from t1 where v like 'This is a test' order by v; select * from t1 where v like 'This is a test' order by v;
v v
...@@ -198,13 +198,13 @@ Some sample data ...@@ -198,13 +198,13 @@ Some sample data
Some samples Some samples
explain select * from t1 where v like 'This is a test' order by v; explain select * from t1 where v like 'This is a test' order by v;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 257 NULL 3 Using where; Using filesort 1 SIMPLE t1 range v v 261 NULL 3 Using where; Using index
explain select * from t1 where v='This is a test' order by v; explain select * from t1 where v='This is a test' order by v;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v v 257 const 3 Using where 1 SIMPLE t1 ref v v 261 const 3 Using where; Using index
explain select * from t1 where v like 'S%' order by v; explain select * from t1 where v like 'S%' order by v;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 257 NULL 2 Using where; Using filesort 1 SIMPLE t1 range v v 261 NULL 2 Using where; Using index
alter table t1 change v v varchar(259); alter table t1 change v v varchar(259);
select * from t1 where v like 'This is a test' order by v; select * from t1 where v like 'This is a test' order by v;
v v
...@@ -222,13 +222,13 @@ Some sample data ...@@ -222,13 +222,13 @@ Some sample data
Some samples Some samples
explain select * from t1 where v like 'This is a test' order by v; explain select * from t1 where v like 'This is a test' order by v;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 257 NULL 3 Using where; Using filesort 1 SIMPLE t1 range v v 262 NULL 3 Using where; Using index
explain select * from t1 where v='This is a test' order by v; explain select * from t1 where v='This is a test' order by v;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v v 257 const 3 Using where 1 SIMPLE t1 ref v v 262 const 3 Using where; Using index
explain select * from t1 where v like 'S%' order by v; explain select * from t1 where v like 'S%' order by v;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 257 NULL 2 Using where; Using filesort 1 SIMPLE t1 range v v 262 NULL 2 Using where; Using index
alter table t1 change v v varchar(258); alter table t1 change v v varchar(258);
select * from t1 where v like 'This is a test' order by v; select * from t1 where v like 'This is a test' order by v;
v v
...@@ -246,13 +246,13 @@ Some sample data ...@@ -246,13 +246,13 @@ Some sample data
Some samples Some samples
explain select * from t1 where v like 'This is a test' order by v; explain select * from t1 where v like 'This is a test' order by v;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 257 NULL 3 Using where; Using filesort 1 SIMPLE t1 range v v 261 NULL 3 Using where; Using index
explain select * from t1 where v='This is a test' order by v; explain select * from t1 where v='This is a test' order by v;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v v 257 const 3 Using where 1 SIMPLE t1 ref v v 261 const 3 Using where; Using index
explain select * from t1 where v like 'S%' order by v; explain select * from t1 where v like 'S%' order by v;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 257 NULL 2 Using where; Using filesort 1 SIMPLE t1 range v v 261 NULL 2 Using where; Using index
alter table t1 change v v varchar(257); alter table t1 change v v varchar(257);
select * from t1 where v like 'This is a test' order by v; select * from t1 where v like 'This is a test' order by v;
v v
...@@ -270,13 +270,13 @@ Some sample data ...@@ -270,13 +270,13 @@ Some sample data
Some samples Some samples
explain select * from t1 where v like 'This is a test' order by v; explain select * from t1 where v like 'This is a test' order by v;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 257 NULL 3 Using where; Using filesort 1 SIMPLE t1 range v v 260 NULL 3 Using where; Using index
explain select * from t1 where v='This is a test' order by v; explain select * from t1 where v='This is a test' order by v;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v v 257 const 3 Using where 1 SIMPLE t1 ref v v 260 const 3 Using where; Using index
explain select * from t1 where v like 'S%' order by v; explain select * from t1 where v like 'S%' order by v;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 257 NULL 2 Using where; Using filesort 1 SIMPLE t1 range v v 260 NULL 2 Using where; Using index
alter table t1 change v v varchar(256); alter table t1 change v v varchar(256);
select * from t1 where v like 'This is a test' order by v; select * from t1 where v like 'This is a test' order by v;
v v
...@@ -294,13 +294,13 @@ Some sample data ...@@ -294,13 +294,13 @@ Some sample data
Some samples Some samples
explain select * from t1 where v like 'This is a test' order by v; explain select * from t1 where v like 'This is a test' order by v;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 257 NULL 3 Using where; Using filesort 1 SIMPLE t1 range v v 259 NULL 3 Using where; Using index
explain select * from t1 where v='This is a test' order by v; explain select * from t1 where v='This is a test' order by v;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v v 257 const 3 Using where 1 SIMPLE t1 ref v v 259 const 3 Using where; Using index
explain select * from t1 where v like 'S%' order by v; explain select * from t1 where v like 'S%' order by v;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 257 NULL 2 Using where; Using filesort 1 SIMPLE t1 range v v 259 NULL 2 Using where; Using index
alter table t1 change v v varchar(255); alter table t1 change v v varchar(255);
select * from t1 where v like 'This is a test' order by v; select * from t1 where v like 'This is a test' order by v;
v v
...@@ -318,13 +318,13 @@ Some sample data ...@@ -318,13 +318,13 @@ Some sample data
Some samples Some samples
explain select * from t1 where v like 'This is a test' order by v; explain select * from t1 where v like 'This is a test' order by v;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 257 NULL 3 Using where; Using filesort 1 SIMPLE t1 range v v 258 NULL 3 Using where; Using index
explain select * from t1 where v='This is a test' order by v; explain select * from t1 where v='This is a test' order by v;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v v 257 const 3 Using where 1 SIMPLE t1 ref v v 258 const 3 Using where; Using index
explain select * from t1 where v like 'S%' order by v; explain select * from t1 where v like 'S%' order by v;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 257 NULL 2 Using where; Using filesort 1 SIMPLE t1 range v v 258 NULL 2 Using where; Using index
alter table t1 change v v varchar(254); alter table t1 change v v varchar(254);
select * from t1 where v like 'This is a test' order by v; select * from t1 where v like 'This is a test' order by v;
v v
...@@ -392,3 +392,26 @@ group by t1.b, t1.a; ...@@ -392,3 +392,26 @@ group by t1.b, t1.a;
a b min(t1.b) a b min(t1.b)
22 NULL NULL 22 NULL NULL
drop table t1, t2; drop table t1, t2;
create table t1 (f1 varchar(65500));
create index index1 on t1(f1(10));
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`f1` varchar(65500) default NULL,
KEY `index1` (`f1`(10))
) ENGINE=MyISAM DEFAULT CHARSET=latin1
alter table t1 modify f1 varchar(255);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`f1` varchar(255) default NULL,
KEY `index1` (`f1`(10))
) ENGINE=MyISAM DEFAULT CHARSET=latin1
alter table t1 modify f1 tinytext;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`f1` tinytext,
KEY `index1` (`f1`(10))
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
...@@ -426,3 +426,12 @@ drop table t1; ...@@ -426,3 +426,12 @@ drop table t1;
--error 1075 --error 1075
create table t1 (a int not null, b int not null auto_increment, create table t1 (a int not null, b int not null auto_increment,
primary key(a, b)) engine=heap; primary key(a, b)) engine=heap;
#
# Bug #10566: Verify that we can create a prefixed key with length > 255
#
create table t1 (c char(255), primary key(c(90)));
insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
--error 1062
insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
drop table t1;
...@@ -324,3 +324,16 @@ alter table t1 add key (c1,c2,c1); ...@@ -324,3 +324,16 @@ alter table t1 add key (c1,c2,c1);
--error 1060 --error 1060
alter table t1 add key (c1,c1,c2); alter table t1 add key (c1,c1,c2);
drop table t1; drop table t1;
#
# If we use a partial field for a key that is actually the length of the
# field, and we extend the field, we end up with a key that includes the
# whole new length of the field.
#
create table t1 (a varchar(10), b varchar(10), key(a(10),b(10)));
show create table t1;
alter table t1 modify b varchar(20);
show create table t1;
alter table t1 modify a varchar(20);
show create table t1;
drop table t1;
...@@ -118,3 +118,15 @@ insert into t2 values (22), (22); ...@@ -118,3 +118,15 @@ insert into t2 values (22), (22);
select t1.a, t1.b, min(t1.b) from t1 inner join t2 ON t2.a = t1.a select t1.a, t1.b, min(t1.b) from t1 inner join t2 ON t2.a = t1.a
group by t1.b, t1.a; group by t1.b, t1.a;
drop table t1, t2; drop table t1, t2;
#
# Bug #10543: convert varchar with index to text
#
create table t1 (f1 varchar(65500));
create index index1 on t1(f1(10));
show create table t1;
alter table t1 modify f1 varchar(255);
show create table t1;
alter table t1 modify f1 tinytext;
show create table t1;
drop table t1;
...@@ -262,7 +262,25 @@ static void movelink(HASH_LINK *array,uint find,uint next_link,uint newlink) ...@@ -262,7 +262,25 @@ static void movelink(HASH_LINK *array,uint find,uint next_link,uint newlink)
return; return;
} }
/* Compare a key in a record to a whole key. Return 0 if identical */ /*
Compare a key in a record to a whole key. Return 0 if identical
SYNOPSIS
hashcmp()
hash hash table
pos position of hash record to use in comparison
key key for comparison
length length of key
NOTES:
If length is 0, comparison is done using the length of the
record being compared against.
RETURN
< 0 key of record < key
= 0 key of record == key
> 0 key of record > key
*/
static int hashcmp(HASH *hash,HASH_LINK *pos,const byte *key,uint length) static int hashcmp(HASH *hash,HASH_LINK *pos,const byte *key,uint length)
{ {
...@@ -270,7 +288,7 @@ static int hashcmp(HASH *hash,HASH_LINK *pos,const byte *key,uint length) ...@@ -270,7 +288,7 @@ static int hashcmp(HASH *hash,HASH_LINK *pos,const byte *key,uint length)
byte *rec_key= (byte*) hash_key(hash,pos->data,&rec_keylength,1); byte *rec_key= (byte*) hash_key(hash,pos->data,&rec_keylength,1);
return ((length && length != rec_keylength) || return ((length && length != rec_keylength) ||
my_strnncoll(hash->charset, (uchar*) rec_key, rec_keylength, my_strnncoll(hash->charset, (uchar*) rec_key, rec_keylength,
(uchar*) key, length)); (uchar*) key, rec_keylength));
} }
......
...@@ -982,6 +982,39 @@ Item_result Field::result_merge_type(enum_field_types field_type) ...@@ -982,6 +982,39 @@ Item_result Field::result_merge_type(enum_field_types field_type)
Static help functions Static help functions
*****************************************************************************/ *****************************************************************************/
/*
Check whether a field type can be partially indexed by a key
This is a static method, rather than a virtual function, because we need
to check the type of a non-Field in mysql_alter_table().
SYNOPSIS
type_can_have_key_part()
type field type
RETURN
TRUE Type can have a prefixed key
FALSE Type can not have a prefixed key
*/
bool Field::type_can_have_key_part(enum enum_field_types type)
{
switch (type) {
case MYSQL_TYPE_VARCHAR:
case MYSQL_TYPE_TINY_BLOB:
case MYSQL_TYPE_MEDIUM_BLOB:
case MYSQL_TYPE_LONG_BLOB:
case MYSQL_TYPE_BLOB:
case MYSQL_TYPE_VAR_STRING:
case MYSQL_TYPE_STRING:
return TRUE;
default:
return FALSE;
}
}
/* /*
Numeric fields base class constructor Numeric fields base class constructor
*/ */
......
...@@ -119,6 +119,7 @@ class Field ...@@ -119,6 +119,7 @@ class Field
virtual Item_result result_type () const=0; virtual Item_result result_type () const=0;
virtual Item_result cmp_type () const { return result_type(); } virtual Item_result cmp_type () const { return result_type(); }
virtual Item_result cast_to_int_type () const { return result_type(); } virtual Item_result cast_to_int_type () const { return result_type(); }
static bool type_can_have_key_part(enum_field_types);
static enum_field_types field_type_merge(enum_field_types, enum_field_types); static enum_field_types field_type_merge(enum_field_types, enum_field_types);
static Item_result result_merge_type(enum_field_types); static Item_result result_merge_type(enum_field_types);
bool eq(Field *field) bool eq(Field *field)
......
...@@ -57,6 +57,7 @@ class ha_heap: public handler ...@@ -57,6 +57,7 @@ class ha_heap: public handler
} }
const key_map *keys_to_use_for_scanning() { return &btree_keys; } const key_map *keys_to_use_for_scanning() { return &btree_keys; }
uint max_supported_keys() const { return MAX_KEY; } uint max_supported_keys() const { return MAX_KEY; }
uint max_supported_key_part_length() const { return MAX_KEY_LENGTH; }
double scan_time() { return (double) (records+deleted) / 20.0+10; } double scan_time() { return (double) (records+deleted) / 20.0+10; }
double read_time(uint index, uint ranges, ha_rows rows) double read_time(uint index, uint ranges, ha_rows rows)
{ return (double) rows / 20.0+1; } { return (double) rows / 20.0+1; }
......
...@@ -707,7 +707,7 @@ failed my_b_read")); ...@@ -707,7 +707,7 @@ failed my_b_read"));
Log_event *res= 0; Log_event *res= 0;
#ifndef max_allowed_packet #ifndef max_allowed_packet
THD *thd=current_thd; THD *thd=current_thd;
uint max_allowed_packet= thd ? thd->variables.max_allowed_packet : ~0; uint max_allowed_packet= thd ? thd->variables.max_allowed_packet : ~(ulong)0;
#endif #endif
if (data_len > max_allowed_packet) if (data_len > max_allowed_packet)
......
...@@ -5172,7 +5172,7 @@ bool mysql_revoke_all(THD *thd, List <LEX_USER> &list) ...@@ -5172,7 +5172,7 @@ bool mysql_revoke_all(THD *thd, List <LEX_USER> &list)
grant_proc->db, grant_proc->db,
grant_proc->tname, grant_proc->tname,
is_proc, is_proc,
~0, 1)) ~(ulong)0, 1))
{ {
revoked= 1; revoked= 1;
continue; continue;
...@@ -5240,7 +5240,7 @@ bool sp_revoke_privileges(THD *thd, const char *sp_db, const char *sp_name, ...@@ -5240,7 +5240,7 @@ bool sp_revoke_privileges(THD *thd, const char *sp_db, const char *sp_name,
lex_user.host.length= strlen(grant_proc->host.hostname); lex_user.host.length= strlen(grant_proc->host.hostname);
if (!replace_routine_table(thd,grant_proc,tables[4].table,lex_user, if (!replace_routine_table(thd,grant_proc,tables[4].table,lex_user,
grant_proc->db, grant_proc->tname, grant_proc->db, grant_proc->tname,
is_proc, ~0, 1)) is_proc, ~(ulong)0, 1))
{ {
revoked= 1; revoked= 1;
continue; continue;
......
...@@ -3398,12 +3398,25 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, ...@@ -3398,12 +3398,25 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
continue; // Field is removed continue; // Field is removed
uint key_part_length=key_part->length; uint key_part_length=key_part->length;
if (cfield->field) // Not new field if (cfield->field) // Not new field
{ // Check if sub key {
if (cfield->field->type() != FIELD_TYPE_BLOB && /*
(cfield->field->pack_length() == key_part_length || If the field can't have only a part used in a key according to its
cfield->length <= key_part_length / new type, or should not be used partially according to its
key_part->field->charset()->mbmaxlen)) previous type, or the field length is less than the key part
key_part_length=0; // Use whole field length, unset the key part length.
We also unset the key part length if it is the same as the
old field's length, so the whole new field will be used.
BLOBs may have cfield->length == 0, which is why we test it before
checking whether cfield->length < key_part_length (in chars).
*/
if (!Field::type_can_have_key_part(cfield->field->type()) ||
!Field::type_can_have_key_part(cfield->sql_type) ||
cfield->field->field_length == key_part_length ||
(cfield->length && (cfield->length < key_part_length /
key_part->field->charset()->mbmaxlen)))
key_part_length= 0; // Use whole field
} }
key_part_length /= key_part->field->charset()->mbmaxlen; key_part_length /= key_part->field->charset()->mbmaxlen;
key_parts.push_back(new key_part_spec(cfield->field_name, key_parts.push_back(new key_part_spec(cfield->field_name,
......
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