Commit b32bc70e authored by Marko Mäkelä's avatar Marko Mäkelä

Merge 10.2 into 10.3

parents f010c908 f72760df
......@@ -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;
......@@ -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;
......@@ -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
#
#
......
......@@ -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 #
......
......@@ -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 *//*!*/;
......
......@@ -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;
......@@ -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;
......@@ -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 *//*!*/;
......
......@@ -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;
......
......@@ -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.
......
......@@ -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;
}
......
......@@ -1442,6 +1442,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()
{
......
......@@ -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
......
/*
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;
}
}
......
......@@ -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");
......
......@@ -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)
{}
};
......
......@@ -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
......
......@@ -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()
{
......
......@@ -2643,16 +2643,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);
}
......
......@@ -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;
......
......@@ -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);
}
......
......@@ -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
......
......@@ -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)
{
......
......@@ -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:
{
......
......@@ -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)
......
......@@ -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);
......
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment