1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

Merge mysql.com:/home/jonas/src/mysql-5.0

into mysql.com:/home/jonas/src/mysql-5.0-ndb
This commit is contained in:
unknown
2004-12-20 16:33:45 +01:00
76 changed files with 2125 additions and 622 deletions

View File

@ -92,6 +92,66 @@ select sql_big_result c,count(t) from t1 group by c limit 10;
select t,count(*) from t1 group by t limit 10;
select t,count(t) from t1 group by t limit 10;
select sql_big_result t,count(t) from t1 group by t limit 10;
#
# Test varchar > 255 bytes
#
alter table t1 modify v varchar(300), drop key v, drop key v_2, add key v (v);
show create table t1;
select count(*) from t1 where v='a';
select count(*) from t1 where v='a ';
select count(*) from t1 where v between 'a' and 'a ';
select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n';
select count(*) from t1 where v like 'a%';
select count(*) from t1 where v like 'a %';
explain select count(*) from t1 where v='a ';
explain select count(*) from t1 where v like 'a%';
explain select count(*) from t1 where v between 'a' and 'a ';
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n';
explain select * from t1 where v='a';
# GROUP BY
select v,count(*) from t1 group by v limit 10;
select v,count(t) from t1 group by v limit 10;
select sql_big_result v,count(t) from t1 group by v limit 10;
#
# Test varchar > 255 bytes, key < 255
#
alter table t1 drop key v, add key v (v(30));
show create table t1;
select count(*) from t1 where v='a';
select count(*) from t1 where v='a ';
select count(*) from t1 where v between 'a' and 'a ';
select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n';
select count(*) from t1 where v like 'a%';
select count(*) from t1 where v like 'a %';
explain select count(*) from t1 where v='a ';
explain select count(*) from t1 where v like 'a%';
explain select count(*) from t1 where v between 'a' and 'a ';
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n';
explain select * from t1 where v='a';
# GROUP BY
select v,count(*) from t1 group by v limit 10;
select v,count(t) from t1 group by v limit 10;
select sql_big_result v,count(t) from t1 group by v limit 10;
#
# Test varchar > 512 (special case for GROUP BY becasue of
# CONVERT_IF_BIGGER_TO_BLOB define)
#
alter table t1 modify v varchar(600), drop key v, add key v (v);
show create table t1;
select v,count(*) from t1 group by v limit 10;
select v,count(t) from t1 group by v limit 10;
select sql_big_result v,count(t) from t1 group by v limit 10;
drop table t1;
#

View File

