Commit 2eaa76b8 authored by Michael Widenius's avatar Michael Widenius

Automatic merge with 5.1

parents 934c57c7 505c663a
...@@ -109,6 +109,7 @@ TEST_DIRS = t r include std_data std_data/parts collections \ ...@@ -109,6 +109,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 suite/innodb/t suite/innodb/r suite/innodb/include \
suite/innodb_plugin suite/innodb_plugin/t suite/innodb_plugin/r \ suite/innodb_plugin suite/innodb_plugin/t suite/innodb_plugin/r \
suite/innodb_plugin/include \ suite/innodb_plugin/include \
suite/handler \
suite/engines suite/engines/funcs suite/engines/iuds suite/engines/rr_trx \ 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/funcs/r suite/engines/funcs/t suite/engines/iuds/r \
suite/engines/iuds/t suite/engines/rr_trx/include suite/engines/rr_trx/r \ suite/engines/iuds/t suite/engines/rr_trx/include suite/engines/rr_trx/r \
......
...@@ -142,7 +142,7 @@ my $path_config_file; # The generated config file, var/my.cnf ...@@ -142,7 +142,7 @@ my $path_config_file; # The generated config file, var/my.cnf
# executables will be used by the test suite. # executables will be used by the test suite.
our $opt_vs_config = $ENV{'MTR_VS_CONFIG'}; our $opt_vs_config = $ENV{'MTR_VS_CONFIG'};
my $DEFAULT_SUITES= "main,binlog,federated,rpl,maria,parts,innodb,innodb_plugin,percona,ndb,vcol,oqgraph,sphinx"; my $DEFAULT_SUITES= "main,binlog,federated,rpl,maria,handler,parts,innodb,innodb_plugin,percona,ndb,vcol,oqgraph,sphinx";
my $opt_suites; my $opt_suites;
our $opt_verbose= 0; # Verbose output, enable with --verbose our $opt_verbose= 0; # Verbose output, enable with --verbose
......
...@@ -162,13 +162,6 @@ ERROR 70100: Query execution was interrupted ...@@ -162,13 +162,6 @@ ERROR 70100: Query execution was interrupted
unlock tables; unlock tables;
drop table t1; drop table t1;
drop table if exists 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); create table t1 (i int);
connection: default connection: default
lock tables t1 write; lock tables t1 write;
......
This diff is collapsed.
# 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
# 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");
...@@ -5,16 +5,13 @@ ...@@ -5,16 +5,13 @@
# Last update: # Last update:
# 2006-07-31 ML test refactored (MySQL 5.1) # 2006-07-31 ML test refactored (MySQL 5.1)
# code of t/handler.test and t/innodb_handler.test united # 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 # 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 --source include/have_innodb.inc
let $engine_type= InnoDB; 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
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
#
# 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;
...@@ -5,20 +5,14 @@ ...@@ -5,20 +5,14 @@
# Last update: # Last update:
# 2006-07-31 ML test refactored (MySQL 5.1) # 2006-07-31 ML test refactored (MySQL 5.1)
# code of t/handler.test and t/innodb_handler.test united # 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 # 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 $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 #
--echo # BUG #46456: HANDLER OPEN + TRUNCATE + DROP (temporary) TABLE, crash --echo # BUG #46456: HANDLER OPEN + TRUNCATE + DROP (temporary) TABLE, crash
...@@ -37,18 +31,6 @@ TRUNCATE t1; ...@@ -37,18 +31,6 @@ TRUNCATE t1;
HANDLER t1 READ FIRST; HANDLER t1 READ FIRST;
DROP TABLE t1; 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 #
--echo # Bug #54007: assert in ha_myisam::index_next , HANDLER --echo # Bug #54007: assert in ha_myisam::index_next , HANDLER
--echo # --echo #
......
...@@ -484,22 +484,6 @@ unlock tables; ...@@ -484,22 +484,6 @@ unlock tables;
connection default; connection default;
drop table t1; 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 sessions used in many subtests above
disconnect locker; disconnect locker;
disconnect reader; disconnect reader;
......
...@@ -375,6 +375,7 @@ void *tree_search_key(TREE *tree, const void *key, ...@@ -375,6 +375,7 @@ void *tree_search_key(TREE *tree, const void *key,
case HA_READ_KEY_EXACT: case HA_READ_KEY_EXACT:
case HA_READ_KEY_OR_NEXT: case HA_READ_KEY_OR_NEXT:
case HA_READ_BEFORE_KEY: case HA_READ_BEFORE_KEY:
case HA_READ_KEY_OR_PREV:
last_equal_element= parents; last_equal_element= parents;
cmp= 1; cmp= 1;
break; break;
...@@ -418,6 +419,9 @@ void *tree_search_key(TREE *tree, const void *key, ...@@ -418,6 +419,9 @@ void *tree_search_key(TREE *tree, const void *key,
case HA_READ_BEFORE_KEY: case HA_READ_BEFORE_KEY:
*last_pos= last_right_step_parent; *last_pos= last_right_step_parent;
break; break;
case HA_READ_KEY_OR_PREV:
*last_pos= last_equal_element ? last_equal_element : last_right_step_parent;
break;
default: default:
return NULL; return NULL;
} }
......
...@@ -2736,7 +2736,10 @@ void handler::print_error(int error, myf errflag) ...@@ -2736,7 +2736,10 @@ void handler::print_error(int error, myf errflag)
textno=ER_DUP_UNIQUE; textno=ER_DUP_UNIQUE;
break; break;
case HA_ERR_RECORD_CHANGED: case HA_ERR_RECORD_CHANGED:
SET_FATAL_ERROR; /*
This is not fatal error when using HANDLER interface
SET_FATAL_ERROR;
*/
textno=ER_CHECKREAD; textno=ER_CHECKREAD;
break; break;
case HA_ERR_CRASHED: case HA_ERR_CRASHED:
......
...@@ -1753,6 +1753,7 @@ public: ...@@ -1753,6 +1753,7 @@ public:
{ return(NULL);} /* gets tablespace name from handler */ { return(NULL);} /* gets tablespace name from handler */
/** used in ALTER TABLE; 1 if changing storage engine is allowed */ /** used in ALTER TABLE; 1 if changing storage engine is allowed */
virtual bool can_switch_engines() { return 1; } virtual bool can_switch_engines() { return 1; }
virtual int can_continue_handler_scan() { return 0; }
/** used in REPLACE; is > 0 if table is referred by a FOREIGN KEY */ /** used in REPLACE; is > 0 if table is referred by a FOREIGN KEY */
virtual int get_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list) virtual int get_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list)
{ return 0; } { return 0; }
......
...@@ -548,6 +548,12 @@ retry: ...@@ -548,6 +548,12 @@ retry:
mode= RLAST; mode= RLAST;
} }
} }
else if (table->file->inited != handler::RND)
{
/* Convert RNEXT to RFIRST if we haven't started row scan */
if (mode == RNEXT)
mode= RFIRST;
}
if (insert_fields(thd, &thd->lex->select_lex.context, if (insert_fields(thd, &thd->lex->select_lex.context,
tables->db, tables->alias, &it, 0)) tables->db, tables->alias, &it, 0))
...@@ -569,6 +575,8 @@ retry: ...@@ -569,6 +575,8 @@ retry:
case RNEXT: case RNEXT:
if (table->file->inited != handler::NONE) if (table->file->inited != handler::NONE)
{ {
if ((error= table->file->can_continue_handler_scan()))
break;
if (keyname) if (keyname)
{ {
/* Check if we read from the same index. */ /* Check if we read from the same index. */
...@@ -603,7 +611,9 @@ retry: ...@@ -603,7 +611,9 @@ retry:
DBUG_ASSERT((uint) keyno == table->file->get_index()); DBUG_ASSERT((uint) keyno == table->file->get_index());
if (table->file->inited != handler::NONE) if (table->file->inited != handler::NONE)
{ {
error=table->file->ha_index_prev(table->record[0]); if ((error= table->file->can_continue_handler_scan()))
break;
error= table->file->ha_index_prev(table->record[0]);
break; break;
} }
/* else fall through */ /* else fall through */
...@@ -673,8 +683,11 @@ retry: ...@@ -673,8 +683,11 @@ retry:
continue; continue;
if (error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE) if (error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE)
{ {
sql_print_error("mysql_ha_read: Got error %d when reading table '%s'", /* Don't give error in the log file for some expected problems */
error, tables->table_name); if (error != HA_ERR_RECORD_CHANGED && error != HA_ERR_WRONG_COMMAND)
sql_print_error("mysql_ha_read: Got error %d when reading "
"table '%s'",
error, tables->table_name);
table->file->print_error(error,MYF(0)); table->file->print_error(error,MYF(0));
goto err; goto err;
} }
......
...@@ -50,7 +50,7 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function, ...@@ -50,7 +50,7 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
switch (function) { switch (function) {
case HA_EXTRA_RESET_STATE: /* Reset state (don't free buffers) */ case HA_EXTRA_RESET_STATE: /* Reset state (don't free buffers) */
info->lastinx= 0; /* Use first index as def */ info->lastinx= ~0; /* Detect index changes */
info->last_search_keypage= info->cur_row.lastpos= HA_OFFSET_ERROR; info->last_search_keypage= info->cur_row.lastpos= HA_OFFSET_ERROR;
info->page_changed= 1; info->page_changed= 1;
/* Next/prev gives first/last */ /* Next/prev gives first/last */
...@@ -545,7 +545,7 @@ int maria_reset(MARIA_HA *info) ...@@ -545,7 +545,7 @@ int maria_reset(MARIA_HA *info)
#endif #endif
info->opt_flag&= ~(KEY_READ_USED | REMEMBER_OLD_POS); info->opt_flag&= ~(KEY_READ_USED | REMEMBER_OLD_POS);
info->quick_mode= 0; info->quick_mode= 0;
info->lastinx= 0; /* Use first index as def */ info->lastinx= ~0; /* detect index changes */
info->last_search_keypage= info->cur_row.lastpos= HA_OFFSET_ERROR; info->last_search_keypage= info->cur_row.lastpos= HA_OFFSET_ERROR;
info->page_changed= 1; info->page_changed= 1;
info->update= ((info->update & HA_STATE_CHANGED) | HA_STATE_NEXT_FOUND | info->update= ((info->update & HA_STATE_CHANGED) | HA_STATE_NEXT_FOUND |
......
...@@ -356,7 +356,7 @@ static int _ft2_search(FTB *ftb, FTB_WORD *ftbw, my_bool init_search) ...@@ -356,7 +356,7 @@ static int _ft2_search(FTB *ftb, FTB_WORD *ftbw, my_bool init_search)
{ {
ftbw->key_root=info->s->state.key_root[ftb->keynr]; ftbw->key_root=info->s->state.key_root[ftb->keynr];
ftbw->keyinfo=info->s->keyinfo+ftb->keynr; ftbw->keyinfo=info->s->keyinfo+ftb->keynr;
key.keyinfo= ftbw->keyinfo; info->last_key.keyinfo= key.keyinfo= ftbw->keyinfo;
key.data= ftbw->word; key.data= ftbw->word;
key.data_length= ftbw->len; key.data_length= ftbw->len;
key.ref_length= 0; key.ref_length= 0;
...@@ -380,7 +380,7 @@ static int _ft2_search(FTB *ftb, FTB_WORD *ftbw, my_bool init_search) ...@@ -380,7 +380,7 @@ static int _ft2_search(FTB *ftb, FTB_WORD *ftbw, my_bool init_search)
max_docid); max_docid);
} }
key.keyinfo= ftbw->keyinfo; info->last_key.keyinfo= key.keyinfo= ftbw->keyinfo;
key.data= lastkey_buf; key.data= lastkey_buf;
key.data_length= USE_WHOLE_KEY; key.data_length= USE_WHOLE_KEY;
key.ref_length= 0; key.ref_length= 0;
......
...@@ -130,6 +130,8 @@ static MARIA_HA *maria_clone_internal(MARIA_SHARE *share, const char *name, ...@@ -130,6 +130,8 @@ static MARIA_HA *maria_clone_internal(MARIA_SHARE *share, const char *name,
info.s=share; info.s=share;
info.cur_row.lastpos= HA_OFFSET_ERROR; info.cur_row.lastpos= HA_OFFSET_ERROR;
/* Impossible first index to force initialization in _ma_check_index() */
info.lastinx= ~0;
info.update= (short) (HA_STATE_NEXT_FOUND+HA_STATE_PREV_FOUND); info.update= (short) (HA_STATE_NEXT_FOUND+HA_STATE_PREV_FOUND);
info.opt_flag=READ_CHECK_USED; info.opt_flag=READ_CHECK_USED;
info.this_unique= (ulong) info.dfile.file; /* Uniq number in process */ info.this_unique= (ulong) info.dfile.file; /* Uniq number in process */
......
...@@ -43,7 +43,7 @@ int maria_rkey(MARIA_HA *info, uchar *buf, int inx, const uchar *key_data, ...@@ -43,7 +43,7 @@ int maria_rkey(MARIA_HA *info, uchar *buf, int inx, const uchar *key_data,
info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED); info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
info->last_key_func= search_flag; info->last_key_func= search_flag;
keyinfo= share->keyinfo + inx; keyinfo= info->last_key.keyinfo;
key_buff= info->lastkey_buff+info->s->base.max_key_length; key_buff= info->lastkey_buff+info->s->base.max_key_length;
......
...@@ -30,6 +30,7 @@ int maria_rnext(MARIA_HA *info, uchar *buf, int inx) ...@@ -30,6 +30,7 @@ int maria_rnext(MARIA_HA *info, uchar *buf, int inx)
uint flag; uint flag;
MARIA_SHARE *share= info->s; MARIA_SHARE *share= info->s;
MARIA_KEYDEF *keyinfo; MARIA_KEYDEF *keyinfo;
uint update_mask= HA_STATE_NEXT_FOUND;
DBUG_ENTER("maria_rnext"); DBUG_ENTER("maria_rnext");
if ((inx = _ma_check_index(info,inx)) < 0) if ((inx = _ma_check_index(info,inx)) < 0)
...@@ -61,6 +62,20 @@ int maria_rnext(MARIA_HA *info, uchar *buf, int inx) ...@@ -61,6 +62,20 @@ int maria_rnext(MARIA_HA *info, uchar *buf, int inx)
error= _ma_search_first(info, keyinfo, share->state.key_root[inx]); error= _ma_search_first(info, keyinfo, share->state.key_root[inx]);
break; break;
} }
/*
"search first" failed. This means we have no pivot for
"search next", or in other words MI_INFO::lastkey is
likely uninitialized.
Normally SQL layer would never request "search next" if
"search first" failed. But HANDLER may do anything.
As mi_rnext() without preceeding mi_rkey()/mi_rfirst()
equals to mi_rfirst(), we must restore original state
as if failing mi_rfirst() was not called.
*/
if (error)
update_mask|= HA_STATE_PREV_FOUND;
} }
else else
{ {
...@@ -104,7 +119,7 @@ int maria_rnext(MARIA_HA *info, uchar *buf, int inx) ...@@ -104,7 +119,7 @@ int maria_rnext(MARIA_HA *info, uchar *buf, int inx)
/* Don't clear if database-changed */ /* Don't clear if database-changed */
info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED); info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
info->update|= HA_STATE_NEXT_FOUND; info->update|= update_mask;
if (error) if (error)
{ {
......
...@@ -36,7 +36,7 @@ int maria_rsame(MARIA_HA *info, uchar *record, int inx) ...@@ -36,7 +36,7 @@ int maria_rsame(MARIA_HA *info, uchar *record, int inx)
{ {
DBUG_ENTER("maria_rsame"); DBUG_ENTER("maria_rsame");
if (inx != -1 && ! maria_is_key_active(info->s->state.key_map, inx)) if (inx >= 0 && !_ma_check_index(info, inx))
{ {
DBUG_PRINT("error", ("wrong index usage")); DBUG_PRINT("error", ("wrong index usage"));
DBUG_RETURN(my_errno=HA_ERR_WRONG_INDEX); DBUG_RETURN(my_errno=HA_ERR_WRONG_INDEX);
...@@ -55,8 +55,7 @@ int maria_rsame(MARIA_HA *info, uchar *record, int inx) ...@@ -55,8 +55,7 @@ int maria_rsame(MARIA_HA *info, uchar *record, int inx)
if (inx >= 0) if (inx >= 0)
{ {
MARIA_KEYDEF *keyinfo= info->s->keyinfo + inx; MARIA_KEYDEF *keyinfo= info->last_key.keyinfo;
info->lastinx= inx;
(*keyinfo->make_key)(info, &info->last_key, (uint) inx, (*keyinfo->make_key)(info, &info->last_key, (uint) inx,
info->lastkey_buff, record, info->lastkey_buff, record,
info->cur_row.lastpos, info->cur_row.lastpos,
......
...@@ -38,6 +38,8 @@ int _ma_check_index(MARIA_HA *info, int inx) ...@@ -38,6 +38,8 @@ int _ma_check_index(MARIA_HA *info, int inx)
if (info->lastinx != inx) /* Index changed */ if (info->lastinx != inx) /* Index changed */
{ {
info->lastinx = inx; info->lastinx = inx;
info->last_key.keyinfo= info->s->keyinfo + inx;
info->last_key.flag= 0;
info->page_changed=1; info->page_changed=1;
info->update= ((info->update & (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED)) | info->update= ((info->update & (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED)) |
HA_STATE_NEXT_FOUND | HA_STATE_PREV_FOUND); HA_STATE_NEXT_FOUND | HA_STATE_PREV_FOUND);
...@@ -180,7 +182,6 @@ static int _ma_search_no_save(register MARIA_HA *info, MARIA_KEY *key, ...@@ -180,7 +182,6 @@ static int _ma_search_no_save(register MARIA_HA *info, MARIA_KEY *key,
} }
} }
info->last_key.keyinfo= keyinfo;
if ((nextflag & (SEARCH_SMALLER | SEARCH_LAST)) && flag != 0) if ((nextflag & (SEARCH_SMALLER | SEARCH_LAST)) && flag != 0)
{ {
uint not_used[2]; uint not_used[2];
...@@ -1696,7 +1697,7 @@ int _ma_search_next(register MARIA_HA *info, MARIA_KEY *key, ...@@ -1696,7 +1697,7 @@ int _ma_search_next(register MARIA_HA *info, MARIA_KEY *key,
} }
tmp_key.data= lastkey; tmp_key.data= lastkey;
info->last_key.keyinfo= tmp_key.keyinfo= keyinfo; tmp_key.keyinfo= keyinfo;
if (nextflag & SEARCH_BIGGER) /* Next key */ if (nextflag & SEARCH_BIGGER) /* Next key */
{ {
...@@ -1778,8 +1779,6 @@ int _ma_search_first(MARIA_HA *info, MARIA_KEYDEF *keyinfo, ...@@ -1778,8 +1779,6 @@ int _ma_search_first(MARIA_HA *info, MARIA_KEYDEF *keyinfo,
first_pos= page.buff + share->keypage_header + page.node; first_pos= page.buff + share->keypage_header + page.node;
} while ((pos= _ma_kpos(page.node, first_pos)) != HA_OFFSET_ERROR); } while ((pos= _ma_kpos(page.node, first_pos)) != HA_OFFSET_ERROR);
info->last_key.keyinfo= keyinfo;
if (!(*keyinfo->get_key)(&info->last_key, page.flag, page.node, &first_pos)) if (!(*keyinfo->get_key)(&info->last_key, page.flag, page.node, &first_pos))
DBUG_RETURN(-1); /* Crashed */ DBUG_RETURN(-1); /* Crashed */
...@@ -1830,8 +1829,6 @@ int _ma_search_last(MARIA_HA *info, MARIA_KEYDEF *keyinfo, ...@@ -1830,8 +1829,6 @@ int _ma_search_last(MARIA_HA *info, MARIA_KEYDEF *keyinfo,
end_of_page= page.buff + page.size; end_of_page= page.buff + page.size;
} while ((pos= _ma_kpos(page.node, end_of_page)) != HA_OFFSET_ERROR); } while ((pos= _ma_kpos(page.node, end_of_page)) != HA_OFFSET_ERROR);
info->last_key.keyinfo= keyinfo;
if (!_ma_get_last_key(&info->last_key, &page, end_of_page)) if (!_ma_get_last_key(&info->last_key, &page, end_of_page))
DBUG_RETURN(-1); DBUG_RETURN(-1);
info->cur_row.lastpos= _ma_row_pos_from_key(&info->last_key); info->cur_row.lastpos= _ma_row_pos_from_key(&info->last_key);
......
...@@ -43,6 +43,7 @@ my_bool _ma_check_unique(MARIA_HA *info, MARIA_UNIQUEDEF *def, uchar *record, ...@@ -43,6 +43,7 @@ my_bool _ma_check_unique(MARIA_HA *info, MARIA_UNIQUEDEF *def, uchar *record,
/* The above changed info->lastkey_buff2. Inform maria_rnext_same(). */ /* The above changed info->lastkey_buff2. Inform maria_rnext_same(). */
info->update&= ~HA_STATE_RNEXT_SAME; info->update&= ~HA_STATE_RNEXT_SAME;
info->last_key.keyinfo= keyinfo;
DBUG_ASSERT(key.data_length == MARIA_UNIQUE_HASH_LENGTH); DBUG_ASSERT(key.data_length == MARIA_UNIQUE_HASH_LENGTH);
if (_ma_search(info, &key, SEARCH_FIND, info->s->state.key_root[def->key])) if (_ma_search(info, &key, SEARCH_FIND, info->s->state.key_root[def->key]))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment