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
This commit is contained in:
Alexey Kopytov 2010-04-30 00:33:06 +04:00
commit 85ed11c60d
40 changed files with 489 additions and 74 deletions

View File

@ -19,15 +19,16 @@ dnl Process this file with autoconf to produce a configure script.
# Minimum Autoconf version required. # Minimum Autoconf version required.
AC_PREREQ(2.59) AC_PREREQ(2.59)
# Various people throughout the community may parse configure.in to dnl Various people throughout the community may parse configure.in to
# get the MySQL version from the source branch. If the formatting dnl get the MySQL version from the source branch. If the formatting
# of this line is going to be changed, please announce the change to dnl of this line is going to be changed, please announce the change to
# internals@lists.mysql.com in advance of pushing the change. dnl internals@lists.mysql.com in advance of pushing the change.
# dnl
# Remember to also update version.c in ndb. dnl When changing the major version number please also check the switch
# When changing major version number please also check switch statement dnl statement in mysqlbinlog::check_master_version(). You may also need
# in client/mysqlbinlog.cc:check_master_version(). dnl to update version.c in ndb.
AC_INIT([MySQL Server], [5.5.5-m3], [], [mysql]) AC_INIT([MySQL Server], [5.5.5-m3], [], [mysql])
AC_CONFIG_SRCDIR([sql/mysqld.cc]) AC_CONFIG_SRCDIR([sql/mysqld.cc])
AC_CANONICAL_SYSTEM AC_CANONICAL_SYSTEM
# USTAR format gives us the possibility to store longer path names in # USTAR format gives us the possibility to store longer path names in

View File

@ -507,7 +507,13 @@ int DbugParse(CODE_STATE *cs, const char *control)
rel= control[0] == '+' || control[0] == '-'; rel= control[0] == '+' || control[0] == '-';
if ((!rel || (!stack->out_file && !stack->next))) 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->flags= 0;
stack->delay= 0; stack->delay= 0;
stack->maxdepth= 0; stack->maxdepth= 0;
@ -1709,7 +1715,10 @@ void _db_end_()
while ((discard= cs->stack)) while ((discard= cs->stack))
{ {
if (discard == &init_settings) if (discard == &init_settings)
{
FreeState (cs, discard, 0);
break; break;
}
cs->stack= discard->next; cs->stack= discard->next;
FreeState(cs, discard, 1); FreeState(cs, discard, 1);
} }

View File

@ -593,30 +593,37 @@ void mysql_query_cache_invalidate4(MYSQL_THD thd,
const char *key, unsigned int key_length, const char *key, unsigned int key_length,
int using_trx); int using_trx);
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
/** /**
Provide a handler data getter to simplify coding Provide a handler data getter to simplify coding
*/ */
inline void *thd_get_ha_data(const MYSQL_THD thd, const struct handlerton *hton);
void *
thd_get_ha_data(const MYSQL_THD thd, const struct handlerton *hton)
{
return *thd_ha_data(thd, hton);
}
/** /**
Provide a handler data setter to simplify coding 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(MYSQL_THD thd, const struct handlerton *hton,
void const void *ha_data);
thd_set_ha_data(const MYSQL_THD thd, const struct handlerton *hton, #ifdef __cplusplus
const void *ha_data)
{
*thd_ha_data(thd, hton)= (void*) ha_data;
} }
#endif #endif

View File

@ -165,3 +165,6 @@ void thd_get_xid(const void* thd, MYSQL_XID *xid);
void mysql_query_cache_invalidate4(void* thd, void mysql_query_cache_invalidate4(void* thd,
const char *key, unsigned int key_length, const char *key, unsigned int key_length,
int using_trx); 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);

View File

@ -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

View File

@ -18,3 +18,26 @@ SELECT MAX(a) FROM t1 GROUP BY a,b;
ERROR 23000: Can't write; duplicate key in table 'tmp_table' ERROR 23000: Can't write; duplicate key in table 'tmp_table'
set tmp_table_size=default; set tmp_table_size=default;
DROP TABLE t1; 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
#

View File

@ -2355,6 +2355,34 @@ Index_type BTREE
Comment Comment
Index_comment Index_comment
DROP TABLE t1; 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 End of 5.1 tests
# #
# Test for bug #39932 "create table fails if column for FK is in different # Test for bug #39932 "create table fails if column for FK is in different

View File

@ -1146,6 +1146,16 @@ ROW(t1.b, 1111.11) <=> ROW('','');
id select_type table type possible_keys key key_len ref rows Extra 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 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
DROP TABLE t1; 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. End of 5.0 tests.
CREATE TABLE t1 (f1 int); CREATE TABLE t1 (f1 int);
CREATE TABLE t2 (f1 int); CREATE TABLE t2 (f1 int);
@ -1174,14 +1184,4 @@ NULL
NULL NULL
1 1
DROP TABLE t1, t2, mm1; 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 End of 5.1 tests

4
mysql-test/r/loaddata.result Executable file → Normal file
View File

@ -204,10 +204,10 @@ a b c
15 NULL Fifteen 15 NULL Fifteen
show variables like "secure_file_pri%"; show variables like "secure_file_pri%";
Variable_name Value Variable_name Value
secure_file_priv MYSQLTEST_VARDIR/ secure_file_priv MYSQLTEST_VARDIR
select @@secure_file_priv; select @@secure_file_priv;
@@secure_file_priv @@secure_file_priv
MYSQLTEST_VARDIR/ MYSQLTEST_VARDIR
set @@secure_file_priv= 0; set @@secure_file_priv= 0;
ERROR HY000: Variable 'secure_file_priv' is a read only variable ERROR HY000: Variable 'secure_file_priv' is a read only variable
truncate table t1; truncate table t1;

View File

@ -2992,6 +2992,19 @@ select @plaintext;
bcd bcd
deallocate prepare encode; deallocate prepare encode;
deallocate prepare decode; 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. End of 5.1 tests.

View File

@ -457,3 +457,12 @@ abc 1 abc 1
select host,user from mysql.user where (host,user) = ('localhost','test'); select host,user from mysql.user where (host,user) = ('localhost','test');
host user host user
drop table t1,t2; 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;

View File

@ -10,3 +10,16 @@ set debug= '-P';
select @@debug; select @@debug;
@@debug @@debug
T 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

View File

@ -246,4 +246,18 @@ GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION
DROP TABLE t1; DROP TABLE t1;
DROP PROCEDURE p1; DROP PROCEDURE p1;
DROP USER 'user49119'@'localhost'; 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" "End of test"

View File

@ -318,4 +318,33 @@ DROP USER 'user49119'@'localhost';
-- sync_slave_with_master -- 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" --echo "End of test"

View File

@ -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;

View File

@ -0,0 +1 @@
--secure_file_priv=''

View File

@ -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;

View File

@ -0,0 +1 @@
--skip-grant-tables $EXAMPLE_PLUGIN_OPT

View File

@ -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

View File

@ -33,3 +33,19 @@ set tmp_table_size=default;
DROP TABLE t1; 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 #

View File

@ -589,6 +589,36 @@ ALTER TABLE t1 DROP INDEX k, ADD UNIQUE INDEX k (a,b);
DROP TABLE t1; 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 --echo End of 5.1 tests

View File

@ -807,6 +807,17 @@ WHERE ROW(t1.a, 1111.11) = ROW(1111.11, 1111.11) AND
ROW(t1.b, 1111.11) <=> ROW('',''); ROW(t1.b, 1111.11) <=> ROW('','');
DROP TABLE t1; 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. --echo End of 5.0 tests.
@ -840,15 +851,4 @@ ENGINE=MERGE UNION=(t1,t2);
SELECT t1.a FROM mm1,t1; SELECT t1.a FROM mm1,t1;
DROP TABLE t1, t2, mm1; 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 --echo End of 5.1 tests

View File

@ -3065,6 +3065,20 @@ select @plaintext;
deallocate prepare encode; deallocate prepare encode;
deallocate prepare decode; 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 --echo

View File

@ -255,3 +255,14 @@ select * from t1,t2 where (a,b) = (c,d);
select host,user from mysql.user where (host,user) = ('localhost','test'); select host,user from mysql.user where (host,user) = ('localhost','test');
drop table t1,t2; 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;

View File

@ -10,3 +10,16 @@ set debug= '+P';
select @@debug; select @@debug;
set debug= '-P'; set debug= '-P';
select @@debug; 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

View File

@ -270,6 +270,14 @@ foreach my $rdb ( @db_desc ) {
my $db = $rdb->{src}; my $db = $rdb->{src};
my @dbh_tables = get_list_of_tables( $db ); 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 ## generate regex for tables/files
my $t_regex; my $t_regex;
my $negated; my $negated;

View File

@ -47,7 +47,7 @@ SET (SQL_SOURCE
hostname.cc init.cc item.cc item_buff.cc item_cmpfunc.cc 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_create.cc item_func.cc item_geofunc.cc item_row.cc
item_strfunc.cc item_subselect.cc item_sum.cc item_timefunc.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.cc rpl_record.cc rpl_reporting.cc
log_event_old.cc rpl_record_old.cc log_event_old.cc rpl_record_old.cc
message.h mf_iocache.cc my_decimal.cc ../sql-common/my_time.c 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) 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() ELSE()
SET(MYSQLD_SOURCE main.cc ${DTRACE_PROBES_ALL}) SET(MYSQLD_SOURCE main.cc ${DTRACE_PROBES_ALL})
ENDIF() ENDIF()

View File

@ -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) uint Field_num::is_equal(Create_field *new_field)
{ {
return ((new_field->sql_type == real_type()) && return ((new_field->sql_type == real_type()) &&
((new_field->flags & UNSIGNED_FLAG) == (uint) (flags & ((new_field->flags & UNSIGNED_FLAG) ==
UNSIGNED_FLAG)) && (uint) (flags & UNSIGNED_FLAG)) &&
((new_field->flags & AUTO_INCREMENT_FLAG) == ((new_field->flags & AUTO_INCREMENT_FLAG) ==
(uint) (flags & AUTO_INCREMENT_FLAG)) && (uint) (flags & AUTO_INCREMENT_FLAG)) &&
(new_field->length <= max_display_length())); (new_field->pack_length == pack_length()));
} }

View File

@ -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) 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 there's no need to rollback here as all transactions must
be rolled back already be rolled back already
*/ */
if (hton->state == SHOW_OPTION_YES && hton->close_connection && if (hton->state == SHOW_OPTION_YES && thd_get_ha_data(thd, hton))
thd_get_ha_data(thd, hton)) {
hton->close_connection(hton, thd); 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; return FALSE;
} }

