diff --git a/mysql-test/include/ps_query.inc b/mysql-test/include/ps_query.inc index e02d0d5bf96..27ab85410c8 100644 --- a/mysql-test/include/ps_query.inc +++ b/mysql-test/include/ps_query.inc @@ -104,13 +104,13 @@ prepare stmt1 from ' select substr(''MySQL'',1,?) from t1 where a=1 ' ; execute stmt1 using @arg00 ; # variations on 'concat' 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(,),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; # -select a , concat(b,@arg00) from t1 ; -prepare stmt1 from ' select a , concat(b,?) from t1 ' ; +select a , concat(b,@arg00) from t1 order by a ; +prepare stmt1 from ' select a , concat(b,?) from t1 order by a ' ; execute stmt1 using @arg00; # variations on 'group_concat' @@ -147,7 +147,7 @@ create table t5 (id1 int(11) not null default '0', value2 varchar(100), value1 varchar(100)) ; insert into t5 values (1,'hh','hh'),(2,'hh','hh'), (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 @arg01='hh' ; execute stmt1 using @arg00, @arg01 ; @@ -216,8 +216,8 @@ execute stmt1 using @arg00 ; # parameter in IN set @arg00=2 ; set @arg01=3 ; -select a FROM t1 where a in (@arg00,@arg01); -prepare stmt1 from ' select a FROM t1 where a in (?,?) '; +select a FROM t1 where a in (@arg00,@arg01) order by a; +prepare stmt1 from ' select a FROM t1 where a in (?,?) order by a '; execute stmt1 using @arg00, @arg01; # case derived from client_test.c: test_bug1500() set @arg00= 'one' ; @@ -270,9 +270,9 @@ execute stmt1 using @arg00 ; ##### parameter used in having clause set @arg00='two' ; 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 -AND b is not NULL having b <> ? ' ; +AND b is not NULL having b <> ? order by a ' ; execute stmt1 using @arg00 ; ##### parameter used in order clause @@ -297,7 +297,7 @@ execute stmt1 using @arg00; ##### parameter used in limit clause set @arg00=1; -prepare stmt1 from ' select a,b from t1 +prepare stmt1 from ' select a,b from t1 order by a limit 1 '; execute stmt1 ; # currently (May 2004, Version 4.1) it is impossible @@ -327,10 +327,10 @@ select '------ join tests ------' as test_sequence ; # no parameter select first.a as a1, second.a as a2 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 from t1 first, t1 second - where first.a = second.a '; + where first.a = second.a order by a1 '; execute stmt1 ; # some parameters @@ -350,15 +350,15 @@ execute stmt1 using @arg00, @arg01, @arg02; drop table if exists t2 ; --enable_warnings create table t2 as select * from t1 ; -set @query1= 'SELECT * FROM t2 join t1 on (t1.a=t2.a) ' ; -set @query2= 'SELECT * FROM t2 natural join t1 ' ; -set @query3= 'SELECT * FROM t2 join t1 using(a) ' ; -set @query4= 'SELECT * FROM t2 left join t1 on(t1.a=t2.a) ' ; -set @query5= 'SELECT * FROM t2 natural left join t1 ' ; -set @query6= 'SELECT * FROM t2 left join t1 using(a) ' ; -set @query7= 'SELECT * FROM t2 right join t1 on(t1.a=t2.a) ' ; -set @query8= 'SELECT * FROM t2 natural right join t1 ' ; -set @query9= 'SELECT * FROM t2 right join t1 using(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 order by t2.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) order by t2.a ' ; +set @query5= 'SELECT * FROM t2 natural left join t1 order by t2.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) order by t2.a ' ; +set @query8= 'SELECT * FROM t2 natural right join t1 order by t2.a ' ; +set @query9= 'SELECT * FROM t2 right join t1 using(a) order by t2.a ' ; let $1= 9 ; while ($1) { @@ -424,7 +424,7 @@ execute stmt1 using @arg00, @arg01, @arg02, @arg03 ; ######## correlated subquery # no parameter 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) # Bug#4106 : ndb table, query with correlated subquery, wrong result execute stmt1 ; diff --git a/mysql-test/r/ndb_subquery.result b/mysql-test/r/ndb_subquery.result index 8c89805a765..f65f09b71b3 100644 --- a/mysql-test/r/ndb_subquery.result +++ b/mysql-test/r/ndb_subquery.result @@ -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 1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using where 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 4 4 4 5 5 5 @@ -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 1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using where 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 4 4 4 5 5 5 @@ -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 1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using where 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 4 4 4 5 5 5 @@ -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 1 PRIMARY t2 ALL NULL NULL NULL NULL 5 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 4 4 4 5 5 5 diff --git a/mysql-test/r/ps_2myisam.result b/mysql-test/r/ps_2myisam.result index 68e0a53fdba..63463baabfd 100644 --- a/mysql-test/r/ps_2myisam.result +++ b/mysql-test/r/ps_2myisam.result @@ -165,26 +165,26 @@ execute stmt1 using @arg00 ; substr('MySQL',1,?) MyS set @arg00='MySQL' ; -select a , concat(@arg00,b) from t1 ; +select a , concat(@arg00,b) from t1 order by a; a concat(@arg00,b) 1 MySQLone 2 MySQLtwo 3 MySQLthree 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; a concat(?,b) 1 MySQLone 2 MySQLtwo 3 MySQLthree 4 MySQLfour -select a , concat(b,@arg00) from t1 ; +select a , concat(b,@arg00) from t1 order by a ; a concat(b,@arg00) 1 oneMySQL 2 twoMySQL 3 threeMySQL 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; a concat(b,?) 1 oneMySQL @@ -234,14 +234,14 @@ create table t5 (id1 int(11) not null default '0', value2 varchar(100), value1 varchar(100)) ; insert into t5 values (1,'hh','hh'),(2,'hh','hh'), (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 @arg01='hh' ; execute stmt1 using @arg00, @arg01 ; id1 value1 1 hh -2 hh 1 ii +2 hh drop table t5 ; drop table if exists t5 ; create table t5(session_id char(9) not null) ; @@ -307,11 +307,11 @@ execute stmt1 using @arg00 ; a set @arg00=2 ; 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 2 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; a 2 @@ -385,13 +385,13 @@ a b 4 four set @arg00='two' ; 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 1 one 3 three 4 four 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 ; a b 1 one @@ -439,7 +439,7 @@ set @arg00=0 ; execute stmt1 using @arg00; ERROR 42S22: Unknown column '?' in 'order clause' set @arg00=1; -prepare stmt1 from ' select a,b from t1 +prepare stmt1 from ' select a,b from t1 order by a limit 1 '; execute stmt1 ; a b @@ -470,7 +470,7 @@ test_sequence ------ join tests ------ select first.a as a1, second.a as a2 from t1 first, t1 second -where first.a = second.a ; +where first.a = second.a order by a1 ; a1 a2 1 1 2 2 @@ -478,7 +478,7 @@ a1 a2 4 4 prepare stmt1 from ' select first.a as a1, second.a as a2 from t1 first, t1 second - where first.a = second.a '; + where first.a = second.a order by a1 '; execute stmt1 ; a1 a2 1 1 @@ -517,17 +517,17 @@ a ? a 4 ABC 4 drop table if exists t2 ; create table t2 as select * from t1 ; -set @query1= 'SELECT * FROM t2 join t1 on (t1.a=t2.a) ' ; -set @query2= 'SELECT * FROM t2 natural join t1 ' ; -set @query3= 'SELECT * FROM t2 join t1 using(a) ' ; -set @query4= 'SELECT * FROM t2 left join t1 on(t1.a=t2.a) ' ; -set @query5= 'SELECT * FROM t2 natural left join t1 ' ; -set @query6= 'SELECT * FROM t2 left join t1 using(a) ' ; -set @query7= 'SELECT * FROM t2 right join t1 on(t1.a=t2.a) ' ; -set @query8= 'SELECT * FROM t2 natural right join t1 ' ; -set @query9= 'SELECT * FROM t2 right join t1 using(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 order by t2.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) order by t2.a ' ; +set @query5= 'SELECT * FROM t2 natural left join t1 order by t2.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) order by t2.a ' ; +set @query8= 'SELECT * FROM t2 natural right join t1 order by t2.a ' ; +set @query9= 'SELECT * FROM t2 right join t1 using(a) order by t2.a ' ; 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 ; execute stmt1 ; a b a b @@ -548,7 +548,7 @@ a b a b 3 three 3 three 4 four 4 four 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 ; execute stmt1 ; a b a b @@ -569,7 +569,7 @@ a b a b 3 three 3 three 4 four 4 four 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 ; execute stmt1 ; a b a b @@ -590,7 +590,7 @@ a b a b 3 three 3 three 4 four 4 four 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 ; execute stmt1 ; a b a b @@ -611,7 +611,7 @@ a b a b 3 three 3 three 4 four 4 four 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 ; execute stmt1 ; a b a b @@ -632,7 +632,7 @@ a b a b 3 three 3 three 4 four 4 four 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 ; execute stmt1 ; a b a b @@ -653,7 +653,7 @@ a b a b 3 three 3 three 4 four 4 four 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 ; execute stmt1 ; a b a b @@ -674,7 +674,7 @@ a b a b 3 three 3 three 4 four 4 four the join statement is: -SELECT * FROM t2 natural join t1 +SELECT * FROM t2 natural join t1 order by t2.a prepare stmt1 from @query2 ; execute stmt1 ; a b @@ -695,7 +695,7 @@ a b 3 three 4 four 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 ; execute stmt1 ; a b a b @@ -769,7 +769,7 @@ execute stmt1 using @arg00, @arg01, @arg02, @arg03 ; a ? b 2 1 two 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 ; a b 1 one diff --git a/mysql-test/r/ps_3innodb.result b/mysql-test/r/ps_3innodb.result index 90cd5e39f9c..70ba4a109d7 100644 --- a/mysql-test/r/ps_3innodb.result +++ b/mysql-test/r/ps_3innodb.result @@ -165,26 +165,26 @@ execute stmt1 using @arg00 ; substr('MySQL',1,?) MyS set @arg00='MySQL' ; -select a , concat(@arg00,b) from t1 ; +select a , concat(@arg00,b) from t1 order by a; a concat(@arg00,b) 1 MySQLone 2 MySQLtwo 3 MySQLthree 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; a concat(?,b) 1 MySQLone 2 MySQLtwo 3 MySQLthree 4 MySQLfour -select a , concat(b,@arg00) from t1 ; +select a , concat(b,@arg00) from t1 order by a ; a concat(b,@arg00) 1 oneMySQL 2 twoMySQL 3 threeMySQL 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; a concat(b,?) 1 oneMySQL @@ -234,14 +234,14 @@ create table t5 (id1 int(11) not null default '0', value2 varchar(100), value1 varchar(100)) ; insert into t5 values (1,'hh','hh'),(2,'hh','hh'), (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 @arg01='hh' ; execute stmt1 using @arg00, @arg01 ; id1 value1 1 hh -2 hh 1 ii +2 hh drop table t5 ; drop table if exists t5 ; create table t5(session_id char(9) not null) ; @@ -307,11 +307,11 @@ execute stmt1 using @arg00 ; a set @arg00=2 ; 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 2 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; a 2 @@ -385,13 +385,13 @@ a b 4 four set @arg00='two' ; 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 1 one 3 three 4 four 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 ; a b 1 one @@ -439,7 +439,7 @@ set @arg00=0 ; execute stmt1 using @arg00; ERROR 42S22: Unknown column '?' in 'order clause' set @arg00=1; -prepare stmt1 from ' select a,b from t1 +prepare stmt1 from ' select a,b from t1 order by a limit 1 '; execute stmt1 ; a b @@ -470,7 +470,7 @@ test_sequence ------ join tests ------ select first.a as a1, second.a as a2 from t1 first, t1 second -where first.a = second.a ; +where first.a = second.a order by a1 ; a1 a2 1 1 2 2 @@ -478,7 +478,7 @@ a1 a2 4 4 prepare stmt1 from ' select first.a as a1, second.a as a2 from t1 first, t1 second - where first.a = second.a '; + where first.a = second.a order by a1 '; execute stmt1 ; a1 a2 1 1 @@ -517,17 +517,17 @@ a ? a 4 ABC 4 drop table if exists t2 ; create table t2 as select * from t1 ; -set @query1= 'SELECT * FROM t2 join t1 on (t1.a=t2.a) ' ; -set @query2= 'SELECT * FROM t2 natural join t1 ' ; -set @query3= 'SELECT * FROM t2 join t1 using(a) ' ; -set @query4= 'SELECT * FROM t2 left join t1 on(t1.a=t2.a) ' ; -set @query5= 'SELECT * FROM t2 natural left join t1 ' ; -set @query6= 'SELECT * FROM t2 left join t1 using(a) ' ; -set @query7= 'SELECT * FROM t2 right join t1 on(t1.a=t2.a) ' ; -set @query8= 'SELECT * FROM t2 natural right join t1 ' ; -set @query9= 'SELECT * FROM t2 right join t1 using(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 order by t2.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) order by t2.a ' ; +set @query5= 'SELECT * FROM t2 natural left join t1 order by t2.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) order by t2.a ' ; +set @query8= 'SELECT * FROM t2 natural right join t1 order by t2.a ' ; +set @query9= 'SELECT * FROM t2 right join t1 using(a) order by t2.a ' ; 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 ; execute stmt1 ; a b a b @@ -548,7 +548,7 @@ a b a b 3 three 3 three 4 four 4 four 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 ; execute stmt1 ; a b a b @@ -569,7 +569,7 @@ a b a b 3 three 3 three 4 four 4 four 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 ; execute stmt1 ; a b a b @@ -590,7 +590,7 @@ a b a b 3 three 3 three 4 four 4 four 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 ; execute stmt1 ; a b a b @@ -611,7 +611,7 @@ a b a b 3 three 3 three 4 four 4 four 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 ; execute stmt1 ; a b a b @@ -632,7 +632,7 @@ a b a b 3 three 3 three 4 four 4 four 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 ; execute stmt1 ; a b a b @@ -653,7 +653,7 @@ a b a b 3 three 3 three 4 four 4 four 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 ; execute stmt1 ; a b a b @@ -674,7 +674,7 @@ a b a b 3 three 3 three 4 four 4 four the join statement is: -SELECT * FROM t2 natural join t1 +SELECT * FROM t2 natural join t1 order by t2.a prepare stmt1 from @query2 ; execute stmt1 ; a b @@ -695,7 +695,7 @@ a b 3 three 4 four 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 ; execute stmt1 ; a b a b @@ -769,7 +769,7 @@ execute stmt1 using @arg00, @arg01, @arg02, @arg03 ; a ? b 2 1 two 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 ; a b 1 one diff --git a/mysql-test/r/ps_4heap.result b/mysql-test/r/ps_4heap.result index feef6bcf83e..4c68f0c8593 100644 --- a/mysql-test/r/ps_4heap.result +++ b/mysql-test/r/ps_4heap.result @@ -166,26 +166,26 @@ execute stmt1 using @arg00 ; substr('MySQL',1,?) MyS set @arg00='MySQL' ; -select a , concat(@arg00,b) from t1 ; +select a , concat(@arg00,b) from t1 order by a; a concat(@arg00,b) 1 MySQLone 2 MySQLtwo 3 MySQLthree 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; a concat(?,b) 1 MySQLone 2 MySQLtwo 3 MySQLthree 4 MySQLfour -select a , concat(b,@arg00) from t1 ; +select a , concat(b,@arg00) from t1 order by a ; a concat(b,@arg00) 1 oneMySQL 2 twoMySQL 3 threeMySQL 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; a concat(b,?) 1 oneMySQL @@ -235,14 +235,14 @@ create table t5 (id1 int(11) not null default '0', value2 varchar(100), value1 varchar(100)) ; insert into t5 values (1,'hh','hh'),(2,'hh','hh'), (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 @arg01='hh' ; execute stmt1 using @arg00, @arg01 ; id1 value1 1 hh -2 hh 1 ii +2 hh drop table t5 ; drop table if exists t5 ; create table t5(session_id char(9) not null) ; @@ -308,11 +308,11 @@ execute stmt1 using @arg00 ; a set @arg00=2 ; 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 2 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; a 2 @@ -386,13 +386,13 @@ a b 4 four set @arg00='two' ; 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 1 one 3 three 4 four 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 ; a b 1 one @@ -440,7 +440,7 @@ set @arg00=0 ; execute stmt1 using @arg00; ERROR 42S22: Unknown column '?' in 'order clause' set @arg00=1; -prepare stmt1 from ' select a,b from t1 +prepare stmt1 from ' select a,b from t1 order by a limit 1 '; execute stmt1 ; a b @@ -471,7 +471,7 @@ test_sequence ------ join tests ------ select first.a as a1, second.a as a2 from t1 first, t1 second -where first.a = second.a ; +where first.a = second.a order by a1 ; a1 a2 1 1 2 2 @@ -479,7 +479,7 @@ a1 a2 4 4 prepare stmt1 from ' select first.a as a1, second.a as a2 from t1 first, t1 second - where first.a = second.a '; + where first.a = second.a order by a1 '; execute stmt1 ; a1 a2 1 1 @@ -518,17 +518,17 @@ a ? a 4 ABC 4 drop table if exists t2 ; create table t2 as select * from t1 ; -set @query1= 'SELECT * FROM t2 join t1 on (t1.a=t2.a) ' ; -set @query2= 'SELECT * FROM t2 natural join t1 ' ; -set @query3= 'SELECT * FROM t2 join t1 using(a) ' ; -set @query4= 'SELECT * FROM t2 left join t1 on(t1.a=t2.a) ' ; -set @query5= 'SELECT * FROM t2 natural left join t1 ' ; -set @query6= 'SELECT * FROM t2 left join t1 using(a) ' ; -set @query7= 'SELECT * FROM t2 right join t1 on(t1.a=t2.a) ' ; -set @query8= 'SELECT * FROM t2 natural right join t1 ' ; -set @query9= 'SELECT * FROM t2 right join t1 using(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 order by t2.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) order by t2.a ' ; +set @query5= 'SELECT * FROM t2 natural left join t1 order by t2.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) order by t2.a ' ; +set @query8= 'SELECT * FROM t2 natural right join t1 order by t2.a ' ; +set @query9= 'SELECT * FROM t2 right join t1 using(a) order by t2.a ' ; 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 ; execute stmt1 ; a b a b @@ -549,7 +549,7 @@ a b a b 3 three 3 three 4 four 4 four 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 ; execute stmt1 ; a b a b @@ -570,7 +570,7 @@ a b a b 3 three 3 three 4 four 4 four 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 ; execute stmt1 ; a b a b @@ -591,7 +591,7 @@ a b a b 3 three 3 three 4 four 4 four 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 ; execute stmt1 ; a b a b @@ -612,7 +612,7 @@ a b a b 3 three 3 three 4 four 4 four 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 ; execute stmt1 ; a b a b @@ -633,7 +633,7 @@ a b a b 3 three 3 three 4 four 4 four 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 ; execute stmt1 ; a b a b @@ -654,7 +654,7 @@ a b a b 3 three 3 three 4 four 4 four 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 ; execute stmt1 ; a b a b @@ -675,7 +675,7 @@ a b a b 3 three 3 three 4 four 4 four the join statement is: -SELECT * FROM t2 natural join t1 +SELECT * FROM t2 natural join t1 order by t2.a prepare stmt1 from @query2 ; execute stmt1 ; a b @@ -696,7 +696,7 @@ a b 3 three 4 four 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 ; execute stmt1 ; a b a b @@ -770,7 +770,7 @@ execute stmt1 using @arg00, @arg01, @arg02, @arg03 ; a ? b 2 1 two 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 ; a b 1 one diff --git a/mysql-test/r/ps_5merge.result b/mysql-test/r/ps_5merge.result index 8f87343c894..af5d08d5eb4 100644 --- a/mysql-test/r/ps_5merge.result +++ b/mysql-test/r/ps_5merge.result @@ -208,26 +208,26 @@ execute stmt1 using @arg00 ; substr('MySQL',1,?) MyS set @arg00='MySQL' ; -select a , concat(@arg00,b) from t1 ; +select a , concat(@arg00,b) from t1 order by a; a concat(@arg00,b) 1 MySQLone 2 MySQLtwo 3 MySQLthree 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; a concat(?,b) 1 MySQLone 2 MySQLtwo 3 MySQLthree 4 MySQLfour -select a , concat(b,@arg00) from t1 ; +select a , concat(b,@arg00) from t1 order by a ; a concat(b,@arg00) 1 oneMySQL 2 twoMySQL 3 threeMySQL 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; a concat(b,?) 1 oneMySQL @@ -277,14 +277,14 @@ create table t5 (id1 int(11) not null default '0', value2 varchar(100), value1 varchar(100)) ; insert into t5 values (1,'hh','hh'),(2,'hh','hh'), (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 @arg01='hh' ; execute stmt1 using @arg00, @arg01 ; id1 value1 1 hh -2 hh 1 ii +2 hh drop table t5 ; drop table if exists t5 ; create table t5(session_id char(9) not null) ; @@ -350,11 +350,11 @@ execute stmt1 using @arg00 ; a set @arg00=2 ; 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 2 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; a 2 @@ -428,13 +428,13 @@ a b 4 four set @arg00='two' ; 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 1 one 3 three 4 four 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 ; a b 1 one @@ -482,7 +482,7 @@ set @arg00=0 ; execute stmt1 using @arg00; ERROR 42S22: Unknown column '?' in 'order clause' set @arg00=1; -prepare stmt1 from ' select a,b from t1 +prepare stmt1 from ' select a,b from t1 order by a limit 1 '; execute stmt1 ; a b @@ -513,7 +513,7 @@ test_sequence ------ join tests ------ select first.a as a1, second.a as a2 from t1 first, t1 second -where first.a = second.a ; +where first.a = second.a order by a1 ; a1 a2 1 1 2 2 @@ -521,7 +521,7 @@ a1 a2 4 4 prepare stmt1 from ' select first.a as a1, second.a as a2 from t1 first, t1 second - where first.a = second.a '; + where first.a = second.a order by a1 '; execute stmt1 ; a1 a2 1 1 @@ -560,17 +560,17 @@ a ? a 4 ABC 4 drop table if exists t2 ; create table t2 as select * from t1 ; -set @query1= 'SELECT * FROM t2 join t1 on (t1.a=t2.a) ' ; -set @query2= 'SELECT * FROM t2 natural join t1 ' ; -set @query3= 'SELECT * FROM t2 join t1 using(a) ' ; -set @query4= 'SELECT * FROM t2 left join t1 on(t1.a=t2.a) ' ; -set @query5= 'SELECT * FROM t2 natural left join t1 ' ; -set @query6= 'SELECT * FROM t2 left join t1 using(a) ' ; -set @query7= 'SELECT * FROM t2 right join t1 on(t1.a=t2.a) ' ; -set @query8= 'SELECT * FROM t2 natural right join t1 ' ; -set @query9= 'SELECT * FROM t2 right join t1 using(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 order by t2.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) order by t2.a ' ; +set @query5= 'SELECT * FROM t2 natural left join t1 order by t2.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) order by t2.a ' ; +set @query8= 'SELECT * FROM t2 natural right join t1 order by t2.a ' ; +set @query9= 'SELECT * FROM t2 right join t1 using(a) order by t2.a ' ; 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 ; execute stmt1 ; a b a b @@ -591,7 +591,7 @@ a b a b 3 three 3 three 4 four 4 four 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 ; execute stmt1 ; a b a b @@ -612,7 +612,7 @@ a b a b 3 three 3 three 4 four 4 four 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 ; execute stmt1 ; a b a b @@ -633,7 +633,7 @@ a b a b 3 three 3 three 4 four 4 four 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 ; execute stmt1 ; a b a b @@ -654,7 +654,7 @@ a b a b 3 three 3 three 4 four 4 four 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 ; execute stmt1 ; a b a b @@ -675,7 +675,7 @@ a b a b 3 three 3 three 4 four 4 four 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 ; execute stmt1 ; a b a b @@ -696,7 +696,7 @@ a b a b 3 three 3 three 4 four 4 four 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 ; execute stmt1 ; a b a b @@ -717,7 +717,7 @@ a b a b 3 three 3 three 4 four 4 four the join statement is: -SELECT * FROM t2 natural join t1 +SELECT * FROM t2 natural join t1 order by t2.a prepare stmt1 from @query2 ; execute stmt1 ; a b @@ -738,7 +738,7 @@ a b 3 three 4 four 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 ; execute stmt1 ; a b a b @@ -812,7 +812,7 @@ execute stmt1 using @arg00, @arg01, @arg02, @arg03 ; a ? b 2 1 two 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 ; a b 1 one @@ -3216,26 +3216,26 @@ execute stmt1 using @arg00 ; substr('MySQL',1,?) MyS set @arg00='MySQL' ; -select a , concat(@arg00,b) from t1 ; +select a , concat(@arg00,b) from t1 order by a; a concat(@arg00,b) 1 MySQLone 2 MySQLtwo 3 MySQLthree 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; a concat(?,b) 1 MySQLone 2 MySQLtwo 3 MySQLthree 4 MySQLfour -select a , concat(b,@arg00) from t1 ; +select a , concat(b,@arg00) from t1 order by a ; a concat(b,@arg00) 1 oneMySQL 2 twoMySQL 3 threeMySQL 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; a concat(b,?) 1 oneMySQL @@ -3285,14 +3285,14 @@ create table t5 (id1 int(11) not null default '0', value2 varchar(100), value1 varchar(100)) ; insert into t5 values (1,'hh','hh'),(2,'hh','hh'), (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 @arg01='hh' ; execute stmt1 using @arg00, @arg01 ; id1 value1 1 hh -2 hh 1 ii +2 hh drop table t5 ; drop table if exists t5 ; create table t5(session_id char(9) not null) ; @@ -3358,11 +3358,11 @@ execute stmt1 using @arg00 ; a set @arg00=2 ; 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 2 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; a 2 @@ -3436,13 +3436,13 @@ a b 4 four set @arg00='two' ; 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 1 one 3 three 4 four 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 ; a b 1 one @@ -3490,7 +3490,7 @@ set @arg00=0 ; execute stmt1 using @arg00; ERROR 42S22: Unknown column '?' in 'order clause' set @arg00=1; -prepare stmt1 from ' select a,b from t1 +prepare stmt1 from ' select a,b from t1 order by a limit 1 '; execute stmt1 ; a b @@ -3521,7 +3521,7 @@ test_sequence ------ join tests ------ select first.a as a1, second.a as a2 from t1 first, t1 second -where first.a = second.a ; +where first.a = second.a order by a1 ; a1 a2 1 1 2 2 @@ -3529,7 +3529,7 @@ a1 a2 4 4 prepare stmt1 from ' select first.a as a1, second.a as a2 from t1 first, t1 second - where first.a = second.a '; + where first.a = second.a order by a1 '; execute stmt1 ; a1 a2 1 1 @@ -3568,17 +3568,17 @@ a ? a 4 ABC 4 drop table if exists t2 ; create table t2 as select * from t1 ; -set @query1= 'SELECT * FROM t2 join t1 on (t1.a=t2.a) ' ; -set @query2= 'SELECT * FROM t2 natural join t1 ' ; -set @query3= 'SELECT * FROM t2 join t1 using(a) ' ; -set @query4= 'SELECT * FROM t2 left join t1 on(t1.a=t2.a) ' ; -set @query5= 'SELECT * FROM t2 natural left join t1 ' ; -set @query6= 'SELECT * FROM t2 left join t1 using(a) ' ; -set @query7= 'SELECT * FROM t2 right join t1 on(t1.a=t2.a) ' ; -set @query8= 'SELECT * FROM t2 natural right join t1 ' ; -set @query9= 'SELECT * FROM t2 right join t1 using(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 order by t2.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) order by t2.a ' ; +set @query5= 'SELECT * FROM t2 natural left join t1 order by t2.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) order by t2.a ' ; +set @query8= 'SELECT * FROM t2 natural right join t1 order by t2.a ' ; +set @query9= 'SELECT * FROM t2 right join t1 using(a) order by t2.a ' ; 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 ; execute stmt1 ; a b a b @@ -3599,7 +3599,7 @@ a b a b 3 three 3 three 4 four 4 four 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 ; execute stmt1 ; a b a b @@ -3620,7 +3620,7 @@ a b a b 3 three 3 three 4 four 4 four 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 ; execute stmt1 ; a b a b @@ -3641,7 +3641,7 @@ a b a b 3 three 3 three 4 four 4 four 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 ; execute stmt1 ; a b a b @@ -3662,7 +3662,7 @@ a b a b 3 three 3 three 4 four 4 four 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 ; execute stmt1 ; a b a b @@ -3683,7 +3683,7 @@ a b a b 3 three 3 three 4 four 4 four 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 ; execute stmt1 ; a b a b @@ -3704,7 +3704,7 @@ a b a b 3 three 3 three 4 four 4 four 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 ; execute stmt1 ; a b a b @@ -3725,7 +3725,7 @@ a b a b 3 three 3 three 4 four 4 four the join statement is: -SELECT * FROM t2 natural join t1 +SELECT * FROM t2 natural join t1 order by t2.a prepare stmt1 from @query2 ; execute stmt1 ; a b @@ -3746,7 +3746,7 @@ a b 3 three 4 four 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 ; execute stmt1 ; a b a b @@ -3820,7 +3820,7 @@ execute stmt1 using @arg00, @arg01, @arg02, @arg03 ; a ? b 2 1 two 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 ; a b 1 one diff --git a/mysql-test/r/ps_6bdb.result b/mysql-test/r/ps_6bdb.result index 52009dcf82a..75358bd201b 100644 --- a/mysql-test/r/ps_6bdb.result +++ b/mysql-test/r/ps_6bdb.result @@ -165,26 +165,26 @@ execute stmt1 using @arg00 ; substr('MySQL',1,?) MyS set @arg00='MySQL' ; -select a , concat(@arg00,b) from t1 ; +select a , concat(@arg00,b) from t1 order by a; a concat(@arg00,b) 1 MySQLone 2 MySQLtwo 3 MySQLthree 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; a concat(?,b) 1 MySQLone 2 MySQLtwo 3 MySQLthree 4 MySQLfour -select a , concat(b,@arg00) from t1 ; +select a , concat(b,@arg00) from t1 order by a ; a concat(b,@arg00) 1 oneMySQL 2 twoMySQL 3 threeMySQL 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; a concat(b,?) 1 oneMySQL @@ -234,14 +234,14 @@ create table t5 (id1 int(11) not null default '0', value2 varchar(100), value1 varchar(100)) ; insert into t5 values (1,'hh','hh'),(2,'hh','hh'), (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 @arg01='hh' ; execute stmt1 using @arg00, @arg01 ; id1 value1 1 hh -2 hh 1 ii +2 hh drop table t5 ; drop table if exists t5 ; create table t5(session_id char(9) not null) ; @@ -307,11 +307,11 @@ execute stmt1 using @arg00 ; a set @arg00=2 ; 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 2 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; a 2 @@ -385,13 +385,13 @@ a b 4 four set @arg00='two' ; 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 1 one 3 three 4 four 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 ; a b 1 one @@ -439,7 +439,7 @@ set @arg00=0 ; execute stmt1 using @arg00; ERROR 42S22: Unknown column '?' in 'order clause' set @arg00=1; -prepare stmt1 from ' select a,b from t1 +prepare stmt1 from ' select a,b from t1 order by a limit 1 '; execute stmt1 ; a b @@ -470,7 +470,7 @@ test_sequence ------ join tests ------ select first.a as a1, second.a as a2 from t1 first, t1 second -where first.a = second.a ; +where first.a = second.a order by a1 ; a1 a2 1 1 2 2 @@ -478,7 +478,7 @@ a1 a2 4 4 prepare stmt1 from ' select first.a as a1, second.a as a2 from t1 first, t1 second - where first.a = second.a '; + where first.a = second.a order by a1 '; execute stmt1 ; a1 a2 1 1 @@ -517,17 +517,17 @@ a ? a 4 ABC 4 drop table if exists t2 ; create table t2 as select * from t1 ; -set @query1= 'SELECT * FROM t2 join t1 on (t1.a=t2.a) ' ; -set @query2= 'SELECT * FROM t2 natural join t1 ' ; -set @query3= 'SELECT * FROM t2 join t1 using(a) ' ; -set @query4= 'SELECT * FROM t2 left join t1 on(t1.a=t2.a) ' ; -set @query5= 'SELECT * FROM t2 natural left join t1 ' ; -set @query6= 'SELECT * FROM t2 left join t1 using(a) ' ; -set @query7= 'SELECT * FROM t2 right join t1 on(t1.a=t2.a) ' ; -set @query8= 'SELECT * FROM t2 natural right join t1 ' ; -set @query9= 'SELECT * FROM t2 right join t1 using(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 order by t2.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) order by t2.a ' ; +set @query5= 'SELECT * FROM t2 natural left join t1 order by t2.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) order by t2.a ' ; +set @query8= 'SELECT * FROM t2 natural right join t1 order by t2.a ' ; +set @query9= 'SELECT * FROM t2 right join t1 using(a) order by t2.a ' ; 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 ; execute stmt1 ; a b a b @@ -548,7 +548,7 @@ a b a b 3 three 3 three 4 four 4 four 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 ; execute stmt1 ; a b a b @@ -569,7 +569,7 @@ a b a b 3 three 3 three 4 four 4 four 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 ; execute stmt1 ; a b a b @@ -590,7 +590,7 @@ a b a b 3 three 3 three 4 four 4 four 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 ; execute stmt1 ; a b a b @@ -611,7 +611,7 @@ a b a b 3 three 3 three 4 four 4 four 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 ; execute stmt1 ; a b a b @@ -632,7 +632,7 @@ a b a b 3 three 3 three 4 four 4 four 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 ; execute stmt1 ; a b a b @@ -653,7 +653,7 @@ a b a b 3 three 3 three 4 four 4 four 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 ; execute stmt1 ; a b a b @@ -674,7 +674,7 @@ a b a b 3 three 3 three 4 four 4 four the join statement is: -SELECT * FROM t2 natural join t1 +SELECT * FROM t2 natural join t1 order by t2.a prepare stmt1 from @query2 ; execute stmt1 ; a b @@ -695,7 +695,7 @@ a b 3 three 4 four 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 ; execute stmt1 ; a b a b @@ -769,7 +769,7 @@ execute stmt1 using @arg00, @arg01, @arg02, @arg03 ; a ? b 2 1 two 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 ; a b 1 one diff --git a/mysql-test/r/ps_7ndb.result b/mysql-test/r/ps_7ndb.result index decfc08b555..e33bbd7002c 100644 --- a/mysql-test/r/ps_7ndb.result +++ b/mysql-test/r/ps_7ndb.result @@ -166,32 +166,32 @@ execute stmt1 using @arg00 ; substr('MySQL',1,?) MyS set @arg00='MySQL' ; -select a , concat(@arg00,b) from t1 ; +select a , concat(@arg00,b) from t1 order by a; a concat(@arg00,b) -2 MySQLtwo -4 MySQLfour -3 MySQLthree 1 MySQLone -prepare stmt1 from ' select a , concat(?,b) from t1 ' ; +2 MySQLtwo +3 MySQLthree +4 MySQLfour +prepare stmt1 from ' select a , concat(?,b) from t1 order by a ' ; execute stmt1 using @arg00; a concat(?,b) -2 MySQLtwo -4 MySQLfour -3 MySQLthree 1 MySQLone -select a , concat(b,@arg00) from t1 ; +2 MySQLtwo +3 MySQLthree +4 MySQLfour +select a , concat(b,@arg00) from t1 order by a ; a concat(b,@arg00) -2 twoMySQL -4 fourMySQL -3 threeMySQL 1 oneMySQL -prepare stmt1 from ' select a , concat(b,?) from t1 ' ; +2 twoMySQL +3 threeMySQL +4 fourMySQL +prepare stmt1 from ' select a , concat(b,?) from t1 order by a ' ; execute stmt1 using @arg00; a concat(b,?) -2 twoMySQL -4 fourMySQL -3 threeMySQL 1 oneMySQL +2 twoMySQL +3 threeMySQL +4 fourMySQL set @arg00='MySQL' ; select group_concat(@arg00,b) from t1 group by 'a' ; @@ -235,14 +235,14 @@ create table t5 (id1 int(11) not null default '0', value2 varchar(100), value1 varchar(100)) ; insert into t5 values (1,'hh','hh'),(2,'hh','hh'), (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 @arg01='hh' ; execute stmt1 using @arg00, @arg01 ; id1 value1 1 hh -2 hh 1 ii +2 hh drop table t5 ; drop table if exists t5 ; create table t5(session_id char(9) not null) ; @@ -308,11 +308,11 @@ execute stmt1 using @arg00 ; a set @arg00=2 ; 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 2 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; a 2 @@ -386,18 +386,18 @@ a b 4 four set @arg00='two' ; 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 -4 four -3 three 1 one +3 three +4 four 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 ; a b -4 four -3 three 1 one +3 three +4 four set @arg00=1 ; select a,b FROM t1 where a is not NULL AND b is not NULL order by a - @arg00 ; @@ -440,11 +440,11 @@ set @arg00=0 ; execute stmt1 using @arg00; ERROR 42S22: Unknown column '?' in 'order clause' set @arg00=1; -prepare stmt1 from ' select a,b from t1 +prepare stmt1 from ' select a,b from t1 order by a limit 1 '; execute stmt1 ; a b -2 two +1 one prepare stmt1 from ' select a,b from t1 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 @@ -471,21 +471,21 @@ test_sequence ------ join tests ------ select first.a as a1, second.a as a2 from t1 first, t1 second -where first.a = second.a ; +where first.a = second.a order by a1 ; a1 a2 -2 2 -4 4 -3 3 1 1 +2 2 +3 3 +4 4 prepare stmt1 from ' select first.a as a1, second.a as a2 from t1 first, t1 second - where first.a = second.a '; + where first.a = second.a order by a1 '; execute stmt1 ; a1 a2 -2 2 -4 4 -3 3 1 1 +2 2 +3 3 +4 4 set @arg00='ABC'; set @arg01='two'; set @arg02='one'; @@ -518,204 +518,204 @@ a ? a 4 ABC 4 drop table if exists t2 ; create table t2 as select * from t1 ; -set @query1= 'SELECT * FROM t2 join t1 on (t1.a=t2.a) ' ; -set @query2= 'SELECT * FROM t2 natural join t1 ' ; -set @query3= 'SELECT * FROM t2 join t1 using(a) ' ; -set @query4= 'SELECT * FROM t2 left join t1 on(t1.a=t2.a) ' ; -set @query5= 'SELECT * FROM t2 natural left join t1 ' ; -set @query6= 'SELECT * FROM t2 left join t1 using(a) ' ; -set @query7= 'SELECT * FROM t2 right join t1 on(t1.a=t2.a) ' ; -set @query8= 'SELECT * FROM t2 natural right join t1 ' ; -set @query9= 'SELECT * FROM t2 right join t1 using(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 order by t2.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) order by t2.a ' ; +set @query5= 'SELECT * FROM t2 natural left join t1 order by t2.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) order by t2.a ' ; +set @query8= 'SELECT * FROM t2 natural right join t1 order by t2.a ' ; +set @query9= 'SELECT * FROM t2 right join t1 using(a) order by t2.a ' ; 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 ; execute stmt1 ; a b a b -2 two 2 two -4 four 4 four -3 three 3 three 1 one 1 one +2 two 2 two +3 three 3 three +4 four 4 four execute stmt1 ; a b a b -2 two 2 two -4 four 4 four -3 three 3 three 1 one 1 one +2 two 2 two +3 three 3 three +4 four 4 four execute stmt1 ; a b a b -2 two 2 two -4 four 4 four -3 three 3 three 1 one 1 one +2 two 2 two +3 three 3 three +4 four 4 four 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 ; execute stmt1 ; a b a b -2 two 2 two -4 four 4 four -3 three 3 three 1 one 1 one +2 two 2 two +3 three 3 three +4 four 4 four execute stmt1 ; a b a b -2 two 2 two -4 four 4 four -3 three 3 three 1 one 1 one +2 two 2 two +3 three 3 three +4 four 4 four execute stmt1 ; a b a b -2 two 2 two -4 four 4 four -3 three 3 three 1 one 1 one +2 two 2 two +3 three 3 three +4 four 4 four 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 ; execute stmt1 ; a b a b -2 two 2 two -4 four 4 four -3 three 3 three 1 one 1 one +2 two 2 two +3 three 3 three +4 four 4 four execute stmt1 ; a b a b -2 two 2 two -4 four 4 four -3 three 3 three 1 one 1 one +2 two 2 two +3 three 3 three +4 four 4 four execute stmt1 ; a b a b -2 two 2 two -4 four 4 four -3 three 3 three 1 one 1 one +2 two 2 two +3 three 3 three +4 four 4 four 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 ; execute stmt1 ; a b a b -2 two 2 two -4 four 4 four -3 three 3 three 1 one 1 one +2 two 2 two +3 three 3 three +4 four 4 four execute stmt1 ; a b a b -2 two 2 two -4 four 4 four -3 three 3 three 1 one 1 one +2 two 2 two +3 three 3 three +4 four 4 four execute stmt1 ; a b a b -2 two 2 two -4 four 4 four -3 three 3 three 1 one 1 one +2 two 2 two +3 three 3 three +4 four 4 four 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 ; execute stmt1 ; a b a b -2 two 2 two -4 four 4 four -3 three 3 three 1 one 1 one +2 two 2 two +3 three 3 three +4 four 4 four execute stmt1 ; a b a b -2 two 2 two -4 four 4 four -3 three 3 three 1 one 1 one +2 two 2 two +3 three 3 three +4 four 4 four execute stmt1 ; a b a b -2 two 2 two -4 four 4 four -3 three 3 three 1 one 1 one +2 two 2 two +3 three 3 three +4 four 4 four 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 ; execute stmt1 ; a b a b -2 two 2 two -4 four 4 four -3 three 3 three 1 one 1 one +2 two 2 two +3 three 3 three +4 four 4 four execute stmt1 ; a b a b -2 two 2 two -4 four 4 four -3 three 3 three 1 one 1 one +2 two 2 two +3 three 3 three +4 four 4 four execute stmt1 ; a b a b -2 two 2 two -4 four 4 four -3 three 3 three 1 one 1 one +2 two 2 two +3 three 3 three +4 four 4 four 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 ; execute stmt1 ; a b a b -2 two 2 two -4 four 4 four -3 three 3 three 1 one 1 one +2 two 2 two +3 three 3 three +4 four 4 four execute stmt1 ; a b a b -2 two 2 two -4 four 4 four -3 three 3 three 1 one 1 one +2 two 2 two +3 three 3 three +4 four 4 four execute stmt1 ; a b a b -2 two 2 two -4 four 4 four -3 three 3 three 1 one 1 one +2 two 2 two +3 three 3 three +4 four 4 four the join statement is: -SELECT * FROM t2 natural join t1 +SELECT * FROM t2 natural join t1 order by t2.a prepare stmt1 from @query2 ; execute stmt1 ; a b -2 two -4 four -3 three 1 one +2 two +3 three +4 four execute stmt1 ; a b -2 two -4 four -3 three 1 one +2 two +3 three +4 four execute stmt1 ; a b -2 two -4 four -3 three 1 one +2 two +3 three +4 four 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 ; execute stmt1 ; a b a b -2 two 2 two -4 four 4 four -3 three 3 three 1 one 1 one +2 two 2 two +3 three 3 three +4 four 4 four execute stmt1 ; a b a b -2 two 2 two -4 four 4 four -3 three 3 three 1 one 1 one +2 two 2 two +3 three 3 three +4 four 4 four execute stmt1 ; a b a b -2 two 2 two -4 four 4 four -3 three 3 three 1 one 1 one +2 two 2 two +3 three 3 three +4 four 4 four drop table t2 ; test_sequence ------ subquery tests ------ @@ -770,13 +770,13 @@ execute stmt1 using @arg00, @arg01, @arg02, @arg03 ; a ? b 2 1 two 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 ; a b -2 two -4 four -3 three 1 one +2 two +3 three +4 four 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) '; execute stmt1 ; @@ -1188,7 +1188,7 @@ c29= 'longblob', c30= 'longtext', c31='two', c32= 'tuesday'; commit ; prepare stmt1 from 'delete from t1 where a=2' ; execute stmt1; -select a,b from t1 where a=2; +select a,b from t1 where a=2 order by b; a b execute stmt1; insert into t1 values(0,NULL); @@ -1474,7 +1474,7 @@ set @arg02=82 ; set @arg03='8-2' ; prepare stmt1 from 'insert into t1 values(?,?),(?,?)'; 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 81 8-1 82 8-2 diff --git a/mysql-test/t/ndb_subquery.test b/mysql-test/t/ndb_subquery.test index e80d9b16b46..cebc1920eaa 100644 --- a/mysql-test/t/ndb_subquery.test +++ b/mysql-test/t/ndb_subquery.test @@ -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 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 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 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 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 t2; diff --git a/mysql-test/t/ps_7ndb.test b/mysql-test/t/ps_7ndb.test index 848eac0080a..30e45f44a0e 100644 --- a/mysql-test/t/ps_7ndb.test +++ b/mysql-test/t/ps_7ndb.test @@ -55,7 +55,7 @@ select '------ delete tests ------' as test_sequence ; ## delete without parameter prepare stmt1 from 'delete from t1 where a=2' ; 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 execute stmt1; @@ -270,7 +270,7 @@ set @arg02=82 ; set @arg03='8-2' ; prepare stmt1 from 'insert into t1 values(?,?),(?,?)'; 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 set @arg00=9 ; diff --git a/sql/examples/ha_archive.cc b/sql/examples/ha_archive.cc index 55b6455f7ad..c7d08772109 100644 --- a/sql/examples/ha_archive.cc +++ b/sql/examples/ha_archive.cc @@ -42,7 +42,18 @@ handle bulk inserts as well (that is if someone was trying to read at 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 good numbers but locally it has out performed both Innodb and MyISAM. For @@ -71,14 +82,35 @@ Add truncate table command. Implement versioning, should be easy. 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 without switching to a block method. 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 */ +/* + 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 */ pthread_mutex_t archive_mutex; @@ -86,8 +118,18 @@ static HASH archive_open_tables; static int archive_init= 0; /* The file extension */ -#define ARZ ".ARZ" -#define ARN ".ARN" +#define ARZ ".ARZ" // The data file +#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. @@ -99,14 +141,130 @@ static byte* archive_get_key(ARCHIVE_SHARE *share,uint *length, 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. - See ha_example.cc for a description. + This method writes out the header of a datafile and returns whether or not it was successful. */ -static ARCHIVE_SHARE *get_share(const char *table_name, TABLE *table) +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. +*/ +ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, TABLE *table) { ARCHIVE_SHARE *share; + char meta_file_name[FN_REFLEN]; uint length; char *tmp_name; @@ -143,33 +301,62 @@ static ARCHIVE_SHARE *get_share(const char *table_name, TABLE *table) return NULL; } - share->use_count=0; - share->table_name_length=length; - share->table_name=tmp_name; + share->use_count= 0; + share->table_name_length= length; + share->table_name= tmp_name; 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); + /* + 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 a gzip file that can be both read and written we keep a writer open that is shared amoung all open tables. */ if ((share->archive_write= gzopen(share->data_file_name, "ab")) == NULL) - goto error; + goto error2; if (my_hash_insert(&archive_open_tables, (byte*) share)) - goto error; + goto error2; thr_lock_init(&share->lock); if (pthread_mutex_init(&share->mutex,MY_MUTEX_INIT_FAST)) - goto error2; + goto error3; } share->use_count++; pthread_mutex_unlock(&archive_mutex); return share; -error2: +error3: + VOID(pthread_mutex_destroy(&share->mutex)); thr_lock_delete(&share->lock); /* We close, but ignore errors since we already have errors */ (void)gzclose(share->archive_write); +error2: + my_close(share->meta_file,MYF(0)); error: pthread_mutex_unlock(&archive_mutex); my_free((gptr) share, MYF(0)); @@ -179,10 +366,10 @@ error: /* - Free lock controls. + Free the share. 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; pthread_mutex_lock(&archive_mutex); @@ -190,7 +377,8 @@ static int free_share(ARCHIVE_SHARE *share) { hash_delete(&archive_open_tables, (byte*) share); 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) rc= 1; my_free((gptr) share, MYF(0)); @@ -205,7 +393,7 @@ static int free_share(ARCHIVE_SHARE *share) We just implement one additional file extension. */ 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 Create/get our shared structure. Init out lock. 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) { @@ -266,54 +453,63 @@ int ha_archive::close(void) /* - We create our data file here. The format is pretty simple. The first - bytes in any file are the version number. Currently we do nothing - with this, but in the future this gives us the ability to figure out - version if we change the format at all. After the version we - starting writing our rows. Unlike other storage engines we do not - "pack" our data. Since we are about to do a general compression, - 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 + We create our data file here. The format is pretty simple. + You can read about the format of the data file above. + Unlike other storage engines we do not "pack" our data. Since we + are about to do a general compression, 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. */ int ha_archive::create(const char *name, TABLE *table_arg, 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]; - size_t written; int error; 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, MY_REPLACE_EXT|MY_UNPACK_FILENAME),0, O_RDWR | O_TRUNC,MYF(MY_WME))) < 0) { error= my_errno; - goto err; + goto error; } if ((archive= gzdopen(create_file, "ab")) == NULL) { error= errno; delete_table(name); - goto err; + goto error; } - version= ARCHIVE_VERSION; - written= gzwrite(archive, &version, sizeof(version)); - if (gzclose(archive) || written != sizeof(version)) + if (write_data_header(archive)) { - error= errno; - delete_table(name); - goto err; + gzclose(archive); + goto error2; } + + if (gzclose(archive)) + goto error2; + DBUG_RETURN(0); -err: +error2: + error= errno; + delete_table(name); +error: /* Return error number, if we got one */ DBUG_RETURN(error ? error : -1); } @@ -334,25 +530,38 @@ int ha_archive::write_row(byte * buf) DBUG_ENTER("ha_archive::write_row"); statistic_increment(ha_write_count,&LOCK_status); - if (table->timestamp_default_now) - update_timestamp(buf+table->timestamp_default_now-1); + if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT) + table->timestamp_field->set_time(); + pthread_mutex_lock(&share->mutex); 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; 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++) { char *ptr; uint32 size= (*field)->get_length(); - (*field)->get_ptr(&ptr); - written= gzwrite(share->archive_write, ptr, (unsigned)size); - if (written != size) - DBUG_RETURN(errno ? errno : -1); + if (size) + { + (*field)->get_ptr(&ptr); + written= gzwrite(share->archive_write, ptr, (unsigned)size); + if (written != size) + goto error; + } } + share->rows_recorded++; + pthread_mutex_unlock(&share->mutex); DBUG_RETURN(0); +error: + pthread_mutex_unlock(&share->mutex); + DBUG_RETURN(errno ? errno : -1); } @@ -368,37 +577,28 @@ int ha_archive::rnd_init(bool scan) 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 */ - if(scan) - { - records= 0; - if (gzrewind(archive)) - DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE); - } - - /* - If dirty, we lock, and then reset/flush the data. - I found that just calling gzflush() doesn't always work. - */ - if (share->dirty == TRUE) - { - pthread_mutex_lock(&share->mutex); - if (share->dirty == TRUE) - { - gzflush(share->archive_write, Z_SYNC_FLUSH); - share->dirty= FALSE; - } - pthread_mutex_unlock(&share->mutex); - } - - /* - At the moment we just check the size of version to make sure the header is - intact. - */ if (scan) { - read= gzread(archive, &version, sizeof(version)); - if (read != sizeof(version)) - DBUG_RETURN(errno ? errno : -1); + scan_rows= share->rows_recorded; + records= 0; + + /* + If dirty, we lock, and then reset/flush the data. + I found that just calling gzflush() doesn't always work. + */ + if (share->dirty == TRUE) + { + pthread_mutex_lock(&share->mutex); + if (share->dirty == TRUE) + { + gzflush(share->archive_write, Z_SYNC_FLUSH); + share->dirty= FALSE; + } + pthread_mutex_unlock(&share->mutex); + } + + if (read_data_header(archive)) + DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE); } DBUG_RETURN(0); @@ -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 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 char *last; @@ -417,7 +617,11 @@ int ha_archive::get_row(byte *buf) Field_blob **field; 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 (read == 0) @@ -439,11 +643,14 @@ int ha_archive::get_row(byte *buf) for (field=table->blob_field; *field ; field++) { size_t size= (*field)->get_length(); - read= gzread(archive, last, size); - if ((size_t) read != size) - DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE); - (*field)->set_ptr(size, last); - last += size; + if (size) + { + read= gzread(file_to_read, last, size); + if ((size_t) read != size) + DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE); + (*field)->set_ptr(size, last); + last += size; + } } DBUG_RETURN(0); } @@ -459,9 +666,15 @@ int ha_archive::rnd_next(byte *buf) int rc; 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); current_position= gztell(archive); - rc= get_row(buf); + rc= get_row(archive, buf); + + if (rc != HA_ERR_END_OF_FILE) records++; @@ -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 needed. */ + void ha_archive::position(const byte *record) { DBUG_ENTER("ha_archive::position"); @@ -496,13 +710,70 @@ int ha_archive::rnd_pos(byte * buf, byte *pos) current_position= ha_get_ptr(pos, ref_length); 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 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) { DBUG_ENTER("ha_archive::optimize"); @@ -512,7 +783,8 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt) char writer_filename[FN_REFLEN]; /* 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 */ gzclose(share->archive_write); @@ -547,6 +819,57 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt) 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 @@ -616,8 +939,8 @@ void ha_archive::info(uint flag) DBUG_ENTER("ha_archive::info"); /* This is a lie, but you don't want the optimizer to see zero or 1 */ - if (records < 2) - records= 2; + records= share->rows_recorded; + deleted= 0; DBUG_VOID_RETURN; } @@ -634,23 +957,6 @@ int ha_archive::reset(void) 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, key_range *max_key) { diff --git a/sql/examples/ha_archive.h b/sql/examples/ha_archive.h index cf7becc5bc0..b619de5f6c1 100644 --- a/sql/examples/ha_archive.h +++ b/sql/examples/ha_archive.h @@ -32,8 +32,10 @@ typedef struct st_archive_share { uint table_name_length,use_count; pthread_mutex_t mutex; THR_LOCK lock; + File meta_file; /* Meta file we use */ gzFile archive_write; /* Archive file we are working with */ bool dirty; /* Flag for if a flush should occur */ + ulonglong rows_recorded; /* Number of rows in tables */ } ARCHIVE_SHARE; /* @@ -50,7 +52,7 @@ class ha_archive: public handler z_off_t current_position; /* The position of the row we just read */ byte byte_buffer[IO_SIZE]; /* Initial buffer for our string */ String buffer; /* Buffer used for blob storage */ - unsigned int version; /* Used for recording version */ + ulonglong scan_rows; /* Number of rows left in scan */ public: ha_archive(TABLE *table): handler(table) @@ -104,7 +106,14 @@ public: int rnd_init(bool scan=1); int rnd_next(byte *buf); 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 info(uint); int extra(enum ha_extra_function operation); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 5e40398574b..5242eca2521 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -963,7 +963,7 @@ void clean_up(bool print_message) if (print_message && errmesg) sql_print_information(ER(ER_SHUTDOWN_COMPLETE),my_progname); -#if !defined(__WIN__) && !defined(EMBEDDED_LIBRARY) +#if !defined(EMBEDDED_LIBRARY) if (!opt_bootstrap) (void) my_delete(pidfile_name,MYF(0)); // This may not always exist #endif @@ -1500,7 +1500,11 @@ static void init_signals(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) {} @@ -2934,10 +2938,10 @@ we force server id to 2, but this MySQL server will not act as a slave."); #ifndef __NETWARE__ (void) pthread_kill(signal_thread, MYSQL_KILL_SIGNAL); #endif /* __NETWARE__ */ -#ifndef __WIN__ + if (!opt_bootstrap) (void) my_delete(pidfile_name,MYF(MY_WME)); // Not needed anymore -#endif + if (unix_sock != INVALID_SOCKET) unlink(mysqld_unix_port); exit(1);