Commit d36d5a29 authored by unknown's avatar unknown

Merge tulin@bk-internal.mysql.com:/home/bk/mysql-4.1

into poseidon.ndb.mysql.com:/home/tomas/mysql-4.1-ndb

parents 4a618a35 1d7ae133
...@@ -104,13 +104,13 @@ prepare stmt1 from ' select substr(''MySQL'',1,?) from t1 where a=1 ' ; ...@@ -104,13 +104,13 @@ prepare stmt1 from ' select substr(''MySQL'',1,?) from t1 where a=1 ' ;
execute stmt1 using @arg00 ; execute stmt1 using @arg00 ;
# variations on 'concat' # variations on 'concat'
set @arg00='MySQL' ; set @arg00='MySQL' ;
select a , concat(@arg00,b) from t1 ; select a , concat(@arg00,b) from t1 order by a;
# BUG#3796 Prepared statement, select concat(<parameter>,<column>),wrong result # BUG#3796 Prepared statement, select concat(<parameter>,<column>),wrong result
prepare stmt1 from ' select a , concat(?,b) from t1 ' ; prepare stmt1 from ' select a , concat(?,b) from t1 order by a ' ;
execute stmt1 using @arg00; execute stmt1 using @arg00;
# #
select a , concat(b,@arg00) from t1 ; select a , concat(b,@arg00) from t1 order by a ;
prepare stmt1 from ' select a , concat(b,?) from t1 ' ; prepare stmt1 from ' select a , concat(b,?) from t1 order by a ' ;
execute stmt1 using @arg00; execute stmt1 using @arg00;
# variations on 'group_concat' # variations on 'group_concat'
...@@ -147,7 +147,7 @@ create table t5 (id1 int(11) not null default '0', ...@@ -147,7 +147,7 @@ create table t5 (id1 int(11) not null default '0',
value2 varchar(100), value1 varchar(100)) ; value2 varchar(100), value1 varchar(100)) ;
insert into t5 values (1,'hh','hh'),(2,'hh','hh'), insert into t5 values (1,'hh','hh'),(2,'hh','hh'),
(1,'ii','ii'),(2,'ii','ii') ; (1,'ii','ii'),(2,'ii','ii') ;
prepare stmt1 from ' select id1,value1 from t5 where id1=? or value1=? ' ; prepare stmt1 from ' select id1,value1 from t5 where id1=? or value1=? order by id1,value1 ' ;
set @arg00=1 ; set @arg00=1 ;
set @arg01='hh' ; set @arg01='hh' ;
execute stmt1 using @arg00, @arg01 ; execute stmt1 using @arg00, @arg01 ;
...@@ -216,8 +216,8 @@ execute stmt1 using @arg00 ; ...@@ -216,8 +216,8 @@ execute stmt1 using @arg00 ;
# parameter in IN # parameter in IN
set @arg00=2 ; set @arg00=2 ;
set @arg01=3 ; set @arg01=3 ;
select a FROM t1 where a in (@arg00,@arg01); select a FROM t1 where a in (@arg00,@arg01) order by a;
prepare stmt1 from ' select a FROM t1 where a in (?,?) '; prepare stmt1 from ' select a FROM t1 where a in (?,?) order by a ';
execute stmt1 using @arg00, @arg01; execute stmt1 using @arg00, @arg01;
# case derived from client_test.c: test_bug1500() # case derived from client_test.c: test_bug1500()
set @arg00= 'one' ; set @arg00= 'one' ;
...@@ -270,9 +270,9 @@ execute stmt1 using @arg00 ; ...@@ -270,9 +270,9 @@ execute stmt1 using @arg00 ;
##### parameter used in having clause ##### parameter used in having clause
set @arg00='two' ; set @arg00='two' ;
select a,b FROM t1 where a is not NULL select a,b FROM t1 where a is not NULL
AND b is not NULL having b <> @arg00 ; AND b is not NULL having b <> @arg00 order by a ;
prepare stmt1 from ' select a,b FROM t1 where a is not NULL prepare stmt1 from ' select a,b FROM t1 where a is not NULL
AND b is not NULL having b <> ? ' ; AND b is not NULL having b <> ? order by a ' ;
execute stmt1 using @arg00 ; execute stmt1 using @arg00 ;
##### parameter used in order clause ##### parameter used in order clause
...@@ -297,7 +297,7 @@ execute stmt1 using @arg00; ...@@ -297,7 +297,7 @@ execute stmt1 using @arg00;
##### parameter used in limit clause ##### parameter used in limit clause
set @arg00=1; set @arg00=1;
prepare stmt1 from ' select a,b from t1 prepare stmt1 from ' select a,b from t1 order by a
limit 1 '; limit 1 ';
execute stmt1 ; execute stmt1 ;
# currently (May 2004, Version 4.1) it is impossible # currently (May 2004, Version 4.1) it is impossible
...@@ -327,10 +327,10 @@ select '------ join tests ------' as test_sequence ; ...@@ -327,10 +327,10 @@ select '------ join tests ------' as test_sequence ;
# no parameter # no parameter
select first.a as a1, second.a as a2 select first.a as a1, second.a as a2
from t1 first, t1 second from t1 first, t1 second
where first.a = second.a ; where first.a = second.a order by a1 ;
prepare stmt1 from ' select first.a as a1, second.a as a2 prepare stmt1 from ' select first.a as a1, second.a as a2
from t1 first, t1 second from t1 first, t1 second
where first.a = second.a '; where first.a = second.a order by a1 ';
execute stmt1 ; execute stmt1 ;
# some parameters # some parameters
...@@ -350,15 +350,15 @@ execute stmt1 using @arg00, @arg01, @arg02; ...@@ -350,15 +350,15 @@ execute stmt1 using @arg00, @arg01, @arg02;
drop table if exists t2 ; drop table if exists t2 ;
--enable_warnings --enable_warnings
create table t2 as select * from t1 ; create table t2 as select * from t1 ;
set @query1= 'SELECT * FROM t2 join t1 on (t1.a=t2.a) ' ; set @query1= 'SELECT * FROM t2 join t1 on (t1.a=t2.a) order by t2.a ' ;
set @query2= 'SELECT * FROM t2 natural join t1 ' ; set @query2= 'SELECT * FROM t2 natural join t1 order by t2.a ' ;
set @query3= 'SELECT * FROM t2 join t1 using(a) ' ; set @query3= 'SELECT * FROM t2 join t1 using(a) order by t2.a ' ;
set @query4= 'SELECT * FROM t2 left join t1 on(t1.a=t2.a) ' ; set @query4= 'SELECT * FROM t2 left join t1 on(t1.a=t2.a) order by t2.a ' ;
set @query5= 'SELECT * FROM t2 natural left join t1 ' ; set @query5= 'SELECT * FROM t2 natural left join t1 order by t2.a ' ;
set @query6= 'SELECT * FROM t2 left join t1 using(a) ' ; set @query6= 'SELECT * FROM t2 left join t1 using(a) order by t2.a ' ;
set @query7= 'SELECT * FROM t2 right join t1 on(t1.a=t2.a) ' ; set @query7= 'SELECT * FROM t2 right join t1 on(t1.a=t2.a) order by t2.a ' ;
set @query8= 'SELECT * FROM t2 natural right join t1 ' ; set @query8= 'SELECT * FROM t2 natural right join t1 order by t2.a ' ;
set @query9= 'SELECT * FROM t2 right join t1 using(a) ' ; set @query9= 'SELECT * FROM t2 right join t1 using(a) order by t2.a ' ;
let $1= 9 ; let $1= 9 ;
while ($1) while ($1)
{ {
...@@ -424,7 +424,7 @@ execute stmt1 using @arg00, @arg01, @arg02, @arg03 ; ...@@ -424,7 +424,7 @@ execute stmt1 using @arg00, @arg01, @arg02, @arg03 ;
######## correlated subquery ######## correlated subquery
# no parameter # no parameter
prepare stmt1 from ' select a, b FROM t1 outer_table where prepare stmt1 from ' select a, b FROM t1 outer_table where
a = (select a from t1 where b = outer_table.b ) '; a = (select a from t1 where b = outer_table.b ) order by a ';
# also Bug#4000 (only BDB tables) # also Bug#4000 (only BDB tables)
# Bug#4106 : ndb table, query with correlated subquery, wrong result # Bug#4106 : ndb table, query with correlated subquery, wrong result
execute stmt1 ; execute stmt1 ;
......
...@@ -10,7 +10,7 @@ explain select * from t2 where p NOT IN (select p from t1); ...@@ -10,7 +10,7 @@ explain select * from t2 where p NOT IN (select p from t1);
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 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using where 1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using where
2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 Using index 2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 Using index
select * from t2 where p NOT IN (select p from t1); select * from t2 where p NOT IN (select p from t1) order by p;
p u o p u o
4 4 4 4 4 4
5 5 5 5 5 5
...@@ -18,7 +18,7 @@ explain select * from t2 where p NOT IN (select u from t1); ...@@ -18,7 +18,7 @@ explain select * from t2 where p NOT IN (select u from t1);
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 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using where 1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using where
2 DEPENDENT SUBQUERY t1 unique_subquery u u 4 func 1 Using index 2 DEPENDENT SUBQUERY t1 unique_subquery u u 4 func 1 Using index
select * from t2 where p NOT IN (select u from t1); select * from t2 where p NOT IN (select u from t1) order by p;
p u o p u o
4 4 4 4 4 4
5 5 5 5 5 5
...@@ -26,7 +26,7 @@ explain select * from t2 where p NOT IN (select o from t1); ...@@ -26,7 +26,7 @@ explain select * from t2 where p NOT IN (select o from t1);
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 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using where 1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using where
2 DEPENDENT SUBQUERY t1 index_subquery o o 4 func 1 Using index 2 DEPENDENT SUBQUERY t1 index_subquery o o 4 func 1 Using index
select * from t2 where p NOT IN (select o from t1); select * from t2 where p NOT IN (select o from t1) order by p;
p u o p u o
4 4 4 4 4 4
5 5 5 5 5 5
...@@ -34,7 +34,7 @@ explain select * from t2 where p NOT IN (select p+0 from t1); ...@@ -34,7 +34,7 @@ explain select * from t2 where p NOT IN (select p+0 from t1);
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 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using where 1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using where
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 Using where 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 Using where
select * from t2 where p NOT IN (select p+0 from t1); select * from t2 where p NOT IN (select p+0 from t1) order by p;
p u o p u o
4 4 4 4 4 4
5 5 5 5 5 5
......
...@@ -165,26 +165,26 @@ execute stmt1 using @arg00 ; ...@@ -165,26 +165,26 @@ execute stmt1 using @arg00 ;
substr('MySQL',1,?) substr('MySQL',1,?)
MyS MyS
set @arg00='MySQL' ; set @arg00='MySQL' ;
select a , concat(@arg00,b) from t1 ; select a , concat(@arg00,b) from t1 order by a;
a concat(@arg00,b) a concat(@arg00,b)
1 MySQLone 1 MySQLone
2 MySQLtwo 2 MySQLtwo
3 MySQLthree 3 MySQLthree
4 MySQLfour 4 MySQLfour
prepare stmt1 from ' select a , concat(?,b) from t1 ' ; prepare stmt1 from ' select a , concat(?,b) from t1 order by a ' ;
execute stmt1 using @arg00; execute stmt1 using @arg00;
a concat(?,b) a concat(?,b)
1 MySQLone 1 MySQLone
2 MySQLtwo 2 MySQLtwo
3 MySQLthree 3 MySQLthree
4 MySQLfour 4 MySQLfour
select a , concat(b,@arg00) from t1 ; select a , concat(b,@arg00) from t1 order by a ;
a concat(b,@arg00) a concat(b,@arg00)
1 oneMySQL 1 oneMySQL
2 twoMySQL 2 twoMySQL
3 threeMySQL 3 threeMySQL
4 fourMySQL 4 fourMySQL
prepare stmt1 from ' select a , concat(b,?) from t1 ' ; prepare stmt1 from ' select a , concat(b,?) from t1 order by a ' ;
execute stmt1 using @arg00; execute stmt1 using @arg00;
a concat(b,?) a concat(b,?)
1 oneMySQL 1 oneMySQL
...@@ -234,14 +234,14 @@ create table t5 (id1 int(11) not null default '0', ...@@ -234,14 +234,14 @@ create table t5 (id1 int(11) not null default '0',
value2 varchar(100), value1 varchar(100)) ; value2 varchar(100), value1 varchar(100)) ;
insert into t5 values (1,'hh','hh'),(2,'hh','hh'), insert into t5 values (1,'hh','hh'),(2,'hh','hh'),
(1,'ii','ii'),(2,'ii','ii') ; (1,'ii','ii'),(2,'ii','ii') ;
prepare stmt1 from ' select id1,value1 from t5 where id1=? or value1=? ' ; prepare stmt1 from ' select id1,value1 from t5 where id1=? or value1=? order by id1,value1 ' ;
set @arg00=1 ; set @arg00=1 ;
set @arg01='hh' ; set @arg01='hh' ;
execute stmt1 using @arg00, @arg01 ; execute stmt1 using @arg00, @arg01 ;
id1 value1 id1 value1
1 hh 1 hh
2 hh
1 ii 1 ii
2 hh
drop table t5 ; drop table t5 ;
drop table if exists t5 ; drop table if exists t5 ;
create table t5(session_id char(9) not null) ; create table t5(session_id char(9) not null) ;
...@@ -307,11 +307,11 @@ execute stmt1 using @arg00 ; ...@@ -307,11 +307,11 @@ execute stmt1 using @arg00 ;
a a
set @arg00=2 ; set @arg00=2 ;
set @arg01=3 ; set @arg01=3 ;
select a FROM t1 where a in (@arg00,@arg01); select a FROM t1 where a in (@arg00,@arg01) order by a;
a a
2 2
3 3
prepare stmt1 from ' select a FROM t1 where a in (?,?) '; prepare stmt1 from ' select a FROM t1 where a in (?,?) order by a ';
execute stmt1 using @arg00, @arg01; execute stmt1 using @arg00, @arg01;
a a
2 2
...@@ -385,13 +385,13 @@ a b ...@@ -385,13 +385,13 @@ a b
4 four 4 four
set @arg00='two' ; set @arg00='two' ;
select a,b FROM t1 where a is not NULL select a,b FROM t1 where a is not NULL
AND b is not NULL having b <> @arg00 ; AND b is not NULL having b <> @arg00 order by a ;
a b a b
1 one 1 one
3 three 3 three
4 four 4 four
prepare stmt1 from ' select a,b FROM t1 where a is not NULL prepare stmt1 from ' select a,b FROM t1 where a is not NULL
AND b is not NULL having b <> ? ' ; AND b is not NULL having b <> ? order by a ' ;
execute stmt1 using @arg00 ; execute stmt1 using @arg00 ;
a b a b
1 one 1 one
...@@ -439,7 +439,7 @@ set @arg00=0 ; ...@@ -439,7 +439,7 @@ set @arg00=0 ;
execute stmt1 using @arg00; execute stmt1 using @arg00;
ERROR 42S22: Unknown column '?' in 'order clause' ERROR 42S22: Unknown column '?' in 'order clause'
set @arg00=1; set @arg00=1;
prepare stmt1 from ' select a,b from t1 prepare stmt1 from ' select a,b from t1 order by a
limit 1 '; limit 1 ';
execute stmt1 ; execute stmt1 ;
a b a b
...@@ -470,7 +470,7 @@ test_sequence ...@@ -470,7 +470,7 @@ test_sequence
------ join tests ------ ------ join tests ------
select first.a as a1, second.a as a2 select first.a as a1, second.a as a2
from t1 first, t1 second from t1 first, t1 second
where first.a = second.a ; where first.a = second.a order by a1 ;
a1 a2 a1 a2
1 1 1 1
2 2 2 2
...@@ -478,7 +478,7 @@ a1 a2 ...@@ -478,7 +478,7 @@ a1 a2
4 4 4 4
prepare stmt1 from ' select first.a as a1, second.a as a2 prepare stmt1 from ' select first.a as a1, second.a as a2
from t1 first, t1 second from t1 first, t1 second
where first.a = second.a '; where first.a = second.a order by a1 ';
execute stmt1 ; execute stmt1 ;
a1 a2 a1 a2
1 1 1 1
...@@ -517,17 +517,17 @@ a ? a ...@@ -517,17 +517,17 @@ a ? a
4 ABC 4 4 ABC 4
drop table if exists t2 ; drop table if exists t2 ;
create table t2 as select * from t1 ; create table t2 as select * from t1 ;
set @query1= 'SELECT * FROM t2 join t1 on (t1.a=t2.a) ' ; set @query1= 'SELECT * FROM t2 join t1 on (t1.a=t2.a) order by t2.a ' ;
set @query2= 'SELECT * FROM t2 natural join t1 ' ; set @query2= 'SELECT * FROM t2 natural join t1 order by t2.a ' ;
set @query3= 'SELECT * FROM t2 join t1 using(a) ' ; set @query3= 'SELECT * FROM t2 join t1 using(a) order by t2.a ' ;
set @query4= 'SELECT * FROM t2 left join t1 on(t1.a=t2.a) ' ; set @query4= 'SELECT * FROM t2 left join t1 on(t1.a=t2.a) order by t2.a ' ;
set @query5= 'SELECT * FROM t2 natural left join t1 ' ; set @query5= 'SELECT * FROM t2 natural left join t1 order by t2.a ' ;
set @query6= 'SELECT * FROM t2 left join t1 using(a) ' ; set @query6= 'SELECT * FROM t2 left join t1 using(a) order by t2.a ' ;
set @query7= 'SELECT * FROM t2 right join t1 on(t1.a=t2.a) ' ; set @query7= 'SELECT * FROM t2 right join t1 on(t1.a=t2.a) order by t2.a ' ;
set @query8= 'SELECT * FROM t2 natural right join t1 ' ; set @query8= 'SELECT * FROM t2 natural right join t1 order by t2.a ' ;
set @query9= 'SELECT * FROM t2 right join t1 using(a) ' ; set @query9= 'SELECT * FROM t2 right join t1 using(a) order by t2.a ' ;
the join statement is: the join statement is:
SELECT * FROM t2 right join t1 using(a) SELECT * FROM t2 right join t1 using(a) order by t2.a
prepare stmt1 from @query9 ; prepare stmt1 from @query9 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -548,7 +548,7 @@ a b a b ...@@ -548,7 +548,7 @@ a b a b
3 three 3 three 3 three 3 three
4 four 4 four 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 natural right join t1 SELECT * FROM t2 natural right join t1 order by t2.a
prepare stmt1 from @query8 ; prepare stmt1 from @query8 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -569,7 +569,7 @@ a b a b ...@@ -569,7 +569,7 @@ a b a b
3 three 3 three 3 three 3 three
4 four 4 four 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 right join t1 on(t1.a=t2.a) SELECT * FROM t2 right join t1 on(t1.a=t2.a) order by t2.a
prepare stmt1 from @query7 ; prepare stmt1 from @query7 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -590,7 +590,7 @@ a b a b ...@@ -590,7 +590,7 @@ a b a b
3 three 3 three 3 three 3 three
4 four 4 four 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 left join t1 using(a) SELECT * FROM t2 left join t1 using(a) order by t2.a
prepare stmt1 from @query6 ; prepare stmt1 from @query6 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -611,7 +611,7 @@ a b a b ...@@ -611,7 +611,7 @@ a b a b
3 three 3 three 3 three 3 three
4 four 4 four 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 natural left join t1 SELECT * FROM t2 natural left join t1 order by t2.a
prepare stmt1 from @query5 ; prepare stmt1 from @query5 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -632,7 +632,7 @@ a b a b ...@@ -632,7 +632,7 @@ a b a b
3 three 3 three 3 three 3 three
4 four 4 four 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 left join t1 on(t1.a=t2.a) SELECT * FROM t2 left join t1 on(t1.a=t2.a) order by t2.a
prepare stmt1 from @query4 ; prepare stmt1 from @query4 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -653,7 +653,7 @@ a b a b ...@@ -653,7 +653,7 @@ a b a b
3 three 3 three 3 three 3 three
4 four 4 four 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 join t1 using(a) SELECT * FROM t2 join t1 using(a) order by t2.a
prepare stmt1 from @query3 ; prepare stmt1 from @query3 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -674,7 +674,7 @@ a b a b ...@@ -674,7 +674,7 @@ a b a b
3 three 3 three 3 three 3 three
4 four 4 four 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 natural join t1 SELECT * FROM t2 natural join t1 order by t2.a
prepare stmt1 from @query2 ; prepare stmt1 from @query2 ;
execute stmt1 ; execute stmt1 ;
a b a b
...@@ -695,7 +695,7 @@ a b ...@@ -695,7 +695,7 @@ a b
3 three 3 three
4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 join t1 on (t1.a=t2.a) SELECT * FROM t2 join t1 on (t1.a=t2.a) order by t2.a
prepare stmt1 from @query1 ; prepare stmt1 from @query1 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -769,7 +769,7 @@ execute stmt1 using @arg00, @arg01, @arg02, @arg03 ; ...@@ -769,7 +769,7 @@ execute stmt1 using @arg00, @arg01, @arg02, @arg03 ;
a ? b a ? b
2 1 two 2 1 two
prepare stmt1 from ' select a, b FROM t1 outer_table where prepare stmt1 from ' select a, b FROM t1 outer_table where
a = (select a from t1 where b = outer_table.b ) '; a = (select a from t1 where b = outer_table.b ) order by a ';
execute stmt1 ; execute stmt1 ;
a b a b
1 one 1 one
......
...@@ -165,26 +165,26 @@ execute stmt1 using @arg00 ; ...@@ -165,26 +165,26 @@ execute stmt1 using @arg00 ;
substr('MySQL',1,?) substr('MySQL',1,?)
MyS MyS
set @arg00='MySQL' ; set @arg00='MySQL' ;
select a , concat(@arg00,b) from t1 ; select a , concat(@arg00,b) from t1 order by a;
a concat(@arg00,b) a concat(@arg00,b)
1 MySQLone 1 MySQLone
2 MySQLtwo 2 MySQLtwo
3 MySQLthree 3 MySQLthree
4 MySQLfour 4 MySQLfour
prepare stmt1 from ' select a , concat(?,b) from t1 ' ; prepare stmt1 from ' select a , concat(?,b) from t1 order by a ' ;
execute stmt1 using @arg00; execute stmt1 using @arg00;
a concat(?,b) a concat(?,b)
1 MySQLone 1 MySQLone
2 MySQLtwo 2 MySQLtwo
3 MySQLthree 3 MySQLthree
4 MySQLfour 4 MySQLfour
select a , concat(b,@arg00) from t1 ; select a , concat(b,@arg00) from t1 order by a ;
a concat(b,@arg00) a concat(b,@arg00)
1 oneMySQL 1 oneMySQL
2 twoMySQL 2 twoMySQL
3 threeMySQL 3 threeMySQL
4 fourMySQL 4 fourMySQL
prepare stmt1 from ' select a , concat(b,?) from t1 ' ; prepare stmt1 from ' select a , concat(b,?) from t1 order by a ' ;
execute stmt1 using @arg00; execute stmt1 using @arg00;
a concat(b,?) a concat(b,?)
1 oneMySQL 1 oneMySQL
...@@ -234,14 +234,14 @@ create table t5 (id1 int(11) not null default '0', ...@@ -234,14 +234,14 @@ create table t5 (id1 int(11) not null default '0',
value2 varchar(100), value1 varchar(100)) ; value2 varchar(100), value1 varchar(100)) ;
insert into t5 values (1,'hh','hh'),(2,'hh','hh'), insert into t5 values (1,'hh','hh'),(2,'hh','hh'),
(1,'ii','ii'),(2,'ii','ii') ; (1,'ii','ii'),(2,'ii','ii') ;
prepare stmt1 from ' select id1,value1 from t5 where id1=? or value1=? ' ; prepare stmt1 from ' select id1,value1 from t5 where id1=? or value1=? order by id1,value1 ' ;
set @arg00=1 ; set @arg00=1 ;
set @arg01='hh' ; set @arg01='hh' ;
execute stmt1 using @arg00, @arg01 ; execute stmt1 using @arg00, @arg01 ;
id1 value1 id1 value1
1 hh 1 hh
2 hh
1 ii 1 ii
2 hh
drop table t5 ; drop table t5 ;
drop table if exists t5 ; drop table if exists t5 ;
create table t5(session_id char(9) not null) ; create table t5(session_id char(9) not null) ;
...@@ -307,11 +307,11 @@ execute stmt1 using @arg00 ; ...@@ -307,11 +307,11 @@ execute stmt1 using @arg00 ;
a a
set @arg00=2 ; set @arg00=2 ;
set @arg01=3 ; set @arg01=3 ;
select a FROM t1 where a in (@arg00,@arg01); select a FROM t1 where a in (@arg00,@arg01) order by a;
a a
2 2
3 3
prepare stmt1 from ' select a FROM t1 where a in (?,?) '; prepare stmt1 from ' select a FROM t1 where a in (?,?) order by a ';
execute stmt1 using @arg00, @arg01; execute stmt1 using @arg00, @arg01;
a a
2 2
...@@ -385,13 +385,13 @@ a b ...@@ -385,13 +385,13 @@ a b
4 four 4 four
set @arg00='two' ; set @arg00='two' ;
select a,b FROM t1 where a is not NULL select a,b FROM t1 where a is not NULL
AND b is not NULL having b <> @arg00 ; AND b is not NULL having b <> @arg00 order by a ;
a b a b
1 one 1 one
3 three 3 three
4 four 4 four
prepare stmt1 from ' select a,b FROM t1 where a is not NULL prepare stmt1 from ' select a,b FROM t1 where a is not NULL
AND b is not NULL having b <> ? ' ; AND b is not NULL having b <> ? order by a ' ;
execute stmt1 using @arg00 ; execute stmt1 using @arg00 ;
a b a b
1 one 1 one
...@@ -439,7 +439,7 @@ set @arg00=0 ; ...@@ -439,7 +439,7 @@ set @arg00=0 ;
execute stmt1 using @arg00; execute stmt1 using @arg00;
ERROR 42S22: Unknown column '?' in 'order clause' ERROR 42S22: Unknown column '?' in 'order clause'
set @arg00=1; set @arg00=1;
prepare stmt1 from ' select a,b from t1 prepare stmt1 from ' select a,b from t1 order by a
limit 1 '; limit 1 ';
execute stmt1 ; execute stmt1 ;
a b a b
...@@ -470,7 +470,7 @@ test_sequence ...@@ -470,7 +470,7 @@ test_sequence
------ join tests ------ ------ join tests ------
select first.a as a1, second.a as a2 select first.a as a1, second.a as a2
from t1 first, t1 second from t1 first, t1 second
where first.a = second.a ; where first.a = second.a order by a1 ;
a1 a2 a1 a2
1 1 1 1
2 2 2 2
...@@ -478,7 +478,7 @@ a1 a2 ...@@ -478,7 +478,7 @@ a1 a2
4 4 4 4
prepare stmt1 from ' select first.a as a1, second.a as a2 prepare stmt1 from ' select first.a as a1, second.a as a2
from t1 first, t1 second from t1 first, t1 second
where first.a = second.a '; where first.a = second.a order by a1 ';
execute stmt1 ; execute stmt1 ;
a1 a2 a1 a2
1 1 1 1
...@@ -517,17 +517,17 @@ a ? a ...@@ -517,17 +517,17 @@ a ? a
4 ABC 4 4 ABC 4
drop table if exists t2 ; drop table if exists t2 ;
create table t2 as select * from t1 ; create table t2 as select * from t1 ;
set @query1= 'SELECT * FROM t2 join t1 on (t1.a=t2.a) ' ; set @query1= 'SELECT * FROM t2 join t1 on (t1.a=t2.a) order by t2.a ' ;
set @query2= 'SELECT * FROM t2 natural join t1 ' ; set @query2= 'SELECT * FROM t2 natural join t1 order by t2.a ' ;
set @query3= 'SELECT * FROM t2 join t1 using(a) ' ; set @query3= 'SELECT * FROM t2 join t1 using(a) order by t2.a ' ;
set @query4= 'SELECT * FROM t2 left join t1 on(t1.a=t2.a) ' ; set @query4= 'SELECT * FROM t2 left join t1 on(t1.a=t2.a) order by t2.a ' ;
set @query5= 'SELECT * FROM t2 natural left join t1 ' ; set @query5= 'SELECT * FROM t2 natural left join t1 order by t2.a ' ;
set @query6= 'SELECT * FROM t2 left join t1 using(a) ' ; set @query6= 'SELECT * FROM t2 left join t1 using(a) order by t2.a ' ;
set @query7= 'SELECT * FROM t2 right join t1 on(t1.a=t2.a) ' ; set @query7= 'SELECT * FROM t2 right join t1 on(t1.a=t2.a) order by t2.a ' ;
set @query8= 'SELECT * FROM t2 natural right join t1 ' ; set @query8= 'SELECT * FROM t2 natural right join t1 order by t2.a ' ;
set @query9= 'SELECT * FROM t2 right join t1 using(a) ' ; set @query9= 'SELECT * FROM t2 right join t1 using(a) order by t2.a ' ;
the join statement is: the join statement is:
SELECT * FROM t2 right join t1 using(a) SELECT * FROM t2 right join t1 using(a) order by t2.a
prepare stmt1 from @query9 ; prepare stmt1 from @query9 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -548,7 +548,7 @@ a b a b ...@@ -548,7 +548,7 @@ a b a b
3 three 3 three 3 three 3 three
4 four 4 four 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 natural right join t1 SELECT * FROM t2 natural right join t1 order by t2.a
prepare stmt1 from @query8 ; prepare stmt1 from @query8 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -569,7 +569,7 @@ a b a b ...@@ -569,7 +569,7 @@ a b a b
3 three 3 three 3 three 3 three
4 four 4 four 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 right join t1 on(t1.a=t2.a) SELECT * FROM t2 right join t1 on(t1.a=t2.a) order by t2.a
prepare stmt1 from @query7 ; prepare stmt1 from @query7 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -590,7 +590,7 @@ a b a b ...@@ -590,7 +590,7 @@ a b a b
3 three 3 three 3 three 3 three
4 four 4 four 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 left join t1 using(a) SELECT * FROM t2 left join t1 using(a) order by t2.a
prepare stmt1 from @query6 ; prepare stmt1 from @query6 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -611,7 +611,7 @@ a b a b ...@@ -611,7 +611,7 @@ a b a b
3 three 3 three 3 three 3 three
4 four 4 four 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 natural left join t1 SELECT * FROM t2 natural left join t1 order by t2.a
prepare stmt1 from @query5 ; prepare stmt1 from @query5 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -632,7 +632,7 @@ a b a b ...@@ -632,7 +632,7 @@ a b a b
3 three 3 three 3 three 3 three
4 four 4 four 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 left join t1 on(t1.a=t2.a) SELECT * FROM t2 left join t1 on(t1.a=t2.a) order by t2.a
prepare stmt1 from @query4 ; prepare stmt1 from @query4 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -653,7 +653,7 @@ a b a b ...@@ -653,7 +653,7 @@ a b a b
3 three 3 three 3 three 3 three
4 four 4 four 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 join t1 using(a) SELECT * FROM t2 join t1 using(a) order by t2.a
prepare stmt1 from @query3 ; prepare stmt1 from @query3 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -674,7 +674,7 @@ a b a b ...@@ -674,7 +674,7 @@ a b a b
3 three 3 three 3 three 3 three
4 four 4 four 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 natural join t1 SELECT * FROM t2 natural join t1 order by t2.a
prepare stmt1 from @query2 ; prepare stmt1 from @query2 ;
execute stmt1 ; execute stmt1 ;
a b a b
...@@ -695,7 +695,7 @@ a b ...@@ -695,7 +695,7 @@ a b
3 three 3 three
4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 join t1 on (t1.a=t2.a) SELECT * FROM t2 join t1 on (t1.a=t2.a) order by t2.a
prepare stmt1 from @query1 ; prepare stmt1 from @query1 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -769,7 +769,7 @@ execute stmt1 using @arg00, @arg01, @arg02, @arg03 ; ...@@ -769,7 +769,7 @@ execute stmt1 using @arg00, @arg01, @arg02, @arg03 ;
a ? b a ? b
2 1 two 2 1 two
prepare stmt1 from ' select a, b FROM t1 outer_table where prepare stmt1 from ' select a, b FROM t1 outer_table where
a = (select a from t1 where b = outer_table.b ) '; a = (select a from t1 where b = outer_table.b ) order by a ';
execute stmt1 ; execute stmt1 ;
a b a b
1 one 1 one
......
...@@ -166,26 +166,26 @@ execute stmt1 using @arg00 ; ...@@ -166,26 +166,26 @@ execute stmt1 using @arg00 ;
substr('MySQL',1,?) substr('MySQL',1,?)
MyS MyS
set @arg00='MySQL' ; set @arg00='MySQL' ;
select a , concat(@arg00,b) from t1 ; select a , concat(@arg00,b) from t1 order by a;
a concat(@arg00,b) a concat(@arg00,b)
1 MySQLone 1 MySQLone
2 MySQLtwo 2 MySQLtwo
3 MySQLthree 3 MySQLthree
4 MySQLfour 4 MySQLfour
prepare stmt1 from ' select a , concat(?,b) from t1 ' ; prepare stmt1 from ' select a , concat(?,b) from t1 order by a ' ;
execute stmt1 using @arg00; execute stmt1 using @arg00;
a concat(?,b) a concat(?,b)
1 MySQLone 1 MySQLone
2 MySQLtwo 2 MySQLtwo
3 MySQLthree 3 MySQLthree
4 MySQLfour 4 MySQLfour
select a , concat(b,@arg00) from t1 ; select a , concat(b,@arg00) from t1 order by a ;
a concat(b,@arg00) a concat(b,@arg00)
1 oneMySQL 1 oneMySQL
2 twoMySQL 2 twoMySQL
3 threeMySQL 3 threeMySQL
4 fourMySQL 4 fourMySQL
prepare stmt1 from ' select a , concat(b,?) from t1 ' ; prepare stmt1 from ' select a , concat(b,?) from t1 order by a ' ;
execute stmt1 using @arg00; execute stmt1 using @arg00;
a concat(b,?) a concat(b,?)
1 oneMySQL 1 oneMySQL
...@@ -235,14 +235,14 @@ create table t5 (id1 int(11) not null default '0', ...@@ -235,14 +235,14 @@ create table t5 (id1 int(11) not null default '0',
value2 varchar(100), value1 varchar(100)) ; value2 varchar(100), value1 varchar(100)) ;
insert into t5 values (1,'hh','hh'),(2,'hh','hh'), insert into t5 values (1,'hh','hh'),(2,'hh','hh'),
(1,'ii','ii'),(2,'ii','ii') ; (1,'ii','ii'),(2,'ii','ii') ;
prepare stmt1 from ' select id1,value1 from t5 where id1=? or value1=? ' ; prepare stmt1 from ' select id1,value1 from t5 where id1=? or value1=? order by id1,value1 ' ;
set @arg00=1 ; set @arg00=1 ;
set @arg01='hh' ; set @arg01='hh' ;
execute stmt1 using @arg00, @arg01 ; execute stmt1 using @arg00, @arg01 ;
id1 value1 id1 value1
1 hh 1 hh
2 hh
1 ii 1 ii
2 hh
drop table t5 ; drop table t5 ;
drop table if exists t5 ; drop table if exists t5 ;
create table t5(session_id char(9) not null) ; create table t5(session_id char(9) not null) ;
...@@ -308,11 +308,11 @@ execute stmt1 using @arg00 ; ...@@ -308,11 +308,11 @@ execute stmt1 using @arg00 ;
a a
set @arg00=2 ; set @arg00=2 ;
set @arg01=3 ; set @arg01=3 ;
select a FROM t1 where a in (@arg00,@arg01); select a FROM t1 where a in (@arg00,@arg01) order by a;
a a
2 2
3 3
prepare stmt1 from ' select a FROM t1 where a in (?,?) '; prepare stmt1 from ' select a FROM t1 where a in (?,?) order by a ';
execute stmt1 using @arg00, @arg01; execute stmt1 using @arg00, @arg01;
a a
2 2
...@@ -386,13 +386,13 @@ a b ...@@ -386,13 +386,13 @@ a b
4 four 4 four
set @arg00='two' ; set @arg00='two' ;
select a,b FROM t1 where a is not NULL select a,b FROM t1 where a is not NULL
AND b is not NULL having b <> @arg00 ; AND b is not NULL having b <> @arg00 order by a ;
a b a b
1 one 1 one
3 three 3 three
4 four 4 four
prepare stmt1 from ' select a,b FROM t1 where a is not NULL prepare stmt1 from ' select a,b FROM t1 where a is not NULL
AND b is not NULL having b <> ? ' ; AND b is not NULL having b <> ? order by a ' ;
execute stmt1 using @arg00 ; execute stmt1 using @arg00 ;
a b a b
1 one 1 one
...@@ -440,7 +440,7 @@ set @arg00=0 ; ...@@ -440,7 +440,7 @@ set @arg00=0 ;
execute stmt1 using @arg00; execute stmt1 using @arg00;
ERROR 42S22: Unknown column '?' in 'order clause' ERROR 42S22: Unknown column '?' in 'order clause'
set @arg00=1; set @arg00=1;
prepare stmt1 from ' select a,b from t1 prepare stmt1 from ' select a,b from t1 order by a
limit 1 '; limit 1 ';
execute stmt1 ; execute stmt1 ;
a b a b
...@@ -471,7 +471,7 @@ test_sequence ...@@ -471,7 +471,7 @@ test_sequence
------ join tests ------ ------ join tests ------
select first.a as a1, second.a as a2 select first.a as a1, second.a as a2
from t1 first, t1 second from t1 first, t1 second
where first.a = second.a ; where first.a = second.a order by a1 ;
a1 a2 a1 a2
1 1 1 1
2 2 2 2
...@@ -479,7 +479,7 @@ a1 a2 ...@@ -479,7 +479,7 @@ a1 a2
4 4 4 4
prepare stmt1 from ' select first.a as a1, second.a as a2 prepare stmt1 from ' select first.a as a1, second.a as a2
from t1 first, t1 second from t1 first, t1 second
where first.a = second.a '; where first.a = second.a order by a1 ';
execute stmt1 ; execute stmt1 ;
a1 a2 a1 a2
1 1 1 1
...@@ -518,17 +518,17 @@ a ? a ...@@ -518,17 +518,17 @@ a ? a
4 ABC 4 4 ABC 4
drop table if exists t2 ; drop table if exists t2 ;
create table t2 as select * from t1 ; create table t2 as select * from t1 ;
set @query1= 'SELECT * FROM t2 join t1 on (t1.a=t2.a) ' ; set @query1= 'SELECT * FROM t2 join t1 on (t1.a=t2.a) order by t2.a ' ;
set @query2= 'SELECT * FROM t2 natural join t1 ' ; set @query2= 'SELECT * FROM t2 natural join t1 order by t2.a ' ;
set @query3= 'SELECT * FROM t2 join t1 using(a) ' ; set @query3= 'SELECT * FROM t2 join t1 using(a) order by t2.a ' ;
set @query4= 'SELECT * FROM t2 left join t1 on(t1.a=t2.a) ' ; set @query4= 'SELECT * FROM t2 left join t1 on(t1.a=t2.a) order by t2.a ' ;
set @query5= 'SELECT * FROM t2 natural left join t1 ' ; set @query5= 'SELECT * FROM t2 natural left join t1 order by t2.a ' ;
set @query6= 'SELECT * FROM t2 left join t1 using(a) ' ; set @query6= 'SELECT * FROM t2 left join t1 using(a) order by t2.a ' ;
set @query7= 'SELECT * FROM t2 right join t1 on(t1.a=t2.a) ' ; set @query7= 'SELECT * FROM t2 right join t1 on(t1.a=t2.a) order by t2.a ' ;
set @query8= 'SELECT * FROM t2 natural right join t1 ' ; set @query8= 'SELECT * FROM t2 natural right join t1 order by t2.a ' ;
set @query9= 'SELECT * FROM t2 right join t1 using(a) ' ; set @query9= 'SELECT * FROM t2 right join t1 using(a) order by t2.a ' ;
the join statement is: the join statement is:
SELECT * FROM t2 right join t1 using(a) SELECT * FROM t2 right join t1 using(a) order by t2.a
prepare stmt1 from @query9 ; prepare stmt1 from @query9 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -549,7 +549,7 @@ a b a b ...@@ -549,7 +549,7 @@ a b a b
3 three 3 three 3 three 3 three
4 four 4 four 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 natural right join t1 SELECT * FROM t2 natural right join t1 order by t2.a
prepare stmt1 from @query8 ; prepare stmt1 from @query8 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -570,7 +570,7 @@ a b a b ...@@ -570,7 +570,7 @@ a b a b
3 three 3 three 3 three 3 three
4 four 4 four 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 right join t1 on(t1.a=t2.a) SELECT * FROM t2 right join t1 on(t1.a=t2.a) order by t2.a
prepare stmt1 from @query7 ; prepare stmt1 from @query7 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -591,7 +591,7 @@ a b a b ...@@ -591,7 +591,7 @@ a b a b
3 three 3 three 3 three 3 three
4 four 4 four 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 left join t1 using(a) SELECT * FROM t2 left join t1 using(a) order by t2.a
prepare stmt1 from @query6 ; prepare stmt1 from @query6 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -612,7 +612,7 @@ a b a b ...@@ -612,7 +612,7 @@ a b a b
3 three 3 three 3 three 3 three
4 four 4 four 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 natural left join t1 SELECT * FROM t2 natural left join t1 order by t2.a
prepare stmt1 from @query5 ; prepare stmt1 from @query5 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -633,7 +633,7 @@ a b a b ...@@ -633,7 +633,7 @@ a b a b
3 three 3 three 3 three 3 three
4 four 4 four 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 left join t1 on(t1.a=t2.a) SELECT * FROM t2 left join t1 on(t1.a=t2.a) order by t2.a
prepare stmt1 from @query4 ; prepare stmt1 from @query4 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -654,7 +654,7 @@ a b a b ...@@ -654,7 +654,7 @@ a b a b
3 three 3 three 3 three 3 three
4 four 4 four 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 join t1 using(a) SELECT * FROM t2 join t1 using(a) order by t2.a
prepare stmt1 from @query3 ; prepare stmt1 from @query3 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -675,7 +675,7 @@ a b a b ...@@ -675,7 +675,7 @@ a b a b
3 three 3 three 3 three 3 three
4 four 4 four 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 natural join t1 SELECT * FROM t2 natural join t1 order by t2.a
prepare stmt1 from @query2 ; prepare stmt1 from @query2 ;
execute stmt1 ; execute stmt1 ;
a b a b
...@@ -696,7 +696,7 @@ a b ...@@ -696,7 +696,7 @@ a b
3 three 3 three
4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 join t1 on (t1.a=t2.a) SELECT * FROM t2 join t1 on (t1.a=t2.a) order by t2.a
prepare stmt1 from @query1 ; prepare stmt1 from @query1 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -770,7 +770,7 @@ execute stmt1 using @arg00, @arg01, @arg02, @arg03 ; ...@@ -770,7 +770,7 @@ execute stmt1 using @arg00, @arg01, @arg02, @arg03 ;
a ? b a ? b
2 1 two 2 1 two
prepare stmt1 from ' select a, b FROM t1 outer_table where prepare stmt1 from ' select a, b FROM t1 outer_table where
a = (select a from t1 where b = outer_table.b ) '; a = (select a from t1 where b = outer_table.b ) order by a ';
execute stmt1 ; execute stmt1 ;
a b a b
1 one 1 one
......
...@@ -208,26 +208,26 @@ execute stmt1 using @arg00 ; ...@@ -208,26 +208,26 @@ execute stmt1 using @arg00 ;
substr('MySQL',1,?) substr('MySQL',1,?)
MyS MyS
set @arg00='MySQL' ; set @arg00='MySQL' ;
select a , concat(@arg00,b) from t1 ; select a , concat(@arg00,b) from t1 order by a;
a concat(@arg00,b) a concat(@arg00,b)
1 MySQLone 1 MySQLone
2 MySQLtwo 2 MySQLtwo
3 MySQLthree 3 MySQLthree
4 MySQLfour 4 MySQLfour
prepare stmt1 from ' select a , concat(?,b) from t1 ' ; prepare stmt1 from ' select a , concat(?,b) from t1 order by a ' ;
execute stmt1 using @arg00; execute stmt1 using @arg00;
a concat(?,b) a concat(?,b)
1 MySQLone 1 MySQLone
2 MySQLtwo 2 MySQLtwo
3 MySQLthree 3 MySQLthree
4 MySQLfour 4 MySQLfour
select a , concat(b,@arg00) from t1 ; select a , concat(b,@arg00) from t1 order by a ;
a concat(b,@arg00) a concat(b,@arg00)
1 oneMySQL 1 oneMySQL
2 twoMySQL 2 twoMySQL
3 threeMySQL 3 threeMySQL
4 fourMySQL 4 fourMySQL
prepare stmt1 from ' select a , concat(b,?) from t1 ' ; prepare stmt1 from ' select a , concat(b,?) from t1 order by a ' ;
execute stmt1 using @arg00; execute stmt1 using @arg00;
a concat(b,?) a concat(b,?)
1 oneMySQL 1 oneMySQL
...@@ -277,14 +277,14 @@ create table t5 (id1 int(11) not null default '0', ...@@ -277,14 +277,14 @@ create table t5 (id1 int(11) not null default '0',
value2 varchar(100), value1 varchar(100)) ; value2 varchar(100), value1 varchar(100)) ;
insert into t5 values (1,'hh','hh'),(2,'hh','hh'), insert into t5 values (1,'hh','hh'),(2,'hh','hh'),
(1,'ii','ii'),(2,'ii','ii') ; (1,'ii','ii'),(2,'ii','ii') ;
prepare stmt1 from ' select id1,value1 from t5 where id1=? or value1=? ' ; prepare stmt1 from ' select id1,value1 from t5 where id1=? or value1=? order by id1,value1 ' ;
set @arg00=1 ; set @arg00=1 ;
set @arg01='hh' ; set @arg01='hh' ;
execute stmt1 using @arg00, @arg01 ; execute stmt1 using @arg00, @arg01 ;
id1 value1 id1 value1
1 hh 1 hh
2 hh
1 ii 1 ii
2 hh
drop table t5 ; drop table t5 ;
drop table if exists t5 ; drop table if exists t5 ;
create table t5(session_id char(9) not null) ; create table t5(session_id char(9) not null) ;
...@@ -350,11 +350,11 @@ execute stmt1 using @arg00 ; ...@@ -350,11 +350,11 @@ execute stmt1 using @arg00 ;
a a
set @arg00=2 ; set @arg00=2 ;
set @arg01=3 ; set @arg01=3 ;
select a FROM t1 where a in (@arg00,@arg01); select a FROM t1 where a in (@arg00,@arg01) order by a;
a a
2 2
3 3
prepare stmt1 from ' select a FROM t1 where a in (?,?) '; prepare stmt1 from ' select a FROM t1 where a in (?,?) order by a ';
execute stmt1 using @arg00, @arg01; execute stmt1 using @arg00, @arg01;
a a
2 2
...@@ -428,13 +428,13 @@ a b ...@@ -428,13 +428,13 @@ a b
4 four 4 four
set @arg00='two' ; set @arg00='two' ;
select a,b FROM t1 where a is not NULL select a,b FROM t1 where a is not NULL
AND b is not NULL having b <> @arg00 ; AND b is not NULL having b <> @arg00 order by a ;
a b a b
1 one 1 one
3 three 3 three
4 four 4 four
prepare stmt1 from ' select a,b FROM t1 where a is not NULL prepare stmt1 from ' select a,b FROM t1 where a is not NULL
AND b is not NULL having b <> ? ' ; AND b is not NULL having b <> ? order by a ' ;
execute stmt1 using @arg00 ; execute stmt1 using @arg00 ;
a b a b
1 one 1 one
...@@ -482,7 +482,7 @@ set @arg00=0 ; ...@@ -482,7 +482,7 @@ set @arg00=0 ;
execute stmt1 using @arg00; execute stmt1 using @arg00;
ERROR 42S22: Unknown column '?' in 'order clause' ERROR 42S22: Unknown column '?' in 'order clause'
set @arg00=1; set @arg00=1;
prepare stmt1 from ' select a,b from t1 prepare stmt1 from ' select a,b from t1 order by a
limit 1 '; limit 1 ';
execute stmt1 ; execute stmt1 ;
a b a b
...@@ -513,7 +513,7 @@ test_sequence ...@@ -513,7 +513,7 @@ test_sequence
------ join tests ------ ------ join tests ------
select first.a as a1, second.a as a2 select first.a as a1, second.a as a2
from t1 first, t1 second from t1 first, t1 second
where first.a = second.a ; where first.a = second.a order by a1 ;
a1 a2 a1 a2
1 1 1 1
2 2 2 2
...@@ -521,7 +521,7 @@ a1 a2 ...@@ -521,7 +521,7 @@ a1 a2
4 4 4 4
prepare stmt1 from ' select first.a as a1, second.a as a2 prepare stmt1 from ' select first.a as a1, second.a as a2
from t1 first, t1 second from t1 first, t1 second
where first.a = second.a '; where first.a = second.a order by a1 ';
execute stmt1 ; execute stmt1 ;
a1 a2 a1 a2
1 1 1 1
...@@ -560,17 +560,17 @@ a ? a ...@@ -560,17 +560,17 @@ a ? a
4 ABC 4 4 ABC 4
drop table if exists t2 ; drop table if exists t2 ;
create table t2 as select * from t1 ; create table t2 as select * from t1 ;
set @query1= 'SELECT * FROM t2 join t1 on (t1.a=t2.a) ' ; set @query1= 'SELECT * FROM t2 join t1 on (t1.a=t2.a) order by t2.a ' ;
set @query2= 'SELECT * FROM t2 natural join t1 ' ; set @query2= 'SELECT * FROM t2 natural join t1 order by t2.a ' ;
set @query3= 'SELECT * FROM t2 join t1 using(a) ' ; set @query3= 'SELECT * FROM t2 join t1 using(a) order by t2.a ' ;
set @query4= 'SELECT * FROM t2 left join t1 on(t1.a=t2.a) ' ; set @query4= 'SELECT * FROM t2 left join t1 on(t1.a=t2.a) order by t2.a ' ;
set @query5= 'SELECT * FROM t2 natural left join t1 ' ; set @query5= 'SELECT * FROM t2 natural left join t1 order by t2.a ' ;
set @query6= 'SELECT * FROM t2 left join t1 using(a) ' ; set @query6= 'SELECT * FROM t2 left join t1 using(a) order by t2.a ' ;
set @query7= 'SELECT * FROM t2 right join t1 on(t1.a=t2.a) ' ; set @query7= 'SELECT * FROM t2 right join t1 on(t1.a=t2.a) order by t2.a ' ;
set @query8= 'SELECT * FROM t2 natural right join t1 ' ; set @query8= 'SELECT * FROM t2 natural right join t1 order by t2.a ' ;
set @query9= 'SELECT * FROM t2 right join t1 using(a) ' ; set @query9= 'SELECT * FROM t2 right join t1 using(a) order by t2.a ' ;
the join statement is: the join statement is:
SELECT * FROM t2 right join t1 using(a) SELECT * FROM t2 right join t1 using(a) order by t2.a
prepare stmt1 from @query9 ; prepare stmt1 from @query9 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -591,7 +591,7 @@ a b a b ...@@ -591,7 +591,7 @@ a b a b
3 three 3 three 3 three 3 three
4 four 4 four 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 natural right join t1 SELECT * FROM t2 natural right join t1 order by t2.a
prepare stmt1 from @query8 ; prepare stmt1 from @query8 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -612,7 +612,7 @@ a b a b ...@@ -612,7 +612,7 @@ a b a b
3 three 3 three 3 three 3 three
4 four 4 four 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 right join t1 on(t1.a=t2.a) SELECT * FROM t2 right join t1 on(t1.a=t2.a) order by t2.a
prepare stmt1 from @query7 ; prepare stmt1 from @query7 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -633,7 +633,7 @@ a b a b ...@@ -633,7 +633,7 @@ a b a b
3 three 3 three 3 three 3 three
4 four 4 four 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 left join t1 using(a) SELECT * FROM t2 left join t1 using(a) order by t2.a
prepare stmt1 from @query6 ; prepare stmt1 from @query6 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -654,7 +654,7 @@ a b a b ...@@ -654,7 +654,7 @@ a b a b
3 three 3 three 3 three 3 three
4 four 4 four 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 natural left join t1 SELECT * FROM t2 natural left join t1 order by t2.a
prepare stmt1 from @query5 ; prepare stmt1 from @query5 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -675,7 +675,7 @@ a b a b ...@@ -675,7 +675,7 @@ a b a b
3 three 3 three 3 three 3 three
4 four 4 four 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 left join t1 on(t1.a=t2.a) SELECT * FROM t2 left join t1 on(t1.a=t2.a) order by t2.a
prepare stmt1 from @query4 ; prepare stmt1 from @query4 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -696,7 +696,7 @@ a b a b ...@@ -696,7 +696,7 @@ a b a b
3 three 3 three 3 three 3 three
4 four 4 four 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 join t1 using(a) SELECT * FROM t2 join t1 using(a) order by t2.a
prepare stmt1 from @query3 ; prepare stmt1 from @query3 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -717,7 +717,7 @@ a b a b ...@@ -717,7 +717,7 @@ a b a b
3 three 3 three 3 three 3 three
4 four 4 four 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 natural join t1 SELECT * FROM t2 natural join t1 order by t2.a
prepare stmt1 from @query2 ; prepare stmt1 from @query2 ;
execute stmt1 ; execute stmt1 ;
a b a b
...@@ -738,7 +738,7 @@ a b ...@@ -738,7 +738,7 @@ a b
3 three 3 three
4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 join t1 on (t1.a=t2.a) SELECT * FROM t2 join t1 on (t1.a=t2.a) order by t2.a
prepare stmt1 from @query1 ; prepare stmt1 from @query1 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -812,7 +812,7 @@ execute stmt1 using @arg00, @arg01, @arg02, @arg03 ; ...@@ -812,7 +812,7 @@ execute stmt1 using @arg00, @arg01, @arg02, @arg03 ;
a ? b a ? b
2 1 two 2 1 two
prepare stmt1 from ' select a, b FROM t1 outer_table where prepare stmt1 from ' select a, b FROM t1 outer_table where
a = (select a from t1 where b = outer_table.b ) '; a = (select a from t1 where b = outer_table.b ) order by a ';
execute stmt1 ; execute stmt1 ;
a b a b
1 one 1 one
...@@ -3216,26 +3216,26 @@ execute stmt1 using @arg00 ; ...@@ -3216,26 +3216,26 @@ execute stmt1 using @arg00 ;
substr('MySQL',1,?) substr('MySQL',1,?)
MyS MyS
set @arg00='MySQL' ; set @arg00='MySQL' ;
select a , concat(@arg00,b) from t1 ; select a , concat(@arg00,b) from t1 order by a;
a concat(@arg00,b) a concat(@arg00,b)
1 MySQLone 1 MySQLone
2 MySQLtwo 2 MySQLtwo
3 MySQLthree 3 MySQLthree
4 MySQLfour 4 MySQLfour
prepare stmt1 from ' select a , concat(?,b) from t1 ' ; prepare stmt1 from ' select a , concat(?,b) from t1 order by a ' ;
execute stmt1 using @arg00; execute stmt1 using @arg00;
a concat(?,b) a concat(?,b)
1 MySQLone 1 MySQLone
2 MySQLtwo 2 MySQLtwo
3 MySQLthree 3 MySQLthree
4 MySQLfour 4 MySQLfour
select a , concat(b,@arg00) from t1 ; select a , concat(b,@arg00) from t1 order by a ;
a concat(b,@arg00) a concat(b,@arg00)
1 oneMySQL 1 oneMySQL
2 twoMySQL 2 twoMySQL
3 threeMySQL 3 threeMySQL
4 fourMySQL 4 fourMySQL
prepare stmt1 from ' select a , concat(b,?) from t1 ' ; prepare stmt1 from ' select a , concat(b,?) from t1 order by a ' ;
execute stmt1 using @arg00; execute stmt1 using @arg00;
a concat(b,?) a concat(b,?)
1 oneMySQL 1 oneMySQL
...@@ -3285,14 +3285,14 @@ create table t5 (id1 int(11) not null default '0', ...@@ -3285,14 +3285,14 @@ create table t5 (id1 int(11) not null default '0',
value2 varchar(100), value1 varchar(100)) ; value2 varchar(100), value1 varchar(100)) ;
insert into t5 values (1,'hh','hh'),(2,'hh','hh'), insert into t5 values (1,'hh','hh'),(2,'hh','hh'),
(1,'ii','ii'),(2,'ii','ii') ; (1,'ii','ii'),(2,'ii','ii') ;
prepare stmt1 from ' select id1,value1 from t5 where id1=? or value1=? ' ; prepare stmt1 from ' select id1,value1 from t5 where id1=? or value1=? order by id1,value1 ' ;
set @arg00=1 ; set @arg00=1 ;
set @arg01='hh' ; set @arg01='hh' ;
execute stmt1 using @arg00, @arg01 ; execute stmt1 using @arg00, @arg01 ;
id1 value1 id1 value1
1 hh 1 hh
2 hh
1 ii 1 ii
2 hh
drop table t5 ; drop table t5 ;
drop table if exists t5 ; drop table if exists t5 ;
create table t5(session_id char(9) not null) ; create table t5(session_id char(9) not null) ;
...@@ -3358,11 +3358,11 @@ execute stmt1 using @arg00 ; ...@@ -3358,11 +3358,11 @@ execute stmt1 using @arg00 ;
a a
set @arg00=2 ; set @arg00=2 ;
set @arg01=3 ; set @arg01=3 ;
select a FROM t1 where a in (@arg00,@arg01); select a FROM t1 where a in (@arg00,@arg01) order by a;
a a
2 2
3 3
prepare stmt1 from ' select a FROM t1 where a in (?,?) '; prepare stmt1 from ' select a FROM t1 where a in (?,?) order by a ';
execute stmt1 using @arg00, @arg01; execute stmt1 using @arg00, @arg01;
a a
2 2
...@@ -3436,13 +3436,13 @@ a b ...@@ -3436,13 +3436,13 @@ a b
4 four 4 four
set @arg00='two' ; set @arg00='two' ;
select a,b FROM t1 where a is not NULL select a,b FROM t1 where a is not NULL
AND b is not NULL having b <> @arg00 ; AND b is not NULL having b <> @arg00 order by a ;
a b a b
1 one 1 one
3 three 3 three
4 four 4 four
prepare stmt1 from ' select a,b FROM t1 where a is not NULL prepare stmt1 from ' select a,b FROM t1 where a is not NULL
AND b is not NULL having b <> ? ' ; AND b is not NULL having b <> ? order by a ' ;
execute stmt1 using @arg00 ; execute stmt1 using @arg00 ;
a b a b
1 one 1 one
...@@ -3490,7 +3490,7 @@ set @arg00=0 ; ...@@ -3490,7 +3490,7 @@ set @arg00=0 ;
execute stmt1 using @arg00; execute stmt1 using @arg00;
ERROR 42S22: Unknown column '?' in 'order clause' ERROR 42S22: Unknown column '?' in 'order clause'
set @arg00=1; set @arg00=1;
prepare stmt1 from ' select a,b from t1 prepare stmt1 from ' select a,b from t1 order by a
limit 1 '; limit 1 ';
execute stmt1 ; execute stmt1 ;
a b a b
...@@ -3521,7 +3521,7 @@ test_sequence ...@@ -3521,7 +3521,7 @@ test_sequence
------ join tests ------ ------ join tests ------
select first.a as a1, second.a as a2 select first.a as a1, second.a as a2
from t1 first, t1 second from t1 first, t1 second
where first.a = second.a ; where first.a = second.a order by a1 ;
a1 a2 a1 a2
1 1 1 1
2 2 2 2
...@@ -3529,7 +3529,7 @@ a1 a2 ...@@ -3529,7 +3529,7 @@ a1 a2
4 4 4 4
prepare stmt1 from ' select first.a as a1, second.a as a2 prepare stmt1 from ' select first.a as a1, second.a as a2
from t1 first, t1 second from t1 first, t1 second
where first.a = second.a '; where first.a = second.a order by a1 ';
execute stmt1 ; execute stmt1 ;
a1 a2 a1 a2
1 1 1 1
...@@ -3568,17 +3568,17 @@ a ? a ...@@ -3568,17 +3568,17 @@ a ? a
4 ABC 4 4 ABC 4
drop table if exists t2 ; drop table if exists t2 ;
create table t2 as select * from t1 ; create table t2 as select * from t1 ;
set @query1= 'SELECT * FROM t2 join t1 on (t1.a=t2.a) ' ; set @query1= 'SELECT * FROM t2 join t1 on (t1.a=t2.a) order by t2.a ' ;
set @query2= 'SELECT * FROM t2 natural join t1 ' ; set @query2= 'SELECT * FROM t2 natural join t1 order by t2.a ' ;
set @query3= 'SELECT * FROM t2 join t1 using(a) ' ; set @query3= 'SELECT * FROM t2 join t1 using(a) order by t2.a ' ;
set @query4= 'SELECT * FROM t2 left join t1 on(t1.a=t2.a) ' ; set @query4= 'SELECT * FROM t2 left join t1 on(t1.a=t2.a) order by t2.a ' ;
set @query5= 'SELECT * FROM t2 natural left join t1 ' ; set @query5= 'SELECT * FROM t2 natural left join t1 order by t2.a ' ;
set @query6= 'SELECT * FROM t2 left join t1 using(a) ' ; set @query6= 'SELECT * FROM t2 left join t1 using(a) order by t2.a ' ;
set @query7= 'SELECT * FROM t2 right join t1 on(t1.a=t2.a) ' ; set @query7= 'SELECT * FROM t2 right join t1 on(t1.a=t2.a) order by t2.a ' ;
set @query8= 'SELECT * FROM t2 natural right join t1 ' ; set @query8= 'SELECT * FROM t2 natural right join t1 order by t2.a ' ;
set @query9= 'SELECT * FROM t2 right join t1 using(a) ' ; set @query9= 'SELECT * FROM t2 right join t1 using(a) order by t2.a ' ;
the join statement is: the join statement is:
SELECT * FROM t2 right join t1 using(a) SELECT * FROM t2 right join t1 using(a) order by t2.a
prepare stmt1 from @query9 ; prepare stmt1 from @query9 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -3599,7 +3599,7 @@ a b a b ...@@ -3599,7 +3599,7 @@ a b a b
3 three 3 three 3 three 3 three
4 four 4 four 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 natural right join t1 SELECT * FROM t2 natural right join t1 order by t2.a
prepare stmt1 from @query8 ; prepare stmt1 from @query8 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -3620,7 +3620,7 @@ a b a b ...@@ -3620,7 +3620,7 @@ a b a b
3 three 3 three 3 three 3 three
4 four 4 four 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 right join t1 on(t1.a=t2.a) SELECT * FROM t2 right join t1 on(t1.a=t2.a) order by t2.a
prepare stmt1 from @query7 ; prepare stmt1 from @query7 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -3641,7 +3641,7 @@ a b a b ...@@ -3641,7 +3641,7 @@ a b a b
3 three 3 three 3 three 3 three
4 four 4 four 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 left join t1 using(a) SELECT * FROM t2 left join t1 using(a) order by t2.a
prepare stmt1 from @query6 ; prepare stmt1 from @query6 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -3662,7 +3662,7 @@ a b a b ...@@ -3662,7 +3662,7 @@ a b a b
3 three 3 three 3 three 3 three
4 four 4 four 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 natural left join t1 SELECT * FROM t2 natural left join t1 order by t2.a
prepare stmt1 from @query5 ; prepare stmt1 from @query5 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -3683,7 +3683,7 @@ a b a b ...@@ -3683,7 +3683,7 @@ a b a b
3 three 3 three 3 three 3 three
4 four 4 four 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 left join t1 on(t1.a=t2.a) SELECT * FROM t2 left join t1 on(t1.a=t2.a) order by t2.a
prepare stmt1 from @query4 ; prepare stmt1 from @query4 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -3704,7 +3704,7 @@ a b a b ...@@ -3704,7 +3704,7 @@ a b a b
3 three 3 three 3 three 3 three
4 four 4 four 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 join t1 using(a) SELECT * FROM t2 join t1 using(a) order by t2.a
prepare stmt1 from @query3 ; prepare stmt1 from @query3 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -3725,7 +3725,7 @@ a b a b ...@@ -3725,7 +3725,7 @@ a b a b
3 three 3 three 3 three 3 three
4 four 4 four 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 natural join t1 SELECT * FROM t2 natural join t1 order by t2.a
prepare stmt1 from @query2 ; prepare stmt1 from @query2 ;
execute stmt1 ; execute stmt1 ;
a b a b
...@@ -3746,7 +3746,7 @@ a b ...@@ -3746,7 +3746,7 @@ a b
3 three 3 three
4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 join t1 on (t1.a=t2.a) SELECT * FROM t2 join t1 on (t1.a=t2.a) order by t2.a
prepare stmt1 from @query1 ; prepare stmt1 from @query1 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -3820,7 +3820,7 @@ execute stmt1 using @arg00, @arg01, @arg02, @arg03 ; ...@@ -3820,7 +3820,7 @@ execute stmt1 using @arg00, @arg01, @arg02, @arg03 ;
a ? b a ? b
2 1 two 2 1 two
prepare stmt1 from ' select a, b FROM t1 outer_table where prepare stmt1 from ' select a, b FROM t1 outer_table where
a = (select a from t1 where b = outer_table.b ) '; a = (select a from t1 where b = outer_table.b ) order by a ';
execute stmt1 ; execute stmt1 ;
a b a b
1 one 1 one
......
...@@ -165,26 +165,26 @@ execute stmt1 using @arg00 ; ...@@ -165,26 +165,26 @@ execute stmt1 using @arg00 ;
substr('MySQL',1,?) substr('MySQL',1,?)
MyS MyS
set @arg00='MySQL' ; set @arg00='MySQL' ;
select a , concat(@arg00,b) from t1 ; select a , concat(@arg00,b) from t1 order by a;
a concat(@arg00,b) a concat(@arg00,b)
1 MySQLone 1 MySQLone
2 MySQLtwo 2 MySQLtwo
3 MySQLthree 3 MySQLthree
4 MySQLfour 4 MySQLfour
prepare stmt1 from ' select a , concat(?,b) from t1 ' ; prepare stmt1 from ' select a , concat(?,b) from t1 order by a ' ;
execute stmt1 using @arg00; execute stmt1 using @arg00;
a concat(?,b) a concat(?,b)
1 MySQLone 1 MySQLone
2 MySQLtwo 2 MySQLtwo
3 MySQLthree 3 MySQLthree
4 MySQLfour 4 MySQLfour
select a , concat(b,@arg00) from t1 ; select a , concat(b,@arg00) from t1 order by a ;
a concat(b,@arg00) a concat(b,@arg00)
1 oneMySQL 1 oneMySQL
2 twoMySQL 2 twoMySQL
3 threeMySQL 3 threeMySQL
4 fourMySQL 4 fourMySQL
prepare stmt1 from ' select a , concat(b,?) from t1 ' ; prepare stmt1 from ' select a , concat(b,?) from t1 order by a ' ;
execute stmt1 using @arg00; execute stmt1 using @arg00;
a concat(b,?) a concat(b,?)
1 oneMySQL 1 oneMySQL
...@@ -234,14 +234,14 @@ create table t5 (id1 int(11) not null default '0', ...@@ -234,14 +234,14 @@ create table t5 (id1 int(11) not null default '0',
value2 varchar(100), value1 varchar(100)) ; value2 varchar(100), value1 varchar(100)) ;
insert into t5 values (1,'hh','hh'),(2,'hh','hh'), insert into t5 values (1,'hh','hh'),(2,'hh','hh'),
(1,'ii','ii'),(2,'ii','ii') ; (1,'ii','ii'),(2,'ii','ii') ;
prepare stmt1 from ' select id1,value1 from t5 where id1=? or value1=? ' ; prepare stmt1 from ' select id1,value1 from t5 where id1=? or value1=? order by id1,value1 ' ;
set @arg00=1 ; set @arg00=1 ;
set @arg01='hh' ; set @arg01='hh' ;
execute stmt1 using @arg00, @arg01 ; execute stmt1 using @arg00, @arg01 ;
id1 value1 id1 value1
1 hh 1 hh
2 hh
1 ii 1 ii
2 hh
drop table t5 ; drop table t5 ;
drop table if exists t5 ; drop table if exists t5 ;
create table t5(session_id char(9) not null) ; create table t5(session_id char(9) not null) ;
...@@ -307,11 +307,11 @@ execute stmt1 using @arg00 ; ...@@ -307,11 +307,11 @@ execute stmt1 using @arg00 ;
a a
set @arg00=2 ; set @arg00=2 ;
set @arg01=3 ; set @arg01=3 ;
select a FROM t1 where a in (@arg00,@arg01); select a FROM t1 where a in (@arg00,@arg01) order by a;
a a
2 2
3 3
prepare stmt1 from ' select a FROM t1 where a in (?,?) '; prepare stmt1 from ' select a FROM t1 where a in (?,?) order by a ';
execute stmt1 using @arg00, @arg01; execute stmt1 using @arg00, @arg01;
a a
2 2
...@@ -385,13 +385,13 @@ a b ...@@ -385,13 +385,13 @@ a b
4 four 4 four
set @arg00='two' ; set @arg00='two' ;
select a,b FROM t1 where a is not NULL select a,b FROM t1 where a is not NULL
AND b is not NULL having b <> @arg00 ; AND b is not NULL having b <> @arg00 order by a ;
a b a b
1 one 1 one
3 three 3 three
4 four 4 four
prepare stmt1 from ' select a,b FROM t1 where a is not NULL prepare stmt1 from ' select a,b FROM t1 where a is not NULL
AND b is not NULL having b <> ? ' ; AND b is not NULL having b <> ? order by a ' ;
execute stmt1 using @arg00 ; execute stmt1 using @arg00 ;
a b a b
1 one 1 one
...@@ -439,7 +439,7 @@ set @arg00=0 ; ...@@ -439,7 +439,7 @@ set @arg00=0 ;
execute stmt1 using @arg00; execute stmt1 using @arg00;
ERROR 42S22: Unknown column '?' in 'order clause' ERROR 42S22: Unknown column '?' in 'order clause'
set @arg00=1; set @arg00=1;
prepare stmt1 from ' select a,b from t1 prepare stmt1 from ' select a,b from t1 order by a
limit 1 '; limit 1 ';
execute stmt1 ; execute stmt1 ;
a b a b
...@@ -470,7 +470,7 @@ test_sequence ...@@ -470,7 +470,7 @@ test_sequence
------ join tests ------ ------ join tests ------
select first.a as a1, second.a as a2 select first.a as a1, second.a as a2
from t1 first, t1 second from t1 first, t1 second
where first.a = second.a ; where first.a = second.a order by a1 ;
a1 a2 a1 a2
1 1 1 1
2 2 2 2
...@@ -478,7 +478,7 @@ a1 a2 ...@@ -478,7 +478,7 @@ a1 a2
4 4 4 4
prepare stmt1 from ' select first.a as a1, second.a as a2 prepare stmt1 from ' select first.a as a1, second.a as a2
from t1 first, t1 second from t1 first, t1 second
where first.a = second.a '; where first.a = second.a order by a1 ';
execute stmt1 ; execute stmt1 ;
a1 a2 a1 a2
1 1 1 1
...@@ -517,17 +517,17 @@ a ? a ...@@ -517,17 +517,17 @@ a ? a
4 ABC 4 4 ABC 4
drop table if exists t2 ; drop table if exists t2 ;
create table t2 as select * from t1 ; create table t2 as select * from t1 ;
set @query1= 'SELECT * FROM t2 join t1 on (t1.a=t2.a) ' ; set @query1= 'SELECT * FROM t2 join t1 on (t1.a=t2.a) order by t2.a ' ;
set @query2= 'SELECT * FROM t2 natural join t1 ' ; set @query2= 'SELECT * FROM t2 natural join t1 order by t2.a ' ;
set @query3= 'SELECT * FROM t2 join t1 using(a) ' ; set @query3= 'SELECT * FROM t2 join t1 using(a) order by t2.a ' ;
set @query4= 'SELECT * FROM t2 left join t1 on(t1.a=t2.a) ' ; set @query4= 'SELECT * FROM t2 left join t1 on(t1.a=t2.a) order by t2.a ' ;
set @query5= 'SELECT * FROM t2 natural left join t1 ' ; set @query5= 'SELECT * FROM t2 natural left join t1 order by t2.a ' ;
set @query6= 'SELECT * FROM t2 left join t1 using(a) ' ; set @query6= 'SELECT * FROM t2 left join t1 using(a) order by t2.a ' ;
set @query7= 'SELECT * FROM t2 right join t1 on(t1.a=t2.a) ' ; set @query7= 'SELECT * FROM t2 right join t1 on(t1.a=t2.a) order by t2.a ' ;
set @query8= 'SELECT * FROM t2 natural right join t1 ' ; set @query8= 'SELECT * FROM t2 natural right join t1 order by t2.a ' ;
set @query9= 'SELECT * FROM t2 right join t1 using(a) ' ; set @query9= 'SELECT * FROM t2 right join t1 using(a) order by t2.a ' ;
the join statement is: the join statement is:
SELECT * FROM t2 right join t1 using(a) SELECT * FROM t2 right join t1 using(a) order by t2.a
prepare stmt1 from @query9 ; prepare stmt1 from @query9 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -548,7 +548,7 @@ a b a b ...@@ -548,7 +548,7 @@ a b a b
3 three 3 three 3 three 3 three
4 four 4 four 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 natural right join t1 SELECT * FROM t2 natural right join t1 order by t2.a
prepare stmt1 from @query8 ; prepare stmt1 from @query8 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -569,7 +569,7 @@ a b a b ...@@ -569,7 +569,7 @@ a b a b
3 three 3 three 3 three 3 three
4 four 4 four 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 right join t1 on(t1.a=t2.a) SELECT * FROM t2 right join t1 on(t1.a=t2.a) order by t2.a
prepare stmt1 from @query7 ; prepare stmt1 from @query7 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -590,7 +590,7 @@ a b a b ...@@ -590,7 +590,7 @@ a b a b
3 three 3 three 3 three 3 three
4 four 4 four 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 left join t1 using(a) SELECT * FROM t2 left join t1 using(a) order by t2.a
prepare stmt1 from @query6 ; prepare stmt1 from @query6 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -611,7 +611,7 @@ a b a b ...@@ -611,7 +611,7 @@ a b a b
3 three 3 three 3 three 3 three
4 four 4 four 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 natural left join t1 SELECT * FROM t2 natural left join t1 order by t2.a
prepare stmt1 from @query5 ; prepare stmt1 from @query5 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -632,7 +632,7 @@ a b a b ...@@ -632,7 +632,7 @@ a b a b
3 three 3 three 3 three 3 three
4 four 4 four 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 left join t1 on(t1.a=t2.a) SELECT * FROM t2 left join t1 on(t1.a=t2.a) order by t2.a
prepare stmt1 from @query4 ; prepare stmt1 from @query4 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -653,7 +653,7 @@ a b a b ...@@ -653,7 +653,7 @@ a b a b
3 three 3 three 3 three 3 three
4 four 4 four 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 join t1 using(a) SELECT * FROM t2 join t1 using(a) order by t2.a
prepare stmt1 from @query3 ; prepare stmt1 from @query3 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -674,7 +674,7 @@ a b a b ...@@ -674,7 +674,7 @@ a b a b
3 three 3 three 3 three 3 three
4 four 4 four 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 natural join t1 SELECT * FROM t2 natural join t1 order by t2.a
prepare stmt1 from @query2 ; prepare stmt1 from @query2 ;
execute stmt1 ; execute stmt1 ;
a b a b
...@@ -695,7 +695,7 @@ a b ...@@ -695,7 +695,7 @@ a b
3 three 3 three
4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 join t1 on (t1.a=t2.a) SELECT * FROM t2 join t1 on (t1.a=t2.a) order by t2.a
prepare stmt1 from @query1 ; prepare stmt1 from @query1 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
...@@ -769,7 +769,7 @@ execute stmt1 using @arg00, @arg01, @arg02, @arg03 ; ...@@ -769,7 +769,7 @@ execute stmt1 using @arg00, @arg01, @arg02, @arg03 ;
a ? b a ? b
2 1 two 2 1 two
prepare stmt1 from ' select a, b FROM t1 outer_table where prepare stmt1 from ' select a, b FROM t1 outer_table where
a = (select a from t1 where b = outer_table.b ) '; a = (select a from t1 where b = outer_table.b ) order by a ';
execute stmt1 ; execute stmt1 ;
a b a b
1 one 1 one
......
...@@ -166,32 +166,32 @@ execute stmt1 using @arg00 ; ...@@ -166,32 +166,32 @@ execute stmt1 using @arg00 ;
substr('MySQL',1,?) substr('MySQL',1,?)
MyS MyS
set @arg00='MySQL' ; set @arg00='MySQL' ;
select a , concat(@arg00,b) from t1 ; select a , concat(@arg00,b) from t1 order by a;
a concat(@arg00,b) a concat(@arg00,b)
1 MySQLone
2 MySQLtwo 2 MySQLtwo
4 MySQLfour
3 MySQLthree 3 MySQLthree
1 MySQLone 4 MySQLfour
prepare stmt1 from ' select a , concat(?,b) from t1 ' ; prepare stmt1 from ' select a , concat(?,b) from t1 order by a ' ;
execute stmt1 using @arg00; execute stmt1 using @arg00;
a concat(?,b) a concat(?,b)
1 MySQLone
2 MySQLtwo 2 MySQLtwo
4 MySQLfour
3 MySQLthree 3 MySQLthree
1 MySQLone 4 MySQLfour
select a , concat(b,@arg00) from t1 ; select a , concat(b,@arg00) from t1 order by a ;
a concat(b,@arg00) a concat(b,@arg00)
1 oneMySQL
2 twoMySQL 2 twoMySQL
4 fourMySQL
3 threeMySQL 3 threeMySQL
1 oneMySQL 4 fourMySQL
prepare stmt1 from ' select a , concat(b,?) from t1 ' ; prepare stmt1 from ' select a , concat(b,?) from t1 order by a ' ;
execute stmt1 using @arg00; execute stmt1 using @arg00;
a concat(b,?) a concat(b,?)
1 oneMySQL
2 twoMySQL 2 twoMySQL
4 fourMySQL
3 threeMySQL 3 threeMySQL
1 oneMySQL 4 fourMySQL
set @arg00='MySQL' ; set @arg00='MySQL' ;
select group_concat(@arg00,b) from t1 select group_concat(@arg00,b) from t1
group by 'a' ; group by 'a' ;
...@@ -235,14 +235,14 @@ create table t5 (id1 int(11) not null default '0', ...@@ -235,14 +235,14 @@ create table t5 (id1 int(11) not null default '0',
value2 varchar(100), value1 varchar(100)) ; value2 varchar(100), value1 varchar(100)) ;
insert into t5 values (1,'hh','hh'),(2,'hh','hh'), insert into t5 values (1,'hh','hh'),(2,'hh','hh'),
(1,'ii','ii'),(2,'ii','ii') ; (1,'ii','ii'),(2,'ii','ii') ;
prepare stmt1 from ' select id1,value1 from t5 where id1=? or value1=? ' ; prepare stmt1 from ' select id1,value1 from t5 where id1=? or value1=? order by id1,value1 ' ;
set @arg00=1 ; set @arg00=1 ;
set @arg01='hh' ; set @arg01='hh' ;
execute stmt1 using @arg00, @arg01 ; execute stmt1 using @arg00, @arg01 ;
id1 value1 id1 value1
1 hh 1 hh
2 hh
1 ii 1 ii
2 hh
drop table t5 ; drop table t5 ;
drop table if exists t5 ; drop table if exists t5 ;
create table t5(session_id char(9) not null) ; create table t5(session_id char(9) not null) ;
...@@ -308,11 +308,11 @@ execute stmt1 using @arg00 ; ...@@ -308,11 +308,11 @@ execute stmt1 using @arg00 ;
a a
set @arg00=2 ; set @arg00=2 ;
set @arg01=3 ; set @arg01=3 ;
select a FROM t1 where a in (@arg00,@arg01); select a FROM t1 where a in (@arg00,@arg01) order by a;
a a
2 2
3 3
prepare stmt1 from ' select a FROM t1 where a in (?,?) '; prepare stmt1 from ' select a FROM t1 where a in (?,?) order by a ';
execute stmt1 using @arg00, @arg01; execute stmt1 using @arg00, @arg01;
a a
2 2
...@@ -386,18 +386,18 @@ a b ...@@ -386,18 +386,18 @@ a b
4 four 4 four
set @arg00='two' ; set @arg00='two' ;
select a,b FROM t1 where a is not NULL select a,b FROM t1 where a is not NULL
AND b is not NULL having b <> @arg00 ; AND b is not NULL having b <> @arg00 order by a ;
a b a b
4 four
3 three
1 one 1 one
3 three
4 four
prepare stmt1 from ' select a,b FROM t1 where a is not NULL prepare stmt1 from ' select a,b FROM t1 where a is not NULL
AND b is not NULL having b <> ? ' ; AND b is not NULL having b <> ? order by a ' ;
execute stmt1 using @arg00 ; execute stmt1 using @arg00 ;
a b a b
4 four
3 three
1 one 1 one
3 three
4 four
set @arg00=1 ; set @arg00=1 ;
select a,b FROM t1 where a is not NULL select a,b FROM t1 where a is not NULL
AND b is not NULL order by a - @arg00 ; AND b is not NULL order by a - @arg00 ;
...@@ -440,11 +440,11 @@ set @arg00=0 ; ...@@ -440,11 +440,11 @@ set @arg00=0 ;
execute stmt1 using @arg00; execute stmt1 using @arg00;
ERROR 42S22: Unknown column '?' in 'order clause' ERROR 42S22: Unknown column '?' in 'order clause'
set @arg00=1; set @arg00=1;
prepare stmt1 from ' select a,b from t1 prepare stmt1 from ' select a,b from t1 order by a
limit 1 '; limit 1 ';
execute stmt1 ; execute stmt1 ;
a b a b
2 two 1 one
prepare stmt1 from ' select a,b from t1 prepare stmt1 from ' select a,b from t1
limit ? '; limit ? ';
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?' at line 2 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?' at line 2
...@@ -471,21 +471,21 @@ test_sequence ...@@ -471,21 +471,21 @@ test_sequence
------ join tests ------ ------ join tests ------
select first.a as a1, second.a as a2 select first.a as a1, second.a as a2
from t1 first, t1 second from t1 first, t1 second
where first.a = second.a ; where first.a = second.a order by a1 ;
a1 a2 a1 a2
1 1
2 2 2 2
4 4
3 3 3 3
1 1 4 4
prepare stmt1 from ' select first.a as a1, second.a as a2 prepare stmt1 from ' select first.a as a1, second.a as a2
from t1 first, t1 second from t1 first, t1 second
where first.a = second.a '; where first.a = second.a order by a1 ';
execute stmt1 ; execute stmt1 ;
a1 a2 a1 a2
1 1
2 2 2 2
4 4
3 3 3 3
1 1 4 4
set @arg00='ABC'; set @arg00='ABC';
set @arg01='two'; set @arg01='two';
set @arg02='one'; set @arg02='one';
...@@ -518,204 +518,204 @@ a ? a ...@@ -518,204 +518,204 @@ a ? a
4 ABC 4 4 ABC 4
drop table if exists t2 ; drop table if exists t2 ;
create table t2 as select * from t1 ; create table t2 as select * from t1 ;
set @query1= 'SELECT * FROM t2 join t1 on (t1.a=t2.a) ' ; set @query1= 'SELECT * FROM t2 join t1 on (t1.a=t2.a) order by t2.a ' ;
set @query2= 'SELECT * FROM t2 natural join t1 ' ; set @query2= 'SELECT * FROM t2 natural join t1 order by t2.a ' ;
set @query3= 'SELECT * FROM t2 join t1 using(a) ' ; set @query3= 'SELECT * FROM t2 join t1 using(a) order by t2.a ' ;
set @query4= 'SELECT * FROM t2 left join t1 on(t1.a=t2.a) ' ; set @query4= 'SELECT * FROM t2 left join t1 on(t1.a=t2.a) order by t2.a ' ;
set @query5= 'SELECT * FROM t2 natural left join t1 ' ; set @query5= 'SELECT * FROM t2 natural left join t1 order by t2.a ' ;
set @query6= 'SELECT * FROM t2 left join t1 using(a) ' ; set @query6= 'SELECT * FROM t2 left join t1 using(a) order by t2.a ' ;
set @query7= 'SELECT * FROM t2 right join t1 on(t1.a=t2.a) ' ; set @query7= 'SELECT * FROM t2 right join t1 on(t1.a=t2.a) order by t2.a ' ;
set @query8= 'SELECT * FROM t2 natural right join t1 ' ; set @query8= 'SELECT * FROM t2 natural right join t1 order by t2.a ' ;
set @query9= 'SELECT * FROM t2 right join t1 using(a) ' ; set @query9= 'SELECT * FROM t2 right join t1 using(a) order by t2.a ' ;
the join statement is: the join statement is:
SELECT * FROM t2 right join t1 using(a) SELECT * FROM t2 right join t1 using(a) order by t2.a
prepare stmt1 from @query9 ; prepare stmt1 from @query9 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
1 one 1 one
2 two 2 two 2 two 2 two
4 four 4 four
3 three 3 three 3 three 3 three
1 one 1 one 4 four 4 four
execute stmt1 ; execute stmt1 ;
a b a b a b a b
1 one 1 one
2 two 2 two 2 two 2 two
4 four 4 four
3 three 3 three 3 three 3 three
1 one 1 one 4 four 4 four
execute stmt1 ; execute stmt1 ;
a b a b a b a b
1 one 1 one
2 two 2 two 2 two 2 two
4 four 4 four
3 three 3 three 3 three 3 three
1 one 1 one 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 natural right join t1 SELECT * FROM t2 natural right join t1 order by t2.a
prepare stmt1 from @query8 ; prepare stmt1 from @query8 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
1 one 1 one
2 two 2 two 2 two 2 two
4 four 4 four
3 three 3 three 3 three 3 three
1 one 1 one 4 four 4 four
execute stmt1 ; execute stmt1 ;
a b a b a b a b
1 one 1 one
2 two 2 two 2 two 2 two
4 four 4 four
3 three 3 three 3 three 3 three
1 one 1 one 4 four 4 four
execute stmt1 ; execute stmt1 ;
a b a b a b a b
1 one 1 one
2 two 2 two 2 two 2 two
4 four 4 four
3 three 3 three 3 three 3 three
1 one 1 one 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 right join t1 on(t1.a=t2.a) SELECT * FROM t2 right join t1 on(t1.a=t2.a) order by t2.a
prepare stmt1 from @query7 ; prepare stmt1 from @query7 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
1 one 1 one
2 two 2 two 2 two 2 two
4 four 4 four
3 three 3 three 3 three 3 three
1 one 1 one 4 four 4 four
execute stmt1 ; execute stmt1 ;
a b a b a b a b
1 one 1 one
2 two 2 two 2 two 2 two
4 four 4 four
3 three 3 three 3 three 3 three
1 one 1 one 4 four 4 four
execute stmt1 ; execute stmt1 ;
a b a b a b a b
1 one 1 one
2 two 2 two 2 two 2 two
4 four 4 four
3 three 3 three 3 three 3 three
1 one 1 one 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 left join t1 using(a) SELECT * FROM t2 left join t1 using(a) order by t2.a
prepare stmt1 from @query6 ; prepare stmt1 from @query6 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
1 one 1 one
2 two 2 two 2 two 2 two
4 four 4 four
3 three 3 three 3 three 3 three
1 one 1 one 4 four 4 four
execute stmt1 ; execute stmt1 ;
a b a b a b a b
1 one 1 one
2 two 2 two 2 two 2 two
4 four 4 four
3 three 3 three 3 three 3 three
1 one 1 one 4 four 4 four
execute stmt1 ; execute stmt1 ;
a b a b a b a b
1 one 1 one
2 two 2 two 2 two 2 two
4 four 4 four
3 three 3 three 3 three 3 three
1 one 1 one 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 natural left join t1 SELECT * FROM t2 natural left join t1 order by t2.a
prepare stmt1 from @query5 ; prepare stmt1 from @query5 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
1 one 1 one
2 two 2 two 2 two 2 two
4 four 4 four
3 three 3 three 3 three 3 three
1 one 1 one 4 four 4 four
execute stmt1 ; execute stmt1 ;
a b a b a b a b
1 one 1 one
2 two 2 two 2 two 2 two
4 four 4 four
3 three 3 three 3 three 3 three
1 one 1 one 4 four 4 four
execute stmt1 ; execute stmt1 ;
a b a b a b a b
1 one 1 one
2 two 2 two 2 two 2 two
4 four 4 four
3 three 3 three 3 three 3 three
1 one 1 one 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 left join t1 on(t1.a=t2.a) SELECT * FROM t2 left join t1 on(t1.a=t2.a) order by t2.a
prepare stmt1 from @query4 ; prepare stmt1 from @query4 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
1 one 1 one
2 two 2 two 2 two 2 two
4 four 4 four
3 three 3 three 3 three 3 three
1 one 1 one 4 four 4 four
execute stmt1 ; execute stmt1 ;
a b a b a b a b
1 one 1 one
2 two 2 two 2 two 2 two
4 four 4 four
3 three 3 three 3 three 3 three
1 one 1 one 4 four 4 four
execute stmt1 ; execute stmt1 ;
a b a b a b a b
1 one 1 one
2 two 2 two 2 two 2 two
4 four 4 four
3 three 3 three 3 three 3 three
1 one 1 one 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 join t1 using(a) SELECT * FROM t2 join t1 using(a) order by t2.a
prepare stmt1 from @query3 ; prepare stmt1 from @query3 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
1 one 1 one
2 two 2 two 2 two 2 two
4 four 4 four
3 three 3 three 3 three 3 three
1 one 1 one 4 four 4 four
execute stmt1 ; execute stmt1 ;
a b a b a b a b
1 one 1 one
2 two 2 two 2 two 2 two
4 four 4 four
3 three 3 three 3 three 3 three
1 one 1 one 4 four 4 four
execute stmt1 ; execute stmt1 ;
a b a b a b a b
1 one 1 one
2 two 2 two 2 two 2 two
4 four 4 four
3 three 3 three 3 three 3 three
1 one 1 one 4 four 4 four
the join statement is: the join statement is:
SELECT * FROM t2 natural join t1 SELECT * FROM t2 natural join t1 order by t2.a
prepare stmt1 from @query2 ; prepare stmt1 from @query2 ;
execute stmt1 ; execute stmt1 ;
a b a b
1 one
2 two 2 two
4 four
3 three 3 three
1 one 4 four
execute stmt1 ; execute stmt1 ;
a b a b
1 one
2 two 2 two
4 four
3 three 3 three
1 one 4 four
execute stmt1 ; execute stmt1 ;
a b a b
1 one
2 two 2 two
4 four
3 three 3 three
1 one 4 four
the join statement is: the join statement is:
SELECT * FROM t2 join t1 on (t1.a=t2.a) SELECT * FROM t2 join t1 on (t1.a=t2.a) order by t2.a
prepare stmt1 from @query1 ; prepare stmt1 from @query1 ;
execute stmt1 ; execute stmt1 ;
a b a b a b a b
1 one 1 one
2 two 2 two 2 two 2 two
4 four 4 four
3 three 3 three 3 three 3 three
1 one 1 one 4 four 4 four
execute stmt1 ; execute stmt1 ;
a b a b a b a b
1 one 1 one
2 two 2 two 2 two 2 two
4 four 4 four
3 three 3 three 3 three 3 three
1 one 1 one 4 four 4 four
execute stmt1 ; execute stmt1 ;
a b a b a b a b
1 one 1 one
2 two 2 two 2 two 2 two
4 four 4 four
3 three 3 three 3 three 3 three
1 one 1 one 4 four 4 four
drop table t2 ; drop table t2 ;
test_sequence test_sequence
------ subquery tests ------ ------ subquery tests ------
...@@ -770,13 +770,13 @@ execute stmt1 using @arg00, @arg01, @arg02, @arg03 ; ...@@ -770,13 +770,13 @@ execute stmt1 using @arg00, @arg01, @arg02, @arg03 ;
a ? b a ? b
2 1 two 2 1 two
prepare stmt1 from ' select a, b FROM t1 outer_table where prepare stmt1 from ' select a, b FROM t1 outer_table where
a = (select a from t1 where b = outer_table.b ) '; a = (select a from t1 where b = outer_table.b ) order by a ';
execute stmt1 ; execute stmt1 ;
a b a b
1 one
2 two 2 two
4 four
3 three 3 three
1 one 4 four
prepare stmt1 from ' SELECT a as ccc from t1 where a+1= prepare stmt1 from ' SELECT a as ccc from t1 where a+1=
(SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) '; (SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';
execute stmt1 ; execute stmt1 ;
...@@ -1188,7 +1188,7 @@ c29= 'longblob', c30= 'longtext', c31='two', c32= 'tuesday'; ...@@ -1188,7 +1188,7 @@ c29= 'longblob', c30= 'longtext', c31='two', c32= 'tuesday';
commit ; commit ;
prepare stmt1 from 'delete from t1 where a=2' ; prepare stmt1 from 'delete from t1 where a=2' ;
execute stmt1; execute stmt1;
select a,b from t1 where a=2; select a,b from t1 where a=2 order by b;
a b a b
execute stmt1; execute stmt1;
insert into t1 values(0,NULL); insert into t1 values(0,NULL);
...@@ -1474,7 +1474,7 @@ set @arg02=82 ; ...@@ -1474,7 +1474,7 @@ set @arg02=82 ;
set @arg03='8-2' ; set @arg03='8-2' ;
prepare stmt1 from 'insert into t1 values(?,?),(?,?)'; prepare stmt1 from 'insert into t1 values(?,?),(?,?)';
execute stmt1 using @arg00, @arg01, @arg02, @arg03 ; execute stmt1 using @arg00, @arg01, @arg02, @arg03 ;
select a,b from t1 where a in (@arg00,@arg02) ; select a,b from t1 where a in (@arg00,@arg02) order by a ;
a b a b
81 8-1 81 8-1
82 8-2 82 8-2
......
...@@ -18,19 +18,19 @@ insert into t2 values (1,1,1),(2,2,2),(3,3,3), (4,4,4), (5,5,5); ...@@ -18,19 +18,19 @@ insert into t2 values (1,1,1),(2,2,2),(3,3,3), (4,4,4), (5,5,5);
# Use pk # Use pk
explain select * from t2 where p NOT IN (select p from t1); explain select * from t2 where p NOT IN (select p from t1);
select * from t2 where p NOT IN (select p from t1); select * from t2 where p NOT IN (select p from t1) order by p;
# Use unique index # Use unique index
explain select * from t2 where p NOT IN (select u from t1); explain select * from t2 where p NOT IN (select u from t1);
select * from t2 where p NOT IN (select u from t1); select * from t2 where p NOT IN (select u from t1) order by p;
# Use ordered index # Use ordered index
explain select * from t2 where p NOT IN (select o from t1); explain select * from t2 where p NOT IN (select o from t1);
select * from t2 where p NOT IN (select o from t1); select * from t2 where p NOT IN (select o from t1) order by p;
# Use scan # Use scan
explain select * from t2 where p NOT IN (select p+0 from t1); explain select * from t2 where p NOT IN (select p+0 from t1);
select * from t2 where p NOT IN (select p+0 from t1); select * from t2 where p NOT IN (select p+0 from t1) order by p;
drop table t1; drop table t1;
drop table t2; drop table t2;
......
...@@ -55,7 +55,7 @@ select '------ delete tests ------' as test_sequence ; ...@@ -55,7 +55,7 @@ select '------ delete tests ------' as test_sequence ;
## delete without parameter ## delete without parameter
prepare stmt1 from 'delete from t1 where a=2' ; prepare stmt1 from 'delete from t1 where a=2' ;
execute stmt1; execute stmt1;
select a,b from t1 where a=2; select a,b from t1 where a=2 order by b;
# delete with row not found # delete with row not found
execute stmt1; execute stmt1;
...@@ -270,7 +270,7 @@ set @arg02=82 ; ...@@ -270,7 +270,7 @@ set @arg02=82 ;
set @arg03='8-2' ; set @arg03='8-2' ;
prepare stmt1 from 'insert into t1 values(?,?),(?,?)'; prepare stmt1 from 'insert into t1 values(?,?),(?,?)';
execute stmt1 using @arg00, @arg01, @arg02, @arg03 ; execute stmt1 using @arg00, @arg01, @arg02, @arg03 ;
select a,b from t1 where a in (@arg00,@arg02) ; select a,b from t1 where a in (@arg00,@arg02) order by a ;
## insert with two parameter in the set part ## insert with two parameter in the set part
set @arg00=9 ; set @arg00=9 ;
......
...@@ -42,7 +42,18 @@ ...@@ -42,7 +42,18 @@
handle bulk inserts as well (that is if someone was trying to read at handle bulk inserts as well (that is if someone was trying to read at
the same time since we would want to flush). the same time since we would want to flush).
No attempts at durability are made. You can corrupt your data. A "meta" file is kept. All this file does is contain information on
the number of rows.
No attempts at durability are made. You can corrupt your data. A repair
method was added to repair the meta file that stores row information,
but if your data file gets corrupted I haven't solved that. I could
create a repair that would solve this, but do you want to take a
chance of loosing your data?
Locks are row level, and you will get a consistant read. Transactions
will be added later (they are not that hard to add at this
stage).
For performance as far as table scans go it is quite fast. I don't have For performance as far as table scans go it is quite fast. I don't have
good numbers but locally it has out performed both Innodb and MyISAM. For good numbers but locally it has out performed both Innodb and MyISAM. For
...@@ -71,14 +82,35 @@ ...@@ -71,14 +82,35 @@
Add truncate table command. Add truncate table command.
Implement versioning, should be easy. Implement versioning, should be easy.
Allow for errors, find a way to mark bad rows. Allow for errors, find a way to mark bad rows.
See if during an optimize you can make the table smaller.
Talk to the gzip guys, come up with a writable format so that updates are doable Talk to the gzip guys, come up with a writable format so that updates are doable
without switching to a block method. without switching to a block method.
Add optional feature so that rows can be flushed at interval (which will cause less Add optional feature so that rows can be flushed at interval (which will cause less
compression but may speed up ordered searches). compression but may speed up ordered searches).
Checkpoint the meta file to allow for faster rebuilds.
Dirty open (right now the meta file is repaired if a crash occured).
Transactions.
Option to allow for dirty reads, this would lower the sync calls, which would make
inserts a lot faster, but would mean highly arbitrary reads.
-Brian -Brian
*/ */
/*
Notes on file formats.
The Meta file is layed out as:
check - Just an int of 254 to make sure that the the file we are opening was
never corrupted.
version - The current version of the file format.
rows - This is an unsigned long long which is the number of rows in the data
file.
check point - Reserved for future use
dirty - Status of the file, whether or not its values are the latest. This flag
is what causes a repair to occur
The data file:
check - Just an int of 254 to make sure that the the file we are opening was
never corrupted.
version - The current version of the file format.
data - The data is stored in a "row +blobs" format.
/* Variables for archive share methods */ /* Variables for archive share methods */
pthread_mutex_t archive_mutex; pthread_mutex_t archive_mutex;
...@@ -86,8 +118,18 @@ static HASH archive_open_tables; ...@@ -86,8 +118,18 @@ static HASH archive_open_tables;
static int archive_init= 0; static int archive_init= 0;
/* The file extension */ /* The file extension */
#define ARZ ".ARZ" #define ARZ ".ARZ" // The data file
#define ARN ".ARN" #define ARN ".ARN" // Files used during an optimize call
#define ARM ".ARM" // Meta file
/*
uchar + uchar + ulonglong + ulonglong + uchar
*/
#define META_BUFFER_SIZE 19 // Size of the data used in the meta file
/*
uchar + uchar
*/
#define DATA_BUFFER_SIZE 2 // Size of the data used in the data file
#define ARCHIVE_CHECK_HEADER 254 // The number we use to determine corruption
/* /*
Used for hash table that tracks open tables. Used for hash table that tracks open tables.
...@@ -99,14 +141,130 @@ static byte* archive_get_key(ARCHIVE_SHARE *share,uint *length, ...@@ -99,14 +141,130 @@ static byte* archive_get_key(ARCHIVE_SHARE *share,uint *length,
return (byte*) share->table_name; return (byte*) share->table_name;
} }
/*
This method reads the header of a datafile and returns whether or not it was successful.
*/
int ha_archive::read_data_header(gzFile file_to_read)
{
uchar data_buffer[DATA_BUFFER_SIZE];
DBUG_ENTER("ha_archive::read_data_header");
if (gzrewind(file_to_read) == -1)
DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
if (gzread(file_to_read, data_buffer, DATA_BUFFER_SIZE) != DATA_BUFFER_SIZE)
DBUG_RETURN(errno ? errno : -1);
DBUG_PRINT("ha_archive::read_data_header", ("Check %u", data_buffer[0]));
DBUG_PRINT("ha_archive::read_data_header", ("Version %u", data_buffer[1]));
if ((data_buffer[0] != (uchar)ARCHIVE_CHECK_HEADER) &&
(data_buffer[1] != (uchar)ARCHIVE_VERSION))
DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
DBUG_RETURN(0);
}
/* /*
Example of simple lock controls. This method writes out the header of a datafile and returns whether or not it was successful.
See ha_example.cc for a description. */
int ha_archive::write_data_header(gzFile file_to_write)
{
uchar data_buffer[DATA_BUFFER_SIZE];
DBUG_ENTER("ha_archive::write_data_header");
data_buffer[0]= (uchar)ARCHIVE_CHECK_HEADER;
data_buffer[1]= (uchar)ARCHIVE_VERSION;
if (gzwrite(file_to_write, &data_buffer, DATA_BUFFER_SIZE) !=
sizeof(DATA_BUFFER_SIZE))
goto error;
DBUG_PRINT("ha_archive::write_data_header", ("Check %u", (uint)data_buffer[0]));
DBUG_PRINT("ha_archive::write_data_header", ("Version %u", (uint)data_buffer[1]));
DBUG_RETURN(0);
error:
DBUG_RETURN(errno);
}
/*
This method reads the header of a meta file and returns whether or not it was successful.
*rows will contain the current number of rows in the data file upon success.
*/
int ha_archive::read_meta_file(File meta_file, ulonglong *rows)
{
uchar meta_buffer[META_BUFFER_SIZE];
ulonglong check_point;
DBUG_ENTER("ha_archive::read_meta_file");
VOID(my_seek(meta_file, 0, MY_SEEK_SET, MYF(0)));
if (my_read(meta_file, (byte*)meta_buffer, META_BUFFER_SIZE, 0) != META_BUFFER_SIZE)
DBUG_RETURN(-1);
/*
Parse out the meta data, we ignore version at the moment
*/
*rows= uint8korr(meta_buffer + 2);
check_point= uint8korr(meta_buffer + 10);
DBUG_PRINT("ha_archive::read_meta_file", ("Check %d", (uint)meta_buffer[0]));
DBUG_PRINT("ha_archive::read_meta_file", ("Version %d", (uint)meta_buffer[1]));
DBUG_PRINT("ha_archive::read_meta_file", ("Rows %lld", *rows));
DBUG_PRINT("ha_archive::read_meta_file", ("Checkpoint %lld", check_point));
DBUG_PRINT("ha_archive::read_meta_file", ("Dirty %d", (int)meta_buffer[18]));
if ((meta_buffer[0] != (uchar)ARCHIVE_CHECK_HEADER) ||
((bool)meta_buffer[18] == TRUE))
DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
my_sync(meta_file, MYF(MY_WME));
DBUG_RETURN(0);
}
/*
This method writes out the header of a meta file and returns whether or not it was successful.
By setting dirty you say whether or not the file represents the actual state of the data file.
Upon ::open() we set to dirty, and upon ::close() we set to clean. If we determine during
a read that the file was dirty we will force a rebuild of this file.
*/
int ha_archive::write_meta_file(File meta_file, ulonglong rows, bool dirty)
{
uchar meta_buffer[META_BUFFER_SIZE];
ulonglong check_point= 0; //Reserved for the future
DBUG_ENTER("ha_archive::write_meta_file");
meta_buffer[0]= (uchar)ARCHIVE_CHECK_HEADER;
meta_buffer[1]= (uchar)ARCHIVE_VERSION;
int8store(meta_buffer + 2, rows);
int8store(meta_buffer + 10, check_point);
*(meta_buffer + 18)= (uchar)dirty;
DBUG_PRINT("ha_archive::write_meta_file", ("Check %d", (uint)ARCHIVE_CHECK_HEADER));
DBUG_PRINT("ha_archive::write_meta_file", ("Version %d", (uint)ARCHIVE_VERSION));
DBUG_PRINT("ha_archive::write_meta_file", ("Rows %llu", rows));
DBUG_PRINT("ha_archive::write_meta_file", ("Checkpoint %llu", check_point));
DBUG_PRINT("ha_archive::write_meta_file", ("Dirty %d", (uint)dirty));
VOID(my_seek(meta_file, 0, MY_SEEK_SET, MYF(0)));
if (my_write(meta_file, (byte *)meta_buffer, META_BUFFER_SIZE, 0) != META_BUFFER_SIZE)
DBUG_RETURN(-1);
my_sync(meta_file, MYF(MY_WME));
DBUG_RETURN(0);
}
/*
We create the shared memory space that we will use for the open table.
See ha_example.cc for a longer description.
*/ */
static ARCHIVE_SHARE *get_share(const char *table_name, TABLE *table) ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, TABLE *table)
{ {
ARCHIVE_SHARE *share; ARCHIVE_SHARE *share;
char meta_file_name[FN_REFLEN];
uint length; uint length;
char *tmp_name; char *tmp_name;
...@@ -143,33 +301,62 @@ static ARCHIVE_SHARE *get_share(const char *table_name, TABLE *table) ...@@ -143,33 +301,62 @@ static ARCHIVE_SHARE *get_share(const char *table_name, TABLE *table)
return NULL; return NULL;
} }
share->use_count=0; share->use_count= 0;
share->table_name_length=length; share->table_name_length= length;
share->table_name=tmp_name; share->table_name= tmp_name;
fn_format(share->data_file_name,table_name,"",ARZ,MY_REPLACE_EXT|MY_UNPACK_FILENAME); fn_format(share->data_file_name,table_name,"",ARZ,MY_REPLACE_EXT|MY_UNPACK_FILENAME);
fn_format(meta_file_name,table_name,"",ARM,MY_REPLACE_EXT|MY_UNPACK_FILENAME);
strmov(share->table_name,table_name); strmov(share->table_name,table_name);
/*
We will use this lock for rows.
*/
VOID(pthread_mutex_init(&share->mutex,MY_MUTEX_INIT_FAST));
if ((share->meta_file= my_open(meta_file_name, O_RDWR, MYF(0))) == -1)
goto error;
if (read_meta_file(share->meta_file, &share->rows_recorded))
{
/*
The problem here is that for some reason, probably a crash, the meta
file has been corrupted. So what do we do? Well we try to rebuild it
ourself. Once that happens, we reread it, but if that fails we just
call it quits and return an error.
*/
if (rebuild_meta_file(share->table_name, share->meta_file))
goto error;
if (read_meta_file(share->meta_file, &share->rows_recorded))
goto error;
}
/*
After we read, we set the file to dirty. When we close, we will do the
opposite.
*/
(void)write_meta_file(share->meta_file, share->rows_recorded, TRUE);
/* /*
It is expensive to open and close the data files and since you can't have It is expensive to open and close the data files and since you can't have
a gzip file that can be both read and written we keep a writer open a gzip file that can be both read and written we keep a writer open
that is shared amoung all open tables. that is shared amoung all open tables.
*/ */
if ((share->archive_write= gzopen(share->data_file_name, "ab")) == NULL) if ((share->archive_write= gzopen(share->data_file_name, "ab")) == NULL)
goto error; goto error2;
if (my_hash_insert(&archive_open_tables, (byte*) share)) if (my_hash_insert(&archive_open_tables, (byte*) share))
goto error; goto error2;
thr_lock_init(&share->lock); thr_lock_init(&share->lock);
if (pthread_mutex_init(&share->mutex,MY_MUTEX_INIT_FAST)) if (pthread_mutex_init(&share->mutex,MY_MUTEX_INIT_FAST))
goto error2; goto error3;
} }
share->use_count++; share->use_count++;
pthread_mutex_unlock(&archive_mutex); pthread_mutex_unlock(&archive_mutex);
return share; return share;
error2: error3:
VOID(pthread_mutex_destroy(&share->mutex));
thr_lock_delete(&share->lock); thr_lock_delete(&share->lock);
/* We close, but ignore errors since we already have errors */ /* We close, but ignore errors since we already have errors */
(void)gzclose(share->archive_write); (void)gzclose(share->archive_write);
error2:
my_close(share->meta_file,MYF(0));
error: error:
pthread_mutex_unlock(&archive_mutex); pthread_mutex_unlock(&archive_mutex);
my_free((gptr) share, MYF(0)); my_free((gptr) share, MYF(0));
...@@ -179,10 +366,10 @@ error: ...@@ -179,10 +366,10 @@ error:
/* /*
Free lock controls. Free the share.
See ha_example.cc for a description. See ha_example.cc for a description.
*/ */
static int free_share(ARCHIVE_SHARE *share) int ha_archive::free_share(ARCHIVE_SHARE *share)
{ {
int rc= 0; int rc= 0;
pthread_mutex_lock(&archive_mutex); pthread_mutex_lock(&archive_mutex);
...@@ -190,7 +377,8 @@ static int free_share(ARCHIVE_SHARE *share) ...@@ -190,7 +377,8 @@ static int free_share(ARCHIVE_SHARE *share)
{ {
hash_delete(&archive_open_tables, (byte*) share); hash_delete(&archive_open_tables, (byte*) share);
thr_lock_delete(&share->lock); thr_lock_delete(&share->lock);
pthread_mutex_destroy(&share->mutex); VOID(pthread_mutex_destroy(&share->mutex));
(void)write_meta_file(share->meta_file, share->rows_recorded, FALSE);
if (gzclose(share->archive_write) == Z_ERRNO) if (gzclose(share->archive_write) == Z_ERRNO)
rc= 1; rc= 1;
my_free((gptr) share, MYF(0)); my_free((gptr) share, MYF(0));
...@@ -205,7 +393,7 @@ static int free_share(ARCHIVE_SHARE *share) ...@@ -205,7 +393,7 @@ static int free_share(ARCHIVE_SHARE *share)
We just implement one additional file extension. We just implement one additional file extension.
*/ */
const char **ha_archive::bas_ext() const const char **ha_archive::bas_ext() const
{ static const char *ext[]= { ARZ, ARN, NullS }; return ext; } { static const char *ext[]= { ARZ, ARN, ARM, NullS }; return ext; }
/* /*
...@@ -213,7 +401,6 @@ const char **ha_archive::bas_ext() const ...@@ -213,7 +401,6 @@ const char **ha_archive::bas_ext() const
Create/get our shared structure. Create/get our shared structure.
Init out lock. Init out lock.
We open the file we will read from. We open the file we will read from.
Set the size of ref_length.
*/ */
int ha_archive::open(const char *name, int mode, uint test_if_locked) int ha_archive::open(const char *name, int mode, uint test_if_locked)
{ {
...@@ -266,54 +453,63 @@ int ha_archive::close(void) ...@@ -266,54 +453,63 @@ int ha_archive::close(void)
/* /*
We create our data file here. The format is pretty simple. The first We create our data file here. The format is pretty simple.
bytes in any file are the version number. Currently we do nothing You can read about the format of the data file above.
with this, but in the future this gives us the ability to figure out Unlike other storage engines we do not "pack" our data. Since we
version if we change the format at all. After the version we are about to do a general compression, packing would just be a waste of
starting writing our rows. Unlike other storage engines we do not CPU time. If the table has blobs they are written after the row in the order
"pack" our data. Since we are about to do a general compression, of creation.
packing would just be a waste of CPU time. If the table has blobs
they are written after the row in the order of creation.
So to read a row we:
Read the version
Read the record and copy it into buf
Loop through any blobs and read them
*/ */
int ha_archive::create(const char *name, TABLE *table_arg, int ha_archive::create(const char *name, TABLE *table_arg,
HA_CREATE_INFO *create_info) HA_CREATE_INFO *create_info)
{ {
File create_file; File create_file; // We use to create the datafile and the metafile
char name_buff[FN_REFLEN]; char name_buff[FN_REFLEN];
size_t written;
int error; int error;
DBUG_ENTER("ha_archive::create"); DBUG_ENTER("ha_archive::create");
if ((create_file= my_create(fn_format(name_buff,name,"",ARM,
MY_REPLACE_EXT|MY_UNPACK_FILENAME),0,
O_RDWR | O_TRUNC,MYF(MY_WME))) < 0)
{
error= my_errno;
goto error;
}
write_meta_file(create_file, 0, FALSE);
my_close(create_file,MYF(0));
/*
We reuse name_buff since it is available.
*/
if ((create_file= my_create(fn_format(name_buff,name,"",ARZ, if ((create_file= my_create(fn_format(name_buff,name,"",ARZ,
MY_REPLACE_EXT|MY_UNPACK_FILENAME),0, MY_REPLACE_EXT|MY_UNPACK_FILENAME),0,
O_RDWR | O_TRUNC,MYF(MY_WME))) < 0) O_RDWR | O_TRUNC,MYF(MY_WME))) < 0)
{ {
error= my_errno; error= my_errno;
goto err; goto error;
} }
if ((archive= gzdopen(create_file, "ab")) == NULL) if ((archive= gzdopen(create_file, "ab")) == NULL)
{ {
error= errno; error= errno;
delete_table(name); delete_table(name);
goto err; goto error;
} }
version= ARCHIVE_VERSION; if (write_data_header(archive))
written= gzwrite(archive, &version, sizeof(version));
if (gzclose(archive) || written != sizeof(version))
{ {
error= errno; gzclose(archive);
delete_table(name); goto error2;
goto err;
} }
if (gzclose(archive))
goto error2;
DBUG_RETURN(0); DBUG_RETURN(0);
err: error2:
error= errno;
delete_table(name);
error:
/* Return error number, if we got one */ /* Return error number, if we got one */
DBUG_RETURN(error ? error : -1); DBUG_RETURN(error ? error : -1);
} }
...@@ -334,25 +530,38 @@ int ha_archive::write_row(byte * buf) ...@@ -334,25 +530,38 @@ int ha_archive::write_row(byte * buf)
DBUG_ENTER("ha_archive::write_row"); DBUG_ENTER("ha_archive::write_row");
statistic_increment(ha_write_count,&LOCK_status); statistic_increment(ha_write_count,&LOCK_status);
if (table->timestamp_default_now) if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT)
update_timestamp(buf+table->timestamp_default_now-1); table->timestamp_field->set_time();
pthread_mutex_lock(&share->mutex);
written= gzwrite(share->archive_write, buf, table->reclength); written= gzwrite(share->archive_write, buf, table->reclength);
DBUG_PRINT("ha_archive::get_row", ("Wrote %d bytes expected %d", written, table->reclength));
share->dirty= TRUE; share->dirty= TRUE;
if (written != table->reclength) if (written != table->reclength)
DBUG_RETURN(errno ? errno : -1); goto error;
/*
We should probably mark the table as damagaged if the record is written
but the blob fails.
*/
for (Field_blob **field=table->blob_field ; *field ; field++) for (Field_blob **field=table->blob_field ; *field ; field++)
{ {
char *ptr; char *ptr;
uint32 size= (*field)->get_length(); uint32 size= (*field)->get_length();
if (size)
{
(*field)->get_ptr(&ptr); (*field)->get_ptr(&ptr);
written= gzwrite(share->archive_write, ptr, (unsigned)size); written= gzwrite(share->archive_write, ptr, (unsigned)size);
if (written != size) if (written != size)
DBUG_RETURN(errno ? errno : -1); goto error;
} }
}
share->rows_recorded++;
pthread_mutex_unlock(&share->mutex);
DBUG_RETURN(0); DBUG_RETURN(0);
error:
pthread_mutex_unlock(&share->mutex);
DBUG_RETURN(errno ? errno : -1);
} }
...@@ -368,12 +577,10 @@ int ha_archive::rnd_init(bool scan) ...@@ -368,12 +577,10 @@ int ha_archive::rnd_init(bool scan)
int read; // gzread() returns int, and we use this to check the header int read; // gzread() returns int, and we use this to check the header
/* We rewind the file so that we can read from the beginning if scan */ /* We rewind the file so that we can read from the beginning if scan */
if(scan) if (scan)
{ {
scan_rows= share->rows_recorded;
records= 0; records= 0;
if (gzrewind(archive))
DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
}
/* /*
If dirty, we lock, and then reset/flush the data. If dirty, we lock, and then reset/flush the data.
...@@ -390,15 +597,8 @@ int ha_archive::rnd_init(bool scan) ...@@ -390,15 +597,8 @@ int ha_archive::rnd_init(bool scan)
pthread_mutex_unlock(&share->mutex); pthread_mutex_unlock(&share->mutex);
} }
/* if (read_data_header(archive))
At the moment we just check the size of version to make sure the header is DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
intact.
*/
if (scan)
{
read= gzread(archive, &version, sizeof(version));
if (read != sizeof(version))
DBUG_RETURN(errno ? errno : -1);
} }
DBUG_RETURN(0); DBUG_RETURN(0);
...@@ -409,7 +609,7 @@ int ha_archive::rnd_init(bool scan) ...@@ -409,7 +609,7 @@ int ha_archive::rnd_init(bool scan)
This is the method that is used to read a row. It assumes that the row is This is the method that is used to read a row. It assumes that the row is
positioned where you want it. positioned where you want it.
*/ */
int ha_archive::get_row(byte *buf) int ha_archive::get_row(gzFile file_to_read, byte *buf)
{ {
int read; // Bytes read, gzread() returns int int read; // Bytes read, gzread() returns int
char *last; char *last;
...@@ -417,7 +617,11 @@ int ha_archive::get_row(byte *buf) ...@@ -417,7 +617,11 @@ int ha_archive::get_row(byte *buf)
Field_blob **field; Field_blob **field;
DBUG_ENTER("ha_archive::get_row"); DBUG_ENTER("ha_archive::get_row");
read= gzread(archive, buf, table->reclength); read= gzread(file_to_read, buf, table->reclength);
DBUG_PRINT("ha_archive::get_row", ("Read %d bytes expected %d", read, table->reclength));
if (read == Z_STREAM_ERROR)
DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
/* If we read nothing we are at the end of the file */ /* If we read nothing we are at the end of the file */
if (read == 0) if (read == 0)
...@@ -439,12 +643,15 @@ int ha_archive::get_row(byte *buf) ...@@ -439,12 +643,15 @@ int ha_archive::get_row(byte *buf)
for (field=table->blob_field; *field ; field++) for (field=table->blob_field; *field ; field++)
{ {
size_t size= (*field)->get_length(); size_t size= (*field)->get_length();
read= gzread(archive, last, size); if (size)
{
read= gzread(file_to_read, last, size);
if ((size_t) read != size) if ((size_t) read != size)
DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE); DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
(*field)->set_ptr(size, last); (*field)->set_ptr(size, last);
last += size; last += size;
} }
}
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -459,9 +666,15 @@ int ha_archive::rnd_next(byte *buf) ...@@ -459,9 +666,15 @@ int ha_archive::rnd_next(byte *buf)
int rc; int rc;
DBUG_ENTER("ha_archive::rnd_next"); DBUG_ENTER("ha_archive::rnd_next");
if (!scan_rows)
DBUG_RETURN(HA_ERR_END_OF_FILE);
scan_rows--;
statistic_increment(ha_read_rnd_next_count,&LOCK_status); statistic_increment(ha_read_rnd_next_count,&LOCK_status);
current_position= gztell(archive); current_position= gztell(archive);
rc= get_row(buf); rc= get_row(archive, buf);
if (rc != HA_ERR_END_OF_FILE) if (rc != HA_ERR_END_OF_FILE)
records++; records++;
...@@ -474,6 +687,7 @@ int ha_archive::rnd_next(byte *buf) ...@@ -474,6 +687,7 @@ int ha_archive::rnd_next(byte *buf)
each call to ha_archive::rnd_next() if an ordering of the rows is each call to ha_archive::rnd_next() if an ordering of the rows is
needed. needed.
*/ */
void ha_archive::position(const byte *record) void ha_archive::position(const byte *record)
{ {
DBUG_ENTER("ha_archive::position"); DBUG_ENTER("ha_archive::position");
...@@ -496,13 +710,70 @@ int ha_archive::rnd_pos(byte * buf, byte *pos) ...@@ -496,13 +710,70 @@ int ha_archive::rnd_pos(byte * buf, byte *pos)
current_position= ha_get_ptr(pos, ref_length); current_position= ha_get_ptr(pos, ref_length);
z_off_t seek= gzseek(archive, current_position, SEEK_SET); z_off_t seek= gzseek(archive, current_position, SEEK_SET);
DBUG_RETURN(get_row(buf)); DBUG_RETURN(get_row(archive, buf));
}
/*
This method rebuilds the meta file. It does this by walking the datafile and
rewriting the meta file.
*/
int ha_archive::rebuild_meta_file(char *table_name, File meta_file)
{
int rc;
byte *buf;
ulonglong rows_recorded= 0;
gzFile rebuild_file; /* Archive file we are working with */
char data_file_name[FN_REFLEN];
DBUG_ENTER("ha_archive::rebuild_meta_file");
/*
Open up the meta file to recreate it.
*/
fn_format(data_file_name, table_name, "", ARZ,
MY_REPLACE_EXT|MY_UNPACK_FILENAME);
if ((rebuild_file= gzopen(data_file_name, "rb")) == NULL)
DBUG_RETURN(errno ? errno : -1);
if (rc= read_data_header(rebuild_file))
goto error;
/*
We malloc up the buffer we will use for counting the rows.
I know, this malloc'ing memory but this should be a very
rare event.
*/
if (!(buf= (byte*) my_malloc(table->rec_buff_length > sizeof(ulonglong) +1 ?
table->rec_buff_length : sizeof(ulonglong) +1 ,
MYF(MY_WME))))
{
rc= HA_ERR_CRASHED_ON_USAGE;
goto error;
}
while (!(rc= get_row(rebuild_file, buf)))
rows_recorded++;
/*
Only if we reach the end of the file do we assume we can rewrite.
At this point we reset rc to a non-message state.
*/
if (rc == HA_ERR_END_OF_FILE)
{
(void)write_meta_file(meta_file, rows_recorded, FALSE);
rc= 0;
}
my_free((gptr) buf, MYF(0));
error:
gzclose(rebuild_file);
DBUG_RETURN(rc);
} }
/* /*
The table can become fragmented if data was inserted, read, and then The table can become fragmented if data was inserted, read, and then
inserted again. What we do is open up the file and recompress it completely. inserted again. What we do is open up the file and recompress it completely.
*/ */
int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt) int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt)
{ {
DBUG_ENTER("ha_archive::optimize"); DBUG_ENTER("ha_archive::optimize");
...@@ -512,7 +783,8 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt) ...@@ -512,7 +783,8 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt)
char writer_filename[FN_REFLEN]; char writer_filename[FN_REFLEN];
/* Lets create a file to contain the new data */ /* Lets create a file to contain the new data */
fn_format(writer_filename,share->table_name,"",ARN, MY_REPLACE_EXT|MY_UNPACK_FILENAME); fn_format(writer_filename, share->table_name, "", ARN,
MY_REPLACE_EXT|MY_UNPACK_FILENAME);
/* Closing will cause all data waiting to be flushed, to be flushed */ /* Closing will cause all data waiting to be flushed, to be flushed */
gzclose(share->archive_write); gzclose(share->archive_write);
...@@ -547,6 +819,57 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt) ...@@ -547,6 +819,57 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt)
DBUG_RETURN(0); DBUG_RETURN(0);
} }
/*
No transactions yet, so this is pretty dull.
*/
int ha_archive::external_lock(THD *thd, int lock_type)
{
DBUG_ENTER("ha_archive::external_lock");
DBUG_RETURN(0);
}
/*
Below is an example of how to setup row level locking.
*/
THR_LOCK_DATA **ha_archive::store_lock(THD *thd,
THR_LOCK_DATA **to,
enum thr_lock_type lock_type)
{
if (lock_type != TL_IGNORE && lock.type == TL_UNLOCK)
{
/*
Here is where we get into the guts of a row level lock.
If TL_UNLOCK is set
If we are not doing a LOCK TABLE or DISCARD/IMPORT
TABLESPACE, then allow multiple writers
*/
if ((lock_type >= TL_WRITE_CONCURRENT_INSERT &&
lock_type <= TL_WRITE) && !thd->in_lock_tables
&& !thd->tablespace_op)
lock_type = TL_WRITE_ALLOW_WRITE;
/*
In queries of type INSERT INTO t1 SELECT ... FROM t2 ...
MySQL would use the lock TL_READ_NO_INSERT on t2, and that
would conflict with TL_WRITE_ALLOW_WRITE, blocking all inserts
to t2. Convert the lock to a normal read lock to allow
concurrent inserts to t2.
*/
if (lock_type == TL_READ_NO_INSERT && !thd->in_lock_tables)
lock_type = TL_READ;
lock.type=lock_type;
}
*to++= &lock;
return to;
}
/****************************************************************************** /******************************************************************************
Everything below here is default, please look at ha_example.cc for Everything below here is default, please look at ha_example.cc for
...@@ -616,8 +939,8 @@ void ha_archive::info(uint flag) ...@@ -616,8 +939,8 @@ void ha_archive::info(uint flag)
DBUG_ENTER("ha_archive::info"); DBUG_ENTER("ha_archive::info");
/* This is a lie, but you don't want the optimizer to see zero or 1 */ /* This is a lie, but you don't want the optimizer to see zero or 1 */
if (records < 2) records= share->rows_recorded;
records= 2; deleted= 0;
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
...@@ -634,23 +957,6 @@ int ha_archive::reset(void) ...@@ -634,23 +957,6 @@ int ha_archive::reset(void)
DBUG_RETURN(0); DBUG_RETURN(0);
} }
int ha_archive::external_lock(THD *thd, int lock_type)
{
DBUG_ENTER("ha_archive::external_lock");
DBUG_RETURN(0);
}
THR_LOCK_DATA **ha_archive::store_lock(THD *thd,
THR_LOCK_DATA **to,
enum thr_lock_type lock_type)
{
if (lock_type != TL_IGNORE && lock.type == TL_UNLOCK)
lock.type=lock_type;
*to++= &lock;
return to;
}
ha_rows ha_archive::records_in_range(uint inx, key_range *min_key, ha_rows ha_archive::records_in_range(uint inx, key_range *min_key,
key_range *max_key) key_range *max_key)
{ {
......
...@@ -32,8 +32,10 @@ typedef struct st_archive_share { ...@@ -32,8 +32,10 @@ typedef struct st_archive_share {
uint table_name_length,use_count; uint table_name_length,use_count;
pthread_mutex_t mutex; pthread_mutex_t mutex;
THR_LOCK lock; THR_LOCK lock;
File meta_file; /* Meta file we use */
gzFile archive_write; /* Archive file we are working with */ gzFile archive_write; /* Archive file we are working with */
bool dirty; /* Flag for if a flush should occur */ bool dirty; /* Flag for if a flush should occur */
ulonglong rows_recorded; /* Number of rows in tables */
} ARCHIVE_SHARE; } ARCHIVE_SHARE;
/* /*
...@@ -50,7 +52,7 @@ class ha_archive: public handler ...@@ -50,7 +52,7 @@ class ha_archive: public handler
z_off_t current_position; /* The position of the row we just read */ z_off_t current_position; /* The position of the row we just read */
byte byte_buffer[IO_SIZE]; /* Initial buffer for our string */ byte byte_buffer[IO_SIZE]; /* Initial buffer for our string */
String buffer; /* Buffer used for blob storage */ String buffer; /* Buffer used for blob storage */
unsigned int version; /* Used for recording version */ ulonglong scan_rows; /* Number of rows left in scan */
public: public:
ha_archive(TABLE *table): handler(table) ha_archive(TABLE *table): handler(table)
...@@ -104,7 +106,14 @@ public: ...@@ -104,7 +106,14 @@ public:
int rnd_init(bool scan=1); int rnd_init(bool scan=1);
int rnd_next(byte *buf); int rnd_next(byte *buf);
int rnd_pos(byte * buf, byte *pos); int rnd_pos(byte * buf, byte *pos);
int get_row(byte *buf); int get_row(gzFile file_to_read, byte *buf);
int read_meta_file(File meta_file, ulonglong *rows);
int write_meta_file(File meta_file, ulonglong rows, bool dirty);
ARCHIVE_SHARE *get_share(const char *table_name, TABLE *table);
int free_share(ARCHIVE_SHARE *share);
int rebuild_meta_file(char *table_name, File meta_file);
int read_data_header(gzFile file_to_read);
int write_data_header(gzFile file_to_write);
void position(const byte *record); void position(const byte *record);
void info(uint); void info(uint);
int extra(enum ha_extra_function operation); int extra(enum ha_extra_function operation);
......
...@@ -963,7 +963,7 @@ void clean_up(bool print_message) ...@@ -963,7 +963,7 @@ void clean_up(bool print_message)
if (print_message && errmesg) if (print_message && errmesg)
sql_print_information(ER(ER_SHUTDOWN_COMPLETE),my_progname); sql_print_information(ER(ER_SHUTDOWN_COMPLETE),my_progname);
#if !defined(__WIN__) && !defined(EMBEDDED_LIBRARY) #if !defined(EMBEDDED_LIBRARY)
if (!opt_bootstrap) if (!opt_bootstrap)
(void) my_delete(pidfile_name,MYF(0)); // This may not always exist (void) my_delete(pidfile_name,MYF(0)); // This may not always exist
#endif #endif
...@@ -1500,7 +1500,11 @@ static void init_signals(void) ...@@ -1500,7 +1500,11 @@ static void init_signals(void)
} }
static void start_signal_handler(void) static void start_signal_handler(void)
{} {
// Save vm id of this process
if (!opt_bootstrap)
create_pid_file();
}
static void check_data_home(const char *path) static void check_data_home(const char *path)
{} {}
...@@ -2934,10 +2938,10 @@ we force server id to 2, but this MySQL server will not act as a slave."); ...@@ -2934,10 +2938,10 @@ we force server id to 2, but this MySQL server will not act as a slave.");
#ifndef __NETWARE__ #ifndef __NETWARE__
(void) pthread_kill(signal_thread, MYSQL_KILL_SIGNAL); (void) pthread_kill(signal_thread, MYSQL_KILL_SIGNAL);
#endif /* __NETWARE__ */ #endif /* __NETWARE__ */
#ifndef __WIN__
if (!opt_bootstrap) if (!opt_bootstrap)
(void) my_delete(pidfile_name,MYF(MY_WME)); // Not needed anymore (void) my_delete(pidfile_name,MYF(MY_WME)); // Not needed anymore
#endif
if (unix_sock != INVALID_SOCKET) if (unix_sock != INVALID_SOCKET)
unlink(mysqld_unix_port); unlink(mysqld_unix_port);
exit(1); exit(1);
......
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