View File

@ -2066,7 +2066,7 @@ extern ulong total_ha, total_ha_2pc;
/* lookups */ /* lookups */
handlerton *ha_default_handlerton(THD *thd); handlerton *ha_default_handlerton(THD *thd);
plugin_ref ha_resolve_by_name(THD *thd, const LEX_STRING *name); 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); handlerton *ha_resolve_by_legacy_type(THD *thd, enum legacy_db_type db_type);
handler *get_new_handler(TABLE_SHARE *share, MEM_ROOT *alloc, handler *get_new_handler(TABLE_SHARE *share, MEM_ROOT *alloc,
handlerton *db_type); handlerton *db_type);

View File

@ -60,9 +60,9 @@ public:
/* Allow owner function to use string buffers. */ /* Allow owner function to use string buffers. */
String value1, value2; 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) {}; 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), a_cache(0), b_cache(0), set_null(TRUE),
get_value_a_func(0), get_value_b_func(0) {}; get_value_a_func(0), get_value_b_func(0) {};
@ -118,6 +118,11 @@ public:
return (owner->type() == Item::FUNC_ITEM && return (owner->type() == Item::FUNC_ITEM &&
((Item_func*)owner)->functype() == Item_func::EQUAL_FUNC); ((Item_func*)owner)->functype() == Item_func::EQUAL_FUNC);
} }
void cleanup()
{
delete [] comparators;
comparators= 0;
}
friend class Item_func; friend class Item_func;
}; };
@ -371,6 +376,11 @@ public:
CHARSET_INFO *compare_collation() { return cmp.cmp_collation.collation; } CHARSET_INFO *compare_collation() { return cmp.cmp_collation.collation; }
uint decimal_precision() const { return 1; } uint decimal_precision() const { return 1; }
void top_level_item() { abort_on_null= TRUE; } void top_level_item() { abort_on_null= TRUE; }
void cleanup()
{
Item_int_func::cleanup();
cmp.cleanup();
}
friend class Arg_comparator; friend class Arg_comparator;
}; };

View File

