diff options
author | Michael Widenius <monty@askmonty.org> | 2011-01-10 23:22:40 +0200 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2011-01-10 23:22:40 +0200 |
commit | 505c663a1e19af4c8ee726b305691414ab5fc999 (patch) | |
tree | d85b2a5bbaaf9829612b2cbb8f34537bff8f9c1b /mysql-test | |
parent | c0fc6d42ace74938c0d39907ddf8acfbeb4d247e (diff) | |
download | mariadb-git-505c663a1e19af4c8ee726b305691414ab5fc999.tar.gz |
- Fixed that Aria works with HANDLER commands
- Added test case for Aria
- Tested HANDLER with HEAP (changes to HEAP code will be pushed in 5.3)
- Moved all HANDLER test to suite/handler.
mysql-test/Makefile.am:
Added suite/handler
mysql-test/mysql-test-run.pl:
Added suite/handler
mysql-test/r/lock_multi.result:
Remove test that is already in handler test suite
mysql-test/suite/handler/aria.result:
Test for HANDLER with Aria storage engine
mysql-test/suite/handler/aria.test:
Test for HANDLER with Aria storage engine
mysql-test/suite/handler/handler.inc:
Extended the general handler test
Moved interface testing to 'interface.test'
mysql-test/suite/handler/init.inc:
Common init for handler tests.
mysql-test/suite/handler/innodb.result:
New results
mysql-test/suite/handler/innodb.test:
Update to use new include files
mysql-test/suite/handler/interface.result:
Test of HANDLER interface (not storage engine dependent parts)
mysql-test/suite/handler/interface.test:
Test of HANDLER interface (not storage engine dependent parts)
mysql-test/suite/handler/myisam.result:
New results
mysql-test/suite/handler/myisam.test:
Update to use new include files
mysql-test/t/lock_multi.test:
Remove test that is already in handler test suite
mysys/tree.c:
Added missing handling of read previous (showed up in HEAP testing)
sql/handler.cc:
Don't marka 'HA_ERR_RECORD_CHANGED' as fatal (can be used with HANDLER READ, especially with MEMORY ENGINE)
sql/handler.h:
Added prototype for can_continue_handler_scan()
sql/sql_handler.cc:
Re-initialize search if we switch from key to table search.
Check if handler can continue searching between calls (via can_continue_handler_scan())
Don't write common not fatal errors to log
storage/maria/ma_extra.c:
Don't set index 0 as default. This forces call to ma_check_index() to set up index variables.
storage/maria/ma_ft_boolean_search.c:
Ensure that info->last_key.keyinfo is set
storage/maria/ma_open.c:
Don't set index 0 as default. This forces call to ma_check_index() to set up index variables.
storage/maria/ma_rkey.c:
Trivial optimization
storage/maria/ma_rnext.c:
Added missing code from mi_rnext.c to ensure that handler next/prev works.
storage/maria/ma_rsame.c:
Simple optimizations
storage/maria/ma_search.c:
Initialize info->last_key once and for all when we change keys.
storage/maria/ma_unique.c:
Ensure that info->last_key.keyinfo is up to date.
Diffstat (limited to 'mysql-test')
-rw-r--r-- | mysql-test/Makefile.am | 2 | ||||
-rwxr-xr-x | mysql-test/mysql-test-run.pl | 2 | ||||
-rw-r--r-- | mysql-test/r/lock_multi.result | 7 | ||||
-rw-r--r-- | mysql-test/suite/handler/aria.result | 671 | ||||
-rw-r--r-- | mysql-test/suite/handler/aria.test | 82 | ||||
-rw-r--r-- | mysql-test/suite/handler/handler.inc (renamed from mysql-test/include/handler.inc) | 382 | ||||
-rw-r--r-- | mysql-test/suite/handler/init.inc | 33 | ||||
-rw-r--r-- | mysql-test/suite/handler/innodb.result (renamed from mysql-test/r/handler_innodb.result) | 371 | ||||
-rw-r--r-- | mysql-test/suite/handler/innodb.test (renamed from mysql-test/t/handler_innodb.test) | 11 | ||||
-rw-r--r-- | mysql-test/suite/handler/interface.result | 259 | ||||
-rw-r--r-- | mysql-test/suite/handler/interface.test | 307 | ||||
-rw-r--r-- | mysql-test/suite/handler/myisam.result (renamed from mysql-test/r/handler_myisam.result) | 390 | ||||
-rw-r--r-- | mysql-test/suite/handler/myisam.test (renamed from mysql-test/t/handler_myisam.test) | 24 | ||||
-rw-r--r-- | mysql-test/t/lock_multi.test | 16 |
14 files changed, 1611 insertions, 946 deletions
diff --git a/mysql-test/Makefile.am b/mysql-test/Makefile.am index f8b3721f600..f90c73d1e92 100644 --- a/mysql-test/Makefile.am +++ b/mysql-test/Makefile.am @@ -106,7 +106,7 @@ TEST_DIRS = t r include std_data std_data/parts collections \ suite/innodb suite/innodb/t suite/innodb/r suite/innodb/include \ suite/innodb_plugin suite/innodb_plugin/t suite/innodb_plugin/r \ suite/innodb_plugin/include \ - suite/percona \ + suite/percona suite/handler \ suite/engines suite/engines/funcs suite/engines/iuds suite/engines/rr_trx \ suite/engines/funcs/r suite/engines/funcs/t suite/engines/iuds/r \ suite/engines/iuds/t suite/engines/rr_trx/include suite/engines/rr_trx/r \ diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 4a652580d97..8a709df54c3 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -142,7 +142,7 @@ my $path_config_file; # The generated config file, var/my.cnf # executables will be used by the test suite. our $opt_vs_config = $ENV{'MTR_VS_CONFIG'}; -my $DEFAULT_SUITES= "main,binlog,federated,rpl,maria,parts,innodb,innodb_plugin,percona,ndb"; +my $DEFAULT_SUITES= "main,binlog,federated,rpl,maria,handler,parts,innodb,innodb_plugin,percona,ndb"; my $opt_suites; our $opt_verbose= 0; # Verbose output, enable with --verbose diff --git a/mysql-test/r/lock_multi.result b/mysql-test/r/lock_multi.result index d8768e802ea..3fc4de3da06 100644 --- a/mysql-test/r/lock_multi.result +++ b/mysql-test/r/lock_multi.result @@ -162,13 +162,6 @@ ERROR 70100: Query execution was interrupted unlock tables; drop table t1; drop table if exists t1; -create table t1 (a int) ENGINE=MEMORY; ---> client 2 -handler t1 open; -ERROR HY000: Table storage engine for 't1' doesn't have this option ---> client 1 -drop table t1; -drop table if exists t1; create table t1 (i int); connection: default lock tables t1 write; diff --git a/mysql-test/suite/handler/aria.result b/mysql-test/suite/handler/aria.result new file mode 100644 index 00000000000..a912a2559e3 --- /dev/null +++ b/mysql-test/suite/handler/aria.result @@ -0,0 +1,671 @@ +SET SESSION STORAGE_ENGINE = Aria; +drop table if exists t1,t3,t4,t5; +create table t1 (a int, b char(10), key a (a), key b (a,b)); +insert into t1 values +(17,"ddd"),(18,"eee"),(19,"fff"),(19,"yyy"), +(14,"aaa"),(16,"ccc"),(16,"xxx"), +(20,"ggg"),(21,"hhh"),(22,"iii"); +handler t1 open as t2; +handler t2 read a first; +a b +14 aaa +handler t2 read a next; +a b +16 ccc +handler t2 read a next; +a b +16 xxx +handler t2 read a prev; +a b +16 ccc +handler t2 read a last; +a b +22 iii +handler t2 read a prev; +a b +21 hhh +handler t2 read a prev; +a b +20 ggg +handler t2 read a first; +a b +14 aaa +handler t2 read a prev; +a b +handler t2 read a last; +a b +22 iii +handler t2 read a prev; +a b +21 hhh +handler t2 read a next; +a b +22 iii +handler t2 read a next; +a b +handler t2 read a=(15); +a b +handler t2 read a=(16); +a b +16 ccc +handler t2 read a=(19,"fff"); +ERROR 42000: Too many key parts specified; max 1 parts allowed +handler t2 read b=(19,"fff"); +a b +19 fff +handler t2 read b=(19,"yyy"); +a b +19 yyy +handler t2 read b=(19); +a b +19 fff +handler t1 read a last; +ERROR 42S02: Unknown table 't1' in HANDLER +handler t2 read a=(11); +a b +handler t2 read a>=(11); +a b +14 aaa +handler t2 read a=(18); +a b +18 eee +handler t2 read a>=(18); +a b +18 eee +handler t2 read a>(18); +a b +19 fff +handler t2 read a<=(18); +a b +18 eee +handler t2 read a<(18); +a b +17 ddd +handler t2 read a=(15); +a b +handler t2 read a>=(15); +a b +16 ccc +handler t2 read a>(15); +a b +16 ccc +handler t2 read a<=(15); +a b +14 aaa +handler t2 read a<(15); +a b +14 aaa +handler t2 read a=(54); +a b +handler t2 read a>=(54); +a b +handler t2 read a>(54); +a b +handler t2 read a<=(54); +a b +22 iii +handler t2 read a<(54); +a b +22 iii +handler t2 read a=(1); +a b +handler t2 read a>=(1); +a b +14 aaa +handler t2 read a>(1); +a b +14 aaa +handler t2 read a<=(1); +a b +handler t2 read a<(1); +a b +handler t2 read a first limit 5; +a b +14 aaa +16 ccc +16 xxx +17 ddd +18 eee +handler t2 read a next limit 3; +a b +19 fff +19 yyy +20 ggg +handler t2 read a prev limit 10; +a b +19 yyy +19 fff +18 eee +17 ddd +16 xxx +16 ccc +14 aaa +handler t2 read a>=(16) limit 4; +a b +16 ccc +16 xxx +17 ddd +18 eee +handler t2 read a>=(16) limit 2,2; +a b +17 ddd +18 eee +handler t2 read a last limit 3; +a b +22 iii +21 hhh +20 ggg +handler t2 read a=(19); +a b +19 fff +handler t2 read a=(19) where b="yyy"; +a b +19 yyy +handler t2 read first; +a b +17 ddd +handler t2 read next; +a b +18 eee +handler t2 read next; +a b +19 fff +handler t2 close; +handler t1 open; +handler t1 read a next; +a b +14 aaa +handler t1 read a next; +a b +16 ccc +handler t1 close; +handler t1 open; +handler t1 read a prev; +a b +22 iii +handler t1 read a prev; +a b +21 hhh +handler t1 close; +handler t1 open as t2; +handler t2 read first; +a b +17 ddd +alter table t1 engine = Aria; +handler t2 read first; +ERROR 42S02: Unknown table 't2' in HANDLER +handler t1 open as t2; +drop table t1; +create table t1 (a int not null); +insert into t1 values (17); +handler t2 read first; +ERROR 42S02: Unknown table 't2' in HANDLER +handler t1 open as t2; +alter table t1 engine=CSV; +handler t2 read first; +ERROR 42S02: Unknown table 't2' in HANDLER +drop table t1; +create table t1 (a int); +insert into t1 values (1),(2),(3),(4),(5),(6); +delete from t1 limit 2; +handler t1 open; +handler t1 read first; +a +3 +handler t1 read first limit 1,1; +a +4 +handler t1 read first limit 2,2; +a +5 +6 +delete from t1 limit 3; +handler t1 read first; +a +6 +drop table t1; +create table t1(a int, index (a)); +insert into t1 values (1), (2), (3); +handler t1 open; +handler t1 read a=(W); +ERROR 42S22: Unknown column 'W' in 'field list' +handler t1 read a=(a); +ERROR HY000: Incorrect arguments to HANDLER ... READ +drop table t1; +create table t1 (a char(5)); +insert into t1 values ("Ok"); +handler t1 open as t; +handler t read first; +a +Ok +use mysql; +handler t read first; +a +Ok +handler t close; +handler test.t1 open as t; +handler t read first; +a +Ok +handler t close; +use test; +drop table t1; +create table t1 ( a int, b int, INDEX a (a) ); +insert into t1 values (1,2), (2,1); +handler t1 open; +handler t1 read a=(1) where b=2; +a b +1 2 +handler t1 read a=(1) where b=3; +a b +handler t1 read a=(1) where b=1; +a b +handler t1 close; +drop table t1; +create table t1 (c1 char(20)); +insert into t1 values ("t1"); +handler t1 open as h1; +handler h1 read first limit 9; +c1 +t1 +create table t2 (c1 char(20)); +insert into t2 values ("t2"); +handler t2 open as h2; +handler h2 read first limit 9; +c1 +t2 +create table t3 (c1 char(20)); +insert into t3 values ("t3"); +handler t3 open as h3; +handler h3 read first limit 9; +c1 +t3 +create table t4 (c1 char(20)); +insert into t4 values ("t4"); +handler t4 open as h4; +handler h4 read first limit 9; +c1 +t4 +create table t5 (c1 char(20)); +insert into t5 values ("t5"); +handler t5 open as h5; +handler h5 read first limit 9; +c1 +t5 +alter table t1 engine=MyISAM; +handler h1 read first limit 9; +ERROR 42S02: Unknown table 'h1' in HANDLER +handler h2 read first limit 9; +c1 +t2 +handler h3 read first limit 9; +c1 +t3 +handler h4 read first limit 9; +c1 +t4 +handler h5 read first limit 9; +c1 +t5 +alter table t5 engine=MyISAM; +handler h1 read first limit 9; +ERROR 42S02: Unknown table 'h1' in HANDLER +handler h2 read first limit 9; +c1 +t2 +handler h3 read first limit 9; +c1 +t3 +handler h4 read first limit 9; +c1 +t4 +handler h5 read first limit 9; +ERROR 42S02: Unknown table 'h5' in HANDLER +alter table t3 engine=MyISAM; +handler h1 read first limit 9; +ERROR 42S02: Unknown table 'h1' in HANDLER +handler h2 read first limit 9; +c1 +t2 +handler h3 read first limit 9; +ERROR 42S02: Unknown table 'h3' in HANDLER +handler h4 read first limit 9; +c1 +t4 +handler h5 read first limit 9; +ERROR 42S02: Unknown table 'h5' in HANDLER +handler h2 close; +handler h4 close; +handler t1 open as h1_1; +handler t1 open as h1_2; +handler t1 open as h1_3; +handler h1_1 read first limit 9; +c1 +t1 +handler h1_2 read first limit 9; +c1 +t1 +handler h1_3 read first limit 9; +c1 +t1 +alter table t1 engine=Aria; +handler h1_1 read first limit 9; +ERROR 42S02: Unknown table 'h1_1' in HANDLER +handler h1_2 read first limit 9; +ERROR 42S02: Unknown table 'h1_2' in HANDLER +handler h1_3 read first limit 9; +ERROR 42S02: Unknown table 'h1_3' in HANDLER +drop table t1; +drop table t2; +drop table t3; +drop table t4; +drop table t5; +create table t1 (c1 int); +insert into t1 values (1); +handler t1 open; +handler t1 read first; +c1 +1 +send the below to another connection, do not wait for the result +optimize table t1; +proceed with the normal connection +handler t1 read next; +c1 +1 +handler t1 close; +read the result from the other connection +Table Op Msg_type Msg_text +test.t1 optimize status OK +proceed with the normal connection +drop table t1; +CREATE TABLE t1 ( no1 smallint(5) NOT NULL default '0', no2 int(10) NOT NULL default '0', PRIMARY KEY (no1,no2)); +INSERT INTO t1 VALUES (1,274),(1,275),(2,6),(2,8),(4,1),(4,2); +HANDLER t1 OPEN; +HANDLER t1 READ `primary` = (1, 1000); +no1 no2 +HANDLER t1 READ `primary` PREV; +no1 no2 +1 275 +HANDLER t1 READ `primary` = (1, 1000); +no1 no2 +HANDLER t1 READ `primary` NEXT; +no1 no2 +2 6 +DROP TABLE t1; +create table t1 (c1 int); +insert into t1 values (14397); +flush tables with read lock; +drop table t1; +ERROR HY000: Can't execute the query because you have a conflicting read lock +send the below to another connection, do not wait for the result +drop table t1; +proceed with the normal connection +select * from t1; +c1 +14397 +unlock tables; +read the result from the other connection +proceed with the normal connection +select * from t1; +ERROR 42S02: Table 'test.t1' doesn't exist +drop table if exists t1; +Warnings: +Note 1051 Unknown table 't1' +create table t1 (a int not null) ENGINE=CSV; +--> client 2 +handler t1 open; +ERROR HY000: Table storage engine for 't1' doesn't have this option +--> client 1 +drop table t1; +create table t1 (a int); +handler t1 open as t1_alias; +handler t1_alias read a next; +ERROR 42000: Key 'a' doesn't exist in table 't1_alias' +handler t1_alias READ a next where inexistent > 0; +ERROR 42S22: Unknown column 'inexistent' in 'field list' +handler t1_alias read a next; +ERROR 42000: Key 'a' doesn't exist in table 't1_alias' +handler t1_alias READ a next where inexistent > 0; +ERROR 42S22: Unknown column 'inexistent' in 'field list' +handler t1_alias close; +drop table t1; +create temporary table t1 (a int, b char(1), key a (a), key b(a,b)); +insert into t1 values (0,"a"),(1,"b"),(2,"c"),(3,"d"),(4,"e"), +(5,"f"),(6,"g"),(7,"h"),(8,"i"),(9,"j"),(9,'k'); +select a,b from t1; +a b +0 a +1 b +2 c +3 d +4 e +5 f +6 g +7 h +8 i +9 j +9 k +handler t1 open as a1; +handler a1 read a=(1); +a b +1 b +handler a1 read a next; +a b +2 c +handler a1 read a next; +a b +3 d +select a,b from t1; +ERROR HY000: Can't reopen table: 'a1' +handler a1 read a prev; +a b +2 c +handler a1 read a prev; +a b +1 b +handler a1 read a=(6) where b="g"; +a b +6 g +handler a1 close; +select a,b from t1; +a b +0 a +1 b +2 c +3 d +4 e +5 f +6 g +7 h +8 i +9 j +9 k +handler t1 open as a2; +handler a2 read a=(9); +a b +9 j +handler a2 read a next; +a b +9 k +handler a2 read a prev limit 2; +a b +9 j +8 i +handler a2 read a last; +a b +9 k +handler a2 read a prev; +a b +9 j +handler a2 close; +drop table t1; +create table t1 (a int); +create temporary table t2 (a int, key (a)); +handler t1 open as a1; +handler t2 open as a2; +handler a2 read a first; +a +drop table t1, t2; +handler a2 read a next; +ERROR 42S02: Unknown table 'a2' in HANDLER +handler a1 close; +ERROR 42S02: Unknown table 'a1' in HANDLER +create table t1 (a int, key (a)); +create table t2 like t1; +handler t1 open as a1; +handler t2 open as a2; +handler a1 read a first; +a +handler a2 read a first; +a +alter table t1 add b int; +handler a1 close; +ERROR 42S02: Unknown table 'a1' in HANDLER +handler a2 close; +drop table t1, t2; +create table t1 (a int, key (a)); +handler t1 open as a1; +handler a1 read a first; +a +rename table t1 to t2; +handler a1 read a first; +ERROR 42S02: Unknown table 'a1' in HANDLER +drop table t2; +create table t1 (a int, key (a)); +create table t2 like t1; +handler t1 open as a1; +handler t2 open as a2; +handler a1 read a first; +a +handler a2 read a first; +a +optimize table t1; +Table Op Msg_type Msg_text +test.t1 optimize status Table is already up to date +handler a1 close; +ERROR 42S02: Unknown table 'a1' in HANDLER +handler a2 close; +drop table t1, t2; +# +# BUG#51877 - HANDLER interface causes invalid memory read +# +CREATE TABLE t1(a INT, KEY (a)); +HANDLER t1 OPEN; +HANDLER t1 READ a FIRST; +a +INSERT INTO t1 VALUES(1); +HANDLER t1 READ a NEXT; +a +1 +HANDLER t1 CLOSE; +DROP TABLE t1; +# +# BUG #46456: HANDLER OPEN + TRUNCATE + DROP (temporary) TABLE, crash +# +CREATE TABLE t1 AS SELECT 1 AS f1; +HANDLER t1 OPEN; +TRUNCATE t1; +HANDLER t1 READ FIRST; +ERROR 42S02: Unknown table 't1' in HANDLER +DROP TABLE t1; +CREATE TEMPORARY TABLE t1 AS SELECT 1 AS f1; +HANDLER t1 OPEN; +TRUNCATE t1; +HANDLER t1 READ FIRST; +ERROR 42S02: Unknown table 't1' in HANDLER +DROP TABLE t1; +# +# Bug #54007: assert in ha_myisam::index_next , HANDLER +# +CREATE TABLE t1(a INT, b INT, PRIMARY KEY(a), KEY b(b), KEY ab(a, b)); +HANDLER t1 OPEN; +HANDLER t1 READ FIRST; +a b +HANDLER t1 READ `PRIMARY` NEXT; +a b +HANDLER t1 READ ab NEXT; +a b +HANDLER t1 READ b NEXT; +a b +HANDLER t1 READ NEXT; +a b +HANDLER t1 CLOSE; +INSERT INTO t1 VALUES (2, 20), (1, 10), (4, 40), (3, 30); +HANDLER t1 OPEN; +HANDLER t1 READ FIRST; +a b +2 20 +HANDLER t1 READ NEXT; +a b +1 10 +HANDLER t1 READ `PRIMARY` NEXT; +a b +1 10 +HANDLER t1 READ `PRIMARY` NEXT; +a b +2 20 +HANDLER t1 READ ab NEXT; +a b +1 10 +HANDLER t1 READ ab NEXT; +a b +2 20 +HANDLER t1 READ b NEXT; +a b +1 10 +HANDLER t1 READ b NEXT; +a b +2 20 +HANDLER t1 READ b NEXT; +a b +3 30 +HANDLER t1 READ b NEXT; +a b +4 40 +HANDLER t1 READ b NEXT; +a b +HANDLER t1 READ NEXT; +a b +2 20 +HANDLER t1 READ NEXT; +a b +1 10 +HANDLER t1 READ NEXT; +a b +4 40 +HANDLER t1 CLOSE; +HANDLER t1 OPEN; +HANDLER t1 READ FIRST; +a b +2 20 +HANDLER t1 READ `PRIMARY` PREV; +a b +4 40 +HANDLER t1 READ `PRIMARY` PREV; +a b +3 30 +HANDLER t1 READ b PREV; +a b +4 40 +HANDLER t1 READ b PREV; +a b +3 30 +HANDLER t1 CLOSE; +HANDLER t1 OPEN; +HANDLER t1 READ FIRST; +a b +2 20 +HANDLER t1 READ `PRIMARY` PREV LIMIT 3; +a b +4 40 +3 30 +2 20 +HANDLER t1 READ b NEXT LIMIT 5; +a b +1 10 +2 20 +3 30 +4 40 +HANDLER t1 CLOSE; +DROP TABLE t1; +End of 5.1 tests diff --git a/mysql-test/suite/handler/aria.test b/mysql-test/suite/handler/aria.test new file mode 100644 index 00000000000..1913d2b791c --- /dev/null +++ b/mysql-test/suite/handler/aria.test @@ -0,0 +1,82 @@ +# t/handler_innodb.test +# +# test of HANDLER ... +# +# Last update: +# 2006-07-31 ML test refactored (MySQL 5.1) +# code of t/handler.test and t/innodb_handler.test united +# main testing code put into handler.inc +# rename t/innodb_handler.test to t/handler_innodb.test +# + +--source include/have_maria.inc +let $engine_type= Aria; + +--source init.inc +--source handler.inc + +--echo # +--echo # BUG #46456: HANDLER OPEN + TRUNCATE + DROP (temporary) TABLE, crash +--echo # +CREATE TABLE t1 AS SELECT 1 AS f1; +HANDLER t1 OPEN; +TRUNCATE t1; +--error ER_UNKNOWN_TABLE +HANDLER t1 READ FIRST; +DROP TABLE t1; + +CREATE TEMPORARY TABLE t1 AS SELECT 1 AS f1; +HANDLER t1 OPEN; +TRUNCATE t1; +--error ER_UNKNOWN_TABLE +HANDLER t1 READ FIRST; +DROP TABLE t1; + +--echo # +--echo # Bug #54007: assert in ha_myisam::index_next , HANDLER +--echo # +CREATE TABLE t1(a INT, b INT, PRIMARY KEY(a), KEY b(b), KEY ab(a, b)); + +HANDLER t1 OPEN; +HANDLER t1 READ FIRST; +HANDLER t1 READ `PRIMARY` NEXT; +HANDLER t1 READ ab NEXT; +HANDLER t1 READ b NEXT; +HANDLER t1 READ NEXT; +HANDLER t1 CLOSE; + +INSERT INTO t1 VALUES (2, 20), (1, 10), (4, 40), (3, 30); +HANDLER t1 OPEN; +HANDLER t1 READ FIRST; +HANDLER t1 READ NEXT; +HANDLER t1 READ `PRIMARY` NEXT; +HANDLER t1 READ `PRIMARY` NEXT; +HANDLER t1 READ ab NEXT; +HANDLER t1 READ ab NEXT; +HANDLER t1 READ b NEXT; +HANDLER t1 READ b NEXT; +HANDLER t1 READ b NEXT; +HANDLER t1 READ b NEXT; +HANDLER t1 READ b NEXT; +HANDLER t1 READ NEXT; +HANDLER t1 READ NEXT; +HANDLER t1 READ NEXT; +HANDLER t1 CLOSE; + +HANDLER t1 OPEN; +HANDLER t1 READ FIRST; +HANDLER t1 READ `PRIMARY` PREV; +HANDLER t1 READ `PRIMARY` PREV; +HANDLER t1 READ b PREV; +HANDLER t1 READ b PREV; +HANDLER t1 CLOSE; + +HANDLER t1 OPEN; +HANDLER t1 READ FIRST; +HANDLER t1 READ `PRIMARY` PREV LIMIT 3; +HANDLER t1 READ b NEXT LIMIT 5; +HANDLER t1 CLOSE; + +DROP TABLE t1; + +--echo End of 5.1 tests diff --git a/mysql-test/include/handler.inc b/mysql-test/suite/handler/handler.inc index 6e7f53ba9b2..48ed2ce0b8a 100644 --- a/mysql-test/include/handler.inc +++ b/mysql-test/suite/handler/handler.inc @@ -1,5 +1,7 @@ -# include/handler.inc +# handler.inc # +# See init.inc for setup of variables for this script +# # The variables # $engine_type -- storage engine to be tested # $other_engine_type -- storage engine <> $engine_type @@ -8,31 +10,19 @@ # 2. $other_handler_engine_type must point to an all # time available storage engine # 2006-08 MySQL 5.1 MyISAM and MEMORY only -# have to be set before sourcing this script. --- source include/not_embedded.inc # # test of HANDLER ... # # Last update: # 2006-07-31 ML test refactored (MySQL 5.1) # code of t/handler.test and t/innodb_handler.test united -# main testing code put into include/handler.inc +# main testing code put into handler.inc # -eval SET SESSION STORAGE_ENGINE = $engine_type; - ---disable_warnings -drop table if exists t1,t3,t4,t5; ---enable_warnings - -create table t1 (a int, b char(10), key a(a), key b(a,b)); -insert into t1 values -(17,"ddd"),(18,"eee"),(19,"fff"),(19,"yyy"), -(14,"aaa"),(15,"bbb"),(16,"ccc"),(16,"xxx"), -(20,"ggg"),(21,"hhh"),(22,"iii"); +# +# Start testing the table created in init.inc +# handler t1 open as t2; --- error 1064 -handler t2 read a=(SELECT 1); handler t2 read a first; handler t2 read a next; handler t2 read a next; @@ -65,12 +55,34 @@ handler t1 read a last; handler t2 read a=(11); handler t2 read a>=(11); +# Search on something we ca nfind handler t2 read a=(18); handler t2 read a>=(18); handler t2 read a>(18); handler t2 read a<=(18); handler t2 read a<(18); +# Search on something we can't find +handler t2 read a=(15); +handler t2 read a>=(15); +handler t2 read a>(15); +handler t2 read a<=(15); +handler t2 read a<(15); + +# Search from upper end +handler t2 read a=(54); +handler t2 read a>=(54); +handler t2 read a>(54); +handler t2 read a<=(54); +handler t2 read a<(54); + +# Search from lower end +handler t2 read a=(1); +handler t2 read a>=(1); +handler t2 read a>(1); +handler t2 read a<=(1); +handler t2 read a<(1); + handler t2 read a first limit 5; handler t2 read a next limit 3; handler t2 read a prev limit 10; @@ -85,8 +97,6 @@ handler t2 read a=(19) where b="yyy"; handler t2 read first; handler t2 read next; handler t2 read next; ---error 1064 -handler t2 read last; handler t2 close; handler t1 open; @@ -110,7 +120,7 @@ handler t2 read first; # handler t1 open as t2; drop table t1; -create table t1 (a int); +create table t1 (a int not null); insert into t1 values (17); --error 1109 handler t2 read first; @@ -137,7 +147,7 @@ drop table t1; # # Test for #751 # -create table t1(a int, index(a)); +eval create table t1(a int, index $key_type (a)); insert into t1 values (1), (2), (3); handler t1 open; --error 1054 @@ -164,7 +174,7 @@ drop table t1; # # BUG#3649 # -create table t1 ( a int, b int, INDEX a (a) ); +eval create table t1 ( a int, b int, INDEX a $key_type (a) ); insert into t1 values (1,2), (2,1); handler t1 open; handler t1 read a=(1) where b=2; @@ -174,143 +184,6 @@ handler t1 close; drop table t1; # -# Check if two database names beginning the same are seen as different. -# -# This database begins like the usual 'test' database. -# ---disable_warnings -drop database if exists test_test; ---enable_warnings -create database test_test; -use test_test; -create table t1(table_id char(20) primary key); -insert into t1 values ('test_test.t1'); -insert into t1 values (''); -handler t1 open; -handler t1 read first limit 9; -create table t2(table_id char(20) primary key); -insert into t2 values ('test_test.t2'); -insert into t2 values (''); -handler t2 open; -handler t2 read first limit 9; -# -# This is the usual 'test' database. -# -use test; ---disable_warnings -drop table if exists t1; ---enable_warnings -create table t1(table_id char(20) primary key); -insert into t1 values ('test.t1'); -insert into t1 values (''); ---error 1066 -handler t1 open; -# -# Check accesibility of all the tables. -# -use test; ---error 1064 -handler test.t1 read first limit 9; ---error 1064 -handler test_test.t1 read first limit 9; -handler t1 read first limit 9; ---error 1064 -handler test_test.t2 read first limit 9; -handler t2 read first limit 9; - -# -# Cleanup. -# - ---error 1064 -handler test_test.t1 close; -handler t1 close; -drop table test_test.t1; ---error 1064 -handler test_test.t2 close; -handler t2 close; -drop table test_test.t2; -drop database test_test; - -# -use test; ---error 1064 -handler test.t1 close; ---error 1109 -handler t1 close; -drop table test.t1; - -# -# BUG#4335 -# ---disable_warnings -drop database if exists test_test; -drop table if exists t1; -drop table if exists t2; -drop table if exists t3; ---enable_warnings -create database test_test; -use test_test; -create table t1 (c1 char(20)); -insert into t1 values ('test_test.t1'); -create table t3 (c1 char(20)); -insert into t3 values ('test_test.t3'); -handler t1 open; -handler t1 read first limit 9; -handler t1 open h1; -handler h1 read first limit 9; -use test; -create table t1 (c1 char(20)); -create table t2 (c1 char(20)); -create table t3 (c1 char(20)); -insert into t1 values ('t1'); -insert into t2 values ('t2'); -insert into t3 values ('t3'); ---error 1066 -handler t1 open; ---error 1066 -handler t2 open t1; ---error 1066 -handler t3 open t1; -handler t1 read first limit 9; ---error 1064 -handler test.t1 close; ---error 1066 -handler test.t1 open h1; ---error 1066 -handler test_test.t1 open h1; -handler test_test.t3 open h3; -handler test.t1 open h2; -handler t1 read first limit 9; -handler h1 read first limit 9; -handler h2 read first limit 9; -handler h3 read first limit 9; -handler h2 read first limit 9; ---error 1064 -handler test.h1 close; -handler t1 close; -handler h1 close; -handler h2 close; ---error 1109 -handler t1 read first limit 9; ---error 1109 -handler h1 read first limit 9; ---error 1109 -handler h2 read first limit 9; -handler h3 read first limit 9; -handler h3 read first limit 9; -use test_test; -handler h3 read first limit 9; ---error 1064 -handler test.h3 read first limit 9; -handler h3 close; -use test; -drop table t3; -drop table t2; -drop table t1; -drop database test_test; - -# # Test if fix for BUG#4286 correctly closes handler tables. # create table t1 (c1 char(20)); @@ -410,11 +283,13 @@ reap; connection default; drop table t1; -CREATE TABLE t1 ( no1 smallint(5) NOT NULL default '0', no2 int(10) NOT NULL default '0', PRIMARY KEY (no1,no2)); +eval CREATE TABLE t1 ( no1 smallint(5) NOT NULL default '0', no2 int(10) NOT NULL default '0', PRIMARY KEY $key_type (no1,no2)); INSERT INTO t1 VALUES (1,274),(1,275),(2,6),(2,8),(4,1),(4,2); HANDLER t1 OPEN; HANDLER t1 READ `primary` = (1, 1000); HANDLER t1 READ `primary` PREV; +HANDLER t1 READ `primary` = (1, 1000); +HANDLER t1 READ `primary` NEXT; DROP TABLE t1; # End of 4.1 tests @@ -468,10 +343,7 @@ drop table if exists t1; # # Bug#25856 - HANDLER table OPEN in one connection lock DROP TABLE in another one # ---disable_warnings -drop table if exists t1; ---enable_warnings -eval create table t1 (a int) ENGINE=$other_engine_type; +eval create table t1 (a int not null) ENGINE=$other_engine_type; --echo --> client 2 connection con2; --error 1031 @@ -484,9 +356,6 @@ disconnect con2; # # Bug#30632 HANDLER read failure causes hang # ---disable_warnings -drop table if exists t1; ---enable_warnings create table t1 (a int); handler t1 open as t1_alias; --error 1176 @@ -501,89 +370,18 @@ handler t1_alias close; drop table t1; # -# Bug#21587 FLUSH TABLES causes server crash when used with HANDLER statements -# - ---disable_warnings -drop table if exists t1,t2; ---enable_warnings -create table t1 (c1 int); -create table t2 (c1 int); -insert into t1 values (1); -insert into t2 values (2); ---echo connection: default -handler t1 open; -handler t1 read first; -connect (flush,localhost,root,,); -connection flush; ---echo connection: flush ---send flush tables; -connection default; ---echo connection: default -let $wait_condition= - select count(*) = 1 from information_schema.processlist - where state = "Flushing tables"; ---source include/wait_condition.inc -handler t2 open; -handler t2 read first; -handler t1 read next; -handler t1 close; -handler t2 close; -connection flush; -reap; -connection default; -drop table t1,t2; -disconnect flush; - -# -# Bug#31409 RENAME TABLE causes server crash or deadlock when used with HANDLER statements -# - ---disable_warnings -drop table if exists t1,t2; ---enable_warnings -create table t1 (c1 int); ---echo connection: default -handler t1 open; -handler t1 read first; -connect (flush,localhost,root,,); -connection flush; ---echo connection: flush ---send rename table t1 to t2; -connection default; ---echo connection: default -let $wait_condition= - select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "rename table t1 to t2"; ---source include/wait_condition.inc -handler t2 open; -handler t2 read first; ---error ER_NO_SUCH_TABLE -handler t1 read next; -handler t1 close; -handler t2 close; -connection flush; -reap; -connection default; -drop table t2; -disconnect flush; - -# # Bug#30882 Dropping a temporary table inside a stored function may cause a server crash # # Test HANDLER statements in conjunction with temporary tables. While the temporary table # is open by a HANDLER, no other statement can access it. # ---disable_warnings -drop table if exists t1; ---enable_warnings -create temporary table t1 (a int, b char(1), key a(a), key b(a,b)); +eval create temporary table t1 (a int, b char(1), key a $key_type (a), key b(a,b)); insert into t1 values (0,"a"),(1,"b"),(2,"c"),(3,"d"),(4,"e"), - (5,"f"),(6,"g"),(7,"h"),(8,"i"),(9,"j"); + (5,"f"),(6,"g"),(7,"h"),(8,"i"),(9,"j"),(9,'k'); select a,b from t1; handler t1 open as a1; -handler a1 read a first; +handler a1 read a=(1); handler a1 read a next; handler a1 read a next; --error ER_CANT_REOPEN_TABLE @@ -594,41 +392,19 @@ handler a1 read a=(6) where b="g"; handler a1 close; select a,b from t1; handler t1 open as a2; -handler a2 read a first; +handler a2 read a=(9); +handler a2 read a next; +handler a2 read a prev limit 2; +--error 0,1031 handler a2 read a last; handler a2 read a prev; handler a2 close; drop table t1; -# -# Bug#31397 Inconsistent drop table behavior of handler tables. -# - ---disable_warnings -drop table if exists t1,t2; ---enable_warnings -create table t1 (a int); -handler t1 open as t1_alias; -drop table t1; -create table t1 (a int); -handler t1 open as t1_alias; -flush tables; -drop table t1; -create table t1 (a int); -handler t1 open as t1_alias; -handler t1_alias close; -drop table t1; -create table t1 (a int); -handler t1 open as t1_alias; -handler t1_alias read first; -drop table t1; ---error ER_UNKNOWN_TABLE -handler t1_alias read next; - # Test that temporary tables associated with handlers are properly dropped. create table t1 (a int); -create temporary table t2 (a int, key(a)); +eval create temporary table t2 (a int, key $key_type (a)); handler t1 open as a1; handler t2 open as a2; handler a2 read a first; @@ -640,7 +416,7 @@ handler a1 close; # Alter table drop handlers -create table t1 (a int, key(a)); +eval create table t1 (a int, key $key_type (a)); create table t2 like t1; handler t1 open as a1; handler t2 open as a2; @@ -654,7 +430,7 @@ drop table t1, t2; # Rename table drop handlers -create table t1 (a int, key(a)); +eval create table t1 (a int, key $key_type (a)); handler t1 open as a1; handler a1 read a first; rename table t1 to t2; @@ -664,7 +440,7 @@ drop table t2; # Optimize table drop handlers -create table t1 (a int, key(a)); +eval create table t1 (a int, key $key_type (a)); create table t2 like t1; handler t1 open as a1; handler t2 open as a2; @@ -676,56 +452,14 @@ handler a1 close; handler a2 close; drop table t1, t2; -# Flush tables causes handlers reopen - -create table t1 (a int, b char(1), key a(a), key b(a,b)); -insert into t1 values (0,"a"),(1,"b"),(2,"c"),(3,"d"),(4,"e"), - (5,"f"),(6,"g"),(7,"h"),(8,"i"),(9,"j"); -handler t1 open; -handler t1 read a first; -handler t1 read a next; -flush tables; -handler t1 read a next; -handler t1 read a next; -flush tables with read lock; -handler t1 read a next; -unlock tables; -drop table t1; ---error ER_UNKNOWN_TABLE -handler t1 read a next; - -# -# Bug#41110: crash with handler command when used concurrently with alter table -# Bug#41112: crash in mysql_ha_close_table/get_lock_data with alter table -# - ---disable_warnings -drop table if exists t1; ---enable_warnings -create table t1 (a int); -insert into t1 values (1); -handler t1 open; -connect(con1,localhost,root,,); -send alter table t1 engine=memory; -connection default; -let $wait_condition= - select count(*) = 1 from information_schema.processlist - where state = "rename result table" and info = "alter table t1 engine=memory"; ---source include/wait_condition.inc ---error ER_ILLEGAL_HA -handler t1 read a next; -handler t1 close; -connection con1; ---reap -drop table t1; -disconnect con1; ---source include/wait_until_disconnected.inc -connection default; - -# -# Bug#44151 using handler commands on information_schema tables crashes server -# -USE information_schema; ---error ER_WRONG_USAGE -HANDLER COLUMNS OPEN; -USE test; +--echo # +--echo # BUG#51877 - HANDLER interface causes invalid memory read +--echo # +eval CREATE TABLE t1(a INT, KEY $key_type (a)); +HANDLER t1 OPEN; +HANDLER t1 READ a FIRST; +INSERT INTO t1 VALUES(1); +--error 0,ER_CHECKREAD +HANDLER t1 READ a NEXT; +HANDLER t1 CLOSE; +DROP TABLE t1; diff --git a/mysql-test/suite/handler/init.inc b/mysql-test/suite/handler/init.inc new file mode 100644 index 00000000000..32c6010f95b --- /dev/null +++ b/mysql-test/suite/handler/init.inc @@ -0,0 +1,33 @@ +# Setup things for handler.inc +# +# Input variables +# $engine_type -- storage engine to be tested +# $key_type -- set if you want a non standard key type +# +# This scripts sets up default values for: +# $other_engine_type -- storage engine <> $engine_type +# $other_handler_engine_type -- storage engine <> $engine_type, if possible +# 1. $other_handler_engine_type must support handler +# 2. $other_handler_engine_type must point to an all +# time available storage engine +# have to be set before sourcing this script. +# +# Handler tests don't work with embedded server +# +-- source include/not_embedded.inc + +eval SET SESSION STORAGE_ENGINE = $engine_type; +let $other_engine_type= CSV; +let $other_handler_engine_type= MyISAM; + +--disable_warnings +drop table if exists t1,t3,t4,t5; +--enable_warnings + +# Create default test table + +eval create table t1 (a int, b char(10), key a $key_type (a), key b $key_type (a,b)); +insert into t1 values +(17,"ddd"),(18,"eee"),(19,"fff"),(19,"yyy"), +(14,"aaa"),(16,"ccc"),(16,"xxx"), +(20,"ggg"),(21,"hhh"),(22,"iii"); diff --git a/mysql-test/r/handler_innodb.result b/mysql-test/suite/handler/innodb.result index 957fc30acef..83ce270612d 100644 --- a/mysql-test/r/handler_innodb.result +++ b/mysql-test/suite/handler/innodb.result @@ -1,25 +1,23 @@ SET SESSION STORAGE_ENGINE = InnoDB; drop table if exists t1,t3,t4,t5; -create table t1 (a int, b char(10), key a(a), key b(a,b)); +create table t1 (a int, b char(10), key a (a), key b (a,b)); insert into t1 values (17,"ddd"),(18,"eee"),(19,"fff"),(19,"yyy"), -(14,"aaa"),(15,"bbb"),(16,"ccc"),(16,"xxx"), +(14,"aaa"),(16,"ccc"),(16,"xxx"), (20,"ggg"),(21,"hhh"),(22,"iii"); handler t1 open as t2; -handler t2 read a=(SELECT 1); -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 'SELECT 1)' at line 1 handler t2 read a first; a b 14 aaa handler t2 read a next; a b -15 bbb +16 ccc handler t2 read a next; a b -16 ccc +16 xxx handler t2 read a prev; a b -15 bbb +16 ccc handler t2 read a last; a b 22 iii @@ -47,7 +45,6 @@ handler t2 read a next; a b handler t2 read a=(15); a b -15 bbb handler t2 read a=(16); a b 16 ccc @@ -84,26 +81,64 @@ a b handler t2 read a<(18); a b 17 ddd +handler t2 read a=(15); +a b +handler t2 read a>=(15); +a b +16 ccc +handler t2 read a>(15); +a b +16 ccc +handler t2 read a<=(15); +a b +14 aaa +handler t2 read a<(15); +a b +14 aaa +handler t2 read a=(54); +a b +handler t2 read a>=(54); +a b +handler t2 read a>(54); +a b +handler t2 read a<=(54); +a b +22 iii +handler t2 read a<(54); +a b +22 iii +handler t2 read a=(1); +a b +handler t2 read a>=(1); +a b +14 aaa +handler t2 read a>(1); +a b +14 aaa +handler t2 read a<=(1); +a b +handler t2 read a<(1); +a b handler t2 read a first limit 5; a b 14 aaa -15 bbb 16 ccc 16 xxx 17 ddd +18 eee handler t2 read a next limit 3; a b -18 eee 19 fff 19 yyy +20 ggg handler t2 read a prev limit 10; a b +19 yyy 19 fff 18 eee 17 ddd 16 xxx 16 ccc -15 bbb 14 aaa handler t2 read a>=(16) limit 4; a b @@ -135,8 +170,6 @@ a b handler t2 read next; a b 19 fff -handler t2 read last; -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 1 handler t2 close; handler t1 open; handler t1 read a next; @@ -144,7 +177,7 @@ a b 14 aaa handler t1 read a next; a b -15 bbb +16 ccc handler t1 close; handler t1 open; handler t1 read a prev; @@ -163,12 +196,12 @@ handler t2 read first; ERROR 42S02: Unknown table 't2' in HANDLER handler t1 open as t2; drop table t1; -create table t1 (a int); +create table t1 (a int not null); insert into t1 values (17); handler t2 read first; ERROR 42S02: Unknown table 't2' in HANDLER handler t1 open as t2; -alter table t1 engine=MEMORY; +alter table t1 engine=CSV; handler t2 read first; ERROR 42S02: Unknown table 't2' in HANDLER drop table t1; @@ -191,7 +224,7 @@ handler t1 read first; a 6 drop table t1; -create table t1(a int, index(a)); +create table t1(a int, index (a)); insert into t1 values (1), (2), (3); handler t1 open; handler t1 read a=(W); @@ -217,7 +250,7 @@ Ok handler t close; use test; drop table t1; -create table t1 ( a int, b int, INDEX a (a) ); +create table t1 ( a int, b int, INDEX a (a) ); insert into t1 values (1,2), (2,1); handler t1 open; handler t1 read a=(1) where b=2; @@ -229,148 +262,6 @@ handler t1 read a=(1) where b=1; a b handler t1 close; drop table t1; -drop database if exists test_test; -create database test_test; -use test_test; -create table t1(table_id char(20) primary key); -insert into t1 values ('test_test.t1'); -insert into t1 values (''); -handler t1 open; -handler t1 read first limit 9; -table_id - -test_test.t1 -create table t2(table_id char(20) primary key); -insert into t2 values ('test_test.t2'); -insert into t2 values (''); -handler t2 open; -handler t2 read first limit 9; -table_id - -test_test.t2 -use test; -drop table if exists t1; -create table t1(table_id char(20) primary key); -insert into t1 values ('test.t1'); -insert into t1 values (''); -handler t1 open; -ERROR 42000: Not unique table/alias: 't1' -use test; -handler test.t1 read first limit 9; -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 'read first limit 9' at line 1 -handler test_test.t1 read first limit 9; -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 'read first limit 9' at line 1 -handler t1 read first limit 9; -table_id - -test_test.t1 -handler test_test.t2 read first limit 9; -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 'read first limit 9' at line 1 -handler t2 read first limit 9; -table_id - -test_test.t2 -handler test_test.t1 close; -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 'close' at line 1 -handler t1 close; -drop table test_test.t1; -handler test_test.t2 close; -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 'close' at line 1 -handler t2 close; -drop table test_test.t2; -drop database test_test; -use test; -handler test.t1 close; -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 'close' at line 1 -handler t1 close; -ERROR 42S02: Unknown table 't1' in HANDLER -drop table test.t1; -drop database if exists test_test; -drop table if exists t1; -drop table if exists t2; -drop table if exists t3; -create database test_test; -use test_test; -create table t1 (c1 char(20)); -insert into t1 values ('test_test.t1'); -create table t3 (c1 char(20)); -insert into t3 values ('test_test.t3'); -handler t1 open; -handler t1 read first limit 9; -c1 -test_test.t1 -handler t1 open h1; -handler h1 read first limit 9; -c1 -test_test.t1 -use test; -create table t1 (c1 char(20)); -create table t2 (c1 char(20)); -create table t3 (c1 char(20)); -insert into t1 values ('t1'); -insert into t2 values ('t2'); -insert into t3 values ('t3'); -handler t1 open; -ERROR 42000: Not unique table/alias: 't1' -handler t2 open t1; -ERROR 42000: Not unique table/alias: 't1' -handler t3 open t1; -ERROR 42000: Not unique table/alias: 't1' -handler t1 read first limit 9; -c1 -test_test.t1 -handler test.t1 close; -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 'close' at line 1 -handler test.t1 open h1; -ERROR 42000: Not unique table/alias: 'h1' -handler test_test.t1 open h1; -ERROR 42000: Not unique table/alias: 'h1' -handler test_test.t3 open h3; -handler test.t1 open h2; -handler t1 read first limit 9; -c1 -test_test.t1 -handler h1 read first limit 9; -c1 -test_test.t1 -handler h2 read first limit 9; -c1 -t1 -handler h3 read first limit 9; -c1 -test_test.t3 -handler h2 read first limit 9; -c1 -t1 -handler test.h1 close; -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 'close' at line 1 -handler t1 close; -handler h1 close; -handler h2 close; -handler t1 read first limit 9; -ERROR 42S02: Unknown table 't1' in HANDLER -handler h1 read first limit 9; -ERROR 42S02: Unknown table 'h1' in HANDLER -handler h2 read first limit 9; -ERROR 42S02: Unknown table 'h2' in HANDLER -handler h3 read first limit 9; -c1 -test_test.t3 -handler h3 read first limit 9; -c1 -test_test.t3 -use test_test; -handler h3 read first limit 9; -c1 -test_test.t3 -handler test.h3 read first limit 9; -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 'read first limit 9' at line 1 -handler h3 close; -use test; -drop table t3; -drop table t2; -drop table t1; -drop database test_test; create table t1 (c1 char(20)); insert into t1 values ("t1"); handler t1 open as h1; @@ -496,6 +387,11 @@ no1 no2 HANDLER t1 READ `primary` PREV; no1 no2 1 275 +HANDLER t1 READ `primary` = (1, 1000); +no1 no2 +HANDLER t1 READ `primary` NEXT; +no1 no2 +2 8 DROP TABLE t1; create table t1 (c1 int); insert into t1 values (14397); @@ -516,14 +412,12 @@ ERROR 42S02: Table 'test.t1' doesn't exist drop table if exists t1; Warnings: Note 1051 Unknown table 't1' -drop table if exists t1; -create table t1 (a int) ENGINE=MEMORY; +create table t1 (a int not null) ENGINE=CSV; --> client 2 handler t1 open; ERROR HY000: Table storage engine for 't1' doesn't have this option --> client 1 drop table t1; -drop table if exists t1; create table t1 (a int); handler t1 open as t1_alias; handler t1_alias read a next; @@ -536,50 +430,9 @@ handler t1_alias READ a next where inexistent > 0; ERROR 42S22: Unknown column 'inexistent' in 'field list' handler t1_alias close; drop table t1; -drop table if exists t1,t2; -create table t1 (c1 int); -create table t2 (c1 int); -insert into t1 values (1); -insert into t2 values (2); -connection: default -handler t1 open; -handler t1 read first; -c1 -1 -connection: flush -flush tables;; -connection: default -handler t2 open; -handler t2 read first; -c1 -2 -handler t1 read next; -c1 -1 -handler t1 close; -handler t2 close; -drop table t1,t2; -drop table if exists t1,t2; -create table t1 (c1 int); -connection: default -handler t1 open; -handler t1 read first; -c1 -connection: flush -rename table t1 to t2;; -connection: default -handler t2 open; -handler t2 read first; -c1 -handler t1 read next; -ERROR 42S02: Table 'test.t1' doesn't exist -handler t1 close; -handler t2 close; -drop table t2; -drop table if exists t1; -create temporary table t1 (a int, b char(1), key a(a), key b(a,b)); +create temporary table t1 (a int, b char(1), key a (a), key b(a,b)); insert into t1 values (0,"a"),(1,"b"),(2,"c"),(3,"d"),(4,"e"), -(5,"f"),(6,"g"),(7,"h"),(8,"i"),(9,"j"); +(5,"f"),(6,"g"),(7,"h"),(8,"i"),(9,"j"),(9,'k'); select a,b from t1; a b 0 a @@ -592,24 +445,25 @@ a b 7 h 8 i 9 j +9 k handler t1 open as a1; -handler a1 read a first; -a b -0 a -handler a1 read a next; +handler a1 read a=(1); a b 1 b handler a1 read a next; a b 2 c +handler a1 read a next; +a b +3 d select a,b from t1; ERROR HY000: Can't reopen table: 'a1' handler a1 read a prev; a b -1 b +2 c handler a1 read a prev; a b -0 a +1 b handler a1 read a=(6) where b="g"; a b 6 g @@ -626,39 +480,28 @@ a b 7 h 8 i 9 j +9 k handler t1 open as a2; -handler a2 read a first; +handler a2 read a=(9); a b -0 a -handler a2 read a last; +9 j +handler a2 read a next; +a b +9 k +handler a2 read a prev limit 2; a b 9 j +8 i +handler a2 read a last; +a b +9 k handler a2 read a prev; a b -8 i +9 j handler a2 close; drop table t1; -drop table if exists t1,t2; create table t1 (a int); -handler t1 open as t1_alias; -drop table t1; -create table t1 (a int); -handler t1 open as t1_alias; -flush tables; -drop table t1; -create table t1 (a int); -handler t1 open as t1_alias; -handler t1_alias close; -drop table t1; -create table t1 (a int); -handler t1 open as t1_alias; -handler t1_alias read first; -a -drop table t1; -handler t1_alias read next; -ERROR 42S02: Unknown table 't1_alias' in HANDLER -create table t1 (a int); -create temporary table t2 (a int, key(a)); +create temporary table t2 (a int, key (a)); handler t1 open as a1; handler t2 open as a2; handler a2 read a first; @@ -668,7 +511,7 @@ handler a2 read a next; ERROR 42S02: Unknown table 'a2' in HANDLER handler a1 close; ERROR 42S02: Unknown table 'a1' in HANDLER -create table t1 (a int, key(a)); +create table t1 (a int, key (a)); create table t2 like t1; handler t1 open as a1; handler t2 open as a2; @@ -681,7 +524,7 @@ handler a1 close; ERROR 42S02: Unknown table 'a1' in HANDLER handler a2 close; drop table t1, t2; -create table t1 (a int, key(a)); +create table t1 (a int, key (a)); handler t1 open as a1; handler a1 read a first; a @@ -689,7 +532,7 @@ rename table t1 to t2; handler a1 read a first; ERROR 42S02: Unknown table 'a1' in HANDLER drop table t2; -create table t1 (a int, key(a)); +create table t1 (a int, key (a)); create table t2 like t1; handler t1 open as a1; handler t2 open as a2; @@ -705,41 +548,15 @@ handler a1 close; ERROR 42S02: Unknown table 'a1' in HANDLER handler a2 close; drop table t1, t2; -create table t1 (a int, b char(1), key a(a), key b(a,b)); -insert into t1 values (0,"a"),(1,"b"),(2,"c"),(3,"d"),(4,"e"), -(5,"f"),(6,"g"),(7,"h"),(8,"i"),(9,"j"); -handler t1 open; -handler t1 read a first; -a b -0 a -handler t1 read a next; -a b -1 b -flush tables; -handler t1 read a next; -a b -0 a -handler t1 read a next; -a b -1 b -flush tables with read lock; -handler t1 read a next; -a b -0 a -unlock tables; -drop table t1; -handler t1 read a next; -ERROR 42S02: Unknown table 't1' in HANDLER -drop table if exists t1; -create table t1 (a int); -insert into t1 values (1); -handler t1 open; -alter table t1 engine=memory; -handler t1 read a next; -ERROR HY000: Table storage engine for 't1' doesn't have this option -handler t1 close; -drop table t1; -USE information_schema; -HANDLER COLUMNS OPEN; -ERROR HY000: Incorrect usage of HANDLER OPEN and information_schema -USE test; +# +# BUG#51877 - HANDLER interface causes invalid memory read +# +CREATE TABLE t1(a INT, KEY (a)); +HANDLER t1 OPEN; +HANDLER t1 READ a FIRST; +a +INSERT INTO t1 VALUES(1); +HANDLER t1 READ a NEXT; +a +HANDLER t1 CLOSE; +DROP TABLE t1; diff --git a/mysql-test/t/handler_innodb.test b/mysql-test/suite/handler/innodb.test index 02982716f78..f4e4bf7cc3f 100644 --- a/mysql-test/t/handler_innodb.test +++ b/mysql-test/suite/handler/innodb.test @@ -5,16 +5,13 @@ # Last update: # 2006-07-31 ML test refactored (MySQL 5.1) # code of t/handler.test and t/innodb_handler.test united -# main testing code put into include/handler.inc +# main testing code put into handler.inc # rename t/innodb_handler.test to t/handler_innodb.test # -# should work in embedded server after mysqltest is fixed ---source include/not_embedded.inc - --source include/have_innodb.inc + let $engine_type= InnoDB; -let $other_engine_type= MEMORY; -let $other_handler_engine_type= MyISAM; ---source include/handler.inc +--source init.inc +--source handler.inc diff --git a/mysql-test/suite/handler/interface.result b/mysql-test/suite/handler/interface.result new file mode 100644 index 00000000000..0b5a4447739 --- /dev/null +++ b/mysql-test/suite/handler/interface.result @@ -0,0 +1,259 @@ +drop table if exists t1,t3,t4,t5; +drop database if exists test_test; +SET SESSION STORAGE_ENGINE = MyISAM; +drop table if exists t1,t3,t4,t5; +create table t1 (a int, b char(10), key a (a), key b (a,b)); +insert into t1 values +(17,"ddd"),(18,"eee"),(19,"fff"),(19,"yyy"), +(14,"aaa"),(16,"ccc"),(16,"xxx"), +(20,"ggg"),(21,"hhh"),(22,"iii"); +handler t1 open; +handler t1 read a=(SELECT 1); +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 'SELECT 1)' at line 1 +handler t1 read a=(1) FIRST; +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 'FIRST' at line 1 +handler t1 read a=(1) NEXT; +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 'NEXT' at line 1 +handler t1 read last; +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 1 +handler t1 close; +drop table t1; +CREATE TABLE t1(a INT, PRIMARY KEY(a)); +insert into t1 values(1),(2); +handler t1 open; +handler t1 read primary=(1); +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 'primary=(1)' at line 1 +handler t1 read `primary`=(1); +a +1 +handler t1 close; +drop table t1; +create database test_test; +use test_test; +create table t1(table_id char(20), primary key (table_id)); +insert into t1 values ('test_test.t1'); +insert into t1 values (''); +handler t1 open; +handler t1 read first limit 9; +table_id +test_test.t1 + +create table t2(table_id char(20), primary key (table_id)); +insert into t2 values ('test_test.t2'); +insert into t2 values (''); +handler t2 open; +handler t2 read first limit 9; +table_id +test_test.t2 + +use test; +create table t1(table_id char(20), primary key (table_id)); +insert into t1 values ('test.t1'); +insert into t1 values (''); +handler t1 open; +ERROR 42000: Not unique table/alias: 't1' +use test; +handler test.t1 read first limit 9; +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 'read first limit 9' at line 1 +handler test_test.t1 read first limit 9; +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 'read first limit 9' at line 1 +handler t1 read first limit 9; +table_id +test_test.t1 + +handler test_test.t2 read first limit 9; +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 'read first limit 9' at line 1 +handler t2 read first limit 9; +table_id +test_test.t2 + +handler test_test.t1 close; +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 'close' at line 1 +handler t1 close; +drop table test_test.t1; +handler test_test.t2 close; +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 'close' at line 1 +handler t2 close; +drop table test_test.t2; +drop database test_test; +use test; +handler test.t1 close; +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 'close' at line 1 +handler t1 close; +ERROR 42S02: Unknown table 't1' in HANDLER +drop table test.t1; +create database test_test; +use test_test; +create table t1 (c1 char(20)); +insert into t1 values ('test_test.t1'); +create table t3 (c1 char(20)); +insert into t3 values ('test_test.t3'); +handler t1 open; +handler t1 read first limit 9; +c1 +test_test.t1 +handler t1 open h1; +handler h1 read first limit 9; +c1 +test_test.t1 +use test; +create table t1 (c1 char(20)); +create table t2 (c1 char(20)); +create table t3 (c1 char(20)); +insert into t1 values ('t1'); +insert into t2 values ('t2'); +insert into t3 values ('t3'); +handler t1 open; +ERROR 42000: Not unique table/alias: 't1' +handler t2 open t1; +ERROR 42000: Not unique table/alias: 't1' +handler t3 open t1; +ERROR 42000: Not unique table/alias: 't1' +handler t1 read first limit 9; +c1 +test_test.t1 +handler test.t1 close; +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 'close' at line 1 +handler test.t1 open h1; +ERROR 42000: Not unique table/alias: 'h1' +handler test_test.t1 open h1; +ERROR 42000: Not unique table/alias: 'h1' +handler test_test.t3 open h3; +handler test.t1 open h2; +handler t1 read first limit 9; +c1 +test_test.t1 +handler h1 read first limit 9; +c1 +test_test.t1 +handler h2 read first limit 9; +c1 +t1 +handler h3 read first limit 9; +c1 +test_test.t3 +handler h2 read first limit 9; +c1 +t1 +handler test.h1 close; +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 'close' at line 1 +handler t1 close; +handler h1 close; +handler h2 close; +handler t1 read first limit 9; +ERROR 42S02: Unknown table 't1' in HANDLER +handler h1 read first limit 9; +ERROR 42S02: Unknown table 'h1' in HANDLER +handler h2 read first limit 9; +ERROR 42S02: Unknown table 'h2' in HANDLER +handler h3 read first limit 9; +c1 +test_test.t3 +handler h3 read first limit 9; +c1 +test_test.t3 +use test_test; +handler h3 read first limit 9; +c1 +test_test.t3 +handler test.h3 read first limit 9; +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 'read first limit 9' at line 1 +handler h3 close; +use test; +drop table t3; +drop table t2; +drop table t1; +drop database test_test; +create table t1 (c1 int); +create table t2 (c1 int); +insert into t1 values (1); +insert into t2 values (2); +connection: default +handler t1 open; +handler t1 read first; +c1 +1 +connection: flush +flush tables;; +connection: default +handler t2 open; +handler t2 read first; +c1 +2 +handler t1 read next; +c1 +1 +handler t1 close; +handler t2 close; +drop table t1,t2; +create table t1 (a int); +handler t1 open as t1_alias; +drop table t1; +create table t1 (a int); +handler t1 open as t1_alias; +flush tables; +drop table t1; +create table t1 (a int); +handler t1 open as t1_alias; +handler t1_alias close; +drop table t1; +create table t1 (a int); +handler t1 open as t1_alias; +handler t1_alias read first; +a +drop table t1; +handler t1_alias read next; +ERROR 42S02: Unknown table 't1_alias' in HANDLER +create table t1 (c1 int); +connection: default +handler t1 open; +handler t1 read first; +c1 +connection: flush +rename table t1 to t2;; +connection: default +handler t2 open; +handler t2 read first; +c1 +handler t1 read next; +ERROR 42S02: Table 'test.t1' doesn't exist +handler t1 close; +handler t2 close; +drop table t2; +create table t1 (a int, b char(1), key a (a), key b (a,b)); +insert into t1 values (0,"a"),(1,"b"),(2,"c"),(3,"d"),(4,"e"), +(5,"f"),(6,"g"),(7,"h"),(8,"i"),(9,"j"); +handler t1 open; +handler t1 read a first; +a b +0 a +handler t1 read a next; +a b +1 b +flush tables; +handler t1 read a next; +a b +0 a +handler t1 read a next; +a b +1 b +flush tables with read lock; +handler t1 read a next; +a b +0 a +unlock tables; +drop table t1; +handler t1 read a next; +ERROR 42S02: Unknown table 't1' in HANDLER +drop table if exists t1; +create table t1 (a int not null); +insert into t1 values (1); +handler t1 open; +alter table t1 engine=csv; +handler t1 read a next; +ERROR HY000: Table storage engine for 't1' doesn't have this option +handler t1 close; +drop table t1; +USE information_schema; +HANDLER COLUMNS OPEN; +ERROR HY000: Incorrect usage of HANDLER OPEN and information_schema diff --git a/mysql-test/suite/handler/interface.test b/mysql-test/suite/handler/interface.test new file mode 100644 index 00000000000..809f0228f98 --- /dev/null +++ b/mysql-test/suite/handler/interface.test @@ -0,0 +1,307 @@ +# +# Tests of handler interface that are system independent +# +# Handler tests don't work yet with embedded server +# +-- source include/not_embedded.inc + +--disable_warnings +drop table if exists t1,t3,t4,t5; +drop database if exists test_test; +--enable_warnings + +# Run tests with myisam (any engine should be ok) + +let $engine_type= MyISAM; + +--source init.inc + +# +# Do some syntax checking +# + +handler t1 open; +--error ER_PARSE_ERROR +handler t1 read a=(SELECT 1); +--error ER_PARSE_ERROR +handler t1 read a=(1) FIRST; +--error ER_PARSE_ERROR +handler t1 read a=(1) NEXT; +--error ER_PARSE_ERROR +handler t1 read last; +handler t1 close; +drop table t1; + +CREATE TABLE t1(a INT, PRIMARY KEY(a)); +insert into t1 values(1),(2); +handler t1 open; +--error ER_PARSE_ERROR +handler t1 read primary=(1); +handler t1 read `primary`=(1); +handler t1 close; +drop table t1; + +# +# Check if two database names beginning the same are seen as different. +# +# This database begins like the usual 'test' database. +# +create database test_test; +use test_test; +eval create table t1(table_id char(20), primary key $key_type (table_id)); +insert into t1 values ('test_test.t1'); +insert into t1 values (''); +handler t1 open; +handler t1 read first limit 9; +eval create table t2(table_id char(20), primary key $key_type (table_id)); +insert into t2 values ('test_test.t2'); +insert into t2 values (''); +handler t2 open; +handler t2 read first limit 9; +# +# This is the usual 'test' database. +# +use test; +eval create table t1(table_id char(20), primary key $key_type (table_id)); +insert into t1 values ('test.t1'); +insert into t1 values (''); +--error 1066 +handler t1 open; +# +# Check accessibility of all the tables. +# +use test; +--error 1064 +handler test.t1 read first limit 9; +--error 1064 +handler test_test.t1 read first limit 9; +handler t1 read first limit 9; +--error 1064 +handler test_test.t2 read first limit 9; +handler t2 read first limit 9; + +# +# Cleanup. +# + +--error 1064 +handler test_test.t1 close; +handler t1 close; +drop table test_test.t1; +--error 1064 +handler test_test.t2 close; +handler t2 close; +drop table test_test.t2; +drop database test_test; + +# +use test; +--error 1064 +handler test.t1 close; +--error 1109 +handler t1 close; +drop table test.t1; + +# +# BUG#4335 one name can be handler open'ed many times +# + +create database test_test; +use test_test; +create table t1 (c1 char(20)); +insert into t1 values ('test_test.t1'); +create table t3 (c1 char(20)); +insert into t3 values ('test_test.t3'); +handler t1 open; +handler t1 read first limit 9; +handler t1 open h1; +handler h1 read first limit 9; +use test; +create table t1 (c1 char(20)); +create table t2 (c1 char(20)); +create table t3 (c1 char(20)); +insert into t1 values ('t1'); +insert into t2 values ('t2'); +insert into t3 values ('t3'); +--error 1066 +handler t1 open; +--error 1066 +handler t2 open t1; +--error 1066 +handler t3 open t1; +handler t1 read first limit 9; +--error 1064 +handler test.t1 close; +--error 1066 +handler test.t1 open h1; +--error 1066 +handler test_test.t1 open h1; +handler test_test.t3 open h3; +handler test.t1 open h2; +handler t1 read first limit 9; +handler h1 read first limit 9; +handler h2 read first limit 9; +handler h3 read first limit 9; +handler h2 read first limit 9; +--error 1064 +handler test.h1 close; +handler t1 close; +handler h1 close; +handler h2 close; +--error 1109 +handler t1 read first limit 9; +--error 1109 +handler h1 read first limit 9; +--error 1109 +handler h2 read first limit 9; +handler h3 read first limit 9; +handler h3 read first limit 9; +use test_test; +handler h3 read first limit 9; +--error 1064 +handler test.h3 read first limit 9; +handler h3 close; +use test; +drop table t3; +drop table t2; +drop table t1; +drop database test_test; + +# +# Bug#21587 FLUSH TABLES causes server crash when used with HANDLER statements +# + +create table t1 (c1 int); +create table t2 (c1 int); +insert into t1 values (1); +insert into t2 values (2); +--echo connection: default +handler t1 open; +handler t1 read first; +connect (flush,localhost,root,,); +connection flush; +--echo connection: flush +--send flush tables; +connection default; +--echo connection: default +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Flushing tables"; +--source include/wait_condition.inc +handler t2 open; +handler t2 read first; +handler t1 read next; +handler t1 close; +handler t2 close; +connection flush; +reap; +connection default; +drop table t1,t2; +disconnect flush; + +# +# Bug#31397 Inconsistent drop table behavior of handler tables. +# + +create table t1 (a int); +handler t1 open as t1_alias; +drop table t1; +create table t1 (a int); +handler t1 open as t1_alias; +flush tables; +drop table t1; +create table t1 (a int); +handler t1 open as t1_alias; +handler t1_alias close; +drop table t1; +create table t1 (a int); +handler t1 open as t1_alias; +handler t1_alias read first; +drop table t1; +--error ER_UNKNOWN_TABLE +handler t1_alias read next; + +# +# Bug#31409 RENAME TABLE causes server crash or deadlock when used with +# HANDLER statements +# + +create table t1 (c1 int); +--echo connection: default +handler t1 open; +handler t1 read first; +connect (flush,localhost,root,,); +connection flush; +--echo connection: flush +--send rename table t1 to t2; +connection default; +--echo connection: default +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for table" and info = "rename table t1 to t2"; +--source include/wait_condition.inc +handler t2 open; +handler t2 read first; +--error ER_NO_SUCH_TABLE +handler t1 read next; +handler t1 close; +handler t2 close; +connection flush; +reap; +connection default; +drop table t2; +disconnect flush; + +# Flush tables causes handlers reopen + +eval create table t1 (a int, b char(1), key a $key_type (a), key b $key_type (a,b)); +insert into t1 values (0,"a"),(1,"b"),(2,"c"),(3,"d"),(4,"e"), + (5,"f"),(6,"g"),(7,"h"),(8,"i"),(9,"j"); +handler t1 open; +handler t1 read a first; +handler t1 read a next; +flush tables; +handler t1 read a next; +handler t1 read a next; +flush tables with read lock; +handler t1 read a next; +unlock tables; +drop table t1; +--error ER_UNKNOWN_TABLE +handler t1 read a next; + +# +# Bug#41110: crash with handler command when used concurrently with alter table +# Bug#41112: crash in mysql_ha_close_table/get_lock_data with alter table +# + +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1 (a int not null); +insert into t1 values (1); +handler t1 open; +connect(con1,localhost,root,,); +send alter table t1 engine=csv; +connection default; +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "rename result table" and info = "alter table t1 engine=csv"; +--source include/wait_condition.inc +--error ER_ILLEGAL_HA +handler t1 read a next; +handler t1 close; +connection con1; +--reap +drop table t1; +disconnect con1; +--source include/wait_until_disconnected.inc +connection default; + +# +# Bug#44151 using handler commands on information_schema tables crashes server +# + +USE information_schema; +--error ER_WRONG_USAGE +HANDLER COLUMNS OPEN; diff --git a/mysql-test/r/handler_myisam.result b/mysql-test/suite/handler/myisam.result index b20b8dbb138..bd356d6e81d 100644 --- a/mysql-test/r/handler_myisam.result +++ b/mysql-test/suite/handler/myisam.result @@ -1,25 +1,23 @@ SET SESSION STORAGE_ENGINE = MyISAM; drop table if exists t1,t3,t4,t5; -create table t1 (a int, b char(10), key a(a), key b(a,b)); +create table t1 (a int, b char(10), key a (a), key b (a,b)); insert into t1 values (17,"ddd"),(18,"eee"),(19,"fff"),(19,"yyy"), -(14,"aaa"),(15,"bbb"),(16,"ccc"),(16,"xxx"), +(14,"aaa"),(16,"ccc"),(16,"xxx"), (20,"ggg"),(21,"hhh"),(22,"iii"); handler t1 open as t2; -handler t2 read a=(SELECT 1); -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 'SELECT 1)' at line 1 handler t2 read a first; a b 14 aaa handler t2 read a next; a b -15 bbb +16 ccc handler t2 read a next; a b -16 ccc +16 xxx handler t2 read a prev; a b -15 bbb +16 ccc handler t2 read a last; a b 22 iii @@ -47,7 +45,6 @@ handler t2 read a next; a b handler t2 read a=(15); a b -15 bbb handler t2 read a=(16); a b 16 ccc @@ -84,26 +81,64 @@ a b handler t2 read a<(18); a b 17 ddd +handler t2 read a=(15); +a b +handler t2 read a>=(15); +a b +16 ccc +handler t2 read a>(15); +a b +16 ccc +handler t2 read a<=(15); +a b +14 aaa +handler t2 read a<(15); +a b +14 aaa +handler t2 read a=(54); +a b +handler t2 read a>=(54); +a b +handler t2 read a>(54); +a b +handler t2 read a<=(54); +a b +22 iii +handler t2 read a<(54); +a b +22 iii +handler t2 read a=(1); +a b +handler t2 read a>=(1); +a b +14 aaa +handler t2 read a>(1); +a b +14 aaa +handler t2 read a<=(1); +a b +handler t2 read a<(1); +a b handler t2 read a first limit 5; a b 14 aaa -15 bbb 16 ccc 16 xxx 17 ddd +18 eee handler t2 read a next limit 3; a b -18 eee 19 fff 19 yyy +20 ggg handler t2 read a prev limit 10; a b +19 yyy 19 fff 18 eee 17 ddd 16 xxx 16 ccc -15 bbb 14 aaa handler t2 read a>=(16) limit 4; a b @@ -135,8 +170,6 @@ a b handler t2 read next; a b 19 fff -handler t2 read last; -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 1 handler t2 close; handler t1 open; handler t1 read a next; @@ -144,7 +177,7 @@ a b 14 aaa handler t1 read a next; a b -15 bbb +16 ccc handler t1 close; handler t1 open; handler t1 read a prev; @@ -163,12 +196,12 @@ handler t2 read first; ERROR 42S02: Unknown table 't2' in HANDLER handler t1 open as t2; drop table t1; -create table t1 (a int); +create table t1 (a int not null); insert into t1 values (17); handler t2 read first; ERROR 42S02: Unknown table 't2' in HANDLER handler t1 open as t2; -alter table t1 engine=MEMORY; +alter table t1 engine=CSV; handler t2 read first; ERROR 42S02: Unknown table 't2' in HANDLER drop table t1; @@ -191,7 +224,7 @@ handler t1 read first; a 6 drop table t1; -create table t1(a int, index(a)); +create table t1(a int, index (a)); insert into t1 values (1), (2), (3); handler t1 open; handler t1 read a=(W); @@ -217,7 +250,7 @@ Ok handler t close; use test; drop table t1; -create table t1 ( a int, b int, INDEX a (a) ); +create table t1 ( a int, b int, INDEX a (a) ); insert into t1 values (1,2), (2,1); handler t1 open; handler t1 read a=(1) where b=2; @@ -229,148 +262,6 @@ handler t1 read a=(1) where b=1; a b handler t1 close; drop table t1; -drop database if exists test_test; -create database test_test; -use test_test; -create table t1(table_id char(20) primary key); -insert into t1 values ('test_test.t1'); -insert into t1 values (''); -handler t1 open; -handler t1 read first limit 9; -table_id -test_test.t1 - -create table t2(table_id char(20) primary key); -insert into t2 values ('test_test.t2'); -insert into t2 values (''); -handler t2 open; -handler t2 read first limit 9; -table_id -test_test.t2 - -use test; -drop table if exists t1; -create table t1(table_id char(20) primary key); -insert into t1 values ('test.t1'); -insert into t1 values (''); -handler t1 open; -ERROR 42000: Not unique table/alias: 't1' -use test; -handler test.t1 read first limit 9; -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 'read first limit 9' at line 1 -handler test_test.t1 read first limit 9; -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 'read first limit 9' at line 1 -handler t1 read first limit 9; -table_id -test_test.t1 - -handler test_test.t2 read first limit 9; -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 'read first limit 9' at line 1 -handler t2 read first limit 9; -table_id -test_test.t2 - -handler test_test.t1 close; -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 'close' at line 1 -handler t1 close; -drop table test_test.t1; -handler test_test.t2 close; -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 'close' at line 1 -handler t2 close; -drop table test_test.t2; -drop database test_test; -use test; -handler test.t1 close; -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 'close' at line 1 -handler t1 close; -ERROR 42S02: Unknown table 't1' in HANDLER -drop table test.t1; -drop database if exists test_test; -drop table if exists t1; -drop table if exists t2; -drop table if exists t3; -create database test_test; -use test_test; -create table t1 (c1 char(20)); -insert into t1 values ('test_test.t1'); -create table t3 (c1 char(20)); -insert into t3 values ('test_test.t3'); -handler t1 open; -handler t1 read first limit 9; -c1 -test_test.t1 -handler t1 open h1; -handler h1 read first limit 9; -c1 -test_test.t1 -use test; -create table t1 (c1 char(20)); -create table t2 (c1 char(20)); -create table t3 (c1 char(20)); -insert into t1 values ('t1'); -insert into t2 values ('t2'); -insert into t3 values ('t3'); -handler t1 open; -ERROR 42000: Not unique table/alias: 't1' -handler t2 open t1; -ERROR 42000: Not unique table/alias: 't1' -handler t3 open t1; -ERROR 42000: Not unique table/alias: 't1' -handler t1 read first limit 9; -c1 -test_test.t1 -handler test.t1 close; -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 'close' at line 1 -handler test.t1 open h1; -ERROR 42000: Not unique table/alias: 'h1' -handler test_test.t1 open h1; -ERROR 42000: Not unique table/alias: 'h1' -handler test_test.t3 open h3; -handler test.t1 open h2; -handler t1 read first limit 9; -c1 -test_test.t1 -handler h1 read first limit 9; -c1 -test_test.t1 -handler h2 read first limit 9; -c1 -t1 -handler h3 read first limit 9; -c1 -test_test.t3 -handler h2 read first limit 9; -c1 -t1 -handler test.h1 close; -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 'close' at line 1 -handler t1 close; -handler h1 close; -handler h2 close; -handler t1 read first limit 9; -ERROR 42S02: Unknown table 't1' in HANDLER -handler h1 read first limit 9; -ERROR 42S02: Unknown table 'h1' in HANDLER -handler h2 read first limit 9; -ERROR 42S02: Unknown table 'h2' in HANDLER -handler h3 read first limit 9; -c1 -test_test.t3 -handler h3 read first limit 9; -c1 -test_test.t3 -use test_test; -handler h3 read first limit 9; -c1 -test_test.t3 -handler test.h3 read first limit 9; -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 'read first limit 9' at line 1 -handler h3 close; -use test; -drop table t3; -drop table t2; -drop table t1; -drop database test_test; create table t1 (c1 char(20)); insert into t1 values ("t1"); handler t1 open as h1; @@ -495,6 +386,11 @@ no1 no2 HANDLER t1 READ `primary` PREV; no1 no2 1 275 +HANDLER t1 READ `primary` = (1, 1000); +no1 no2 +HANDLER t1 READ `primary` NEXT; +no1 no2 +2 6 DROP TABLE t1; create table t1 (c1 int); insert into t1 values (14397); @@ -515,14 +411,12 @@ ERROR 42S02: Table 'test.t1' doesn't exist drop table if exists t1; Warnings: Note 1051 Unknown table 't1' -drop table if exists t1; -create table t1 (a int) ENGINE=MEMORY; +create table t1 (a int not null) ENGINE=CSV; --> client 2 handler t1 open; ERROR HY000: Table storage engine for 't1' doesn't have this option --> client 1 drop table t1; -drop table if exists t1; create table t1 (a int); handler t1 open as t1_alias; handler t1_alias read a next; @@ -535,50 +429,9 @@ handler t1_alias READ a next where inexistent > 0; ERROR 42S22: Unknown column 'inexistent' in 'field list' handler t1_alias close; drop table t1; -drop table if exists t1,t2; -create table t1 (c1 int); -create table t2 (c1 int); -insert into t1 values (1); -insert into t2 values (2); -connection: default -handler t1 open; -handler t1 read first; -c1 -1 -connection: flush -flush tables;; -connection: default -handler t2 open; -handler t2 read first; -c1 -2 -handler t1 read next; -c1 -1 -handler t1 close; -handler t2 close; -drop table t1,t2; -drop table if exists t1,t2; -create table t1 (c1 int); -connection: default -handler t1 open; -handler t1 read first; -c1 -connection: flush -rename table t1 to t2;; -connection: default -handler t2 open; -handler t2 read first; -c1 -handler t1 read next; -ERROR 42S02: Table 'test.t1' doesn't exist -handler t1 close; -handler t2 close; -drop table t2; -drop table if exists t1; -create temporary table t1 (a int, b char(1), key a(a), key b(a,b)); +create temporary table t1 (a int, b char(1), key a (a), key b(a,b)); insert into t1 values (0,"a"),(1,"b"),(2,"c"),(3,"d"),(4,"e"), -(5,"f"),(6,"g"),(7,"h"),(8,"i"),(9,"j"); +(5,"f"),(6,"g"),(7,"h"),(8,"i"),(9,"j"),(9,'k'); select a,b from t1; a b 0 a @@ -591,24 +444,25 @@ a b 7 h 8 i 9 j +9 k handler t1 open as a1; -handler a1 read a first; -a b -0 a -handler a1 read a next; +handler a1 read a=(1); a b 1 b handler a1 read a next; a b 2 c +handler a1 read a next; +a b +3 d select a,b from t1; ERROR HY000: Can't reopen table: 'a1' handler a1 read a prev; a b -1 b +2 c handler a1 read a prev; a b -0 a +1 b handler a1 read a=(6) where b="g"; a b 6 g @@ -625,39 +479,28 @@ a b 7 h 8 i 9 j +9 k handler t1 open as a2; -handler a2 read a first; +handler a2 read a=(9); a b -0 a -handler a2 read a last; +9 j +handler a2 read a next; +a b +9 k +handler a2 read a prev limit 2; a b 9 j +8 i +handler a2 read a last; +a b +9 k handler a2 read a prev; a b -8 i +9 j handler a2 close; drop table t1; -drop table if exists t1,t2; -create table t1 (a int); -handler t1 open as t1_alias; -drop table t1; -create table t1 (a int); -handler t1 open as t1_alias; -flush tables; -drop table t1; -create table t1 (a int); -handler t1 open as t1_alias; -handler t1_alias close; -drop table t1; -create table t1 (a int); -handler t1 open as t1_alias; -handler t1_alias read first; -a -drop table t1; -handler t1_alias read next; -ERROR 42S02: Unknown table 't1_alias' in HANDLER create table t1 (a int); -create temporary table t2 (a int, key(a)); +create temporary table t2 (a int, key (a)); handler t1 open as a1; handler t2 open as a2; handler a2 read a first; @@ -667,7 +510,7 @@ handler a2 read a next; ERROR 42S02: Unknown table 'a2' in HANDLER handler a1 close; ERROR 42S02: Unknown table 'a1' in HANDLER -create table t1 (a int, key(a)); +create table t1 (a int, key (a)); create table t2 like t1; handler t1 open as a1; handler t2 open as a2; @@ -680,7 +523,7 @@ handler a1 close; ERROR 42S02: Unknown table 'a1' in HANDLER handler a2 close; drop table t1, t2; -create table t1 (a int, key(a)); +create table t1 (a int, key (a)); handler t1 open as a1; handler a1 read a first; a @@ -688,7 +531,7 @@ rename table t1 to t2; handler a1 read a first; ERROR 42S02: Unknown table 'a1' in HANDLER drop table t2; -create table t1 (a int, key(a)); +create table t1 (a int, key (a)); create table t2 like t1; handler t1 open as a1; handler t2 open as a2; @@ -703,44 +546,19 @@ handler a1 close; ERROR 42S02: Unknown table 'a1' in HANDLER handler a2 close; drop table t1, t2; -create table t1 (a int, b char(1), key a(a), key b(a,b)); -insert into t1 values (0,"a"),(1,"b"),(2,"c"),(3,"d"),(4,"e"), -(5,"f"),(6,"g"),(7,"h"),(8,"i"),(9,"j"); -handler t1 open; -handler t1 read a first; -a b -0 a -handler t1 read a next; -a b -1 b -flush tables; -handler t1 read a next; -a b -0 a -handler t1 read a next; -a b -1 b -flush tables with read lock; -handler t1 read a next; -a b -0 a -unlock tables; -drop table t1; -handler t1 read a next; -ERROR 42S02: Unknown table 't1' in HANDLER -drop table if exists t1; -create table t1 (a int); -insert into t1 values (1); -handler t1 open; -alter table t1 engine=memory; -handler t1 read a next; -ERROR HY000: Table storage engine for 't1' doesn't have this option -handler t1 close; -drop table t1; -USE information_schema; -HANDLER COLUMNS OPEN; -ERROR HY000: Incorrect usage of HANDLER OPEN and information_schema -USE test; +# +# BUG#51877 - HANDLER interface causes invalid memory read +# +CREATE TABLE t1(a INT, KEY (a)); +HANDLER t1 OPEN; +HANDLER t1 READ a FIRST; +a +INSERT INTO t1 VALUES(1); +HANDLER t1 READ a NEXT; +a +1 +HANDLER t1 CLOSE; +DROP TABLE t1; # # BUG #46456: HANDLER OPEN + TRUNCATE + DROP (temporary) TABLE, crash # @@ -757,19 +575,6 @@ HANDLER t1 READ FIRST; ERROR 42S02: Unknown table 't1' in HANDLER DROP TABLE t1; # -# BUG#51877 - HANDLER interface causes invalid memory read -# -CREATE TABLE t1(a INT, KEY(a)); -HANDLER t1 OPEN; -HANDLER t1 READ a FIRST; -a -INSERT INTO t1 VALUES(1); -HANDLER t1 READ a NEXT; -a -1 -HANDLER t1 CLOSE; -DROP TABLE t1; -# # Bug #54007: assert in ha_myisam::index_next , HANDLER # CREATE TABLE t1(a INT, b INT, PRIMARY KEY(a), KEY b(b), KEY ab(a, b)); @@ -821,12 +626,13 @@ HANDLER t1 READ b NEXT; a b HANDLER t1 READ NEXT; a b -4 40 +2 20 HANDLER t1 READ NEXT; a b -3 30 +1 10 HANDLER t1 READ NEXT; a b +4 40 HANDLER t1 CLOSE; HANDLER t1 OPEN; HANDLER t1 READ FIRST; diff --git a/mysql-test/t/handler_myisam.test b/mysql-test/suite/handler/myisam.test index e78072ef8a0..c6acf1e822c 100644 --- a/mysql-test/t/handler_myisam.test +++ b/mysql-test/suite/handler/myisam.test @@ -5,20 +5,14 @@ # Last update: # 2006-07-31 ML test refactored (MySQL 5.1) # code of t/handler.test and t/innodb_handler.test united -# main testing code put into include/handler.inc +# main testing code put into handler.inc # rename t/handler.test to t/handler_myisam.test # -# should work in embedded server after mysqltest is fixed ---source include/not_embedded.inc - let $engine_type= MyISAM; -let $other_engine_type= MEMORY; -# There is unfortunately no other all time available storage engine -# which supports the handler interface -let $other_handler_engine_type= MyISAM; ---source include/handler.inc +--source init.inc +--source handler.inc --echo # --echo # BUG #46456: HANDLER OPEN + TRUNCATE + DROP (temporary) TABLE, crash @@ -38,18 +32,6 @@ HANDLER t1 READ FIRST; DROP TABLE t1; --echo # ---echo # BUG#51877 - HANDLER interface causes invalid memory read ---echo # -CREATE TABLE t1(a INT, KEY(a)); -HANDLER t1 OPEN; -HANDLER t1 READ a FIRST; -INSERT INTO t1 VALUES(1); -HANDLER t1 READ a NEXT; -HANDLER t1 CLOSE; -DROP TABLE t1; - - ---echo # --echo # Bug #54007: assert in ha_myisam::index_next , HANDLER --echo # CREATE TABLE t1(a INT, b INT, PRIMARY KEY(a), KEY b(b), KEY ab(a, b)); diff --git a/mysql-test/t/lock_multi.test b/mysql-test/t/lock_multi.test index 4df1a0f3478..742a83f7bad 100644 --- a/mysql-test/t/lock_multi.test +++ b/mysql-test/t/lock_multi.test @@ -484,22 +484,6 @@ unlock tables; connection default; drop table t1; -# -# Bug#25856 HANDLER table OPEN in one connection lock DROP TABLE in another one -# ---disable_warnings -drop table if exists t1; ---enable_warnings -create table t1 (a int) ENGINE=MEMORY; ---echo --> client 2 -connection locker; ---error ER_ILLEGAL_HA -handler t1 open; ---echo --> client 1 -connection default; -drop table t1; - - # Disconnect sessions used in many subtests above disconnect locker; disconnect reader; |