diff options
author | Alexey Kopytov <Alexey.Kopytov@Sun.com> | 2010-04-30 00:33:06 +0400 |
---|---|---|
committer | Alexey Kopytov <Alexey.Kopytov@Sun.com> | 2010-04-30 00:33:06 +0400 |
commit | 85ed11c60d569a54a32cce1588594ee18c43e40a (patch) | |
tree | a2457e79f43173dfb97236266c5bb7a47fdbf65f | |
parent | 21b8741b57204f784633c6337f9abacaa59ff3e2 (diff) | |
parent | 2303a8c6e4dd94eb6b682c61e0ff333c21b188b2 (diff) | |
download | mariadb-git-85ed11c60d569a54a32cce1588594ee18c43e40a.tar.gz |
Manual merge of mysql-5.1-bugteam to mysql-trunk-merge.
Conflicts:
Text conflict in configure.in
Text conflict in dbug/dbug.c
Text conflict in mysql-test/r/ps.result
Text conflict in mysql-test/t/ps.test
Text conflict in sql/CMakeLists.txt
Text conflict in sql/ha_ndbcluster.cc
Text conflict in sql/mysqld.cc
Text conflict in sql/sql_plugin.cc
Text conflict in sql/sql_table.cc
40 files changed, 489 insertions, 74 deletions
diff --git a/configure.in b/configure.in index ec74b15efb0..c2770536d1f 100644 --- a/configure.in +++ b/configure.in @@ -19,15 +19,16 @@ dnl Process this file with autoconf to produce a configure script. # Minimum Autoconf version required. AC_PREREQ(2.59) -# Various people throughout the community may parse configure.in to -# get the MySQL version from the source branch. If the formatting -# of this line is going to be changed, please announce the change to -# internals@lists.mysql.com in advance of pushing the change. -# -# Remember to also update version.c in ndb. -# When changing major version number please also check switch statement -# in client/mysqlbinlog.cc:check_master_version(). +dnl Various people throughout the community may parse configure.in to +dnl get the MySQL version from the source branch. If the formatting +dnl of this line is going to be changed, please announce the change to +dnl internals@lists.mysql.com in advance of pushing the change. +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.5-m3], [], [mysql]) + AC_CONFIG_SRCDIR([sql/mysqld.cc]) AC_CANONICAL_SYSTEM # USTAR format gives us the possibility to store longer path names in diff --git a/dbug/dbug.c b/dbug/dbug.c index 0355d553cff..15d31e0c370 100644 --- a/dbug/dbug.c +++ b/dbug/dbug.c @@ -507,7 +507,13 @@ int DbugParse(CODE_STATE *cs, const char *control) rel= control[0] == '+' || control[0] == '-'; if ((!rel || (!stack->out_file && !stack->next))) { - FreeState(cs, stack, 0); + /* + We need to free what's already in init_settings, because unlike + the thread related stack frames there's a chance that something + is in these variables already. + */ + if (stack == &init_settings) + FreeState(cs, stack, 0); stack->flags= 0; stack->delay= 0; stack->maxdepth= 0; @@ -1709,7 +1715,10 @@ void _db_end_() while ((discard= cs->stack)) { if (discard == &init_settings) + { + FreeState (cs, discard, 0); break; + } cs->stack= discard->next; FreeState(cs, discard, 1); } diff --git a/include/mysql/plugin.h b/include/mysql/plugin.h index 567734c1d5c..19cf0ed050d 100644 --- a/include/mysql/plugin.h +++ b/include/mysql/plugin.h @@ -593,30 +593,37 @@ void mysql_query_cache_invalidate4(MYSQL_THD thd, const char *key, unsigned int key_length, int using_trx); -#ifdef __cplusplus -} -#endif -#ifdef __cplusplus /** Provide a handler data getter to simplify coding */ -inline -void * -thd_get_ha_data(const MYSQL_THD thd, const struct handlerton *hton) -{ - return *thd_ha_data(thd, hton); -} +void *thd_get_ha_data(const MYSQL_THD thd, const struct handlerton *hton); + /** Provide a handler data setter to simplify coding + + @details + Set ha_data pointer (storage engine per-connection information). + + To avoid unclean deactivation (uninstall) of storage engine plugin + in the middle of transaction, additional storage engine plugin + lock is acquired. + + If ha_data is not null and storage engine plugin was not locked + by thd_set_ha_data() in this connection before, storage engine + plugin gets locked. + + If ha_data is null and storage engine plugin was locked by + thd_set_ha_data() in this connection before, storage engine + plugin lock gets released. + + If handlerton::close_connection() didn't reset ha_data, server does + it immediately after calling handlerton::close_connection(). */ -inline -void -thd_set_ha_data(const MYSQL_THD thd, const struct handlerton *hton, - const void *ha_data) -{ - *thd_ha_data(thd, hton)= (void*) ha_data; +void thd_set_ha_data(MYSQL_THD thd, const struct handlerton *hton, + const void *ha_data); +#ifdef __cplusplus } #endif diff --git a/include/mysql/plugin.h.pp b/include/mysql/plugin.h.pp index 5dad31bd008..3a1b03742da 100644 --- a/include/mysql/plugin.h.pp +++ b/include/mysql/plugin.h.pp @@ -165,3 +165,6 @@ void thd_get_xid(const void* thd, MYSQL_XID *xid); void mysql_query_cache_invalidate4(void* thd, const char *key, unsigned int key_length, int using_trx); +void *thd_get_ha_data(const void* thd, const struct handlerton *hton); +void thd_set_ha_data(void* thd, const struct handlerton *hton, + const void *ha_data); diff --git a/mysql-test/r/bug46261.result b/mysql-test/r/bug46261.result new file mode 100644 index 00000000000..f54b698e08f --- /dev/null +++ b/mysql-test/r/bug46261.result @@ -0,0 +1,8 @@ +# +# Bug#46261 Plugins can be installed with --skip-grant-tables +# +INSTALL PLUGIN example SONAME 'ha_example.so'; +ERROR HY000: The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement +UNINSTALL PLUGIN example; +ERROR HY000: The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement +End of 5.1 tests diff --git a/mysql-test/r/error_simulation.result b/mysql-test/r/error_simulation.result index 6153dad2534..27e51a33112 100644 --- a/mysql-test/r/error_simulation.result +++ b/mysql-test/r/error_simulation.result @@ -18,3 +18,26 @@ SELECT MAX(a) FROM t1 GROUP BY a,b; ERROR 23000: Can't write; duplicate key in table 'tmp_table' set tmp_table_size=default; DROP TABLE t1; +# +# Bug #50946: fast index creation still seems to copy the table +# +CREATE TABLE t1 (a INT(100) NOT NULL); +INSERT INTO t1 VALUES (1), (0), (2); +SET SESSION debug='+d,alter_table_only_index_change'; +ALTER TABLE t1 ADD INDEX a(a); +SET SESSION debug=DEFAULT; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(100) NOT NULL, + KEY `a` (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT * FROM t1; +a +0 +1 +2 +DROP TABLE t1; +# +# End of 5.1 tests +# diff --git a/mysql-test/r/innodb_mysql.result b/mysql-test/r/innodb_mysql.result index 0a3df1f99b5..43719b6dfd3 100644 --- a/mysql-test/r/innodb_mysql.result +++ b/mysql-test/r/innodb_mysql.result @@ -2355,6 +2355,34 @@ Index_type BTREE Comment Index_comment DROP TABLE t1; +# +# Bug #47453: InnoDB incorrectly changes TIMESTAMP columns when +# JOINed during an UPDATE +# +CREATE TABLE t1 (d INT) ENGINE=InnoDB; +CREATE TABLE t2 (a INT, b INT, +c TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP +ON UPDATE CURRENT_TIMESTAMP) ENGINE=InnoDB; +set up our data elements +INSERT INTO t1 (d) VALUES (1); +INSERT INTO t2 (a,b) VALUES (1,1); +SELECT SECOND(c) INTO @bug47453 FROM t2; +SELECT SECOND(c)-@bug47453 FROM t1 JOIN t2 ON d=a; +SECOND(c)-@bug47453 +0 +UPDATE t1 JOIN t2 ON d=a SET b=1 WHERE a=1; +SELECT SECOND(c)-@bug47453 FROM t1 JOIN t2 ON d=a; +SECOND(c)-@bug47453 +0 +SELECT SLEEP(1); +SLEEP(1) +0 +UPDATE t1 JOIN t2 ON d=a SET b=1 WHERE a=1; +#should be 0 +SELECT SECOND(c)-@bug47453 FROM t1 JOIN t2 ON d=a; +SECOND(c)-@bug47453 +0 +DROP TABLE t1, t2; End of 5.1 tests # # Test for bug #39932 "create table fails if column for FK is in different diff --git a/mysql-test/r/join.result b/mysql-test/r/join.result index f8a0917ffe7..9f87ea082db 100644 --- a/mysql-test/r/join.result +++ b/mysql-test/r/join.result @@ -1146,6 +1146,16 @@ ROW(t1.b, 1111.11) <=> ROW('',''); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables DROP TABLE t1; +# +# Bug #50335: Assertion `!(order->used & map)' in eq_ref_table +# +CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, PRIMARY KEY (a,b)); +INSERT INTO t1 VALUES (0,0), (1,1); +SELECT * FROM t1 STRAIGHT_JOIN t1 t2 ON t1.a=t2.a AND t1.a=t2.b ORDER BY t2.a, t1.a; +a b a b +0 0 0 0 +1 1 1 1 +DROP TABLE t1; End of 5.0 tests. CREATE TABLE t1 (f1 int); CREATE TABLE t2 (f1 int); @@ -1174,14 +1184,4 @@ NULL NULL 1 DROP TABLE t1, t2, mm1; -# -# Bug #50335: Assertion `!(order->used & map)' in eq_ref_table -# -CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, PRIMARY KEY (a,b)); -INSERT INTO t1 VALUES (0,0), (1,1); -SELECT * FROM t1 STRAIGHT_JOIN t1 t2 ON t1.a=t2.a AND t1.a=t2.b ORDER BY t2.a, t1.a; -a b a b -0 0 0 0 -1 1 1 1 -DROP TABLE t1; End of 5.1 tests diff --git a/mysql-test/r/loaddata.result b/mysql-test/r/loaddata.result index c07bf8ee4dd..9969147a93e 100755..100644 --- a/mysql-test/r/loaddata.result +++ b/mysql-test/r/loaddata.result @@ -204,10 +204,10 @@ a b c 15 NULL Fifteen show variables like "secure_file_pri%"; Variable_name Value -secure_file_priv MYSQLTEST_VARDIR/ +secure_file_priv MYSQLTEST_VARDIR select @@secure_file_priv; @@secure_file_priv -MYSQLTEST_VARDIR/ +MYSQLTEST_VARDIR set @@secure_file_priv= 0; ERROR HY000: Variable 'secure_file_priv' is a read only variable truncate table t1; diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result index 0b2002b1350..5ac8ec78f2d 100644 --- a/mysql-test/r/ps.result +++ b/mysql-test/r/ps.result @@ -2992,6 +2992,19 @@ select @plaintext; bcd deallocate prepare encode; deallocate prepare decode; +# +# Bug#52124 memory leaks like a sieve in datetime, timestamp, time, date fields + warnings +# +CREATE TABLE t1 (a DATETIME NOT NULL, b TINYINT); +INSERT INTO t1 VALUES (0, 0),(0, 0); +PREPARE stmt FROM "SELECT 1 FROM t1 WHERE +ROW(a, b) >= ROW('1', (SELECT 1 FROM t1 WHERE a > 1234))"; +EXECUTE stmt; +1 +EXECUTE stmt; +1 +DEALLOCATE PREPARE stmt; +DROP TABLE t1; End of 5.1 tests. diff --git a/mysql-test/r/row.result b/mysql-test/r/row.result index 2eaec67c547..2962123fcb2 100644 --- a/mysql-test/r/row.result +++ b/mysql-test/r/row.result @@ -457,3 +457,12 @@ abc 1 abc 1 select host,user from mysql.user where (host,user) = ('localhost','test'); host user drop table t1,t2; +# +# Bug#52124 memory leaks like a sieve in datetime, timestamp, time, date fields + warnings +# +CREATE TABLE t1 (a DATETIME NOT NULL, b TINYINT); +INSERT INTO t1 VALUES (0, 0),(0, 0); +SELECT 1 FROM t1 WHERE ROW(a, b) >= +ROW('1', (SELECT 1 FROM t1 WHERE a > 1234)); +1 +DROP TABLE t1; diff --git a/mysql-test/r/variables_debug.result b/mysql-test/r/variables_debug.result index 9cd133dddb1..85eaf34b033 100644 --- a/mysql-test/r/variables_debug.result +++ b/mysql-test/r/variables_debug.result @@ -10,3 +10,16 @@ set debug= '-P'; select @@debug; @@debug T +# +# Bug #52629: memory leak from sys_var_thd_dbug in +# binlog.binlog_write_error +# +SET GLOBAL debug='d,injecting_fault_writing'; +SELECT @@global.debug; +@@global.debug +d,injecting_fault_writing +SET GLOBAL debug=''; +SELECT @@global.debug; +@@global.debug + +End of 5.1 tests diff --git a/mysql-test/suite/rpl/r/rpl_do_grant.result b/mysql-test/suite/rpl/r/rpl_do_grant.result index 9eecc1bab3f..1cea2cfa9ad 100644 --- a/mysql-test/suite/rpl/r/rpl_do_grant.result +++ b/mysql-test/suite/rpl/r/rpl_do_grant.result @@ -246,4 +246,18 @@ GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION DROP TABLE t1; DROP PROCEDURE p1; DROP USER 'user49119'@'localhost'; +stop slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +reset master; +reset slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +start slave; +grant all on *.* to foo@"1.2.3.4"; +revoke all privileges, grant option from "foo"; +ERROR HY000: Can't revoke all privileges for one or more of the requested users +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # use `test`; grant all on *.* to foo@"1.2.3.4" +master-bin.000001 # Query # # use `test`; revoke all privileges, grant option from "foo" +DROP USER foo@"1.2.3.4"; "End of test" diff --git a/mysql-test/suite/rpl/t/rpl_do_grant.test b/mysql-test/suite/rpl/t/rpl_do_grant.test index e3d7784429e..37358077145 100644 --- a/mysql-test/suite/rpl/t/rpl_do_grant.test +++ b/mysql-test/suite/rpl/t/rpl_do_grant.test @@ -318,4 +318,33 @@ DROP USER 'user49119'@'localhost'; -- sync_slave_with_master +# +# Bug #51987 revoke privileges logs wrong error code +# + +-- connection master +-- source include/master-slave-reset.inc +-- connection master + +grant all on *.* to foo@"1.2.3.4"; +-- error ER_REVOKE_GRANTS +revoke all privileges, grant option from "foo"; + +## assertion: revoke is logged +-- source include/show_binlog_events.inc + +-- sync_slave_with_master + +## assertion: slave replicates revoke and does not fail because master +## logged revoke with correct expected error code +-- let $err= query_get_value(SHOW SLAVE STATUS, Last_SQL_Errno, 1) + if ($err) +{ + -- die UNEXPECTED ERROR AT SLAVE: $err +} + +-- connection master +DROP USER foo@"1.2.3.4"; +-- sync_slave_with_master + --echo "End of test" diff --git a/mysql-test/suite/sys_vars/r/secure_file_priv.result b/mysql-test/suite/sys_vars/r/secure_file_priv.result new file mode 100644 index 00000000000..eeeb9a58c0f --- /dev/null +++ b/mysql-test/suite/sys_vars/r/secure_file_priv.result @@ -0,0 +1,22 @@ +# +# Bug50373 --secure-file-priv="" +# +CREATE TABLE t1 (c1 VARCHAR(50)); +INSERT INTO t1 VALUES ("one"),("two"),("three"),("four"),("five"); +SHOW VARIABLES LIKE 'secure_file_priv'; +Variable_name Value +secure_file_priv +c1 +one +two +three +four +five +loaded_file +one +two +three +four +five + +DROP TABLE t1; diff --git a/mysql-test/suite/sys_vars/t/secure_file_priv-master.opt b/mysql-test/suite/sys_vars/t/secure_file_priv-master.opt new file mode 100644 index 00000000000..b41d9b04b96 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/secure_file_priv-master.opt @@ -0,0 +1 @@ +--secure_file_priv='' diff --git a/mysql-test/suite/sys_vars/t/secure_file_priv.test b/mysql-test/suite/sys_vars/t/secure_file_priv.test new file mode 100644 index 00000000000..7a534e7d6e4 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/secure_file_priv.test @@ -0,0 +1,21 @@ +--echo # +--echo # Bug50373 --secure-file-priv="" +--echo # +CREATE TABLE t1 (c1 VARCHAR(50)); +INSERT INTO t1 VALUES ("one"),("two"),("three"),("four"),("five"); +SHOW VARIABLES LIKE 'secure_file_priv'; +--disable_query_log +# Atempt to create a file where we normally aren't allowed to create one. +# Doing this in a portable manner is difficult but we should be able to +# count on the depth of the directory hierarchy used. Three steps up from +# the datadir is the 'mysql_test' directory. +--let $PROTECTED_FILE=`SELECT concat(@@datadir,'/../../../bug50373.txt')`; +--eval SELECT * FROM t1 INTO OUTFILE '$PROTECTED_FILE'; +DELETE FROM t1; +--eval LOAD DATA INFILE '$PROTECTED_FILE' INTO TABLE t1; +SELECT * FROM t1; +--eval SELECT load_file('$PROTECTED_FILE') AS loaded_file; +--enable_query_log +remove_file $PROTECTED_FILE; +DROP TABLE t1; + diff --git a/mysql-test/t/bug46261-master.opt b/mysql-test/t/bug46261-master.opt new file mode 100644 index 00000000000..6be4269e809 --- /dev/null +++ b/mysql-test/t/bug46261-master.opt @@ -0,0 +1 @@ +--skip-grant-tables $EXAMPLE_PLUGIN_OPT diff --git a/mysql-test/t/bug46261.test b/mysql-test/t/bug46261.test new file mode 100644 index 00000000000..67bdc995850 --- /dev/null +++ b/mysql-test/t/bug46261.test @@ -0,0 +1,16 @@ +--source include/not_embedded.inc +--source include/have_example_plugin.inc + +--echo # +--echo # Bug#46261 Plugins can be installed with --skip-grant-tables +--echo # + +--replace_regex /\.dll/.so/ +--error ER_OPTION_PREVENTS_STATEMENT +eval INSTALL PLUGIN example SONAME $HA_EXAMPLE_SO; + +--replace_regex /\.dll/.so/ +--error ER_OPTION_PREVENTS_STATEMENT +eval UNINSTALL PLUGIN example; + +--echo End of 5.1 tests diff --git a/mysql-test/t/error_simulation.test b/mysql-test/t/error_simulation.test index f730c95208e..7cd16a6bc5a 100644 --- a/mysql-test/t/error_simulation.test +++ b/mysql-test/t/error_simulation.test @@ -33,3 +33,19 @@ set tmp_table_size=default; DROP TABLE t1; +--echo # +--echo # Bug #50946: fast index creation still seems to copy the table +--echo # +CREATE TABLE t1 (a INT(100) NOT NULL); +INSERT INTO t1 VALUES (1), (0), (2); +SET SESSION debug='+d,alter_table_only_index_change'; +ALTER TABLE t1 ADD INDEX a(a); +SET SESSION debug=DEFAULT; +SHOW CREATE TABLE t1; +SELECT * FROM t1; +DROP TABLE t1; + + +--echo # +--echo # End of 5.1 tests +--echo # diff --git a/mysql-test/t/innodb_mysql.test b/mysql-test/t/innodb_mysql.test index 63eff93ba7f..7ecee4d2924 100644 --- a/mysql-test/t/innodb_mysql.test +++ b/mysql-test/t/innodb_mysql.test @@ -589,6 +589,36 @@ ALTER TABLE t1 DROP INDEX k, ADD UNIQUE INDEX k (a,b); DROP TABLE t1; + +--echo # +--echo # Bug #47453: InnoDB incorrectly changes TIMESTAMP columns when +--echo # JOINed during an UPDATE +--echo # + +CREATE TABLE t1 (d INT) ENGINE=InnoDB; +CREATE TABLE t2 (a INT, b INT, + c TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP + ON UPDATE CURRENT_TIMESTAMP) ENGINE=InnoDB; + +--echo set up our data elements +INSERT INTO t1 (d) VALUES (1); +INSERT INTO t2 (a,b) VALUES (1,1); +SELECT SECOND(c) INTO @bug47453 FROM t2; + +SELECT SECOND(c)-@bug47453 FROM t1 JOIN t2 ON d=a; +UPDATE t1 JOIN t2 ON d=a SET b=1 WHERE a=1; +SELECT SECOND(c)-@bug47453 FROM t1 JOIN t2 ON d=a; + +SELECT SLEEP(1); + +UPDATE t1 JOIN t2 ON d=a SET b=1 WHERE a=1; + +--echo #should be 0 +SELECT SECOND(c)-@bug47453 FROM t1 JOIN t2 ON d=a; + +DROP TABLE t1, t2; + + --echo End of 5.1 tests diff --git a/mysql-test/t/join.test b/mysql-test/t/join.test index 09464c4d926..43b373c9703 100644 --- a/mysql-test/t/join.test +++ b/mysql-test/t/join.test @@ -807,6 +807,17 @@ WHERE ROW(t1.a, 1111.11) = ROW(1111.11, 1111.11) AND ROW(t1.b, 1111.11) <=> ROW('',''); DROP TABLE t1; +--echo # +--echo # Bug #50335: Assertion `!(order->used & map)' in eq_ref_table +--echo # + +CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, PRIMARY KEY (a,b)); +INSERT INTO t1 VALUES (0,0), (1,1); + +SELECT * FROM t1 STRAIGHT_JOIN t1 t2 ON t1.a=t2.a AND t1.a=t2.b ORDER BY t2.a, t1.a; + +DROP TABLE t1; + --echo End of 5.0 tests. @@ -840,15 +851,4 @@ ENGINE=MERGE UNION=(t1,t2); SELECT t1.a FROM mm1,t1; DROP TABLE t1, t2, mm1; ---echo # ---echo # Bug #50335: Assertion `!(order->used & map)' in eq_ref_table ---echo # - -CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, PRIMARY KEY (a,b)); -INSERT INTO t1 VALUES (0,0), (1,1); - -SELECT * FROM t1 STRAIGHT_JOIN t1 t2 ON t1.a=t2.a AND t1.a=t2.b ORDER BY t2.a, t1.a; - -DROP TABLE t1; - --echo End of 5.1 tests diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test index dcea4d9828b..f7ce70c1d3a 100644 --- a/mysql-test/t/ps.test +++ b/mysql-test/t/ps.test @@ -3065,6 +3065,20 @@ select @plaintext; deallocate prepare encode; deallocate prepare decode; +--echo # +--echo # Bug#52124 memory leaks like a sieve in datetime, timestamp, time, date fields + warnings +--echo # +CREATE TABLE t1 (a DATETIME NOT NULL, b TINYINT); +INSERT INTO t1 VALUES (0, 0),(0, 0); +PREPARE stmt FROM "SELECT 1 FROM t1 WHERE +ROW(a, b) >= ROW('1', (SELECT 1 FROM t1 WHERE a > 1234))"; +--disable_warnings +EXECUTE stmt; +EXECUTE stmt; +--enable_warnings +DEALLOCATE PREPARE stmt; +DROP TABLE t1; + ########################################################################### --echo diff --git a/mysql-test/t/row.test b/mysql-test/t/row.test index fcc4259168b..cec44078279 100644 --- a/mysql-test/t/row.test +++ b/mysql-test/t/row.test @@ -255,3 +255,14 @@ select * from t1,t2 where (a,b) = (c,d); select host,user from mysql.user where (host,user) = ('localhost','test'); drop table t1,t2; + +--echo # +--echo # Bug#52124 memory leaks like a sieve in datetime, timestamp, time, date fields + warnings +--echo # +CREATE TABLE t1 (a DATETIME NOT NULL, b TINYINT); +INSERT INTO t1 VALUES (0, 0),(0, 0); +--disable_warnings +SELECT 1 FROM t1 WHERE ROW(a, b) >= +ROW('1', (SELECT 1 FROM t1 WHERE a > 1234)); +--enable_warnings +DROP TABLE t1; diff --git a/mysql-test/t/variables_debug.test b/mysql-test/t/variables_debug.test index 7dcaf246803..8f2bde7ae42 100644 --- a/mysql-test/t/variables_debug.test +++ b/mysql-test/t/variables_debug.test @@ -10,3 +10,16 @@ set debug= '+P'; select @@debug; set debug= '-P'; select @@debug; + +--echo # +--echo # Bug #52629: memory leak from sys_var_thd_dbug in +--echo # binlog.binlog_write_error +--echo # + +SET GLOBAL debug='d,injecting_fault_writing'; +SELECT @@global.debug; +SET GLOBAL debug=''; +SELECT @@global.debug; + + +--echo End of 5.1 tests diff --git a/scripts/mysqlhotcopy.sh b/scripts/mysqlhotcopy.sh index 90f759739d0..aea7a657c9e 100644 --- a/scripts/mysqlhotcopy.sh +++ b/scripts/mysqlhotcopy.sh @@ -270,6 +270,14 @@ foreach my $rdb ( @db_desc ) { my $db = $rdb->{src}; my @dbh_tables = get_list_of_tables( $db ); + ## filter out certain system non-lockable tables. + ## keep in sync with mysqldump. + if ($db =~ m/^mysql$/i) + { + @dbh_tables = grep + { !/^(apply_status|schema|general_log|slow_log)$/ } @dbh_tables + } + ## generate regex for tables/files my $t_regex; my $negated; diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index 396c8b1fd27..f86ad9b4e47 100755 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -47,7 +47,7 @@ SET (SQL_SOURCE hostname.cc init.cc item.cc item_buff.cc item_cmpfunc.cc item_create.cc item_func.cc item_geofunc.cc item_row.cc item_strfunc.cc item_subselect.cc item_sum.cc item_timefunc.cc - key.cc log.cc lock.cc message.rc + key.cc log.cc lock.cc log_event.cc rpl_record.cc rpl_reporting.cc log_event_old.cc rpl_record_old.cc message.h mf_iocache.cc my_decimal.cc ../sql-common/my_time.c @@ -92,7 +92,7 @@ TARGET_LINK_LIBRARIES(sql ${MYSQLD_STATIC_PLUGIN_LIBS} IF(WIN32) - SET(MYSQLD_SOURCE main.cc nt_servc.cc nt_servc.h) + SET(MYSQLD_SOURCE main.cc nt_servc.cc nt_servc.h message.rc) ELSE() SET(MYSQLD_SOURCE main.cc ${DTRACE_PROBES_ALL}) ENDIF() diff --git a/sql/field.cc b/sql/field.cc index bd091f7eb57..fcabaeaa74d 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -8464,14 +8464,20 @@ bool Field_num::eq_def(Field *field) } +/** + Check whether two numeric fields can be considered 'equal' for table + alteration purposes. Fields are equal if they are of the same type + and retain the same pack length. +*/ + uint Field_num::is_equal(Create_field *new_field) { return ((new_field->sql_type == real_type()) && - ((new_field->flags & UNSIGNED_FLAG) == (uint) (flags & - UNSIGNED_FLAG)) && + ((new_field->flags & UNSIGNED_FLAG) == + (uint) (flags & UNSIGNED_FLAG)) && ((new_field->flags & AUTO_INCREMENT_FLAG) == (uint) (flags & AUTO_INCREMENT_FLAG)) && - (new_field->length <= max_display_length())); + (new_field->pack_length == pack_length())); } diff --git a/sql/handler.cc b/sql/handler.cc index ee02441e7ff..d641133c57a 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -174,7 +174,7 @@ redo: } -plugin_ref ha_lock_engine(THD *thd, handlerton *hton) +plugin_ref ha_lock_engine(THD *thd, const handlerton *hton) { if (hton) { @@ -642,9 +642,13 @@ static my_bool closecon_handlerton(THD *thd, plugin_ref plugin, there's no need to rollback here as all transactions must be rolled back already */ - if (hton->state == SHOW_OPTION_YES && hton->close_connection && - thd_get_ha_data(thd, hton)) - hton->close_connection(hton, thd); + if (hton->state == SHOW_OPTION_YES && thd_get_ha_data(thd, hton)) + { + if (hton->close_connection) + hton->close_connection(hton, thd); + /* make sure ha_data is reset and ha_data_lock is released */ + thd_set_ha_data(thd, hton, NULL); + } return FALSE; } diff --git a/sql/handler.h b/sql/handler.h index 9f21cb0f25d..4464f4f3920 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -2066,7 +2066,7 @@ extern ulong total_ha, total_ha_2pc; /* lookups */ handlerton *ha_default_handlerton(THD *thd); plugin_ref ha_resolve_by_name(THD *thd, const LEX_STRING *name); -plugin_ref ha_lock_engine(THD *thd, handlerton *hton); +plugin_ref ha_lock_engine(THD *thd, const handlerton *hton); handlerton *ha_resolve_by_legacy_type(THD *thd, enum legacy_db_type db_type); handler *get_new_handler(TABLE_SHARE *share, MEM_ROOT *alloc, handlerton *db_type); diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index afd25688e79..a0b3f2c29a1 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -60,9 +60,9 @@ public: /* Allow owner function to use string buffers. */ String value1, value2; - Arg_comparator(): thd(0), a_cache(0), b_cache(0), set_null(TRUE), + Arg_comparator(): comparators(0), thd(0), a_cache(0), b_cache(0), set_null(TRUE), get_value_a_func(0), get_value_b_func(0) {}; - Arg_comparator(Item **a1, Item **a2): a(a1), b(a2), thd(0), + Arg_comparator(Item **a1, Item **a2): a(a1), b(a2), comparators(0), thd(0), a_cache(0), b_cache(0), set_null(TRUE), get_value_a_func(0), get_value_b_func(0) {}; @@ -118,6 +118,11 @@ public: return (owner->type() == Item::FUNC_ITEM && ((Item_func*)owner)->functype() == Item_func::EQUAL_FUNC); } + void cleanup() + { + delete [] comparators; + comparators= 0; + } friend class Item_func; }; @@ -371,6 +376,11 @@ public: CHARSET_INFO *compare_collation() { return cmp.cmp_collation.collation; } uint decimal_precision() const { return 1; } void top_level_item() { abort_on_null= TRUE; } + void cleanup() + { + Item_int_func::cleanup(); + cmp.cleanup(); + } friend class Arg_comparator; }; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index e209c698f9a..2c90aa8fbf5 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -7771,10 +7771,25 @@ static int fix_paths(void) */ if (opt_secure_file_priv) { - convert_dirname(buff, opt_secure_file_priv, NullS); - x_free(opt_secure_file_priv); - opt_secure_file_priv= my_strdup(buff, MYF(MY_FAE)); + if (*opt_secure_file_priv == 0) + { + opt_secure_file_priv= 0; + } + else + { + convert_dirname(buff, opt_secure_file_priv, NullS); + char *secure_file_real_path= (char *)my_malloc(FN_REFLEN, MYF(MY_FAE)); + if (secure_file_real_path == 0 || + my_realpath(secure_file_real_path, buff, 0)) + { + sql_print_warning("Failed to normalize the argument for --secure-file-priv."); + return 1; + } + my_free(opt_secure_file_priv, MYF(0)); + opt_secure_file_priv= secure_file_real_path; + } } + return 0; } diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index f8be3ff6d4a..5a7fb7f154a 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -6255,21 +6255,21 @@ bool mysql_revoke_all(THD *thd, List <LEX_USER> &list) mysql_mutex_unlock(&acl_cache->lock); - int binlog_error= + if (result) + my_message(ER_REVOKE_GRANTS, ER(ER_REVOKE_GRANTS), MYF(0)); + + result= result | write_bin_log(thd, FALSE, thd->query(), thd->query_length()); mysql_rwlock_unlock(&LOCK_grant); close_thread_tables(thd); - /* error for writing binary log has already been reported */ - if (result && !binlog_error) - my_message(ER_REVOKE_GRANTS, ER(ER_REVOKE_GRANTS), MYF(0)); /* Restore the state of binlog format */ DBUG_ASSERT(!thd->is_current_stmt_binlog_format_row()); if (save_binlog_row_based) thd->set_current_stmt_binlog_format_row(); - DBUG_RETURN(result || binlog_error); + DBUG_RETURN(result); } diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 0010ce088d5..0f0ce605b54 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -305,6 +305,37 @@ void **thd_ha_data(const THD *thd, const struct handlerton *hton) return (void **) &thd->ha_data[hton->slot].ha_ptr; } + +/** + Provide a handler data getter to simplify coding +*/ +extern "C" +void *thd_get_ha_data(const THD *thd, const struct handlerton *hton) +{ + return *thd_ha_data(thd, hton); +} + + +/** + Provide a handler data setter to simplify coding + @see thd_set_ha_data() definition in plugin.h +*/ +extern "C" +void thd_set_ha_data(THD *thd, const struct handlerton *hton, + const void *ha_data) +{ + plugin_ref *lock= &thd->ha_data[hton->slot].lock; + if (ha_data && !*lock) + *lock= ha_lock_engine(NULL, (handlerton*) hton); + else if (!ha_data && *lock) + { + plugin_unlock(NULL, *lock); + *lock= NULL; + } + *thd_ha_data(thd, hton)= (void*) ha_data; +} + + extern "C" long long thd_test_options(const THD *thd, long long test_options) { diff --git a/sql/sql_class.h b/sql/sql_class.h index 7a77f9172b7..3a1f83fc9e5 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1470,7 +1470,11 @@ struct Ha_data @sa trans_register_ha() */ Ha_trx_info ha_info[2]; - + /** + NULL: engine is not bound to this thread + non-NULL: engine is bound to this thread, engine shutdown forbidden + */ + plugin_ref lock; Ha_data() :ha_ptr(NULL) {} }; diff --git a/sql/sql_load.cc b/sql/sql_load.cc index 89bb8a9634c..d264c61c36c 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -396,9 +396,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, } else if (opt_secure_file_priv) { - char secure_file_real_path[FN_REFLEN]; - (void) my_realpath(secure_file_real_path, opt_secure_file_priv, 0); - if (strncmp(secure_file_real_path, name, strlen(secure_file_real_path))) + if (strncmp(opt_secure_file_priv, name, strlen(opt_secure_file_priv))) { /* Read only allowed from within dir specified by secure_file_priv */ my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--secure-file-priv"); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 058c6844d15..f83ab95042a 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1160,8 +1160,16 @@ bool dispatch_command(enum enum_server_command command, THD *thd, We have name + wildcard in packet, separated by endzero */ arg_end= strend(packet); + uint arg_length= arg_end - packet; + + /* Check given table name length. */ + if (arg_length >= packet_length || arg_length > NAME_LEN) + { + my_message(ER_UNKNOWN_COM_ERROR, ER(ER_UNKNOWN_COM_ERROR), MYF(0)); + break; + } thd->convert_string(&conv_name, system_charset_info, - packet, (uint) (arg_end - packet), thd->charset()); + packet, arg_length, thd->charset()); table_list.alias= table_list.table_name= conv_name.str; packet= arg_end + 1; diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 31e0cced207..0282053ce7e 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -1755,6 +1755,12 @@ bool mysql_install_plugin(THD *thd, const LEX_STRING *name, const LEX_STRING *dl struct st_plugin_int *tmp; DBUG_ENTER("mysql_install_plugin"); + if (opt_noacl) + { + my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--skip-grant-tables"); + DBUG_RETURN(TRUE); + } + tables.init_one_table("mysql", 5, "plugin", 6, "plugin", TL_WRITE); if (check_table_access(thd, INSERT_ACL, &tables, FALSE, 1, FALSE)) DBUG_RETURN(TRUE); @@ -1829,6 +1835,12 @@ bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name) struct st_plugin_int *plugin; DBUG_ENTER("mysql_uninstall_plugin"); + if (opt_noacl) + { + my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--skip-grant-tables"); + DBUG_RETURN(TRUE); + } + tables.init_one_table("mysql", 5, "plugin", 6, "plugin", TL_WRITE); if (check_table_access(thd, DELETE_ACL, &tables, FALSE, 1, FALSE)) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index c752905d14c..03976e2784a 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -6935,7 +6935,14 @@ view_err: &index_add_buffer, &index_add_count, &candidate_key_count)) goto err; - + + DBUG_EXECUTE_IF("alter_table_only_metadata_change", { + if (need_copy_table_res != ALTER_TABLE_METADATA_ONLY) + goto err; }); + DBUG_EXECUTE_IF("alter_table_only_index_change", { + if (need_copy_table_res != ALTER_TABLE_INDEX_CHANGED) + goto err; }); + if (need_copy_table == ALTER_TABLE_METADATA_ONLY) need_copy_table= need_copy_table_res; } diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 41737b33fb6..a4c7d665b8a 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -1337,6 +1337,16 @@ int multi_update::prepare(List<Item> ¬_used_values, { table->read_set= &table->def_read_set; bitmap_union(table->read_set, &table->tmp_set); + /* + If a timestamp field settable on UPDATE is present then to avoid wrong + update force the table handler to retrieve write-only fields to be able + to compare records and detect data change. + */ + if (table->file->ha_table_flags() & HA_PARTIAL_COLUMN_READ && + table->timestamp_field && + (table->timestamp_field_type == TIMESTAMP_AUTO_SET_ON_UPDATE || + table->timestamp_field_type == TIMESTAMP_AUTO_SET_ON_BOTH)) + bitmap_union(table->read_set, table->write_set); } } |