diff --git a/client/mysqltest.cc b/client/mysqltest.cc index cd7e82f34e5b6..ca15e5e2808a3 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -192,6 +192,7 @@ static char TMPDIR[FN_REFLEN]; static char global_subst_from[200]; static char global_subst_to[200]; static char *global_subst= NULL; +static char *read_command_buf= NULL; static MEM_ROOT require_file_root; static const my_bool my_true= 1; static const my_bool my_false= 0; @@ -1531,6 +1532,7 @@ void free_used_memory() free_defaults(default_argv); free_root(&require_file_root, MYF(0)); free_re(); + my_free(read_command_buf); #ifdef _WIN32 free_tmp_sh_file(); free_win_path_patterns(); @@ -6552,7 +6554,6 @@ static inline bool is_escape_char(char c, char in_string) */ -static char *read_command_buf= NULL; static size_t read_command_buflen= 0; static const size_t max_multibyte_length= 6; diff --git a/mysql-test/main/check_constraint.result b/mysql-test/main/check_constraint.result index 8cb1066ba9a99..3511af841666a 100644 --- a/mysql-test/main/check_constraint.result +++ b/mysql-test/main/check_constraint.result @@ -222,3 +222,16 @@ ERROR 23000: CONSTRAINT `t.b` failed for `test`.`t` insert into t values (1,1); ERROR 23000: CONSTRAINT `b` failed for `test`.`t` drop table t; +create table t1 (a int auto_increment primary key, b int, check (b > 5)); +insert t1 (b) values (1); +ERROR 23000: CONSTRAINT `CONSTRAINT_1` failed for `test`.`t1` +insert t1 (b) values (10); +select * from t1 where a is null; +a b +set sql_auto_is_null=1; +select * from t1 where a is null; +a b +1 10 +insert t1 (b) values (1); +ERROR 23000: CONSTRAINT `CONSTRAINT_1` failed for `test`.`t1` +drop table t1; diff --git a/mysql-test/main/check_constraint.test b/mysql-test/main/check_constraint.test index 37fdc7203b1b4..93538fd166635 100644 --- a/mysql-test/main/check_constraint.test +++ b/mysql-test/main/check_constraint.test @@ -162,3 +162,17 @@ insert into t values (-1, 0); insert into t values (1,1); drop table t; + +# +# check constraints and auto_is_null typo +# +create table t1 (a int auto_increment primary key, b int, check (b > 5)); +--error ER_CONSTRAINT_FAILED +insert t1 (b) values (1); +insert t1 (b) values (10); +select * from t1 where a is null; +set sql_auto_is_null=1; +select * from t1 where a is null; +--error ER_CONSTRAINT_FAILED +insert t1 (b) values (1); +drop table t1; diff --git a/mysql-test/main/func_json.result b/mysql-test/main/func_json.result index 3eae5be2492db..aa5685b19fa12 100644 --- a/mysql-test/main/func_json.result +++ b/mysql-test/main/func_json.result @@ -831,6 +831,18 @@ select JSON_VALID( '{"a":1]' ); JSON_VALID( '{"a":1]' ) 0 # +# MDEV-18886 JSON_ARRAY() does not recognise JSON argument. +# +SELECT JSON_ARRAY(_UTF8 'str', JSON_OBJECT(_LATIN1 'plugin', _LATIN1'unix_socket')); +JSON_ARRAY(_UTF8 'str', JSON_OBJECT(_LATIN1 'plugin', _LATIN1'unix_socket')) +["str", {"plugin": "unix_socket"}] +SELECT CHARSET(JSON_ARRAY()); +CHARSET(JSON_ARRAY()) +latin1 +SELECT CHARSET(JSON_OBJECT()); +CHARSET(JSON_OBJECT()) +latin1 +# # End of 10.2 tests # # diff --git a/mysql-test/main/func_json.test b/mysql-test/main/func_json.test index 09ae35ad65386..ea0be8fd75766 100644 --- a/mysql-test/main/func_json.test +++ b/mysql-test/main/func_json.test @@ -484,6 +484,13 @@ SET sql_mode=default; select JSON_VALID( '{"a":1]' ); +--echo # +--echo # MDEV-18886 JSON_ARRAY() does not recognise JSON argument. +--echo # +SELECT JSON_ARRAY(_UTF8 'str', JSON_OBJECT(_LATIN1 'plugin', _LATIN1'unix_socket')); +SELECT CHARSET(JSON_ARRAY()); +SELECT CHARSET(JSON_OBJECT()); + --echo # --echo # End of 10.2 tests --echo # diff --git a/mysql-test/main/mysqlbinlog.result b/mysql-test/main/mysqlbinlog.result index 668952d20d740..8d7f6337c0539 100644 --- a/mysql-test/main/mysqlbinlog.result +++ b/mysql-test/main/mysqlbinlog.result @@ -724,7 +724,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=1253783037/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=0/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -778,7 +778,7 @@ DELIMITER /*!*/; ROLLBACK/*!*/; SET TIMESTAMP=1253783037/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=0/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -813,7 +813,7 @@ ROLLBACK /* added by mysqlbinlog */; DELIMITER /*!*/; SET TIMESTAMP=1266652094/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=0/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -855,7 +855,7 @@ ROLLBACK /* added by mysqlbinlog */; DELIMITER /*!*/; SET TIMESTAMP=1266652094/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=0/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -962,7 +962,7 @@ AAAAAAAAAAAAAAAAAAAgrgJSFzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC # Event: Query thread_id=1 exec_time=0 error_code=0 SET TIMESTAMP=1375907364/*!*/; SET @@session.pseudo_thread_id=1/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=0/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -1045,7 +1045,7 @@ AAAAAAAAAAAAAAAAAAA/rQJSGzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC # Event: Query thread_id=1 exec_time=1 error_code=0 SET TIMESTAMP=1375907141/*!*/; SET @@session.pseudo_thread_id=1/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=0/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -1128,7 +1128,7 @@ AAAAAAAAAAAAAAAAAAAnrAJSHzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC # Event: Query thread_id=1 exec_time=0 error_code=0 SET TIMESTAMP=1375906879/*!*/; SET @@session.pseudo_thread_id=1/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=0/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -1211,7 +1211,7 @@ AAAAAAAAAAAAAAAAAABbsAJSEzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC # Event: Query thread_id=1 exec_time=0 error_code=0 SET TIMESTAMP=1375907933/*!*/; SET @@session.pseudo_thread_id=1/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=0/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; diff --git a/mysql-test/main/reopen_temp_table.result b/mysql-test/main/reopen_temp_table.result index 217aa3c8bad55..ef215366db7ae 100644 --- a/mysql-test/main/reopen_temp_table.result +++ b/mysql-test/main/reopen_temp_table.result @@ -190,3 +190,56 @@ NULL NULL DROP TABLE t; # Cleanup DROP DATABASE temp_db; +USE test; +create temporary table t1 (f char(255), b int, index(b)) engine=MyISAM; +replace into t1 values (null,1),(null,2); +alter table t1 add fulltext key(f); +alter table t1 change if exists a b int, algorithm=inplace; +ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +select * from t1; +f b +NULL 1 +NULL 2 +drop table t1; +create temporary table t1 (f char(255), b int, index(b)) engine=aria transactional=1; +replace into t1 values (null,1),(null,2); +alter table t1 add fulltext key(f); +alter table t1 change if exists a b int, algorithm=inplace; +ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +select * from t1; +f b +NULL 1 +NULL 2 +drop table t1; +create temporary table t1 (f char(255), b int, index(b)) engine=aria transactional=0 row_format=page; +replace into t1 values (null,1),(null,2); +alter table t1 add fulltext key(f); +alter table t1 change if exists a b int, algorithm=inplace; +ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +select * from t1; +f b +NULL 1 +NULL 2 +drop table t1; +create temporary table t1 (f char(255), b int, index(b)) engine=aria transactional=0 row_format=dynamic; +replace into t1 values (null,1),(null,2); +alter table t1 add fulltext key(f); +alter table t1 change if exists a b int, algorithm=inplace; +ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +select * from t1; +f b +NULL 1 +NULL 2 +drop table t1; diff --git a/mysql-test/main/reopen_temp_table.test b/mysql-test/main/reopen_temp_table.test index 2aa6caa165527..2b3ff3bab5ebc 100644 --- a/mysql-test/main/reopen_temp_table.test +++ b/mysql-test/main/reopen_temp_table.test @@ -182,3 +182,43 @@ DROP TABLE t; --echo # Cleanup DROP DATABASE temp_db; +USE test; + +# +# MDEV-17070 Table corruption or Assertion `table->file->stats.records > 0 || error' or Assertion `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())' failed upon actions on temporary table +# +create temporary table t1 (f char(255), b int, index(b)) engine=MyISAM; +replace into t1 values (null,1),(null,2); +alter table t1 add fulltext key(f); +--error ER_ALTER_OPERATION_NOT_SUPPORTED +alter table t1 change if exists a b int, algorithm=inplace; +check table t1; +select * from t1; +drop table t1; + +create temporary table t1 (f char(255), b int, index(b)) engine=aria transactional=1; +replace into t1 values (null,1),(null,2); +alter table t1 add fulltext key(f); +--error ER_ALTER_OPERATION_NOT_SUPPORTED +alter table t1 change if exists a b int, algorithm=inplace; +check table t1; +select * from t1; +drop table t1; + +create temporary table t1 (f char(255), b int, index(b)) engine=aria transactional=0 row_format=page; +replace into t1 values (null,1),(null,2); +alter table t1 add fulltext key(f); +--error ER_ALTER_OPERATION_NOT_SUPPORTED +alter table t1 change if exists a b int, algorithm=inplace; +check table t1; +select * from t1; +drop table t1; + +create temporary table t1 (f char(255), b int, index(b)) engine=aria transactional=0 row_format=dynamic; +replace into t1 values (null,1),(null,2); +alter table t1 add fulltext key(f); +--error ER_ALTER_OPERATION_NOT_SUPPORTED +alter table t1 change if exists a b int, algorithm=inplace; +check table t1; +select * from t1; +drop table t1; diff --git a/mysql-test/suite/binlog/r/binlog_base64_flag.result b/mysql-test/suite/binlog/r/binlog_base64_flag.result index 5e52ea5425138..114272329dedb 100644 --- a/mysql-test/suite/binlog/r/binlog_base64_flag.result +++ b/mysql-test/suite/binlog/r/binlog_base64_flag.result @@ -57,7 +57,7 @@ ROLLBACK/*!*/; <#> use `test`/*!*/; SET TIMESTAMP=1196959712/*!*/; -<#>SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=0/*!*/; +<#>SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; diff --git a/mysql-test/suite/innodb/r/foreign-keys.result b/mysql-test/suite/innodb/r/foreign-keys.result index 4402c5ca2fe49..447013d408dae 100644 --- a/mysql-test/suite/innodb/r/foreign-keys.result +++ b/mysql-test/suite/innodb/r/foreign-keys.result @@ -87,6 +87,19 @@ drop table t3; drop table t2; drop table t1; set debug_sync='reset'; +# +# MDEV-17595 - Server crashes in copy_data_between_tables or +# Assertion `thd->transaction.stmt.is_empty() || +# (thd->state_flags & Open_tables_state::BACKUPS_AVAIL)' +# fails in close_tables_for_reopen upon concurrent +# ALTER TABLE and FLUSH +# +CREATE TABLE t1 (a INT, KEY(a)) ENGINE=InnoDB; +INSERT INTO t1 VALUES(1),(2); +CREATE TABLE t2 (b INT, KEY(b)) ENGINE=InnoDB; +INSERT INTO t2 VALUES(2); +ALTER TABLE t2 ADD FOREIGN KEY(b) REFERENCES t1(a), LOCK=EXCLUSIVE; +DROP TABLE t2, t1; create table t1 (a int primary key, b int) engine=innodb; create table t2 (c int primary key, d int, foreign key (d) references t1 (a) on update cascade) engine=innodb; diff --git a/mysql-test/suite/innodb/t/foreign-keys.test b/mysql-test/suite/innodb/t/foreign-keys.test index 35da5a5d07526..442467b7dbedd 100644 --- a/mysql-test/suite/innodb/t/foreign-keys.test +++ b/mysql-test/suite/innodb/t/foreign-keys.test @@ -112,6 +112,21 @@ drop table t2; drop table t1; set debug_sync='reset'; + +--echo # +--echo # MDEV-17595 - Server crashes in copy_data_between_tables or +--echo # Assertion `thd->transaction.stmt.is_empty() || +--echo # (thd->state_flags & Open_tables_state::BACKUPS_AVAIL)' +--echo # fails in close_tables_for_reopen upon concurrent +--echo # ALTER TABLE and FLUSH +--echo # +CREATE TABLE t1 (a INT, KEY(a)) ENGINE=InnoDB; +INSERT INTO t1 VALUES(1),(2); +CREATE TABLE t2 (b INT, KEY(b)) ENGINE=InnoDB; +INSERT INTO t2 VALUES(2); +ALTER TABLE t2 ADD FOREIGN KEY(b) REFERENCES t1(a), LOCK=EXCLUSIVE; +DROP TABLE t2, t1; + # # FK and prelocking: # child table accesses (reads and writes) wait for locks. diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc index 54bdadc3a32ee..da14c308b8730 100644 --- a/sql/item_jsonfunc.cc +++ b/sql/item_jsonfunc.cc @@ -1483,9 +1483,10 @@ bool Item_func_json_array::fix_length_and_dec() if (arg_count == 0) { - collation.set(&my_charset_utf8_general_ci, + THD* thd= current_thd; + collation.set(thd->variables.collation_connection, DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII); - tmp_val.set_charset(&my_charset_utf8_general_ci); + tmp_val.set_charset(thd->variables.collation_connection); max_length= 2; return FALSE; } diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index 2ead0f44e4960..832036c972f5e 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -1437,6 +1437,7 @@ class Item_func_conv_charset :public Item_str_func (cs->state & MY_CS_UNICODE)); } } + bool is_json_type() { return args[0]->is_json_type(); } String *val_str(String *); longlong val_int() { diff --git a/sql/sql_priv.h b/sql/sql_priv.h index 3744dfce7707c..25384527c105c 100644 --- a/sql/sql_priv.h +++ b/sql/sql_priv.h @@ -126,7 +126,7 @@ #define TMP_TABLE_ALL_COLUMNS (1ULL << 12) // SELECT, intern #define OPTION_WARNINGS (1ULL << 13) // THD, user #define OPTION_AUTO_IS_NULL (1ULL << 14) // THD, user, binlog -#define OPTION_NO_CHECK_CONSTRAINT_CHECKS (1ULL << 14) +#define OPTION_NO_CHECK_CONSTRAINT_CHECKS (1ULL << 15) #define OPTION_SAFE_UPDATES (1ULL << 16) // THD, user #define OPTION_BUFFER_RESULT (1ULL << 17) // SELECT, user #define OPTION_BIN_LOG (1ULL << 18) // THD, user diff --git a/sql/sql_table.cc b/sql/sql_table.cc index b2212fe0ab0df..826484a4ef5ea 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2016, Oracle and/or its affiliates. - Copyright (c) 2010, 2018, MariaDB + Copyright (c) 2010, 2019, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -10021,6 +10021,8 @@ do_continue:; new_table->file->get_foreign_key_list(thd, &fk_list); while ((fk= fk_list_it++)) { + MDL_request mdl_request; + if (lower_case_table_names) { char buf[NAME_LEN]; @@ -10032,19 +10034,14 @@ do_continue:; len = my_casedn_str(files_charset_info, buf); thd->make_lex_string(fk->referenced_table, buf, len); } - if (table_already_fk_prelocked(table_list, fk->referenced_db, - fk->referenced_table, TL_READ_NO_INSERT)) - continue; - TABLE_LIST *tl= (TABLE_LIST *) thd->alloc(sizeof(TABLE_LIST)); - tl->init_one_table_for_prelocking(fk->referenced_db, fk->referenced_table, - NULL, TL_READ_NO_INSERT, TABLE_LIST::PRELOCK_FK, - NULL, 0, &thd->lex->query_tables_last); + mdl_request.init(MDL_key::TABLE, + fk->referenced_db->str, fk->referenced_table->str, + MDL_SHARED_NO_WRITE, MDL_TRANSACTION); + if (thd->mdl_context.acquire_lock(&mdl_request, + thd->variables.lock_wait_timeout)) + goto err_new_table_cleanup; } - - if (open_tables(thd, &table_list->next_global, &tables_opened, 0, - &alter_prelocking_strategy)) - goto err_new_table_cleanup; } } diff --git a/sql/temporary_tables.cc b/sql/temporary_tables.cc index 77e19830119f9..9cdae7d18856d 100644 --- a/sql/temporary_tables.cc +++ b/sql/temporary_tables.cc @@ -504,6 +504,7 @@ bool THD::close_temporary_tables() /* Traverse the table list. */ while ((table= share->all_tmp_tables.pop_front())) { + table->file->extra(HA_EXTRA_PREPARE_FOR_DROP); free_temporary_table(table); } } @@ -588,9 +589,7 @@ bool THD::rename_temporary_table(TABLE *table, @return false Table was dropped true Error */ -bool THD::drop_temporary_table(TABLE *table, - bool *is_trans, - bool delete_table) +bool THD::drop_temporary_table(TABLE *table, bool *is_trans, bool delete_table) { DBUG_ENTER("THD::drop_temporary_table"); @@ -633,7 +632,8 @@ bool THD::drop_temporary_table(TABLE *table, parallel replication */ tab->in_use= this; - + if (delete_table) + tab->file->extra(HA_EXTRA_PREPARE_FOR_DROP); free_temporary_table(tab); } @@ -1435,8 +1435,7 @@ bool THD::log_events_and_free_tmp_shares() @return void */ -void THD::free_tmp_table_share(TMP_TABLE_SHARE *share, - bool delete_table) +void THD::free_tmp_table_share(TMP_TABLE_SHARE *share, bool delete_table) { DBUG_ENTER("THD::free_tmp_table_share"); diff --git a/storage/innobase/include/que0types.h b/storage/innobase/include/que0types.h index 2b5a04811b3be..29134145c3585 100644 --- a/storage/innobase/include/que0types.h +++ b/storage/innobase/include/que0types.h @@ -87,8 +87,9 @@ struct que_common_t{ explicitly */ /** Constructor */ - que_common_t(ulint type, que_node_t* parent) - : type(type), parent(parent), brother(), val(), val_buf_size() + que_common_t(ulint type, que_node_t* parent) : + type(type), parent(parent), brother(NULL), + val(), val_buf_size(0) {} }; diff --git a/storage/innobase/include/row0purge.h b/storage/innobase/include/row0purge.h index a1718398a8339..35e66985561d5 100644 --- a/storage/innobase/include/row0purge.h +++ b/storage/innobase/include/row0purge.h @@ -133,7 +133,14 @@ struct purge_node_t{ /** Constructor */ explicit purge_node_t(que_thr_t* parent) : - common(QUE_NODE_PURGE, parent), heap(mem_heap_create(256)) + common(QUE_NODE_PURGE, parent), + undo_recs(NULL), + unavailable_table_id(0), + heap(mem_heap_create(256)), +#ifdef UNIV_DEBUG + in_progress(false), +#endif + vcol_info() {} #ifdef UNIV_DEBUG diff --git a/storage/innobase/include/row0types.h b/storage/innobase/include/row0types.h index d2aef89f69598..84afbbc3ec715 100644 --- a/storage/innobase/include/row0types.h +++ b/storage/innobase/include/row0types.h @@ -69,6 +69,11 @@ struct purge_vcol_info_t TABLE* mariadb_table; public: + /** Default constructor */ + purge_vcol_info_t() : + requested(false), used(false), first_use(false), + mariadb_table(NULL) + {} /** Reset the state. */ void reset() { diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc index bc2e7082f5594..ba4e7d590066a 100644 --- a/storage/innobase/log/log0recv.cc +++ b/storage/innobase/log/log0recv.cc @@ -2553,16 +2553,20 @@ bool recv_parse_log_recs(lsn_t checkpoint_lsn, store_t store, bool apply) &type, ptr, end_ptr, &space, &page_no, false, &body); - if (recv_sys->found_corrupt_log - || type == MLOG_CHECKPOINT - || (ptr != end_ptr - && (*ptr & MLOG_SINGLE_REC_FLAG))) { - recv_sys->found_corrupt_log = true; + if (recv_sys->found_corrupt_log) { +corrupted_log: recv_report_corrupt_log( ptr, type, space, page_no); return(true); } + if (ptr == end_ptr) { + } else if (type == MLOG_CHECKPOINT + || (*ptr & MLOG_SINGLE_REC_FLAG)) { + recv_sys->found_corrupt_log = true; + goto corrupted_log; + } + if (recv_sys->found_corrupt_fs) { return(true); } diff --git a/storage/innobase/row/row0ftsort.cc b/storage/innobase/row/row0ftsort.cc index 37d2871d5d1cc..e94c9f8217358 100644 --- a/storage/innobase/row/row0ftsort.cc +++ b/storage/innobase/row/row0ftsort.cc @@ -96,8 +96,8 @@ row_merge_create_fts_sort_index( field = dict_index_get_nth_field(new_index, 0); field->name = NULL; field->prefix_len = 0; - field->col = new(mem_heap_zalloc(new_index->heap, sizeof(dict_col_t))) - dict_col_t(); + field->col = static_cast( + mem_heap_zalloc(new_index->heap, sizeof(dict_col_t))); field->col->prtype = idx_field->col->prtype | DATA_NOT_NULL; field->col->mtype = charset == &my_charset_latin1 ? DATA_VARCHAR : DATA_VARMYSQL; @@ -111,8 +111,8 @@ row_merge_create_fts_sort_index( field = dict_index_get_nth_field(new_index, 1); field->name = NULL; field->prefix_len = 0; - field->col = new(mem_heap_zalloc(new_index->heap, sizeof(dict_col_t))) - dict_col_t(); + field->col = static_cast( + mem_heap_zalloc(new_index->heap, sizeof(dict_col_t))); field->col->mtype = DATA_INT; *opt_doc_id_size = FALSE; @@ -150,8 +150,8 @@ row_merge_create_fts_sort_index( field = dict_index_get_nth_field(new_index, 2); field->name = NULL; field->prefix_len = 0; - field->col = new(mem_heap_zalloc(new_index->heap, sizeof(dict_col_t))) - dict_col_t(); + field->col = static_cast( + mem_heap_zalloc(new_index->heap, sizeof(dict_col_t))); field->col->mtype = DATA_INT; field->col->len = 4 ; field->fixed_len = 4; diff --git a/storage/innobase/row/row0purge.cc b/storage/innobase/row/row0purge.cc index 416d72f6a9cb0..ef78a33ff53d1 100644 --- a/storage/innobase/row/row0purge.cc +++ b/storage/innobase/row/row0purge.cc @@ -1031,6 +1031,11 @@ row_purge_parse_undo_rec( return false; case TRX_UNDO_INSERT_METADATA: case TRX_UNDO_INSERT_REC: + /* These records do not store any transaction identifier. + + FIXME: Update SYS_TABLES.ID on both DISCARD TABLESPACE + and IMPORT TABLESPACE to get rid of the repeated lookups! */ + node->trx_id = TRX_ID_MAX; break; default: #ifdef UNIV_DEBUG @@ -1116,9 +1121,7 @@ row_purge_parse_undo_rec( node->table = NULL; err_exit: rw_lock_s_unlock(dict_operation_lock); - if (table_id) { - node->skip(table_id, trx_id); - } + node->skip(table_id, trx_id); return(false); } diff --git a/storage/innobase/trx/trx0purge.cc b/storage/innobase/trx/trx0purge.cc index 97d578c0385f2..d0b56e139d2ce 100644 --- a/storage/innobase/trx/trx0purge.cc +++ b/storage/innobase/trx/trx0purge.cc @@ -148,7 +148,7 @@ purge_graph_build() for (ulint i = 0; i < srv_n_purge_threads; ++i) { que_thr_t* thr = que_thr_create(fork, heap, NULL); - thr->child = new(mem_heap_zalloc(heap, sizeof(purge_node_t))) + thr->child = new(mem_heap_alloc(heap, sizeof(purge_node_t))) purge_node_t(thr); } diff --git a/storage/maria/ma_blockrec.c b/storage/maria/ma_blockrec.c index 29a31a4596f1e..e148e33b9f692 100644 --- a/storage/maria/ma_blockrec.c +++ b/storage/maria/ma_blockrec.c @@ -449,9 +449,7 @@ my_bool _ma_once_end_block_record(MARIA_SHARE *share) if (share->bitmap.file.file >= 0) { if (flush_pagecache_blocks(share->pagecache, &share->bitmap.file, - ((share->temporary || share->deleting) ? - FLUSH_IGNORE_CHANGED : - FLUSH_RELEASE))) + share->deleting ? FLUSH_IGNORE_CHANGED : FLUSH_RELEASE)) res= 1; /* File must be synced as it is going out of the maria_open_list and so diff --git a/storage/maria/ma_close.c b/storage/maria/ma_close.c index 6e85551c24f1f..08bb7cee138de 100644 --- a/storage/maria/ma_close.c +++ b/storage/maria/ma_close.c @@ -47,9 +47,7 @@ int maria_close(register MARIA_HA *info) a global mutex */ if (flush_pagecache_blocks(share->pagecache, &share->kfile, - ((share->temporary || share->deleting) ? - FLUSH_IGNORE_CHANGED : - FLUSH_RELEASE))) + share->deleting ? FLUSH_IGNORE_CHANGED : FLUSH_RELEASE)) error= my_errno; } @@ -113,23 +111,14 @@ int maria_close(register MARIA_HA *info) since the start of the function (very unlikely) */ if (flush_pagecache_blocks(share->pagecache, &share->kfile, - ((share->temporary || share->deleting) ? - FLUSH_IGNORE_CHANGED : - FLUSH_RELEASE))) + share->deleting ? FLUSH_IGNORE_CHANGED : FLUSH_RELEASE)) error= my_errno; #ifdef HAVE_MMAP if (share->file_map) _ma_unmap_file(info); #endif - /* - If we are crashed, we can safely flush the current state as it will - not change the crashed state. - We can NOT write the state in other cases as other threads - may be using the file at this point - IF using --external-locking, which does not apply to Maria. - */ if (((share->changed && share->base.born_transactional) || - maria_is_crashed(info))) + maria_is_crashed(info) || (share->temporary && !share->deleting))) { if (save_global_changed) { diff --git a/storage/maria/ma_extra.c b/storage/maria/ma_extra.c index 9b544aaba59e1..9980574610946 100644 --- a/storage/maria/ma_extra.c +++ b/storage/maria/ma_extra.c @@ -314,6 +314,8 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function, share->state.open_count= 1; share->changed= 1; _ma_mark_file_changed_now(share); + if (share->temporary) + break; /* fall through */ case HA_EXTRA_PREPARE_FOR_RENAME: { diff --git a/storage/maria/ma_open.c b/storage/maria/ma_open.c index cd065d5eb1cbe..750acf73813f2 100644 --- a/storage/maria/ma_open.c +++ b/storage/maria/ma_open.c @@ -1386,7 +1386,7 @@ uint _ma_state_info_write(MARIA_SHARE *share, uint pWrite) if (pWrite & MA_STATE_INFO_WRITE_LOCK) mysql_mutex_lock(&share->intern_lock); - else if (maria_multi_threaded) + else if (maria_multi_threaded && !share->temporary) mysql_mutex_assert_owner(&share->intern_lock); if (share->base.born_transactional && translog_status == TRANSLOG_OK && !maria_in_recovery) diff --git a/storage/myisam/mi_close.c b/storage/myisam/mi_close.c index d68110ead6d92..214f4fc7ce330 100644 --- a/storage/myisam/mi_close.c +++ b/storage/myisam/mi_close.c @@ -65,11 +65,8 @@ int mi_close(register MI_INFO *info) DBUG_EXECUTE_IF("crash_before_flush_keys", if (share->kfile >= 0) DBUG_SUICIDE();); if (share->kfile >= 0 && - flush_key_blocks(share->key_cache, share->kfile, - &share->dirty_part_map, - ((share->temporary || share->deleting) ? - FLUSH_IGNORE_CHANGED : - FLUSH_RELEASE))) + flush_key_blocks(share->key_cache, share->kfile, &share->dirty_part_map, + share->deleting ? FLUSH_IGNORE_CHANGED : FLUSH_RELEASE)) error=my_errno; if (share->kfile >= 0) { @@ -77,10 +74,14 @@ int mi_close(register MI_INFO *info) If we are crashed, we can safely flush the current state as it will not change the crashed state. We can NOT write the state in other cases as other threads - may be using the file at this point - IF using --external-locking. + may be using the file at this point IF using --external-locking. + + Also, write the state if a temporary table is not being dropped + (the server might want to reopen it, and mi_lock_database() only + writes the state for non-temp ones) */ - if (share->mode != O_RDONLY && mi_is_crashed(info)) + if (share->mode != O_RDONLY && + (mi_is_crashed(info) || (share->temporary && !share->deleting))) mi_state_info_write(share->kfile, &share->state, 1); /* Decrement open count must be last I/O on this file. */ _mi_decrement_open_count(info); diff --git a/storage/myisam/mi_extra.c b/storage/myisam/mi_extra.c index 15f0297002f70..618c3251afc8d 100644 --- a/storage/myisam/mi_extra.c +++ b/storage/myisam/mi_extra.c @@ -263,6 +263,8 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) share->deleting= TRUE; share->global_changed= FALSE; /* force writing changed flag */ _mi_mark_file_changed(info); + if (share->temporary) + break; /* fall through */ case HA_EXTRA_PREPARE_FOR_RENAME: DBUG_ASSERT(!share->temporary);