Skip to content

Commit

Permalink
merge 10.5
Browse files Browse the repository at this point in the history
  • Loading branch information
vaintroub committed Jul 4, 2020
2 parents 272828a + a85f81a commit d46576b
Show file tree
Hide file tree
Showing 87 changed files with 689 additions and 807 deletions.
67 changes: 35 additions & 32 deletions include/my_valgrind.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,22 @@
# define __SANITIZE_ADDRESS__ 1
#endif

#ifdef HAVE_valgrind
#define IF_VALGRIND(A,B) A
#else
#define IF_VALGRIND(A,B) B
#endif

#if defined(HAVE_VALGRIND_MEMCHECK_H) && defined(HAVE_valgrind)
#if __has_feature(memory_sanitizer)
# include <sanitizer/msan_interface.h>
# define HAVE_valgrind
# define MEM_UNDEFINED(a,len) __msan_allocated_memory(a,len)
# define MEM_MAKE_ADDRESSABLE(a,len) MEM_UNDEFINED(a,len)
# define MEM_MAKE_DEFINED(a,len) __msan_unpoison(a,len)
# define MEM_NOACCESS(a,len) ((void) 0)
# define MEM_CHECK_ADDRESSABLE(a,len) ((void) 0)
# define MEM_CHECK_DEFINED(a,len) __msan_check_mem_is_initialized(a,len)
# define MEM_GET_VBITS(a,b,len) __msan_copy_shadow(b,a,len)
# define MEM_SET_VBITS(a,b,len) __msan_copy_shadow(a,b,len)
# define REDZONE_SIZE 8
#elif defined(HAVE_VALGRIND_MEMCHECK_H) && defined(HAVE_valgrind)
# include <valgrind/memcheck.h>
# define HAVE_valgrind_or_MSAN
# define MEM_UNDEFINED(a,len) VALGRIND_MAKE_MEM_UNDEFINED(a,len)
# define MEM_MAKE_ADDRESSABLE(a,len) MEM_UNDEFINED(a,len)
# define MEM_MAKE_DEFINED(a,len) VALGRIND_MAKE_MEM_DEFINED(a,len)
# define MEM_NOACCESS(a,len) VALGRIND_MAKE_MEM_NOACCESS(a,len)
# define MEM_CHECK_ADDRESSABLE(a,len) VALGRIND_CHECK_MEM_IS_ADDRESSABLE(a,len)
Expand All @@ -45,53 +51,50 @@
# include <sanitizer/asan_interface.h>
/* How to do manual poisoning:
https://github.com/google/sanitizers/wiki/AddressSanitizerManualPoisoning */
# define MEM_UNDEFINED(a,len) ASAN_UNPOISON_MEMORY_REGION(a,len)
# define MEM_UNDEFINED(a,len) ((void) 0)
# define MEM_MAKE_ADDRESSABLE(a,len) ASAN_UNPOISON_MEMORY_REGION(a,len)
# define MEM_MAKE_DEFINED(a,len) ((void) 0)
# define MEM_NOACCESS(a,len) ASAN_POISON_MEMORY_REGION(a,len)
# define MEM_CHECK_ADDRESSABLE(a,len) ((void) 0)
# define MEM_CHECK_ADDRESSABLE(a,len) \
assert(!__asan_region_is_poisoned((void*) a,len))
# define MEM_CHECK_DEFINED(a,len) ((void) 0)
# define MEM_GET_VBITS(a,b,len) ((void) 0)
# define MEM_SET_VBITS(a,b,len) ((void) 0)
# define REDZONE_SIZE 8
#elif __has_feature(memory_sanitizer)
# include <sanitizer/msan_interface.h>
# define HAVE_valgrind_or_MSAN
# define MEM_UNDEFINED(a,len) __msan_allocated_memory(a,len)
# define MEM_MAKE_DEFINED(a,len) __msan_unpoison(a,len)
# define MEM_NOACCESS(a,len) ((void) 0)
# define MEM_CHECK_ADDRESSABLE(a,len) ((void) 0)
# define MEM_CHECK_DEFINED(a,len) __msan_check_mem_is_initialized(a,len)
# define MEM_GET_VBITS(a,b,len) __msan_copy_shadow(b,a,len)
# define MEM_SET_VBITS(a,b,len) __msan_copy_shadow(a,b,len)
# define REDZONE_SIZE 8
#else
# define MEM_UNDEFINED(a,len) ((void) (a), (void) (len))
# define MEM_UNDEFINED(a,len) ((void) 0)
# define MEM_MAKE_ADDRESSABLE(a,len) ((void) 0)
# define MEM_MAKE_DEFINED(a,len) ((void) 0)
# define MEM_NOACCESS(a,len) ((void) 0)
# define MEM_CHECK_ADDRESSABLE(a,len) ((void) 0)
# define MEM_CHECK_DEFINED(a,len) ((void) 0)
# define MEM_GET_VBITS(a,b,len) ((void) 0)
# define MEM_SET_VBITS(a,b,len) ((void) 0)
# define REDZONE_SIZE 0
#endif /* HAVE_VALGRIND_MEMCHECK_H */
#endif /* __has_feature(memory_sanitizer) */

