diff options
author | Evgeny Potemkin <epotemkin@mysql.com> | 2010-11-04 23:38:45 +0300 |
---|---|---|
committer | Evgeny Potemkin <epotemkin@mysql.com> | 2010-11-04 23:38:45 +0300 |
commit | 2adecd8ce7d327d63c812439c4f7051df6dbfa19 (patch) | |
tree | 4c7e6c9fc32fd06b993c22477419072c164f1eaf | |
parent | 368ac9f03ef9c1f0c9d02985c13708ac52cfbfaf (diff) | |
parent | c1b2d729002fa28bf29957436c0ed1926e9c45a6 (diff) | |
download | mariadb-git-2adecd8ce7d327d63c812439c4f7051df6dbfa19.tar.gz |
Auto-merged.
87 files changed, 1531 insertions, 402 deletions
diff --git a/.bzr-mysql/default.conf b/.bzr-mysql/default.conf index 36f40105d26..1b6d7676984 100644 --- a/.bzr-mysql/default.conf +++ b/.bzr-mysql/default.conf @@ -1,4 +1,4 @@ [MYSQL] -post_commit_to = "commits@lists.mysql.com" -post_push_to = "commits@lists.mysql.com" -tree_name = "mysql-5.5-bugteam" +post_commit_to = "dbg_mysql_security@sun.com" +post_push_to = "dbg_mysql_security@sun.com" +tree_name = "mysql-5.5-security" diff --git a/.bzrignore b/.bzrignore index 4c437cdd36c..a882c6a9adc 100644 --- a/.bzrignore +++ b/.bzrignore @@ -9,6 +9,7 @@ *.core *.d *.da +*.dylib *.exe *.gcda *.gcno @@ -606,6 +607,7 @@ include/mysql_version.h include/mysqld_ername.h include/mysqld_error.h include/openssl +include/probes_mysql_dtrace.h include/readline include/readline/*.h include/readline/readline.h diff --git a/configure.in b/configure.in index d8a45214a5c..9f986e068cb 100644 --- a/configure.in +++ b/configure.in @@ -27,7 +27,7 @@ dnl dnl When changing the major version number please also check the switch dnl statement in mysqlbinlog::check_master_version(). You may also need dnl to update version.c in ndb. -AC_INIT([MySQL Server], [5.5.8-ga], [], [mysql]) +AC_INIT([MySQL Server], [5.5.8-rc], [], [mysql]) AC_CONFIG_SRCDIR([sql/mysqld.cc]) AC_CANONICAL_SYSTEM diff --git a/include/mysql/plugin_auth.h b/include/mysql/plugin_auth.h index 5622e9cdebe..420eb3bb80f 100644 --- a/include/mysql/plugin_auth.h +++ b/include/mysql/plugin_auth.h @@ -90,8 +90,8 @@ typedef struct st_mysql_server_auth_info int password_used; /** - Set to the name of the connected client if it can be resolved, or to - the address otherwise + Set to the name of the connected client host, if it can be resolved, + or to its IP address otherwise. */ const char *host_or_ip; @@ -107,7 +107,7 @@ typedef struct st_mysql_server_auth_info */ struct st_mysql_auth { - int interface_version; /**< version plugin uses */ + int interface_version; /** version plugin uses */ /** A plugin that a client must use for authentication with this server plugin. Can be NULL to mean "any plugin". diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result index e14b54b59a3..13e1092cb98 100644 --- a/mysql-test/r/ctype_utf8.result +++ b/mysql-test/r/ctype_utf8.result @@ -1898,6 +1898,37 @@ CONVERT(a, CHAR) CONVERT(b, CHAR) 70000 1092 DROP TABLE t1; End of 5.0 tests +SELECT LENGTH(RPAD(0.0115E88, 61297, _utf8'яэюя')); +LENGTH(RPAD(0.0115E88, 61297, _utf8'яэюя')) +122587 +SELECT LENGTH(RPAD(0.0115E88, 61297, _utf8'йцуя')); +LENGTH(RPAD(0.0115E88, 61297, _utf8'йцуя')) +122587 +SELECT HEX(RPAD(0x20, 2, _utf8 0xD18F)); +HEX(RPAD(0x20, 2, _utf8 0xD18F)) +20D1 +SELECT HEX(RPAD(0x20, 4, _utf8 0xD18F)); +HEX(RPAD(0x20, 4, _utf8 0xD18F)) +20D18FD1 +SELECT HEX(LPAD(0x20, 2, _utf8 0xD18F)); +HEX(LPAD(0x20, 2, _utf8 0xD18F)) +D120 +SELECT HEX(LPAD(0x20, 4, _utf8 0xD18F)); +HEX(LPAD(0x20, 4, _utf8 0xD18F)) +D18FD120 +SELECT HEX(RPAD(_utf8 0xD18F, 3, 0x20)); +HEX(RPAD(_utf8 0xD18F, 3, 0x20)) +D18F20 +SELECT HEX(LPAD(_utf8 0xD18F, 3, 0x20)); +HEX(LPAD(_utf8 0xD18F, 3, 0x20)) +20D18F +SELECT HEX(INSERT(_utf8 0xD18F, 2, 1, 0x20)); +HEX(INSERT(_utf8 0xD18F, 2, 1, 0x20)) +D120 +SELECT HEX(INSERT(_utf8 0xD18FD18E, 2, 1, 0x20)); +HEX(INSERT(_utf8 0xD18FD18E, 2, 1, 0x20)) +D120D18E +End of 5.1 tests Start of 5.4 tests SET NAMES utf8mb3; SHOW VARIABLES LIKE 'character_set_results%'; diff --git a/mysql-test/r/explain.result b/mysql-test/r/explain.result index b8dbb54e5fb..b9ae362f6cd 100644 --- a/mysql-test/r/explain.result +++ b/mysql-test/r/explain.result @@ -271,4 +271,50 @@ EXPLAIN SELECT c1 FROM t1 WHERE c2 = 1 AND c4 = 1 AND c5 = 1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref c2,c2_2 c2 10 const,const 3 Using where DROP TABLE t1; +# +# Bug#56814 Explain + subselect + fulltext crashes server +# +CREATE TABLE t1(f1 VARCHAR(6) NOT NULL, +FULLTEXT KEY(f1),UNIQUE(f1)); +INSERT INTO t1 VALUES ('test'); +EXPLAIN SELECT 1 FROM t1 +WHERE 1 > ALL((SELECT 1 FROM t1 JOIN t1 a ON (MATCH(t1.f1) AGAINST ("")) +WHERE t1.f1 GROUP BY t1.f1)); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 +2 SUBQUERY a system NULL NULL NULL NULL 1 Using filesort +2 SUBQUERY t1 fulltext f1 f1 0 1 Using where +PREPARE stmt FROM +'EXPLAIN SELECT 1 FROM t1 + WHERE 1 > ALL((SELECT 1 FROM t1 RIGHT OUTER JOIN t1 a + ON (MATCH(t1.f1) AGAINST ("")) + WHERE t1.f1 GROUP BY t1.f1))'; +EXECUTE stmt; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 +2 SUBQUERY a system NULL NULL NULL NULL 1 Using filesort +2 SUBQUERY t1 fulltext f1 f1 0 1 Using where +EXECUTE stmt; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 +2 SUBQUERY a system NULL NULL NULL NULL 1 Using filesort +2 SUBQUERY t1 fulltext f1 f1 0 1 Using where +DEALLOCATE PREPARE stmt; +PREPARE stmt FROM +'EXPLAIN SELECT 1 FROM t1 + WHERE 1 > ALL((SELECT 1 FROM t1 JOIN t1 a + ON (MATCH(t1.f1) AGAINST ("")) + WHERE t1.f1 GROUP BY t1.f1))'; +EXECUTE stmt; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 +2 SUBQUERY a system NULL NULL NULL NULL 1 Using filesort +2 SUBQUERY t1 fulltext f1 f1 0 1 Using where +EXECUTE stmt; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 +2 SUBQUERY a system NULL NULL NULL NULL 1 Using filesort +2 SUBQUERY t1 fulltext f1 f1 0 1 Using where +DEALLOCATE PREPARE stmt; +DROP TABLE t1; End of 5.1 tests. diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result index a75f502c735..7788a32ac90 100644 --- a/mysql-test/r/fulltext.result +++ b/mysql-test/r/fulltext.result @@ -652,4 +652,40 @@ Table Op Msg_type Msg_text test.t1 repair status OK SET myisam_sort_buffer_size=@@global.myisam_sort_buffer_size; DROP TABLE t1; +# +# Bug#54484 explain + prepared statement: crash and Got error -1 from storage engine +# +CREATE TABLE t1(f1 VARCHAR(6) NOT NULL, FULLTEXT KEY(f1), UNIQUE(f1)); +INSERT INTO t1 VALUES ('test'); +SELECT 1 FROM t1 WHERE 1 > +ALL((SELECT 1 FROM t1 JOIN t1 a +ON (MATCH(t1.f1) against ("")) +WHERE t1.f1 GROUP BY t1.f1)) xor f1; +1 +1 +PREPARE stmt FROM +'SELECT 1 FROM t1 WHERE 1 > + ALL((SELECT 1 FROM t1 RIGHT OUTER JOIN t1 a + ON (MATCH(t1.f1) against ("")) + WHERE t1.f1 GROUP BY t1.f1)) xor f1'; +EXECUTE stmt; +1 +1 +EXECUTE stmt; +1 +1 +DEALLOCATE PREPARE stmt; +PREPARE stmt FROM +'SELECT 1 FROM t1 WHERE 1 > + ALL((SELECT 1 FROM t1 JOIN t1 a + ON (MATCH(t1.f1) against ("")) + WHERE t1.f1 GROUP BY t1.f1))'; +EXECUTE stmt; +1 +1 +EXECUTE stmt; +1 +1 +DEALLOCATE PREPARE stmt; +DROP TABLE t1; End of 5.1 tests diff --git a/mysql-test/r/func_gconcat.result b/mysql-test/r/func_gconcat.result index 302de9de9f7..69be0107b8f 100644 --- a/mysql-test/r/func_gconcat.result +++ b/mysql-test/r/func_gconcat.result @@ -1038,6 +1038,14 @@ GROUP_CONCAT(t1.a ORDER BY t1.a) 1,1,2,2 DEALLOCATE PREPARE stmt; DROP TABLE t1; +# +# Bug#57194 group_concat cause crash and/or invalid memory reads with type errors +# +CREATE TABLE t1(f1 int); +INSERT INTO t1 values (0),(0); +SELECT POLYGON((SELECT 1 FROM (SELECT 1 IN (GROUP_CONCAT(t1.f1)) FROM t1, t1 t GROUP BY t.f1 ) d)); +ERROR 22007: Illegal non geometric '(select 1 from (select (1 = group_concat(`test`.`t1`.`f1` separator ',')) AS `1 IN (GROUP_CONCAT(t1.f1))` from `test`.`t1` join `test`.`t1` `t` group by `t`.`f1`) `d`)' value found during parsing +DROP TABLE t1; End of 5.1 tests DROP TABLE IF EXISTS t1, t2; CREATE TABLE t1 (a VARCHAR(6), b INT); diff --git a/mysql-test/r/func_math.result b/mysql-test/r/func_math.result index bfb3af0afff..5b2f01969a6 100644 --- a/mysql-test/r/func_math.result +++ b/mysql-test/r/func_math.result @@ -481,6 +481,18 @@ RAND(i) 0.15522042769493574 DROP TABLE t1; # +# Bug#57477 SIGFPE when dividing a huge number a negative number +# +SELECT -9999999999999999991 DIV -1; +ERROR 22003: BIGINT value is out of range in '(-(9999999999999999991) DIV -(1))' +SELECT -9223372036854775808 DIV -1; +ERROR 22003: BIGINT value is out of range in '(-(9223372036854775808) DIV -(1))' +SELECT -9223372036854775808 MOD -1; +-9223372036854775808 MOD -1 +0 +SELECT -9223372036854775808999 MOD -1; +-9223372036854775808999 MOD -1 +0 select 123456789012345678901234567890.123456789012345678901234567890 div 1 as x; ERROR 22003: BIGINT value is out of range in '(123456789012345678901234567890.123456789012345678901234567890 DIV 1)' select "123456789012345678901234567890.123456789012345678901234567890" div 1 as x; diff --git a/mysql-test/r/func_misc.result b/mysql-test/r/func_misc.result index 85448a258e4..9ea02d5a9e3 100644 --- a/mysql-test/r/func_misc.result +++ b/mysql-test/r/func_misc.result @@ -375,4 +375,11 @@ GREATEST(a, (SELECT b FROM t1 LIMIT 1)) 3 1 DROP TABLE t1; +SELECT INET_NTOA(0); +INET_NTOA(0) +0.0.0.0 +SELECT '1' IN ('1', INET_NTOA(0)); +'1' IN ('1', INET_NTOA(0)) +1 End of 5.1 tests +End of tests diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result index 2621f69da06..188485d366f 100644 --- a/mysql-test/r/group_by.result +++ b/mysql-test/r/group_by.result @@ -1846,6 +1846,16 @@ SELECT SUBSTRING(a,1,10), LENGTH(a) FROM t1 GROUP BY a; SUBSTRING(a,1,10) LENGTH(a) 1111111111 1300 DROP TABLE t1; +# +# Bug#57688 Assertion `!table || (!table->write_set || bitmap_is_set(table->write_set, field +# +CREATE TABLE t1(f1 INT NOT NULL); +INSERT INTO t1 VALUES (16777214),(0); +SELECT COUNT(*) FROM t1 LEFT JOIN t1 t2 +ON 1 WHERE t2.f1 > 1 GROUP BY t2.f1; +COUNT(*) +2 +DROP TABLE t1; # End of 5.1 tests # # Bug#49771: Incorrect MIN (date) when minimum value is 0000-00-00 diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result index 0af32d8f749..99ca9f05535 100644 --- a/mysql-test/r/join_outer.result +++ b/mysql-test/r/join_outer.result @@ -1402,4 +1402,34 @@ id select_type table type possible_keys key key_len ref rows filtered Extra Warnings: Note 1003 select straight_join `test`.`jt1`.`f1` AS `f1` from `test`.`t1` `jt6` left join (`test`.`t1` `jt3` join `test`.`t1` `jt4` left join `test`.`t1` `jt5` on(1) left join `test`.`t1` `jt2` on(1)) on((`test`.`jt6`.`f1` and 1)) left join `test`.`t1` `jt1` on(1) where 1 DROP TABLE t1; +# +# Bug#57688 Assertion `!table || (!table->write_set || bitmap_is_set(table->write_set, field +# +CREATE TABLE t1 (f1 INT NOT NULL, PRIMARY KEY (f1)); +CREATE TABLE t2 (f1 INT NOT NULL, f2 INT NOT NULL, PRIMARY KEY (f1, f2)); +INSERT INTO t1 VALUES (4); +INSERT INTO t2 VALUES (3, 3); +INSERT INTO t2 VALUES (7, 7); +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1 +WHERE t1.f1 = 4 +GROUP BY t2.f1, t2.f2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 system PRIMARY NULL NULL NULL 1 Using temporary; Using filesort +1 SIMPLE t2 ref PRIMARY PRIMARY 4 const 1 Using index +SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1 +WHERE t1.f1 = 4 +GROUP BY t2.f1, t2.f2; +f1 f1 f2 +4 NULL NULL +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1 +WHERE t1.f1 = 4 AND t2.f1 IS NOT NULL AND t2.f2 IS NOT NULL +GROUP BY t2.f1, t2.f2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 system PRIMARY NULL NULL NULL 1 Using filesort +1 SIMPLE t2 ref PRIMARY PRIMARY 4 const 1 Using where; Using index +SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1 +WHERE t1.f1 = 4 AND t2.f1 IS NOT NULL AND t2.f2 IS NOT NULL +GROUP BY t2.f1, t2.f2; +f1 f1 f2 +DROP TABLE t1,t2; End of 5.1 tests diff --git a/mysql-test/r/lock_sync.result b/mysql-test/r/lock_sync.result index 726b754eaa8..8fe94679e70 100644 --- a/mysql-test/r/lock_sync.result +++ b/mysql-test/r/lock_sync.result @@ -738,3 +738,38 @@ SET DEBUG_SYNC= 'now SIGNAL release_thrlock'; # Connection default DROP TABLE t1; SET DEBUG_SYNC= 'RESET'; +# +# Bug#57130 crash in Item_field::print during SHOW CREATE TABLE or VIEW +# +DROP TABLE IF EXISTS t1; +DROP VIEW IF EXISTS v1; +DROP FUNCTION IF EXISTS f1; +CREATE TABLE t1(a INT); +CREATE FUNCTION f1() RETURNS INTEGER RETURN 1; +CREATE VIEW v1 AS SELECT * FROM t1 WHERE f1() = 1; +DROP FUNCTION f1; +# Connection con1 +SET DEBUG_SYNC= 'open_tables_after_open_and_process_table SIGNAL opened WAIT_FOR dropped EXECUTE 2'; +# Sending: +SHOW CREATE VIEW v1; +# Connection con2 +SET DEBUG_SYNC= 'now WAIT_FOR opened'; +SET DEBUG_SYNC= 'now SIGNAL dropped'; +SET DEBUG_SYNC= 'now WAIT_FOR opened'; +# Sending: +FLUSH TABLES; +# Connection default +# Waiting for FLUSH TABLES to be blocked. +SET DEBUG_SYNC= 'now SIGNAL dropped'; +# Connection con1 +# Reaping: SHOW CREATE VIEW v1 +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where (`f1`() = 1) latin1 latin1_swedish_ci +Warnings: +Warning 1356 View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +# Connection con2 +# Reaping: FLUSH TABLES +# Connection default +SET DEBUG_SYNC= 'RESET'; +DROP VIEW v1; +DROP TABLE t1; diff --git a/mysql-test/r/partition_innodb.result b/mysql-test/r/partition_innodb.result index 148504bcc8b..72415d35f60 100644 --- a/mysql-test/r/partition_innodb.result +++ b/mysql-test/r/partition_innodb.result @@ -1,5 +1,31 @@ drop table if exists t1, t2; # +# Bug#56287: crash when using Partition datetime in sub in query +# +CREATE TABLE t1 +(c1 bigint(20) unsigned NOT NULL AUTO_INCREMENT, +c2 varchar(40) not null default '', +c3 datetime not NULL, +PRIMARY KEY (c1,c3), +KEY partidx(c3)) +ENGINE=InnoDB +PARTITION BY RANGE (TO_DAYS(c3)) +(PARTITION p200912 VALUES LESS THAN (to_days('2010-01-01')), +PARTITION p201103 VALUES LESS THAN (to_days('2011-04-01')), +PARTITION p201912 VALUES LESS THAN MAXVALUE); +insert into t1(c2,c3) values ("Test row",'2010-01-01 00:00:00'); +SELECT PARTITION_NAME, TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME = 't1' AND TABLE_SCHEMA = 'test'; +PARTITION_NAME TABLE_ROWS +p200912 0 +p201103 1 +p201912 0 +SELECT count(*) FROM t1 p where c3 in +(select c3 from t1 t where t.c3 < date '2011-04-26 19:19:44' + and t.c3 > date '2011-04-26 19:18:44') ; +count(*) +0 +DROP TABLE t1; +# # Bug#54747: Deadlock between REORGANIZE PARTITION and # SELECT is not detected # diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result index cf3594f32a8..33282823931 100644 --- a/mysql-test/r/ps.result +++ b/mysql-test/r/ps.result @@ -3005,6 +3005,44 @@ EXECUTE stmt; 1 DEALLOCATE PREPARE stmt; DROP TABLE t1; +# +# Bug#54494 crash with explain extended and prepared statements +# +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (1),(2); +PREPARE stmt FROM 'EXPLAIN EXTENDED SELECT 1 FROM t1 RIGHT JOIN t1 t2 ON 1'; +EXECUTE stmt; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 +Warnings: +Note 1003 select 1 AS `1` from `test`.`t1` `t2` left join `test`.`t1` on(1) where 1 +EXECUTE stmt; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 +Warnings: +Note 1003 select 1 AS `1` from `test`.`t1` `t2` left join `test`.`t1` on(1) where 1 +DEALLOCATE PREPARE stmt; +DROP TABLE t1; +# +# Bug#54488 crash when using explain and prepared statements with subqueries +# +CREATE TABLE t1(f1 INT); +INSERT INTO t1 VALUES (1),(1); +PREPARE stmt FROM 'EXPLAIN SELECT 1 FROM t1 WHERE (SELECT (SELECT 1 FROM t1 GROUP BY f1))'; +EXECUTE stmt; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used +3 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort +EXECUTE stmt; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used +3 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort +DEALLOCATE PREPARE stmt; +DROP TABLE t1; End of 5.1 tests. diff --git a/mysql-test/r/signal.result b/mysql-test/r/signal.result index 67bf9330451..cfa056d5d13 100644 --- a/mysql-test/r/signal.result +++ b/mysql-test/r/signal.result @@ -1379,9 +1379,6 @@ MESSAGE_TEXT = msg, MYSQL_ERRNO = 1012; end $$ insert into t1 values (1), (2) $$ -Warnings: -Warning 1012 This trigger SIGNAL a warning, a=1 -Warning 1012 This trigger SIGNAL a warning, a=2 drop trigger t1_ai $$ create trigger t1_ai after insert on t1 for each row begin @@ -1416,11 +1413,7 @@ MESSAGE_TEXT = NEW.msg, MYSQL_ERRNO = NEW.errno; end $$ insert into t1 set errno=1012, msg='Warning message 1 in trigger' $$ -Warnings: -Warning 1012 Warning message 1 in trigger insert into t1 set errno=1013, msg='Warning message 2 in trigger' $$ -Warnings: -Warning 1013 Warning message 2 in trigger drop table t1 $$ drop table if exists t1 $$ drop procedure if exists p1 $$ diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result index 7b8364379df..4e97429c48f 100644 --- a/mysql-test/r/sp-error.result +++ b/mysql-test/r/sp-error.result @@ -1877,9 +1877,6 @@ DROP PROCEDURE p1; # # Bug#5889: Exit handler for a warning doesn't hide the warning in trigger # - -# - Case 1 - CREATE TABLE t1(a INT, b INT); INSERT INTO t1 VALUES (1, 2); CREATE TRIGGER t1_bu BEFORE UPDATE ON t1 FOR EACH ROW @@ -1889,40 +1886,13 @@ SET NEW.a = 10; SET NEW.a = 99999999999; END| UPDATE t1 SET b = 20; -Warnings: -Warning 1264 Out of range value for column 'a' at row 1 SHOW WARNINGS; Level Code Message -Warning 1264 Out of range value for column 'a' at row 1 SELECT * FROM t1; a b 10 20 DROP TRIGGER t1_bu; DROP TABLE t1; - -# - Case 2 - -CREATE TABLE t1(a INT); -CREATE TABLE t2(b CHAR(1)); -CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW -BEGIN -INSERT INTO t2 VALUES('ab'); # Produces a warning. -INSERT INTO t2 VALUES('b'); # Does not produce a warning, -# previous warning should be cleared. -END| -INSERT INTO t1 VALUES(0); -SHOW WARNINGS; -Level Code Message -SELECT * FROM t1; -a -0 -SELECT * FROM t2; -b -a -b -DROP TRIGGER t1_bi; -DROP TABLE t1; -DROP TABLE t2; # # Bug#9857: Stored procedures: handler for sqlwarning ignored # @@ -1961,3 +1931,64 @@ Warning 1365 Division by 0 DROP PROCEDURE p1; DROP PROCEDURE p2; SET sql_mode = @sql_mode_saved; +# +# Bug#55850: Trigger warnings not cleared. +# +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +DROP PROCEDURE IF EXISTS p1; +CREATE TABLE t1(x SMALLINT, y SMALLINT, z SMALLINT); +CREATE TABLE t2(a SMALLINT, b SMALLINT, c SMALLINT, +d SMALLINT, e SMALLINT, f SMALLINT); +CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW +INSERT INTO t2(a, b, c) VALUES(99999, 99999, 99999); +CREATE TRIGGER t1_ai AFTER INSERT ON t1 FOR EACH ROW +INSERT INTO t2(d, e, f) VALUES(99999, 99999, 99999); +CREATE PROCEDURE p1() +INSERT INTO t1 VALUES(99999, 99999, 99999); + +CALL p1(); +Warnings: +Warning 1264 Out of range value for column 'x' at row 1 +Warning 1264 Out of range value for column 'y' at row 1 +Warning 1264 Out of range value for column 'z' at row 1 + +SHOW WARNINGS; +Level Code Message +Warning 1264 Out of range value for column 'x' at row 1 +Warning 1264 Out of range value for column 'y' at row 1 +Warning 1264 Out of range value for column 'z' at row 1 + +DROP TABLE t1; +DROP TABLE t2; +DROP PROCEDURE p1; +# ---------------------------------------------------------------------- +CREATE TABLE t1(x SMALLINT, y SMALLINT, z SMALLINT); +CREATE TABLE t2(a SMALLINT, b SMALLINT, c SMALLINT NOT NULL); +CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW +BEGIN +INSERT INTO t2 VALUES( +CAST('111111 ' AS SIGNED), +CAST('222222 ' AS SIGNED), +NULL); +END| +CREATE PROCEDURE p1() +INSERT INTO t1 VALUES(99999, 99999, 99999); + +CALL p1(); +ERROR 23000: Column 'c' cannot be null + +SHOW WARNINGS; +Level Code Message +Warning 1264 Out of range value for column 'x' at row 1 +Warning 1264 Out of range value for column 'y' at row 1 +Warning 1264 Out of range value for column 'z' at row 1 +Warning 1292 Truncated incorrect INTEGER value: '111111 ' +Warning 1264 Out of range value for column 'a' at row 1 +Warning 1292 Truncated incorrect INTEGER value: '222222 ' +Warning 1264 Out of range value for column 'b' at row 1 +Error 1048 Column 'c' cannot be null + +DROP TABLE t1; +DROP TABLE t2; +DROP PROCEDURE p1; diff --git a/mysql-test/r/trigger.result b/mysql-test/r/trigger.result index b9b1c94ce1a..b24c5b87fa0 100644 --- a/mysql-test/r/trigger.result +++ b/mysql-test/r/trigger.result @@ -1072,8 +1072,6 @@ SELECT @x; NULL SET @x=2; UPDATE t1 SET i1 = @x; -Warnings: -Warning 1365 Division by 0 SELECT @x; @x NULL @@ -1085,9 +1083,6 @@ SELECT @x; NULL SET @x=4; UPDATE t1 SET i1 = @x; -Warnings: -Warning 1365 Division by 0 -Warning 1365 Division by 0 SELECT @x; @x NULL @@ -1198,8 +1193,6 @@ Warnings: Warning 1365 Division by 0 create trigger t1_bi before insert on t1 for each row set @a:=1/0| insert into t1 values(20, 20)| -Warnings: -Warning 1365 Division by 0 drop trigger t1_bi| create trigger t1_bi before insert on t1 for each row begin @@ -1218,8 +1211,6 @@ set @a:=1/0; end| set @check=0, @t4_bi_called=0, @t4_bu_called=0| insert into t1 values(30, 30)| -Warnings: -Warning 1365 Division by 0 select @check, @t4_bi_called, @t4_bu_called| @check @t4_bi_called @t4_bu_called 2 1 1 @@ -2090,12 +2081,8 @@ SELECT 1 FROM t1 c WHERE END// SET @bug51650 = 1; INSERT IGNORE INTO t2 VALUES(); -Warnings: -Warning 1329 No data - zero rows fetched, selected, or processed INSERT IGNORE INTO t1 SET b = '777'; INSERT IGNORE INTO t2 SET a = '111'; -Warnings: -Warning 1329 No data - zero rows fetched, selected, or processed SET @bug51650 = 1; INSERT IGNORE INTO t2 SET a = '777'; DROP TRIGGER trg1; @@ -2177,8 +2164,6 @@ SELECT 'ab' INTO a; SELECT 'a' INTO a; END| INSERT INTO t1 VALUES (1); -Warnings: -Warning 1265 Data truncated for column 'a' at row 1 DROP TRIGGER trg1; DROP TABLE t1; DROP TRIGGER IF EXISTS trg1; @@ -2196,20 +2181,12 @@ DECLARE trg2 CHAR; SELECT 'ab' INTO trg2; END| INSERT INTO t1 VALUES (0); -Warnings: -Warning 1265 Data truncated for column 'trg1' at row 1 -Warning 1265 Data truncated for column 'trg2' at row 1 SELECT * FROM t1; a 0 SHOW WARNINGS; Level Code Message INSERT INTO t1 VALUES (1),(2); -Warnings: -Warning 1265 Data truncated for column 'trg1' at row 1 -Warning 1265 Data truncated for column 'trg2' at row 1 -Warning 1265 Data truncated for column 'trg1' at row 1 -Warning 1265 Data truncated for column 'trg2' at row 1 DROP TRIGGER trg1; DROP TRIGGER trg2; DROP TABLE t1; diff --git a/mysql-test/r/truncate_coverage.result b/mysql-test/r/truncate_coverage.result index a7a4b9c70f4..728702f7ab5 100644 --- a/mysql-test/r/truncate_coverage.result +++ b/mysql-test/r/truncate_coverage.result @@ -78,3 +78,30 @@ COMMIT; UNLOCK TABLES; DROP TABLE t1; SET DEBUG_SYNC='RESET'; +# +# Bug#57659 Segfault in Query_cache::invalidate_data for TRUNCATE TABLE +# +# Note that this test case only reproduces the problem +# when it is run with valgrind. +DROP TABLE IF EXISTS t1, m1; +CREATE TABLE t1(a INT) engine=memory; +CREATE TABLE m1(a INT) engine=merge UNION(t1); +# Connection con1 +SET DEBUG_SYNC= 'open_tables_after_open_and_process_table SIGNAL opened WAIT_FOR dropped'; +# Sending: +TRUNCATE TABLE m1; +# Connection con2 +SET DEBUG_SYNC= 'now WAIT_FOR opened'; +# Sending: +FLUSH TABLES; +# Connection default +# Waiting for FLUSH TABLES to be blocked. +SET DEBUG_SYNC= 'now SIGNAL dropped'; +# Connection con1 +# Reaping: TRUNCATE TABLE m1 +ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist +# Connection con2 +# Reaping: FLUSH TABLES +# Connection default +SET DEBUG_SYNC= 'RESET'; +DROP TABLE m1, t1; diff --git a/mysql-test/suite/binlog/t/disabled.def b/mysql-test/suite/binlog/t/disabled.def index a9841f592f8..d80a42c6e27 100644 --- a/mysql-test/suite/binlog/t/disabled.def +++ b/mysql-test/suite/binlog/t/disabled.def @@ -9,6 +9,5 @@ # Do not use any TAB characters for whitespace. # ############################################################################## - -binlog_truncate_innodb : BUG#42643 2009-02-06 mats Changes to InnoDB requires to complete fix for BUG#36763 +binlog_truncate_innodb : BUG#57291 2010-10-20 anitha Originally disabled due to BUG#42643. Product bug fixed, but test changes needed binlog_spurious_ddl_errors : BUG#54195 2010-06-03 alik binlog_spurious_ddl_errors.test fails, thus disabled diff --git a/mysql-test/suite/funcs_1/r/innodb_trig_08.result b/mysql-test/suite/funcs_1/r/innodb_trig_08.result index b2b38694680..a25147a1480 100644 --- a/mysql-test/suite/funcs_1/r/innodb_trig_08.result +++ b/mysql-test/suite/funcs_1/r/innodb_trig_08.result @@ -353,8 +353,6 @@ B Test 3.5.8.5-case 00191 0000000016 C=one C Test 3.5.8.5-case 00200 0000000001 C=one Insert into tb3 (f120, f122, f136) values ('d', 'Test 3.5.8.5-case', 152); -Warnings: -Warning 1265 Data truncated for column 'f120' at row 1 select f120, f122, f136, f144, @test_var from tb3 where f122 = 'Test 3.5.8.5-case' order by f120,f136; f120 f122 f136 f144 @test_var @@ -364,8 +362,6 @@ B Test 3.5.8.5-case 00191 0000000016 1*0000099999 C Test 3.5.8.5-case 00200 0000000001 1*0000099999 Insert into tb3 (f120, f122, f136, f144) values ('e', 'Test 3.5.8.5-case', 200, 8); -Warnings: -Warning 1265 Data truncated for column 'f120' at row 1 select f120, f122, f136, f144, @test_var from tb3 where f122 = 'Test 3.5.8.5-case' order by f120,f136; f120 f122 f136 f144 @test_var diff --git a/mysql-test/suite/funcs_1/r/memory_trig_08.result b/mysql-test/suite/funcs_1/r/memory_trig_08.result index 03505af95c5..3f303ef607f 100644 --- a/mysql-test/suite/funcs_1/r/memory_trig_08.result +++ b/mysql-test/suite/funcs_1/r/memory_trig_08.result @@ -354,8 +354,6 @@ B Test 3.5.8.5-case 00191 0000000016 C=one C Test 3.5.8.5-case 00200 0000000001 C=one Insert into tb3 (f120, f122, f136) values ('d', 'Test 3.5.8.5-case', 152); -Warnings: -Warning 1265 Data truncated for column 'f120' at row 1 select f120, f122, f136, f144, @test_var from tb3 where f122 = 'Test 3.5.8.5-case' order by f120,f136; f120 f122 f136 f144 @test_var @@ -365,8 +363,6 @@ B Test 3.5.8.5-case 00191 0000000016 1*0000099999 C Test 3.5.8.5-case 00200 0000000001 1*0000099999 Insert into tb3 (f120, f122, f136, f144) values ('e', 'Test 3.5.8.5-case', 200, 8); -Warnings: -Warning 1265 Data truncated for column 'f120' at row 1 select f120, f122, f136, f144, @test_var from tb3 where f122 = 'Test 3.5.8.5-case' order by f120,f136; f120 f122 f136 f144 @test_var diff --git a/mysql-test/suite/funcs_1/r/myisam_trig_08.result b/mysql-test/suite/funcs_1/r/myisam_trig_08.result index 03505af95c5..3f303ef607f 100644 --- a/mysql-test/suite/funcs_1/r/myisam_trig_08.result +++ b/mysql-test/suite/funcs_1/r/myisam_trig_08.result @@ -354,8 +354,6 @@ B Test 3.5.8.5-case 00191 0000000016 C=one C Test 3.5.8.5-case 00200 0000000001 C=one Insert into tb3 (f120, f122, f136) values ('d', 'Test 3.5.8.5-case', 152); -Warnings: -Warning 1265 Data truncated for column 'f120' at row 1 select f120, f122, f136, f144, @test_var from tb3 where f122 = 'Test 3.5.8.5-case' order by f120,f136; f120 f122 f136 f144 @test_var @@ -365,8 +363,6 @@ B Test 3.5.8.5-case 00191 0000000016 1*0000099999 C Test 3.5.8.5-case 00200 0000000001 1*0000099999 Insert into tb3 (f120, f122, f136, f144) values ('e', 'Test 3.5.8.5-case', 200, 8); -Warnings: -Warning 1265 Data truncated for column 'f120' at row 1 select f120, f122, f136, f144, @test_var from tb3 where f122 = 'Test 3.5.8.5-case' order by f120,f136; f120 f122 f136 f144 @test_var diff --git a/mysql-test/suite/innodb/r/innodb_bug56947.result b/mysql-test/suite/innodb/r/innodb_bug56947.result new file mode 100644 index 00000000000..b279069d834 --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb_bug56947.result @@ -0,0 +1,8 @@ +SET @old_innodb_file_per_table=@@innodb_file_per_table; +SET GLOBAL innodb_file_per_table=0; +create table bug56947(a int not null) engine = innodb; +CREATE TABLE `bug56947#1`(a int) ENGINE=InnoDB; +alter table bug56947 add unique index (a); +ERROR HY000: Table 'test.bug56947#1' already exists +drop table `bug56947#1`; +drop table bug56947; diff --git a/mysql-test/suite/innodb/r/innodb_bug57255.result b/mysql-test/suite/innodb/r/innodb_bug57255.result new file mode 100644 index 00000000000..d61a0d42ba3 --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb_bug57255.result @@ -0,0 +1,10 @@ +create table A(id int not null primary key) engine=innodb; +create table B(id int not null auto_increment primary key, f1 int not null, foreign key(f1) references A(id) on delete cascade) engine=innodb; +create table C(id int not null auto_increment primary key, f1 int not null, foreign key(f1) references B(id) on delete cascade) engine=innodb; +insert into A values(1), (2); +DELETE FROM A where id = 1; +DELETE FROM C where f1 = 2; +DELETE FROM A where id = 1; +DROP TABLE C; +DROP TABLE B; +DROP TABLE A; diff --git a/mysql-test/suite/innodb/t/innodb_bug56947.test b/mysql-test/suite/innodb/t/innodb_bug56947.test new file mode 100644 index 00000000000..e11f39b97a8 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_bug56947.test @@ -0,0 +1,16 @@ +# +# Bug #56947 valgrind reports a memory leak in innodb-plugin.innodb-index +# +-- source include/have_innodb.inc + +SET @old_innodb_file_per_table=@@innodb_file_per_table; +# avoid a message about filed *.ibd file creation in the error log +SET GLOBAL innodb_file_per_table=0; +create table bug56947(a int not null) engine = innodb; +CREATE TABLE `bug56947#1`(a int) ENGINE=InnoDB; +--error 156 +alter table bug56947 add unique index (a); +drop table `bug56947#1`; +drop table bug56947; +--disable_query_log +SET GLOBAL innodb_file_per_table=@old_innodb_file_per_table; diff --git a/mysql-test/suite/innodb/t/innodb_bug57255.test b/mysql-test/suite/innodb/t/innodb_bug57255.test new file mode 100644 index 00000000000..2b37a0a6092 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_bug57255.test @@ -0,0 +1,36 @@ +# Test Bug #57255. Cascade deletes that affect different rows should not +# result in DB_FOREIGN_EXCEED_MAX_CASCADE error + +--source include/have_innodb.inc + +create table A(id int not null primary key) engine=innodb; + +create table B(id int not null auto_increment primary key, f1 int not null, foreign key(f1) references A(id) on delete cascade) engine=innodb; + +create table C(id int not null auto_increment primary key, f1 int not null, foreign key(f1) references B(id) on delete cascade) engine=innodb; + +insert into A values(1), (2); + +--disable_query_log +let $i=257; +while ($i) +{ +insert into B(f1) values(1); +dec $i; +} +let $i=486; +while ($i) +{ +insert into C(f1) values(2); +dec $i; +} +--enable_query_log + +# Following Deletes should not report error +DELETE FROM A where id = 1; +DELETE FROM C where f1 = 2; +DELETE FROM A where id = 1; + +DROP TABLE C; +DROP TABLE B; +DROP TABLE A; diff --git a/mysql-test/suite/perfschema/r/schema.result b/mysql-test/suite/perfschema/r/schema.result index a802539b7e0..1599d51a59f 100644 --- a/mysql-test/suite/perfschema/r/schema.result +++ b/mysql-test/suite/perfschema/r/schema.result @@ -195,6 +195,6 @@ show create table THREADS; Table Create Table THREADS CREATE TABLE `THREADS` ( `THREAD_ID` int(11) NOT NULL, - `ID` int(11) NOT NULL, - `NAME` varchar(64) NOT NULL + `PROCESSLIST_ID` int(11) DEFAULT NULL, + `NAME` varchar(128) NOT NULL ) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8 diff --git a/mysql-test/suite/rpl/r/rpl_row_trig003.result b/mysql-test/suite/rpl/r/rpl_row_trig003.result index 131af933b41..43c2ecde2b4 100644 --- a/mysql-test/suite/rpl/r/rpl_row_trig003.result +++ b/mysql-test/suite/rpl/r/rpl_row_trig003.result @@ -69,15 +69,9 @@ INSERT INTO test.t2 VALUES(NULL,0,'Testing MySQL databases is a cool ', 'MySQL C UPDATE test.t1 SET b1 = 0 WHERE b1 = 1; INSERT INTO test.t2 VALUES(NULL,1,'This is an after update test.', 'If this works, total will not be zero on the master or slave',1.4321,5.221,0,YEAR(NOW()),NOW()); UPDATE test.t2 SET b1 = 0 WHERE b1 = 1; -Warnings: -Error 1329 No data - zero rows fetched, selected, or processed INSERT INTO test.t1 VALUES(NULL,1,'add some more test data test.', 'and hope for the best', 3.321,5.221,0,YEAR(NOW()),NOW()); DELETE FROM test.t1 WHERE id = 1; -Warnings: -Error 1329 No data - zero rows fetched, selected, or processed DELETE FROM test.t2 WHERE id = 1; -Warnings: -Error 1329 No data - zero rows fetched, selected, or processed DROP TRIGGER test.t1_bi; DROP TRIGGER test.t2_ai; DROP TRIGGER test.t1_bu; diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test index 5b665e24958..318bbdca0c7 100644 --- a/mysql-test/t/ctype_utf8.test +++ b/mysql-test/t/ctype_utf8.test @@ -1439,6 +1439,26 @@ DROP TABLE t1; --echo End of 5.0 tests +# +# Bug #57272: crash in rpad() when using utf8 +# +SELECT LENGTH(RPAD(0.0115E88, 61297, _utf8'яэюя')); +SELECT LENGTH(RPAD(0.0115E88, 61297, _utf8'йцуя')); +SELECT HEX(RPAD(0x20, 2, _utf8 0xD18F)); +SELECT HEX(RPAD(0x20, 4, _utf8 0xD18F)); +SELECT HEX(LPAD(0x20, 2, _utf8 0xD18F)); +SELECT HEX(LPAD(0x20, 4, _utf8 0xD18F)); + +SELECT HEX(RPAD(_utf8 0xD18F, 3, 0x20)); +SELECT HEX(LPAD(_utf8 0xD18F, 3, 0x20)); + +SELECT HEX(INSERT(_utf8 0xD18F, 2, 1, 0x20)); +SELECT HEX(INSERT(_utf8 0xD18FD18E, 2, 1, 0x20)); + + +--echo End of 5.1 tests + + --echo Start of 5.4 tests # diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index 5bd53ec568e..2f0cd1401f1 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -11,8 +11,7 @@ ############################################################################## kill : Bug#37780 2008-12-03 HHunger need some changes to be robust enough for pushbuild. lowercase_table3 : Bug#54845 2010-06-30 alik main.lowercase_table3 on Mac OSX -mysqlhotcopy_myisam : Bug#54129 2010-08-31 alik mysqlhotcopy* fails -mysqlhotcopy_archive : Bug#54129 2010-08-31 alik mysqlhotcopy* fails query_cache_28249 : Bug#43861 2009-03-25 main.query_cache_28249 fails sporadically -sp_sync : Bug#48157 2010-02-06 5.5-m3 demands a differnt solution ctype_utf8mb4_ndb : Bug#55799, Bug#51907, disabled by Konstantin 2010-08-06 +main.mysqlhotcopy_myisam : Bug#56817 2010-10-21 anitha mysqlhotcopy* fails +main.mysqlhotcopy_archive: Bug#56817 2010-10-21 anitha mysqlhotcopy* fails diff --git a/mysql-test/t/explain.test b/mysql-test/t/explain.test index 60108b3b038..931948b1b65 100644 --- a/mysql-test/t/explain.test +++ b/mysql-test/t/explain.test @@ -238,4 +238,40 @@ EXPLAIN SELECT c1 FROM t1 WHERE c2 = 1 AND c4 = 1 AND c5 = 1; DROP TABLE t1; +--echo # +--echo # Bug#56814 Explain + subselect + fulltext crashes server +--echo # + +CREATE TABLE t1(f1 VARCHAR(6) NOT NULL, +FULLTEXT KEY(f1),UNIQUE(f1)); +INSERT INTO t1 VALUES ('test'); + +EXPLAIN SELECT 1 FROM t1 +WHERE 1 > ALL((SELECT 1 FROM t1 JOIN t1 a ON (MATCH(t1.f1) AGAINST ("")) +WHERE t1.f1 GROUP BY t1.f1)); + +PREPARE stmt FROM +'EXPLAIN SELECT 1 FROM t1 + WHERE 1 > ALL((SELECT 1 FROM t1 RIGHT OUTER JOIN t1 a + ON (MATCH(t1.f1) AGAINST ("")) + WHERE t1.f1 GROUP BY t1.f1))'; + +EXECUTE stmt; +EXECUTE stmt; + +DEALLOCATE PREPARE stmt; + +PREPARE stmt FROM +'EXPLAIN SELECT 1 FROM t1 + WHERE 1 > ALL((SELECT 1 FROM t1 JOIN t1 a + ON (MATCH(t1.f1) AGAINST ("")) + WHERE t1.f1 GROUP BY t1.f1))'; + +EXECUTE stmt; +EXECUTE stmt; + +DEALLOCATE PREPARE stmt; + +DROP TABLE t1; + --echo End of 5.1 tests. diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test index 388b1432390..db7d9fd2d08 100644 --- a/mysql-test/t/fulltext.test +++ b/mysql-test/t/fulltext.test @@ -594,4 +594,41 @@ REPAIR TABLE t1; SET myisam_sort_buffer_size=@@global.myisam_sort_buffer_size; DROP TABLE t1; +--echo # +--echo # Bug#54484 explain + prepared statement: crash and Got error -1 from storage engine +--echo # + +CREATE TABLE t1(f1 VARCHAR(6) NOT NULL, FULLTEXT KEY(f1), UNIQUE(f1)); +INSERT INTO t1 VALUES ('test'); +--disable_warnings +SELECT 1 FROM t1 WHERE 1 > + ALL((SELECT 1 FROM t1 JOIN t1 a + ON (MATCH(t1.f1) against ("")) + WHERE t1.f1 GROUP BY t1.f1)) xor f1; + +PREPARE stmt FROM +'SELECT 1 FROM t1 WHERE 1 > + ALL((SELECT 1 FROM t1 RIGHT OUTER JOIN t1 a + ON (MATCH(t1.f1) against ("")) + WHERE t1.f1 GROUP BY t1.f1)) xor f1'; + +EXECUTE stmt; +EXECUTE stmt; + +DEALLOCATE PREPARE stmt; + +PREPARE stmt FROM +'SELECT 1 FROM t1 WHERE 1 > + ALL((SELECT 1 FROM t1 JOIN t1 a + ON (MATCH(t1.f1) against ("")) + WHERE t1.f1 GROUP BY t1.f1))'; + +EXECUTE stmt; +EXECUTE stmt; + +DEALLOCATE PREPARE stmt; +--enable_warnings + +DROP TABLE t1; + --echo End of 5.1 tests diff --git a/mysql-test/t/func_gconcat.test b/mysql-test/t/func_gconcat.test index 0624fce3a34..13b3697cbf6 100644 --- a/mysql-test/t/func_gconcat.test +++ b/mysql-test/t/func_gconcat.test @@ -738,6 +738,17 @@ EXECUTE stmt; DEALLOCATE PREPARE stmt; DROP TABLE t1; +--echo # +--echo # Bug#57194 group_concat cause crash and/or invalid memory reads with type errors +--echo # + +CREATE TABLE t1(f1 int); +INSERT INTO t1 values (0),(0); +--disable_ps_protocol +--error ER_ILLEGAL_VALUE_FOR_TYPE +SELECT POLYGON((SELECT 1 FROM (SELECT 1 IN (GROUP_CONCAT(t1.f1)) FROM t1, t1 t GROUP BY t.f1 ) d)); +--enable_ps_protocol +DROP TABLE t1; --echo End of 5.1 tests diff --git a/mysql-test/t/func_math.test b/mysql-test/t/func_math.test index efdf7201a40..1e7026b0bcb 100644 --- a/mysql-test/t/func_math.test +++ b/mysql-test/t/func_math.test @@ -316,6 +316,14 @@ SELECT RAND(i) FROM t1; DROP TABLE t1; --echo # +--echo # Bug#57477 SIGFPE when dividing a huge number a negative number +--echo # +--error ER_DATA_OUT_OF_RANGE +SELECT -9999999999999999991 DIV -1; +--error ER_DATA_OUT_OF_RANGE +SELECT -9223372036854775808 DIV -1; +SELECT -9223372036854775808 MOD -1; +SELECT -9223372036854775808999 MOD -1; # # Bug #8457: Precision math: diff --git a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test index ec71e950ca7..2251ae45b3f 100644 --- a/mysql-test/t/func_misc.test +++ b/mysql-test/t/func_misc.test @@ -504,4 +504,15 @@ SELECT DISTINCT GREATEST(a, (SELECT b FROM t1 LIMIT 1)) FROM t1 UNION SELECT 1; DROP TABLE t1; + +# +# Bug #57283: inet_ntoa() crashes +# +SELECT INET_NTOA(0); +SELECT '1' IN ('1', INET_NTOA(0)); + + --echo End of 5.1 tests + + +--echo End of tests diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test index 2fb73af0c99..282b286749a 100644 --- a/mysql-test/t/group_by.test +++ b/mysql-test/t/group_by.test @@ -1236,6 +1236,17 @@ SELECT SUBSTRING(a,1,10), LENGTH(a) FROM t1 GROUP BY a; SELECT SUBSTRING(a,1,10), LENGTH(a) FROM t1 GROUP BY a; DROP TABLE t1; +--echo # +--echo # Bug#57688 Assertion `!table || (!table->write_set || bitmap_is_set(table->write_set, field +--echo # + +CREATE TABLE t1(f1 INT NOT NULL); +INSERT INTO t1 VALUES (16777214),(0); + +SELECT COUNT(*) FROM t1 LEFT JOIN t1 t2 +ON 1 WHERE t2.f1 > 1 GROUP BY t2.f1; + +DROP TABLE t1; --echo # End of 5.1 tests diff --git a/mysql-test/t/join_outer.test b/mysql-test/t/join_outer.test index cf881e6aaa2..3251ff292b6 100644 --- a/mysql-test/t/join_outer.test +++ b/mysql-test/t/join_outer.test @@ -981,4 +981,33 @@ EXPLAIN EXTENDED SELECT STRAIGHT_JOIN jt1.f1 FROM t1 AS jt1 DROP TABLE t1; +--echo # +--echo # Bug#57688 Assertion `!table || (!table->write_set || bitmap_is_set(table->write_set, field +--echo # + +CREATE TABLE t1 (f1 INT NOT NULL, PRIMARY KEY (f1)); +CREATE TABLE t2 (f1 INT NOT NULL, f2 INT NOT NULL, PRIMARY KEY (f1, f2)); + +INSERT INTO t1 VALUES (4); +INSERT INTO t2 VALUES (3, 3); +INSERT INTO t2 VALUES (7, 7); + +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1 +WHERE t1.f1 = 4 +GROUP BY t2.f1, t2.f2; + +SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1 +WHERE t1.f1 = 4 +GROUP BY t2.f1, t2.f2; + +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1 +WHERE t1.f1 = 4 AND t2.f1 IS NOT NULL AND t2.f2 IS NOT NULL +GROUP BY t2.f1, t2.f2; + +SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1 +WHERE t1.f1 = 4 AND t2.f1 IS NOT NULL AND t2.f2 IS NOT NULL +GROUP BY t2.f1, t2.f2; + +DROP TABLE t1,t2; + --echo End of 5.1 tests diff --git a/mysql-test/t/lock_sync.test b/mysql-test/t/lock_sync.test index 7131e2cde31..d5ad7becd7d 100644 --- a/mysql-test/t/lock_sync.test +++ b/mysql-test/t/lock_sync.test @@ -1078,6 +1078,65 @@ DROP TABLE t1; SET DEBUG_SYNC= 'RESET'; +--echo # +--echo # Bug#57130 crash in Item_field::print during SHOW CREATE TABLE or VIEW +--echo # + +--disable_warnings +DROP TABLE IF EXISTS t1; +DROP VIEW IF EXISTS v1; +DROP FUNCTION IF EXISTS f1; +--enable_warnings + +CREATE TABLE t1(a INT); +CREATE FUNCTION f1() RETURNS INTEGER RETURN 1; +CREATE VIEW v1 AS SELECT * FROM t1 WHERE f1() = 1; +DROP FUNCTION f1; +connect(con2, localhost, root); + +--echo # Connection con1 +connect (con1, localhost, root); +# Need to trigger this sync point at least twice in order to +# get valgrind test failures without the patch +SET DEBUG_SYNC= 'open_tables_after_open_and_process_table SIGNAL opened WAIT_FOR dropped EXECUTE 2'; +--echo # Sending: +--send SHOW CREATE VIEW v1 + +--echo # Connection con2 +connection con2; +SET DEBUG_SYNC= 'now WAIT_FOR opened'; +SET DEBUG_SYNC= 'now SIGNAL dropped'; +SET DEBUG_SYNC= 'now WAIT_FOR opened'; +--echo # Sending: +--send FLUSH TABLES + +--echo # Connection default +connection default; +--echo # Waiting for FLUSH TABLES to be blocked. +let $wait_condition= SELECT COUNT(*)=1 FROM information_schema.processlist + WHERE state= 'Waiting for table flush' AND info= 'FLUSH TABLES'; +--source include/wait_condition.inc +SET DEBUG_SYNC= 'now SIGNAL dropped'; + +--echo # Connection con1 +connection con1; +--echo # Reaping: SHOW CREATE VIEW v1 +--reap + +--echo # Connection con2 +connection con2; +--echo # Reaping: FLUSH TABLES +--reap + +--echo # Connection default +connection default; +SET DEBUG_SYNC= 'RESET'; +DROP VIEW v1; +DROP TABLE t1; +disconnect con1; +disconnect con2; + + # Check that all connections opened by test cases in this file are really # gone so execution of other tests won't be affected by their presence. --source include/wait_until_count_sessions.inc diff --git a/mysql-test/t/partition_innodb.test b/mysql-test/t/partition_innodb.test index 3e9ac2ce2b5..21769a8b944 100644 --- a/mysql-test/t/partition_innodb.test +++ b/mysql-test/t/partition_innodb.test @@ -9,6 +9,31 @@ drop table if exists t1, t2; let $MYSQLD_DATADIR= `SELECT @@datadir`; --echo # +--echo # Bug#56287: crash when using Partition datetime in sub in query +--echo # + +CREATE TABLE t1 +(c1 bigint(20) unsigned NOT NULL AUTO_INCREMENT, + c2 varchar(40) not null default '', + c3 datetime not NULL, + PRIMARY KEY (c1,c3), + KEY partidx(c3)) +ENGINE=InnoDB +PARTITION BY RANGE (TO_DAYS(c3)) +(PARTITION p200912 VALUES LESS THAN (to_days('2010-01-01')), + PARTITION p201103 VALUES LESS THAN (to_days('2011-04-01')), + PARTITION p201912 VALUES LESS THAN MAXVALUE); + +insert into t1(c2,c3) values ("Test row",'2010-01-01 00:00:00'); + +SELECT PARTITION_NAME, TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME = 't1' AND TABLE_SCHEMA = 'test'; +SELECT count(*) FROM t1 p where c3 in +(select c3 from t1 t where t.c3 < date '2011-04-26 19:19:44' + and t.c3 > date '2011-04-26 19:18:44') ; + +DROP TABLE t1; + +--echo # --echo # Bug#54747: Deadlock between REORGANIZE PARTITION and --echo # SELECT is not detected --echo # @@ -552,6 +577,19 @@ connection default; SELECT * FROM t1; COMMIT; DROP TABLE t1; + +# +# Bug #55146 Assertion `m_part_spec.start_part == m_part_spec.end_part' in index_read_idx_map +# + +CREATE TABLE t1 (i1 int NOT NULL primary key, f1 int) ENGINE = InnoDB + PARTITION BY HASH(i1) PARTITIONS 2; + +INSERT INTO t1 VALUES (1,1), (2,2); + +SELECT * FROM t1 WHERE i1 = ( SELECT i1 FROM t1 WHERE f1=0 LIMIT 1 ); +DROP TABLE t1; + --enable_parsing --echo # diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test index f7ce70c1d3a..bf15648951b 100644 --- a/mysql-test/t/ps.test +++ b/mysql-test/t/ps.test @@ -3079,7 +3079,27 @@ EXECUTE stmt; DEALLOCATE PREPARE stmt; DROP TABLE t1; -########################################################################### +--echo # +--echo # Bug#54494 crash with explain extended and prepared statements +--echo # +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (1),(2); +PREPARE stmt FROM 'EXPLAIN EXTENDED SELECT 1 FROM t1 RIGHT JOIN t1 t2 ON 1'; +EXECUTE stmt; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +DROP TABLE t1; + +--echo # +--echo # Bug#54488 crash when using explain and prepared statements with subqueries +--echo # +CREATE TABLE t1(f1 INT); +INSERT INTO t1 VALUES (1),(1); +PREPARE stmt FROM 'EXPLAIN SELECT 1 FROM t1 WHERE (SELECT (SELECT 1 FROM t1 GROUP BY f1))'; +EXECUTE stmt; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +DROP TABLE t1; --echo --echo End of 5.1 tests. diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test index 13ca55a0127..6175fc53adf 100644 --- a/mysql-test/t/sp-error.test +++ b/mysql-test/t/sp-error.test @@ -2719,10 +2719,6 @@ DROP PROCEDURE p1; --echo # Bug#5889: Exit handler for a warning doesn't hide the warning in trigger --echo # ---echo ---echo # - Case 1 ---echo - CREATE TABLE t1(a INT, b INT); INSERT INTO t1 VALUES (1, 2); @@ -2747,36 +2743,6 @@ SELECT * FROM t1; DROP TRIGGER t1_bu; DROP TABLE t1; ---echo ---echo # - Case 2 ---echo - -CREATE TABLE t1(a INT); -CREATE TABLE t2(b CHAR(1)); - -delimiter |; - -CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW -BEGIN - INSERT INTO t2 VALUES('ab'); # Produces a warning. - - INSERT INTO t2 VALUES('b'); # Does not produce a warning, - # previous warning should be cleared. -END| - -delimiter ;| - -INSERT INTO t1 VALUES(0); - -SHOW WARNINGS; - -SELECT * FROM t1; -SELECT * FROM t2; - -DROP TRIGGER t1_bi; -DROP TABLE t1; -DROP TABLE t2; - --echo # --echo # Bug#9857: Stored procedures: handler for sqlwarning ignored --echo # @@ -2813,3 +2779,83 @@ SHOW WARNINGS; DROP PROCEDURE p1; DROP PROCEDURE p2; SET sql_mode = @sql_mode_saved; + +--echo # +--echo # Bug#55850: Trigger warnings not cleared. +--echo # + +--disable_warnings +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +DROP PROCEDURE IF EXISTS p1; +--enable_warnings + +CREATE TABLE t1(x SMALLINT, y SMALLINT, z SMALLINT); +CREATE TABLE t2(a SMALLINT, b SMALLINT, c SMALLINT, + d SMALLINT, e SMALLINT, f SMALLINT); + +CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW + INSERT INTO t2(a, b, c) VALUES(99999, 99999, 99999); + +CREATE TRIGGER t1_ai AFTER INSERT ON t1 FOR EACH ROW + INSERT INTO t2(d, e, f) VALUES(99999, 99999, 99999); + +CREATE PROCEDURE p1() + INSERT INTO t1 VALUES(99999, 99999, 99999); + +# What happened before the patch was: +# - INSERT INTO t1 added 3 warnings about overflow in 'x', 'y' and 'z' columns; +# - t1_bi run and added 3 warnings about overflow in 'a', 'b' and 'c' columns; +# - t1_ai run and added 3 warnings about overflow in 'd', 'e' and 'f' columns; +# => we had 9 warnings. +# +# Now what happens is: +# - INSERT INTO t1 adds 3 warnings about overflow in 'x', 'y' and 'z' columns; +# - t1_bi adds 3 warnings about overflow in 'a', 'b' and 'c' columns; +# - The warnings added by triggers are cleared; +# - t1_ai run and added 3 warnings about overflow in 'd', 'e' and 'f' columns; +# - The warnings added by triggers are cleared; +# => we have 3 warnings. + +--echo +CALL p1(); + +--echo +SHOW WARNINGS; + +--echo +DROP TABLE t1; +DROP TABLE t2; +DROP PROCEDURE p1; + +--echo # ---------------------------------------------------------------------- + +CREATE TABLE t1(x SMALLINT, y SMALLINT, z SMALLINT); +CREATE TABLE t2(a SMALLINT, b SMALLINT, c SMALLINT NOT NULL); + +delimiter |; + +CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW +BEGIN + INSERT INTO t2 VALUES( + CAST('111111 ' AS SIGNED), + CAST('222222 ' AS SIGNED), + NULL); +END| + +delimiter ;| + +CREATE PROCEDURE p1() + INSERT INTO t1 VALUES(99999, 99999, 99999); + +--echo +--error ER_BAD_NULL_ERROR +CALL p1(); + +--echo +SHOW WARNINGS; + +--echo +DROP TABLE t1; +DROP TABLE t2; +DROP PROCEDURE p1; diff --git a/mysql-test/t/truncate_coverage.test b/mysql-test/t/truncate_coverage.test index c9c4bd90ca4..135935b53b3 100644 --- a/mysql-test/t/truncate_coverage.test +++ b/mysql-test/t/truncate_coverage.test @@ -172,3 +172,57 @@ UNLOCK TABLES; DROP TABLE t1; SET DEBUG_SYNC='RESET'; +--echo # +--echo # Bug#57659 Segfault in Query_cache::invalidate_data for TRUNCATE TABLE +--echo # + +--echo # Note that this test case only reproduces the problem +--echo # when it is run with valgrind. + +--disable_warnings +DROP TABLE IF EXISTS t1, m1; +--enable_warnings + +CREATE TABLE t1(a INT) engine=memory; +CREATE TABLE m1(a INT) engine=merge UNION(t1); +connect(con2, localhost, root); + +--echo # Connection con1 +connect(con1, localhost, root); +SET DEBUG_SYNC= 'open_tables_after_open_and_process_table SIGNAL opened WAIT_FOR dropped'; +--echo # Sending: +--send TRUNCATE TABLE m1 + +--echo # Connection con2 +connection con2; +SET DEBUG_SYNC= 'now WAIT_FOR opened'; +--echo # Sending: +--send FLUSH TABLES + +--echo # Connection default +connection default; +--echo # Waiting for FLUSH TABLES to be blocked. +let $wait_condition= SELECT COUNT(*)=1 FROM information_schema.processlist + WHERE state= 'Waiting for table flush' AND info= 'FLUSH TABLES'; +--source include/wait_condition.inc +SET DEBUG_SYNC= 'now SIGNAL dropped'; + +--echo # Connection con1 +connection con1; +--echo # Reaping: TRUNCATE TABLE m1 +--error ER_WRONG_MRG_TABLE +--reap +disconnect con1; +--source include/wait_until_disconnected.inc + +--echo # Connection con2 +connection con2; +--echo # Reaping: FLUSH TABLES +--reap +disconnect con2; +--source include/wait_until_disconnected.inc + +--echo # Connection default +connection default; +SET DEBUG_SYNC= 'RESET'; +DROP TABLE m1, t1; diff --git a/mysys/my_symlink.c b/mysys/my_symlink.c index 258e227bb7b..b57edd2179a 100644 --- a/mysys/my_symlink.c +++ b/mysys/my_symlink.c @@ -113,7 +113,6 @@ int my_is_symlink(const char *filename __attribute__((unused))) #endif } - /* Resolve all symbolic links in path 'to' may be equal to 'filename' @@ -147,7 +146,23 @@ int my_realpath(char *to, const char *filename, } DBUG_RETURN(result); #else +#ifdef _WIN32 + int ret= GetFullPathName(filename,FN_REFLEN,
+ to,
+ NULL); + if (ret == 0 || ret > FN_REFLEN) + { + if (ret > FN_REFLEN) + my_errno= ENAMETOOLONG; + else + my_errno= EACCES; + if (MyFlags & MY_WME) + my_error(EE_REALPATH, MYF(0), filename, my_errno); + return -1; + } +#else my_load_path(to, filename, NullS); +#endif return 0; #endif } diff --git a/plugin/auth/dialog.c b/plugin/auth/dialog.c index 54f88dd9b4e..41312f95674 100644 --- a/plugin/auth/dialog.c +++ b/plugin/auth/dialog.c @@ -52,7 +52,7 @@ /** first byte of the question string is the question "type". - It can be a "ordinary" or a "password" question. + It can be an "ordinary" or a "password" question. The last bit set marks a last question in the authentication exchange. */ #define ORDINARY_QUESTION "\2" @@ -176,7 +176,7 @@ mysql_declare_plugin_end; This plugin performs a dialog with the user, asking questions and reading answers. Depending on the client it may be desirable to do it using GUI, or console, with or without curses, or read answers - from a smardcard, for example. + from a smartcard, for example. To support all this variety, the dialog plugin has a callback function "authentication_dialog_ask". If the client has a function of this name @@ -256,7 +256,7 @@ static int perform_dialog(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql) in mysql_change_user() the client sends the first packet, so the first vio->read_packet() does nothing (pkt == 0). - We send the "password", assuming the client knows what its doing. + We send the "password", assuming the client knows what it's doing. (in other words, the dialog plugin should be only set as a default authentication plugin on the client if the first question asks for a password - which will be sent in clear text, by the way) diff --git a/plugin/auth/test_plugin.c b/plugin/auth/test_plugin.c index caea7795833..161062d5b6c 100644 --- a/plugin/auth/test_plugin.c +++ b/plugin/auth/test_plugin.c @@ -17,22 +17,12 @@ /** @file - dialog client authentication plugin with examples - - dialog is a general purpose client authentication plugin, it simply - asks the user the question, as provided by the server and reports - the answer back to the server. No encryption is involved, - the answers are sent in clear text. - - Two examples are provided: two_questions server plugin, that asks - the password and an "Are you sure?" question with a reply "yes, of course". - It demonstrates the usage of "password" (input is hidden) and "ordinary" - (input can be echoed) questions, and how to mark the last question, - to avoid an extra roundtrip. - - And three_attempts plugin that gives the user three attempts to enter - a correct password. It shows the situation when a number of questions - is not known in advance. + Test driver for the mysql-test/t/plugin_auth.test + + This is a set of test plugins used to test the external authentication + implementation. + See the above test file for more details. + This test plugin is based on the dialog plugin example. */ #include <my_global.h> @@ -55,7 +45,7 @@ /********************* SERVER SIDE ****************************************/ /** - dialog test plugin mimicing the ordinary auth mechanism. Used to test the auth plugin API + dialog test plugin mimicking the ordinary auth mechanism. Used to test the auth plugin API */ static int auth_test_plugin(MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info) { @@ -150,10 +140,10 @@ static int test_plugin_client(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql) in mysql_change_user() the client sends the first packet, so the first vio->read_packet() does nothing (pkt == 0). - We send the "password", assuming the client knows what its doing. + We send the "password", assuming the client knows what it's doing. (in other words, the dialog plugin should be only set as a default authentication plugin on the client if the first question - asks for a password - which will be sent in cleat text, by the way) + asks for a password - which will be sent in clear text, by the way) */ reply= mysql->passwd; } diff --git a/sql/field.cc b/sql/field.cc index d746de385b6..ce1b1fc6eb0 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -7725,12 +7725,6 @@ void Field_blob::sql_type(String &res) const uchar *Field_blob::pack(uchar *to, const uchar *from, uint max_length, bool low_byte_first) { - DBUG_ENTER("Field_blob::pack"); - DBUG_PRINT("enter", ("to: 0x%lx; from: 0x%lx;" - " max_length: %u; low_byte_first: %d", - (ulong) to, (ulong) from, - max_length, low_byte_first)); - DBUG_DUMP("record", from, table->s->reclength); uchar *save= ptr; ptr= (uchar*) from; uint32 length=get_length(); // Length of from string @@ -7751,8 +7745,7 @@ uchar *Field_blob::pack(uchar *to, const uchar *from, memcpy(to+packlength, from,length); } ptr=save; // Restore org row pointer - DBUG_DUMP("packed", to, packlength + length); - DBUG_RETURN(to+packlength+length); + return to+packlength+length; } @@ -8396,6 +8389,50 @@ uint Field_enum::is_equal(Create_field *new_field) } +uchar *Field_enum::pack(uchar *to, const uchar *from, + uint max_length, bool low_byte_first) +{ + DBUG_ENTER("Field_enum::pack"); + DBUG_PRINT("debug", ("packlength: %d", packlength)); + DBUG_DUMP("from", from, packlength); + + switch (packlength) + { + case 1: + *to = *from; + DBUG_RETURN(to + 1); + case 2: DBUG_RETURN(pack_int16(to, from, low_byte_first)); + case 3: DBUG_RETURN(pack_int24(to, from, low_byte_first)); + case 4: DBUG_RETURN(pack_int32(to, from, low_byte_first)); + case 8: DBUG_RETURN(pack_int64(to, from, low_byte_first)); + default: + DBUG_ASSERT(0); + } +} + +const uchar *Field_enum::unpack(uchar *to, const uchar *from, + uint param_data, bool low_byte_first) +{ + DBUG_ENTER("Field_enum::unpack"); + DBUG_PRINT("debug", ("packlength: %d", packlength)); + DBUG_DUMP("from", from, packlength); + + switch (packlength) + { + case 1: + *to = *from; + DBUG_RETURN(from + 1); + + case 2: DBUG_RETURN(unpack_int16(to, from, low_byte_first)); + case 3: DBUG_RETURN(unpack_int24(to, from, low_byte_first)); + case 4: DBUG_RETURN(unpack_int32(to, from, low_byte_first)); + case 8: DBUG_RETURN(unpack_int64(to, from, low_byte_first)); + default: + DBUG_ASSERT(0); + } +} + + /** @return returns 1 if the fields are equally defined diff --git a/sql/field.h b/sql/field.h index 7b250c34fe4..d854b78f9a3 100644 --- a/sql/field.h +++ b/sql/field.h @@ -554,6 +554,48 @@ private: { return 0; } protected: + static void handle_int16(uchar *to, const uchar *from, + bool low_byte_first_from, bool low_byte_first_to) + { + int16 val; +#ifdef WORDS_BIGENDIAN + if (low_byte_first_from) + val = sint2korr(from); + else +#endif + shortget(val, from); + +#ifdef WORDS_BIGENDIAN + if (low_byte_first_to) + int2store(to, val); + else +#endif + shortstore(to, val); + } + + static void handle_int24(uchar *to, const uchar *from, + bool low_byte_first_from, bool low_byte_first_to) + { + int32 val; +#ifdef WORDS_BIGENDIAN + if (low_byte_first_from) + val = sint3korr(from); + else +#endif + val= (from[0] << 16) + (from[1] << 8) + from[2]; + +#ifdef WORDS_BIGENDIAN + if (low_byte_first_to) + int2store(to, val); + else +#endif + { + to[0]= 0xFF & (val >> 16); + to[1]= 0xFF & (val >> 8); + to[2]= 0xFF & val; + } + } + /* Helper function to pack()/unpack() int32 values */ @@ -598,6 +640,32 @@ protected: longlongstore(to, val); } + uchar *pack_int16(uchar *to, const uchar *from, bool low_byte_first_to) + { + handle_int16(to, from, table->s->db_low_byte_first, low_byte_first_to); + return to + sizeof(int16); + } + + const uchar *unpack_int16(uchar* to, const uchar *from, + bool low_byte_first_from) + { + handle_int16(to, from, low_byte_first_from, table->s->db_low_byte_first); + return from + sizeof(int16); + } + + uchar *pack_int24(uchar *to, const uchar *from, bool low_byte_first_to) + { + handle_int24(to, from, table->s->db_low_byte_first, low_byte_first_to); + return to + 3; + } + + const uchar *unpack_int24(uchar* to, const uchar *from, + bool low_byte_first_from) + { + handle_int24(to, from, low_byte_first_from, table->s->db_low_byte_first); + return from + 3; + } + uchar *pack_int32(uchar *to, const uchar *from, bool low_byte_first_to) { handle_int32(to, from, table->s->db_low_byte_first, low_byte_first_to); @@ -918,41 +986,13 @@ public: virtual uchar *pack(uchar* to, const uchar *from, uint max_length, bool low_byte_first) { - int16 val; -#ifdef WORDS_BIGENDIAN - if (table->s->db_low_byte_first) - val = sint2korr(from); - else -#endif - shortget(val, from); - -#ifdef WORDS_BIGENDIAN - if (low_byte_first) - int2store(to, val); - else -#endif - shortstore(to, val); - return to + sizeof(val); + return pack_int16(to, from, low_byte_first); } virtual const uchar *unpack(uchar* to, const uchar *from, uint param_data, bool low_byte_first) { - int16 val; -#ifdef WORDS_BIGENDIAN - if (low_byte_first) - val = sint2korr(from); - else -#endif - shortget(val, from); - -#ifdef WORDS_BIGENDIAN - if (table->s->db_low_byte_first) - int2store(to, val); - else -#endif - shortstore(to, val); - return from + sizeof(val); + return unpack_int16(to, from, low_byte_first); } }; @@ -1895,6 +1935,12 @@ public: bool has_charset(void) const { return TRUE; } /* enum and set are sorted as integers */ CHARSET_INFO *sort_charset(void) const { return &my_charset_bin; } + + virtual uchar *pack(uchar *to, const uchar *from, + uint max_length, bool low_byte_first); + virtual const uchar *unpack(uchar *to, const uchar *from, + uint param_data, bool low_byte_first); + private: int do_save_field_metadata(uchar *first_byte); uint is_equal(Create_field *new_field); diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 3d8d5ae9eb8..52eda6c507f 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -4392,8 +4392,12 @@ int ha_partition::index_read_idx_map(uchar *buf, uint index, get_partition_set(table, buf, index, &m_start_key, &m_part_spec); - /* How can it be more than one partition with the current use? */ - DBUG_ASSERT(m_part_spec.start_part == m_part_spec.end_part); + /* + We have either found exactly 1 partition + (in which case start_part == end_part) + or no matching partitions (start_part > end_part) + */ + DBUG_ASSERT(m_part_spec.start_part >= m_part_spec.end_part); for (part= m_part_spec.start_part; part <= m_part_spec.end_part; part++) { @@ -4628,6 +4632,7 @@ int ha_partition::partition_scan_set_up(uchar * buf, bool idx_read_flag) key not found. */ DBUG_PRINT("info", ("scan with no partition to scan")); + table->status= STATUS_NOT_FOUND; DBUG_RETURN(HA_ERR_END_OF_FILE); } if (m_part_spec.start_part == m_part_spec.end_part) @@ -4652,6 +4657,7 @@ int ha_partition::partition_scan_set_up(uchar * buf, bool idx_read_flag) if (start_part == MY_BIT_NONE) { DBUG_PRINT("info", ("scan with no partition to scan")); + table->status= STATUS_NOT_FOUND; DBUG_RETURN(HA_ERR_END_OF_FILE); } if (start_part > m_part_spec.start_part) diff --git a/sql/item_func.cc b/sql/item_func.cc index afb09ff5b17..73c22de0da9 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -5727,7 +5727,17 @@ void Item_func_match::init_search(bool no_order) /* Check if init_search() has been called before */ if (ft_handler) + { + /* + We should reset ft_handler as it is cleaned up + on destruction of FT_SELECT object + (necessary in case of re-execution of subquery). + TODO: FT_SELECT should not clean up ft_handler. + */ + if (join_key) + table->file->ft_handler= ft_handler; DBUG_VOID_RETURN; + } if (key == NO_SUCH_KEY) { diff --git a/sql/item_func.h b/sql/item_func.h index 15730516c71..63662d97019 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -1595,7 +1595,7 @@ public: join_key(0), ft_handler(0), table(0), master(0), concat_ws(0) { } void cleanup() { - DBUG_ENTER("Item_func_match"); + DBUG_ENTER("Item_func_match::cleanup"); Item_real_func::cleanup(); if (!master && ft_handler) ft_handler->please->close_search(ft_handler); diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 89c1e785c71..6d8a113d4a4 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1184,6 +1184,20 @@ String *Item_func_insert::val_str(String *str) if ((length < 0) || (length > res->length())) length= res->length(); + /* + There is one exception not handled (intentionaly) by the character set + aggregation code. If one string is strong side and is binary, and + another one is weak side and is a multi-byte character string, + then we need to operate on the second string in terms on bytes when + calling ::numchars() and ::charpos(), rather than in terms of characters. + Lets substitute its character set to binary. + */ + if (collation.collation == &my_charset_bin) + { + res->set_charset(&my_charset_bin); + res2->set_charset(&my_charset_bin); + } + /* start and length are now sufficiently valid to pass to charpos function */ start= res->charpos((int) start); length= res->charpos((int) length, (uint32) start); @@ -2725,6 +2739,20 @@ String *Item_func_rpad::val_str(String *str) /* Set here so that rest of code sees out-of-bound value as such. */ if ((ulonglong) count > INT_MAX32) count= INT_MAX32; + /* + There is one exception not handled (intentionaly) by the character set + aggregation code. If one string is strong side and is binary, and + another one is weak side and is a multi-byte character string, + then we need to operate on the second string in terms on bytes when + calling ::numchars() and ::charpos(), rather than in terms of characters. + Lets substitute its character set to binary. + */ + if (collation.collation == &my_charset_bin) + { + res->set_charset(&my_charset_bin); + rpad->set_charset(&my_charset_bin); + } + if (count <= (res_char_length= res->numchars())) { // String to pad is big enough res->length(res->charpos((int) count)); // Shorten result if longer @@ -2814,6 +2842,20 @@ String *Item_func_lpad::val_str(String *str) if ((ulonglong) count > INT_MAX32) count= INT_MAX32; + /* + There is one exception not handled (intentionaly) by the character set + aggregation code. If one string is strong side and is binary, and + another one is weak side and is a multi-byte character string, + then we need to operate on the second string in terms on bytes when + calling ::numchars() and ::charpos(), rather than in terms of characters. + Lets substitute its character set to binary. + */ + if (collation.collation == &my_charset_bin) + { + res->set_charset(&my_charset_bin); + pad->set_charset(&my_charset_bin); + } + res_char_length= res->numchars(); if (count <= res_char_length) diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 56bd8c75a20..c1b1f47e5e9 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -1910,19 +1910,28 @@ int subselect_single_select_engine::exec() DBUG_RETURN(join->error ? join->error : 1); } if (!select_lex->uncacheable && thd->lex->describe && - !(join->select_options & SELECT_DESCRIBE) && - join->need_tmp && item->const_item()) + !(join->select_options & SELECT_DESCRIBE)) { - /* - Force join->join_tmp creation, because this subquery will be replaced - by a simple select from the materialization temp table by optimize() - called by EXPLAIN and we need to preserve the initial query structure - so we can display it. - */ - select_lex->uncacheable|= UNCACHEABLE_EXPLAIN; - select_lex->master_unit()->uncacheable|= UNCACHEABLE_EXPLAIN; - if (join->init_save_join_tab()) - DBUG_RETURN(1); /* purecov: inspected */ + item->update_used_tables(); + if (item->const_item()) + { + /* + It's necessary to keep original JOIN table because + create_sort_index() function may overwrite original + JOIN_TAB::type and wrong optimization method can be + selected on re-execution. + */ + select_lex->uncacheable|= UNCACHEABLE_EXPLAIN; + select_lex->master_unit()->uncacheable|= UNCACHEABLE_EXPLAIN; + /* + Force join->join_tmp creation, because this subquery will be replaced + by a simple select from the materialization temp table by optimize() + called by EXPLAIN and we need to preserve the initial query structure + so we can display it. + */ + if (join->need_tmp && join->init_save_join_tab()) + DBUG_RETURN(1); /* purecov: inspected */ + } } if (item->engine_changed) { diff --git a/sql/item_sum.cc b/sql/item_sum.cc index b6e5d6d3182..8cd8e1bb222 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -3395,8 +3395,6 @@ String* Item_func_group_concat::val_str(String* str) void Item_func_group_concat::print(String *str, enum_query_type query_type) { - /* orig_args is not filled with valid values until fix_fields() */ - Item **pargs= fixed ? orig_args : args; str->append(STRING_WITH_LEN("group_concat(")); if (distinct) str->append(STRING_WITH_LEN("distinct ")); @@ -3404,7 +3402,7 @@ void Item_func_group_concat::print(String *str, enum_query_type query_type) { if (i) str->append(','); - pargs[i]->print(str, query_type); + orig_args[i]->print(str, query_type); } if (arg_count_order) { @@ -3413,7 +3411,7 @@ void Item_func_group_concat::print(String *str, enum_query_type query_type) { if (i) str->append(','); - pargs[i + arg_count_field]->print(str, query_type); + orig_args[i + arg_count_field]->print(str, query_type); if (order[i]->asc) str->append(STRING_WITH_LEN(" ASC")); else diff --git a/sql/rpl_record.cc b/sql/rpl_record.cc index 8219f70727e..dd16318303d 100644 --- a/sql/rpl_record.cc +++ b/sql/rpl_record.cc @@ -78,8 +78,6 @@ pack_row(TABLE *table, MY_BITMAP const* cols, unsigned int null_mask= 1U; for ( ; (field= *p_field) ; p_field++) { - DBUG_PRINT("debug", ("null_mask=%d; null_ptr=%p; row_data=%p; null_byte_count=%d", - null_mask, null_ptr, row_data, null_byte_count)); if (bitmap_is_set(cols, p_field - table->field)) { my_ptrdiff_t offset; @@ -110,6 +108,7 @@ pack_row(TABLE *table, MY_BITMAP const* cols, field->field_name, field->real_type(), (ulong) old_pack_ptr, (ulong) pack_ptr, (int) (pack_ptr - old_pack_ptr))); + DBUG_DUMP("packed_data", old_pack_ptr, pack_ptr - old_pack_ptr); } null_mask <<= 1; @@ -380,8 +379,11 @@ unpack_row(Relay_log_info const *rli, } DBUG_ASSERT(null_mask & 0xFF); // One of the 8 LSB should be set - if (!((null_bits & null_mask) && tabledef->maybe_null(i))) - pack_ptr+= tabledef->calc_field_size(i, (uchar *) pack_ptr); + if (!((null_bits & null_mask) && tabledef->maybe_null(i))) { + uint32 len= tabledef->calc_field_size(i, (uchar *) pack_ptr); + DBUG_DUMP("field_data", pack_ptr, len); + pack_ptr+= len; + } null_mask <<= 1; } } diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 379e81d406e..0d33bd5c599 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -1176,10 +1176,17 @@ find_handler_after_execution(THD *thd, sp_rcontext *ctx) /** Execute the routine. The main instruction jump loop is there. Assume the parameters already set. + + @param thd Thread context. + @param merge_da_on_success Flag specifying if Warning Info should be + propagated to the caller on Completion + Condition or not. + @todo - Will write this SP statement into binlog separately (TODO: consider changing the condition to "not inside event union") + @return Error status. @retval FALSE on success @retval @@ -1187,7 +1194,7 @@ find_handler_after_execution(THD *thd, sp_rcontext *ctx) */ bool -sp_head::execute(THD *thd) +sp_head::execute(THD *thd, bool merge_da_on_success) { DBUG_ENTER("sp_head::execute"); char saved_cur_db_name_buf[NAME_LEN+1]; @@ -1481,8 +1488,15 @@ sp_head::execute(THD *thd) thd->stmt_arena= old_arena; state= EXECUTED; - /* Restore the caller's original warning information area. */ - saved_warning_info->merge_with_routine_info(thd, thd->warning_info); + /* + Restore the caller's original warning information area: + - warnings generated during trigger execution should not be + propagated to the caller on success; + - if there was an exception during execution, warning info should be + propagated to the caller in any case. + */ + if (err_status || merge_da_on_success) + saved_warning_info->merge_with_routine_info(thd, thd->warning_info); thd->warning_info= saved_warning_info; done: @@ -1704,7 +1718,7 @@ sp_head::execute_trigger(THD *thd, thd->spcont= nctx; - err_status= execute(thd); + err_status= execute(thd, FALSE); err_with_cleanup: thd->restore_active_arena(&call_arena, &backup_arena); @@ -1921,7 +1935,7 @@ sp_head::execute_function(THD *thd, Item **argp, uint argcount, */ thd->set_n_backup_active_arena(&call_arena, &backup_arena); - err_status= execute(thd); + err_status= execute(thd, TRUE); thd->restore_active_arena(&call_arena, &backup_arena); @@ -2154,7 +2168,7 @@ sp_head::execute_procedure(THD *thd, List<Item> *args) #endif if (!err_status) - err_status= execute(thd); + err_status= execute(thd, TRUE); if (save_log_general) thd->variables.option_bits &= ~OPTION_LOG_OFF; diff --git a/sql/sp_head.h b/sql/sp_head.h index e72ce6455f6..5efd48fc7c6 100644 --- a/sql/sp_head.h +++ b/sql/sp_head.h @@ -527,7 +527,7 @@ private: HASH m_sptabs; bool - execute(THD *thd); + execute(THD *thd, bool merge_da_on_success); /** Perform a forward flow analysis in the generated code. diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 49224444f5c..c741a50a1db 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -8091,6 +8091,24 @@ static bool send_plugin_request_packet(MPVIO_EXT *mpvio, DBUG_RETURN (1); } + /* + If we're dealing with an older client we can't just send a change plugin + packet to re-initiate the authentication handshake, because the client + won't understand it. The good thing is that we don't need to : the old client + expects us to just check the user credentials here, which we can do by just reading + the cached data that are placed there by parse_com_change_user_packet() + In this case we just do nothing and behave as if normal authentication + should continue. + */ + if (!(mpvio->client_capabilities & CLIENT_PLUGIN_AUTH)) + { + DBUG_PRINT("info", ("old client sent a COM_CHANGE_USER")); + DBUG_ASSERT(mpvio->cached_client_reply.pkt); + /* get the status back so the read can process the cached result */ + mpvio->status= MPVIO_EXT::RESTART; + DBUG_RETURN(0); + } + DBUG_PRINT("info", ("requesting client to use the %s plugin", client_auth_plugin)); DBUG_RETURN(net_write_command(net, switch_plugin_request_buf[0], @@ -8574,8 +8592,16 @@ static int server_mpvio_write_packet(MYSQL_PLUGIN_VIO *param, int res; DBUG_ENTER("server_mpvio_write_packet"); - /* reset cached_client_reply */ - mpvio->cached_client_reply.pkt= 0; + /* + Reset cached_client_reply if not an old client doing mysql_change_user, + as this is where the password from COM_CHANGE_USER is stored. + */ + if (!((!(mpvio->client_capabilities & CLIENT_PLUGIN_AUTH)) && + mpvio->status == MPVIO_EXT::RESTART && + mpvio->cached_client_reply.plugin == + ((st_mysql_auth *) (plugin_decl(mpvio->plugin)->info))->client_auth_plugin + )) + mpvio->cached_client_reply.pkt= 0; /* for the 1st packet we wrap plugin data into the handshake packet */ if (mpvio->packets_written == 0) res= send_server_handshake_packet(mpvio, (char*) packet, packet_len); @@ -8641,6 +8667,15 @@ static int server_mpvio_read_packet(MYSQL_PLUGIN_VIO *param, uchar **buf) mpvio->packets_read++; DBUG_RETURN ((int) mpvio->cached_client_reply.pkt_len); } + + /* older clients don't support change of client plugin request */ + if (!(mpvio->client_capabilities & CLIENT_PLUGIN_AUTH)) + { + mpvio->status= MPVIO_EXT::FAILURE; + pkt_len= packet_error; + goto err; + } + /* But if the client has used the wrong plugin, the cached data are useless. Furthermore, we have to send a "change plugin" request diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index e909431a7fa..455d95ada85 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -166,12 +166,13 @@ int get_part_iter_for_interval_via_walking(partition_info *part_info, uint min_len, uint max_len, uint flags, PARTITION_ITERATOR *part_iter); + +#ifdef WITH_PARTITION_STORAGE_ENGINE static int cmp_rec_and_tuple(part_column_list_val *val, uint32 nvals_in_rec); static int cmp_rec_and_tuple_prune(part_column_list_val *val, uint32 n_vals_in_rec, bool tail_is_min); -#ifdef WITH_PARTITION_STORAGE_ENGINE /* Convert constants in VALUES definition to the character set the corresponding field uses. diff --git a/sql/sql_partition_admin.cc b/sql/sql_partition_admin.cc index 98750314a4a..8f6ab5803d7 100644 --- a/sql/sql_partition_admin.cc +++ b/sql/sql_partition_admin.cc @@ -18,7 +18,9 @@ #include "sql_lex.h" // Sql_statement #include "sql_admin.h" // Analyze/Check/.._table_statement #include "sql_partition_admin.h" // Alter_table_*_partition +#ifdef WITH_PARTITION_STORAGE_ENGINE #include "ha_partition.h" // ha_partition +#endif #include "sql_base.h" // open_and_lock_tables #ifndef WITH_PARTITION_STORAGE_ENGINE diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 366c46d9c92..fcbf2c48896 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -2420,11 +2420,15 @@ void reinit_stmt_before_use(THD *thd, LEX *lex) sl->where= sl->prep_where->copy_andor_structure(thd); sl->where->cleanup(); } + else + sl->where= NULL; if (sl->prep_having) { sl->having= sl->prep_having->copy_andor_structure(thd); sl->having->cleanup(); } + else + sl->having= NULL; DBUG_ASSERT(sl->join == 0); ORDER *order; /* Fix GROUP list */ diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 2a2fe3eb36f..6c7ba8bde7b 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1754,6 +1754,9 @@ JOIN::reinit() func->clear(); } + if (!(select_options & SELECT_DESCRIBE)) + init_ftfuncs(thd, select_lex, test(order)); + DBUG_RETURN(0); } @@ -2511,6 +2514,13 @@ mysql_select(THD *thd, Item ***rref_pointer_array, { DBUG_RETURN(TRUE); } + /* + Original join tabs might be overwritten at first + subselect execution. So we need to restore them. + */ + Item_subselect *subselect= select_lex->master_unit()->item; + if (subselect && subselect->is_uncacheable() && join->reinit()) + DBUG_RETURN(TRUE); } else { @@ -13429,6 +13439,8 @@ static bool list_contains_unique_index(TABLE *table, bool (*find_func) (Field *, void *), void *data) { + if (table->pos_in_table_list->outer_join) + return 0; for (uint keynr= 0; keynr < table->s->keys; keynr++) { if (keynr == table->s->primary_key || @@ -13442,7 +13454,7 @@ list_contains_unique_index(TABLE *table, key_part < key_part_end; key_part++) { - if (key_part->field->maybe_null() || + if (key_part->field->real_maybe_null() || !find_func(key_part->field, data)) break; } diff --git a/sql/sql_show.cc b/sql/sql_show.cc index a25cfcdedc8..fa9c0e85c27 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -29,6 +29,8 @@ #include "repl_failsafe.h" #include "sql_parse.h" // check_access, check_table_access #include "sql_partition.h" // partition_element +#include "sql_derived.h" // mysql_derived_prepare, + // mysql_handle_derived, #include "sql_db.h" // check_db_dir_existence, load_db_opt_by_name #include "sql_time.h" // interval_type_to_name #include "tztime.h" // struct Time_zone @@ -98,11 +100,13 @@ static TYPELIB grant_types = { sizeof(grant_names)/sizeof(char **), static void store_key_options(THD *thd, String *packet, TABLE *table, KEY *key_info); +#ifdef WITH_PARTITION_STORAGE_ENGINE static void get_cs_converted_string_value(THD *thd, String *input_str, String *output_str, CHARSET_INFO *cs, bool use_hex); +#endif static void append_algorithm(TABLE_LIST *table, String *buff); @@ -681,11 +685,18 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list) thd->lex->view_prepare_mode= TRUE; { + /* + Use open_tables() directly rather than open_normal_and_derived_tables(). + This ensures that close_thread_tables() is not called if open tables fails + and the error is ignored. This allows us to handle broken views nicely. + */ + uint counter; Show_create_error_handler view_error_suppressor(thd, table_list); thd->push_internal_handler(&view_error_suppressor); bool open_error= - open_normal_and_derived_tables(thd, table_list, - MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL); + open_tables(thd, &table_list, &counter, + MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL) || + mysql_handle_derived(thd->lex, &mysql_derived_prepare); thd->pop_internal_handler(); if (open_error && (thd->killed || thd->is_error())) goto exit; @@ -7850,6 +7861,7 @@ void initialize_information_schema_acl() &is_internal_schema_access); } +#ifdef WITH_PARTITION_STORAGE_ENGINE /* Convert a string in character set in column character set format to utf8 character set if possible, the utf8 character set string @@ -7941,3 +7953,4 @@ static void get_cs_converted_string_value(THD *thd, } return; } +#endif diff --git a/sql/sql_truncate.cc b/sql/sql_truncate.cc index 0cff2875ac8..909c6a08b67 100644 --- a/sql/sql_truncate.cc +++ b/sql/sql_truncate.cc @@ -472,6 +472,13 @@ bool Truncate_statement::truncate_table(THD *thd, TABLE_LIST *table_ref) binlog_stmt= !error || error != HA_ERR_WRONG_COMMAND; } + /* + If we tried to open a MERGE table and failed due to problems with the + children tables, the table will have been closed and table_ref->table + will be invalid. Reset the pointer here in any case as + query_cache_invalidate does not need a valid TABLE object. + */ + table_ref->table= NULL; query_cache_invalidate3(thd, table_ref, FALSE); } diff --git a/storage/innobase/CMakeLists.txt b/storage/innobase/CMakeLists.txt index 6cfd3d754f6..fa45cc96687 100644 --- a/storage/innobase/CMakeLists.txt +++ b/storage/innobase/CMakeLists.txt @@ -13,7 +13,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -# This is the CMakeLists for InnoDB Plugin +# This is the CMakeLists for InnoDB INCLUDE(CheckFunctionExists) INCLUDE(CheckCSourceCompiles) @@ -254,29 +254,7 @@ IF(WITH_INNODB) SET(WITH_INNOBASE_STORAGE_ENGINE TRUE) ENDIF() - -#The plugin's CMakeLists.txt still needs to work with previous versions of MySQL. -IF(EXISTS ${SOURCE_DIR}/storage/mysql_storage_engine.cmake) - # Old plugin support on Windows only, - # use tricks to force ha_innodb.dll name for DLL - INCLUDE(${SOURCE_DIR}/storage/mysql_storage_engine.cmake) - MYSQL_STORAGE_ENGINE(INNOBASE) - GET_TARGET_PROPERTY(LIB_LOCATION ha_innobase LOCATION) - IF(LIB_LOCATION) - SET_TARGET_PROPERTIES(ha_innobase PROPERTIES OUTPUT_NAME ha_innodb) - ENDIF() -ELSEIF (MYSQL_VERSION_ID LESS "50137") - # Windows only, no plugin support - IF (NOT SOURCE_SUBLIBS) - ADD_DEFINITIONS(-DMYSQL_SERVER) - ADD_LIBRARY(innobase STATIC ${INNOBASE_SOURCES}) - # Require mysqld_error.h, which is built as part of the GenError - ADD_DEPENDENCIES(innobase GenError) - ENDIF() -ELSE() - # New plugin support, cross-platform , base name for shared module is "ha_innodb" - MYSQL_ADD_PLUGIN(innobase ${INNOBASE_SOURCES} STORAGE_ENGINE - DEFAULT - MODULE_OUTPUT_NAME ha_innodb - LINK_LIBRARIES ${ZLIB_LIBRARY}) -ENDIF() +MYSQL_ADD_PLUGIN(innobase ${INNOBASE_SOURCES} STORAGE_ENGINE + DEFAULT + MODULE_OUTPUT_NAME ha_innodb + LINK_LIBRARIES ${ZLIB_LIBRARY}) diff --git a/storage/innobase/buf/buf0buf.c b/storage/innobase/buf/buf0buf.c index abfde83a3bd..b79b5634957 100644 --- a/storage/innobase/buf/buf0buf.c +++ b/storage/innobase/buf/buf0buf.c @@ -246,8 +246,8 @@ static const int WAIT_FOR_READ = 5000; /** Number of attemtps made to read in a page in the buffer pool */ static const ulint BUF_PAGE_READ_MAX_RETRIES = 100; -/** The buffer buf_pool of the database */ -UNIV_INTERN buf_pool_t* buf_pool_ptr[MAX_BUFFER_POOLS]; +/** The buffer pools of the database */ +UNIV_INTERN buf_pool_t* buf_pool_ptr; #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG static ulint buf_dbg_counter = 0; /*!< This is used to insert validation @@ -858,7 +858,7 @@ buf_block_init( block->frame = frame; - block->page.buf_pool = buf_pool; + block->page.buf_pool_index = buf_pool_index(buf_pool); block->page.state = BUF_BLOCK_NOT_USED; block->page.buf_fix_count = 0; block->page.io_fix = BUF_IO_NONE; @@ -1280,8 +1280,6 @@ buf_pool_free_instance( mem_free(buf_pool->chunks); hash_table_free(buf_pool->page_hash); hash_table_free(buf_pool->zip_hash); - mem_free(buf_pool); - buf_pool = NULL; } /********************************************************************//** @@ -1294,25 +1292,23 @@ buf_pool_init( ulint total_size, /*!< in: size of the total pool in bytes */ ulint n_instances) /*!< in: number of instances */ { - ulint i; + ulint i; + const ulint size = total_size / n_instances; + + ut_ad(n_instances > 0); + ut_ad(n_instances <= MAX_BUFFER_POOLS); + ut_ad(n_instances == srv_buf_pool_instances); /* We create an extra buffer pool instance, this instance is used for flushing the flush lists, to keep track of n_flush for all the buffer pools and also used as a waiting object during flushing. */ - for (i = 0; i < n_instances; i++) { - buf_pool_t* ptr; - ulint size; - - ptr = mem_zalloc(sizeof(*ptr)); + buf_pool_ptr = mem_zalloc(n_instances * sizeof *buf_pool_ptr); - size = total_size / n_instances; - - buf_pool_ptr[i] = ptr; + for (i = 0; i < n_instances; i++) { + buf_pool_t* ptr = &buf_pool_ptr[i]; if (buf_pool_init_instance(ptr, size, i) != DB_SUCCESS) { - mem_free(buf_pool_ptr[i]); - /* Free all the instances created so far. */ buf_pool_free(i); @@ -1341,8 +1337,10 @@ buf_pool_free( for (i = 0; i < n_instances; i++) { buf_pool_free_instance(buf_pool_from_array(i)); - buf_pool_ptr[i] = NULL; } + + mem_free(buf_pool_ptr); + buf_pool_ptr = NULL; } /********************************************************************//** @@ -3685,7 +3683,7 @@ err_exit: bpage = buf_buddy_alloc(buf_pool, sizeof *bpage, &lru); /* Initialize the buf_pool pointer. */ - bpage->buf_pool = buf_pool; + bpage->buf_pool_index = buf_pool_index(buf_pool); /* If buf_buddy_alloc() allocated storage from the LRU list, it released and reacquired buf_pool->mutex. Thus, we must diff --git a/storage/innobase/dict/dict0load.c b/storage/innobase/dict/dict0load.c index 6bd15f0556a..9c6fa086d58 100644 --- a/storage/innobase/dict/dict0load.c +++ b/storage/innobase/dict/dict0load.c @@ -1718,13 +1718,24 @@ err_exit: err = dict_load_indexes(table, heap); + /* Initialize table foreign_child value. Its value could be + changed when dict_load_foreigns() is called below */ + table->fk_max_recusive_level = 0; + /* If the force recovery flag is set, we open the table irrespective of the error condition, since the user may want to dump data from the clustered index. However we load the foreign key information only if all indexes were loaded. */ if (!cached) { } else if (err == DB_SUCCESS) { - err = dict_load_foreigns(table->name, TRUE); + err = dict_load_foreigns(table->name, TRUE, TRUE); + + if (err != DB_SUCCESS) { + dict_table_remove_from_cache(table); + table = NULL; + } else { + table->fk_max_recusive_level = 0; + } } else if (!srv_force_recovery) { dict_table_remove_from_cache(table); table = NULL; @@ -1952,8 +1963,12 @@ dict_load_foreign( /*==============*/ const char* id, /*!< in: foreign constraint id as a null-terminated string */ - ibool check_charsets) + ibool check_charsets, /*!< in: TRUE=check charset compatibility */ + ibool check_recursive) + /*!< in: Whether to record the foreign table + parent count to avoid unlimited recursive + load of chained foreign tables */ { dict_foreign_t* foreign; dict_table_t* sys_foreign; @@ -1967,6 +1982,8 @@ dict_load_foreign( ulint len; ulint n_fields_and_type; mtr_t mtr; + dict_table_t* for_table; + dict_table_t* ref_table; ut_ad(mutex_own(&(dict_sys->mutex))); @@ -2051,11 +2068,54 @@ dict_load_foreign( dict_load_foreign_cols(id, foreign); - /* If the foreign table is not yet in the dictionary cache, we - have to load it so that we are able to make type comparisons - in the next function call. */ - - dict_table_get_low(foreign->foreign_table_name); + ref_table = dict_table_check_if_in_cache_low( + foreign->referenced_table_name); + + /* We could possibly wind up in a deep recursive calls if + we call dict_table_get_low() again here if there + is a chain of tables concatenated together with + foreign constraints. In such case, each table is + both a parent and child of the other tables, and + act as a "link" in such table chains. + To avoid such scenario, we would need to check the + number of ancesters the current table has. If that + exceeds DICT_FK_MAX_CHAIN_LEN, we will stop loading + the child table. + Foreign constraints are loaded in a Breath First fashion, + that is, the index on FOR_NAME is scanned first, and then + index on REF_NAME. So foreign constrains in which + current table is a child (foreign table) are loaded first, + and then those constraints where current table is a + parent (referenced) table. + Thus we could check the parent (ref_table) table's + reference count (fk_max_recusive_level) to know how deep the + recursive call is. If the parent table (ref_table) is already + loaded, and its fk_max_recusive_level is larger than + DICT_FK_MAX_CHAIN_LEN, we will stop the recursive loading + by skipping loading the child table. It will not affect foreign + constraint check for DMLs since child table will be loaded + at that time for the constraint check. */ + if (!ref_table + || ref_table->fk_max_recusive_level < DICT_FK_MAX_RECURSIVE_LOAD) { + + /* If the foreign table is not yet in the dictionary cache, we + have to load it so that we are able to make type comparisons + in the next function call. */ + + for_table = dict_table_get_low(foreign->foreign_table_name); + + if (for_table && ref_table && check_recursive) { + /* This is to record the longest chain of ancesters + this table has, if the parent has more ancesters + than this table has, record it after add 1 (for this + parent */ + if (ref_table->fk_max_recusive_level + >= for_table->fk_max_recusive_level) { + for_table->fk_max_recusive_level = + ref_table->fk_max_recusive_level + 1; + } + } + } /* Note that there may already be a foreign constraint object in the dictionary cache for this constraint: then the following @@ -2080,6 +2140,8 @@ ulint dict_load_foreigns( /*===============*/ const char* table_name, /*!< in: table name */ + ibool check_recursive,/*!< in: Whether to check recursive + load of tables chained by FK */ ibool check_charsets) /*!< in: TRUE=check charset compatibility */ { @@ -2181,7 +2243,7 @@ loop: /* Load the foreign constraint definition to the dictionary cache */ - err = dict_load_foreign(id, check_charsets); + err = dict_load_foreign(id, check_charsets, check_recursive); if (err != DB_SUCCESS) { btr_pcur_close(&pcur); @@ -2209,6 +2271,11 @@ load_next_index: mtr_start(&mtr); + /* Switch to scan index on REF_NAME, fk_max_recusive_level + already been updated when scanning FOR_NAME index, no need to + update again */ + check_recursive = FALSE; + goto start_load; } diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 97ddbfc8199..c955f807a63 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -95,10 +95,6 @@ extern "C" { # define MYSQL_PLUGIN_IMPORT /* nothing */ # endif /* MYSQL_PLUGIN_IMPORT */ -#if MYSQL_VERSION_ID < 50124 -bool check_global_access(THD *thd, ulong want_access); -#endif /* MYSQL_VERSION_ID < 50124 */ - /** to protect innobase_open_files */ static mysql_mutex_t innobase_share_mutex; /** to force correct commit order in binlog */ @@ -240,7 +236,6 @@ static PSI_mutex_info all_innodb_mutexes[] = { {&ibuf_mutex_key, "ibuf_mutex", 0}, {&ibuf_pessimistic_insert_mutex_key, "ibuf_pessimistic_insert_mutex", 0}, - {&ios_mutex_key, "ios_mutex", 0}, {&kernel_mutex_key, "kernel_mutex", 0}, {&log_sys_mutex_key, "log_sys_mutex", 0}, # ifdef UNIV_MEM_DEBUG @@ -900,6 +895,19 @@ convert_error_code_to_mysql( case DB_INTERRUPTED: my_error(ER_QUERY_INTERRUPTED, MYF(0)); /* fall through */ + + case DB_FOREIGN_EXCEED_MAX_CASCADE: + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + HA_ERR_ROW_IS_REFERENCED, + "InnoDB: Cannot delete/update " + "rows with cascading foreign key " + "constraints that exceed max " + "depth of %d. Please " + "drop extra constraints and try " + "again", DICT_FK_MAX_RECURSIVE_LOAD); + + /* fall through */ + case DB_ERROR: default: return(-1); /* unspecified error */ @@ -1886,11 +1894,7 @@ innobase_convert_identifier( FALSE=id is an UTF-8 string */ { char nz[NAME_LEN + 1]; -#if MYSQL_VERSION_ID >= 50141 char nz2[NAME_LEN + 1 + EXPLAIN_FILENAME_MAX_EXTRA_LENGTH]; -#else /* MYSQL_VERSION_ID >= 50141 */ - char nz2[NAME_LEN + 1 + sizeof srv_mysql50_table_name_prefix]; -#endif /* MYSQL_VERSION_ID >= 50141 */ const char* s = id; int q; @@ -1908,13 +1912,9 @@ innobase_convert_identifier( nz[idlen] = 0; s = nz2; -#if MYSQL_VERSION_ID >= 50141 idlen = explain_filename((THD*) thd, nz, nz2, sizeof nz2, EXPLAIN_PARTITIONS_AS_COMMENT); goto no_quote; -#else /* MYSQL_VERSION_ID >= 50141 */ - idlen = filename_to_tablename(nz, nz2, sizeof nz2); -#endif /* MYSQL_VERSION_ID >= 50141 */ } /* See if the identifier needs to be quoted. */ @@ -1925,9 +1925,7 @@ innobase_convert_identifier( } if (q == EOF) { -#if MYSQL_VERSION_ID >= 50141 no_quote: -#endif /* MYSQL_VERSION_ID >= 50141 */ if (UNIV_UNLIKELY(idlen > buflen)) { idlen = buflen; } diff --git a/storage/innobase/handler/ha_innodb.h b/storage/innobase/handler/ha_innodb.h index 9c78c60d71e..f05ea8801f0 100644 --- a/storage/innobase/handler/ha_innodb.h +++ b/storage/innobase/handler/ha_innodb.h @@ -276,14 +276,13 @@ int thd_binlog_format(const MYSQL_THD thd); */ void thd_mark_transaction_to_rollback(MYSQL_THD thd, bool all); -#if MYSQL_VERSION_ID > 50140 /** Check if binary logging is filtered for thread's current db. @param thd Thread handle @retval 1 the query is not filtered, 0 otherwise. */ bool thd_binlog_filter_ok(const MYSQL_THD thd); -#endif /* MYSQL_VERSION_ID > 50140 */ + /** Check if the query may generate row changes which may end up in the binary. diff --git a/storage/innobase/ibuf/ibuf0ibuf.c b/storage/innobase/ibuf/ibuf0ibuf.c index 7ef577e5178..ab42f1ad4f3 100644 --- a/storage/innobase/ibuf/ibuf0ibuf.c +++ b/storage/innobase/ibuf/ibuf0ibuf.c @@ -1363,12 +1363,12 @@ ibuf_add_ops( const ulint* ops) /*!< in: operation counts */ { + ulint i; + #ifndef HAVE_ATOMIC_BUILTINS ut_ad(mutex_own(&ibuf_mutex)); #endif /* !HAVE_ATOMIC_BUILTINS */ - ulint i; - for (i = 0; i < IBUF_OP_COUNT; i++) { #ifdef HAVE_ATOMIC_BUILTINS os_atomic_increment_ulint(&arr[i], ops[i]); diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h index b0fff919918..a42eba57fd2 100644 --- a/storage/innobase/include/buf0buf.h +++ b/storage/innobase/include/buf0buf.h @@ -69,7 +69,7 @@ Created 11/5/1995 Heikki Tuuri #define BUF_POOL_WATCH_SIZE 1 /*!< Maximum number of concurrent buffer pool watches */ -extern buf_pool_t* buf_pool_ptr[MAX_BUFFER_POOLS]; /*!< The buffer pools +extern buf_pool_t* buf_pool_ptr; /*!< The buffer pools of the database */ #ifdef UNIV_DEBUG extern ibool buf_debug_prints;/*!< If this is set TRUE, the program @@ -1034,6 +1034,15 @@ buf_page_address_fold( ulint space, /*!< in: space id */ ulint offset) /*!< in: offset of the page within space */ __attribute__((const)); +/********************************************************************//** +Calculates the index of a buffer pool to the buf_pool[] array. +@return the position of the buffer pool in buf_pool[] */ +UNIV_INLINE +ulint +buf_pool_index( +/*===========*/ + const buf_pool_t* buf_pool) /*!< in: buffer pool */ + __attribute__((nonnull, const)); /******************************************************************//** Returns the buffer pool instance given a page instance @return buf_pool */ @@ -1065,8 +1074,9 @@ Returns the buffer pool instance given its array index UNIV_INLINE buf_pool_t* buf_pool_from_array( -/*====================*/ - ulint index); /*!< in: array index to get buffer pool instance from */ +/*================*/ + ulint index); /*!< in: array index to get + buffer pool instance from */ /******************************************************************//** Returns the control block of a file page, NULL if not found. @return block, NULL if not found */ @@ -1204,8 +1214,13 @@ struct buf_page_struct{ unsigned io_fix:2; /*!< type of pending I/O operation; also protected by buf_pool->mutex @see enum buf_io_fix */ - unsigned buf_fix_count:25;/*!< count of how manyfold this block + unsigned buf_fix_count:19;/*!< count of how manyfold this block is currently bufferfixed */ + unsigned buf_pool_index:6;/*!< index number of the buffer pool + that this block belongs to */ +# if MAX_BUFFER_POOLS > 64 +# error "MAX_BUFFER_POOLS > 64; redefine buf_pool_index:6" +# endif /* @} */ #endif /* !UNIV_HOTBACKUP */ page_zip_des_t zip; /*!< compressed page; zip.data @@ -1324,8 +1339,6 @@ struct buf_page_struct{ frees a page in buffer pool */ # endif /* UNIV_DEBUG_FILE_ACCESSES */ #endif /* !UNIV_HOTBACKUP */ - buf_pool_t* buf_pool; /*!< buffer pool instance this - page belongs to */ }; /** The buffer control block structure */ diff --git a/storage/innobase/include/buf0buf.ic b/storage/innobase/include/buf0buf.ic index 713b7cb990d..e2e83de0a78 100644 --- a/storage/innobase/include/buf0buf.ic +++ b/storage/innobase/include/buf0buf.ic @@ -46,6 +46,48 @@ buf_pool_get_curr_size(void) return(srv_buf_pool_curr_size); } +/********************************************************************//** +Calculates the index of a buffer pool to the buf_pool[] array. +@return the position of the buffer pool in buf_pool[] */ +UNIV_INLINE +ulint +buf_pool_index( +/*===========*/ + const buf_pool_t* buf_pool) /*!< in: buffer pool */ +{ + ulint i = buf_pool - buf_pool_ptr; + ut_ad(i < MAX_BUFFER_POOLS); + ut_ad(i < srv_buf_pool_instances); + return(i); +} + +/******************************************************************//** +Returns the buffer pool instance given a page instance +@return buf_pool */ +UNIV_INLINE +buf_pool_t* +buf_pool_from_bpage( +/*================*/ + const buf_page_t* bpage) /*!< in: buffer pool page */ +{ + ulint i; + i = bpage->buf_pool_index; + ut_ad(i < srv_buf_pool_instances); + return(&buf_pool_ptr[i]); +} + +/******************************************************************//** +Returns the buffer pool instance given a block instance +@return buf_pool */ +UNIV_INLINE +buf_pool_t* +buf_pool_from_block( +/*================*/ + const buf_block_t* block) /*!< in: block */ +{ + return(buf_pool_from_bpage(&block->page)); +} + /*********************************************************************//** Gets the current size of buffer buf_pool in pages. @return size in pages*/ @@ -886,33 +928,6 @@ buf_block_buf_fix_dec( } /******************************************************************//** -Returns the buffer pool instance given a page instance -@return buf_pool */ -UNIV_INLINE -buf_pool_t* -buf_pool_from_bpage( -/*================*/ - const buf_page_t* bpage) /*!< in: buffer pool page */ -{ - /* Every page must be in some buffer pool. */ - ut_ad(bpage->buf_pool != NULL); - - return(bpage->buf_pool); -} - -/******************************************************************//** -Returns the buffer pool instance given a block instance -@return buf_pool */ -UNIV_INLINE -buf_pool_t* -buf_pool_from_block( -/*================*/ - const buf_block_t* block) /*!< in: block */ -{ - return(buf_pool_from_bpage(&block->page)); -} - -/******************************************************************//** Returns the buffer pool instance given space and offset of page @return buffer pool */ UNIV_INLINE @@ -929,7 +944,7 @@ buf_pool_get( ignored_offset = offset >> 6; /* 2log of BUF_READ_AHEAD_AREA (64)*/ fold = buf_page_address_fold(space, ignored_offset); index = fold % srv_buf_pool_instances; - return buf_pool_ptr[index]; + return(&buf_pool_ptr[index]); } /******************************************************************//** @@ -939,10 +954,12 @@ UNIV_INLINE buf_pool_t* buf_pool_from_array( /*================*/ - ulint index) /*!< in: array index to get + ulint index) /*!< in: array index to get buffer pool instance from */ { - return buf_pool_ptr[index]; + ut_ad(index < MAX_BUFFER_POOLS); + ut_ad(index < srv_buf_pool_instances); + return(&buf_pool_ptr[index]); } /******************************************************************//** diff --git a/storage/innobase/include/db0err.h b/storage/innobase/include/db0err.h index f84ce2d15aa..01bb1b80754 100644 --- a/storage/innobase/include/db0err.h +++ b/storage/innobase/include/db0err.h @@ -101,6 +101,9 @@ enum db_err { requested but this storage does not exist itself or the stats for a given table do not exist */ + DB_FOREIGN_EXCEED_MAX_CASCADE, /* Foreign key constraint related + cascading delete/update exceeds + maximum allowed depth */ /* The following are partial failure codes */ DB_FAIL = 1000, diff --git a/storage/innobase/include/dict0load.h b/storage/innobase/include/dict0load.h index 05d3532d59a..f009f221f32 100644 --- a/storage/innobase/include/dict0load.h +++ b/storage/innobase/include/dict0load.h @@ -200,6 +200,8 @@ ulint dict_load_foreigns( /*===============*/ const char* table_name, /*!< in: table name */ + ibool check_recursive,/*!< in: Whether to check recursive + load of tables chained by FK */ ibool check_charsets);/*!< in: TRUE=check charsets compatibility */ /********************************************************************//** diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h index 75f9acd6b26..d448e57e395 100644 --- a/storage/innobase/include/dict0mem.h +++ b/storage/innobase/include/dict0mem.h @@ -116,6 +116,21 @@ ROW_FORMAT=REDUNDANT. */ in table->flags. */ /* @} */ +/** Tables could be chained together with Foreign key constraint. When +first load the parent table, we would load all of its descedents. +This could result in rescursive calls and out of stack error eventually. +DICT_FK_MAX_RECURSIVE_LOAD defines the maximum number of recursive loads, +when exceeded, the child table will not be loaded. It will be loaded when +the foreign constraint check needs to be run. */ +#define DICT_FK_MAX_RECURSIVE_LOAD 255 + +/** Similarly, when tables are chained together with foreign key constraints +with on cascading delete/update clause, delete from parent table could +result in recursive cascading calls. This defines the maximum number of +such cascading deletes/updates allowed. When exceeded, the delete from +parent table will fail, and user has to drop excessive foreign constraint +before proceeds. */ +#define FK_MAX_CASCADE_DEL 255 /**********************************************************************//** Creates a table memory object. @@ -469,6 +484,12 @@ struct dict_table_struct{ NOT allowed until this count gets to zero; MySQL does NOT itself check the number of open handles at drop */ + unsigned fk_max_recusive_level:8; + /*!< maximum recursive level we support when + loading tables chained together with FK + constraints. If exceeds this level, we will + stop loading child table into memory along with + its parent table */ ulint n_foreign_key_checks_running; /*!< count of how many foreign key check operations are currently being performed diff --git a/storage/innobase/include/que0que.h b/storage/innobase/include/que0que.h index 09734bbb197..720da6dcb46 100644 --- a/storage/innobase/include/que0que.h +++ b/storage/innobase/include/que0que.h @@ -381,6 +381,9 @@ struct que_thr_struct{ thus far */ ulint lock_state; /*!< lock state of thread (table or row) */ + ulint fk_cascade_depth; /*!< maximum cascading call depth + supported for foreign key constraint + related delete/updates */ }; #define QUE_THR_MAGIC_N 8476583 diff --git a/storage/innobase/include/sync0sync.h b/storage/innobase/include/sync0sync.h index 940e583350a..fb3a24c5ee5 100644 --- a/storage/innobase/include/sync0sync.h +++ b/storage/innobase/include/sync0sync.h @@ -85,7 +85,6 @@ extern mysql_pfs_key_t hash_table_mutex_key; extern mysql_pfs_key_t ibuf_bitmap_mutex_key; extern mysql_pfs_key_t ibuf_mutex_key; extern mysql_pfs_key_t ibuf_pessimistic_insert_mutex_key; -extern mysql_pfs_key_t ios_mutex_key; extern mysql_pfs_key_t log_sys_mutex_key; extern mysql_pfs_key_t log_flush_order_mutex_key; extern mysql_pfs_key_t kernel_mutex_key; diff --git a/storage/innobase/include/trx0undo.h b/storage/innobase/include/trx0undo.h index 54809f9c2d5..937e9d7ef79 100644 --- a/storage/innobase/include/trx0undo.h +++ b/storage/innobase/include/trx0undo.h @@ -262,8 +262,6 @@ UNIV_INTERN page_t* trx_undo_set_state_at_finish( /*=========================*/ - trx_rseg_t* rseg, /*!< in: rollback segment memory object */ - trx_t* trx, /*!< in: transaction */ trx_undo_t* undo, /*!< in: undo log memory copy */ mtr_t* mtr); /*!< in: mtr */ /******************************************************************//** diff --git a/storage/innobase/os/os0file.c b/storage/innobase/os/os0file.c index 3d1577fe3ca..93d2f72746d 100644 --- a/storage/innobase/os/os0file.c +++ b/storage/innobase/os/os0file.c @@ -2400,7 +2400,10 @@ os_file_read_func( ulint i; #endif /* !UNIV_HOTBACKUP */ + /* On 64-bit Windows, ulint is 64 bits. But offset and n should be + no more than 32 bits. */ ut_a((offset & 0xFFFFFFFFUL) == offset); + ut_a((n & 0xFFFFFFFFUL) == n); os_n_file_reads++; os_bytes_read_since_printout += n; @@ -2526,7 +2529,10 @@ os_file_read_no_error_handling_func( ulint i; #endif /* !UNIV_HOTBACKUP */ + /* On 64-bit Windows, ulint is 64 bits. But offset and n should be + no more than 32 bits. */ ut_a((offset & 0xFFFFFFFFUL) == offset); + ut_a((n & 0xFFFFFFFFUL) == n); os_n_file_reads++; os_bytes_read_since_printout += n; @@ -2658,7 +2664,10 @@ os_file_write_func( ulint i; #endif /* !UNIV_HOTBACKUP */ - ut_a((offset & 0xFFFFFFFF) == offset); + /* On 64-bit Windows, ulint is 64 bits. But offset and n should be + no more than 32 bits. */ + ut_a((offset & 0xFFFFFFFFUL) == offset); + ut_a((n & 0xFFFFFFFFUL) == n); os_n_file_writes++; @@ -3621,6 +3630,10 @@ os_aio_array_reserve_slot( ulint slots_per_seg; ulint local_seg; +#ifdef WIN_ASYNC_IO + ut_a((len & 0xFFFFFFFFUL) == len); +#endif + /* No need of a mutex. Only reading constant fields */ slots_per_seg = array->n_slots / array->n_segments; @@ -3996,6 +4009,9 @@ os_aio_func( ut_ad(n % OS_FILE_LOG_BLOCK_SIZE == 0); ut_ad(offset % OS_FILE_LOG_BLOCK_SIZE == 0); ut_ad(os_aio_validate()); +#ifdef WIN_ASYNC_IO + ut_ad((n & 0xFFFFFFFFUL) == n); +#endif wake_later = mode & OS_AIO_SIMULATED_WAKE_LATER; mode = mode & (~OS_AIO_SIMULATED_WAKE_LATER); @@ -4271,16 +4287,18 @@ os_aio_windows_handle( __FILE__, __LINE__); #endif + ut_a((slot->len & 0xFFFFFFFFUL) == slot->len); + switch (slot->type) { case OS_FILE_WRITE: ret = WriteFile(slot->file, slot->buf, - slot->len, &len, + (DWORD) slot->len, &len, &(slot->control)); break; case OS_FILE_READ: ret = ReadFile(slot->file, slot->buf, - slot->len, &len, + (DWORD) slot->len, &len, &(slot->control)); break; diff --git a/storage/innobase/os/os0sync.c b/storage/innobase/os/os0sync.c index 5c400ae31c5..24d36acecb2 100644 --- a/storage/innobase/os/os0sync.c +++ b/storage/innobase/os/os0sync.c @@ -136,20 +136,30 @@ os_cond_wait_timed( #ifndef __WIN__ const struct timespec* abstime /*!< in: timeout */ #else - ulint time_in_ms /*!< in: timeout in + DWORD time_in_ms /*!< in: timeout in milliseconds*/ #endif /* !__WIN__ */ ) { #ifdef __WIN__ - BOOL ret; + BOOL ret; + DWORD err; ut_a(sleep_condition_variable != NULL); ret = sleep_condition_variable(cond, mutex, time_in_ms); - if (!ret && GetLastError() == WAIT_TIMEOUT) { - return(TRUE); + if (!ret) { + err = GetLastError(); + /* From http://msdn.microsoft.com/en-us/library/ms686301%28VS.85%29.aspx, + "Condition variables are subject to spurious wakeups + (those not associated with an explicit wake) and stolen wakeups + (another thread manages to run before the woken thread)." + Check for both types of timeouts. + Conditions are checked by the caller.*/ + if ((err == WAIT_TIMEOUT) || (err == ERROR_TIMEOUT)) { + return(TRUE); + } } ut_a(ret); @@ -163,12 +173,15 @@ os_cond_wait_timed( switch (ret) { case 0: case ETIMEDOUT: - break; + /* We play it safe by checking for EINTR even though + according to the POSIX documentation it can't return EINTR. */ + case EINTR: + break; default: fprintf(stderr, " InnoDB: pthread_cond_timedwait() returned: " "%d: abstime={%lu,%lu}\n", - ret, abstime->tv_sec, abstime->tv_nsec); + ret, (ulong) abstime->tv_sec, (ulong) abstime->tv_nsec); ut_error; } @@ -655,7 +668,7 @@ os_event_wait_time_low( ut_a(event); if (time_in_usec != OS_SYNC_INFINITE_TIME) { - time_in_ms = time_in_ms / 1000; + time_in_ms = time_in_usec / 1000; err = WaitForSingleObject(event->handle, time_in_ms); } else { err = WaitForSingleObject(event->handle, INFINITE); @@ -663,7 +676,7 @@ os_event_wait_time_low( if (err == WAIT_OBJECT_0) { return(0); - } else if (err == WAIT_TIMEOUT) { + } else if ((err == WAIT_TIMEOUT) || (err == ERROR_TIMEOUT)) { return(OS_SYNC_TIME_EXCEEDED); } diff --git a/storage/innobase/row/row0merge.c b/storage/innobase/row/row0merge.c index 38ec4bff08f..1b96ff50e66 100644 --- a/storage/innobase/row/row0merge.c +++ b/storage/innobase/row/row0merge.c @@ -2418,7 +2418,7 @@ row_merge_rename_tables( goto err_exit; } - err = dict_load_foreigns(old_name, TRUE); + err = dict_load_foreigns(old_name, FALSE, TRUE); if (err != DB_SUCCESS) { err_exit: diff --git a/storage/innobase/row/row0mysql.c b/storage/innobase/row/row0mysql.c index 71ef587b141..f5076075fa3 100644 --- a/storage/innobase/row/row0mysql.c +++ b/storage/innobase/row/row0mysql.c @@ -635,6 +635,13 @@ handle_new_error: "InnoDB: " REFMAN "forcing-recovery.html" " for help.\n", stderr); break; + case DB_FOREIGN_EXCEED_MAX_CASCADE: + fprintf(stderr, "InnoDB: Cannot delete/update rows with" + " cascading foreign key constraints that exceed max" + " depth of %lu\n" + "Please drop excessive foreign constraints" + " and try again\n", (ulong) DICT_FK_MAX_RECURSIVE_LOAD); + break; default: fprintf(stderr, "InnoDB: unknown error code %lu\n", (ulong) err); @@ -1440,11 +1447,15 @@ row_update_for_mysql( run_again: thr->run_node = node; thr->prev_node = node; + thr->fk_cascade_depth = 0; row_upd_step(thr); err = trx->error_state; + /* Reset fk_cascade_depth back to 0 */ + thr->fk_cascade_depth = 0; + if (err != DB_SUCCESS) { que_thr_stop_for_mysql(thr); @@ -1640,12 +1651,27 @@ row_update_cascade_for_mysql( trx_t* trx; trx = thr_get_trx(thr); + + /* Increment fk_cascade_depth to record the recursive call depth on + a single update/delete that affects multiple tables chained + together with foreign key relations. */ + thr->fk_cascade_depth++; + + if (thr->fk_cascade_depth > FK_MAX_CASCADE_DEL) { + return (DB_FOREIGN_EXCEED_MAX_CASCADE); + } run_again: thr->run_node = node; thr->prev_node = node; row_upd_step(thr); + /* The recursive call for cascading update/delete happens + in above row_upd_step(), reset the counter once we come + out of the recursive call, so it does not accumulate for + different row deletes */ + thr->fk_cascade_depth = 0; + err = trx->error_state; /* Note that the cascade node is a subnode of another InnoDB @@ -1912,15 +1938,13 @@ err_exit: err = trx->error_state; - if (UNIV_UNLIKELY(err != DB_SUCCESS)) { + switch (err) { + case DB_SUCCESS: + break; + case DB_OUT_OF_FILE_SPACE: trx->error_state = DB_SUCCESS; trx_general_rollback_for_mysql(trx, NULL); - /* TO DO: free table? The code below will dereference - table->name, though. */ - } - switch (err) { - case DB_OUT_OF_FILE_SPACE: ut_print_timestamp(stderr); fputs(" InnoDB: Warning: cannot create table ", stderr); @@ -1935,9 +1959,13 @@ err_exit: break; case DB_DUPLICATE_KEY: + default: /* We may also get err == DB_ERROR if the .ibd file for the table already exists */ + trx->error_state = DB_SUCCESS; + trx_general_rollback_for_mysql(trx, NULL); + dict_mem_table_free(table); break; } @@ -2120,7 +2148,7 @@ row_table_add_foreign_constraints( name, reject_fks); if (err == DB_SUCCESS) { /* Check that also referencing constraints are ok */ - err = dict_load_foreigns(name, TRUE); + err = dict_load_foreigns(name, FALSE, TRUE); } if (err != DB_SUCCESS) { @@ -2813,15 +2841,6 @@ row_truncate_table_for_mysql( trx->table_id = table->id; - /* Lock all index trees for this table, as we will - truncate the table/index and possibly change their metadata. - All DML/DDL are blocked by table level lock, with - a few exceptions such as queries into information schema - about the table, MySQL could try to access index stats - for this kind of query, we need to use index locks to - sync up */ - dict_table_x_lock_indexes(table); - if (table->space && !table->dir_path_of_temp_table) { /* Discard and create the single-table tablespace. */ ulint space = table->space; @@ -2834,6 +2853,11 @@ row_truncate_table_for_mysql( dict_hdr_get_new_id(NULL, NULL, &space); + /* Lock all index trees for this table. We must + do so after dict_hdr_get_new_id() to preserve + the latch order */ + dict_table_x_lock_indexes(table); + if (space == ULINT_UNDEFINED || fil_create_new_single_table_tablespace( space, table->name, FALSE, flags, @@ -2867,6 +2891,15 @@ row_truncate_table_for_mysql( FIL_IBD_FILE_INITIAL_SIZE, &mtr); mtr_commit(&mtr); } + } else { + /* Lock all index trees for this table, as we will + truncate the table/index and possibly change their metadata. + All DML/DDL are blocked by table level lock, with + a few exceptions such as queries into information schema + about the table, MySQL could try to access index stats + for this kind of query, we need to use index locks to + sync up */ + dict_table_x_lock_indexes(table); } /* scan SYS_INDEXES for all indexes of the table */ @@ -3992,7 +4025,7 @@ end: an ALTER, not in a RENAME. */ err = dict_load_foreigns( - new_name, !old_is_tmp || trx->check_foreigns); + new_name, FALSE, !old_is_tmp || trx->check_foreigns); if (err != DB_SUCCESS) { ut_print_timestamp(stderr); diff --git a/storage/innobase/srv/srv0start.c b/storage/innobase/srv/srv0start.c index 67586de736c..d7ea3d5d3da 100644 --- a/storage/innobase/srv/srv0start.c +++ b/storage/innobase/srv/srv0start.c @@ -120,11 +120,6 @@ UNIV_INTERN enum srv_shutdown_state srv_shutdown_state = SRV_SHUTDOWN_NONE; /** Files comprising the system tablespace */ static os_file_t files[1000]; -/** Mutex protecting the ios count */ -static mutex_t ios_mutex; -/** Count of I/O operations in io_handler_thread() */ -static ulint ios; - /** io_handler_thread parameters for thread identification */ static ulint n[SRV_MAX_N_IO_THREADS + 6]; /** io_handler_thread identifiers */ @@ -152,11 +147,6 @@ UNIV_INTERN mysql_pfs_key_t srv_master_thread_key; UNIV_INTERN mysql_pfs_key_t srv_purge_thread_key; #endif /* UNIV_PFS_THREAD */ -#ifdef UNIV_PFS_MUTEX -/* Key to register ios_mutex_key with performance schema */ -UNIV_INTERN mysql_pfs_key_t ios_mutex_key; -#endif /* UNIV_PFS_MUTEX */ - /*********************************************************************//** Convert a numeric string that optionally ends in G or M, to a number containing megabytes. @@ -491,10 +481,6 @@ io_handler_thread( while (srv_shutdown_state != SRV_SHUTDOWN_EXIT_THREADS) { fil_aio_wait(segment); - - mutex_enter(&ios_mutex); - ios++; - mutex_exit(&ios_mutex); } /* We count the number of threads in os_thread_exit(). A created @@ -998,10 +984,6 @@ skip_size_check: srv_data_file_is_raw_partition[i] != 0); } - ios = 0; - - mutex_create(ios_mutex_key, &ios_mutex, SYNC_NO_ORDER_CHECK); - return(DB_SUCCESS); } diff --git a/storage/innobase/trx/trx0trx.c b/storage/innobase/trx/trx0trx.c index 6bae0527b53..7f2ca1f1471 100644 --- a/storage/innobase/trx/trx0trx.c +++ b/storage/innobase/trx/trx0trx.c @@ -753,8 +753,7 @@ trx_commit_off_kernel( mutex_enter(&(rseg->mutex)); if (trx->insert_undo != NULL) { - trx_undo_set_state_at_finish( - rseg, trx, trx->insert_undo, &mtr); + trx_undo_set_state_at_finish(trx->insert_undo, &mtr); } undo = trx->update_undo; @@ -769,7 +768,7 @@ trx_commit_off_kernel( transaction commit for this transaction. */ update_hdr_page = trx_undo_set_state_at_finish( - rseg, trx, undo, &mtr); + undo, &mtr); /* We have to do the cleanup for the update log while holding the rseg mutex because update log headers diff --git a/storage/innobase/trx/trx0undo.c b/storage/innobase/trx/trx0undo.c index 9162c82e423..4021a2ed573 100644 --- a/storage/innobase/trx/trx0undo.c +++ b/storage/innobase/trx/trx0undo.c @@ -1798,8 +1798,6 @@ UNIV_INTERN page_t* trx_undo_set_state_at_finish( /*=========================*/ - trx_rseg_t* rseg, /*!< in: rollback segment memory object */ - trx_t* trx __attribute__((unused)), /*!< in: transaction */ trx_undo_t* undo, /*!< in: undo log memory copy */ mtr_t* mtr) /*!< in: mtr */ { @@ -1808,10 +1806,8 @@ trx_undo_set_state_at_finish( page_t* undo_page; ulint state; - ut_ad(trx); ut_ad(undo); ut_ad(mtr); - ut_ad(mutex_own(&rseg->mutex)); if (undo->id >= TRX_RSEG_N_SLOTS) { fprintf(stderr, "InnoDB: Error: undo->id is %lu\n", @@ -1830,19 +1826,7 @@ trx_undo_set_state_at_finish( && mach_read_from_2(page_hdr + TRX_UNDO_PAGE_FREE) < TRX_UNDO_PAGE_REUSE_LIMIT) { - /* This is a heuristic to avoid the problem of all UNDO - slots ending up in one of the UNDO lists. Previously if - the server crashed with all the slots in one of the lists, - transactions that required the slots of a different type - would fail for lack of slots. */ - - if (UT_LIST_GET_LEN(rseg->update_undo_list) < 500 - && UT_LIST_GET_LEN(rseg->insert_undo_list) < 500) { - - state = TRX_UNDO_CACHED; - } else { - state = TRX_UNDO_TO_FREE; - } + state = TRX_UNDO_CACHED; } else if (undo->type == TRX_UNDO_INSERT) { diff --git a/storage/innobase/ut/ut0ut.c b/storage/innobase/ut/ut0ut.c index 39978304696..39c60d2bc2f 100644 --- a/storage/innobase/ut/ut0ut.c +++ b/storage/innobase/ut/ut0ut.c @@ -693,6 +693,8 @@ ut_strerr( return("Lock structs have exhausted the buffer pool"); case DB_FOREIGN_DUPLICATE_KEY: return("Foreign key activated with duplicate keys"); + case DB_FOREIGN_EXCEED_MAX_CASCADE: + return("Foreign key cascade delete/update exceeds max depth"); case DB_TOO_MANY_CONCURRENT_TRXS: return("Too many concurrent transactions"); case DB_UNSUPPORTED: diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index b17948fb75c..5c2ea2305d3 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -974,11 +974,23 @@ echo "=====" >> $STATUS_HISTORY %attr(755, root, root) %{_libdir}/mysql/plugin/mypluglib.so %attr(755, root, root) %{_libdir}/mysql/plugin/semisync_master.so %attr(755, root, root) %{_libdir}/mysql/plugin/semisync_slave.so +%attr(755, root, root) %{_libdir}/mysql/plugin/auth.so +%attr(755, root, root) %{_libdir}/mysql/plugin/auth_socket.so +%attr(755, root, root) %{_libdir}/mysql/plugin/auth_test_plugin.so +%attr(755, root, root) %{_libdir}/mysql/plugin/qa_auth_client.so +%attr(755, root, root) %{_libdir}/mysql/plugin/qa_auth_interface.so +%attr(755, root, root) %{_libdir}/mysql/plugin/qa_auth_server.so %attr(755, root, root) %{_libdir}/mysql/plugin/debug/adt_null.so %attr(755, root, root) %{_libdir}/mysql/plugin/debug/libdaemon_example.so %attr(755, root, root) %{_libdir}/mysql/plugin/debug/mypluglib.so %attr(755, root, root) %{_libdir}/mysql/plugin/debug/semisync_master.so %attr(755, root, root) %{_libdir}/mysql/plugin/debug/semisync_slave.so +%attr(755, root, root) %{_libdir}/mysql/plugin/debug/auth.so +%attr(755, root, root) %{_libdir}/mysql/plugin/debug/auth_socket.so +%attr(755, root, root) %{_libdir}/mysql/plugin/debug/auth_test_plugin.so +%attr(755, root, root) %{_libdir}/mysql/plugin/debug/qa_auth_client.so +%attr(755, root, root) %{_libdir}/mysql/plugin/debug/qa_auth_interface.so +%attr(755, root, root) %{_libdir}/mysql/plugin/debug/qa_auth_server.so %if %{WITH_TCMALLOC} %attr(755, root, root) %{_libdir}/mysql/%{malloc_lib_target} @@ -1075,6 +1087,14 @@ echo "=====" >> $STATUS_HISTORY # merging BK trees) ############################################################################## %changelog +* Mon Nov 1 2010 Georgi Kodinov <georgi.godinov@oracle.com> + +- Added test authentication (WL#1054) plugin binaries + +* Wed Oct 6 2010 Georgi Kodinov <georgi.godinov@oracle.com> + +- Added example external authentication (WL#1054) plugin binaries + * Wed Aug 11 2010 Joerg Bruehe <joerg.bruehe@oracle.com> - With a recent spec file cleanup, names have changed: A "-community" part was dropped. |