summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@mariadb.com>2020-07-04 18:14:41 +0200
committerVladislav Vaintroub <wlad@mariadb.com>2020-07-04 18:14:41 +0200
commitd46576b35ac0775e6500ee15e828f29c74998262 (patch)
treeeb2e7d153b56ff7f29a9b6e6d372ecacf4b51ab1
parent272828a171417c2cc7b27b7e3aad18c85bb7d0be (diff)
parenta85f81af035f3c9420ccd536d249bd1e8ee429be (diff)
downloadmariadb-git-d46576b35ac0775e6500ee15e828f29c74998262.tar.gz
merge 10.5
-rw-r--r--include/my_valgrind.h67
-rw-r--r--libmysqld/libmysql.c1
-rw-r--r--mysql-test/main/drop-no_root.result28
-rw-r--r--mysql-test/main/drop-no_root.test85
-rw-r--r--mysql-test/main/drop.result13
-rw-r--r--mysql-test/main/drop.test21
-rw-r--r--mysql-test/main/drop_combinations.result6
-rw-r--r--mysql-test/main/drop_table_force.result13
-rw-r--r--mysql-test/main/drop_table_force.test22
-rw-r--r--mysql-test/main/mysql_upgrade.test2
-rw-r--r--mysql-test/main/temp_table.result21
-rw-r--r--mysql-test/main/temp_table.test33
-rw-r--r--mysql-test/main/type_temporal_innodb.result3
-rw-r--r--mysql-test/main/type_temporal_innodb.test4
-rw-r--r--mysql-test/suite/csv/read_only.test1
-rw-r--r--mysql-test/suite/galera/r/galera_lock_tables_in_transaction.result12
-rw-r--r--mysql-test/suite/galera/t/galera_lock_tables_in_transaction.test21
-rw-r--r--mysql-test/suite/heap/drop.result3
-rw-r--r--mysql-test/suite/heap/drop.test11
-rw-r--r--mysql-test/suite/parts/r/partition_open.result2
-rw-r--r--mysql-test/suite/rpl/disabled.def1
-rw-r--r--mysys/my_alloc.c2
-rw-r--r--mysys/my_atomic_writes.c114
-rw-r--r--plugin/feedback/feedback.cc19
-rw-r--r--plugin/metadata_lock_info/metadata_lock_info.cc22
-rw-r--r--sql/datadict.cc13
-rw-r--r--sql/datadict.h6
-rw-r--r--sql/field.cc2
-rw-r--r--sql/field.h4
-rw-r--r--sql/ha_partition.cc22
-rw-r--r--sql/ha_sequence.cc3
-rw-r--r--sql/handler.cc175
-rw-r--r--sql/handler.h19
-rw-r--r--sql/log.cc6
-rw-r--r--sql/session_tracker.cc14
-rw-r--r--sql/sql_base.cc22
-rw-r--r--sql/sql_load.cc4
-rw-r--r--sql/sql_parse.cc6
-rw-r--r--sql/sql_plugin.cc3
-rw-r--r--sql/sql_select.cc74
-rw-r--r--sql/sql_show.cc3
-rw-r--r--sql/sql_table.cc184
-rw-r--r--sql/table.cc13
-rw-r--r--sql/table.h3
-rw-r--r--sql/temporary_tables.cc6
-rw-r--r--sql/unireg.cc4
-rw-r--r--sql/wsrep_mysqld.h1
-rw-r--r--storage/blackhole/ha_blackhole.cc20
-rw-r--r--storage/example/ha_example.cc22
-rw-r--r--storage/federated/ha_federated.cc21
-rw-r--r--storage/federatedx/ha_federatedx.cc4
-rw-r--r--storage/heap/ha_heap.cc31
-rw-r--r--storage/heap/heapdef.h2
-rw-r--r--storage/innobase/btr/btr0cur.cc6
-rw-r--r--storage/innobase/buf/buf0buddy.cc2
-rw-r--r--storage/innobase/buf/buf0buf.cc8
-rw-r--r--storage/innobase/buf/buf0lru.cc8
-rw-r--r--storage/innobase/data/data0data.cc4
-rw-r--r--storage/innobase/handler/ha_innodb.cc4
-rw-r--r--storage/innobase/include/buf0buf.ic2
-rw-r--r--storage/innobase/include/dict0stats.ic4
-rw-r--r--storage/innobase/include/mem0mem.ic2
-rw-r--r--storage/innobase/include/read0types.h15
-rw-r--r--storage/innobase/include/srv0mon.h6
-rw-r--r--storage/innobase/include/ut0pool.h28
-rw-r--r--storage/innobase/log/log0recv.cc8
-rw-r--r--storage/innobase/mtr/mtr0mtr.cc4
-rw-r--r--storage/innobase/page/page0cur.cc8
-rw-r--r--storage/innobase/page/page0zip.cc6
-rw-r--r--storage/innobase/row/row0ftsort.cc4
-rw-r--r--storage/innobase/row/row0ins.cc2
-rw-r--r--storage/innobase/row/row0log.cc18
-rw-r--r--storage/innobase/row/row0merge.cc14
-rw-r--r--storage/innobase/row/row0sel.cc10
-rw-r--r--storage/innobase/row/row0upd.cc2
-rw-r--r--storage/innobase/sync/sync0arr.cc2
-rw-r--r--storage/innobase/trx/trx0trx.cc20
-rw-r--r--storage/mroonga/ha_mroonga.cpp13
-rw-r--r--storage/myisam/ha_myisam.cc25
-rw-r--r--storage/myisam/myisamdef.h2
-rw-r--r--storage/oqgraph/ha_oqgraph.cc1
-rw-r--r--storage/perfschema/ha_perfschema.cc26
-rw-r--r--storage/rocksdb/rdb_datadic.cc3
-rw-r--r--storage/sequence/sequence.cc11
-rw-r--r--storage/sphinx/ha_sphinx.cc3
-rw-r--r--storage/spider/spd_table.cc2
-rw-r--r--storage/test_sql_discovery/test_sql_discovery.cc9
87 files changed, 689 insertions, 807 deletions
diff --git a/include/my_valgrind.h b/include/my_valgrind.h
index 1de6714700b..62794a2d70c 100644
--- a/include/my_valgrind.h
+++ b/include/my_valgrind.h
@@ -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)
@@ -45,27 +51,19 @@
# 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)
@@ -73,25 +71,30 @@ https://github.com/google/sanitizers/wiki/AddressSanitizerManualPoisoning */
# 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 */
diff --git a/libmysqld/libmysql.c b/libmysqld/libmysql.c
index 8b48d6d4bcb..e269840d674 100644
--- a/libmysqld/libmysql.c
+++ b/libmysqld/libmysql.c
@@ -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;
diff --git a/mysql-test/main/drop-no_root.result b/mysql-test/main/drop-no_root.result
deleted file mode 100644
index 3e1f2fe2cf0..00000000000
--- a/mysql-test/main/drop-no_root.result
+++ /dev/null
@@ -1,28 +0,0 @@
-
-# --
-# -- Bug#26704: Failing DROP DATABASE brings mysql-client out of sync.
-# --
-
-DROP DATABASE IF EXISTS mysql_test;
-
-CREATE DATABASE mysql_test;
-CREATE TABLE mysql_test.t1(c INT);
-use mysql_test;
-
-chmod 000 mysql_test/t1.frm
-
-DROP DATABASE mysql_test;
-
-SELECT DATABASE();
-DATABASE()
-mysql_test
-
-rm -f mysql_test/t1.MYD mysql_test/t1.MYI
-chmod 666 mysql_test/t1.frm
-rm -f mysql_test/t1.frm
-
-DROP DATABASE mysql_test;
-
-use test;
-
-# -- End of Bug#26704.
diff --git a/mysql-test/main/drop-no_root.test b/mysql-test/main/drop-no_root.test
deleted file mode 100644
index 8fb5b3f74a8..00000000000
--- a/mysql-test/main/drop-no_root.test
+++ /dev/null
@@ -1,85 +0,0 @@
-# This test uses chmod, can't be run with root permissions
---source include/not_as_root.inc
-
-###########################################################################
-
---echo
---echo # --
---echo # -- Bug#26704: Failing DROP DATABASE brings mysql-client out of sync.
---echo # --
-
---echo
---disable_warnings
-DROP DATABASE IF EXISTS mysql_test;
---enable_warnings
-
---echo
-CREATE DATABASE mysql_test;
-CREATE TABLE mysql_test.t1(c INT);
-
-use mysql_test;
-
-let $MYSQLD_DATADIR= `select @@datadir`;
-
---echo
---echo chmod 000 mysql_test/t1.frm
---chmod 0000 $MYSQLD_DATADIR/mysql_test/t1.frm
-
-# NOTE: For the DROP DATABASE below we need:
-# - disable result log because ER_DB_DROP_RMDIR contains errno, which can be
-# different on different platforms.
-# - expect different error codes, because Windows and UNIX behaves
-# differently (see below).
-#
-# NOTE: Windows and UNIX behaves differently in this test case:
-#
-# - on UNIX when t1.frm is chmoded to 000, it is perfectly deleted
-# by the first DROP DATABASE, but some other files (t1.MYI and t1.MYD) left
-# in the directory. So, we have to explicitly removes them before the
-# second DROP DATABASE.
-#
-# - on Windows when t1.frm is chmoded to 000, it is not deleted by the first
-# DROP DATABASE, but all other files in the database directory are deleted.
-# Thus, we have to change the t1.frm permissions again and delete it
-# explicitly before the second DROP DATABASE.
-#
-# All those differences do not really matter for the idea of this test case:
-# checking that if DROP DATABASE failed, the client is Ok.
-
---echo
---disable_result_log
---error ER_DB_DROP_RMDIR,6
-DROP DATABASE mysql_test;
---enable_result_log
-
---echo
-SELECT DATABASE();
-
-# Remove t1.MYI and t1.MYD. On UNIX it should succeed. On Windows, it fails.
---echo
---echo rm -f mysql_test/t1.MYD mysql_test/t1.MYI
---error 0, 1
---remove_file $MYSQLD_DATADIR/mysql_test/t1.MYD
---error 0, 1
---remove_file $MYSQLD_DATADIR/mysql_test/t1.MYI
-
-# Make t1.frm removable: fail on UNIX, succeed on Windows.
---echo chmod 666 mysql_test/t1.frm
---error 0, 1
---chmod 0666 $MYSQLD_DATADIR/mysql_test/t1.frm
-
-# Remove t1.frm: fail on UNIX, succeed on Windows.
---echo rm -f mysql_test/t1.frm
---error 0, 1
---remove_file $MYSQLD_DATADIR/mysql_test/t1.frm
-
---echo
-DROP DATABASE mysql_test;
-
---echo
-use test;
-
---echo
---echo # -- End of Bug#26704.
-
-###########################################################################
diff --git a/mysql-test/main/drop.result b/mysql-test/main/drop.result
index 4755965cbb2..d50ffabc9fa 100644
--- a/mysql-test/main/drop.result
+++ b/mysql-test/main/drop.result
@@ -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
diff --git a/mysql-test/main/drop.test b/mysql-test/main/drop.test
index 2a2d2715185..17065a32347 100644
--- a/mysql-test/main/drop.test
+++ b/mysql-test/main/drop.test
@@ -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
diff --git a/mysql-test/main/drop_combinations.result b/mysql-test/main/drop_combinations.result
index eb6d70e0704..140665efd19 100644
--- a/mysql-test/main/drop_combinations.result
+++ b/mysql-test/main/drop_combinations.result
@@ -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
@@ -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
diff --git a/mysql-test/main/drop_table_force.result b/mysql-test/main/drop_table_force.result
index bb4ecc060b0..d3142887ade 100644
--- a/mysql-test/main/drop_table_force.result
+++ b/mysql-test/main/drop_table_force.result
@@ -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;
@@ -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;
@@ -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;
diff --git a/mysql-test/main/drop_table_force.test b/mysql-test/main/drop_table_force.test
index bb735309167..518b4e754c3 100644
--- a/mysql-test/main/drop_table_force.test
+++ b/mysql-test/main/drop_table_force.test
@@ -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', );
@@ -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;
@@ -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;
diff --git a/mysql-test/main/mysql_upgrade.test b/mysql-test/main/mysql_upgrade.test
index 5c07d3858d3..42c4a545dd7 100644
--- a/mysql-test/main/mysql_upgrade.test
+++ b/mysql-test/main/mysql_upgrade.test
@@ -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
diff --git a/mysql-test/main/temp_table.result b/mysql-test/main/temp_table.result
index 293b6d5cd77..64a5d9b681b 100644
--- a/mysql-test/main/temp_table.result
+++ b/mysql-test/main/temp_table.result
@@ -1,5 +1,3 @@
-drop table if exists t1,t2;
-drop view if exists v1;
#
# test basic creation of temporary tables together with normal table
#
@@ -602,3 +600,22 @@ DROP TEMPORARY TABLE t1;
#
# End of 10.2 tests
#
+create function f1() returns int
+begin
+drop temporary table t1, t2;
+return 1;
+end;
+$$
+create temporary table t1 (a int);
+create temporary table t2 (a int);
+insert t1 values (2);
+insert t2 values (3);
+select a,f1() from t1;
+ERROR HY000: Can't reopen table: 't1'
+drop function f1;
+drop temporary table t1;
+drop temporary table t2;
+ERROR 42S02: Unknown table 'test.t2'
+#
+# End of 10.5 tests
+#
diff --git a/mysql-test/main/temp_table.test b/mysql-test/main/temp_table.test
index dc5fe7f3cd0..ccaa5fb93e8 100644
--- a/mysql-test/main/temp_table.test
+++ b/mysql-test/main/temp_table.test
@@ -6,11 +6,6 @@
# Test of temporary tables
#
---disable_warnings
-drop table if exists t1,t2;
-drop view if exists v1;
---enable_warnings
-
--echo #
--echo # test basic creation of temporary tables together with normal table
--echo #
@@ -658,3 +653,31 @@ DROP TEMPORARY TABLE t1;
--echo #
--echo # End of 10.2 tests
--echo #
+
+#
+# DROP TEMPORARY TABLE fails in the middle
+#
+delimiter $$;
+create function f1() returns int
+begin
+ drop temporary table t1, t2;
+ return 1;
+end;
+$$
+delimiter ;$$
+
+create temporary table t1 (a int);
+create temporary table t2 (a int);
+insert t1 values (2);
+insert t2 values (3);
+--error ER_CANT_REOPEN_TABLE
+select a,f1() from t1;
+drop function f1;
+drop temporary table t1;
+--error ER_BAD_TABLE_ERROR
+drop temporary table t2;
+
+--echo #
+--echo # End of 10.5 tests
+--echo #
+
diff --git a/mysql-test/main/type_temporal_innodb.result b/mysql-test/main/type_temporal_innodb.result
index 2aad1e02d02..b11ea8476bd 100644
--- a/mysql-test/main/type_temporal_innodb.result
+++ b/mysql-test/main/type_temporal_innodb.result
@@ -173,6 +173,9 @@ ERROR 22007: Truncated incorrect datetime value: '0000-00-00 00:00:00'
DROP TABLE t1,t2;
SET sql_mode=DEFAULT;
#
+# End of 10.3 tests
+#
+#
# MDEV-19166 Assertion `!is_zero_datetime()' failed in Timestamp_or_zero_datetime::tv
#
CREATE TABLE t1 (f TIMESTAMP DEFAULT 0) ENGINE=InnoDB;
diff --git a/mysql-test/main/type_temporal_innodb.test b/mysql-test/main/type_temporal_innodb.test
index b8c7720f8b6..4adaa483ca2 100644
--- a/mysql-test/main/type_temporal_innodb.test
+++ b/mysql-test/main/type_temporal_innodb.test
@@ -82,6 +82,9 @@ CREATE TABLE tbl SELECT * FROM t1 WHERE t1.c1 = (SELECT c2 FROM t2 WHERE pk = 6)
DROP TABLE t1,t2;
SET sql_mode=DEFAULT;
+--echo #
+--echo # End of 10.3 tests
+--echo #
--echo #
--echo # MDEV-19166 Assertion `!is_zero_datetime()' failed in Timestamp_or_zero_datetime::tv
@@ -92,7 +95,6 @@ INSERT INTO t1 VALUES ('2024-02-29');
SELECT * FROM t1 WHERE SUBSTR(1 FROM BIT_LENGTH(f) FOR DEFAULT(f));
DROP TABLE t1;
-
--echo #
--echo # End of 10.4 tests
--echo #
diff --git a/mysql-test/suite/csv/read_only.test b/mysql-test/suite/csv/read_only.test
index 2af209182d0..a3c851a6a70 100644
--- a/mysql-test/suite/csv/read_only.test
+++ b/mysql-test/suite/csv/read_only.test
@@ -1,3 +1,4 @@
+--source include/not_as_root.inc
#
# MDEV-11883 MariaDB crashes with out-of-memory when query information_schema
#
diff --git a/mysql-test/suite/galera/r/galera_lock_tables_in_transaction.result b/mysql-test/suite/galera/r/galera_lock_tables_in_transaction.result
new file mode 100644
index 00000000000..68691a4efd2
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_lock_tables_in_transaction.result
@@ -0,0 +1,12 @@
+connection node_2;
+connection node_1;
+CREATE TABLE t1 (a INT) ENGINE=InnoDB;
+START TRANSACTION;
+INSERT INTO t1 VALUES (1);
+LOCK TABLES t2 READ;
+ERROR 42S02: Table 'test.t2' doesn't exist
+START TRANSACTION;
+INSERT INTO t1 VALUES (1);
+LOCK TABLES t1 READ;
+UNLOCK TABLES;
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera/t/galera_lock_tables_in_transaction.test b/mysql-test/suite/galera/t/galera_lock_tables_in_transaction.test
new file mode 100644
index 00000000000..5cb7347639c
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_lock_tables_in_transaction.test
@@ -0,0 +1,21 @@
+#
+# Check `LOCK TABLES` command with or without existing table in database.
+# Test case for MDEV-22222 / MDEV-22223
+#
+
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+CREATE TABLE t1 (a INT) ENGINE=InnoDB;
+
+START TRANSACTION;
+INSERT INTO t1 VALUES (1);
+--error ER_NO_SUCH_TABLE
+LOCK TABLES t2 READ;
+
+START TRANSACTION;
+INSERT INTO t1 VALUES (1);
+LOCK TABLES t1 READ;
+UNLOCK TABLES;
+
+DROP TABLE t1;
diff --git a/mysql-test/suite/heap/drop.result b/mysql-test/suite/heap/drop.result
new file mode 100644
index 00000000000..cbc784fd59b
--- /dev/null
+++ b/mysql-test/suite/heap/drop.result
@@ -0,0 +1,3 @@
+create table t1 (a int) engine=memory;
+drop table t1;
+drop table t2;
diff --git a/mysql-test/suite/heap/drop.test b/mysql-test/suite/heap/drop.test
new file mode 100644
index 00000000000..ef61d4400f1
--- /dev/null
+++ b/mysql-test/suite/heap/drop.test
@@ -0,0 +1,11 @@
+create table t1 (a int) engine=memory;
+let $DATADIR= `select @@datadir`;
+copy_file $DATADIR/test/t1.frm $DATADIR/test/t2.frm;
+#
+# drop a newly created MEMORY table
+#
+drop table t1;
+#
+# drop a MEMORY table after a server restart (frm only, nothing in memory)
+#
+drop table t2;
diff --git a/mysql-test/suite/parts/r/partition_open.result b/mysql-test/suite/parts/r/partition_open.result
index 98600d98ce3..a8ffac1109e 100644
--- a/mysql-test/suite/parts/r/partition_open.result
+++ b/mysql-test/suite/parts/r/partition_open.result
@@ -5,4 +5,4 @@ select * from t1 partition (p0);
ERROR HY000: Can't find file: './test/t1.MYI' (errno: 2 "No such file or directory")
drop table t1;
Warnings:
-Warning 1017 Can't find file: './test/t1.MYI' (errno: 2 "No such file or directory")
+Warning 1017 Can't find file: './test/t1.par' (errno: 2 "No such file or directory")
diff --git a/mysql-test/suite/rpl/disabled.def b/mysql-test/suite/rpl/disabled.def
index 9e52c277726..640c4b56cd0 100644
--- a/mysql-test/suite/rpl/disabled.def
+++ b/mysql-test/suite/rpl/disabled.def
@@ -19,3 +19,4 @@ rpl_semi_sync_after_sync : fails after MDEV-16172
rpl_slave_grp_exec: MDEV-10514
rpl_auto_increment_update_failure : disabled for now
rpl_current_user : waits for MDEV-22374 fix
+rpl_parallel2 : waits for MDEV-23089
diff --git a/mysys/my_alloc.c b/mysys/my_alloc.c
index f5537885227..b4a63e93be3 100644
--- a/mysys/my_alloc.c
+++ b/mysys/my_alloc.c
@@ -205,7 +205,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;
+ size_t original_length __attribute__((unused)) = length;
DBUG_ENTER("alloc_root");
DBUG_PRINT("enter",("root: %p name: %s", mem_root, root_name(mem_root)));
DBUG_ASSERT(alloc_root_inited(mem_root));
diff --git a/mysys/my_atomic_writes.c b/mysys/my_atomic_writes.c
index b383af11ba8..34207a6fd07 100644
--- a/mysys/my_atomic_writes.c
+++ b/mysys/my_atomic_writes.c
@@ -19,7 +19,8 @@ my_bool my_may_have_atomic_write= IF_WIN(1,0);
#ifdef __linux__
-my_bool has_shannon_atomic_write= 0, has_fusion_io_atomic_write= 0;
+my_bool has_shannon_atomic_write= 0, has_fusion_io_atomic_write= 0,
+ has_sfx_atomic_write= 0;
#include <sys/ioctl.h>
@@ -255,6 +256,109 @@ static my_bool shannon_has_atomic_write(File file, int page_size)
/***********************************************************************
+ ScaleFlux
+************************************************************************/
+
+#define SFX_GET_ATOMIC_SIZE _IO('N', 0x244)
+#define SFX_MAX_DEVICES 32
+#define SFX_NO_ATOMIC_SIZE_YET -2
+
+struct sfx_dev
+{
+ char dev_name[32];
+ dev_t st_dev;
+ int atomic_size;
+};
+
+static struct sfx_dev sfx_devices[SFX_MAX_DEVICES + 1];
+
+/**
+ Check if the system has a ScaleFlux card
+ If card exists, record device numbers to allow us to later check if
+ a given file is on this device.
+ @return TRUE Card exists
+*/
+
+static my_bool test_if_sfx_card_exists()
+{
+ uint sfx_found_devices = 0;
+ uint dev_num;
+
+ for (dev_num = 0; dev_num < SFX_MAX_DEVICES; dev_num++)
+ {
+ struct stat stat_buff;
+
+ sprintf(sfx_devices[sfx_found_devices].dev_name, "/dev/sfdv%dn1",
+ dev_num);
+ if (lstat(sfx_devices[sfx_found_devices].dev_name,
+ &stat_buff) < 0)
+ break;
+
+ sfx_devices[sfx_found_devices].st_dev= stat_buff.st_rdev;
+ /*
+ The atomic size will be checked on first access. This is needed
+ as a normal user can't open the /dev/sfdvXn1 file
+ */
+ sfx_devices[sfx_found_devices].atomic_size = SFX_NO_ATOMIC_SIZE_YET;
+ if (++sfx_found_devices == SFX_MAX_DEVICES)
+ goto end;
+ }
+end:
+ sfx_devices[sfx_found_devices].st_dev= 0;
+ return sfx_found_devices > 0;
+}
+
+static my_bool sfx_dev_has_atomic_write(struct sfx_dev *dev,
+ int page_size)
+{
+ if (dev->atomic_size == SFX_NO_ATOMIC_SIZE_YET)
+ {
+ int fd= open(dev->dev_name, 0);
+ if (fd < 0)
+ {
+ perror("open() failed!");
+ dev->atomic_size= 0; /* Don't try again */
+ return FALSE;
+ }
+
+ dev->atomic_size= ioctl(fd, SFX_GET_ATOMIC_SIZE);
+ close(fd);
+ }
+
+ return (page_size <= dev->atomic_size);
+}
+
+
+/**
+ Check if a file is on a ScaleFlux device and that it supports atomic_write
+ @param[in] file OS file handle
+ @param[in] page_size page size
+ @return TRUE Atomic write supported
+
+ @notes
+ This is called only at first open of a file. In this case it's doesn't
+ matter so much that we loop over all cards.
+ We update the atomic size on first access.
+*/
+
+static my_bool sfx_has_atomic_write(File file, int page_size)
+{
+ struct sfx_dev *dev;
+ struct stat stat_buff;
+
+ if (fstat(file, &stat_buff) < 0)
+ {
+ return 0;
+ }
+
+ for (dev = sfx_devices; dev->st_dev; dev++)
+ {
+ if (stat_buff.st_dev == dev->st_dev)
+ return sfx_dev_has_atomic_write(dev, page_size);
+ }
+ return 0;
+}
+/***********************************************************************
Generic atomic write code
************************************************************************/
@@ -266,7 +370,8 @@ static my_bool shannon_has_atomic_write(File file, int page_size)
void my_init_atomic_write(void)
{
if ((has_shannon_atomic_write= test_if_shannon_card_exists()) ||
- (has_fusion_io_atomic_write= test_if_fusion_io_card_exists()))
+ (has_fusion_io_atomic_write= test_if_fusion_io_card_exists()) ||
+ (has_sfx_atomic_write= test_if_sfx_card_exists()))
my_may_have_atomic_write= 1;
#ifdef TEST_SHANNON
printf("%s(): has_shannon_atomic_write=%d, my_may_have_atomic_write=%d\n",
@@ -294,6 +399,7 @@ my_bool my_test_if_atomic_write(File handle, int page_size)
#endif
if (!my_may_have_atomic_write)
return 0;
+
if (has_shannon_atomic_write &&
shannon_has_atomic_write(handle, page_size))
return 1;
@@ -302,6 +408,10 @@ my_bool my_test_if_atomic_write(File handle, int page_size)
fusion_io_has_atomic_write(handle, page_size))
return 1;
+ if (has_sfx_atomic_write &&
+ sfx_has_atomic_write(handle, page_size))
+ return 1;
+
return 0;
}
diff --git a/plugin/feedback/feedback.cc b/plugin/feedback/feedback.cc
index 03cc4ab465a..eb3f562f329 100644
--- a/plugin/feedback/feedback.cc
+++ b/plugin/feedback/feedback.cc
@@ -409,24 +409,6 @@ static struct st_mysql_information_schema feedback =
} // namespace feedback
-mysql_declare_plugin(feedback)
-{
- MYSQL_INFORMATION_SCHEMA_PLUGIN,
- &feedback::feedback,
- "FEEDBACK",
- "Sergei Golubchik",
- "MariaDB User Feedback Plugin",
- PLUGIN_LICENSE_GPL,
- feedback::init,
- feedback::free,
- 0x0101,
- NULL,
- feedback::settings,
- NULL,
- 0
-}
-mysql_declare_plugin_end;
-#ifdef MARIA_PLUGIN_INTERFACE_VERSION
maria_declare_plugin(feedback)
{
MYSQL_INFORMATION_SCHEMA_PLUGIN,
@@ -444,4 +426,3 @@ maria_declare_plugin(feedback)
MariaDB_PLUGIN_MATURITY_STABLE
}
maria_declare_plugin_end;
-#endif
diff --git a/plugin/metadata_lock_info/metadata_lock_info.cc b/plugin/metadata_lock_info/metadata_lock_info.cc
index 46c31ca3a96..a85048de47f 100644
--- a/plugin/metadata_lock_info/metadata_lock_info.cc
+++ b/plugin/metadata_lock_info/metadata_lock_info.cc
@@ -125,7 +125,6 @@ static int i_s_metadata_lock_info_deinit(
static struct st_mysql_information_schema i_s_metadata_lock_info_plugin =
{ MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION };
-#ifdef MARIADB_BASE_VERSION
maria_declare_plugin(metadata_lock_info)
{
MYSQL_INFORMATION_SCHEMA_PLUGIN,
@@ -143,24 +142,3 @@ maria_declare_plugin(metadata_lock_info)
MariaDB_PLUGIN_MATURITY_STABLE
}
maria_declare_plugin_end;
-#else
-mysql_declare_plugin(metadata_lock_info)
-{
- MYSQL_INFORMATION_SCHEMA_PLUGIN,
- &i_s_metadata_lock_info_plugin,
- "METADATA_LOCK_INFO",
- "Kentoku Shiba",
- "Metadata locking viewer",
- PLUGIN_LICENSE_GPL,
- i_s_metadata_lock_info_init,
- i_s_metadata_lock_info_deinit,
- 0x0001,
- NULL,
- NULL,
- NULL,
-#if MYSQL_VERSION_ID >= 50600
- 0,
-#endif
-}
-mysql_declare_plugin_end;
-#endif
diff --git a/sql/datadict.cc b/sql/datadict.cc
index 5cfda166b2b..e09eee98565 100644
--- a/sql/datadict.cc
+++ b/sql/datadict.cc
@@ -49,16 +49,13 @@ static int read_string(File file, uchar**to, size_t length)
If engine_name is 0, then the function will only test if the file is a
view or not
- @param[out] is_sequence 1 if table is a SEQUENCE, 0 otherwise
-
@retval TABLE_TYPE_UNKNOWN error - file can't be opened
@retval TABLE_TYPE_NORMAL table
@retval TABLE_TYPE_SEQUENCE sequence table
@retval TABLE_TYPE_VIEW view
*/
-Table_type dd_frm_type(THD *thd, char *path, LEX_CSTRING *engine_name,
- bool *is_sequence)
+Table_type dd_frm_type(THD *thd, char *path, LEX_CSTRING *engine_name)
{
File file;
uchar header[40]; //"TYPE=VIEW\n" it is 10 characters
@@ -67,10 +64,8 @@ Table_type dd_frm_type(THD *thd, char *path, LEX_CSTRING *engine_name,
uchar dbt;
DBUG_ENTER("dd_frm_type");
- *is_sequence= 0;
-
- if ((file= mysql_file_open(key_file_frm, path, O_RDONLY | O_SHARE, MYF(0)))
- < 0)
+ file= mysql_file_open(key_file_frm, path, O_RDONLY | O_SHARE, MYF(0));
+ if (file < 0)
DBUG_RETURN(TABLE_TYPE_UNKNOWN);
/*
@@ -110,7 +105,7 @@ Table_type dd_frm_type(THD *thd, char *path, LEX_CSTRING *engine_name,
if (((header[39] >> 4) & 3) == HA_CHOICE_YES)
{
DBUG_PRINT("info", ("Sequence found"));
- *is_sequence= 1;
+ type= TABLE_TYPE_SEQUENCE;
}
/* cannot use ha_resolve_by_legacy_type without a THD */
diff --git a/sql/datadict.h b/sql/datadict.h
index cbdf788deb6..f4af592247a 100644
--- a/sql/datadict.h
+++ b/sql/datadict.h
@@ -38,13 +38,11 @@ enum Table_type
To check whether it's an frm of a view, use dd_frm_is_view().
*/
-enum Table_type dd_frm_type(THD *thd, char *path, LEX_CSTRING *engine_name,
- bool *is_sequence);
+enum Table_type dd_frm_type(THD *thd, char *path, LEX_CSTRING *engine_name);
static inline bool dd_frm_is_view(THD *thd, char *path)
{
- bool not_used2;
- return dd_frm_type(thd, path, NULL, &not_used2) == TABLE_TYPE_VIEW;
+ return dd_frm_type(thd, path, NULL) == TABLE_TYPE_VIEW;
}
bool dd_recreate_table(THD *thd, const char *db, const char *table_name);
diff --git a/sql/field.cc b/sql/field.cc
index 9b6f117a82e..e73cc380196 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -7698,7 +7698,7 @@ my_decimal *Field_varstring::val_decimal(my_decimal *decimal_value)
}
-#ifdef HAVE_valgrind_or_MSAN
+#ifdef HAVE_valgrind
void Field_varstring::mark_unused_memory_as_defined()
{
uint used_length= get_length();
diff --git a/sql/field.h b/sql/field.h
index 420ff6866bd..72c99c37fb7 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -997,7 +997,7 @@ public:
*/
virtual int store_from_statistical_minmax_field(Field *field, String *str);
-#ifdef HAVE_valgrind_or_MSAN
+#ifdef HAVE_valgrind
/**
Mark unused memory in the field as defined. Mainly used to ensure
that if we write full field to disk (for example in
@@ -4136,7 +4136,7 @@ public:
}
int store(const char *to,size_t length,CHARSET_INFO *charset) override;
using Field_str::store;
-#ifdef HAVE_valgrind_or_MSAN
+#ifdef HAVE_valgrind
void mark_unused_memory_as_defined() override;
#endif
double val_real() override;
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index dfbc8d52dcd..f5eab028755 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -811,7 +811,7 @@ create_error:
{
if (!create_partition_name(name_buff, sizeof(name_buff), path,
name_buffer_ptr, NORMAL_PART_NAME, FALSE))
- (void) (*file)->ha_delete_table((const char*) name_buff);
+ (void) (*file)->delete_table((const char*) name_buff);
name_buffer_ptr= strend(name_buffer_ptr) + 1;
}
handler::delete_table(name);
@@ -880,7 +880,7 @@ int ha_partition::drop_partitions(const char *path)
error= ret_error;
file= m_file[part];
DBUG_PRINT("info", ("Drop subpartition %s", part_name_buff));
- if (unlikely((ret_error= file->ha_delete_table(part_name_buff))))
+ if (unlikely((ret_error= file->delete_table(part_name_buff))))
error= ret_error;
if (unlikely(deactivate_ddl_log_entry(sub_elem->log_entry->
entry_pos)))
@@ -897,7 +897,7 @@ int ha_partition::drop_partitions(const char *path)
{
file= m_file[i];
DBUG_PRINT("info", ("Drop partition %s", part_name_buff));
- if (unlikely((ret_error= file->ha_delete_table(part_name_buff))))
+ if (unlikely((ret_error= file->delete_table(part_name_buff))))
error= ret_error;
if (unlikely(deactivate_ddl_log_entry(part_elem->log_entry->
entry_pos)))
@@ -989,7 +989,7 @@ int ha_partition::rename_partitions(const char *path)
NORMAL_PART_NAME))))
error= ret_error;
DBUG_PRINT("info", ("Delete subpartition %s", norm_name_buff));
- if (unlikely((ret_error= file->ha_delete_table(norm_name_buff))))
+ if (unlikely((ret_error= file->delete_table(norm_name_buff))))
error= ret_error;
else if (unlikely(deactivate_ddl_log_entry(sub_elem->log_entry->
entry_pos)))
@@ -1010,7 +1010,7 @@ int ha_partition::rename_partitions(const char *path)
else
{
DBUG_PRINT("info", ("Delete partition %s", norm_name_buff));
- if (unlikely((ret_error= file->ha_delete_table(norm_name_buff))))
+ if (unlikely((ret_error= file->delete_table(norm_name_buff))))
error= ret_error;
else if (unlikely(deactivate_ddl_log_entry(part_elem->log_entry->
entry_pos)))
@@ -1071,7 +1071,7 @@ int ha_partition::rename_partitions(const char *path)
{
file= m_reorged_file[part_count++];
DBUG_PRINT("info", ("Delete subpartition %s", norm_name_buff));
- if (unlikely((ret_error= file->ha_delete_table(norm_name_buff))))
+ if (unlikely((ret_error= file->delete_table(norm_name_buff))))
error= ret_error;
else if (unlikely(deactivate_ddl_log_entry(sub_elem->log_entry->
entry_pos)))
@@ -1118,7 +1118,7 @@ int ha_partition::rename_partitions(const char *path)
{
file= m_reorged_file[part_count++];
DBUG_PRINT("info", ("Delete partition %s", norm_name_buff));
- if (unlikely((ret_error= file->ha_delete_table(norm_name_buff))))
+ if (unlikely((ret_error= file->delete_table(norm_name_buff))))
error= ret_error;
else if (unlikely(deactivate_ddl_log_entry(part_elem->log_entry->
entry_pos)))
@@ -1670,7 +1670,7 @@ int ha_partition::prepare_new_partition(TABLE *tbl,
error_external_lock:
(void) file->ha_close();
error_open:
- (void) file->ha_delete_table(part_name);
+ (void) file->delete_table(part_name);
error_create:
DBUG_RETURN(error);
}
@@ -1716,7 +1716,7 @@ void ha_partition::cleanup_new_partition(uint part_count)
(*file)->ha_external_unlock(thd);
(*file)->ha_close();
- /* Leave the (*file)->ha_delete_table(part_name) to the ddl-log */
+ /* Leave the (*file)->delete_table(part_name) to the ddl-log */
file++;
part_count--;
@@ -2309,7 +2309,7 @@ void ha_partition::update_create_info(HA_CREATE_INFO *create_info)
@param table_arg TABLE object
@param share New share to use
- @note Is used in error handling in ha_delete_table.
+ @note Is used in error handling in delete_table.
All handlers should exist (lock_partitions should not be used)
*/
@@ -2450,7 +2450,7 @@ uint ha_partition::del_ren_table(const char *from, const char *to)
}
else // delete branch
{
- error= (*file)->ha_delete_table(from_buff);
+ error= (*file)->delete_table(from_buff);
}
name_buffer_ptr= strend(name_buffer_ptr) + 1;
if (unlikely(error))
diff --git a/sql/ha_sequence.cc b/sql/ha_sequence.cc
index bf3b5ce2cd0..596f8584041 100644
--- a/sql/ha_sequence.cc
+++ b/sql/ha_sequence.cc
@@ -439,8 +439,7 @@ static int sequence_initialize(void *p)
HTON_HIDDEN |
HTON_TEMPORARY_NOT_SUPPORTED |
HTON_ALTER_NOT_SUPPORTED |
- HTON_NO_PARTITION |
- HTON_AUTOMATIC_DELETE_TABLE);
+ HTON_NO_PARTITION);
DBUG_RETURN(0);
}
diff --git a/sql/handler.cc b/sql/handler.cc
index c2fb7da384c..ace58869145 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -45,6 +45,7 @@
#include "sql_audit.h"
#include "ha_sequence.h"
#include "rowid_filter.h"
+#include "mysys_err.h"
#ifdef WITH_PARTITION_STORAGE_ENGINE
#include "ha_partition.h"
@@ -546,6 +547,26 @@ static void update_discovery_counters(handlerton *hton, int val)
engines_with_discover+= val;
}
+int ha_drop_table(THD *thd, handlerton *hton, const char *path)
+{
+ if (ha_check_if_updates_are_ignored(thd, hton, "DROP"))
+ return 0; // Simulate dropped
+ return hton->drop_table(hton, path);
+}
+
+static int hton_drop_table(handlerton *hton, const char *path)
+{
+ char tmp_path[FN_REFLEN];
+ handler *file= get_new_handler(nullptr, current_thd->mem_root, hton);
+ if (!file)
+ return ENOMEM;
+ path= get_canonical_filename(file, path, tmp_path);
+ int error= file->delete_table(path);
+ delete file;
+ return error;
+}
+
+
int ha_finalize_handlerton(st_plugin_int *plugin)
{
handlerton *hton= (handlerton *)plugin->data;
@@ -616,6 +637,7 @@ int ha_initialize_handlerton(st_plugin_int *plugin)
hton->tablefile_extensions= no_exts;
hton->discover_table_names= hton_ext_based_table_discovery;
+ hton->drop_table= hton_drop_table;
hton->slot= HA_SLOT_UNDEF;
/* Historical Requirement */
@@ -2724,48 +2746,46 @@ const char *get_canonical_filename(handler *file, const char *path,
The .frm file should be deleted by the caller only if we return <= 0.
*/
-int ha_delete_table(THD *thd, handlerton *table_type, const char *path,
+int ha_delete_table(THD *thd, handlerton *hton, const char *path,
const LEX_CSTRING *db, const LEX_CSTRING *alias,
bool generate_warning)
{
- handler *file;
- char tmp_path[FN_REFLEN];
int error;
- TABLE dummy_table;
- TABLE_SHARE dummy_share;
bool is_error= thd->is_error();
DBUG_ENTER("ha_delete_table");
- /* table_type is NULL in ALTER TABLE when renaming only .frm files */
- if (table_type == NULL || table_type == view_pseudo_hton ||
- ! (file=get_new_handler((TABLE_SHARE*)0, thd->mem_root, table_type)))
- DBUG_RETURN(-1);
-
- bzero((char*) &dummy_table, sizeof(dummy_table));
- bzero((char*) &dummy_share, sizeof(dummy_share));
- dummy_table.s= &dummy_share;
+ /* hton is NULL in ALTER TABLE when renaming only .frm files */
+ if (hton == NULL || hton == view_pseudo_hton)
+ DBUG_RETURN(0);
- path= get_canonical_filename(file, path, tmp_path);
- if (unlikely((error= file->ha_delete_table(path))))
+ error= hton->drop_table(hton, path);
+ if (error > 0)
{
/*
It's not an error if the table doesn't exist in the engine.
warn the user, but still report DROP being a success
*/
bool intercept= non_existing_table_error(error);
- DBUG_ASSERT(error > 0);
if ((!intercept || generate_warning) && ! thd->is_error())
{
- /* Fill up strucutures that print_error may need */
- dummy_share.path.str= (char*) path;
- dummy_share.path.length= strlen(path);
- dummy_share.normalized_path= dummy_share.path;
- dummy_share.db= *db;
- dummy_share.table_name= *alias;
- dummy_table.alias.set(alias->str, alias->length, table_alias_charset);
- file->change_table_ptr(&dummy_table, &dummy_share);
- file->print_error(error, MYF(intercept ? ME_WARNING : 0));
+ TABLE dummy_table;
+ TABLE_SHARE dummy_share;
+ handler *file= get_new_handler(nullptr, thd->mem_root, hton);
+ if (file) {
+ bzero((char*) &dummy_table, sizeof(dummy_table));
+ bzero((char*) &dummy_share, sizeof(dummy_share));
+ dummy_share.path.str= (char*) path;
+ dummy_share.path.length= strlen(path);
+ dummy_share.normalized_path= dummy_share.path;
+ dummy_share.db= *db;
+ dummy_share.table_name= *alias;
+ dummy_table.s= &dummy_share;
+ dummy_table.alias.set(alias->str, alias->length, table_alias_charset);
+ file->change_table_ptr(&dummy_table, &dummy_share);
+ file->print_error(error, MYF(intercept ? ME_WARNING : 0));
+ delete file;
+ }
}
if (intercept)
{
@@ -2775,7 +2795,6 @@ int ha_delete_table(THD *thd, handlerton *table_type, const char *path,
error= -1;
}
}
- delete file;
DBUG_RETURN(error);
}
@@ -4439,23 +4458,10 @@ int handler::delete_table(const char *name)
bool some_file_deleted= 0;
DBUG_ENTER("handler::delete_table");
- // For discovery tables, it's ok if first file doesn't exists
- if (ht->discover_table)
- {
- abort_if_first_file_error= 0;
- saved_error= 0;
- if (!bas_ext())
- {
- DBUG_ASSERT(ht->flags & HTON_AUTOMATIC_DELETE_TABLE);
- DBUG_RETURN(0); // Drop succeded
- }
- }
-
for (const char **ext= bas_ext(); *ext ; ext++)
{
- int error;
- if ((error= mysql_file_delete_with_symlink(key_file_misc, name, *ext,
- MYF(0))))
+ int err= mysql_file_delete_with_symlink(key_file_misc, name, *ext, MYF(0));
+ if (err)
{
if (my_errno != ENOENT)
{
@@ -4515,7 +4521,9 @@ void handler::drop_table(const char *name)
bool non_existing_table_error(int error)
{
- return (error == ENOENT || error == HA_ERR_NO_SUCH_TABLE ||
+ return (error == ENOENT ||
+ (error == EE_DELETE && my_errno == ENOENT) ||
+ error == HA_ERR_NO_SUCH_TABLE ||
error == HA_ERR_UNSUPPORTED ||
error == ER_NO_SUCH_TABLE ||
error == ER_NO_SUCH_TABLE_IN_ENGINE ||
@@ -4586,8 +4594,8 @@ void handler::mark_trx_read_write_internal()
if (ha_info->is_started())
{
/*
- table_share can be NULL in ha_delete_table(). See implementation
- of standalone function ha_delete_table() in sql_base.cc.
+ table_share can be NULL, for example, in ha_delete_table() or
+ ha_rename_table().
*/
if (table_share == NULL || table_share->tmp_table == NO_TMP_TABLE)
ha_info->set_trx_read_write();
@@ -4948,22 +4956,6 @@ handler::ha_rename_table(const char *from, const char *to)
/**
- Delete table: public interface.
-
- @sa handler::delete_table()
-*/
-
-int
-handler::ha_delete_table(const char *name)
-{
- if (ha_check_if_updates_are_ignored(ha_thd(), ht, "DROP"))
- return 0; // Simulate dropped
- mark_trx_read_write();
- return delete_table(name);
-}
-
-
-/**
Drop table in the engine: public interface.
@sa handler::drop_table()
@@ -4994,6 +4986,7 @@ struct st_force_drop_table_params
const LEX_CSTRING *db;
const LEX_CSTRING *alias;
int error;
+ bool discovering;
};
@@ -5009,19 +5002,10 @@ static my_bool delete_table_force(THD *thd, plugin_ref plugin, void *arg)
handlerton *hton = plugin_hton(plugin);
st_force_drop_table_params *param = (st_force_drop_table_params *)arg;
- /*
- We have to ignore HEAP tables as these may not have been created yet
- We also remove engines that is using discovery (as these will recrate
- any missing .frm if needed) and tables marked with
- HTON_AUTOMATIC_DELETE_TABLE as for these we can't check if the table
- ever existed.
- */
- if (!hton->discover_table && hton->db_type != DB_TYPE_HEAP &&
- !(hton->flags & HTON_AUTOMATIC_DELETE_TABLE))
+ if (param->discovering == (hton->discover_table != NULL))
{
int error;
- error= ha_delete_table(thd, hton, param->path, param->db,
- param->alias, 0);
+ error= ha_delete_table(thd, hton, param->path, param->db, param->alias, 0);
if (error > 0 && !non_existing_table_error(error))
param->error= error;
if (error == 0)
@@ -5052,15 +5036,23 @@ int ha_delete_table_force(THD *thd, const char *path, const LEX_CSTRING *db,
Table_exists_error_handler no_such_table_handler;
DBUG_ENTER("ha_delete_table_force");
- param.path= path;
- param.db= db;
- param.alias= alias;
- param.error= -1; // Table not found
+ param.path= path;
+ param.db= db;
+ param.alias= alias;
+ param.error= -1; // Table not found
+ param.discovering= true;
thd->push_internal_handler(&no_such_table_handler);
if (plugin_foreach(thd, delete_table_force, MYSQL_STORAGE_ENGINE_PLUGIN,
&param))
param.error= 0; // Delete succeded
+ else
+ {
+ param.discovering= false;
+ if (plugin_foreach(thd, delete_table_force, MYSQL_STORAGE_ENGINE_PLUGIN,
+ &param))
+ param.error= 0; // Delete succeded
+ }
thd->pop_internal_handler();
DBUG_RETURN(param.error);
}
@@ -5846,27 +5838,28 @@ bool ha_table_exists(THD *thd, const LEX_CSTRING *db,
{
char engine_buf[NAME_CHAR_LEN + 1];
LEX_CSTRING engine= { engine_buf, 0 };
- Table_type type;
+ Table_type type= dd_frm_type(thd, path, &engine);
- if ((type= dd_frm_type(thd, path, &engine, is_sequence)) ==
- TABLE_TYPE_UNKNOWN)
- {
- DBUG_PRINT("exit", ("Does not exist"));
+ switch (type) {
+ case TABLE_TYPE_UNKNOWN:
+ DBUG_PRINT("exit", ("Exist, cannot be opened"));
DBUG_RETURN(true); // Frm exists
- }
- if (type != TABLE_TYPE_VIEW)
- {
- plugin_ref p= plugin_lock_by_name(thd, &engine,
- MYSQL_STORAGE_ENGINE_PLUGIN);
- *hton= p ? plugin_hton(p) : NULL;
- if (*hton)
+ case TABLE_TYPE_VIEW:
+ *hton= view_pseudo_hton;
+ DBUG_PRINT("exit", ("Exist, view"));
+ DBUG_RETURN(true); // Frm exists
+ case TABLE_TYPE_SEQUENCE:
+ *is_sequence= true;
+ /* fall through */
+ case TABLE_TYPE_NORMAL:
{
- // verify that the table really exists
- exists= discover_existence(thd, p, &args);
+ plugin_ref p= plugin_lock_by_name(thd, &engine,
+ MYSQL_STORAGE_ENGINE_PLUGIN);
+ *hton= p ? plugin_hton(p) : NULL;
+ if (*hton) // verify that the table really exists
+ exists= discover_existence(thd, p, &args);
}
}
- else
- *hton= view_pseudo_hton;
}
DBUG_PRINT("exit", (exists ? "Exists" : "Does not exist"));
DBUG_RETURN(exists);
diff --git a/sql/handler.h b/sql/handler.h
index 786dc7c4d43..0f72a394333 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -1484,6 +1484,12 @@ struct handlerton
void (*close_cursor_read_view)(handlerton *hton, THD *thd, void *read_view);
handler *(*create)(handlerton *hton, TABLE_SHARE *table, MEM_ROOT *mem_root);
void (*drop_database)(handlerton *hton, char* path);
+ /*
+ return 0 if dropped successfully,
+ -1 if nothing was done by design (as in e.g. blackhole)
+ an error code (e.g. HA_ERR_NO_SUCH_TABLE) otherwise
+ */
+ int (*drop_table)(handlerton *hton, const char* path);
int (*panic)(handlerton *hton, enum ha_panic_function flag);
int (*start_consistent_snapshot)(handlerton *hton, THD *thd);
bool (*flush_logs)(handlerton *hton);
@@ -1790,13 +1796,6 @@ handlerton *ha_default_tmp_handlerton(THD *thd);
*/
#define HTON_TRANSACTIONAL_AND_NON_TRANSACTIONAL (1 << 17)
-/*
- The engine doesn't keep track of tables, delete_table() is not
- needed and delete_table() always returns 0 (table deleted). This flag
- mainly used to skip storage engines in case of ha_delete_table_force()
-*/
-#define HTON_AUTOMATIC_DELETE_TABLE (1 << 18)
-
class Ha_trx_info;
struct THD_TRANS
@@ -3453,7 +3452,6 @@ public:
int ha_enable_indexes(uint mode);
int ha_discard_or_import_tablespace(my_bool discard);
int ha_rename_table(const char *from, const char *to);
- int ha_delete_table(const char *name);
void ha_drop_table(const char *name);
int ha_create(const char *name, TABLE *form, HA_CREATE_INFO *info);
@@ -4673,13 +4671,14 @@ protected:
provide useful functionality.
*/
virtual int rename_table(const char *from, const char *to);
+
+
+public:
/**
Delete a table in the engine. Called for base as well as temporary
tables.
*/
virtual int delete_table(const char *name);
-
-public:
bool check_table_binlog_row_based();
bool prepare_for_row_logging();
int prepare_for_insert(bool do_create);
diff --git a/sql/log.cc b/sql/log.cc
index abf22e7897a..5f4fd6bbcab 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -1692,6 +1692,7 @@ int binlog_init(void *p)
binlog_savepoint_rollback_can_release_mdl;
binlog_hton->commit= binlog_commit;
binlog_hton->rollback= binlog_rollback;
+ binlog_hton->drop_table= [](handlerton *, const char*) { return -1; };
if (WSREP_ON || opt_bin_log)
{
binlog_hton->prepare= binlog_prepare;
@@ -1701,10 +1702,7 @@ int binlog_init(void *p)
// recover needs to be set to make xa{commit,rollback}_handlerton effective
binlog_hton->recover= binlog_xa_recover_dummy;
}
- binlog_hton->flags= (HTON_NOT_USER_SELECTABLE |
- HTON_HIDDEN |
- HTON_NO_ROLLBACK |
- HTON_AUTOMATIC_DELETE_TABLE);
+ binlog_hton->flags= HTON_NOT_USER_SELECTABLE | HTON_HIDDEN | HTON_NO_ROLLBACK;
return 0;
}
diff --git a/sql/session_tracker.cc b/sql/session_tracker.cc
index d94ecdc2b24..4cee6cb0dfa 100644
--- a/sql/session_tracker.cc
+++ b/sql/session_tracker.cc
@@ -381,16 +381,14 @@ bool Session_sysvars_tracker::enable(THD *thd)
bool Session_sysvars_tracker::update(THD *thd, set_var *var)
{
vars_list tool_list;
- void *copy;
size_t length= 1;
- if (var->save_result.string_value.str)
- copy= my_memdup(PSI_INSTRUMENT_ME, var->save_result.string_value.str,
- (length= var->save_result.string_value.length + 1),
- MYF(MY_WME | MY_THREAD_SPECIFIC));
- else
- copy= my_strdup(PSI_INSTRUMENT_ME, "", MYF(MY_WME | MY_THREAD_SPECIFIC));
-
+ void *copy= var->save_result.string_value.str ?
+ my_memdup(PSI_INSTRUMENT_ME, var->save_result.string_value.str,
+ (length= var->save_result.string_value.length + 1),
+ MYF(MY_WME | MY_THREAD_SPECIFIC)) :
+ my_strdup(PSI_INSTRUMENT_ME, "",
+ MYF(MY_WME | MY_THREAD_SPECIFIC));
if (!copy)
return true;
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 88a28c470c0..6d53a8ee6e3 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -8794,7 +8794,7 @@ fill_record_n_invoke_before_triggers(THD *thd, TABLE *table, Field **ptr,
my_bool mysql_rm_tmp_tables(void)
{
uint i, idx;
- char filePath[FN_REFLEN], *tmpdir, filePathCopy[FN_REFLEN];
+ char path[FN_REFLEN], *tmpdir, path_copy[FN_REFLEN];
MY_DIR *dirp;
FILEINFO *file;
TABLE_SHARE share;
@@ -8823,23 +8823,17 @@ my_bool mysql_rm_tmp_tables(void)
{
char *ext= fn_ext(file->name);
size_t ext_len= strlen(ext);
- size_t filePath_len= my_snprintf(filePath, sizeof(filePath),
+ size_t path_len= my_snprintf(path, sizeof(path),
"%s%c%s", tmpdir, FN_LIBCHAR,
file->name);
if (!strcmp(reg_ext, ext))
{
- handler *handler_file= 0;
/* We should cut file extention before deleting of table */
- memcpy(filePathCopy, filePath, filePath_len - ext_len);
- filePathCopy[filePath_len - ext_len]= 0;
- init_tmp_table_share(thd, &share, "", 0, "", filePathCopy);
- if (!open_table_def(thd, &share) &&
- ((handler_file= get_new_handler(&share, thd->mem_root,
- share.db_type()))))
- {
- handler_file->ha_delete_table(filePathCopy);
- delete handler_file;
- }
+ memcpy(path_copy, path, path_len - ext_len);
+ path_copy[path_len - ext_len]= 0;
+ init_tmp_table_share(thd, &share, "", 0, "", path_copy);
+ if (!open_table_def(thd, &share))
+ share.db_type()->drop_table(share.db_type(), path_copy);
free_table_share(&share);
}
/*
@@ -8847,7 +8841,7 @@ my_bool mysql_rm_tmp_tables(void)
So we hide error messages which happnes during deleting of these
files(MYF(0)).
*/
- (void) mysql_file_delete(key_file_misc, filePath, MYF(0));
+ (void) mysql_file_delete(key_file_misc, path, MYF(0));
}
}
my_dirend(dirp);
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index c3e301cd39d..2869011e313 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -2029,8 +2029,8 @@ int READ_INFO::read_xml(THD *thd)
case '=': /* attribute name end - read the value */
//check for tag field and attribute name
- if(!memcmp(tag.c_ptr_safe(), STRING_WITH_LEN("field")) &&
- !memcmp(attribute.c_ptr_safe(), STRING_WITH_LEN("name")))
+ if(!strcmp(tag.c_ptr_safe(), "field") &&
+ !strcmp(attribute.c_ptr_safe(), "name"))
{
/*
this is format <field name="xx">xx</field>
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 167aefee7a6..8d074e13d1f 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -5058,6 +5058,12 @@ mysql_execute_command(THD *thd)
if (res)
goto error;
+#ifdef WITH_WSREP
+ /* Clean up the previous transaction on implicit commit. */
+ if (wsrep_on(thd) && !wsrep_not_committed(thd) && wsrep_after_statement(thd))
+ goto error;
+#endif
+
/* We can't have any kind of table locks while backup is active */
if (thd->current_backup_stage != BACKUP_FINISHED)
{
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc
index 4750be99d30..4526cac5af1 100644
--- a/sql/sql_plugin.cc
+++ b/sql/sql_plugin.cc
@@ -1720,8 +1720,7 @@ int plugin_init(int *argc, char **argv, int flags)
{
char path[FN_REFLEN + 1];
build_table_filename(path, sizeof(path) - 1, "mysql", "plugin", reg_ext, 0);
- bool dummy;
- Table_type ttype= dd_frm_type(0, path, &plugin_table_engine_name, &dummy);
+ Table_type ttype= dd_frm_type(0, path, &plugin_table_engine_name);
if (ttype != TABLE_TYPE_NORMAL)
plugin_table_engine_name=empty_clex_str;
}
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 896e7fdf5e7..fc9fea42a99 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -6562,6 +6562,7 @@ add_ft_keys(DYNAMIC_ARRAY *keyuse_array,
keyuse.keypart= FT_KEYPART;
keyuse.used_tables=cond_func->key_item()->used_tables();
keyuse.optimize= 0;
+ keyuse.ref_table_rows= 0;
keyuse.keypart_map= 0;
keyuse.sj_pred_no= UINT_MAX;
keyuse.validity_ref= 0;
@@ -18641,17 +18642,15 @@ bool Create_tmp_table::finalize(THD *thd,
uint null_pack_length[2];
uint null_pack_base[2];
uint null_counter[2]= {0, 0};
-
uint whole_null_pack_length;
-
bool use_packed_rows= false;
+ bool save_abort_on_warning;
uchar *pos;
uchar *null_flags;
KEY *keyinfo;
TMP_ENGINE_COLUMNDEF *recinfo;
TABLE_SHARE *share= table->s;
Copy_field *copy= param->copy_field;
-
MEM_ROOT *mem_root_save= thd->mem_root;
thd->mem_root= &table->mem_root;
@@ -18752,6 +18751,11 @@ bool Create_tmp_table::finalize(THD *thd,
{
null_counter[(m_field_count[other] ? other : distinct)]++;
}
+
+ /* Protect against warnings in field_conv() in the next loop*/
+ save_abort_on_warning= thd->abort_on_warning;
+ thd->abort_on_warning= 0;
+
for (uint i= 0; i < share->fields; i++, recinfo++)
{
Field *field= table->field[i];
@@ -18795,25 +18799,31 @@ bool Create_tmp_table::finalize(THD *thd,
inherit the default value that is defined for the field referred
by the Item_field object from which 'field' has been created.
*/
- const Field *orig_field= m_default_field[i];
+ Field *orig_field= m_default_field[i];
/* Get the value from default_values */
if (orig_field->is_null_in_record(orig_field->table->s->default_values))
field->set_null();
else
{
+ /*
+ Copy default value. We have to use field_conv() for copy, instead of
+ memcpy(), because bit_fields may be stored differently
+ */
+ my_ptrdiff_t ptr_diff= (orig_field->table->s->default_values -
+ orig_field->table->record[0]);
field->set_notnull();
- memcpy(field->ptr,
- orig_field->ptr_in_record(orig_field->table->s->default_values),
- field->pack_length_in_rec());
+ orig_field->move_field_offset(ptr_diff);
+ field_conv(field, orig_field);
+ orig_field->move_field_offset(-ptr_diff);
}
- }
+ }
if (m_from_field[i])
{ /* Not a table Item */
copy->set(field, m_from_field[i], m_save_sum_fields);
copy++;
}
- length=field->pack_length();
+ length=field->pack_length_in_rec();
pos+= length;
/* Make entry for create table */
@@ -18823,7 +18833,11 @@ bool Create_tmp_table::finalize(THD *thd,
// fix table name in field entry
field->set_table_name(&table->alias);
}
+ /* Handle group_null_items */
+ bzero(pos, table->s->reclength - (pos - table->record[0]));
+ MEM_CHECK_DEFINED(table->record[0], table->s->reclength);
+ thd->abort_on_warning= save_abort_on_warning;
param->copy_field_end= copy;
param->recinfo= recinfo; // Pointer to after last field
store_record(table,s->default_values); // Make empty default record
@@ -19086,8 +19100,9 @@ bool Create_tmp_table::finalize(THD *thd,
goto err;
}
- // Make empty record so random data is not written to disk
- empty_record(table);
+ /* record[0] and share->default_values should now have been set up */
+ MEM_CHECK_DEFINED(table->record[0], table->s->reclength);
+ MEM_CHECK_DEFINED(share->default_values, table->s->reclength);
thd->mem_root= mem_root_save;
@@ -19483,7 +19498,11 @@ bool create_internal_tmp_table(TABLE *table, KEY *keyinfo,
(*recinfo)->type= FIELD_CHECK;
(*recinfo)->length= MARIA_UNIQUE_HASH_LENGTH;
(*recinfo)++;
- share->reclength+= MARIA_UNIQUE_HASH_LENGTH;
+
+ /* Avoid warnings from valgrind */
+ bzero(table->record[0]+ share->reclength, MARIA_UNIQUE_HASH_LENGTH);
+ bzero(share->default_values+ share->reclength, MARIA_UNIQUE_HASH_LENGTH);
+ share->reclength+= MARIA_UNIQUE_HASH_LENGTH;
}
else
{
@@ -19677,7 +19696,10 @@ bool create_internal_tmp_table(TABLE *table, KEY *keyinfo,
(*recinfo)->type= FIELD_CHECK;
(*recinfo)->length=MI_UNIQUE_HASH_LENGTH;
(*recinfo)++;
- share->reclength+=MI_UNIQUE_HASH_LENGTH;
+ /* Avoid warnings from valgrind */
+ bzero(table->record[0]+ share->reclength, MI_UNIQUE_HASH_LENGTH);
+ bzero(share->default_values+ share->reclength, MI_UNIQUE_HASH_LENGTH);
+ share->reclength+= MI_UNIQUE_HASH_LENGTH;
}
else
{
@@ -19780,8 +19802,7 @@ create_internal_tmp_table_from_heap(THD *thd, TABLE *table,
if (is_duplicate)
*is_duplicate= FALSE;
- if (table->s->db_type() != heap_hton ||
- error != HA_ERR_RECORD_FILE_FULL)
+ if (table->s->db_type() != heap_hton || error != HA_ERR_RECORD_FILE_FULL)
{
/*
We don't want this error to be converted to a warning, e.g. in case of
@@ -19795,7 +19816,7 @@ create_internal_tmp_table_from_heap(THD *thd, TABLE *table,
new_table.s= &share;
new_table.s->db_plugin= ha_lock_engine(thd, TMP_ENGINE_HTON);
if (unlikely(!(new_table.file= get_new_handler(&share, &new_table.mem_root,
- new_table.s->db_type()))))
+ TMP_ENGINE_HTON))))
DBUG_RETURN(1); // End of memory
if (unlikely(new_table.file->set_ha_share_ref(&share.ha_share)))
@@ -19886,7 +19907,7 @@ err_killed:
(void) table->file->ha_rnd_end();
(void) new_table.file->ha_close();
err1:
- new_table.file->ha_delete_table(new_table.s->path.str);
+ TMP_ENGINE_HTON->drop_table(TMP_ENGINE_HTON, new_table.s->path.str);
err2:
delete new_table.file;
thd_proc_info(thd, save_proc_info);
@@ -19909,16 +19930,12 @@ free_tmp_table(THD *thd, TABLE *entry)
if (entry->file && entry->is_created())
{
+ DBUG_ASSERT(entry->db_stat);
entry->file->ha_index_or_rnd_end();
- if (entry->db_stat)
- {
- entry->file->info(HA_STATUS_VARIABLE);
- thd->tmp_tables_size+= (entry->file->stats.data_file_length +
- entry->file->stats.index_file_length);
- entry->file->ha_drop_table(entry->s->path.str);
- }
- else
- entry->file->ha_delete_table(entry->s->path.str);
+ entry->file->info(HA_STATUS_VARIABLE);
+ thd->tmp_tables_size+= (entry->file->stats.data_file_length +
+ entry->file->stats.index_file_length);
+ entry->file->ha_drop_table(entry->s->path.str);
delete entry->file;
}
@@ -20269,11 +20286,11 @@ bool instantiate_tmp_table(TABLE *table, KEY *keyinfo,
If it is not heap (in-memory) table then convert index to unique
constrain.
*/
+ MEM_CHECK_DEFINED(table->record[0], table->s->reclength);
if (create_internal_tmp_table(table, keyinfo, start_recinfo, recinfo,
options))
return TRUE;
- // Make empty record so random data is not written to disk
- empty_record(table);
+ MEM_CHECK_DEFINED(table->record[0], table->s->reclength);
}
if (open_tmp_table(table))
return TRUE;
@@ -28795,7 +28812,6 @@ AGGR_OP::prepare_tmp_table()
join->select_options))
return true;
(void) table->file->extra(HA_EXTRA_WRITE_CACHE);
- empty_record(table);
}
/* If it wasn't already, start index scan for grouping using table index. */
if (!table->file->inited && table->group &&
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 5eb2d911926..64076197cf8 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -4479,8 +4479,7 @@ static void get_table_engine_for_i_s(THD *thd, char *buf, TABLE_LIST *tl,
char path[FN_REFLEN];
build_table_filename(path, sizeof(path) - 1,
db->str, table->str, reg_ext, 0);
- bool is_sequence;
- if (dd_frm_type(thd, path, &engine_name, &is_sequence) == TABLE_TYPE_NORMAL)
+ if (dd_frm_type(thd, path, &engine_name) == TABLE_TYPE_NORMAL)
tl->option= engine_name.str;
}
}
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index f091fd29303..87257bc9ab4 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -1168,7 +1168,7 @@ static int execute_ddl_log_action(THD *thd, DDL_LOG_ENTRY *ddl_log_entry)
}
else
{
- if (unlikely((error= file->ha_delete_table(ddl_log_entry->name))))
+ if (unlikely((error= hton->drop_table(hton, ddl_log_entry->name))))
{
if (!non_existing_table_error(error))
break;
@@ -2236,10 +2236,9 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
bool dont_free_locks)
{
TABLE_LIST *table;
- char path[FN_REFLEN + 1], unknown_tables_buff[160];
+ char path[FN_REFLEN + 1];
LEX_CSTRING alias= null_clex_str;
- String unknown_tables(unknown_tables_buff, sizeof(unknown_tables_buff)-1,
- system_charset_info);
+ StringBuffer<160> unknown_tables(system_charset_info);
uint not_found_errors= 0;
int error= 0;
int non_temp_tables_count= 0;
@@ -2247,7 +2246,7 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
bool trans_tmp_table_deleted= 0, non_trans_tmp_table_deleted= 0;
bool non_tmp_table_deleted= 0;
bool is_drop_tmp_if_exists_added= 0;
- bool was_view= 0, was_table= 0, is_sequence, log_if_exists= if_exists;
+ bool was_view= 0, was_table= 0, log_if_exists= if_exists;
const char *object_to_drop= (drop_sequence) ? "SEQUENCE" : "TABLE";
String normal_tables;
String built_trans_tmp_query, built_non_trans_tmp_query;
@@ -2307,18 +2306,20 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
for (table= tables; table; table= table->next_local)
{
- bool is_trans= 0, frm_was_deleted= 0, temporary_table_was_dropped= 0;
- bool table_creation_was_logged= 0, trigger_drop_executed= 0;
- bool local_non_tmp_error= 0, frm_exists= 0, wrong_drop_sequence= 0;
+ bool is_trans= 0, temporary_table_was_dropped= 0;
+ bool table_creation_was_logged= 0;
+ bool local_non_tmp_error= 0, wrong_drop_sequence= 0;
bool table_dropped= 0;
- LEX_CSTRING db= table->db;
- handlerton *table_type= 0;
+ const LEX_CSTRING db= table->db;
+ const LEX_CSTRING table_name= table->table_name;
+ handlerton *hton= 0;
+ Table_type table_type;
size_t path_length= 0;
char *path_end= 0;
error= 0;
DBUG_PRINT("table", ("table_l: '%s'.'%s' table: %p s: %p",
- table->db.str, table->table_name.str, table->table,
+ db.str, table_name.str, table->table,
table->table ? table->table->s : NULL));
/*
@@ -2337,17 +2338,12 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
{
table_creation_was_logged= table->table->s->table_creation_was_logged;
if (thd->drop_temporary_table(table->table, &is_trans, true))
- {
- /*
- This is a very unlikely scenaro as dropping a temporary table
- should always work. Would be better if we tried to drop all
- temporary tables before giving the error.
- */
error= 1;
- goto err;
+ else
+ {
+ table->table= 0;
+ temporary_table_was_dropped= 1;
}
- table->table= 0;
- temporary_table_was_dropped= 1;
}
if ((drop_temporary && if_exists) || temporary_table_was_dropped)
@@ -2363,14 +2359,6 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
*/
if (!dont_log_query && table_creation_was_logged)
{
- /*
- DROP TEMPORARY succeded. For the moment when we only come
- here on success (error == 0)
-
- If there is an error, we don't know the type of the engine
- at this point. So, we keep it in the trx-cache.
- */
- is_trans= error ? TRUE : is_trans;
if (is_trans)
trans_tmp_table_deleted= TRUE;
else
@@ -2389,7 +2377,7 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
append_identifier(thd, built_ptr_query, &db);
built_ptr_query->append(".");
}
- append_identifier(thd, built_ptr_query, &table->table_name);
+ append_identifier(thd, built_ptr_query, &table_name);
built_ptr_query->append(",");
}
/*
@@ -2404,11 +2392,10 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
{
non_temp_tables_count++;
- DBUG_ASSERT(thd->mdl_context.is_lock_owner(MDL_key::TABLE, table->db.str,
- table->table_name.str,
- MDL_SHARED));
+ DBUG_ASSERT(thd->mdl_context.is_lock_owner(MDL_key::TABLE, db.str,
+ table_name.str, MDL_SHARED));
- alias= (lower_case_table_names == 2) ? table->alias : table->table_name;
+ alias= (lower_case_table_names == 2) ? table->alias : table_name;
/* remove .frm file and engine files */
path_length= build_table_filename(path, sizeof(path) - 1, db.str,
alias.str, reg_ext, 0);
@@ -2416,17 +2403,35 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
}
DEBUG_SYNC(thd, "rm_table_no_locks_before_delete_table");
- error= 0;
if (drop_temporary)
{
/* "DROP TEMPORARY" but a temporary table was not found */
+ unknown_tables.append(&db);
+ unknown_tables.append('.');
+ unknown_tables.append(&table_name);
+ unknown_tables.append(',');
error= ENOENT;
+ not_found_errors++;
+ continue;
+ }
+
+ {
+ char engine_buf[NAME_CHAR_LEN + 1];
+ LEX_CSTRING engine= { engine_buf, 0 };
+
+ table_type= dd_frm_type(thd, path, &engine);
+ if (table_type == TABLE_TYPE_NORMAL || table_type == TABLE_TYPE_SEQUENCE)
+ {
+ plugin_ref p= plugin_lock_by_name(thd, &engine,
+ MYSQL_STORAGE_ENGINE_PLUGIN);
+ hton= p ? plugin_hton(p) : NULL;
+ }
+ // note that for TABLE_TYPE_VIEW and TABLE_TYPE_UNKNOWN hton == NULL
}
- else if (((frm_exists= ha_table_exists(thd, &db, &alias, &table_type,
- &is_sequence)) == 0 &&
- table_type == 0) ||
- (!drop_view && (was_view= (table_type == view_pseudo_hton))) ||
- (drop_sequence && !is_sequence))
+
+ was_view= table_type == TABLE_TYPE_VIEW;
+ if ((table_type == TABLE_TYPE_UNKNOWN) || (was_view && !drop_view) ||
+ (table_type != TABLE_TYPE_SEQUENCE && drop_sequence))
{
/*
One of the following cases happened:
@@ -2434,36 +2439,18 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
. "DROP TABLE" statement, but it's a view.
. "DROP SEQUENCE", but it's not a sequence
*/
- wrong_drop_sequence= drop_sequence && table_type;
+ wrong_drop_sequence= drop_sequence && hton;
was_table|= wrong_drop_sequence;
local_non_tmp_error= 1;
- error= -1;
- if ((!frm_exists && !table_type)) // no .frm
- error= ENOENT;
+ error= table_type == TABLE_TYPE_UNKNOWN ? ENOENT : -1;
}
else
{
-#ifdef WITH_WSREP
- if (WSREP(thd) &&
- !wsrep_should_replicate_ddl(thd, table_type->db_type))
+ if (WSREP(thd) && hton && !wsrep_should_replicate_ddl(thd, hton->db_type))
{
error= 1;
goto err;
}
-#endif
-
- /*
- It could happen that table's share in the table definition cache
- is the only thing that keeps the engine plugin loaded
- (if it is uninstalled and waits for the ref counter to drop to 0).
-
- In this case, the tdc_remove_table() below will release and unload
- the plugin. And ha_delete_table() will get a dangling pointer.
-
- Let's lock the plugin till the end of the statement.
- */
- if (table_type && table_type != view_pseudo_hton)
- ha_lock_engine(thd, table_type);
if (thd->locked_tables_mode == LTM_LOCK_TABLES ||
thd->locked_tables_mode == LTM_PRELOCKED_UNDER_LOCK_TABLES)
@@ -2478,23 +2465,21 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
table->table= 0;
}
else
- tdc_remove_table(thd, table->db.str, table->table_name.str);
+ tdc_remove_table(thd, db.str, table_name.str);
/* Check that we have an exclusive lock on the table to be dropped. */
- DBUG_ASSERT(thd->mdl_context.is_lock_owner(MDL_key::TABLE, table->db.str,
- table->table_name.str,
- MDL_EXCLUSIVE));
+ DBUG_ASSERT(thd->mdl_context.is_lock_owner(MDL_key::TABLE, db.str,
+ table_name.str, MDL_EXCLUSIVE));
// Remove extension for delete
*path_end= '\0';
- if (table_type && table_type != view_pseudo_hton &&
- table_type->flags & HTON_TABLE_MAY_NOT_EXIST_ON_SLAVE)
+ if (hton && hton->flags & HTON_TABLE_MAY_NOT_EXIST_ON_SLAVE)
log_if_exists= 1;
thd->replication_flags= 0;
- error= ha_delete_table(thd, table_type, path, &db,
- &table->table_name, !dont_log_query);
+ bool enoent_warning= !dont_log_query && !(hton && hton->discover_table);
+ error= ha_delete_table(thd, hton, path, &db, &table_name, enoent_warning);
if (!error)
table_dropped= 1;
@@ -2522,8 +2507,7 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
{
int frm_delete_error= 0;
/* Delete the table definition file */
- if (table_type && table_type != view_pseudo_hton &&
- (table_type->discover_table || error))
+ if (hton && (hton->discover_table || error))
{
/*
Table type is using discovery and may not need a .frm file
@@ -2541,7 +2525,6 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
frm_delete_error= my_errno;
DBUG_ASSERT(frm_delete_error);
}
- frm_was_deleted= 1; // We tried to delete .frm
if (frm_delete_error)
{
@@ -2554,16 +2537,6 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
table_dropped= 1;
}
}
- if (likely(!error) || non_existing_table_error(error))
- {
- trigger_drop_executed= 1;
-
- if (Table_triggers_list::drop_all_triggers(thd, &db,
- &table->table_name,
- MYF(MY_WME |
- MY_IGNORE_ENOENT)))
- error= error ? error : -1;
- }
local_non_tmp_error|= MY_TEST(error);
}
@@ -2571,20 +2544,15 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
If there was no .frm file and the table is not temporary,
scan all engines try to drop the table from there.
This is to ensure we don't have any partial table files left.
-
- We check for trigger_drop_executed to ensure we don't again try
- to drop triggers when it failed above (after sucecssfully dropping
- the table).
*/
- if (non_existing_table_error(error) && !drop_temporary &&
- table_type != view_pseudo_hton && !trigger_drop_executed &&
- !wrong_drop_sequence)
+ if (non_existing_table_error(error) && !wrong_drop_sequence)
{
int ferror= 0;
+ DBUG_ASSERT(!was_view);
/* Remove extension for delete */
*path_end= '\0';
- ferror= ha_delete_table_force(thd, path, &db, &table->table_name);
+ ferror= ha_delete_table_force(thd, path, &db, &table_name);
if (!ferror)
{
/* Table existed and was deleted */
@@ -2596,35 +2564,32 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
{
ferror= 0; // Ignore table not found
- /* Delete the table definition file */
- if (!frm_was_deleted)
- {
- strmov(path_end, reg_ext);
- if (mysql_file_delete(key_file_frm, path,
- MYF(MY_WME | MY_IGNORE_ENOENT)))
- ferror= my_errno;
- }
- if (Table_triggers_list::drop_all_triggers(thd, &db,
- &table->table_name,
- MYF(MY_WME |
- MY_IGNORE_ENOENT)))
- ferror= -1;
+ /* Delete the frm file again (just in case it was rediscovered) */
+ strmov(path_end, reg_ext);
+ if (mysql_file_delete(key_file_frm, path, MYF(MY_WME|MY_IGNORE_ENOENT)))
+ ferror= my_errno;
}
if (!error)
error= ferror;
}
+ if (likely(!error) || non_existing_table_error(error))
+ {
+ if (Table_triggers_list::drop_all_triggers(thd, &db, &table_name,
+ MYF(MY_WME | MY_IGNORE_ENOENT)))
+ error= error ? error : -1;
+ }
+
if (error)
{
- char buff[FN_REFLEN];
- String tbl_name(buff, sizeof(buff), system_charset_info);
+ StringBuffer<FN_REFLEN> tbl_name(system_charset_info);
uint is_note= (if_exists && (was_view || wrong_drop_sequence) ?
ME_NOTE : 0);
tbl_name.length(0);
tbl_name.append(&db);
tbl_name.append('.');
- tbl_name.append(&table->table_name);
+ tbl_name.append(&table_name);
if (!non_existing_table_error(error) || is_note)
{
@@ -2665,13 +2630,12 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
if (!error && table_dropped)
{
PSI_CALL_drop_table_share(temporary_table_was_dropped,
- table->db.str, (uint)table->db.length,
- table->table_name.str,
- (uint)table->table_name.length);
+ db.str, (uint)db.length,
+ table_name.str, (uint)table_name.length);
mysql_audit_drop_table(thd, table);
}
- if (!dont_log_query && !drop_temporary &&
+ if (!dont_log_query &&
(!error || table_dropped || non_existing_table_error(error)))
{
non_tmp_table_deleted|= (if_exists || table_dropped);
@@ -2685,7 +2649,7 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
normal_tables.append(".");
}
- append_identifier(thd, &normal_tables, &table->table_name);
+ append_identifier(thd, &normal_tables, &table_name);
normal_tables.append(",");
}
DBUG_PRINT("table", ("table: %p s: %p", table->table,
diff --git a/sql/table.cc b/sql/table.cc
index 9e7592e4b97..32d0ee6f538 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -2109,8 +2109,8 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
share->rec_buff_length= rec_buff_length;
if (!(record= (uchar *) alloc_root(&share->mem_root, rec_buff_length)))
goto err; /* purecov: inspected */
- MEM_NOACCESS(record, rec_buff_length);
- MEM_UNDEFINED(record, share->reclength);
+ /* Mark bytes after record as not accessable to catch overrun bugs */
+ MEM_NOACCESS(record + share->reclength, rec_buff_length - share->reclength);
share->default_values= record;
memcpy(record, frm_image + record_offset, share->reclength);
@@ -3959,7 +3959,6 @@ enum open_frm_error open_table_from_share(THD *thd, TABLE_SHARE *share,
if (!(record= (uchar*) alloc_root(&outparam->mem_root,
share->rec_buff_length * records)))
goto err; /* purecov: inspected */
- MEM_NOACCESS(record, share->rec_buff_length * records);
}
for (i= 0; i < 3;)
@@ -3968,8 +3967,10 @@ enum open_frm_error open_table_from_share(THD *thd, TABLE_SHARE *share,
if (++i < records)
record+= share->rec_buff_length;
}
+ /* Mark bytes between records as not accessable to catch overrun bugs */
for (i= 0; i < records; i++)
- MEM_UNDEFINED(outparam->record[i], share->reclength);
+ MEM_NOACCESS(outparam->record[i] + share->reclength,
+ share->rec_buff_length - share->reclength);
if (!(field_ptr = (Field **) alloc_root(&outparam->mem_root,
(uint) ((share->fields+1)*
@@ -9921,7 +9922,7 @@ bool TABLE::export_structure(THD *thd, Row_definition_list *defs)
return false;
}
-/*
+/**
@brief
Initialize all the opt_range structures that are used to stored the
estimates when the range optimizer is run.
@@ -9930,7 +9931,7 @@ bool TABLE::export_structure(THD *thd, Row_definition_list *defs)
to be able to find wrong usage of data with valgrind or MSAN.
*/
-void TABLE::initialize_opt_range_structures()
+inline void TABLE::initialize_opt_range_structures()
{
TRASH_ALLOC((void*)&opt_range_keys, sizeof(opt_range_keys));
TRASH_ALLOC(opt_range, s->keys * sizeof(*opt_range));
diff --git a/sql/table.h b/sql/table.h
index c0397dd9590..94c08fdce4b 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -1637,7 +1637,8 @@ public:
bool is_filled_at_execution();
bool update_const_key_parts(COND *conds);
- void initialize_opt_range_structures();
+
+ inline void initialize_opt_range_structures();
my_ptrdiff_t default_values_offset() const
{ return (my_ptrdiff_t) (s->default_values - record[0]); }
diff --git a/sql/temporary_tables.cc b/sql/temporary_tables.cc
index a8d8113945b..1a8b5c471bd 100644
--- a/sql/temporary_tables.cc
+++ b/sql/temporary_tables.cc
@@ -694,23 +694,19 @@ bool THD::rm_temporary_table(handlerton *base, const char *path)
DBUG_ENTER("THD::rm_temporary_table");
bool error= false;
- handler *file;
char frm_path[FN_REFLEN + 1];
strxnmov(frm_path, sizeof(frm_path) - 1, path, reg_ext, NullS);
if (mysql_file_delete(key_file_frm, frm_path,
MYF(MY_WME | MY_IGNORE_ENOENT)))
error= true;
-
- file= get_new_handler((TABLE_SHARE*) 0, current_thd->mem_root, base);
- if (file && file->ha_delete_table(path))
+ if (base->drop_table(base, path) > 0)
{
error= true;
sql_print_warning("Could not remove temporary table: '%s', error: %d",
path, my_errno);
}
- delete file;
DBUG_RETURN(error);
}
diff --git a/sql/unireg.cc b/sql/unireg.cc
index fa193a7712d..525e7a8a56a 100644
--- a/sql/unireg.cc
+++ b/sql/unireg.cc
@@ -592,8 +592,8 @@ LEX_CUSTRING build_frm_image(THD *thd, const LEX_CSTRING &table,
pos+= create_info->comment.length;
}
- memcpy(frm_ptr + filepos, forminfo, 288);
- pos= frm_ptr + filepos + 288;
+ memcpy(frm_ptr + filepos, forminfo, FRM_FORMINFO_SIZE);
+ pos= frm_ptr + filepos + FRM_FORMINFO_SIZE;
if (pack_fields(&pos, create_fields, create_info, data_offset))
goto err;
diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h
index 3347a94cdd6..51c23085717 100644
--- a/sql/wsrep_mysqld.h
+++ b/sql/wsrep_mysqld.h
@@ -627,6 +627,7 @@ enum wsrep::streaming_context::fragment_unit wsrep_fragment_unit(ulong unit);
#define wsrep_thr_deinit() do {} while(0)
#define wsrep_init_globals() do {} while(0)
#define wsrep_create_appliers(X) do {} while(0)
+#define wsrep_should_replicate_ddl(X,Y) (1)
#endif /* WITH_WSREP */
diff --git a/storage/blackhole/ha_blackhole.cc b/storage/blackhole/ha_blackhole.cc
index 98589f1d043..0134032351e 100644
--- a/storage/blackhole/ha_blackhole.cc
+++ b/storage/blackhole/ha_blackhole.cc
@@ -399,7 +399,8 @@ static int blackhole_init(void *p)
blackhole_hton= (handlerton *)p;
blackhole_hton->db_type= DB_TYPE_BLACKHOLE_DB;
blackhole_hton->create= blackhole_create_handler;
- blackhole_hton->flags= HTON_CAN_RECREATE | HTON_AUTOMATIC_DELETE_TABLE;
+ blackhole_hton->drop_table= [](handlerton *, const char*) { return -1; };
+ blackhole_hton->flags= HTON_CAN_RECREATE;
mysql_mutex_init(bh_key_mutex_blackhole,
&blackhole_mutex, MY_MUTEX_INIT_FAST);
@@ -422,23 +423,6 @@ static int blackhole_fini(void *p)
struct st_mysql_storage_engine blackhole_storage_engine=
{ MYSQL_HANDLERTON_INTERFACE_VERSION };
-mysql_declare_plugin(blackhole)
-{
- MYSQL_STORAGE_ENGINE_PLUGIN,
- &blackhole_storage_engine,
- "BLACKHOLE",
- "MySQL AB",
- "/dev/null storage engine (anything you write to it disappears)",
- PLUGIN_LICENSE_GPL,
- blackhole_init, /* Plugin Init */
- blackhole_fini, /* Plugin Deinit */
- 0x0100 /* 1.0 */,
- NULL, /* status variables */
- NULL, /* system variables */
- NULL, /* config options */
- 0, /* flags */
-}
-mysql_declare_plugin_end;
maria_declare_plugin(blackhole)
{
MYSQL_STORAGE_ENGINE_PLUGIN,
diff --git a/storage/example/ha_example.cc b/storage/example/ha_example.cc
index 3bfe1e5e27b..30484a41087 100644
--- a/storage/example/ha_example.cc
+++ b/storage/example/ha_example.cc
@@ -215,6 +215,8 @@ static void init_example_psi_keys()
count= array_elements(all_example_mutexes);
mysql_mutex_register(category, all_example_mutexes, count);
}
+#else
+static void init_example_psi_keys() { }
#endif
@@ -252,9 +254,7 @@ static int example_init_func(void *p)
{
DBUG_ENTER("example_init_func");
-#ifdef HAVE_PSI_INTERFACE
init_example_psi_keys();
-#endif
example_hton= (handlerton *)p;
example_hton->create= example_create_handler;
@@ -262,6 +262,7 @@ static int example_init_func(void *p)
example_hton->table_options= example_table_option_list;
example_hton->field_options= example_field_option_list;
example_hton->tablefile_extensions= ha_example_exts;
+ example_hton->drop_table= [](handlerton *, const char*) { return 0; };
DBUG_RETURN(0);
}
@@ -1093,23 +1094,6 @@ static struct st_mysql_show_var func_status[]=
struct st_mysql_daemon unusable_example=
{ MYSQL_DAEMON_INTERFACE_VERSION };
-mysql_declare_plugin(example)
-{
- MYSQL_STORAGE_ENGINE_PLUGIN,
- &example_storage_engine,
- "EXAMPLE",
- "Brian Aker, MySQL AB",
- "Example storage engine",
- PLUGIN_LICENSE_GPL,
- example_init_func, /* Plugin Init */
- NULL, /* Plugin Deinit */
- 0x0001 /* 0.1 */,
- func_status, /* status variables */
- example_system_variables, /* system variables */
- NULL, /* config options */
- 0, /* flags */
-}
-mysql_declare_plugin_end;
maria_declare_plugin(example)
{
MYSQL_STORAGE_ENGINE_PLUGIN,
diff --git a/storage/federated/ha_federated.cc b/storage/federated/ha_federated.cc
index b62b74d12bb..871a254f8c0 100644
--- a/storage/federated/ha_federated.cc
+++ b/storage/federated/ha_federated.cc
@@ -484,8 +484,8 @@ int federated_db_init(void *p)
federated_hton->commit= federated_commit;
federated_hton->rollback= federated_rollback;
federated_hton->create= federated_create_handler;
- federated_hton->flags= (HTON_ALTER_NOT_SUPPORTED | HTON_NO_PARTITION |
- HTON_AUTOMATIC_DELETE_TABLE);
+ federated_hton->drop_table= [](handlerton *, const char*) { return -1; };
+ federated_hton->flags= HTON_ALTER_NOT_SUPPORTED | HTON_NO_PARTITION;
/*
Support for transactions disabled until WL#2952 fixes it.
@@ -3389,23 +3389,6 @@ int ha_federated::execute_simple_query(const char *query, int len)
struct st_mysql_storage_engine federated_storage_engine=
{ MYSQL_HANDLERTON_INTERFACE_VERSION };
-mysql_declare_plugin(federated)
-{
- MYSQL_STORAGE_ENGINE_PLUGIN,
- &federated_storage_engine,
- "FEDERATED",
- "Patrick Galbraith and Brian Aker, MySQL AB",
- "Federated MySQL storage engine",
- PLUGIN_LICENSE_GPL,
- federated_db_init, /* Plugin Init */
- federated_done, /* Plugin Deinit */
- 0x0100 /* 1.0 */,
- NULL, /* status variables */
- NULL, /* system variables */
- NULL, /* config options */
- 0, /* flags */
-}
-mysql_declare_plugin_end;
maria_declare_plugin(federated)
{
MYSQL_STORAGE_ENGINE_PLUGIN,
diff --git a/storage/federatedx/ha_federatedx.cc b/storage/federatedx/ha_federatedx.cc
index 2370473236e..dfcbf156f88 100644
--- a/storage/federatedx/ha_federatedx.cc
+++ b/storage/federatedx/ha_federatedx.cc
@@ -438,8 +438,8 @@ int federatedx_db_init(void *p)
federatedx_hton->rollback= ha_federatedx::rollback;
federatedx_hton->discover_table_structure= ha_federatedx::discover_assisted;
federatedx_hton->create= federatedx_create_handler;
- federatedx_hton->flags= (HTON_ALTER_NOT_SUPPORTED |
- HTON_AUTOMATIC_DELETE_TABLE);
+ federatedx_hton->drop_table= [](handlerton *, const char*) { return -1; };
+ federatedx_hton->flags= HTON_ALTER_NOT_SUPPORTED;
federatedx_hton->create_derived= create_federatedx_derived_handler;
federatedx_hton->create_select= create_federatedx_select_handler;
diff --git a/storage/heap/ha_heap.cc b/storage/heap/ha_heap.cc
index ee2c9f0d916..895b6edfcf2 100644
--- a/storage/heap/ha_heap.cc
+++ b/storage/heap/ha_heap.cc
@@ -34,24 +34,29 @@ heap_prepare_hp_create_info(TABLE *table_arg, bool internal_table,
HP_CREATE_INFO *hp_create_info);
-int heap_panic(handlerton *hton, ha_panic_function flag)
+static int heap_panic(handlerton *hton, ha_panic_function flag)
{
return hp_panic(flag);
}
+static int heap_drop_table(handlerton *hton, const char *path)
+{
+ int error= heap_delete_table(path);
+ return error == ENOENT ? -1 : error;
+}
+
int heap_init(void *p)
{
handlerton *heap_hton;
-#ifdef HAVE_PSI_INTERFACE
init_heap_psi_keys();
-#endif
heap_hton= (handlerton *)p;
heap_hton->db_type= DB_TYPE_HEAP;
heap_hton->create= heap_create_handler;
heap_hton->panic= heap_panic;
+ heap_hton->drop_table= heap_drop_table;
heap_hton->flags= HTON_CAN_RECREATE;
return 0;
@@ -561,8 +566,7 @@ THR_LOCK_DATA **ha_heap::store_lock(THD *thd,
int ha_heap::delete_table(const char *name)
{
- int error= heap_delete_table(name);
- return error == ENOENT ? 0 : error;
+ return heap_drop_table(0, name);
}
@@ -835,23 +839,6 @@ int ha_heap::find_unique_row(uchar *record, uint unique_idx)
struct st_mysql_storage_engine heap_storage_engine=
{ MYSQL_HANDLERTON_INTERFACE_VERSION };
-mysql_declare_plugin(heap)
-{
- MYSQL_STORAGE_ENGINE_PLUGIN,
- &heap_storage_engine,
- "MEMORY",
- "MySQL AB",
- "Hash based, stored in memory, useful for temporary tables",
- PLUGIN_LICENSE_GPL,
- heap_init,
- NULL,
- 0x0100, /* 1.0 */
- NULL, /* status variables */
- NULL, /* system variables */
- NULL, /* config options */
- 0, /* flags */
-}
-mysql_declare_plugin_end;
maria_declare_plugin(heap)
{
MYSQL_STORAGE_ENGINE_PLUGIN,
diff --git a/storage/heap/heapdef.h b/storage/heap/heapdef.h
index 6136a90f0aa..ffd5382b6f7 100644
--- a/storage/heap/heapdef.h
+++ b/storage/heap/heapdef.h
@@ -110,6 +110,8 @@ extern PSI_memory_key hp_key_memory_HP_KEYDEF;
#ifdef HAVE_PSI_INTERFACE
void init_heap_psi_keys();
+#else
+#define init_heap_psi_keys() do { } while(0)
#endif /* HAVE_PSI_INTERFACE */
C_MODE_END
diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc
index a282826b8de..550e3f36c6c 100644
--- a/storage/innobase/btr/btr0cur.cc
+++ b/storage/innobase/btr/btr0cur.cc
@@ -1299,12 +1299,10 @@ btr_cur_search_to_nth_level_func(
ut_ad(!(index->type & DICT_FTS));
ut_ad(index->page != FIL_NULL);
-#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(&cursor->up_match, sizeof cursor->up_match);
MEM_UNDEFINED(&cursor->up_bytes, sizeof cursor->up_bytes);
MEM_UNDEFINED(&cursor->low_match, sizeof cursor->low_match);
MEM_UNDEFINED(&cursor->low_bytes, sizeof cursor->low_bytes);
-#endif /* HAVE_valgrind_or_MSAN */
#ifdef UNIV_DEBUG
cursor->up_match = ULINT_UNDEFINED;
cursor->low_match = ULINT_UNDEFINED;
@@ -3367,12 +3365,12 @@ btr_cur_optimistic_insert(
|| (flags & BTR_CREATE_FLAG));
ut_ad(dtuple_check_typed(entry));
-#ifdef HAVE_valgrind_or_MSAN
+#ifdef HAVE_valgrind
if (block->page.zip.data) {
MEM_CHECK_DEFINED(page, srv_page_size);
MEM_CHECK_DEFINED(block->page.zip.data, block->zip_size());
}
-#endif /* HAVE_valgrind_or_MSAN */
+#endif /* HAVE_valgrind */
leaf = page_is_leaf(page);
diff --git a/storage/innobase/buf/buf0buddy.cc b/storage/innobase/buf/buf0buddy.cc
index bedf00441ec..8280377b42a 100644
--- a/storage/innobase/buf/buf0buddy.cc
+++ b/storage/innobase/buf/buf0buddy.cc
@@ -364,9 +364,7 @@ buf_buddy_block_free(void* buf)
HASH_DELETE(buf_page_t, hash, &buf_pool.zip_hash, fold, bpage);
ut_d(memset(buf, 0, srv_page_size));
-#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(buf, srv_page_size);
-#endif /* HAVE_valgrind_or_MSAN */
block = (buf_block_t*) bpage;
buf_LRU_block_free_non_file_page(block);
diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc
index 1e2abc2e04d..4deb34efc74 100644
--- a/storage/innobase/buf/buf0buf.cc
+++ b/storage/innobase/buf/buf0buf.cc
@@ -1356,6 +1356,8 @@ inline bool buf_pool_t::chunk_t::create(size_t bytes)
if (UNIV_UNLIKELY(!mem))
return false;
+ MEM_MAKE_ADDRESSABLE(mem, mem_size());
+
#ifdef HAVE_LIBNUMA
if (srv_numa_interleave)
{
@@ -1736,9 +1738,7 @@ inline bool buf_pool_t::realloc(buf_block_t *block)
"not perfect alignment");
memset_aligned<2>(block->frame
+ FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, 0xff, 4);
-#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(block->frame, srv_page_size);
-#endif /* HAVE_valgrind_or_MSAN */
block->page.set_state(BUF_BLOCK_REMOVE_HASH);
/* Relocate flush_list. */
@@ -2257,6 +2257,8 @@ withdraw_retry:
ulint sum_freed = 0;
while (chunk < echunk) {
+ MEM_MAKE_ADDRESSABLE(chunk->mem, chunk->size);
+
buf_block_t* block = chunk->blocks;
for (ulint j = chunk->size; j--; block++) {
@@ -3382,9 +3384,7 @@ evict_from_pool:
block->page.set_io_fix(BUF_IO_READ);
rw_lock_x_lock_inline(&block->lock, 0, file, line);
-#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(bpage, sizeof *bpage);
-#endif /* HAVE_valgrind_or_MSAN */
mutex_exit(&buf_pool.mutex);
hash_lock->write_unlock();
diff --git a/storage/innobase/buf/buf0lru.cc b/storage/innobase/buf/buf0lru.cc
index 41d1e40a730..577f1dae91c 100644
--- a/storage/innobase/buf/buf0lru.cc
+++ b/storage/innobase/buf/buf0lru.cc
@@ -626,7 +626,7 @@ buf_block_t* buf_LRU_get_free_only()
assert_block_ahi_empty(block);
block->page.set_state(BUF_BLOCK_MEMORY);
- MEM_UNDEFINED(block->frame, srv_page_size);
+ MEM_MAKE_ADDRESSABLE(block->frame, srv_page_size);
break;
}
@@ -1307,13 +1307,9 @@ func_exit:
order to avoid bogus Valgrind or MSAN warnings.*/
buf_block_t* block = reinterpret_cast<buf_block_t*>(bpage);
-#ifdef HAVE_valgrind_or_MSAN
MEM_MAKE_DEFINED(block->frame, srv_page_size);
-#endif /* HAVE_valgrind_or_MSAN */
btr_search_drop_page_hash_index(block);
-#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(block->frame, srv_page_size);
-#endif /* HAVE_valgrind_or_MSAN */
if (UNIV_LIKELY_NULL(b)) {
ut_ad(b->zip_size());
@@ -1511,9 +1507,7 @@ static bool buf_LRU_block_remove_hashed(buf_page_t *bpage, const page_id_t id,
"not perfect alignment");
memset_aligned<2>(reinterpret_cast<buf_block_t*>(bpage)->frame
+ FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, 0xff, 4);
-#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(((buf_block_t*) bpage)->frame, srv_page_size);
-#endif /* HAVE_valgrind_or_MSAN */
bpage->set_state(BUF_BLOCK_REMOVE_HASH);
/* Question: If we release hash_lock here
diff --git a/storage/innobase/data/data0data.cc b/storage/innobase/data/data0data.cc
index 0fb9f5e66af..1341136d8d6 100644
--- a/storage/innobase/data/data0data.cc
+++ b/storage/innobase/data/data0data.cc
@@ -234,7 +234,7 @@ dtuple_validate(
const dtuple_t* tuple) /*!< in: tuple */
{
ut_ad(tuple->magic_n == DATA_TUPLE_MAGIC_N);
-#ifdef HAVE_valgrind_or_MSAN
+#ifdef HAVE_valgrind
const ulint n_fields = dtuple_get_n_fields(tuple);
for (ulint i = 0; i < n_fields; i++) {
@@ -245,7 +245,7 @@ dtuple_validate(
dfield_get_len(field));
}
}
-#endif /* HAVE_valgrind_or_MSAN */
+#endif /* HAVE_valgrind */
ut_ad(dtuple_check_typed(tuple));
return(TRUE);
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 9344ec660b9..858fefaf2de 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -7033,9 +7033,7 @@ build_template_field(
ut_ad(clust_index->table == index->table);
templ = prebuilt->mysql_template + prebuilt->n_template++;
-#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(templ, sizeof *templ);
-#endif /* HAVE_valgrind_or_MSAN */
templ->is_virtual = !field->stored_in_db();
if (!templ->is_virtual) {
@@ -8146,9 +8144,7 @@ calc_row_difference(
/* The field has changed */
ufield = uvect->fields + n_changed;
-#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(ufield, sizeof *ufield);
-#endif /* HAVE_valgrind_or_MSAN */
/* Let us use a dummy dfield to make the conversion
from the MySQL column format to the InnoDB format */
diff --git a/storage/innobase/include/buf0buf.ic b/storage/innobase/include/buf0buf.ic
index 242c9cbb65d..cda7d435725 100644
--- a/storage/innobase/include/buf0buf.ic
+++ b/storage/innobase/include/buf0buf.ic
@@ -185,9 +185,7 @@ buf_page_alloc_descriptor(void)
bpage = (buf_page_t*) ut_zalloc_nokey(sizeof *bpage);
ut_ad(bpage);
-#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(bpage, sizeof *bpage);
-#endif /* HAVE_valgrind_or_MSAN */
return(bpage);
}
diff --git a/storage/innobase/include/dict0stats.ic b/storage/innobase/include/dict0stats.ic
index dbdbceab9ba..0b8c57a5eba 100644
--- a/storage/innobase/include/dict0stats.ic
+++ b/storage/innobase/include/dict0stats.ic
@@ -187,7 +187,7 @@ dict_stats_deinit(
table->stat_initialized = FALSE;
-#ifdef HAVE_valgrind_or_MSAN
+#ifdef HAVE_valgrind
MEM_UNDEFINED(&table->stat_n_rows, sizeof table->stat_n_rows);
MEM_UNDEFINED(&table->stat_clustered_index_size,
sizeof table->stat_clustered_index_size);
@@ -220,7 +220,7 @@ dict_stats_deinit(
&index->stat_n_leaf_pages,
sizeof(index->stat_n_leaf_pages));
}
-#endif /* HAVE_valgrind_or_MSAN */
+#endif /* HAVE_valgrind */
rw_lock_x_unlock(&table->stats_latch);
}
diff --git a/storage/innobase/include/mem0mem.ic b/storage/innobase/include/mem0mem.ic
index c1e7348a548..9236bbef05d 100644
--- a/storage/innobase/include/mem0mem.ic
+++ b/storage/innobase/include/mem0mem.ic
@@ -203,7 +203,7 @@ mem_heap_alloc(
mem_block_set_free(block, free + MEM_SPACE_NEEDED(n));
buf = buf + REDZONE_SIZE;
- MEM_UNDEFINED(buf, n - REDZONE_SIZE);
+ MEM_MAKE_ADDRESSABLE(buf, n - REDZONE_SIZE);
return(buf);
}
diff --git a/storage/innobase/include/read0types.h b/storage/innobase/include/read0types.h
index 1428170e704..de3ff927520 100644
--- a/storage/innobase/include/read0types.h
+++ b/storage/innobase/include/read0types.h
@@ -279,17 +279,20 @@ public:
/**
- Unpoison the memory for innodb_monitor_set_option;
- It is operating also on the freed transaction objects.
- Declare the contents as initialized for Valgrind;
- We checked that it was initialized in trx_pools->mem_free(trx).
+ Make the memory accessible by innodb_monitor_set_option;
+ It is operating also on freed transaction objects.
*/
void mem_valid() const
{
+ /* Cancel the effect of MEM_NOACCESS(). */
#ifdef __SANITIZE_ADDRESS__
- MEM_UNDEFINED(&m_mutex, sizeof m_mutex);
+ MEM_MAKE_ADDRESSABLE(&m_mutex, sizeof m_mutex);
#endif
-#ifdef HAVE_valgrind
+#if defined HAVE_valgrind && !__has_feature(memory_sanitizer)
+ /* In Valgrind, we cannot cancel MEM_NOACCESS() without changing
+ the state of the V bits (indicating which bits are initialized).
+ We will declare the contents as initialized.
+ We did invoke MEM_CHECK_DEFINED() in trx_pools->mem_free(). */
MEM_MAKE_DEFINED(&m_mutex, sizeof m_mutex);
#endif
}
diff --git a/storage/innobase/include/srv0mon.h b/storage/innobase/include/srv0mon.h
index 8e833642ee0..325bb3a2cee 100644
--- a/storage/innobase/include/srv0mon.h
+++ b/storage/innobase/include/srv0mon.h
@@ -651,14 +651,14 @@ Use MONITOR_DEC if appropriate mutex protection exists.
} \
}
-#ifdef HAVE_valgrind_or_MSAN
+#ifdef HAVE_valgrind
# define MONITOR_CHECK_DEFINED(value) do { \
mon_type_t m = value; \
MEM_CHECK_DEFINED(&m, sizeof m); \
} while (0)
-#else /* HAVE_valgrind_or_MSAN */
+#else /* HAVE_valgrind */
# define MONITOR_CHECK_DEFINED(value) (void) 0
-#endif /* HAVE_valgrind_or_MSAN */
+#endif /* HAVE_valgrind */
#define MONITOR_INC_VALUE(monitor, value) \
MONITOR_CHECK_DEFINED(value); \
diff --git a/storage/innobase/include/ut0pool.h b/storage/innobase/include/ut0pool.h
index 703a07a23f2..c31633e7f4c 100644
--- a/storage/innobase/include/ut0pool.h
+++ b/storage/innobase/include/ut0pool.h
@@ -89,11 +89,15 @@ struct Pool {
ut_ad(elem->m_pool == this);
#ifdef __SANITIZE_ADDRESS__
/* Unpoison the memory for AddressSanitizer */
- MEM_UNDEFINED(&elem->m_type, sizeof elem->m_type);
+ MEM_MAKE_ADDRESSABLE(&elem->m_type,
+ sizeof elem->m_type);
#endif
-#ifdef HAVE_valgrind
- /* Declare the contents as initialized for Valgrind;
- we checked this in mem_free(). */
+#if defined HAVE_valgrind && !__has_feature(memory_sanitizer)
+ /* In Valgrind, we cannot cancel MEM_NOACCESS() without
+ changing the state of the V bits (which indicate
+ which bits are initialized).
+ We will declare the contents as initialized.
+ We did invoke MEM_CHECK_DEFINED() in mem_free(). */
MEM_MAKE_DEFINED(&elem->m_type, sizeof elem->m_type);
#endif
Factory::destroy(&elem->m_type);
@@ -134,15 +138,17 @@ struct Pool {
if (elem) {
# ifdef __SANITIZE_ADDRESS__
/* Unpoison the memory for AddressSanitizer */
- MEM_UNDEFINED(&elem->m_type, sizeof elem->m_type);
-# endif
-# ifdef HAVE_valgrind
- /* Declare the memory initialized for Valgrind.
- The trx_t that are released to the pool are
- actually initialized; we checked that by
- MEM_CHECK_DEFINED() in mem_free() below. */
+ MEM_MAKE_ADDRESSABLE(&elem->m_type,
+ sizeof elem->m_type);
# endif
+# if defined HAVE_valgrind && !__has_feature(memory_sanitizer)
+ /* In Valgrind, we cannot cancel MEM_NOACCESS() without
+ changing the state of the V bits (which indicate
+ which bits are initialized).
+ We will declare the contents as initialized.
+ We did invoke MEM_CHECK_DEFINED() in mem_free(). */
MEM_MAKE_DEFINED(&elem->m_type, sizeof elem->m_type);
+# endif
}
#endif
diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc
index 2a4891f2716..7afac5c7d54 100644
--- a/storage/innobase/log/log0recv.cc
+++ b/storage/innobase/log/log0recv.cc
@@ -1050,6 +1050,7 @@ inline void recv_sys_t::clear()
buf_block_t *prev_block= UT_LIST_GET_PREV(unzip_LRU, block);
ut_ad(block->page.state() == BUF_BLOCK_MEMORY);
UT_LIST_REMOVE(blocks, block);
+ MEM_MAKE_ADDRESSABLE(block->frame, srv_page_size);
buf_block_free(block);
block= prev_block;
}
@@ -1093,7 +1094,7 @@ create_block:
ut_calc_align<uint16_t>(static_cast<uint16_t>(len), ALIGNMENT);
static_assert(ut_is_2pow(ALIGNMENT), "ALIGNMENT must be a power of 2");
UT_LIST_ADD_FIRST(blocks, block);
- MEM_UNDEFINED(block->frame, len);
+ MEM_MAKE_ADDRESSABLE(block->frame, len);
MEM_NOACCESS(block->frame + len, srv_page_size - len);
return my_assume_aligned<ALIGNMENT>(block->frame);
}
@@ -1113,7 +1114,7 @@ create_block:
block->page.access_time= ((block->page.access_time >> 16) + 1) << 16 |
ut_calc_align<uint16_t>(static_cast<uint16_t>(free_offset), ALIGNMENT);
- MEM_UNDEFINED(block->frame + free_offset - len, len);
+ MEM_MAKE_ADDRESSABLE(block->frame + free_offset - len, len);
return my_assume_aligned<ALIGNMENT>(block->frame + free_offset - len);
}
@@ -1148,6 +1149,7 @@ inline void recv_sys_t::free(const void *data)
if (!((block->page.access_time -= 1U << 16) >> 16))
{
UT_LIST_REMOVE(blocks, block);
+ MEM_MAKE_ADDRESSABLE(block->frame, srv_page_size);
buf_block_free(block);
}
return;
@@ -1758,7 +1760,7 @@ inline void recv_sys_t::add(const page_id_t page_id,
{
/* Use already allocated 'padding' bytes */
append:
- MEM_UNDEFINED(end + 1, len);
+ MEM_MAKE_ADDRESSABLE(end + 1, len);
/* Append to the preceding record for the page */
tail->append(l, len);
return;
diff --git a/storage/innobase/mtr/mtr0mtr.cc b/storage/innobase/mtr/mtr0mtr.cc
index 16a0ecc051c..940429b2cd6 100644
--- a/storage/innobase/mtr/mtr0mtr.cc
+++ b/storage/innobase/mtr/mtr0mtr.cc
@@ -354,10 +354,9 @@ struct mtr_write_log_t {
/** Start a mini-transaction. */
void mtr_t::start()
{
-#ifdef HAVE_valgrind_or_MSAN
+ ut_ad(!m_freed_pages);
MEM_UNDEFINED(this, sizeof *this);
MEM_MAKE_DEFINED(&m_freed_pages, sizeof(m_freed_pages));
-#endif /* HAVE_valgrind_or_MSAN */
ut_d(m_start= true);
ut_d(m_commit= false);
@@ -376,7 +375,6 @@ void mtr_t::start()
m_user_space= nullptr;
m_commit_lsn= 0;
m_freed_in_system_tablespace= m_trim_pages= false;
- ut_ad(!m_freed_pages);
}
/** Release the resources */
diff --git a/storage/innobase/page/page0cur.cc b/storage/innobase/page/page0cur.cc
index 92e7ce5e60d..36fdde82cb3 100644
--- a/storage/innobase/page/page0cur.cc
+++ b/storage/innobase/page/page0cur.cc
@@ -1302,7 +1302,7 @@ page_cur_insert_rec_low(
/* 1. Get the size of the physical record in the page */
const ulint rec_size= rec_offs_size(offsets);
-#ifdef HAVE_valgrind_or_MSAN
+#ifdef HAVE_valgrind
{
const void *rec_start= rec - rec_offs_extra_size(offsets);
ulint extra_size= rec_offs_extra_size(offsets) -
@@ -1314,7 +1314,7 @@ page_cur_insert_rec_low(
/* The variable-length header must be valid. */
MEM_CHECK_DEFINED(rec_start, extra_size);
}
-#endif /* HAVE_valgrind_or_MSAN */
+#endif /* HAVE_valgrind */
/* 2. Try to find suitable space from page memory management */
bool reuse= false;
@@ -1702,7 +1702,7 @@ page_cur_insert_rec_zip(
/* 1. Get the size of the physical record in the page */
const ulint rec_size= rec_offs_size(offsets);
-#ifdef HAVE_valgrind_or_MSAN
+#ifdef HAVE_valgrind
{
const void *rec_start= rec - rec_offs_extra_size(offsets);
ulint extra_size= rec_offs_extra_size(offsets) - REC_N_NEW_EXTRA_BYTES;
@@ -1711,7 +1711,7 @@ page_cur_insert_rec_zip(
/* The variable-length header must be valid. */
MEM_CHECK_DEFINED(rec_start, extra_size);
}
-#endif /* HAVE_valgrind_or_MSAN */
+#endif /* HAVE_valgrind */
const bool reorg_before_insert= page_has_garbage(cursor->block->frame) &&
rec_size > page_get_max_insert_size(cursor->block->frame, 1) &&
rec_size <= page_get_max_insert_size_after_reorganize(cursor->block->frame,
diff --git a/storage/innobase/page/page0zip.cc b/storage/innobase/page/page0zip.cc
index a89ae5b3a64..0f6a1c33e54 100644
--- a/storage/innobase/page/page0zip.cc
+++ b/storage/innobase/page/page0zip.cc
@@ -1552,11 +1552,11 @@ err_exit:
ut_ad(buf + c_stream.total_out == c_stream.next_out);
ut_ad((ulint) (storage - c_stream.next_out) >= c_stream.avail_out);
-#ifdef HAVE_valgrind
+#if defined HAVE_valgrind && !__has_feature(memory_sanitizer)
/* Valgrind believes that zlib does not initialize some bits
in the last 7 or 8 bytes of the stream. Make Valgrind happy. */
MEM_MAKE_DEFINED(buf, c_stream.total_out);
-#endif /* HAVE_valgrind */
+#endif /* HAVE_valgrind && !memory_sanitizer */
/* Zero out the area reserved for the modification log.
Space for the end marker of the modification log is not
@@ -3076,9 +3076,7 @@ page_zip_decompress_low(
/* Clear the uncompressed page, except the header. */
memset(PAGE_DATA + page, 0x55, srv_page_size - PAGE_DATA);
#endif /* UNIV_ZIP_DEBUG */
-#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(PAGE_DATA + page, srv_page_size - PAGE_DATA);
-#endif /* HAVE_valgrind_or_MSAN */
/* Copy the page directory. */
if (UNIV_UNLIKELY(!page_zip_dir_decode(page_zip, page, recs,
diff --git a/storage/innobase/row/row0ftsort.cc b/storage/innobase/row/row0ftsort.cc
index 4698f25428c..29197fde46b 100644
--- a/storage/innobase/row/row0ftsort.cc
+++ b/storage/innobase/row/row0ftsort.cc
@@ -982,14 +982,14 @@ exit:
goto func_exit;
}
-#ifdef HAVE_valgrind_or_MSAN
+#ifdef HAVE_valgrind
MEM_UNDEFINED(block[i], srv_sort_buf_size);
if (crypt_block[i]) {
MEM_UNDEFINED(crypt_block[i],
srv_sort_buf_size);
}
-#endif /* HAVE_valgrind_or_MSAN */
+#endif /* HAVE_valgrind */
}
buf[i] = row_merge_buf_empty(buf[i]);
diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc
index 5f3cdb4356e..0f1e8007d36 100644
--- a/storage/innobase/row/row0ins.cc
+++ b/storage/innobase/row/row0ins.cc
@@ -1240,10 +1240,8 @@ row_ins_foreign_check_on_constraint(
update->info_bits = 0;
update->n_fields = foreign->n_fields;
-#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(update->fields,
update->n_fields * sizeof *update->fields);
-#endif /* HAVE_valgrind_or_MSAN */
bool affects_fulltext = false;
diff --git a/storage/innobase/row/row0log.cc b/storage/innobase/row/row0log.cc
index 78f605c373d..4db1b7cfa7f 100644
--- a/storage/innobase/row/row0log.cc
+++ b/storage/innobase/row/row0log.cc
@@ -375,9 +375,7 @@ row_log_online_op(
goto err_exit;
}
-#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(log->tail.buf, sizeof log->tail.buf);
-#endif /* HAVE_valgrind_or_MSAN */
ut_ad(log->tail.bytes < srv_sort_buf_size);
avail_size = srv_sort_buf_size - log->tail.bytes;
@@ -462,10 +460,8 @@ write_failed:
index->type |= DICT_CORRUPT;
}
-#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(log->tail.block, srv_sort_buf_size);
MEM_UNDEFINED(buf, srv_sort_buf_size);
-#endif /* HAVE_valgrind_or_MSAN */
memcpy(log->tail.block, log->tail.buf + avail_size,
mrec_size - avail_size);
@@ -475,9 +471,7 @@ write_failed:
ut_ad(b == log->tail.block + log->tail.bytes);
}
-#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(log->tail.buf, sizeof log->tail.buf);
-#endif /* HAVE_valgrind_or_MSAN */
err_exit:
mutex_exit(&log->mutex);
}
@@ -509,9 +503,7 @@ row_log_table_open(
{
mutex_enter(&log->mutex);
-#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(log->tail.buf, sizeof log->tail.buf);
-#endif /* HAVE_valgrind_or_MSAN */
if (log->error != DB_SUCCESS) {
err_exit:
@@ -603,10 +595,9 @@ row_log_table_close_func(
write_failed:
log->error = DB_ONLINE_LOG_TOO_BIG;
}
-#ifdef HAVE_valgrind_or_MSAN
+
MEM_UNDEFINED(log->tail.block, srv_sort_buf_size);
MEM_UNDEFINED(buf, srv_sort_buf_size);
-#endif /* HAVE_valgrind_or_MSAN */
memcpy(log->tail.block, log->tail.buf + avail, size - avail);
log->tail.bytes = size - avail;
} else {
@@ -615,9 +606,7 @@ write_failed:
}
log->tail.total += size;
-#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(log->tail.buf, sizeof log->tail.buf);
-#endif /* HAVE_valgrind_or_MSAN */
err_exit:
mutex_exit(&log->mutex);
@@ -2789,9 +2778,7 @@ row_log_table_apply_ops(
ut_ad(new_trx_id_col > 0);
ut_ad(new_trx_id_col != ULINT_UNDEFINED);
-#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(&mrec_end, sizeof mrec_end);
-#endif /* HAVE_valgrind_or_MSAN */
offsets = static_cast<rec_offs*>(ut_malloc_nokey(i * sizeof *offsets));
rec_offs_set_n_alloc(offsets, i);
@@ -3703,9 +3690,8 @@ row_log_apply_ops(
ut_ad(!index->is_committed());
ut_ad(rw_lock_own(dict_index_get_lock(index), RW_LOCK_X));
ut_ad(index->online_log);
-#ifdef HAVE_valgrind_or_MSAN
+
MEM_UNDEFINED(&mrec_end, sizeof mrec_end);
-#endif /* HAVE_valgrind_or_MSAN */
offsets = static_cast<rec_offs*>(ut_malloc_nokey(i * sizeof *offsets));
rec_offs_set_n_alloc(offsets, i);
diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc
index d1074f74725..3e0ffcf28b9 100644
--- a/storage/innobase/row/row0merge.cc
+++ b/storage/innobase/row/row0merge.cc
@@ -1021,11 +1021,11 @@ row_merge_buf_write(
ut_a(b < &block[srv_sort_buf_size]);
ut_a(b == &block[0] + buf->total_size);
*b++ = 0;
-#ifdef HAVE_valgrind_or_MSAN
+#ifdef HAVE_valgrind
/* The rest of the block is uninitialized. Initialize it
to avoid bogus warnings. */
memset(b, 0xff, &block[srv_sort_buf_size] - b);
-#endif /* HAVE_valgrind_or_MSAN */
+#endif /* HAVE_valgrind */
DBUG_LOG("ib_merge_sort",
"write " << reinterpret_cast<const void*>(b) << ','
<< of->fd << ',' << of->offset << " EOF");
@@ -1418,9 +1418,7 @@ row_merge_write_rec(
return(NULL);
}
-#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(&block[0], srv_sort_buf_size);
-#endif /* HAVE_valgrind_or_MSAN */
/* Copy the rest. */
b = &block[0];
@@ -1471,9 +1469,7 @@ row_merge_write_eof(
DBUG_RETURN(NULL);
}
-#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(&block[0], srv_sort_buf_size);
-#endif
DBUG_RETURN(&block[0]);
}
@@ -2661,10 +2657,8 @@ write_buffers:
break;
}
-#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(
&block[0], srv_sort_buf_size);
-#endif /* HAVE_valgrind_or_MSAN */
}
}
merge_buf[i] = row_merge_buf_empty(buf);
@@ -3164,9 +3158,7 @@ row_merge(
foffs0 = 0;
foffs1 = ihalf;
-#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(run_offset, *num_run * sizeof *run_offset);
-#endif /* HAVE_valgrind_or_MSAN */
for (; foffs0 < ihalf && foffs1 < file->offset; foffs0++, foffs1++) {
@@ -3247,9 +3239,7 @@ row_merge(
*tmpfd = file->fd;
*file = of;
-#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(&block[0], 3 * srv_sort_buf_size);
-#endif /* HAVE_valgrind_or_MSAN */
return(DB_SUCCESS);
}
diff --git a/storage/innobase/row/row0sel.cc b/storage/innobase/row/row0sel.cc
index 8b46364c744..595a72eb415 100644
--- a/storage/innobase/row/row0sel.cc
+++ b/storage/innobase/row/row0sel.cc
@@ -974,11 +974,9 @@ row_sel_get_clust_rec(
switch (err) {
case DB_SUCCESS:
case DB_SUCCESS_LOCKED_REC:
-#ifdef HAVE_valgrind_or_MSAN
/* Declare the variable uninitialized.
It should be set to DB_SUCCESS at func_exit. */
MEM_UNDEFINED(&err, sizeof err);
-#endif /* HAVE_valgrind_or_MSAN */
break;
default:
goto err_exit;
@@ -2686,9 +2684,7 @@ row_sel_field_store_in_mysql_format_func(
ut_ad(len != UNIV_SQL_NULL);
MEM_CHECK_DEFINED(data, len);
MEM_CHECK_ADDRESSABLE(dest, templ->mysql_col_len);
-#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(dest, templ->mysql_col_len);
-#endif /* HAVE_valgrind_or_MSAN */
byte* pad = dest + len;
@@ -3615,9 +3611,7 @@ row_sel_copy_cached_field_for_mysql(
row_mysql_read_true_varchar(
&len, cache, templ->mysql_length_bytes);
len += templ->mysql_length_bytes;
-#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(buf, templ->mysql_col_len);
-#endif /* HAVE_valgrind_or_MSAN */
} else {
len = templ->mysql_col_len;
}
@@ -3693,9 +3687,7 @@ row_sel_dequeue_cached_row_for_mysql(
/* The record is long. Copy it field by field, in case
there are some long VARCHAR column of which only a
small length is being used. */
-#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(buf, prebuilt->mysql_prefix_len);
-#endif /* HAVE_valgrind_or_MSAN */
/* First copy the NULL bits. */
memcpy(buf, cached_rec, prebuilt->null_bitmap_len);
@@ -3779,10 +3771,8 @@ row_sel_fetch_last_buf(
}
ut_ad(prebuilt->fetch_cache_first == 0);
-#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(prebuilt->fetch_cache[prebuilt->n_fetch_cached],
prebuilt->mysql_row_len);
-#endif /* HAVE_valgrind_or_MSAN */
return(prebuilt->fetch_cache[prebuilt->n_fetch_cached]);
}
diff --git a/storage/innobase/row/row0upd.cc b/storage/innobase/row/row0upd.cc
index 969d0017eeb..fe81cb46916 100644
--- a/storage/innobase/row/row0upd.cc
+++ b/storage/innobase/row/row0upd.cc
@@ -1542,9 +1542,7 @@ row_upd_changes_ord_field_binary_func(
/* Silence a compiler warning without
silencing a Valgrind error. */
dfield_len = 0;
-#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(&dfield_len, sizeof dfield_len);
-#endif /* HAVE_valgrind_or_MSAN */
/* See if the column is stored externally. */
buf = row_ext_lookup(ext, col_no, &dfield_len);
diff --git a/storage/innobase/sync/sync0arr.cc b/storage/innobase/sync/sync0arr.cc
index a0203ca6bde..1e8ef62b429 100644
--- a/storage/innobase/sync/sync0arr.cc
+++ b/storage/innobase/sync/sync0arr.cc
@@ -891,7 +891,7 @@ sync_array_print_long_waits_low(
return(false);
}
-#ifdef HAVE_valgrind
+#if defined HAVE_valgrind && !__has_feature(memory_sanitizer)
/* Increase the timeouts if running under valgrind because it executes
extremely slowly. HAVE_valgrind does not necessary mean that
we are running under valgrind but we have no better way to tell.
diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc
index eaf127b5a43..03e60d80d5b 100644
--- a/storage/innobase/trx/trx0trx.cc
+++ b/storage/innobase/trx/trx0trx.cc
@@ -454,19 +454,19 @@ void trx_free(trx_t*& trx)
#ifdef __SANITIZE_ADDRESS__
/* Unpoison the memory for innodb_monitor_set_option;
it is operating also on the freed transaction objects. */
- MEM_UNDEFINED(&trx->mutex, sizeof trx->mutex);
- /* For innobase_kill_connection() */
+ MEM_MAKE_ADDRESSABLE(&trx->mutex, sizeof trx->mutex);
# ifdef WITH_WSREP
- MEM_UNDEFINED(&trx->wsrep, sizeof trx->wsrep);
+ MEM_MAKE_ADDRESSABLE(&trx->wsrep, sizeof trx->wsrep);
# endif
- MEM_UNDEFINED(&trx->state, sizeof trx->state);
- MEM_UNDEFINED(&trx->mysql_thd, sizeof trx->mysql_thd);
+ /* For innobase_kill_connection() */
+ MEM_MAKE_ADDRESSABLE(&trx->state, sizeof trx->state);
+ MEM_MAKE_ADDRESSABLE(&trx->mysql_thd, sizeof trx->mysql_thd);
#endif
-#ifdef HAVE_valgrind_or_MSAN
- /* Unpoison the memory for innodb_monitor_set_option;
- it is operating also on the freed transaction objects.
- We checked that these were initialized in
- trx_pools->mem_free(trx). */
+#if defined HAVE_valgrind && !__has_feature(memory_sanitizer)
+ /* In Valgrind, we cannot cancel the effect of MEM_NOACCESS()
+ without changing the state of the V bits (indicating which
+ bits are initialized). We did invoke MEM_CHECK_DEFINED() in
+ trx_pools->mem_free(). */
MEM_MAKE_DEFINED(&trx->mutex, sizeof trx->mutex);
/* For innobase_kill_connection() */
# ifdef WITH_WSREP
diff --git a/storage/mroonga/ha_mroonga.cpp b/storage/mroonga/ha_mroonga.cpp
index 6f302e89213..4747495fd22 100644
--- a/storage/mroonga/ha_mroonga.cpp
+++ b/storage/mroonga/ha_mroonga.cpp
@@ -5031,19 +5031,8 @@ int ha_mroonga::wrapper_delete_table(const char *name,
handlerton *wrap_handlerton,
const char *table_name)
{
- int error = 0;
MRN_DBUG_ENTER_METHOD();
-
- handler *hnd = get_new_handler(NULL, current_thd->mem_root, wrap_handlerton);
- if (!hnd)
- {
- DBUG_RETURN(HA_ERR_OUT_OF_MEM);
- }
-
- error = hnd->ha_delete_table(name);
- delete hnd;
-
- DBUG_RETURN(error);
+ DBUG_RETURN(wrap_handlerton->drop_table(wrap_handlerton, name));
}
int ha_mroonga::generic_delete_table(const char *name, const char *table_name)
diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc
index 448aab0a092..92fb49bea8d 100644
--- a/storage/myisam/ha_myisam.cc
+++ b/storage/myisam/ha_myisam.cc
@@ -2512,13 +2512,16 @@ int myisam_panic(handlerton *hton, ha_panic_function flag)
return mi_panic(flag);
}
+static int myisam_drop_table(handlerton *hton, const char *path)
+{
+ return mi_delete_table(path);
+}
+
static int myisam_init(void *p)
{
handlerton *hton;
-#ifdef HAVE_PSI_INTERFACE
init_myisam_psi_keys();
-#endif
/* Set global variables based on startup options */
if (myisam_recover_options && myisam_recover_options != HA_RECOVER_OFF)
@@ -2531,6 +2534,7 @@ static int myisam_init(void *p)
hton= (handlerton *)p;
hton->db_type= DB_TYPE_MYISAM;
hton->create= myisam_create_handler;
+ hton->drop_table= myisam_drop_table;
hton->panic= myisam_panic;
hton->flags= HTON_CAN_RECREATE | HTON_SUPPORT_LOG_TABLES;
hton->tablefile_extensions= ha_myisam_exts;
@@ -2644,23 +2648,6 @@ bool ha_myisam::rowid_filter_push(Rowid_filter* rowid_filter)
struct st_mysql_storage_engine myisam_storage_engine=
{ MYSQL_HANDLERTON_INTERFACE_VERSION };
-mysql_declare_plugin(myisam)
-{
- MYSQL_STORAGE_ENGINE_PLUGIN,
- &myisam_storage_engine,
- "MyISAM",
- "MySQL AB",
- "MyISAM storage engine",
- PLUGIN_LICENSE_GPL,
- myisam_init, /* Plugin Init */
- NULL, /* Plugin Deinit */
- 0x0100, /* 1.0 */
- NULL, /* status variables */
- myisam_sysvars, /* system variables */
- NULL,
- 0,
-}
-mysql_declare_plugin_end;
maria_declare_plugin(myisam)
{
MYSQL_STORAGE_ENGINE_PLUGIN,
diff --git a/storage/myisam/myisamdef.h b/storage/myisam/myisamdef.h
index 640a04fb3df..f48d1078000 100644
--- a/storage/myisam/myisamdef.h
+++ b/storage/myisam/myisamdef.h
@@ -774,6 +774,8 @@ extern PSI_file_key mi_key_file_datatmp, mi_key_file_dfile, mi_key_file_kfile,
extern PSI_thread_key mi_key_thread_find_all_keys;
void init_myisam_psi_keys();
+#else
+#define init_myisam_psi_keys() do { } while(0)
#endif /* HAVE_PSI_INTERFACE */
extern PSI_memory_key mi_key_memory_MYISAM_SHARE;
diff --git a/storage/oqgraph/ha_oqgraph.cc b/storage/oqgraph/ha_oqgraph.cc
index 20a3732ce95..8b219b20ec6 100644
--- a/storage/oqgraph/ha_oqgraph.cc
+++ b/storage/oqgraph/ha_oqgraph.cc
@@ -192,6 +192,7 @@ static int oqgraph_init(void *p)
hton->discover_table_structure= oqgraph_discover_table_structure;
hton->close_connection = oqgraph_close_connection;
+ hton->drop_table= [](handlerton *, const char*) { return 0; };
oqgraph_init_done= TRUE;
return 0;
diff --git a/storage/perfschema/ha_perfschema.cc b/storage/perfschema/ha_perfschema.cc
index c4c59d109f5..f54d46ce979 100644
--- a/storage/perfschema/ha_perfschema.cc
+++ b/storage/perfschema/ha_perfschema.cc
@@ -94,12 +94,10 @@ static int pfs_init_func(void *p)
pfs_hton= reinterpret_cast<handlerton *> (p);
pfs_hton->create= pfs_create_handler;
+ pfs_hton->drop_table= [](handlerton *, const char*) { return -1; };
pfs_hton->show_status= pfs_show_status;
- pfs_hton->flags= (HTON_ALTER_NOT_SUPPORTED |
- HTON_TEMPORARY_NOT_SUPPORTED |
- HTON_NO_PARTITION |
- HTON_NO_BINLOG_ROW_OPT |
- HTON_AUTOMATIC_DELETE_TABLE);
+ pfs_hton->flags= HTON_ALTER_NOT_SUPPORTED | HTON_TEMPORARY_NOT_SUPPORTED |
+ HTON_NO_PARTITION | HTON_NO_BINLOG_ROW_OPT;
/*
As long as the server implementation keeps using legacy_db_type,
@@ -218,24 +216,6 @@ struct st_mysql_storage_engine pfs_storage_engine=
const char* pfs_engine_name= "PERFORMANCE_SCHEMA";
-mysql_declare_plugin(perfschema)
-{
- MYSQL_STORAGE_ENGINE_PLUGIN,
- &pfs_storage_engine,
- pfs_engine_name,
- "Marc Alff, Oracle", /* Formerly Sun Microsystems, formerly MySQL */
- "Performance Schema",
- PLUGIN_LICENSE_GPL,
- pfs_init_func, /* Plugin Init */
- pfs_done_func, /* Plugin Deinit */
- 0x0001 /* 0.1 */,
- pfs_status_vars, /* status variables */
- NULL, /* system variables */
- NULL, /* config options */
- 0, /* flags */
-}
-mysql_declare_plugin_end;
-
maria_declare_plugin(perfschema)
{
MYSQL_STORAGE_ENGINE_PLUGIN,
diff --git a/storage/rocksdb/rdb_datadic.cc b/storage/rocksdb/rdb_datadic.cc
index 6e73535d1de..13da87ad92c 100644
--- a/storage/rocksdb/rdb_datadic.cc
+++ b/storage/rocksdb/rdb_datadic.cc
@@ -3793,8 +3793,7 @@ bool Rdb_validate_tbls::check_frm_file(const std::string &fullpath,
*/
char eng_type_buf[NAME_CHAR_LEN+1];
LEX_CSTRING eng_type_str = {eng_type_buf, 0};
- bool is_sequence;
- enum Table_type type = dd_frm_type(nullptr, fullfilename.c_ptr(), &eng_type_str, &is_sequence);
+ enum Table_type type = dd_frm_type(nullptr, fullfilename.c_ptr(), &eng_type_str);
if (type == TABLE_TYPE_UNKNOWN) {
// NO_LINT_DEBUG
sql_print_warning("RocksDB: Failed to open/read .from file: %s",
diff --git a/storage/sequence/sequence.cc b/storage/sequence/sequence.cc
index 31522b8f3b7..c8f3e76b873 100644
--- a/storage/sequence/sequence.cc
+++ b/storage/sequence/sequence.cc
@@ -497,18 +497,27 @@ int ha_seq_group_by_handler::next_row()
Initialize the interface between the sequence engine and MariaDB
*****************************************************************************/
+static int drop_table(handlerton *hton, const char *path)
+{
+ const char *name= strrchr(path, FN_LIBCHAR)+1;
+ ulonglong from, to, step;
+ if (parse_table_name(name, strlen(name), &from, &to, &step))
+ return ENOENT;
+ return 0;
+}
+
static int init(void *p)
{
handlerton *hton= (handlerton *)p;
sequence_hton= hton;
hton->create= create_handler;
+ hton->drop_table= drop_table;
hton->discover_table= discover_table;
hton->discover_table_existence= discover_table_existence;
hton->commit= hton->rollback= dummy_commit_rollback;
hton->savepoint_set= hton->savepoint_rollback= hton->savepoint_release=
dummy_savepoint;
hton->create_group_by= create_group_by_handler;
- hton->flags= HTON_AUTOMATIC_DELETE_TABLE;
return 0;
}
diff --git a/storage/sphinx/ha_sphinx.cc b/storage/sphinx/ha_sphinx.cc
index d60a4d229e6..ca68a5feb60 100644
--- a/storage/sphinx/ha_sphinx.cc
+++ b/storage/sphinx/ha_sphinx.cc
@@ -749,7 +749,8 @@ static int sphinx_init_func ( void * p )
hton->close_connection = sphinx_close_connection;
hton->show_status = sphinx_show_status;
hton->panic = sphinx_panic;
- hton->flags = HTON_CAN_RECREATE | HTON_AUTOMATIC_DELETE_TABLE;
+ hton->drop_table= [](handlerton *, const char*) { return -1; };
+ hton->flags = HTON_CAN_RECREATE;
#endif
}
SPH_RET(0);
diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc
index f4b0177c794..e77e1a9261b 100644
--- a/storage/spider/spd_table.cc
+++ b/storage/spider/spd_table.cc
@@ -7249,7 +7249,7 @@ int spider_db_init(
DBUG_ENTER("spider_db_init");
spider_hton_ptr = spider_hton;
- spider_hton->flags = HTON_NO_FLAGS | HTON_AUTOMATIC_DELETE_TABLE;
+ spider_hton->flags = HTON_NO_FLAGS;
#ifdef HTON_CAN_READ_CONNECT_STRING_IN_PARTITION
spider_hton->flags |= HTON_CAN_READ_CONNECT_STRING_IN_PARTITION;
#endif
diff --git a/storage/test_sql_discovery/test_sql_discovery.cc b/storage/test_sql_discovery/test_sql_discovery.cc
index 9e7a22368fc..0758d5f503f 100644
--- a/storage/test_sql_discovery/test_sql_discovery.cc
+++ b/storage/test_sql_discovery/test_sql_discovery.cc
@@ -147,11 +147,20 @@ static int discover_table(handlerton *hton, THD* thd, TABLE_SHARE *share)
sql, strlen(sql));
}
+static int drop_table(handlerton *hton, const char *path)
+{
+ const char *name= strrchr(path, FN_LIBCHAR)+1;
+ const char *sql= THDVAR(current_thd, statement);
+ return !sql || strncmp(sql, name, strlen(name)) || sql[strlen(name)] != ':'
+ ? ENOENT : 0;
+}
+
static int init(void *p)
{
handlerton *hton = (handlerton *)p;
hton->create = create_handler;
hton->discover_table = discover_table;
+ hton->drop_table= drop_table;
return 0;
}