#ifdef HAVE_valgrind
#define IF_VALGRIND(A,B) A
#else
#define IF_VALGRIND(A,B) B
#endif

#ifdef TRASH_FREED_MEMORY
/*
TRASH_FILL() has to call MEM_UNDEFINED() to cancel any effect of TRASH_FREE().
_TRASH_FILL() has to call MEM_MAKE_ADDRESSABLE() to cancel any effect of
TRASH_FREE().
This can happen in the case one does
TRASH_ALLOC(A,B) ; TRASH_FREE(A,B) ; TRASH_ALLOC(A,B)
to reuse the same memory in an internal memory allocator like MEM_ROOT.
For my_malloc() and safemalloc() the extra MEM_UNDEFINED is bit of an
overkill.
TRASH_FILL() is an internal function and should not be used externally.
_TRASH_FILL() is an internal function and should not be used externally.
*/
#define TRASH_FILL(A,B,C) do { const size_t trash_tmp= (B); MEM_UNDEFINED(A, trash_tmp); memset(A, C, trash_tmp); } while (0)
#define _TRASH_FILL(A,B,C) do { const size_t trash_tmp= (B); MEM_MAKE_ADDRESSABLE(A, trash_tmp); memset(A, C, trash_tmp); } while (0)
#else
#define TRASH_FILL(A,B,C) do { MEM_UNDEFINED((A), (B)); } while (0)
#define _TRASH_FILL(A,B,C) do { MEM_UNDEFINED((A), (B)); } while (0)
#endif
/** Note that some memory became allocated or uninitialized. */
#define TRASH_ALLOC(A,B) do { TRASH_FILL(A,B,0xA5); MEM_UNDEFINED(A,B); } while(0)
/** Note that some memory became allocated and/or uninitialized. */
#define TRASH_ALLOC(A,B) do { _TRASH_FILL(A,B,0xA5); MEM_MAKE_ADDRESSABLE(A,B); } while(0)
/** Note that some memory became freed. (Prohibit further access to it.) */
#define TRASH_FREE(A,B) do { TRASH_FILL(A,B,0x8F); MEM_NOACCESS(A,B); } while(0)
#define TRASH_FREE(A,B) do { _TRASH_FILL(A,B,0x8F); MEM_NOACCESS(A,B); } while(0)