@ -1578,6 +1578,217 @@ f 10
g 10
h 10
i 10
alter table t1 modify v varchar(300), drop key v, drop key v_2, add key v (v);
Warnings:
Warning 1071 Specified key was too long; max key length is 255 bytes
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`v` varchar(300) default NULL,
`c` char(10) default NULL,
`t` text,
KEY `c` (`c`),
KEY `t` (`t`(10)),
KEY `v` (`v`(255))
) ENGINE=BerkeleyDB DEFAULT CHARSET=latin1
select count(*) from t1 where v='a';
count(*)
10
select count(*) from t1 where v='a ';
count(*)
10
select count(*) from t1 where v between 'a' and 'a ';
count(*)
10
select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n';
count(*)
10
select count(*) from t1 where v like 'a%';
count(*)
11
select count(*) from t1 where v like 'a %';
count(*)
9
explain select count(*) from t1 where v='a ';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v v 258 const 10 Using where
explain select count(*) from t1 where v like 'a%';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 258 NULL 11 Using where
explain select count(*) from t1 where v between 'a' and 'a ';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 258 NULL 10 Using where
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 258 NULL 10 Using where
explain select * from t1 where v='a';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v v 258 const 10 Using where
select v,count(*) from t1 group by v limit 10;
v count(*)
a 1
a 10
b 10
c 10
d 10
e 10
f 10
g 10
h 10
i 10
select v,count(t) from t1 group by v limit 10;
v count(t)
a 1
a 10
b 10
c 10
d 10
e 10
f 10
g 10
h 10
i 10
select sql_big_result v,count(t) from t1 group by v limit 10;
v count(t)
a 1
a 10
b 10
c 10
d 10
e 10
f 10
g 10
h 10
i 10
alter table t1 drop key v, add key v (v(30));
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`v` varchar(300) default NULL,
`c` char(10) default NULL,
`t` text,
KEY `c` (`c`),
KEY `t` (`t`(10)),
KEY `v` (`v`(30))
) ENGINE=BerkeleyDB DEFAULT CHARSET=latin1
select count(*) from t1 where v='a';
count(*)
10
select count(*) from t1 where v='a ';
count(*)
10
select count(*) from t1 where v between 'a' and 'a ';
count(*)
10
select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n';
count(*)
10
select count(*) from t1 where v like 'a%';
count(*)
11
select count(*) from t1 where v like 'a %';
count(*)
9
explain select count(*) from t1 where v='a ';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v v 33 const 10 Using where
explain select count(*) from t1 where v like 'a%';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 33 NULL 11 Using where
explain select count(*) from t1 where v between 'a' and 'a ';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 33 NULL 10 Using where
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 33 NULL 10 Using where
explain select * from t1 where v='a';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v v 33 const 10 Using where
select v,count(*) from t1 group by v limit 10;
v count(*)
a 1
a 10
b 10
c 10
d 10
e 10
f 10
g 10
h 10
i 10
select v,count(t) from t1 group by v limit 10;
v count(t)
a 1
a 10
b 10
c 10
d 10
e 10
f 10
g 10
h 10
i 10
select sql_big_result v,count(t) from t1 group by v limit 10;
v count(t)
a 1
a 10
b 10
c 10
d 10
e 10
f 10
g 10
h 10
i 10
alter table t1 modify v varchar(600), drop key v, add key v (v);
Warnings:
Warning 1071 Specified key was too long; max key length is 255 bytes
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`v` varchar(600) default NULL,
`c` char(10) default NULL,
`t` text,
KEY `c` (`c`),
KEY `t` (`t`(10)),
KEY `v` (`v`(255))
) ENGINE=BerkeleyDB DEFAULT CHARSET=latin1
select v,count(*) from t1 group by v limit 10;
v count(*)
a 1
a 10
b 10
c 10
d 10
e 10
f 10
g 10
h 10
i 10
select v,count(t) from t1 group by v limit 10;
v count(t)
a 1
a 10
b 10
c 10
d 10
e 10
f 10
g 10
h 10
i 10
select sql_big_result v,count(t) from t1 group by v limit 10;
v count(t)
a 1
a 10
b 10
c 10
d 10
e 10
f 10
g 10
h 10
i 10
drop table t1;
create table t1 (a char(10), unique (a));
insert into t1 values ('a ');

View File

@ -471,7 +471,7 @@ character_sets CREATE TEMPORARY TABLE `character_sets` (
`DEFAULT_COLLATE_NAME` varchar(60) NOT NULL default '',
`DESCRIPTION` varchar(60) NOT NULL default '',
`MAXLEN` bigint(3) NOT NULL default '0'
) ENGINE=HEAP DEFAULT CHARSET=utf8 MAX_ROWS=2252
) ENGINE=HEAP DEFAULT CHARSET=utf8 MAX_ROWS=2267
set names latin2;
SHOW CREATE TABLE INFORMATION_SCHEMA.character_sets;
Table Create Table
@ -480,7 +480,7 @@ character_sets CREATE TEMPORARY TABLE `character_sets` (
`DEFAULT_COLLATE_NAME` varchar(60) NOT NULL default '',
`DESCRIPTION` varchar(60) NOT NULL default '',
`MAXLEN` bigint(3) NOT NULL default '0'
) ENGINE=HEAP DEFAULT CHARSET=utf8 MAX_ROWS=2252
) ENGINE=HEAP DEFAULT CHARSET=utf8 MAX_ROWS=2267
set names latin1;
create table t1 select * from information_schema.CHARACTER_SETS
where CHARACTER_SET_NAME like "latin1";

