summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CREDITS4
-rw-r--r--mysql-test/r/contributors.result4
-rw-r--r--mysql-test/r/create_or_replace.result15
-rw-r--r--mysql-test/r/func_time.result158
-rw-r--r--mysql-test/r/grant.result29
-rw-r--r--mysql-test/r/sp-security.result23
-rw-r--r--mysql-test/r/type_float.result36
-rw-r--r--mysql-test/suite/parts/r/update_and_cache.result7
-rw-r--r--mysql-test/suite/parts/t/update_and_cache.test12
-rw-r--r--mysql-test/t/create_or_replace.test21
-rw-r--r--mysql-test/t/func_time.test49
-rw-r--r--mysql-test/t/grant.test22
-rw-r--r--mysql-test/t/sp-security.test28
-rw-r--r--mysql-test/t/type_float.test30
-rw-r--r--mysys/my_alloc.c3
-rw-r--r--sql/contributors.h4
-rw-r--r--sql/field.cc3
-rw-r--r--sql/item.cc184
-rw-r--r--sql/item.h92
-rw-r--r--sql/item_func.cc5
-rw-r--r--sql/item_func.h10
-rw-r--r--sql/item_timefunc.cc29
-rw-r--r--sql/sql_acl.cc5
-rw-r--r--sql/sql_base.cc3
-rw-r--r--sql/sql_delete.cc1
-rw-r--r--sql/sql_error.h7
-rw-r--r--sql/sql_type_int.h44
-rw-r--r--sql/sql_update.cc2
-rw-r--r--sql/table_cache.cc1
-rw-r--r--storage/tokudb/ha_tokudb.cc12
-rw-r--r--storage/tokudb/ha_tokudb.h2
-rw-r--r--storage/tokudb/hatoku_defines.h16
32 files changed, 542 insertions, 319 deletions
diff --git a/CREDITS b/CREDITS
index 1788b6304fe..9f03f7fc24e 100644
--- a/CREDITS
+++ b/CREDITS
@@ -10,9 +10,11 @@ Microsoft https://microsoft.com/ (2017)
Tencent Cloud https://cloud.tencent.com (2017)
Development Bank of Singapore https://dbs.com (2016)
IBM https://www.ibm.com (2017)
+Tencent Games http://game.qq.com/ (2018)
Visma https://visma.com (2015)
-Acronis http://acronis.com (2016)
+Acronis https://acronis.com (2016)
Nexedi https://www.nexedi.com (2016)
+Percona https://www.percona.com (2018)
Tencent Game DBA http://tencentdba.com/about (2016)
Tencent TDSQL http://tdsql.org (2016)
Verkkokauppa.com https://www.verkkokauppa.com (2015)
diff --git a/mysql-test/r/contributors.result b/mysql-test/r/contributors.result
index 36d033f4cb3..3e4bf5f0d43 100644
--- a/mysql-test/r/contributors.result
+++ b/mysql-test/r/contributors.result
@@ -8,12 +8,14 @@ MariaDB Corporation https://mariadb.com Founding member, Platinum Sponsor of the
Visma https://visma.com Gold Sponsor of the MariaDB Foundation
DBS https://dbs.com Gold Sponsor of the MariaDB Foundation
IBM https://www.ibm.com Gold Sponsor of the MariaDB Foundation
+Tencent Games http://game.qq.com/ Gold Sponsor of the MariaDB Foundation
Nexedi https://www.nexedi.com Silver Sponsor of the MariaDB Foundation
-Acronis http://www.acronis.com Silver Sponsor of the MariaDB Foundation
+Acronis https://www.acronis.com Silver Sponsor of the MariaDB Foundation
Verkkokauppa.com https://www.verkkokauppa.com Bronze Sponsor of the MariaDB Foundation
Virtuozzo https://virtuozzo.com Bronze Sponsor of the MariaDB Foundation
Tencent Game DBA http://tencentdba.com/about Bronze Sponsor of the MariaDB Foundation
Tencent TDSQL http://tdsql.org Bronze Sponsor of the MariaDB Foundation
+Percona https://www.percona.com/ Bronze Sponsor of the MariaDB Foundation
Google USA Sponsoring encryption, parallel replication and GTID
Facebook USA Sponsoring non-blocking API, LIMIT ROWS EXAMINED etc
Ronald Bradford Brisbane, Australia EFF contribution for UC2006 Auction
diff --git a/mysql-test/r/create_or_replace.result b/mysql-test/r/create_or_replace.result
index 27aafa976a4..3bb730a3d74 100644
--- a/mysql-test/r/create_or_replace.result
+++ b/mysql-test/r/create_or_replace.result
@@ -471,3 +471,18 @@ ERROR HY000: Table 't1' was not locked with LOCK TABLES
UNLOCK TABLES;
DROP FUNCTION f1;
DROP TABLE t1;
+#
+# MDEV-14410 - Assertion `table->pos_in_locked_tables == __null ||
+# table->pos_in_locked_tables->table == table' failed in
+# mark_used_tables_as_free_for_reuse
+#
+CREATE TABLE t1 (a INT);
+CREATE TABLE t2 (b INT);
+CREATE TABLE t3 (c INT);
+CREATE TRIGGER tr1 BEFORE INSERT ON t3 FOR EACH ROW INSERT INTO t1 VALUES ();
+CREATE TRIGGER tr2 BEFORE INSERT ON t2 FOR EACH ROW INSERT INTO t3 SELECT * FROM t1;
+LOCK TABLE t1 WRITE, t2 WRITE;
+CREATE OR REPLACE TABLE t1 (i INT);
+UNLOCK TABLES;
+INSERT INTO t2 VALUES (1);
+DROP TABLE t1, t2, t3;
diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result
index 74911287a6a..f0652236a38 100644
--- a/mysql-test/r/func_time.result
+++ b/mysql-test/r/func_time.result
@@ -2802,6 +2802,164 @@ PERIOD_DIFF(2018, AES_ENCRYPT('Rae Bareli', 'Rae Bareli'))
Warnings:
Warning 1292 Truncated incorrect INTEGER value: '-3S\xFA\xDE?\x00\x00\xCA\xB3\xEEE\xA4\xD1\xC1\xA8'
#
+# MDEV-17249 MAKETIME(-1e50,0,0) returns a wrong result
+#
+SELECT
+MAKETIME(1e10,0,0),
+MAKETIME(-1e10,0,0),
+MAKETIME(1e50,0,0),
+MAKETIME(-1e50,0,0),
+MAKETIME(COALESCE(1e50),0,0),
+MAKETIME(COALESCE(-1e50),0,0);
+MAKETIME(1e10,0,0) 838:59:59
+MAKETIME(-1e10,0,0) -838:59:59
+MAKETIME(1e50,0,0) 838:59:59
+MAKETIME(-1e50,0,0) -838:59:59
+MAKETIME(COALESCE(1e50),0,0) 838:59:59
+MAKETIME(COALESCE(-1e50),0,0) -838:59:59
+Warnings:
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '10000000000:00:00'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '-10000000000:00:00'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '9223372036854775807:00:00'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '-9223372036854775808:00:00'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '9223372036854775807:00:00'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '-9223372036854775808:00:00'
+CREATE TABLE t1 (a FLOAT);
+INSERT INTO t1 VALUES (1e30),(-1e30);
+SELECT MAKETIME(a,0,0) FROM t1;
+MAKETIME(a,0,0)
+838:59:59
+-838:59:59
+Warnings:
+Warning 1292 Truncated incorrect time value: '9223372036854775807:00:00'
+Warning 1292 Truncated incorrect time value: '-9223372036854775808:00:00'
+DROP TABLE t1;
+#
+# MDEV-17244 MAKETIME(900,0,0.111) returns a wrong result
+#
+SELECT MAKETIME(900,0,0);
+MAKETIME(900,0,0)
+838:59:59
+Warnings:
+Warning 1292 Truncated incorrect time value: '900:00:00'
+SELECT MAKETIME(900,0,0.1);
+MAKETIME(900,0,0.1)
+838:59:59.9
+Warnings:
+Warning 1292 Truncated incorrect time value: '900:00:00'
+SELECT MAKETIME(900,0,0.11);
+MAKETIME(900,0,0.11)
+838:59:59.99
+Warnings:
+Warning 1292 Truncated incorrect time value: '900:00:00'
+SELECT MAKETIME(900,0,0.111);
+MAKETIME(900,0,0.111)
+838:59:59.999
+Warnings:
+Warning 1292 Truncated incorrect time value: '900:00:00'
+SELECT MAKETIME(900,0,0.1111);
+MAKETIME(900,0,0.1111)
+838:59:59.9999
+Warnings:
+Warning 1292 Truncated incorrect time value: '900:00:00'
+SELECT MAKETIME(900,0,0.11111);
+MAKETIME(900,0,0.11111)
+838:59:59.99999
+Warnings:
+Warning 1292 Truncated incorrect time value: '900:00:00'
+SELECT MAKETIME(900,0,0.111111);
+MAKETIME(900,0,0.111111)
+838:59:59.999999
+Warnings:
+Warning 1292 Truncated incorrect time value: '900:00:00'
+SELECT MAKETIME(900,0,0.1111111);
+MAKETIME(900,0,0.1111111)
+838:59:59.999999
+Warnings:
+Warning 1292 Truncated incorrect time value: '900:00:00'
+SELECT MAKETIME(900,0,0.11111111);
+MAKETIME(900,0,0.11111111)
+838:59:59.999999
+Warnings:
+Warning 1292 Truncated incorrect time value: '900:00:00'
+SELECT MAKETIME(900,0,0.111111111);
+MAKETIME(900,0,0.111111111)
+838:59:59.999999
+Warnings:
+Warning 1292 Truncated incorrect time value: '900:00:00'
+SELECT MAKETIME(900,0,EXP(1));
+MAKETIME(900,0,EXP(1))
+838:59:59.999999
+Warnings:
+Warning 1292 Truncated incorrect time value: '900:00:02'
+SELECT MAKETIME(-900,0,0);
+MAKETIME(-900,0,0)
+-838:59:59
+Warnings:
+Warning 1292 Truncated incorrect time value: '-900:00:00'
+SELECT MAKETIME(-900,0,0.1);
+MAKETIME(-900,0,0.1)
+-838:59:59.9
+Warnings:
+Warning 1292 Truncated incorrect time value: '-900:00:00'
+SELECT MAKETIME(-900,0,0.11);
+MAKETIME(-900,0,0.11)
+-838:59:59.99
+Warnings:
+Warning 1292 Truncated incorrect time value: '-900:00:00'
+SELECT MAKETIME(-900,0,0.111);
+MAKETIME(-900,0,0.111)
+-838:59:59.999
+Warnings:
+Warning 1292 Truncated incorrect time value: '-900:00:00'
+SELECT MAKETIME(-900,0,0.1111);
+MAKETIME(-900,0,0.1111)
+-838:59:59.9999
+Warnings:
+Warning 1292 Truncated incorrect time value: '-900:00:00'
+SELECT MAKETIME(-900,0,0.11111);
+MAKETIME(-900,0,0.11111)
+-838:59:59.99999
+Warnings:
+Warning 1292 Truncated incorrect time value: '-900:00:00'
+SELECT MAKETIME(-900,0,0.111111);
+MAKETIME(-900,0,0.111111)
+-838:59:59.999999
+Warnings:
+Warning 1292 Truncated incorrect time value: '-900:00:00'
+SELECT MAKETIME(-900,0,0.1111111);
+MAKETIME(-900,0,0.1111111)
+-838:59:59.999999
+Warnings:
+Warning 1292 Truncated incorrect time value: '-900:00:00'
+SELECT MAKETIME(-900,0,0.11111111);
+MAKETIME(-900,0,0.11111111)
+-838:59:59.999999
+Warnings:
+Warning 1292 Truncated incorrect time value: '-900:00:00'
+SELECT MAKETIME(-900,0,0.111111111);
+MAKETIME(-900,0,0.111111111)
+-838:59:59.999999
+Warnings:
+Warning 1292 Truncated incorrect time value: '-900:00:00'
+SELECT MAKETIME(-900,0,EXP(1));
+MAKETIME(-900,0,EXP(1))
+-838:59:59.999999
+Warnings:
+Warning 1292 Truncated incorrect time value: '-900:00:02'
+#
# End of 5.5 tests
#
#
diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result
index 7abaf834975..dc2664e040d 100644
--- a/mysql-test/r/grant.result
+++ b/mysql-test/r/grant.result
@@ -2577,6 +2577,35 @@ foo@localhost foo@127.0.0.1
# Clean-up
DROP USER foo@'127.0.0.1';
# End of Bug#12766319
+create user foo@localhost;
+create database foodb;
+grant create routine on foodb.* to foo@localhost;
+create procedure fooproc() select 'i am fooproc';
+show grants;
+Grants for foo@localhost
+GRANT USAGE ON *.* TO 'foo'@'localhost'
+GRANT CREATE ROUTINE ON `foodb`.* TO 'foo'@'localhost'
+GRANT EXECUTE, ALTER ROUTINE ON PROCEDURE `test`.`fooproc` TO 'foo'@'localhost'
+rename table mysql.procs_priv to mysql.procs_priv1;
+flush privileges;
+show grants for foo@localhost;
+Grants for foo@localhost
+GRANT USAGE ON *.* TO 'foo'@'localhost'
+GRANT CREATE ROUTINE ON `foodb`.* TO 'foo'@'localhost'
+rename table mysql.procs_priv1 to mysql.procs_priv;
+show grants for foo@localhost;
+Grants for foo@localhost
+GRANT USAGE ON *.* TO 'foo'@'localhost'
+GRANT CREATE ROUTINE ON `foodb`.* TO 'foo'@'localhost'
+flush privileges;
+show grants for foo@localhost;
+Grants for foo@localhost
+GRANT USAGE ON *.* TO 'foo'@'localhost'
+GRANT CREATE ROUTINE ON `foodb`.* TO 'foo'@'localhost'
+GRANT EXECUTE, ALTER ROUTINE ON PROCEDURE `test`.`fooproc` TO 'foo'@'localhost'
+drop user foo@localhost;
+drop procedure fooproc;
+drop database foodb;
#
# Bug#11756966 - 48958: STORED PROCEDURES CAN BE LEVERAGED TO BYPASS
# DATABASE SECURITY
diff --git a/mysql-test/r/sp-security.result b/mysql-test/r/sp-security.result
index 276da41a0fe..44ac680f9c1 100644
--- a/mysql-test/r/sp-security.result
+++ b/mysql-test/r/sp-security.result
@@ -628,6 +628,29 @@ SELECT 1 latin1 latin1_swedish_ci latin1_swedish_ci
# Connection default
DROP USER user2@localhost;
DROP DATABASE db1;
+create user foo@local_ost;
+create user foo@`local\_ost`;
+update mysql.user set plugin='foobar' where host='local\\_ost';
+flush privileges;
+create database foodb;
+grant create routine on foodb.* to foo@local_ost;
+select user(), current_user();
+user() current_user()
+foo@localhost foo@local_ost
+show grants;
+Grants for foo@local_ost
+GRANT USAGE ON *.* TO 'foo'@'local_ost'
+GRANT CREATE ROUTINE ON `foodb`.* TO 'foo'@'local_ost'
+create procedure fooproc() select 'i am fooproc';
+show grants;
+Grants for foo@local_ost
+GRANT USAGE ON *.* TO 'foo'@'local_ost'
+GRANT CREATE ROUTINE ON `foodb`.* TO 'foo'@'local_ost'
+GRANT EXECUTE, ALTER ROUTINE ON PROCEDURE `test`.`fooproc` TO 'foo'@'local_ost'
+drop user foo@local_ost;
+drop user foo@`local\_ost`;
+drop procedure fooproc;
+drop database foodb;
#
# Test for bug#12602983 - User without privilege on routine can discover
# its existence by executing "select non_existing_func();" or by
diff --git a/mysql-test/r/type_float.result b/mysql-test/r/type_float.result
index e7267f012ae..f1d429a8058 100644
--- a/mysql-test/r/type_float.result
+++ b/mysql-test/r/type_float.result
@@ -448,6 +448,42 @@ select format(truncate('1.7976931348623157E+308',-12),1,'fr_BE') as foo;
foo
0
#
+# MDEV-17249 MAKETIME(-1e50,0,0) returns a wrong result
+#
+SELECT LEFT('a',EXP(50));
+LEFT('a',EXP(50))
+a
+SELECT LEFT('a', COALESCE(1e30));
+LEFT('a', COALESCE(1e30))
+a
+CREATE TABLE t1 (a FLOAT);
+INSERT INTO t1 VALUES (1e30);
+SELECT LEFT('a',a), LEFT('a',1e30) FROM t1;
+LEFT('a',a) LEFT('a',1e30)
+a a
+DROP TABLE t1;
+PREPARE stmt FROM 'SELECT LEFT(111,?)';
+SET @a=1e30;
+EXECUTE stmt USING @a;
+LEFT(111,?)
+111
+DEALLOCATE PREPARE stmt;
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1),(2),(3);
+SELECT LEFT('a',(SELECT 1e30 FROM t1 LIMIT 1));
+LEFT('a',(SELECT 1e30 FROM t1 LIMIT 1))
+a
+DROP TABLE t1;
+CREATE TABLE t1 (a DOUBLE);
+INSERT INTO t1 VALUES (1e30),(0);
+SELECT LEFT('a', SUM(a)) FROM t1;
+LEFT('a', SUM(a))
+a
+SELECT LEFT('a', AVG(a)) FROM t1;
+LEFT('a', AVG(a))
+a
+DROP TABLE t1;
+#
# Bug #13500371 63704: CONVERSION OF '1.' TO A NUMBER GIVES ERROR 1265
# (WARN_DATA_TRUNCATED)
#
diff --git a/mysql-test/suite/parts/r/update_and_cache.result b/mysql-test/suite/parts/r/update_and_cache.result
new file mode 100644
index 00000000000..52f13e66702
--- /dev/null
+++ b/mysql-test/suite/parts/r/update_and_cache.result
@@ -0,0 +1,7 @@
+CREATE TABLE t1 (pk INT PRIMARY KEY, a INT);
+INSERT INTO t1 VALUES (1,10),(2,20);
+CREATE TABLE t2 (b INT) PARTITION BY KEY (b) PARTITIONS 2;
+INSERT INTO t2 VALUES (1),(2);
+DELETE t2 FROM t2 WHERE b BETWEEN 5 AND 9;
+UPDATE t2 JOIN t1 SET b = 5;
+DROP TABLE t1, t2;
diff --git a/mysql-test/suite/parts/t/update_and_cache.test b/mysql-test/suite/parts/t/update_and_cache.test
new file mode 100644
index 00000000000..08ade807422
--- /dev/null
+++ b/mysql-test/suite/parts/t/update_and_cache.test
@@ -0,0 +1,12 @@
+--source include/have_partition.inc
+
+CREATE TABLE t1 (pk INT PRIMARY KEY, a INT);
+INSERT INTO t1 VALUES (1,10),(2,20);
+
+CREATE TABLE t2 (b INT) PARTITION BY KEY (b) PARTITIONS 2;
+INSERT INTO t2 VALUES (1),(2);
+
+DELETE t2 FROM t2 WHERE b BETWEEN 5 AND 9;
+UPDATE t2 JOIN t1 SET b = 5;
+
+DROP TABLE t1, t2;
diff --git a/mysql-test/t/create_or_replace.test b/mysql-test/t/create_or_replace.test
index c1441d218cf..455f079b58d 100644
--- a/mysql-test/t/create_or_replace.test
+++ b/mysql-test/t/create_or_replace.test
@@ -421,3 +421,24 @@ UNLOCK TABLES;
DROP FUNCTION f1;
DROP TABLE t1;
+
+
+--echo #
+--echo # MDEV-14410 - Assertion `table->pos_in_locked_tables == __null ||
+--echo # table->pos_in_locked_tables->table == table' failed in
+--echo # mark_used_tables_as_free_for_reuse
+--echo #
+CREATE TABLE t1 (a INT);
+CREATE TABLE t2 (b INT);
+CREATE TABLE t3 (c INT);
+
+CREATE TRIGGER tr1 BEFORE INSERT ON t3 FOR EACH ROW INSERT INTO t1 VALUES ();
+CREATE TRIGGER tr2 BEFORE INSERT ON t2 FOR EACH ROW INSERT INTO t3 SELECT * FROM t1;
+
+LOCK TABLE t1 WRITE, t2 WRITE;
+CREATE OR REPLACE TABLE t1 (i INT);
+UNLOCK TABLES;
+INSERT INTO t2 VALUES (1);
+
+# Cleanup
+DROP TABLE t1, t2, t3;
diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test
index 80ee18b6b1f..0a4b85c2a81 100644
--- a/mysql-test/t/func_time.test
+++ b/mysql-test/t/func_time.test
@@ -1706,6 +1706,55 @@ SELECT SEC_TO_TIME(MAKEDATE(0,RAND(~0)));
#
SELECT PERIOD_DIFF(2018, AES_ENCRYPT('Rae Bareli', 'Rae Bareli'));
+
+--echo #
+--echo # MDEV-17249 MAKETIME(-1e50,0,0) returns a wrong result
+--echo #
+
+--vertical_results
+SELECT
+ MAKETIME(1e10,0,0),
+ MAKETIME(-1e10,0,0),
+ MAKETIME(1e50,0,0),
+ MAKETIME(-1e50,0,0),
+ MAKETIME(COALESCE(1e50),0,0),
+ MAKETIME(COALESCE(-1e50),0,0);
+--horizontal_results
+
+CREATE TABLE t1 (a FLOAT);
+INSERT INTO t1 VALUES (1e30),(-1e30);
+SELECT MAKETIME(a,0,0) FROM t1;
+DROP TABLE t1;
+
+--echo #
+--echo # MDEV-17244 MAKETIME(900,0,0.111) returns a wrong result
+--echo #
+
+SELECT MAKETIME(900,0,0);
+SELECT MAKETIME(900,0,0.1);
+SELECT MAKETIME(900,0,0.11);
+SELECT MAKETIME(900,0,0.111);
+SELECT MAKETIME(900,0,0.1111);
+SELECT MAKETIME(900,0,0.11111);
+SELECT MAKETIME(900,0,0.111111);
+SELECT MAKETIME(900,0,0.1111111);
+SELECT MAKETIME(900,0,0.11111111);
+SELECT MAKETIME(900,0,0.111111111);
+SELECT MAKETIME(900,0,EXP(1));
+
+SELECT MAKETIME(-900,0,0);
+SELECT MAKETIME(-900,0,0.1);
+SELECT MAKETIME(-900,0,0.11);
+SELECT MAKETIME(-900,0,0.111);
+SELECT MAKETIME(-900,0,0.1111);
+SELECT MAKETIME(-900,0,0.11111);
+SELECT MAKETIME(-900,0,0.111111);
+SELECT MAKETIME(-900,0,0.1111111);
+SELECT MAKETIME(-900,0,0.11111111);
+SELECT MAKETIME(-900,0,0.111111111);
+SELECT MAKETIME(-900,0,EXP(1));
+
+
--echo #
--echo # End of 5.5 tests
--echo #
diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test
index 837484c6929..e4a7d62f85e 100644
--- a/mysql-test/t/grant.test
+++ b/mysql-test/t/grant.test
@@ -2234,6 +2234,28 @@ DROP USER foo@'127.0.0.1';
--echo # End of Bug#12766319
+#
+# Bug#27230925: HANDLE_FATAL_SIGNAL (SIG=11) IN SHOW_ROUTINE_GRANTS
+#
+create user foo@localhost;
+create database foodb;
+grant create routine on foodb.* to foo@localhost;
+connect con1,localhost,foo;
+create procedure fooproc() select 'i am fooproc';
+show grants;
+disconnect con1;
+connection default;
+rename table mysql.procs_priv to mysql.procs_priv1;
+flush privileges;
+show grants for foo@localhost;
+rename table mysql.procs_priv1 to mysql.procs_priv;
+show grants for foo@localhost;
+flush privileges;
+show grants for foo@localhost;
+drop user foo@localhost;
+drop procedure fooproc;
+drop database foodb;
+
--echo #
--echo # Bug#11756966 - 48958: STORED PROCEDURES CAN BE LEVERAGED TO BYPASS
diff --git a/mysql-test/t/sp-security.test b/mysql-test/t/sp-security.test
index a5df4859d6b..417e3a3050a 100644
--- a/mysql-test/t/sp-security.test
+++ b/mysql-test/t/sp-security.test
@@ -1005,6 +1005,34 @@ disconnect con2;
DROP USER user2@localhost;
DROP DATABASE db1;
+#
+# Bug#27407480: AUTOMATIC_SP_PRIVILEGES REQUIRES NEED THE INSERT PRIVILEGES FOR MYSQL.USER TABLE
+#
+create user foo@local_ost;
+#
+# Create a user with an authentification plugin 'foobar'.
+# Instead of using a normal "CREATE USER <user> IDENTIFIED VIA <plugin>"
+# we do CREATE (without VIA) followed by UPDATE and FLUSH.
+# This is to avoid installing a real plugin and thus avoid the test dependency.
+# We won't login under this user in the below test, so this is fine.
+#
+create user foo@`local\_ost`;
+update mysql.user set plugin='foobar' where host='local\\_ost';
+flush privileges;
+create database foodb;
+grant create routine on foodb.* to foo@local_ost;
+connect con1,localhost,foo;
+select user(), current_user();
+show grants;
+create procedure fooproc() select 'i am fooproc';
+show grants;
+disconnect con1;
+connection default;
+drop user foo@local_ost;
+drop user foo@`local\_ost`;
+drop procedure fooproc;
+drop database foodb;
+
--echo #
--echo # Test for bug#12602983 - User without privilege on routine can discover
--echo # its existence by executing "select non_existing_func();" or by
diff --git a/mysql-test/t/type_float.test b/mysql-test/t/type_float.test
index 3717dc028ba..228812c2ae5 100644
--- a/mysql-test/t/type_float.test
+++ b/mysql-test/t/type_float.test
@@ -332,6 +332,36 @@ eval select concat((truncate((-1.7976931348623157E+307),(0x1e))),
select format(truncate('1.7976931348623157E+308',-12),1,'fr_BE') as foo;
+
+--echo #
+--echo # MDEV-17249 MAKETIME(-1e50,0,0) returns a wrong result
+--echo #
+
+SELECT LEFT('a',EXP(50));
+SELECT LEFT('a', COALESCE(1e30));
+
+CREATE TABLE t1 (a FLOAT);
+INSERT INTO t1 VALUES (1e30);
+SELECT LEFT('a',a), LEFT('a',1e30) FROM t1;
+DROP TABLE t1;
+
+PREPARE stmt FROM 'SELECT LEFT(111,?)';
+SET @a=1e30;
+EXECUTE stmt USING @a;
+DEALLOCATE PREPARE stmt;
+
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1),(2),(3);
+SELECT LEFT('a',(SELECT 1e30 FROM t1 LIMIT 1));
+DROP TABLE t1;
+
+CREATE TABLE t1 (a DOUBLE);
+INSERT INTO t1 VALUES (1e30),(0);
+SELECT LEFT('a', SUM(a)) FROM t1;
+SELECT LEFT('a', AVG(a)) FROM t1;
+DROP TABLE t1;
+
+
--echo #
--echo # Bug #13500371 63704: CONVERSION OF '1.' TO A NUMBER GIVES ERROR 1265
--echo # (WARN_DATA_TRUNCATED)
diff --git a/mysys/my_alloc.c b/mysys/my_alloc.c
index 1b0ef857afa..276ad080520 100644
--- a/mysys/my_alloc.c
+++ b/mysys/my_alloc.c
@@ -204,6 +204,7 @@ void *alloc_root(MEM_ROOT *mem_root, size_t length)
uchar* point;
reg1 USED_MEM *next= 0;
reg2 USED_MEM **prev;
+ size_t original_length = length;
DBUG_ENTER("alloc_root");
DBUG_PRINT("enter",("root: %p", mem_root));
DBUG_ASSERT(alloc_root_inited(mem_root));
@@ -264,7 +265,7 @@ void *alloc_root(MEM_ROOT *mem_root, size_t length)
mem_root->used= next;
mem_root->first_block_usage= 0;
}
- TRASH_ALLOC(point, length);
+ TRASH_ALLOC(point, original_length);
DBUG_PRINT("exit",("ptr: %p", point));
DBUG_RETURN((void*) point);
#endif
diff --git a/sql/contributors.h b/sql/contributors.h
index a0d05af3fa6..69f8fa6bd4c 100644
--- a/sql/contributors.h
+++ b/sql/contributors.h
@@ -45,12 +45,14 @@ struct show_table_contributors_st show_table_contributors[]= {
{"Visma", "https://visma.com", "Gold Sponsor of the MariaDB Foundation"},
{"DBS", "https://dbs.com", "Gold Sponsor of the MariaDB Foundation"},
{"IBM", "https://www.ibm.com", "Gold Sponsor of the MariaDB Foundation"},
+ {"Tencent Games", "http://game.qq.com/", "Gold Sponsor of the MariaDB Foundation"},
{"Nexedi", "https://www.nexedi.com", "Silver Sponsor of the MariaDB Foundation"},
- {"Acronis", "http://www.acronis.com", "Silver Sponsor of the MariaDB Foundation"},
+ {"Acronis", "https://www.acronis.com", "Silver Sponsor of the MariaDB Foundation"},
{"Verkkokauppa.com", "https://www.verkkokauppa.com", "Bronze Sponsor of the MariaDB Foundation"},
{"Virtuozzo", "https://virtuozzo.com", "Bronze Sponsor of the MariaDB Foundation"},
{"Tencent Game DBA", "http://tencentdba.com/about", "Bronze Sponsor of the MariaDB Foundation"},
{"Tencent TDSQL", "http://tdsql.org", "Bronze Sponsor of the MariaDB Foundation"},
+ {"Percona", "https://www.percona.com/", "Bronze Sponsor of the MariaDB Foundation"},
/* Sponsors of important features */
{"Google", "USA", "Sponsoring encryption, parallel replication and GTID"},
diff --git a/sql/field.cc b/sql/field.cc
index ecb383a9575..a4308a378b3 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -4430,7 +4430,8 @@ longlong Field_float::val_int(void)
{
float j;
float4get(j,ptr);
- return (longlong) rint(j);
+ bool error;
+ return double_to_longlong(j, false, &error);
}
diff --git a/sql/item.cc b/sql/item.cc
index ad278465a4a..1a2c4eba5fb 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -3566,7 +3566,10 @@ longlong Item_param::val_int()
{
switch (state) {
case REAL_VALUE:
- return (longlong) rint(value.real);
+ {
+ bool error;
+ return double_to_longlong(value.real, unsigned_flag, &error);
+ }
case INT_VALUE:
return value.integer;
case DECIMAL_VALUE:
@@ -4032,32 +4035,6 @@ bool Item_param::append_for_log(THD *thd, String *str)
return str->append(*val);
}
-/****************************************************************************
- Item_copy
-****************************************************************************/
-
-Item_copy *Item_copy::create(THD *thd, Item *item)
-{
- MEM_ROOT *mem_root= thd->mem_root;
- switch (item->result_type())
- {
- case STRING_RESULT:
- return new (mem_root) Item_copy_string(thd, item);
- case REAL_RESULT:
- return new (mem_root) Item_copy_float(thd, item);
- case INT_RESULT:
- return item->unsigned_flag ?
- new (mem_root) Item_copy_uint(thd, item) :
- new (mem_root) Item_copy_int(thd, item);
- case DECIMAL_RESULT:
- return new (mem_root) Item_copy_decimal(thd, item);
- case TIME_RESULT:
- case ROW_RESULT:
- DBUG_ASSERT (0);
- }
- /* should not happen */
- return NULL;
-}
/****************************************************************************
Item_copy_string
@@ -4115,156 +4092,6 @@ my_decimal *Item_copy_string::val_decimal(my_decimal *decimal_value)
}
-/****************************************************************************
- Item_copy_int
-****************************************************************************/
-
-void Item_copy_int::copy()
-{
- cached_value= item->val_int();
- null_value=item->null_value;
-}
-
-static int save_int_value_in_field (Field *, longlong, bool, bool);
-
-int Item_copy_int::save_in_field(Field *field, bool no_conversions)
-{
- return save_int_value_in_field(field, cached_value,
- null_value, unsigned_flag);
-}
-
-
-String *Item_copy_int::val_str(String *str)
-{
- if (null_value)
- return (String *) 0;
-
- str->set(cached_value, &my_charset_bin);
- return str;
-}
-
-
-my_decimal *Item_copy_int::val_decimal(my_decimal *decimal_value)
-{
- if (null_value)
- return (my_decimal *) 0;
-
- int2my_decimal(E_DEC_FATAL_ERROR, cached_value, unsigned_flag, decimal_value);
- return decimal_value;
-}
-
-
-/****************************************************************************
- Item_copy_uint
-****************************************************************************/
-
-String *Item_copy_uint::val_str(String *str)
-{
- if (null_value)
- return (String *) 0;
-
- str->set((ulonglong) cached_value, &my_charset_bin);
- return str;
-}
-
-
-/****************************************************************************
- Item_copy_float
-****************************************************************************/
-
-String *Item_copy_float::val_str(String *str)
-{
- if (null_value)
- return (String *) 0;
- else
- {
- double nr= val_real();
- str->set_real(nr,decimals, &my_charset_bin);
- return str;
- }
-}
-
-
-my_decimal *Item_copy_float::val_decimal(my_decimal *decimal_value)
-{
- if (null_value)
- return (my_decimal *) 0;
- else
- {
- double nr= val_real();
- double2my_decimal(E_DEC_FATAL_ERROR, nr, decimal_value);
- return decimal_value;
- }
-}
-
-
-int Item_copy_float::save_in_field(Field *field, bool no_conversions)
-{
- if (null_value)
- return set_field_to_null(field);
- field->set_notnull();
- return field->store(cached_value);
-}
-
-
-/****************************************************************************
- Item_copy_decimal
-****************************************************************************/
-
-int Item_copy_decimal::save_in_field(Field *field, bool no_conversions)
-{
- if (null_value)
- return set_field_to_null(field);
- field->set_notnull();
- return field->store_decimal(&cached_value);
-}
-
-
-String *Item_copy_decimal::val_str(String *result)
-{
- if (null_value)
- return (String *) 0;
- result->set_charset(&my_charset_bin);
- my_decimal2string(E_DEC_FATAL_ERROR, &cached_value, 0, 0, 0, result);
- return result;
-}
-
-
-double Item_copy_decimal::val_real()
-{
- if (null_value)
- return 0.0;
- else
- {
- double result;
- my_decimal2double(E_DEC_FATAL_ERROR, &cached_value, &result);
- return result;
- }
-}
-
-
-longlong Item_copy_decimal::val_int()
-{
- if (null_value)
- return 0;
- else
- {
- longlong result;
- my_decimal2int(E_DEC_FATAL_ERROR, &cached_value, unsigned_flag, &result);
- return result;
- }
-}
-
-
-void Item_copy_decimal::copy()
-{
- my_decimal *nr= item->val_decimal(&cached_value);
- if (nr && nr != &cached_value)
- my_decimal2decimal (nr, &cached_value);
- null_value= item->null_value;
-}
-
-
/*
Functions to convert item to field (for send_result_set_metadata)
*/
@@ -9170,7 +8997,8 @@ longlong Item_cache_real::val_int()
DBUG_ASSERT(fixed == 1);
if (!has_value())
return 0;
- return (longlong) rint(value);
+ bool error;
+ return double_to_longlong(value, unsigned_flag, &error);
}
diff --git a/sql/item.h b/sql/item.h
index dcd773ffc59..57f10740fed 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -4545,7 +4545,7 @@ public:
Base class to implement typed value caching Item classes
Item_copy_ classes are very similar to the corresponding Item_
- classes (e.g. Item_copy_int is similar to Item_int) but they add
+ classes (e.g. Item_copy_string is similar to Item_string) but they add
the following additional functionality to Item_ :
1. Nullability
2. Possibility to store the value not only on instantiation time,
@@ -4598,13 +4598,6 @@ protected:
}
public:
- /**
- Factory method to create the appropriate subclass dependent on the type of
- the original item.
-
- @param item the original item.
- */
- static Item_copy *create(THD *thd, Item *item);
/**
Update the cache with the value of the original item
@@ -4666,89 +4659,6 @@ public:
};
-class Item_copy_int : public Item_copy
-{
-protected:
- longlong cached_value;
-public:
- Item_copy_int(THD *thd, Item *i): Item_copy(thd, i) {}
- int save_in_field(Field *field, bool no_conversions);
-
- virtual String *val_str(String*);
- virtual my_decimal *val_decimal(my_decimal *);
- virtual double val_real()
- {
- return null_value ? 0.0 : (double) cached_value;
- }
- virtual longlong val_int()
- {
- return null_value ? 0 : cached_value;
- }
- virtual void copy();
-};
-
-
-class Item_copy_uint : public Item_copy_int
-{
-public:
- Item_copy_uint(THD *thd, Item *item_arg): Item_copy_int(thd, item_arg)
- {
- unsigned_flag= 1;
- }
-
- String *val_str(String*);
- double val_real()
- {
- return null_value ? 0.0 : (double) (ulonglong) cached_value;
- }
-};
-
-
-class Item_copy_float : public Item_copy
-{
-protected:
- double cached_value;
-public:
- Item_copy_float(THD *thd, Item *i): Item_copy(thd, i) {}
- int save_in_field(Field *field, bool no_conversions);
-
- String *val_str(String*);
- my_decimal *val_decimal(my_decimal *);
- double val_real()
- {
- return null_value ? 0.0 : cached_value;
- }
- longlong val_int()
- {
- return (longlong) rint(val_real());
- }
- void copy()
- {
- cached_value= item->val_real();
- null_value= item->null_value;
- }
-};
-
-
-class Item_copy_decimal : public Item_copy
-{
-protected:
- my_decimal cached_value;
-public:
- Item_copy_decimal(THD *thd, Item *i): Item_copy(thd, i) {}
- int save_in_field(Field *field, bool no_conversions);
-
- String *val_str(String*);
- my_decimal *val_decimal(my_decimal *)
- {
- return null_value ? NULL: &cached_value;
- }
- double val_real();
- longlong val_int();
- void copy();
-};
-
-
/*
Cached_item_XXX objects are not exactly caches. They do the following:
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 05a34a9a24a..8b1c7b3bc61 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -940,7 +940,10 @@ longlong Item_func_hybrid_field_type::val_int()
case INT_RESULT:
return int_op();
case REAL_RESULT:
- return (longlong) rint(real_op());
+ {
+ bool error;
+ return double_to_longlong(real_op(), unsigned_flag, &error);
+ }
case TIME_RESULT:
{
MYSQL_TIME ltime;
diff --git a/sql/item_func.h b/sql/item_func.h
index 3219c813821..2c0e3a62f6a 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -382,7 +382,11 @@ public:
String *val_str(String*str);
my_decimal *val_decimal(my_decimal *decimal_value);
longlong val_int()
- { DBUG_ASSERT(fixed == 1); return (longlong) rint(val_real()); }
+ {
+ DBUG_ASSERT(fixed == 1);
+ bool error;
+ return double_to_longlong(val_real(), unsigned_flag, &error);
+ }
enum Item_result result_type () const { return REAL_RESULT; }
void fix_length_and_dec()
{ decimals= NOT_FIXED_DEC; max_length= float_length(decimals); }
@@ -1477,7 +1481,9 @@ class Item_func_udf_float :public Item_udf_func
longlong val_int()
{
DBUG_ASSERT(fixed == 1);
- return (longlong) rint(Item_func_udf_float::val_real());
+ bool error;
+ return double_to_longlong(Item_func_udf_float::val_real(),
+ unsigned_flag, &error);
}
my_decimal *val_decimal(my_decimal *dec_buf)
{
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index 44105bd4a12..83949f2502e 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -41,6 +41,7 @@
#include "set_var.h"
#include "sql_locale.h" // MY_LOCALE my_locale_en_US
#include "strfunc.h" // check_word
+#include "sql_type_int.h" // Longlong_hybrid
#include "sql_time.h" // make_truncated_value_warning,
// get_date_from_daynr,
// calc_weekday, calc_week,
@@ -2802,8 +2803,7 @@ bool Item_func_timediff::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date)
bool Item_func_maketime::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date)
{
DBUG_ASSERT(fixed == 1);
- bool overflow= 0;
- longlong hour= args[0]->val_int();
+ Longlong_hybrid hour(args[0]->val_int(), args[0]->unsigned_flag);
longlong minute= args[1]->val_int();
ulonglong second;
ulong microsecond;
@@ -2815,32 +2815,23 @@ bool Item_func_maketime::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date)
bzero(ltime, sizeof(*ltime));
ltime->time_type= MYSQL_TIMESTAMP_TIME;
+ ltime->neg= hour.neg();
- /* Check for integer overflows */
- if (hour < 0)
+ if (hour.abs() <= TIME_MAX_HOUR)
{
- if (args[0]->unsigned_flag)
- overflow= 1;
- else
- ltime->neg= 1;
- }
- if (-hour > TIME_MAX_HOUR || hour > TIME_MAX_HOUR)
- overflow= 1;
-
- if (!overflow)
- {
- ltime->hour= (uint) ((hour < 0 ? -hour : hour));
+ ltime->hour= (uint) hour.abs();
ltime->minute= (uint) minute;
ltime->second= (uint) second;
ltime->second_part= microsecond;
}
else
{
- ltime->hour= TIME_MAX_HOUR;
- ltime->minute= TIME_MAX_MINUTE;
- ltime->second= TIME_MAX_SECOND;
+ // use check_time_range() to set ltime to the max value depending on dec
+ int unused;
+ ltime->hour= TIME_MAX_HOUR + 1;
+ check_time_range(ltime, decimals, &unused);
char buf[28];
- char *ptr= longlong10_to_str(hour, buf, args[0]->unsigned_flag ? 10 : -10);
+ char *ptr= longlong10_to_str(hour.value(), buf, hour.is_unsigned() ? 10 : -10);
int len = (int)(ptr - buf) + sprintf(ptr, ":%02u:%02u", (uint)minute, (uint)second);
make_truncated_value_warning(current_thd, Sql_condition::WARN_LEVEL_WARN,
buf, len, MYSQL_TIMESTAMP_TIME,
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 3fab00a46df..72d65e14a94 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -10187,9 +10187,8 @@ bool sp_grant_privileges(THD *thd, const char *sp_db, const char *sp_name,
combo->user.str= (char *) sctx->priv_user;
mysql_mutex_lock(&acl_cache->lock);
-
- if ((au= find_user_wild(combo->host.str= (char *) sctx->priv_host,
- combo->user.str)))
+ if ((au= find_user_exact(combo->host.str= (char *) sctx->priv_host,
+ combo->user.str)))
goto found_acl;
mysql_mutex_unlock(&acl_cache->lock);
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index fecb5686541..c4b243e5aba 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -850,6 +850,7 @@ close_all_tables_for_name(THD *thd, TABLE_SHARE *share,
uint key_length= share->table_cache_key.length;
const char *db= key;
const char *table_name= db + share->db.length + 1;
+ bool remove_from_locked_tables= extra != HA_EXTRA_NOT_USED;
memcpy(key, share->table_cache_key.str, key_length);
@@ -863,7 +864,7 @@ close_all_tables_for_name(THD *thd, TABLE_SHARE *share,
{
thd->locked_tables_list.unlink_from_list(thd,
table->pos_in_locked_tables,
- extra != HA_EXTRA_NOT_USED);
+ remove_from_locked_tables);
/* Inform handler that there is a drop table or a rename going on */
if (extra != HA_EXTRA_NOT_USED && table->db_stat)
{
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index 453d7ffdc01..7733d2501b8 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -1021,6 +1021,7 @@ multi_delete::~multi_delete()
{
TABLE *table= table_being_deleted->table;
table->no_keyread=0;
+ table->no_cache= 0;
}
for (uint counter= 0; counter < num_of_tables; counter++)
diff --git a/sql/sql_error.h b/sql/sql_error.h
index e03c3dd4a93..0134f938c75 100644
--- a/sql/sql_error.h
+++ b/sql/sql_error.h
@@ -18,6 +18,7 @@
#include "sql_list.h" /* Sql_alloc, MEM_ROOT */
#include "m_string.h" /* LEX_STRING */
+#include "sql_type_int.h" // Longlong_hybrid
#include "sql_string.h" /* String */
#include "sql_plist.h" /* I_P_List */
#include "mysql_com.h" /* MYSQL_ERRMSG_SIZE */
@@ -573,13 +574,11 @@ public:
{ return err_conv(err_buffer, sizeof(err_buffer), str, len, cs); }
};
-class ErrConvInteger : public ErrConv
+class ErrConvInteger : public ErrConv, public Longlong_hybrid
{
- longlong m_value;
- bool m_unsigned;
public:
ErrConvInteger(longlong num_arg, bool unsigned_flag= false) :
- ErrConv(), m_value(num_arg), m_unsigned(unsigned_flag) {}
+ ErrConv(), Longlong_hybrid(num_arg, unsigned_flag) {}
const char *ptr() const
{
return m_unsigned ? ullstr(m_value, err_buffer) :
diff --git a/sql/sql_type_int.h b/sql/sql_type_int.h
new file mode 100644
index 00000000000..1eda5651df5
--- /dev/null
+++ b/sql/sql_type_int.h
@@ -0,0 +1,44 @@
+/* Copyright (c) 2006, 2010, Oracle and/or its affiliates.
+ Copyright (c) 2011, 2016, MariaDB
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
+
+#ifndef SQL_TYPE_INT_INCLUDED
+#define SQL_TYPE_INT_INCLUDED
+
+
+// A longlong/ulonglong hybrid. Good to store results of val_int().
+class Longlong_hybrid
+{
+protected:
+ longlong m_value;
+ bool m_unsigned;
+public:
+ Longlong_hybrid(longlong nr, bool unsigned_flag)
+ :m_value(nr), m_unsigned(unsigned_flag)
+ { }
+ longlong value() const { return m_value; }
+ bool is_unsigned() const { return m_unsigned; }
+ bool neg() const { return m_value < 0 && !m_unsigned; }
+ ulonglong abs() const
+ {
+ if (m_unsigned)
+ return (ulonglong) m_value;
+ if (m_value == LONGLONG_MIN) // avoid undefined behavior
+ return ((ulonglong) LONGLONG_MAX) + 1;
+ return m_value < 0 ? -m_value : m_value;
+ }
+};
+
+#endif // SQL_TYPE_INT_INCLUDED
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index db9f9013188..b50c91426b3 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -2067,7 +2067,7 @@ multi_update::~multi_update()
TABLE_LIST *table;
for (table= update_tables ; table; table= table->next_local)
{
- table->table->no_keyread= table->table->no_cache= 0;
+ table->table->no_keyread= 0;
if (ignore)
table->table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
}
diff --git a/sql/table_cache.cc b/sql/table_cache.cc
index 16a47b37417..6d190400217 100644
--- a/sql/table_cache.cc
+++ b/sql/table_cache.cc
@@ -328,6 +328,7 @@ bool tc_release_table(TABLE *table)
{
DBUG_ASSERT(table->in_use);
DBUG_ASSERT(table->file);
+ DBUG_ASSERT(!table->pos_in_locked_tables);
if (table->needs_reopen() || tc_records() > tc_size)
{
diff --git a/storage/tokudb/ha_tokudb.cc b/storage/tokudb/ha_tokudb.cc
index 61c7011252b..0b0cc152578 100644
--- a/storage/tokudb/ha_tokudb.cc
+++ b/storage/tokudb/ha_tokudb.cc
@@ -48,7 +48,7 @@ static inline uint get_ext_key_parts(const KEY *key) {
#endif // defined(TOKU_INCLUDE_EXTENDED_KEYS) && TOKU_INCLUDE_EXTENDED_KEYS
std::unordered_map<std::string, TOKUDB_SHARE*> TOKUDB_SHARE::_open_tables;
-tokudb::thread::mutex_t TOKUDB_SHARE::_open_tables_mutex;
+tokudb::thread::mutex_t* TOKUDB_SHARE::_open_tables_mutex;
static const char* ha_tokudb_exts[] = {
ha_tokudb_ext,
@@ -154,6 +154,7 @@ static void free_key_and_col_info (KEY_AND_COL_INFO* kc_info) {
void TOKUDB_SHARE::static_init() {
assert_always(_open_tables.size() == 0);
+ _open_tables_mutex = new tokudb::thread::mutex_t();
}
void TOKUDB_SHARE::static_destroy() {
for (auto it = _open_tables.cbegin(); it != _open_tables.cend(); it++) {
@@ -164,6 +165,7 @@ void TOKUDB_SHARE::static_destroy() {
}
_open_tables.clear();
assert_always(_open_tables.size() == 0);
+ delete _open_tables_mutex;
}
const char* TOKUDB_SHARE::get_state_string(share_state_t state) {
static const char* state_string[] = {
@@ -218,7 +220,7 @@ TOKUDB_SHARE* TOKUDB_SHARE::get_share(const char* table_name,
THR_LOCK_DATA* data,
bool create_new) {
std::string find_table_name(table_name);
- mutex_t_lock(_open_tables_mutex);
+ mutex_t_lock(*_open_tables_mutex);
auto it = _open_tables.find(find_table_name);
TOKUDB_SHARE *share = nullptr;
if (it != _open_tables.end()) {
@@ -251,7 +253,7 @@ TOKUDB_SHARE* TOKUDB_SHARE::get_share(const char* table_name,
thr_lock_data_init(&(share->_thr_lock), data, NULL);
exit:
- mutex_t_unlock(_open_tables_mutex);
+ mutex_t_unlock(*_open_tables_mutex);
return share;
}
void TOKUDB_SHARE::drop_share(TOKUDB_SHARE* share) {
@@ -262,12 +264,12 @@ void TOKUDB_SHARE::drop_share(TOKUDB_SHARE* share) {
get_state_string(share->_state),
share->_use_count);
- mutex_t_lock(_open_tables_mutex);
+ mutex_t_lock(*_open_tables_mutex);
size_t n = _open_tables.erase(std::string(share->full_table_name()));
assert_always(n == 1);
share->destroy();
delete share;
- mutex_t_unlock(_open_tables_mutex);
+ mutex_t_unlock(*_open_tables_mutex);
}
TOKUDB_SHARE::share_state_t TOKUDB_SHARE::addref() {
TOKUDB_SHARE_TRACE_FOR_FLAGS((TOKUDB_DEBUG_ENTER & TOKUDB_DEBUG_SHARE),
diff --git a/storage/tokudb/ha_tokudb.h b/storage/tokudb/ha_tokudb.h
index 6f592617b76..e322c3de18e 100644
--- a/storage/tokudb/ha_tokudb.h
+++ b/storage/tokudb/ha_tokudb.h
@@ -274,7 +274,7 @@ public:
private:
static std::unordered_map<std::string, TOKUDB_SHARE*> _open_tables;
- static tokudb::thread::mutex_t _open_tables_mutex;
+ static tokudb::thread::mutex_t* _open_tables_mutex;
//*********************************
// Spans open-close-open
diff --git a/storage/tokudb/hatoku_defines.h b/storage/tokudb/hatoku_defines.h
index ab9e0f79ef8..d71ed6e6688 100644
--- a/storage/tokudb/hatoku_defines.h
+++ b/storage/tokudb/hatoku_defines.h
@@ -290,23 +290,23 @@ inline uint tokudb_uint3korr(const uchar *a) {
typedef unsigned int pfs_key_t;
#if defined(SAFE_MUTEX) || defined(HAVE_PSI_MUTEX_INTERFACE)
-#define mutex_t_lock(M) M.lock(__FILE__, __LINE__)
+#define mutex_t_lock(M) (M).lock(__FILE__, __LINE__)
#else // SAFE_MUTEX || HAVE_PSI_MUTEX_INTERFACE
-#define mutex_t_lock(M) M.lock()
+#define mutex_t_lock(M) (M).lock()
#endif // SAFE_MUTEX || HAVE_PSI_MUTEX_INTERFACE
#if defined(SAFE_MUTEX)
-#define mutex_t_unlock(M) M.unlock(__FILE__, __LINE__)
+#define mutex_t_unlock(M) (M).unlock(__FILE__, __LINE__)
#else // SAFE_MUTEX
-#define mutex_t_unlock(M) M.unlock()
+#define mutex_t_unlock(M) (M).unlock()
#endif // SAFE_MUTEX
#if defined(HAVE_PSI_RWLOCK_INTERFACE)
-#define rwlock_t_lock_read(M) M.lock_read(__FILE__, __LINE__)
-#define rwlock_t_lock_write(M) M.lock_write(__FILE__, __LINE__)
+#define rwlock_t_lock_read(M) (M).lock_read(__FILE__, __LINE__)
+#define rwlock_t_lock_write(M) (M).lock_write(__FILE__, __LINE__)
#else // HAVE_PSI_RWLOCK_INTERFACE
-#define rwlock_t_lock_read(M) M.lock_read()
-#define rwlock_t_lock_write(M) M.lock_write()
+#define rwlock_t_lock_read(M) (M).lock_read()
+#define rwlock_t_lock_write(M) (M).lock_write()
#endif // HAVE_PSI_RWLOCK_INTERFACE
#endif // _HATOKU_DEFINES_H