#endif /* MY_VALGRIND_INCLUDED */
1 change: 1 addition & 0 deletions libmysqld/libmysql.c
Original file line number Diff line number Diff line change
Expand Up @@ -1164,6 +1164,7 @@ my_bool STDCALL mysql_embedded(void)
void my_net_local_init(NET *net)
{
net->max_packet= (uint) net_buffer_length;
net->read_timeout= net->write_timeout= 0;
my_net_set_read_timeout(net, CLIENT_NET_READ_TIMEOUT);
my_net_set_write_timeout(net, CLIENT_NET_WRITE_TIMEOUT);
net->retry_count= 1;
Expand Down
28 changes: 0 additions & 28 deletions mysql-test/main/drop-no_root.result

This file was deleted.

85 changes: 0 additions & 85 deletions mysql-test/main/drop-no_root.test

This file was deleted.

13 changes: 13 additions & 0 deletions mysql-test/main/drop.result
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,19 @@ create table mysql_test.`#sql-347f_7` (f1 int);
create table mysql_test.`#sql-347f_8` (f1 int);
drop table mysql_test.`#sql-347f_8`;
drop database mysql_test;
create database mysql_test;
use mysql_test;
create table t1(c int);
drop database mysql_test;
ERROR HY000: Error dropping database (can't rmdir './mysql_test', errno: 39 "Directory not empty")
select database();
database()
mysql_test
drop database mysql_test;
select database();
database()
NULL
use test;

# --
# -- Bug#29958: Weird message on DROP DATABASE if mysql.proc does not
Expand Down
21 changes: 21 additions & 0 deletions mysql-test/main/drop.test
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,27 @@ let $MYSQLD_DATADIR= `select @@datadir`;
copy_file $MYSQLD_DATADIR/mysql_test/t1.frm $MYSQLD_DATADIR/mysql_test/#sql-347f_6.frm;
drop database mysql_test;

#
# Bug#26704: Failing DROP DATABASE brings mysql-client out of sync.
#

create database mysql_test;
use mysql_test;
create table t1(c int);

write_file $MYSQLD_DATADIR/mysql_test/do_not_delete;
do_not_delete
EOF

replace_result $MYSQLD_DATADIR ./ \\ / 41 39;
error ER_DB_DROP_RMDIR;
drop database mysql_test;
select database();
remove_file $MYSQLD_DATADIR/mysql_test/do_not_delete;
drop database mysql_test;
select database();
use test;

###########################################################################

--echo
Expand Down
6 changes: 2 additions & 4 deletions mysql-test/main/drop_combinations.result
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,7 @@ drop table if exists t1,s1,v1,t3,t4;
Warnings:
Warning 1017 Can't find file: './test/t1.MYI' (errno: 2 "No such file or directory")
Note 1965 'test.v1' is a view
Note 1965 'test.t3' is a view
Note 1965 'test.t4' is a view
Note 1051 Unknown table 'test.t3,test.t4'
drop table if exists s2,v2,t2,t1;
Warnings:
Note 1965 'test.v2' is a view
Expand Down Expand Up @@ -493,8 +492,7 @@ Warnings:
Warning 1017 Can't find file: './test/s1.MYI' (errno: 2 "No such file or directory")
Note 4090 'test.t1' is not a SEQUENCE
Note 1965 'test.v1' is a view
Note 1965 'test.t3' is a view
Note 1965 'test.s4' is a view
Note 4091 Unknown SEQUENCE: 'test.t3,test.s4'
drop sequence if exists t2,v2,s2,s1;
Warnings:
Note 4090 'test.t2' is not a SEQUENCE
Expand Down
13 changes: 1 addition & 12 deletions mysql-test/main/drop_table_force.result
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ db.opt
# Test droping table without frm without super privilege
create table t1(a int) engine=innodb;
create user test identified by '123456';
grant all privileges on test.t1 to 'test'@'%'identified by '123456' with grant option;
grant all privileges on test.t1 to 'test'@'%'identified by '123456';
connect con_test, localhost, test,'123456', ;
connection con_test;
drop table t1;
Expand All @@ -18,10 +18,6 @@ connection default;
disconnect con_test;
drop user test;
db.opt
#Test4: drop table can drop consistent table as well
create table t1(a int) engine=innodb;
drop table t1;
db.opt
#Test5: drop table with triger, and with missing frm
create table t1(a int)engine=innodb;
create trigger t1_trg before insert on t1 for each row begin end;
Expand All @@ -45,13 +41,6 @@ drop table if exists t1;
Warnings:
Note 1051 Unknown table 'test.t1'
db.opt
#Test8: check compatibility with if exists
create table t1(a int)engine=innodb;
drop table t1;
db.opt
drop table if exists t1;
Warnings:
Note 1051 Unknown table 'test.t1'
#Test9: check compatibility with restrict/cascade
CREATE TABLE parent (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB;
CREATE TABLE child (id INT, parent_id INT, INDEX par_ind (parent_id), FOREIGN KEY (parent_id) REFERENCES parent(id) ON DELETE CASCADE) ENGINE=INNODB;
Expand Down
22 changes: 1 addition & 21 deletions mysql-test/main/drop_table_force.test
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ create table t1(a int) engine=innodb;

# create test user
create user test identified by '123456';
grant all privileges on test.t1 to 'test'@'%'identified by '123456' with grant option;
grant all privileges on test.t1 to 'test'@'%'identified by '123456';

# connect as test
connect (con_test, localhost, test,'123456', );
Expand All @@ -52,13 +52,6 @@ drop user test;
# check files in datadir about t1
--list_files $DATADIR/test/

--echo #Test4: drop table can drop consistent table as well
create table t1(a int) engine=innodb;
drop table t1;

# check files in datadir about t1
--list_files $DATADIR/test/

--echo #Test5: drop table with triger, and with missing frm
# create table t1 with triger and rm frm
create table t1(a int)engine=innodb;
Expand Down Expand Up @@ -107,19 +100,6 @@ drop table if exists t1;
# check files in datadir about t1
--list_files $DATADIR/test/

--echo #Test8: check compatibility with if exists
create table t1(a int)engine=innodb;
--remove_file $DATADIR/test/t1.frm

# first drop will success
drop table t1;

# check files in datadir about t1
--list_files $DATADIR/test/

# second drop with if exists will success
drop table if exists t1;

--echo #Test9: check compatibility with restrict/cascade
# create table with foreign key reference and rm frm
CREATE TABLE parent (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB;
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/main/mysql_upgrade.test
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ let $MYSQLD_DATADIR= `select @@datadir`;
file_exists $MYSQLD_DATADIR/mysql_upgrade_info;

--echo Run it again - should say already completed
--replace_result $MYSQL_SERVER_VERSION VERSION
--replace_regex /upgraded to .*, use/upgraded to VERSION, use/
--exec $MYSQL_UPGRADE 2>&1

# It should have created a file in the MySQL Servers datadir
Expand Down
Loading

0 comments on commit d46576b

Please sign in to comment.