summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/main/check_constraint.result13
-rw-r--r--mysql-test/main/check_constraint.test14
-rw-r--r--mysql-test/main/func_json.result12
-rw-r--r--mysql-test/main/func_json.test7
-rw-r--r--mysql-test/main/mysqlbinlog.result16
-rw-r--r--mysql-test/main/reopen_temp_table.result53
-rw-r--r--mysql-test/main/reopen_temp_table.test40
-rw-r--r--mysql-test/suite/binlog/r/binlog_base64_flag.result2
-rw-r--r--mysql-test/suite/innodb/r/foreign-keys.result13
-rw-r--r--mysql-test/suite/innodb/t/foreign-keys.test15
-rw-r--r--sql/item_jsonfunc.cc5
-rw-r--r--sql/item_strfunc.h1
-rw-r--r--sql/sql_priv.h2
-rw-r--r--sql/sql_table.cc21
-rw-r--r--sql/temporary_tables.cc11
-rw-r--r--storage/innobase/include/que0types.h5
-rw-r--r--storage/innobase/include/row0purge.h9
-rw-r--r--storage/innobase/include/row0types.h5
-rw-r--r--storage/innobase/log/log0recv.cc14
-rw-r--r--storage/innobase/row/row0ftsort.cc12
-rw-r--r--storage/innobase/trx/trx0purge.cc2
-rw-r--r--storage/maria/ma_blockrec.c4
-rw-r--r--storage/maria/ma_close.c17
-rw-r--r--storage/maria/ma_extra.c2
-rw-r--r--storage/maria/ma_open.c2
-rw-r--r--storage/myisam/mi_close.c17
-rw-r--r--storage/myisam/mi_extra.c2
27 files changed, 245 insertions, 71 deletions
diff --git a/mysql-test/main/check_constraint.result b/mysql-test/main/check_constraint.result
index 8cb1066ba9a..3511af84166 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 37fdc7203b1..93538fd1666 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 61dd55850ac..6222d5f1feb 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 fabca504530..bcf0fdfe3fc 100644
--- a/mysql-test/main/func_json.test
+++ b/mysql-test/main/func_json.test
@@ -485,6 +485,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 668952d20d7..8d7f6337c05 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 217aa3c8bad..ef215366db7 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 2aa6caa1655..2b3ff3bab5e 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 5e52ea54251..114272329de 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 4402c5ca2fe..447013d408d 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 35da5a5d075..442467b7dbe 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 588d41479e1..fe8784a7073 100644
--- a/sql/item_jsonfunc.cc
+++ b/sql/item_jsonfunc.cc
@@ -1489,9 +1489,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 29af0b43d9d..a458ff53d11 100644
--- a/sql/item_strfunc.h
+++ b/sql/item_strfunc.h
@@ -1442,6 +1442,7 @@ public:
(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 e48b6195bb7..b179ae6ae40 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 f3bc8fe8bc9..36357ce765d 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
@@ -9857,6 +9857,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];
@@ -9868,19 +9870,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 917a85e6c3b..2f980993fa1 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);
}
@@ -1433,8 +1433,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 2b5a04811b3..29134145c35 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 a1718398a83..35e66985561 100644
--- a/storage/innobase/include/row0purge.h
+++ b/storage/innobase/include/row0purge.h
@@ -133,7 +133,14 @@ public:
/** 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 d2aef89f695..84afbbc3ec7 100644
--- a/storage/innobase/include/row0types.h
+++ b/storage/innobase/include/row0types.h
@@ -69,6 +69,11 @@ private:
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 2a303bd4419..2dac106cabf 100644
--- a/storage/innobase/log/log0recv.cc
+++ b/storage/innobase/log/log0recv.cc
@@ -2643,16 +2643,20 @@ loop:
&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 14e20ae268d..a2a843320bc 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<dict_col_t*>(
+ 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<dict_col_t*>(
+ 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<dict_col_t*>(
+ 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/trx/trx0purge.cc b/storage/innobase/trx/trx0purge.cc
index 980e518daf6..1c9450fb26d 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 eeb922dd3f5..59c9040fe2b 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 6e85551c24f..08bb7cee138 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 9feead42cf7..47c796daab3 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 13f7a64e786..3d77d7e2c10 100644
--- a/storage/maria/ma_open.c
+++ b/storage/maria/ma_open.c
@@ -1375,7 +1375,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 d68110ead6d..214f4fc7ce3 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 c10bf61a477..dcb79a8dc3e 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);