@ -7771,10 +7771,25 @@ static int fix_paths(void)
*/ */
if (opt_secure_file_priv) if (opt_secure_file_priv)
{ {
convert_dirname(buff, opt_secure_file_priv, NullS); if (*opt_secure_file_priv == 0)
x_free(opt_secure_file_priv); {
opt_secure_file_priv= my_strdup(buff, MYF(MY_FAE)); 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; return 0;
} }

View File

@ -6255,21 +6255,21 @@ bool mysql_revoke_all(THD *thd, List <LEX_USER> &list)
mysql_mutex_unlock(&acl_cache->lock); 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()); write_bin_log(thd, FALSE, thd->query(), thd->query_length());
mysql_rwlock_unlock(&LOCK_grant); mysql_rwlock_unlock(&LOCK_grant);
close_thread_tables(thd); 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 */ /* Restore the state of binlog format */
DBUG_ASSERT(!thd->is_current_stmt_binlog_format_row()); DBUG_ASSERT(!thd->is_current_stmt_binlog_format_row());
if (save_binlog_row_based) if (save_binlog_row_based)
thd->set_current_stmt_binlog_format_row(); thd->set_current_stmt_binlog_format_row();
DBUG_RETURN(result || binlog_error); DBUG_RETURN(result);
} }

View File

@ -305,6 +305,37 @@ void **thd_ha_data(const THD *thd, const struct handlerton *hton)
return (void **) &thd->ha_data[hton->slot].ha_ptr; 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" extern "C"
long long thd_test_options(const THD *thd, long long test_options) long long thd_test_options(const THD *thd, long long test_options)
{ {

View File

@ -1470,7 +1470,11 @@ struct Ha_data
@sa trans_register_ha() @sa trans_register_ha()
*/ */
Ha_trx_info ha_info[2]; 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) {} Ha_data() :ha_ptr(NULL) {}
}; };

View File

@ -396,9 +396,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
} }
else if (opt_secure_file_priv) else if (opt_secure_file_priv)
{ {
char secure_file_real_path[FN_REFLEN]; if (strncmp(opt_secure_file_priv, name, strlen(opt_secure_file_priv)))
(void) my_realpath(secure_file_real_path, opt_secure_file_priv, 0);
if (strncmp(secure_file_real_path, name, strlen(secure_file_real_path)))
{ {
/* Read only allowed from within dir specified by 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"); my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--secure-file-priv");

View File

@ -1160,8 +1160,16 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
We have name + wildcard in packet, separated by endzero We have name + wildcard in packet, separated by endzero
*/ */
arg_end= strend(packet); 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, 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; table_list.alias= table_list.table_name= conv_name.str;
packet= arg_end + 1; packet= arg_end + 1;

View File

@ -1755,6 +1755,12 @@ bool mysql_install_plugin(THD *thd, const LEX_STRING *name, const LEX_STRING *dl
struct st_plugin_int *tmp; struct st_plugin_int *tmp;
DBUG_ENTER("mysql_install_plugin"); 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); tables.init_one_table("mysql", 5, "plugin", 6, "plugin", TL_WRITE);
if (check_table_access(thd, INSERT_ACL, &tables, FALSE, 1, FALSE)) if (check_table_access(thd, INSERT_ACL, &tables, FALSE, 1, FALSE))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
@ -1829,6 +1835,12 @@ bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name)
struct st_plugin_int *plugin; struct st_plugin_int *plugin;
DBUG_ENTER("mysql_uninstall_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); tables.init_one_table("mysql", 5, "plugin", 6, "plugin", TL_WRITE);
if (check_table_access(thd, DELETE_ACL, &tables, FALSE, 1, FALSE)) if (check_table_access(thd, DELETE_ACL, &tables, FALSE, 1, FALSE))

View File

@ -6935,7 +6935,14 @@ view_err:
&index_add_buffer, &index_add_count, &index_add_buffer, &index_add_count,
&candidate_key_count)) &candidate_key_count))
goto err; 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) if (need_copy_table == ALTER_TABLE_METADATA_ONLY)
need_copy_table= need_copy_table_res; need_copy_table= need_copy_table_res;
} }

View File

@ -1337,6 +1337,16 @@ int multi_update::prepare(List<Item> &not_used_values,
{ {
table->read_set= &table->def_read_set; table->read_set= &table->def_read_set;
bitmap_union(table->read_set, &table->tmp_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);
} }
} }