Commit 058916ae authored by Michael Widenius's avatar Michael Widenius

Fix for bug#39226 Maria: crash with FLUSH TABLES WITH READ LOCK after LOCK TABLES

- The problem was that we didn't inform the handler that we are going to close tables that are locked and may have (at least in Maria) be part of an active transaction.
Fix for Bug#39227 Maria: crash with ALTER TABLE PARTITION
Fix for Bug #39987 main.partition_not_windows fails under debug build
Fixed some compiler errors & warnings found by pushbuild

include/my_base.h:
  Added HA_EXTRA_PREPARE_FOR_FORCED_CLOSE for signaling the handler that the file will be forced closed
include/my_global.h:
  Removed 'register' from 'swap_variables' as this gives a warnings when the variables are structs. Compilers should also now be smart enough to figure out this themselves
mysql-test/r/subselect_debug.result:
  Reset value of the debug variable;  Without setting this the subselect_innodb test will fail when run after this one
mysql-test/suite/maria/r/maria.result:
  Merged test with myisam.test
  Added tests for new fixed bugs
mysql-test/suite/maria/t/maria.test:
  Merged test with myisam.test
  Added tests for new fixed bugs
mysql-test/t/subselect_debug.test:
  Reset value of the debug variable;  Without setting this the subselect_innodb test will fail when run after this one
mysys/my_uuid.c:
  Fixed compiler error on windows
