mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 12:32:27 +01:00
b57ef6d3cd
Invalid memory read if HANDLER ... READ NEXT is executed after failed (e.g. empty table) HANDLER ... READ FIRST. The problem was that we attempted to perform READ NEXT, whereas there is no pivot available from failed READ FIRST. With this fix READ NEXT after failed READ FIRST equals to READ FIRST. This bug affects MyISAM tables only. mysql-test/r/gis-rtree.result: Restore a test case for BUG51357. mysql-test/r/handler_myisam.result: A test case for BUG#51877. mysql-test/t/gis-rtree.test: Restore a test case for BUG51357. mysql-test/t/handler_myisam.test: A test case for BUG#51877. storage/myisam/mi_rnext.c: "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.
51 lines
1.2 KiB
Text
51 lines
1.2 KiB
Text
# t/handler_myisam.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 include/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
|
|
|
|
--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#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 End of 5.1 tests
|