diff options
-rw-r--r-- | include/my_base.h | 4 | ||||
-rw-r--r-- | include/my_global.h | 2 | ||||
-rw-r--r-- | mysql-test/r/subselect_debug.result | 3 | ||||
-rw-r--r-- | mysql-test/suite/maria/r/maria.result | 292 | ||||
-rw-r--r-- | mysql-test/suite/maria/t/maria.test | 290 | ||||
-rw-r--r-- | mysql-test/t/subselect_debug.test | 3 | ||||
-rw-r--r-- | mysys/my_uuid.c | 3 | ||||
-rw-r--r-- | sql/ha_partition.cc | 8 | ||||
-rw-r--r-- | sql/mysqld.cc | 3 | ||||
-rw-r--r-- | sql/sql_base.cc | 5 | ||||
-rw-r--r-- | sql/sql_parse.cc | 11 | ||||
-rw-r--r-- | storage/maria/ma_extra.c | 10 | ||||
-rw-r--r-- | storage/myisam/mi_open.c | 2 | ||||
-rw-r--r-- | unittest/mysys/waiting_threads-t.c | 4 |
14 files changed, 624 insertions, 16 deletions
diff --git a/include/my_base.h b/include/my_base.h index 3d7e8e1e60b..a2079f6745c 100644 --- a/include/my_base.h +++ b/include/my_base.h @@ -195,7 +195,9 @@ enum ha_extra_function { begin and end of a statement. */ 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 */ diff --git a/include/my_global.h b/include/my_global.h index 6970fa5a0b6..7277d513635 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -579,7 +579,7 @@ typedef unsigned short ushort; #define CMP_NUM(a,b) (((a) < (b)) ? -1 : ((a) == (b)) ? 0 : 1) #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 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) diff --git a/mysql-test/r/subselect_debug.result b/mysql-test/r/subselect_debug.result index 9ba552bbdf7..37a5c82a9f8 100644 --- a/mysql-test/r/subselect_debug.result +++ b/mysql-test/r/subselect_debug.result @@ -1,6 +1,7 @@ CREATE TABLE t1(id INT); INSERT INTO t1 VALUES (1),(2),(3),(4); 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"; SELECT SUM(EXISTS(SELECT RAND() FROM t1)) FROM t1; SUM(EXISTS(SELECT RAND() FROM t1)) @@ -8,5 +9,5 @@ SUM(EXISTS(SELECT RAND() FROM t1)) SELECT REVERSE(EXISTS(SELECT RAND() FROM t1)); REVERSE(EXISTS(SELECT RAND() FROM t1)) 0 -SET SESSION debug=DEFAULT; +SET SESSION debug=@orig_debug; DROP TABLE t1; diff --git a/mysql-test/suite/maria/r/maria.result b/mysql-test/suite/maria/r/maria.result index 82e73f67245..dce6048db6c 100644 --- a/mysql-test/suite/maria/r/maria.result +++ b/mysql-test/suite/maria/r/maria.result @@ -1887,6 +1887,287 @@ t1 CREATE TABLE `t1` ( KEY `b` (`b`) KEY_BLOCK_SIZE=8192 ) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=0 KEY_BLOCK_SIZE=16384 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; 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)), @@ -2309,3 +2590,14 @@ ALTER TABLE t1 CHANGE c d varchar(10); affected rows: 0 info: Records: 0 Duplicates: 0 Warnings: 0 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; diff --git a/mysql-test/suite/maria/t/maria.test b/mysql-test/suite/maria/t/maria.test index cb39b3c4109..1271d70e864 100644 --- a/mysql-test/suite/maria/t/maria.test +++ b/mysql-test/suite/maria/t/maria.test @@ -1087,7 +1087,7 @@ CHECK TABLE t1 EXTENDED; 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)); @@ -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; 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 # @@ -1598,3 +1866,23 @@ INSERT INTO t1 VALUES (1,"1"); ALTER TABLE t1 CHANGE c d varchar(10); --disable_info 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; diff --git a/mysql-test/t/subselect_debug.test b/mysql-test/t/subselect_debug.test index 358705da4f2..c2a7bafe1cd 100644 --- a/mysql-test/t/subselect_debug.test +++ b/mysql-test/t/subselect_debug.test @@ -9,8 +9,9 @@ CREATE TABLE t1(id INT); INSERT INTO t1 VALUES (1),(2),(3),(4); INSERT INTO t1 SELECT a.id FROM t1 a,t1 b,t1 c,t1 d; # Setup the mysqld to crash at certain point +SET @orig_debug=@@debug; SET SESSION debug="d,subselect_exec_fail"; SELECT SUM(EXISTS(SELECT RAND() FROM t1)) FROM t1; SELECT REVERSE(EXISTS(SELECT RAND() FROM t1)); -SET SESSION debug=DEFAULT; +SET SESSION debug=@orig_debug; DROP TABLE t1; diff --git a/mysys/my_uuid.c b/mysys/my_uuid.c index 36f1d2227f0..ca5e94c4754 100644 --- a/mysys/my_uuid.c +++ b/mysys/my_uuid.c @@ -145,11 +145,12 @@ void my_uuid(uchar *to) */ if (nanoseq) { + long delta; DBUG_ASSERT((tv > uuid_time) && (nanoseq > 0)); /* -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; nanoseq-= delta; } diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 0eb36be2f3b..078b22bff02 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -5042,6 +5042,7 @@ int ha_partition::extra(enum ha_extra_function operation) case HA_EXTRA_KEYREAD: case HA_EXTRA_NO_KEYREAD: case HA_EXTRA_FLUSH: + case HA_EXTRA_PREPARE_FOR_FORCED_CLOSE: DBUG_RETURN(loop_extra(operation)); /* Category 2), used by non-MyISAM handlers */ @@ -5065,8 +5066,7 @@ int ha_partition::extra(enum ha_extra_function operation) case HA_EXTRA_PREPARE_FOR_DROP: case HA_EXTRA_FLUSH_CACHE: { - if (m_myisam) - DBUG_RETURN(loop_extra(operation)); + DBUG_RETURN(loop_extra(operation)); break; } case HA_EXTRA_CACHE: @@ -5260,8 +5260,8 @@ int ha_partition::loop_extra(enum ha_extra_function operation) DBUG_ENTER("ha_partition::loop_extra()"); /* - TODO, 5.2: this is where you could possibly add optimisations to add the bitmap - _if_ a SELECT. + TODO, 5.2: this is where you could possibly add optimisations to add the + bitmap _if_ a SELECT. */ for (file= m_file; *file; file++) { diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 4df9842c4e5..3b176e8d37f 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -7487,7 +7487,10 @@ static void mysql_init_variables(void) /* Things reset to zero */ opt_skip_slave_start= opt_reckless_slave = 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; +#endif opt_log= opt_slow_log= 0; opt_update_log= 0; log_output_options= find_bit_type(log_output_str, &log_output_typelib); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index ab9fff22b9a..0b993748fc3 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -3427,6 +3427,11 @@ static void close_old_data_files(THD *thd, TABLE *table, bool morph_locks, 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 so they won't sneak in when we will temporarily remove our lock on it. This will also give them a chance to close their diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 1495a5d8e6c..819c9b9ed26 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -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 + SYNOPSIS test_if_data_home_dir() dir directory - conv_home_dir converted data home directory - home_dir_len converted data home directory length RETURN VALUES 0 ok - 1 error + 1 error ; Given path contains data directory */ C_MODE_START @@ -7513,11 +7512,17 @@ int test_if_data_home_dir(const char *dir) mysql_unpacked_real_data_home_len, (const uchar*) mysql_unpacked_real_data_home, mysql_unpacked_real_data_home_len)) + { + DBUG_PRINT("error", ("Path is part of mysql_real_data_home")); DBUG_RETURN(1); + } } else if (!memcmp(path, mysql_unpacked_real_data_home, mysql_unpacked_real_data_home_len)) + { + DBUG_PRINT("error", ("Path is part of mysql_real_data_home")); DBUG_RETURN(1); + } } DBUG_RETURN(0); } diff --git a/storage/maria/ma_extra.c b/storage/maria/ma_extra.c index 7fab28edf42..301d3af3549 100644 --- a/storage/maria/ma_extra.c +++ b/storage/maria/ma_extra.c @@ -371,6 +371,16 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function, pthread_mutex_unlock(&THR_LOCK_maria); 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: if (!share->temporary) error= _ma_flush_table_files(info, MARIA_FLUSH_DATA | MARIA_FLUSH_INDEX, diff --git a/storage/myisam/mi_open.c b/storage/myisam/mi_open.c index 3f9c1e7f155..6f5c29fa1e6 100644 --- a/storage/myisam/mi_open.c +++ b/storage/myisam/mi_open.c @@ -96,7 +96,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) bzero((uchar*) &info,sizeof(info)); 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) && (realpath_err || (*myisam_test_invalid_symlink)(name_buff))) { diff --git a/unittest/mysys/waiting_threads-t.c b/unittest/mysys/waiting_threads-t.c index dc3cf7d6265..953b02f3eb9 100644 --- a/unittest/mysys/waiting_threads-t.c +++ b/unittest/mysys/waiting_threads-t.c @@ -54,7 +54,7 @@ pthread_handler_t test_wt(void *arg) my_rnd_init(&rand, (ulong)(intptr)&m, id); if (kill_strategy == YOUNGEST) - thds[id].thd.weight= (ulong volatile)~my_getsystime(); + thds[id].thd.weight= (ulong)~my_getsystime(); if (kill_strategy == LOCKS) thds[id].thd.weight= 0; @@ -104,7 +104,7 @@ retry: if (kill_strategy == LOCKS) thds[id].thd.weight= 0; if (kill_strategy == YOUNGEST) - thds[id].thd.weight= (ulong volatile)~my_getsystime(); + thds[id].thd.weight= (ulong)~my_getsystime(); } else if (kill_strategy == LOCKS) thds[id].thd.weight++; |