View File

@ -1421,19 +1421,19 @@ insert t2 select * from t1;
insert t3 select * from t1;
checksum table t1, t2, t3, t4 quick;
Table Checksum
test.t1 272226711
test.t1 2948697075
test.t2 NULL
test.t3 NULL
test.t4 NULL
checksum table t1, t2, t3, t4;
Table Checksum
test.t1 272226711
test.t1 2948697075
test.t2 968604391
test.t3 968604391
test.t4 NULL
checksum table t1, t2, t3, t4 extended;
Table Checksum
test.t1 272226711
test.t1 3092701434
test.t2 968604391
test.t3 968604391
test.t4 NULL

View File

@ -513,18 +513,18 @@ insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, "");
insert t2 select * from t1;
checksum table t1, t2, t3 quick;
Table Checksum
test.t1 272226711
test.t1 2948697075
test.t2 NULL
test.t3 NULL
checksum table t1, t2, t3;
Table Checksum
test.t1 272226711
test.t2 272226711
test.t1 2948697075
test.t2 3092701434
test.t3 NULL
checksum table t1, t2, t3 extended;
Table Checksum
test.t1 272226711
test.t2 272226711
test.t1 3092701434
test.t2 3092701434
test.t3 NULL
drop table t1,t2;
create table t1 (a int, key (a));
@ -849,6 +849,213 @@ f 10
g 10
h 10
i 10
alter table t1 modify v varchar(300), drop key v, drop key v_2, add key v (v);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`v` varchar(300) default NULL,
`c` char(10) default NULL,
`t` text,
KEY `c` (`c`),
KEY `t` (`t`(10)),
KEY `v` (`v`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select count(*) from t1 where v='a';
count(*)
10
select count(*) from t1 where v='a ';
count(*)
10
select count(*) from t1 where v between 'a' and 'a ';
count(*)
10
select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n';
count(*)
10
select count(*) from t1 where v like 'a%';
count(*)
11
select count(*) from t1 where v like 'a %';
count(*)
9
explain select count(*) from t1 where v='a ';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v v 303 const 7 Using where; Using index
explain select count(*) from t1 where v like 'a%';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 303 NULL 8 Using where; Using index
explain select count(*) from t1 where v between 'a' and 'a ';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 303 NULL 7 Using where; Using index
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 303 NULL 7 Using where; Using index
explain select * from t1 where v='a';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v v 303 const 7 Using where
select v,count(*) from t1 group by v limit 10;
v count(*)
a 1
a 10
b 10
c 10
d 10
e 10
f 10
g 10
h 10
i 10
select v,count(t) from t1 group by v limit 10;
v count(t)
a 1
a 10
b 10
c 10
d 10
e 10
f 10
g 10
h 10
i 10
select sql_big_result v,count(t) from t1 group by v limit 10;
v count(t)
a 1
a 10
b 10
c 10
d 10
e 10
f 10
g 10
h 10
i 10
alter table t1 drop key v, add key v (v(30));
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`v` varchar(300) default NULL,
`c` char(10) default NULL,
`t` text,
KEY `c` (`c`),
KEY `t` (`t`(10)),
KEY `v` (`v`(30))
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select count(*) from t1 where v='a';
count(*)
10
select count(*) from t1 where v='a ';
count(*)
10
select count(*) from t1 where v between 'a' and 'a ';
count(*)
10
select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n';
count(*)
10
select count(*) from t1 where v like 'a%';
count(*)
11
select count(*) from t1 where v like 'a %';
count(*)
9
explain select count(*) from t1 where v='a ';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v v 33 const 7 Using where
explain select count(*) from t1 where v like 'a%';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 33 NULL 8 Using where
explain select count(*) from t1 where v between 'a' and 'a ';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 33 NULL 7 Using where
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 33 NULL 7 Using where
explain select * from t1 where v='a';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v v 33 const 7 Using where
select v,count(*) from t1 group by v limit 10;
v count(*)
a 1
a 10
b 10
c 10
d 10
e 10
f 10
g 10
h 10
i 10
select v,count(t) from t1 group by v limit 10;
v count(t)
a 1
a 10
b 10
c 10
d 10
e 10
f 10
g 10
h 10
i 10
select sql_big_result v,count(t) from t1 group by v limit 10;
v count(t)
a 1
a 10
b 10
c 10
d 10
e 10
f 10
g 10
h 10
i 10
alter table t1 modify v varchar(600), drop key v, add key v (v);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`v` varchar(600) default NULL,
`c` char(10) default NULL,
`t` text,
KEY `c` (`c`),
KEY `t` (`t`(10)),
KEY `v` (`v`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select v,count(*) from t1 group by v limit 10;
v count(*)
a 1
a 10
b 10
c 10
d 10
e 10
f 10
g 10
h 10
i 10
select v,count(t) from t1 group by v limit 10;
v count(t)
a 1
a 10
b 10
c 10
d 10
e 10
f 10
g 10
h 10
i 10
select sql_big_result v,count(t) from t1 group by v limit 10;
v count(t)
a 1
a 10
b 10
c 10
d 10
e 10
f 10
g 10
h 10
i 10
drop table t1;
create table t1 (a char(10), unique (a));
insert into t1 values ('a ');

View File

@ -278,7 +278,7 @@ t2 MyISAM 9 Fixed 0 0 0 64424509439 1024 0 NULL # # # latin1_swedish_ci NULL
prepare stmt4 from ' show table status from test like ''t9%'' ';
execute stmt4;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t9 MyISAM 10 Dynamic 2 222 444 4294967295 2048 0 NULL # # # latin1_swedish_ci NULL
t9 MyISAM 10 Dynamic 2 220 440 4294967295 2048 0 NULL # # # latin1_swedish_ci NULL
prepare stmt4 from ' show status like ''Threads_running'' ';
execute stmt4;
Variable_name Value

View File

@ -314,57 +314,57 @@ insert into t2 values (1),(2);
insert into t3 values (1,1),(2,2);
show table status;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 HEAP 9 Fixed 2 5 # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
t2 HEAP 9 Fixed 2 5 # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
t3 HEAP 9 Fixed 2 9 # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
t1 HEAP 9 Fixed 2 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
t2 HEAP 9 Fixed 2 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
t3 HEAP 9 Fixed 2 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
insert into t1 values (3),(4);
insert into t2 values (3),(4);
insert into t3 values (3,3),(4,4);
show table status;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 HEAP 9 Fixed 4 5 # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
t2 HEAP 9 Fixed 4 5 # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
t3 HEAP 9 Fixed 4 9 # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
t1 HEAP 9 Fixed 4 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
t2 HEAP 9 Fixed 4 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
t3 HEAP 9 Fixed 4 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
insert into t1 values (5);
insert into t2 values (5);
insert into t3 values (5,5);
show table status;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 HEAP 9 Fixed 5 5 # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
t2 HEAP 9 Fixed 5 5 # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
t3 HEAP 9 Fixed 5 9 # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
t1 HEAP 9 Fixed 5 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
t2 HEAP 9 Fixed 5 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
t3 HEAP 9 Fixed 5 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
delete from t1 where a=3;
delete from t2 where b=3;
delete from t3 where a=3;
show table status;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 HEAP 9 Fixed 4 5 # # # 5 NULL NULL NULL NULL latin1_swedish_ci NULL
t2 HEAP 9 Fixed 4 5 # # # 5 NULL NULL NULL NULL latin1_swedish_ci NULL
t3 HEAP 9 Fixed 4 9 # # # 9 NULL NULL NULL NULL latin1_swedish_ci NULL
t1 HEAP 9 Fixed 4 # # # # 5 NULL NULL NULL NULL latin1_swedish_ci NULL
t2 HEAP 9 Fixed 4 # # # # 5 NULL NULL NULL NULL latin1_swedish_ci NULL
t3 HEAP 9 Fixed 4 # # # # 9 NULL NULL NULL NULL latin1_swedish_ci NULL
delete from t1;
delete from t2;
delete from t3;
show table status;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 HEAP 9 Fixed 0 5 # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
t2 HEAP 9 Fixed 0 5 # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
t3 HEAP 9 Fixed 0 9 # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
t1 HEAP 9 Fixed 0 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
t2 HEAP 9 Fixed 0 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
t3 HEAP 9 Fixed 0 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
insert into t1 values (5);
insert into t2 values (5);
insert into t3 values (5,5);
show table status;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 HEAP 9 Fixed 1 5 # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
t2 HEAP 9 Fixed 1 5 # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
t3 HEAP 9 Fixed 1 9 # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
t1 HEAP 9 Fixed 1 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
t2 HEAP 9 Fixed 1 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
t3 HEAP 9 Fixed 1 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
delete from t1 where a=5;
delete from t2 where b=5;
delete from t3 where a=5;
show table status;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 HEAP 9 Fixed 0 5 # # # 5 NULL NULL NULL NULL latin1_swedish_ci NULL
t2 HEAP 9 Fixed 0 5 # # # 5 NULL NULL NULL NULL latin1_swedish_ci NULL
t3 HEAP 9 Fixed 0 9 # # # 9 NULL NULL NULL NULL latin1_swedish_ci NULL
t1 HEAP 9 Fixed 0 # # # # 5 NULL NULL NULL NULL latin1_swedish_ci NULL
t2 HEAP 9 Fixed 0 # # # # 5 NULL NULL NULL NULL latin1_swedish_ci NULL
t3 HEAP 9 Fixed 0 # # # # 9 NULL NULL NULL NULL latin1_swedish_ci NULL
drop table t1, t2, t3;
create database mysqltest;
show create database mysqltest;

View File

@ -321,6 +321,12 @@ select a+0, b+0, c+0 from t1 where a = 4 and b = 0 limit 2;
a+0 b+0 c+0
4 0 3
4 0 23
select a+0, b+0, c+0 from t1 where a = 4 and b = 1;
a+0 b+0 c+0
4 1 100
select a+0, b+0, c+0 from t1 where a = 4 and b = 1 and c=100;
a+0 b+0 c+0
4 1 100
select a+0, b+0, c+0 from t1 order by b desc;
a+0 b+0 c+0
2 1 4

View File

@ -68,3 +68,311 @@ create table t1 (v varbinary(20));
insert into t1 values('a');
insert into t1 values('a ');
alter table t1 add primary key (v);
drop table t1;
create table t1 (v varchar(254), index (v));
insert into t1 values ("This is a test ");
insert into t1 values ("Some sample data");
insert into t1 values (" garbage ");
insert into t1 values (" This is a test ");
insert into t1 values ("This is a test");
insert into t1 values ("Hello world");
insert into t1 values ("Foo bar");
insert into t1 values ("This is a test");
insert into t1 values ("MySQL varchar test");
insert into t1 values ("test MySQL varchar");
insert into t1 values ("This is a long string to have some random length data included");
insert into t1 values ("Short string");
insert into t1 values ("VSS");
insert into t1 values ("Some samples");
insert into t1 values ("Bar foo");
insert into t1 values ("Bye");
select * from t1 where v like 'This is a test' order by v;
v
This is a test
This is a test
select * from t1 where v='This is a test' order by v;
v
This is a test
This is a test
This is a test
select * from t1 where v like 'S%' order by v;
v
Short string
Some sample data
Some samples
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
1 SIMPLE t1 range v v 257 NULL 3 Using where; Using index
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
1 SIMPLE t1 ref v v 257 const 3 Using where; Using index
explain select * from t1 where v like 'S%' order by v;
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 index
alter table t1 change v v varchar(255);
select * from t1 where v like 'This is a test' order by v;
v
This is a test
This is a test
select * from t1 where v='This is a test' order by v;
v
This is a test
This is a test
This is a test
select * from t1 where v like 'S%' order by v;
v
Short string
Some sample data
Some samples
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
1 SIMPLE t1 range v v 257 NULL 3 Using where; Using filesort
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
1 SIMPLE t1 ref v v 257 const 3 Using where
explain select * from t1 where v like 'S%' order by v;
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
alter table t1 change v v varchar(256);
select * from t1 where v like 'This is a test' order by v;
v
This is a test
This is a test
select * from t1 where v='This is a test' order by v;
v
This is a test
This is a test
This is a test
select * from t1 where v like 'S%' order by v;
v
Short string
Some sample data
Some samples
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
1 SIMPLE t1 range v v 257 NULL 3 Using where; Using filesort
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
1 SIMPLE t1 ref v v 257 const 3 Using where
explain select * from t1 where v like 'S%' order by v;
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
alter table t1 change v v varchar(257);
select * from t1 where v like 'This is a test' order by v;
v
This is a test
This is a test
select * from t1 where v='This is a test' order by v;
v
This is a test
This is a test
This is a test
select * from t1 where v like 'S%' order by v;
v
Short string
Some sample data
Some samples
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
1 SIMPLE t1 range v v 257 NULL 3 Using where; Using filesort
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
1 SIMPLE t1 ref v v 257 const 3 Using where
explain select * from t1 where v like 'S%' order by v;
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
alter table t1 change v v varchar(258);
select * from t1 where v like 'This is a test' order by v;
v
This is a test
This is a test
select * from t1 where v='This is a test' order by v;
v
This is a test
This is a test
This is a test
select * from t1 where v like 'S%' order by v;
v
Short string
Some sample data
Some samples
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
1 SIMPLE t1 range v v 257 NULL 3 Using where; Using filesort
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
1 SIMPLE t1 ref v v 257 const 3 Using where
explain select * from t1 where v like 'S%' order by v;
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
alter table t1 change v v varchar(259);
select * from t1 where v like 'This is a test' order by v;
v
This is a test
This is a test
select * from t1 where v='This is a test' order by v;
v
This is a test
This is a test
This is a test
select * from t1 where v like 'S%' order by v;
v
Short string
Some sample data
Some samples
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
1 SIMPLE t1 range v v 257 NULL 3 Using where; Using filesort
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
1 SIMPLE t1 ref v v 257 const 3 Using where
explain select * from t1 where v like 'S%' order by v;
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
alter table t1 change v v varchar(258);
select * from t1 where v like 'This is a test' order by v;
v
This is a test
This is a test
select * from t1 where v='This is a test' order by v;
v
This is a test
This is a test
This is a test
select * from t1 where v like 'S%' order by v;
v
Short string
Some sample data
Some samples
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
1 SIMPLE t1 range v v 257 NULL 3 Using where; Using filesort
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
1 SIMPLE t1 ref v v 257 const 3 Using where
explain select * from t1 where v like 'S%' order by v;
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
alter table t1 change v v varchar(257);
select * from t1 where v like 'This is a test' order by v;
v
This is a test
This is a test
select * from t1 where v='This is a test' order by v;
v
This is a test
This is a test
This is a test
select * from t1 where v like 'S%' order by v;
v
Short string
Some sample data
Some samples
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
1 SIMPLE t1 range v v 257 NULL 3 Using where; Using filesort
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
1 SIMPLE t1 ref v v 257 const 3 Using where
explain select * from t1 where v like 'S%' order by v;
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
alter table t1 change v v varchar(256);
select * from t1 where v like 'This is a test' order by v;
v
This is a test
This is a test
select * from t1 where v='This is a test' order by v;
v
This is a test
This is a test
This is a test
select * from t1 where v like 'S%' order by v;
v
Short string
Some sample data
Some samples
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
1 SIMPLE t1 range v v 257 NULL 3 Using where; Using filesort
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
1 SIMPLE t1 ref v v 257 const 3 Using where
explain select * from t1 where v like 'S%' order by v;
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
alter table t1 change v v varchar(255);
select * from t1 where v like 'This is a test' order by v;
v
This is a test
This is a test
select * from t1 where v='This is a test' order by v;
v
This is a test
This is a test
This is a test
select * from t1 where v like 'S%' order by v;
v
Short string
Some sample data
Some samples
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
1 SIMPLE t1 range v v 257 NULL 3 Using where; Using filesort
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
1 SIMPLE t1 ref v v 257 const 3 Using where
explain select * from t1 where v like 'S%' order by v;
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
alter table t1 change v v varchar(254);
select * from t1 where v like 'This is a test' order by v;
v
This is a test
This is a test
select * from t1 where v='This is a test' order by v;
v
This is a test
This is a test
This is a test
select * from t1 where v like 'S%' order by v;
v
Short string
Some sample data
Some samples
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
1 SIMPLE t1 range v v 257 NULL 3 Using where; Using index
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
1 SIMPLE t1 ref v v 257 const 3 Using where; Using index
explain select * from t1 where v like 'S%' order by v;
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 index
alter table t1 change v v varchar(253);
alter table t1 change v v varchar(254), drop key v;
alter table t1 change v v varchar(300), add key (v(10));
select * from t1 where v like 'This is a test' order by v;
v
This is a test
This is a test
select * from t1 where v='This is a test' order by v;
v
This is a test
This is a test
This is a test
select * from t1 where v like 'S%' order by v;
v
Short string
Some sample data
Some samples
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
1 SIMPLE t1 range v v 13 NULL 4 Using where; Using filesort
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
1 SIMPLE t1 ref v v 13 const 4 Using where
explain select * from t1 where v like 'S%' order by v;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 13 NULL 2 Using where; Using filesort
drop table t1;

View File

@ -824,7 +824,7 @@ select a from t1;
drop table t1;
#
# bug#2686 - index_merge select on BerkeleyDB table with varchar PK causes mysqld to crash
# bug#2686 - index_merge select on BerkeleyDB table with varchar PK crashes
#
create table t1(
@ -842,7 +842,8 @@ select substring(pk1, 1, 4), substring(pk1, 4001),
drop table t1;
#
# bug#2688 - Wrong index_merge query results for BDB table with variable length primary key
# bug#2688 - Wrong index_merge query results for BDB table with
# variable length primary key
#
create table t1 (

View File

@ -236,37 +236,37 @@ CREATE TABLE t3 (
insert into t1 values (1),(2);
insert into t2 values (1),(2);
insert into t3 values (1,1),(2,2);
--replace_column 7 # 8 # 9 #
--replace_column 6 # 7 # 8 # 9 #
show table status;
insert into t1 values (3),(4);
insert into t2 values (3),(4);
insert into t3 values (3,3),(4,4);
--replace_column 7 # 8 # 9 #
--replace_column 6 # 7 # 8 # 9 #
show table status;
insert into t1 values (5);
insert into t2 values (5);
insert into t3 values (5,5);
--replace_column 7 # 8 # 9 #
--replace_column 6 # 7 # 8 # 9 #
show table status;
delete from t1 where a=3;
delete from t2 where b=3;
delete from t3 where a=3;
--replace_column 7 # 8 # 9 #
--replace_column 6 # 7 # 8 # 9 #
show table status;
delete from t1;
delete from t2;
delete from t3;
--replace_column 7 # 8 # 9 #
--replace_column 6 # 7 # 8 # 9 #
show table status;
insert into t1 values (5);
insert into t2 values (5);
insert into t3 values (5,5);
--replace_column 7 # 8 # 9 #
--replace_column 6 # 7 # 8 # 9 #
show table status;
delete from t1 where a=5;
delete from t2 where b=5;
delete from t3 where a=5;
--replace_column 7 # 8 # 9 #
--replace_column 6 # 7 # 8 # 9 #
show table status;
drop table t1, t2, t3;

View File

@ -88,6 +88,8 @@ select hex(min(b)) from t1 where a = 4;
select hex(min(c)) from t1 where a = 4 and b = 0;
select hex(max(b)) from t1;
select a+0, b+0, c+0 from t1 where a = 4 and b = 0 limit 2;
select a+0, b+0, c+0 from t1 where a = 4 and b = 1;
select a+0, b+0, c+0 from t1 where a = 4 and b = 1 and c=100;
select a+0, b+0, c+0 from t1 order by b desc;
select a+0, b+0, c+0 from t1 order by c;
drop table t1;
@ -101,6 +103,6 @@ drop table t1;
# Some magic numbers
create table t1 (a bit(7), key(a));
insert into t1 values (44), (57);
insert into t1 values (44), (57);
select a+0 from t1;
drop table t1;

View File

@ -32,3 +32,68 @@ create table t1 (v varbinary(20));
insert into t1 values('a');
insert into t1 values('a ');
alter table t1 add primary key (v);
drop table t1;
#
# Test with varchar of lengths 254,255,256,258 & 258 to ensure we don't
# have any problems with varchar with one or two byte length_bytes
#
create table t1 (v varchar(254), index (v));
insert into t1 values ("This is a test ");
insert into t1 values ("Some sample data");
insert into t1 values (" garbage ");
insert into t1 values (" This is a test ");
insert into t1 values ("This is a test");
insert into t1 values ("Hello world");
insert into t1 values ("Foo bar");
insert into t1 values ("This is a test");
insert into t1 values ("MySQL varchar test");
insert into t1 values ("test MySQL varchar");
insert into t1 values ("This is a long string to have some random length data included");
insert into t1 values ("Short string");
insert into t1 values ("VSS");
insert into t1 values ("Some samples");
insert into t1 values ("Bar foo");
insert into t1 values ("Bye");
let $i= 255;
let $j= 5;
while ($j)
{
select * from t1 where v like 'This is a test' order by v;
select * from t1 where v='This is a test' order by v;
select * from t1 where v like 'S%' order by v;
explain select * from t1 where v like 'This is a test' order by v;
explain select * from t1 where v='This is a test' order by v;
explain select * from t1 where v like 'S%' order by v;
eval alter table t1 change v v varchar($i);
inc $i;
dec $j;
}
let $i= 258;
let $j= 6;
while ($j)
{
select * from t1 where v like 'This is a test' order by v;
select * from t1 where v='This is a test' order by v;
select * from t1 where v like 'S%' order by v;
explain select * from t1 where v like 'This is a test' order by v;
explain select * from t1 where v='This is a test' order by v;
explain select * from t1 where v like 'S%' order by v;
eval alter table t1 change v v varchar($i);
dec $i;
dec $j;
}
alter table t1 change v v varchar(254), drop key v;
# Test with length(varchar) > 256 and key < 256 (to ensure things works with
# different kind of packing
alter table t1 change v v varchar(300), add key (v(10));
select * from t1 where v like 'This is a test' order by v;
select * from t1 where v='This is a test' order by v;
select * from t1 where v like 'S%' order by v;
explain select * from t1 where v like 'This is a test' order by v;
explain select * from t1 where v='This is a test' order by v;
explain select * from t1 where v like 'S%' order by v;
drop table t1;