sql/ha_partition.cc:
  Added support for the new extra flag: HA_EXTRA_PREPARE_FOR_FORCED_CLOSE (Bug #39226)
  Ensure that we call extra() for HA_EXTRA_PREPARE_FOR_DROP (Bug#39227)
sql/mysqld.cc:
  Fix for Bug #39987 main.partition_not_windows fails under debug build
  The problem was that when compiling for purify/valgrind realpath() is not used, which causes test_if_data_home_dir to fail when it shouldn't
sql/sql_base.cc:
  Call HA_EXTRA_PREPARE_FOR_FORCED_CLOSE for tables that are locked but we are going to force close without doing a commit
sql/sql_parse.cc:
  More DBUG_PRINT. Fixed comments
storage/maria/ma_extra.c:
  If HA_EXTRA_PREPARE_FOR_FORCED_CLOSE is called and the table is part of a transaction, remove the table from beeing part of a transaction.
  This is safe as this is only used as part of flush tables or when the table is not part of a transaction
storage/myisam/mi_open.c:
  Indentation fix
unittest/mysys/waiting_threads-t.c:
  Remove not needed 'volatile' to get rid of compiler warnings on windows
parent 0e43d765
...@@ -195,7 +195,9 @@ enum ha_extra_function { ...@@ -195,7 +195,9 @@ enum ha_extra_function {
begin and end of a statement. begin and end of a statement.
*/ */
HA_EXTRA_ATTACH_CHILDREN, HA_EXTRA_ATTACH_CHILDREN,
HA_EXTRA_DETACH_CHILDREN HA_EXTRA_DETACH_CHILDREN,
/* Inform handler we will force a close as part of flush */
HA_EXTRA_PREPARE_FOR_FORCED_CLOSE
}; };
/* Compatible option, to be deleted in 6.0 */ /* Compatible option, to be deleted in 6.0 */
......
...@@ -579,7 +579,7 @@ typedef unsigned short ushort; ...@@ -579,7 +579,7 @@ typedef unsigned short ushort;
#define CMP_NUM(a,b) (((a) < (b)) ? -1 : ((a) == (b)) ? 0 : 1) #define CMP_NUM(a,b) (((a) < (b)) ? -1 : ((a) == (b)) ? 0 : 1)
#define sgn(a) (((a) < 0) ? -1 : ((a) > 0) ? 1 : 0) #define sgn(a) (((a) < 0) ? -1 : ((a) > 0) ? 1 : 0)
#define swap_variables(t, a, b) { register t swap_dummy; swap_dummy= a; a= b; b= swap_dummy; } #define swap_variables(t, a, b) { t swap_dummy; swap_dummy= a; a= b; b= swap_dummy; }
#define test(a) ((a) ? 1 : 0) #define test(a) ((a) ? 1 : 0)
#define set_if_bigger(a,b) do { if ((a) < (b)) (a)=(b); } while(0) #define set_if_bigger(a,b) do { if ((a) < (b)) (a)=(b); } while(0)
#define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0) #define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0)
......
CREATE TABLE t1(id INT); CREATE TABLE t1(id INT);
INSERT INTO t1 VALUES (1),(2),(3),(4); INSERT INTO t1 VALUES (1),(2),(3),(4);
INSERT INTO t1 SELECT a.id FROM t1 a,t1 b,t1 c,t1 d; INSERT INTO t1 SELECT a.id FROM t1 a,t1 b,t1 c,t1 d;
SET @orig_debug=@@debug;
SET SESSION debug="d,subselect_exec_fail"; SET SESSION debug="d,subselect_exec_fail";
SELECT SUM(EXISTS(SELECT RAND() FROM t1)) FROM t1; SELECT SUM(EXISTS(SELECT RAND() FROM t1)) FROM t1;
SUM(EXISTS(SELECT RAND() FROM t1)) SUM(EXISTS(SELECT RAND() FROM t1))
...@@ -8,5 +9,5 @@ SUM(EXISTS(SELECT RAND() FROM t1)) ...@@ -8,5 +9,5 @@ SUM(EXISTS(SELECT RAND() FROM t1))
SELECT REVERSE(EXISTS(SELECT RAND() FROM t1)); SELECT REVERSE(EXISTS(SELECT RAND() FROM t1));
REVERSE(EXISTS(SELECT RAND() FROM t1)) REVERSE(EXISTS(SELECT RAND() FROM t1))
0 0
SET SESSION debug=DEFAULT; SET SESSION debug=@orig_debug;
DROP TABLE t1; DROP TABLE t1;
...@@ -1887,6 +1887,287 @@ t1 CREATE TABLE `t1` ( ...@@ -1887,6 +1887,287 @@ t1 CREATE TABLE `t1` (
KEY `b` (`b`) KEY_BLOCK_SIZE=8192 KEY `b` (`b`) KEY_BLOCK_SIZE=8192
) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=0 KEY_BLOCK_SIZE=16384 ) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=0 KEY_BLOCK_SIZE=16384
drop table t1; drop table t1;
create table t1 (a int not null, key `a` (a) key_block_size=512);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
KEY `a` (`a`) KEY_BLOCK_SIZE=8192
) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=0
drop table t1;
create table t1 (a varchar(2048), key `a` (a) key_block_size=1000000000000000000);
Warnings:
Warning 1071 Specified key was too long; max key length is 1112 bytes
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` varchar(2048) DEFAULT NULL,
KEY `a` (`a`(1112)) KEY_BLOCK_SIZE=8192
) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=0
drop table t1;
create table t1 (a int not null, key `a` (a) key_block_size=1025);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
KEY `a` (`a`) KEY_BLOCK_SIZE=8192
) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=0
drop table t1;
create table t1 (a int not null, key key_block_size=1024 (a));
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 '=1024 (a))' at line 1
create table t1 (a int not null, key `a` key_block_size=1024 (a));
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 'key_block_size=1024 (a))' at line 1
CREATE TABLE t1 (
c1 INT,
c2 VARCHAR(300),
KEY (c1) KEY_BLOCK_SIZE 1024,
KEY (c2) KEY_BLOCK_SIZE 8192
);
INSERT INTO t1 VALUES (10, REPEAT('a', CEIL(RAND(10) * 300))),
(11, REPEAT('b', CEIL(RAND() * 300))),
(12, REPEAT('c', CEIL(RAND() * 300))),
(13, REPEAT('d', CEIL(RAND() * 300))),
(14, REPEAT('e', CEIL(RAND() * 300))),
(15, REPEAT('f', CEIL(RAND() * 300))),
(16, REPEAT('g', CEIL(RAND() * 300))),
(17, REPEAT('h', CEIL(RAND() * 300))),
(18, REPEAT('i', CEIL(RAND() * 300))),
(19, REPEAT('j', CEIL(RAND() * 300))),
(20, REPEAT('k', CEIL(RAND() * 300))),
(21, REPEAT('l', CEIL(RAND() * 300))),
(22, REPEAT('m', CEIL(RAND() * 300))),
(23, REPEAT('n', CEIL(RAND() * 300))),
(24, REPEAT('o', CEIL(RAND() * 300))),
(25, REPEAT('p', CEIL(RAND() * 300))),
(26, REPEAT('q', CEIL(RAND() * 300))),
(27, REPEAT('r', CEIL(RAND() * 300))),
(28, REPEAT('s', CEIL(RAND() * 300))),
(29, REPEAT('t', CEIL(RAND() * 300))),
(30, REPEAT('u', CEIL(RAND() * 300))),
(31, REPEAT('v', CEIL(RAND() * 300))),
(32, REPEAT('w', CEIL(RAND() * 300))),
(33, REPEAT('x', CEIL(RAND() * 300))),
(34, REPEAT('y', CEIL(RAND() * 300))),
(35, REPEAT('z', CEIL(RAND() * 300)));
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
REPAIR TABLE t1;
Table Op Msg_type Msg_text
test.t1 repair status OK
DELETE FROM t1 WHERE c1 >= 10;
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
DROP TABLE t1;
CREATE TABLE t1 (
c1 CHAR(130),
c2 VARCHAR(1)
) ENGINE=maria;
INSERT INTO t1 VALUES(REPEAT("a",128), 'b');
SELECT COUNT(*) FROM t1;
COUNT(*)
1
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
REPAIR TABLE t1;
Table Op Msg_type Msg_text
test.t1 repair status OK
SELECT COUNT(*) FROM t1;
COUNT(*)
1
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
DROP TABLE t1;
CREATE TABLE t1 (
c1 CHAR(130),
c2 VARCHAR(1)
) ENGINE=maria;
INSERT INTO t1 VALUES(REPEAT("a",128), 'b');
SELECT COUNT(*) FROM t1;
COUNT(*)
1
CHECK TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 check status OK
REPAIR TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 repair status OK
SELECT COUNT(*) FROM t1;
COUNT(*)
1
CHECK TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 check status OK
DROP TABLE t1;
CREATE TABLE t1 (
c1 CHAR(130),
c2 VARCHAR(1)
) ENGINE=maria;
INSERT INTO t1 VALUES(REPEAT("a",128), 'b');
INSERT INTO t1 VALUES('b', 'b');
INSERT INTO t1 VALUES('c', 'b');
DELETE FROM t1 WHERE c1='b';
SELECT COUNT(*) FROM t1;
COUNT(*)
2
OPTIMIZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 optimize status OK
SELECT COUNT(*) FROM t1;
COUNT(*)
2
DROP TABLE t1;
CREATE TABLE t1 (
c1 CHAR(130),
c2 VARCHAR(1),
KEY (c1)
) ENGINE=maria;
# Insert 100 rows. Query log disabled.
UPDATE t1 SET c1=REPEAT("a",128) LIMIT 90;
SELECT COUNT(*) FROM t1;
COUNT(*)
100
ALTER TABLE t1 ENGINE=maria;
SELECT COUNT(*) FROM t1;
COUNT(*)
100
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
CHECK TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 check status OK
DROP TABLE t1;
CREATE TABLE t1 (
c1 CHAR(50),
c2 VARCHAR(1)
) ENGINE=maria DEFAULT CHARSET UTF8;
INSERT INTO t1 VALUES(REPEAT(_utf8 x'e0ae85',43), 'b');
SELECT COUNT(*) FROM t1;
COUNT(*)
1
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
REPAIR TABLE t1;
Table Op Msg_type Msg_text
test.t1 repair status OK
SELECT COUNT(*) FROM t1;
COUNT(*)
1
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
DROP TABLE t1;
CREATE TABLE t1 (
c1 CHAR(50),
c2 VARCHAR(1)
) ENGINE=maria DEFAULT CHARSET UTF8;
INSERT INTO t1 VALUES(REPEAT(_utf8 x'e0ae85',43), 'b');
SELECT COUNT(*) FROM t1;
COUNT(*)
1
CHECK TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 check status OK
REPAIR TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 repair status OK
SELECT COUNT(*) FROM t1;
COUNT(*)
1
CHECK TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 check status OK
DROP TABLE t1;
CREATE TABLE t1 (
c1 CHAR(50),
c2 VARCHAR(1)
) ENGINE=maria DEFAULT CHARSET UTF8;
INSERT INTO t1 VALUES(REPEAT(_utf8 x'e0ae85',43), 'b');
INSERT INTO t1 VALUES('b', 'b');
INSERT INTO t1 VALUES('c', 'b');
DELETE FROM t1 WHERE c1='b';
SELECT COUNT(*) FROM t1;
COUNT(*)
2
OPTIMIZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 optimize status OK
SELECT COUNT(*) FROM t1;
COUNT(*)
2
DROP TABLE t1;
CREATE TABLE t1 (
c1 CHAR(50),
c2 VARCHAR(1),
KEY (c1)
) ENGINE=maria DEFAULT CHARSET UTF8;
# Insert 100 rows. Query log disabled.
UPDATE t1 SET c1=REPEAT(_utf8 x'e0ae85',43) LIMIT 90;
SELECT COUNT(*) FROM t1;
COUNT(*)
100
ALTER TABLE t1 ENGINE=maria;
SELECT COUNT(*) FROM t1;
COUNT(*)
100
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
CHECK TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 check status OK
DROP TABLE t1;
CREATE TABLE t1 (
c1 VARCHAR(10) NOT NULL,
c2 CHAR(10) DEFAULT NULL,
c3 VARCHAR(10) NOT NULL,
KEY (c1),
KEY (c2)
) ENGINE=maria DEFAULT CHARSET=utf8 PACK_KEYS=0;
MARIA file: MYSQLTEST_VARDIR/master-data/test/t1
Record format: Block
Crashsafe: yes
Character set: utf8_general_ci (33)
Data records: 0 Deleted blocks: 0
Block_size: 8192
Recordlength: 99
table description:
Key Start Len Index Type
1 2 30 multip. varchar
2 33 30 multip. char NULL
DROP TABLE t1;
create table t1 (n int not null, c char(1)) transactional=1;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`n` int(11) NOT NULL,
`c` char(1) DEFAULT NULL
) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=0 TRANSACTIONAL=1
drop table t1;
CREATE TABLE t1 (line LINESTRING NOT NULL) engine=maria;
INSERT INTO t1 VALUES (GeomFromText("POINT(0 0)"));
checksum table t1;
Table Checksum
test.t1 326284887
CREATE TABLE t2 (line LINESTRING NOT NULL) engine=maria;
INSERT INTO t2 VALUES (GeomFromText("POINT(0 0)"));
checksum table t2;
Table Checksum
test.t2 326284887
CREATE TABLE t3 select * from t1;
checksum table t3;
Table Checksum
test.t3 326284887
drop table t1,t2,t3;
End of 5.1 tests
create table t2(a varchar(255),key(a))engine=maria row_format=dynamic transactional=0; create table t2(a varchar(255),key(a))engine=maria row_format=dynamic transactional=0;
insert into t2 values (repeat('o',124)), (repeat('h',226)), (repeat('i',236)), insert into t2 values (repeat('o',124)), (repeat('h',226)), (repeat('i',236)),
(repeat('l',234)), (repeat('b',13)), (repeat('g',236)), (repeat('y',205)), (repeat('l',234)), (repeat('b',13)), (repeat('g',236)), (repeat('y',205)),
...@@ -2309,3 +2590,14 @@ ALTER TABLE t1 CHANGE c d varchar(10); ...@@ -2309,3 +2590,14 @@ ALTER TABLE t1 CHANGE c d varchar(10);
affected rows: 0 affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0 info: Records: 0 Duplicates: 0 Warnings: 0
drop table t1; drop table t1;
create table t1 (s1 int);
insert into t1 values (1);
alter table t1 partition by list (s1) (partition p1 values in (2));
ERROR HY000: Table has no partition for value 1
drop table t1;
create table t1 (c1 int);
create table t2 (c1 int);
lock table t1 read, t2 read;
flush tables with read lock;
unlock tables;
drop table t1, t2;
...@@ -1087,7 +1087,7 @@ CHECK TABLE t1 EXTENDED; ...@@ -1087,7 +1087,7 @@ CHECK TABLE t1 EXTENDED;
DROP TABLE t1; DROP TABLE t1;
# #
# Bug#28837: Maria storage engine error (134) doing delete with self-join # Test doing delete with self-join
# #
CREATE TABLE t1 (id int NOT NULL, ref int NOT NULL, INDEX (id)); CREATE TABLE t1 (id int NOT NULL, ref int NOT NULL, INDEX (id));
...@@ -1163,6 +1163,274 @@ create table t1 (a int not null, b int, key (a) key_block_size=1024, key(b) key_ ...@@ -1163,6 +1163,274 @@ create table t1 (a int not null, b int, key (a) key_block_size=1024, key(b) key_
show create table t1; show create table t1;
drop table t1; drop table t1;
# Test limits and errors of key_block_size
create table t1 (a int not null, key `a` (a) key_block_size=512);
show create table t1;
drop table t1;
create table t1 (a varchar(2048), key `a` (a) key_block_size=1000000000000000000);
show create table t1;
drop table t1;
create table t1 (a int not null, key `a` (a) key_block_size=1025);
show create table t1;
drop table t1;
--error 1064
create table t1 (a int not null, key key_block_size=1024 (a));
--error 1064
create table t1 (a int not null, key `a` key_block_size=1024 (a));
#
# Bug#22119 - Changing MI_KEY_BLOCK_LENGTH makes a wrong myisamchk
#
CREATE TABLE t1 (
c1 INT,
c2 VARCHAR(300),
KEY (c1) KEY_BLOCK_SIZE 1024,
KEY (c2) KEY_BLOCK_SIZE 8192
);
INSERT INTO t1 VALUES (10, REPEAT('a', CEIL(RAND(10) * 300))),
(11, REPEAT('b', CEIL(RAND() * 300))),
(12, REPEAT('c', CEIL(RAND() * 300))),
(13, REPEAT('d', CEIL(RAND() * 300))),
(14, REPEAT('e', CEIL(RAND() * 300))),
(15, REPEAT('f', CEIL(RAND() * 300))),
(16, REPEAT('g', CEIL(RAND() * 300))),
(17, REPEAT('h', CEIL(RAND() * 300))),
(18, REPEAT('i', CEIL(RAND() * 300))),
(19, REPEAT('j', CEIL(RAND() * 300))),
(20, REPEAT('k', CEIL(RAND() * 300))),
(21, REPEAT('l', CEIL(RAND() * 300))),
(22, REPEAT('m', CEIL(RAND() * 300))),
(23, REPEAT('n', CEIL(RAND() * 300))),
(24, REPEAT('o', CEIL(RAND() * 300))),
(25, REPEAT('p', CEIL(RAND() * 300))),
(26, REPEAT('q', CEIL(RAND() * 300))),
(27, REPEAT('r', CEIL(RAND() * 300))),
(28, REPEAT('s', CEIL(RAND() * 300))),
(29, REPEAT('t', CEIL(RAND() * 300))),
(30, REPEAT('u', CEIL(RAND() * 300))),
(31, REPEAT('v', CEIL(RAND() * 300))),
(32, REPEAT('w', CEIL(RAND() * 300))),
(33, REPEAT('x', CEIL(RAND() * 300))),
(34, REPEAT('y', CEIL(RAND() * 300))),
(35, REPEAT('z', CEIL(RAND() * 300)));
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
CHECK TABLE t1;
REPAIR TABLE t1;
DELETE FROM t1 WHERE c1 >= 10;
CHECK TABLE t1;
DROP TABLE t1;
#
# Bug#33222 - myisam-table drops rows when column is added
# and a char-field > 128 exists
#
# Test #1 - CHECK TABLE sees wrong record, REPAR TABLE deletes it.
# Using a CHAR column that can have > 127 characters.
# Using a VARCHAR to create a table with dynamic row format.
CREATE TABLE t1 (
c1 CHAR(130),
c2 VARCHAR(1)
) ENGINE=maria;
INSERT INTO t1 VALUES(REPEAT("a",128), 'b');
SELECT COUNT(*) FROM t1;
CHECK TABLE t1;
REPAIR TABLE t1;
SELECT COUNT(*) FROM t1;
CHECK TABLE t1;
DROP TABLE t1;
#
# Test #2 - same as test #1, but using EXTENDED.
# Using a CHAR column that can have > 127 characters.
# Using a VARCHAR to create a table with dynamic row format.
CREATE TABLE t1 (
c1 CHAR(130),
c2 VARCHAR(1)
) ENGINE=maria;
INSERT INTO t1 VALUES(REPEAT("a",128), 'b');
SELECT COUNT(*) FROM t1;
CHECK TABLE t1 EXTENDED;
REPAIR TABLE t1 EXTENDED;
SELECT COUNT(*) FROM t1;
CHECK TABLE t1 EXTENDED;
DROP TABLE t1;
#
# Test #3 - same as test #1, but using OPTIMIZE TABLE.
# Using a CHAR column that can have > 127 characters.
# Using a VARCHAR to create a table with dynamic row format.
CREATE TABLE t1 (
c1 CHAR(130),
c2 VARCHAR(1)
) ENGINE=maria;
INSERT INTO t1 VALUES(REPEAT("a",128), 'b');
# Insert more rows and delete one in the middle to force optimize.
INSERT INTO t1 VALUES('b', 'b');
INSERT INTO t1 VALUES('c', 'b');
DELETE FROM t1 WHERE c1='b';
SELECT COUNT(*) FROM t1;
OPTIMIZE TABLE t1;
SELECT COUNT(*) FROM t1;
DROP TABLE t1;
#
# Test #4 - ALTER TABLE deletes rows.
# Using a CHAR column that can have > 127 characters.
# Using a VARCHAR to create a table with dynamic row format.
# Using an index which can be disabled during bulk insert.
CREATE TABLE t1 (
c1 CHAR(130),
c2 VARCHAR(1),
KEY (c1)
) ENGINE=maria;
#
# Insert 100 rows. This turns bulk insert on during the copy phase of
# ALTER TABLE. Bulk insert disables keys before the insert and re-enables
# them by repair after the insert.
--disable_query_log
let $count= 100;
--echo # Insert $count rows. Query log disabled.
while ($count)
{
INSERT INTO t1 VALUES ('a', 'b');
dec $count;
}
--enable_query_log
#
# Change most of the rows into long character values with > 127 characters.
UPDATE t1 SET c1=REPEAT("a",128) LIMIT 90;
SELECT COUNT(*) FROM t1;
ALTER TABLE t1 ENGINE=maria;
#
# With bug present, this shows that all long rows are gone.
SELECT COUNT(*) FROM t1;
CHECK TABLE t1;
CHECK TABLE t1 EXTENDED;
DROP TABLE t1;
#
# Test #5 - same as test #1 but UTF-8.
# Using a CHAR column that can have > 127 characters.
# Using a VARCHAR to create a table with dynamic row format.
CREATE TABLE t1 (
c1 CHAR(50),
c2 VARCHAR(1)
) ENGINE=maria DEFAULT CHARSET UTF8;
# Using Tamil Letter A, Unicode U+0B85
INSERT INTO t1 VALUES(REPEAT(_utf8 x'e0ae85',43), 'b');
SELECT COUNT(*) FROM t1;
CHECK TABLE t1;
REPAIR TABLE t1;
SELECT COUNT(*) FROM t1;
CHECK TABLE t1;
DROP TABLE t1;
#
# Test #6 - same as test #2, but UTF-8.
# Using a CHAR column that can have > 127 characters.
# Using a VARCHAR to create a table with dynamic row format.
CREATE TABLE t1 (
c1 CHAR(50),
c2 VARCHAR(1)
) ENGINE=maria DEFAULT CHARSET UTF8;
# Using Tamil Letter A, Unicode U+0B85
INSERT INTO t1 VALUES(REPEAT(_utf8 x'e0ae85',43), 'b');
SELECT COUNT(*) FROM t1;
CHECK TABLE t1 EXTENDED;
REPAIR TABLE t1 EXTENDED;
SELECT COUNT(*) FROM t1;
CHECK TABLE t1 EXTENDED;
DROP TABLE t1;
#
# Test #7 - same as test #3, but UTF-8.
# Using a CHAR column that can have > 127 characters.
# Using a VARCHAR to create a table with dynamic row format.
CREATE TABLE t1 (
c1 CHAR(50),
c2 VARCHAR(1)
) ENGINE=maria DEFAULT CHARSET UTF8;
# Using Tamil Letter A, Unicode U+0B85
INSERT INTO t1 VALUES(REPEAT(_utf8 x'e0ae85',43), 'b');
# Insert more rows and delete one in the middle to force optimize.
INSERT INTO t1 VALUES('b', 'b');
INSERT INTO t1 VALUES('c', 'b');
DELETE FROM t1 WHERE c1='b';
SELECT COUNT(*) FROM t1;
OPTIMIZE TABLE t1;
SELECT COUNT(*) FROM t1;
DROP TABLE t1;
#
# Test #8 - same as test #4, but UTF-8.
# Using a CHAR column that can have > 42 UTF-8 characters.
# Using a VARCHAR to create a table with dynamic row format.
# Using an index which can be disabled during bulk insert.
CREATE TABLE t1 (
c1 CHAR(50),
c2 VARCHAR(1),
KEY (c1)
) ENGINE=maria DEFAULT CHARSET UTF8;
#
# Insert 100 rows. This turns bulk insert on during the copy phase of
# ALTER TABLE. Bulk insert disables keys before the insert and re-enables
# them by repair after the insert.
--disable_query_log
let $count= 100;
--echo # Insert $count rows. Query log disabled.
while ($count)
{
INSERT INTO t1 VALUES ('a', 'b');
dec $count;
}
--enable_query_log
#
# Change most of the rows into long character values with > 42 characters.
# Using Tamil Letter A, Unicode U+0B85
UPDATE t1 SET c1=REPEAT(_utf8 x'e0ae85',43) LIMIT 90;
SELECT COUNT(*) FROM t1;
ALTER TABLE t1 ENGINE=maria;
#
# With bug present, this shows that all long rows are gone.
SELECT COUNT(*) FROM t1;
CHECK TABLE t1;
CHECK TABLE t1 EXTENDED;
DROP TABLE t1;
#
# Bug#29182 - MyISAMCHK reports wrong character set
#
CREATE TABLE t1 (
c1 VARCHAR(10) NOT NULL,
c2 CHAR(10) DEFAULT NULL,
c3 VARCHAR(10) NOT NULL,
KEY (c1),
KEY (c2)
) ENGINE=maria DEFAULT CHARSET=utf8 PACK_KEYS=0;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MARIA_CHK -d $MYSQLTEST_VARDIR/master-data/test/t1
DROP TABLE t1;
# Test warnings with transactional=1 with MyISAM
#
create table t1 (n int not null, c char(1)) transactional=1;
show create table t1;
drop table t1;
#
# Test of BUG#35570 CHECKSUM TABLE unreliable if LINESTRING field
# (same content / differen checksum)
#
CREATE TABLE t1 (line LINESTRING NOT NULL) engine=maria;
INSERT INTO t1 VALUES (GeomFromText("POINT(0 0)"));
checksum table t1;
CREATE TABLE t2 (line LINESTRING NOT NULL) engine=maria;
INSERT INTO t2 VALUES (GeomFromText("POINT(0 0)"));
checksum table t2;
CREATE TABLE t3 select * from t1;
checksum table t3;
drop table t1,t2,t3;
--echo End of 5.1 tests
# #
# from bug37276_reduced_corruption.sql # from bug37276_reduced_corruption.sql
# #
...@@ -1598,3 +1866,23 @@ INSERT INTO t1 VALUES (1,"1"); ...@@ -1598,3 +1866,23 @@ INSERT INTO t1 VALUES (1,"1");
ALTER TABLE t1 CHANGE c d varchar(10); ALTER TABLE t1 CHANGE c d varchar(10);
--disable_info --disable_info
drop table t1; drop table t1;
#
# Bug #39227 Maria: crash with ALTER TABLE PARTITION
#
create table t1 (s1 int);
insert into t1 values (1);
--error ER_NO_PARTITION_FOR_GIVEN_VALUE
alter table t1 partition by list (s1) (partition p1 values in (2));
drop table t1;
#
# Bug #39226 Maria: crash with FLUSH TABLES WITH READ LOCK after LOCK TABLES
create table t1 (c1 int);
create table t2 (c1 int);
lock table t1 read, t2 read;
flush tables with read lock;
unlock tables;
drop table t1, t2;
...@@ -9,8 +9,9 @@ CREATE TABLE t1(id INT); ...@@ -9,8 +9,9 @@ CREATE TABLE t1(id INT);
INSERT INTO t1 VALUES (1),(2),(3),(4); INSERT INTO t1 VALUES (1),(2),(3),(4);
INSERT INTO t1 SELECT a.id FROM t1 a,t1 b,t1 c,t1 d; INSERT INTO t1 SELECT a.id FROM t1 a,t1 b,t1 c,t1 d;
# Setup the mysqld to crash at certain point # Setup the mysqld to crash at certain point
SET @orig_debug=@@debug;
SET SESSION debug="d,subselect_exec_fail"; SET SESSION debug="d,subselect_exec_fail";
SELECT SUM(EXISTS(SELECT RAND() FROM t1)) FROM t1; SELECT SUM(EXISTS(SELECT RAND() FROM t1)) FROM t1;
SELECT REVERSE(EXISTS(SELECT RAND() FROM t1)); SELECT REVERSE(EXISTS(SELECT RAND() FROM t1));
SET SESSION debug=DEFAULT; SET SESSION debug=@orig_debug;
DROP TABLE t1; DROP TABLE t1;
...@@ -145,11 +145,12 @@ void my_uuid(uchar *to) ...@@ -145,11 +145,12 @@ void my_uuid(uchar *to)
*/ */
if (nanoseq) if (nanoseq)
{ {
long delta;
DBUG_ASSERT((tv > uuid_time) && (nanoseq > 0)); DBUG_ASSERT((tv > uuid_time) && (nanoseq > 0));
/* /*
-1 so we won't make tv= uuid_time for nanoseq >= (tv - uuid_time) -1 so we won't make tv= uuid_time for nanoseq >= (tv - uuid_time)
*/ */
long delta= min(nanoseq, tv - uuid_time -1); delta= min(nanoseq, tv - uuid_time -1);
tv-= delta; tv-= delta;
nanoseq-= delta; nanoseq-= delta;
} }
......
...@@ -5042,6 +5042,7 @@ int ha_partition::extra(enum ha_extra_function operation) ...@@ -5042,6 +5042,7 @@ int ha_partition::extra(enum ha_extra_function operation)
case HA_EXTRA_KEYREAD: case HA_EXTRA_KEYREAD:
case HA_EXTRA_NO_KEYREAD: case HA_EXTRA_NO_KEYREAD:
case HA_EXTRA_FLUSH: case HA_EXTRA_FLUSH:
case HA_EXTRA_PREPARE_FOR_FORCED_CLOSE:
DBUG_RETURN(loop_extra(operation)); DBUG_RETURN(loop_extra(operation));
/* Category 2), used by non-MyISAM handlers */ /* Category 2), used by non-MyISAM handlers */
...@@ -5065,8 +5066,7 @@ int ha_partition::extra(enum ha_extra_function operation) ...@@ -5065,8 +5066,7 @@ int ha_partition::extra(enum ha_extra_function operation)
case HA_EXTRA_PREPARE_FOR_DROP: case HA_EXTRA_PREPARE_FOR_DROP:
case HA_EXTRA_FLUSH_CACHE: case HA_EXTRA_FLUSH_CACHE:
{ {
if (m_myisam) DBUG_RETURN(loop_extra(operation));
DBUG_RETURN(loop_extra(operation));
break; break;
} }
case HA_EXTRA_CACHE: case HA_EXTRA_CACHE:
...@@ -5260,8 +5260,8 @@ int ha_partition::loop_extra(enum ha_extra_function operation) ...@@ -5260,8 +5260,8 @@ int ha_partition::loop_extra(enum ha_extra_function operation)
DBUG_ENTER("ha_partition::loop_extra()"); DBUG_ENTER("ha_partition::loop_extra()");
/* /*
TODO, 5.2: this is where you could possibly add optimisations to add the bitmap TODO, 5.2: this is where you could possibly add optimisations to add the
_if_ a SELECT. bitmap _if_ a SELECT.
*/ */
for (file= m_file; *file; file++) for (file= m_file; *file; file++)
{ {
......
...@@ -7487,7 +7487,10 @@ static void mysql_init_variables(void) ...@@ -7487,7 +7487,10 @@ static void mysql_init_variables(void)
/* Things reset to zero */ /* Things reset to zero */
opt_skip_slave_start= opt_reckless_slave = 0; opt_skip_slave_start= opt_reckless_slave = 0;
mysql_home[0]= pidfile_name[0]= log_error_file[0]= 0; mysql_home[0]= pidfile_name[0]= log_error_file[0]= 0;
#if defined(HAVE_REALPATH) && !defined(HAVE_purify) && !defined(HAVE_BROKEN_REALPATH)
/* We can only test for sub paths if my_symlink.c is using realpath */
myisam_test_invalid_symlink= test_if_data_home_dir; myisam_test_invalid_symlink= test_if_data_home_dir;
#endif
opt_log= opt_slow_log= 0; opt_log= opt_slow_log= 0;
opt_update_log= 0; opt_update_log= 0;
log_output_options= find_bit_type(log_output_str, &log_output_typelib); log_output_options= find_bit_type(log_output_str, &log_output_typelib);
......
...@@ -3426,6 +3426,11 @@ static void close_old_data_files(THD *thd, TABLE *table, bool morph_locks, ...@@ -3426,6 +3426,11 @@ static void close_old_data_files(THD *thd, TABLE *table, bool morph_locks,
TABLE *ulcktbl= table->parent ? table->parent : table; TABLE *ulcktbl= table->parent ? table->parent : table;
if (ulcktbl->lock_count) if (ulcktbl->lock_count)
{ {
/*
Inform handler that we will do a close even if the table may be
locked or part of a transaction
*/
table->file->extra(HA_EXTRA_PREPARE_FOR_FORCED_CLOSE);
/* /*
Wake up threads waiting for table-level lock on this table Wake up threads waiting for table-level lock on this table
so they won't sneak in when we will temporarily remove our so they won't sneak in when we will temporarily remove our
......
...@@ -7477,15 +7477,14 @@ bool check_string_char_length(LEX_STRING *str, const char *err_msg, ...@@ -7477,15 +7477,14 @@ bool check_string_char_length(LEX_STRING *str, const char *err_msg,
/* /*
Check if path does not contain mysql data home directory Check if path does not contain mysql data home directory
SYNOPSIS SYNOPSIS
test_if_data_home_dir() test_if_data_home_dir()
dir directory dir directory
conv_home_dir converted data home directory
home_dir_len converted data home directory length
RETURN VALUES RETURN VALUES
0 ok 0 ok
1 error 1 error ; Given path contains data directory
*/ */
C_MODE_START C_MODE_START
...@@ -7513,11 +7512,17 @@ int test_if_data_home_dir(const char *dir) ...@@ -7513,11 +7512,17 @@ int test_if_data_home_dir(const char *dir)
mysql_unpacked_real_data_home_len, mysql_unpacked_real_data_home_len,
(const uchar*) mysql_unpacked_real_data_home, (const uchar*) mysql_unpacked_real_data_home,
mysql_unpacked_real_data_home_len)) mysql_unpacked_real_data_home_len))
{
DBUG_PRINT("error", ("Path is part of mysql_real_data_home"));
DBUG_RETURN(1); DBUG_RETURN(1);
}
} }
else if (!memcmp(path, mysql_unpacked_real_data_home, else if (!memcmp(path, mysql_unpacked_real_data_home,
mysql_unpacked_real_data_home_len)) mysql_unpacked_real_data_home_len))
{
DBUG_PRINT("error", ("Path is part of mysql_real_data_home"));
DBUG_RETURN(1); DBUG_RETURN(1);
}
} }
DBUG_RETURN(0); DBUG_RETURN(0);
} }
......
...@@ -371,6 +371,16 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function, ...@@ -371,6 +371,16 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
pthread_mutex_unlock(&THR_LOCK_maria); pthread_mutex_unlock(&THR_LOCK_maria);
break; break;
} }
case HA_EXTRA_PREPARE_FOR_FORCED_CLOSE:
if (info->trn)
{
pthread_mutex_lock(&share->intern_lock);
_ma_remove_table_from_trnman(share, info->trn);
/* Ensure we don't point to the deleted data in trn */
info->state= info->state_start= &share->state.state;
pthread_mutex_unlock(&share->intern_lock);
}
break;
case HA_EXTRA_FLUSH: case HA_EXTRA_FLUSH:
if (!share->temporary) if (!share->temporary)
error= _ma_flush_table_files(info, MARIA_FLUSH_DATA | MARIA_FLUSH_INDEX, error= _ma_flush_table_files(info, MARIA_FLUSH_DATA | MARIA_FLUSH_INDEX,
......
...@@ -96,7 +96,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) ...@@ -96,7 +96,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
bzero((uchar*) &info,sizeof(info)); bzero((uchar*) &info,sizeof(info));
realpath_err= my_realpath(name_buff, realpath_err= my_realpath(name_buff,
fn_format(org_name,name,"",MI_NAME_IEXT,4),MYF(0)); fn_format(org_name,name,"",MI_NAME_IEXT,4),MYF(0));
if (my_is_symlink(org_name) && if (my_is_symlink(org_name) &&
(realpath_err || (*myisam_test_invalid_symlink)(name_buff))) (realpath_err || (*myisam_test_invalid_symlink)(name_buff)))
{ {
......
...@@ -54,7 +54,7 @@ pthread_handler_t test_wt(void *arg) ...@@ -54,7 +54,7 @@ pthread_handler_t test_wt(void *arg)
my_rnd_init(&rand, (ulong)(intptr)&m, id); my_rnd_init(&rand, (ulong)(intptr)&m, id);
if (kill_strategy == YOUNGEST) if (kill_strategy == YOUNGEST)
thds[id].thd.weight= (ulong volatile)~my_getsystime(); thds[id].thd.weight= (ulong)~my_getsystime();
if (kill_strategy == LOCKS) if (kill_strategy == LOCKS)
thds[id].thd.weight= 0; thds[id].thd.weight= 0;
...@@ -104,7 +104,7 @@ retry: ...@@ -104,7 +104,7 @@ retry:
if (kill_strategy == LOCKS) if (kill_strategy == LOCKS)
thds[id].thd.weight= 0; thds[id].thd.weight= 0;
if (kill_strategy == YOUNGEST) if (kill_strategy == YOUNGEST)
thds[id].thd.weight= (ulong volatile)~my_getsystime(); thds[id].thd.weight= (ulong)~my_getsystime();
} }
else if (kill_strategy == LOCKS) else if (kill_strategy == LOCKS)
thds[id].thd.weight++; thds[id].thd.weight++;
......
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