Merge 10.1 to 10.2

Follow-up fix to MDEV-14008: Let Field_double::val_uint() silently
return 0 on error
This commit is contained in:
Marko Mäkelä 2017-12-19 16:48:28 +02:00
commit 8d70097c21
22 changed files with 218 additions and 239 deletions

View File

@ -1060,11 +1060,13 @@ struct my_option xb_server_options[] =
(G_PTR*) &defaults_group, (G_PTR*) &defaults_group, (G_PTR*) &defaults_group, (G_PTR*) &defaults_group,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"plugin-dir", OPT_PLUGIN_DIR, "Server plugin directory", {"plugin-dir", OPT_PLUGIN_DIR,
"Server plugin directory. Used to load encryption plugin during 'prepare' phase."
"Has no effect in the 'backup' phase (plugin directory during backup is the same as server's)",
&xb_plugin_dir, &xb_plugin_dir, &xb_plugin_dir, &xb_plugin_dir,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "plugin-load", OPT_PLUGIN_LOAD, "encrypton plugin to load", { "plugin-load", OPT_PLUGIN_LOAD, "encrypton plugin to load during 'prepare' phase.",
&xb_plugin_load, &xb_plugin_load, &xb_plugin_load, &xb_plugin_load,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },

View File

@ -1351,3 +1351,15 @@ t CREATE TABLE `t` (
KEY `i` (`i`) KEY `i` (`i`)
) ENGINE=InnoDB AUTO_INCREMENT=401 DEFAULT CHARSET=latin1 ) ENGINE=InnoDB AUTO_INCREMENT=401 DEFAULT CHARSET=latin1
DROP TABLE t; DROP TABLE t;
#
# MDEV-14008 Assertion failing: `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())
#
SET sql_mode=STRICT_ALL_TABLES;
CREATE TABLE t1 (
c1 DOUBLE NOT NULL PRIMARY KEY AUTO_INCREMENT
) ENGINE=InnoDB AUTO_INCREMENT=10000000000000000000;
INSERT INTO t1 VALUES ();
SELECT * FROM t1;
c1
1e19
DROP TABLE t1;

View File

@ -683,3 +683,15 @@ INSERT INTO t VALUES (NULL);
SELECT * FROM t; SELECT * FROM t;
SHOW CREATE TABLE t; SHOW CREATE TABLE t;
DROP TABLE t; DROP TABLE t;
--echo #
--echo # MDEV-14008 Assertion failing: `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())
--echo #
SET sql_mode=STRICT_ALL_TABLES;
CREATE TABLE t1 (
c1 DOUBLE NOT NULL PRIMARY KEY AUTO_INCREMENT
) ENGINE=InnoDB AUTO_INCREMENT=10000000000000000000;
INSERT INTO t1 VALUES ();
SELECT * FROM t1;
DROP TABLE t1;

View File

@ -0,0 +1,10 @@
CREATE TABLE t1 (i INT) ENGINE=MYISAM
PARTITION BY LIST(i) (
PARTITION p0 VALUES IN (1),
PARTITION p1 VALUES IN (2)
);
ALTER TABLE t1 ROW_FORMAT=COMPRESSED;
ALTER TABLE t1 DROP PARTITION p1;
SELECT * FROM t1;
i
DROP TABLE t1;

View File

@ -0,0 +1,17 @@
#
# MDEV-14641 Incompatible key or row definition between the MariaDB .frm file and the information in the storage engine
#
--source include/have_partition.inc
CREATE TABLE t1 (i INT) ENGINE=MYISAM
PARTITION BY LIST(i) (
PARTITION p0 VALUES IN (1),
PARTITION p1 VALUES IN (2)
);
ALTER TABLE t1 ROW_FORMAT=COMPRESSED;
ALTER TABLE t1 DROP PARTITION p1;
SELECT * FROM t1;
# Cleanup
DROP TABLE t1;

View File

@ -118,3 +118,19 @@ B
select count(*) from events_statements_history where sql_text like "%..."; select count(*) from events_statements_history where sql_text like "%...";
count(*) count(*)
2 2
use test;
create table t1 (id int);
insert into t1 values (1), (2), (3);
truncate performance_schema.events_statements_history;
select * from t1;
id
1
2
3
insert into t1 select RAND()*10000 from t1;
select sql_text, rows_examined from performance_schema.events_statements_history;
sql_text rows_examined
truncate performance_schema.events_statements_history 0
select * from t1 3
insert into t1 select RAND()*10000 from t1 6
drop table t1;

View File

@ -207,3 +207,18 @@ select 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
select _utf8mb4 'васÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑ' as B; select _utf8mb4 'васÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑвасÑ' as B;
select count(*) from events_statements_history where sql_text like "%..."; select count(*) from events_statements_history where sql_text like "%...";
#
# MDEV-10486 MariaDB 10.x does not update rows_examined in performance_schema tables
# Verify that the rows_examined counter is set properly.
use test;
create table t1 (id int);
insert into t1 values (1), (2), (3);
truncate performance_schema.events_statements_history;
select * from t1;
insert into t1 select RAND()*10000 from t1;
select sql_text, rows_examined from performance_schema.events_statements_history;
drop table t1;

View File

@ -420,7 +420,7 @@ Events::create_event(THD *thd, Event_parse_data *parse_data)
DBUG_RETURN(ret); DBUG_RETURN(ret);
#ifdef WITH_WSREP #ifdef WITH_WSREP
error: error:
DBUG_RETURN(TRUE); DBUG_RETURN(true);
#endif /* WITH_WSREP */ #endif /* WITH_WSREP */
} }

View File

@ -4807,6 +4807,15 @@ double Field_double::val_real(void)
} }
longlong Field_double::val_int_from_real(bool want_unsigned_result)
{
Converter_double_to_longlong conv(val_real(), want_unsigned_result);
if (!want_unsigned_result && conv.error())
conv.push_warning(get_thd(), Field_double::val_real(), false);
return conv.result();
}
my_decimal *Field_real::val_decimal(my_decimal *decimal_value) my_decimal *Field_real::val_decimal(my_decimal *decimal_value)
{ {
ASSERT_COLUMN_MARKED_FOR_READ; ASSERT_COLUMN_MARKED_FOR_READ;

View File

@ -851,6 +851,10 @@ public:
{ return store(ls->str, (uint32) ls->length, cs); } { return store(ls->str, (uint32) ls->length, cs); }
virtual double val_real(void)=0; virtual double val_real(void)=0;
virtual longlong val_int(void)=0; virtual longlong val_int(void)=0;
virtual ulonglong val_uint(void)
{
return (ulonglong) val_int();
}
virtual bool val_bool(void)= 0; virtual bool val_bool(void)= 0;
virtual my_decimal *val_decimal(my_decimal *); virtual my_decimal *val_decimal(my_decimal *);
inline String *val_str(String *str) { return val_str(str, str); } inline String *val_str(String *str) { return val_str(str, str); }
@ -2175,6 +2179,7 @@ private:
class Field_double :public Field_real { class Field_double :public Field_real {
longlong val_int_from_real(bool want_unsigned_result);
public: public:
Field_double(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, Field_double(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, uchar null_bit_arg,
@ -2211,13 +2216,8 @@ public:
int store(longlong nr, bool unsigned_val); int store(longlong nr, bool unsigned_val);
int reset(void) { bzero(ptr,sizeof(double)); return 0; } int reset(void) { bzero(ptr,sizeof(double)); return 0; }
double val_real(void); double val_real(void);
longlong val_int(void) longlong val_int(void) { return val_int_from_real(false); }
{ ulonglong val_uint(void) { return (ulonglong) val_int_from_real(true); }
Converter_double_to_longlong conv(Field_double::val_real(), false);
if (conv.error())
conv.push_warning(get_thd(), Field_double::val_real(), false);
return conv.result();
}
String *val_str(String*,String *); String *val_str(String*,String *);
bool send_binary(Protocol *protocol); bool send_binary(Protocol *protocol);
int cmp(const uchar *,const uchar *); int cmp(const uchar *,const uchar *);

View File

@ -1764,6 +1764,13 @@ struct HA_CREATE_INFO: public Table_scope_and_contents_source_st,
used_fields|= (HA_CREATE_USED_CHARSET | HA_CREATE_USED_DEFAULT_CHARSET); used_fields|= (HA_CREATE_USED_CHARSET | HA_CREATE_USED_DEFAULT_CHARSET);
return false; return false;
} }
ulong table_options_with_row_type()
{
if (row_type == ROW_TYPE_DYNAMIC || row_type == ROW_TYPE_PAGE)
return table_options | HA_OPTION_PACK_RECORD;
else
return table_options;
}
}; };

View File

@ -2379,11 +2379,12 @@ com_multi_end:
THD_STAGE_INFO(thd, stage_cleaning_up); THD_STAGE_INFO(thd, stage_cleaning_up);
thd->reset_query(); thd->reset_query();
thd->set_examined_row_count(0); // For processlist
thd->set_command(COM_SLEEP);
/* Performance Schema Interface instrumentation, end */ /* Performance Schema Interface instrumentation, end */
MYSQL_END_STATEMENT(thd->m_statement_psi, thd->get_stmt_da()); MYSQL_END_STATEMENT(thd->m_statement_psi, thd->get_stmt_da());
thd->set_examined_row_count(0); // For processlist
thd->set_command(COM_SLEEP);
thd->m_statement_psi= NULL; thd->m_statement_psi= NULL;
thd->m_digest= NULL; thd->m_digest= NULL;

View File

@ -6560,10 +6560,7 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
lpt->part_info= part_info; lpt->part_info= part_info;
lpt->alter_info= alter_info; lpt->alter_info= alter_info;
lpt->create_info= create_info; lpt->create_info= create_info;
lpt->db_options= create_info->table_options; lpt->db_options= create_info->table_options_with_row_type();
if (create_info->row_type != ROW_TYPE_FIXED &&
create_info->row_type != ROW_TYPE_DEFAULT)
lpt->db_options|= HA_OPTION_PACK_RECORD;
lpt->table= table; lpt->table= table;
lpt->key_info_buffer= 0; lpt->key_info_buffer= 0;
lpt->key_count= 0; lpt->key_count= 0;

View File

@ -4434,10 +4434,7 @@ handler *mysql_create_frm_image(THD *thd,
set_table_default_charset(thd, create_info, (char*) db); set_table_default_charset(thd, create_info, (char*) db);
db_options= create_info->table_options; db_options= create_info->table_options_with_row_type();
if (create_info->row_type == ROW_TYPE_DYNAMIC ||
create_info->row_type == ROW_TYPE_PAGE)
db_options|= HA_OPTION_PACK_RECORD;
if (!(file= get_new_handler((TABLE_SHARE*) 0, thd->mem_root, if (!(file= get_new_handler((TABLE_SHARE*) 0, thd->mem_root,
create_info->db_type))) create_info->db_type)))

View File

@ -430,14 +430,14 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views,
lex->link_first_table_back(view, link_to_local); lex->link_first_table_back(view, link_to_local);
view->open_type= OT_BASE_ONLY; view->open_type= OT_BASE_ONLY;
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL)
if (check_dependencies_in_with_clauses(lex->with_clauses_list)) if (check_dependencies_in_with_clauses(lex->with_clauses_list))
{ {
res= TRUE; res= TRUE;
goto err; goto err;
} }
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL)
/* /*
ignore lock specs for CREATE statement ignore lock specs for CREATE statement
*/ */

View File

@ -8614,7 +8614,7 @@ no_commit:
col_max_value = innobase_get_int_col_max_value(table->next_number_field); col_max_value = innobase_get_int_col_max_value(table->next_number_field);
/* Get the value that MySQL attempted to store in the table.*/ /* Get the value that MySQL attempted to store in the table.*/
auto_inc = table->next_number_field->val_int(); auto_inc = table->next_number_field->val_uint();
switch (error) { switch (error) {
case DB_DUPLICATE_KEY: case DB_DUPLICATE_KEY:
@ -9080,12 +9080,7 @@ calc_row_difference(
if (field != table->found_next_number_field if (field != table->found_next_number_field
|| dfield_is_null(&ufield->new_val)) { || dfield_is_null(&ufield->new_val)) {
} else { } else {
auto_inc = row_parse_int( auto_inc = field->val_uint();
static_cast<const byte*>(
ufield->new_val.data),
ufield->new_val.len,
col->mtype,
col->prtype & DATA_UNSIGNED);
} }
} }
n_changed++; n_changed++;

View File

@ -75,7 +75,7 @@ ibool row_rollback_on_timeout = FALSE;
/** Chain node of the list of tables to drop in the background. */ /** Chain node of the list of tables to drop in the background. */
struct row_mysql_drop_t{ struct row_mysql_drop_t{
char* table_name; /*!< table name */ table_id_t table_id; /*!< table id */
UT_LIST_NODE_T(row_mysql_drop_t)row_mysql_drop_list; UT_LIST_NODE_T(row_mysql_drop_t)row_mysql_drop_list;
/*!< list chain node */ /*!< list chain node */
}; };
@ -112,19 +112,6 @@ row_mysql_is_system_table(
|| 0 == strcmp(name + 6, "db")); || 0 == strcmp(name + 6, "db"));
} }
/*********************************************************************//**
If a table is not yet in the drop list, adds the table to the list of tables
which the master thread drops in background. We need this on Unix because in
ALTER TABLE MySQL may call drop table even if the table has running queries on
it. Also, if there are running foreign key checks on the table, we drop the
table lazily.
@return TRUE if the table was not yet in the drop list, and was added there */
static
ibool
row_add_table_to_background_drop_list(
/*==================================*/
const char* name); /*!< in: table name */
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
/** Wait for the background drop list to become empty. */ /** Wait for the background drop list to become empty. */
void void
@ -2817,7 +2804,7 @@ loop:
mutex_enter(&row_drop_list_mutex); mutex_enter(&row_drop_list_mutex);
ut_a(row_mysql_drop_list_inited); ut_a(row_mysql_drop_list_inited);
next:
drop = UT_LIST_GET_FIRST(row_mysql_drop_list); drop = UT_LIST_GET_FIRST(row_mysql_drop_list);
n_tables = UT_LIST_GET_LEN(row_mysql_drop_list); n_tables = UT_LIST_GET_LEN(row_mysql_drop_list);
@ -2830,61 +2817,38 @@ loop:
return(n_tables + n_tables_dropped); return(n_tables + n_tables_dropped);
} }
DBUG_EXECUTE_IF("row_drop_tables_in_background_sleep", table = dict_table_open_on_id(drop->table_id, FALSE,
os_thread_sleep(5000000); DICT_TABLE_OP_OPEN_ONLY_IF_CACHED);
);
table = dict_table_open_on_name(drop->table_name, FALSE, FALSE, if (!table) {
DICT_ERR_IGNORE_NONE); n_tables_dropped++;
mutex_enter(&row_drop_list_mutex);
if (table == NULL) { UT_LIST_REMOVE(row_mysql_drop_list, drop);
/* If for some reason the table has already been dropped MONITOR_DEC(MONITOR_BACKGROUND_DROP_TABLE);
through some other mechanism, do not try to drop it */ ut_free(drop);
goto next;
goto already_dropped;
}
if (!table->to_be_dropped) {
/* There is a scenario: the old table is dropped
just after it's added into drop list, and new
table with the same name is created, then we try
to drop the new table in background. */
dict_table_close(table, FALSE, FALSE);
goto already_dropped;
} }
ut_a(!table->can_be_evicted); ut_a(!table->can_be_evicted);
if (!table->to_be_dropped) {
dict_table_close(table, FALSE, FALSE);
mutex_enter(&row_drop_list_mutex);
UT_LIST_REMOVE(row_mysql_drop_list, drop);
UT_LIST_ADD_LAST(row_mysql_drop_list, drop);
goto next;
}
dict_table_close(table, FALSE, FALSE); dict_table_close(table, FALSE, FALSE);
if (DB_SUCCESS != row_drop_table_for_mysql_in_background( if (DB_SUCCESS != row_drop_table_for_mysql_in_background(
drop->table_name)) { table->name.m_name)) {
/* If the DROP fails for some table, we return, and let the /* If the DROP fails for some table, we return, and let the
main thread retry later */ main thread retry later */
return(n_tables + n_tables_dropped); return(n_tables + n_tables_dropped);
} }
n_tables_dropped++;
already_dropped:
mutex_enter(&row_drop_list_mutex);
UT_LIST_REMOVE(row_mysql_drop_list, drop);
MONITOR_DEC(MONITOR_BACKGROUND_DROP_TABLE);
ib::info() << "Dropped table "
<< ut_get_name(NULL, drop->table_name)
<< " in background drop queue.",
ut_free(drop->table_name);
ut_free(drop);
mutex_exit(&row_drop_list_mutex);
goto loop; goto loop;
} }
@ -2915,14 +2879,13 @@ which the master thread drops in background. We need this on Unix because in
ALTER TABLE MySQL may call drop table even if the table has running queries on ALTER TABLE MySQL may call drop table even if the table has running queries on
it. Also, if there are running foreign key checks on the table, we drop the it. Also, if there are running foreign key checks on the table, we drop the
table lazily. table lazily.
@return TRUE if the table was not yet in the drop list, and was added there */ @return whether background DROP TABLE was scheduled for the first time */
static static
ibool bool
row_add_table_to_background_drop_list( row_add_table_to_background_drop_list(table_id_t table_id)
/*==================================*/
const char* name) /*!< in: table name */
{ {
row_mysql_drop_t* drop; row_mysql_drop_t* drop;
bool added = true;
mutex_enter(&row_drop_list_mutex); mutex_enter(&row_drop_list_mutex);
@ -2933,27 +2896,21 @@ row_add_table_to_background_drop_list(
drop != NULL; drop != NULL;
drop = UT_LIST_GET_NEXT(row_mysql_drop_list, drop)) { drop = UT_LIST_GET_NEXT(row_mysql_drop_list, drop)) {
if (strcmp(drop->table_name, name) == 0) { if (drop->table_id == table_id) {
/* Already in the list */ added = false;
goto func_exit;
mutex_exit(&row_drop_list_mutex);
return(FALSE);
} }
} }
drop = static_cast<row_mysql_drop_t*>( drop = static_cast<row_mysql_drop_t*>(ut_malloc_nokey(sizeof *drop));
ut_malloc_nokey(sizeof(row_mysql_drop_t))); drop->table_id = table_id;
drop->table_name = mem_strdup(name);
UT_LIST_ADD_LAST(row_mysql_drop_list, drop); UT_LIST_ADD_LAST(row_mysql_drop_list, drop);
MONITOR_INC(MONITOR_BACKGROUND_DROP_TABLE); MONITOR_INC(MONITOR_BACKGROUND_DROP_TABLE);
func_exit:
mutex_exit(&row_drop_list_mutex); mutex_exit(&row_drop_list_mutex);
return added;
return(TRUE);
} }
/** Reassigns the table identifier of a table. /** Reassigns the table identifier of a table.
@ -3687,7 +3644,7 @@ row_drop_table_for_mysql(
DBUG_EXECUTE_IF("row_drop_table_add_to_background", DBUG_EXECUTE_IF("row_drop_table_add_to_background",
row_add_table_to_background_drop_list(table->name.m_name); row_add_table_to_background_drop_list(table->id);
err = DB_SUCCESS; err = DB_SUCCESS;
goto funct_exit; goto funct_exit;
); );
@ -3699,28 +3656,17 @@ row_drop_table_for_mysql(
checks take an IS or IX lock on the table. */ checks take an IS or IX lock on the table. */
if (table->n_foreign_key_checks_running > 0) { if (table->n_foreign_key_checks_running > 0) {
if (row_add_table_to_background_drop_list(table->id)) {
const char* save_tablename = table->name.m_name;
ibool added;
added = row_add_table_to_background_drop_list(save_tablename);
if (added) {
ib::info() << "You are trying to drop table " ib::info() << "You are trying to drop table "
<< table->name << table->name
<< " though there is a foreign key check" << " though there is a foreign key check"
" running on it. Adding the table to the" " running on it. Adding the table to the"
" background drop queue."; " background drop queue.";
}
/* We return DB_SUCCESS to MySQL though the drop will /* We return DB_SUCCESS to MySQL though the drop will
happen lazily later */ happen lazily later */
err = DB_SUCCESS; err = DB_SUCCESS;
} else {
/* The table is already in the background drop list */
err = DB_ERROR;
}
goto funct_exit; goto funct_exit;
} }
@ -3745,12 +3691,7 @@ row_drop_table_for_mysql(
lock_remove_all_on_table(table, TRUE); lock_remove_all_on_table(table, TRUE);
ut_a(table->n_rec_locks == 0); ut_a(table->n_rec_locks == 0);
} else if (table->get_ref_count() > 0 || table->n_rec_locks > 0) { } else if (table->get_ref_count() > 0 || table->n_rec_locks > 0) {
ibool added; if (row_add_table_to_background_drop_list(table->id)) {
added = row_add_table_to_background_drop_list(
table->name.m_name);
if (added) {
ib::info() << "MySQL is trying to drop table " ib::info() << "MySQL is trying to drop table "
<< table->name << table->name
<< " though there are still open handles to" << " though there are still open handles to"

View File

@ -4,13 +4,17 @@ IF(CMAKE_VERSION VERSION_LESS "2.8.9")
MESSAGE(STATUS "CMake 2.8.9 or higher is required by TokuDB") MESSAGE(STATUS "CMake 2.8.9 or higher is required by TokuDB")
ELSEIF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR ELSEIF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR
CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64") CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64")
# tokudb requires F_NOCACHE, O_DIRECT, and designated initializers # tokudb requires F_NOCACHE or O_DIRECT, and designated initializers
CHECK_CXX_SOURCE_COMPILES( CHECK_CXX_SOURCE_COMPILES(
" "
#include <fcntl.h> #include <fcntl.h>
struct a {int b; int c; }; struct a {int b; int c; };
struct a d = { .b=1, .c=2 }; struct a d = { .b=1, .c=2 };
int main() { return F_NOCACHE + O_DIRECT; } #if defined(O_DIRECT) || defined(F_NOCACHE)
int main() { return 0; }
#else
#error
#endif
" TOKUDB_OK) " TOKUDB_OK)
ENDIF() ENDIF()

View File

@ -8844,7 +8844,7 @@ no_commit:
table->next_number_field); table->next_number_field);
/* Get the value that MySQL attempted to store in the table.*/ /* Get the value that MySQL attempted to store in the table.*/
auto_inc = table->next_number_field->val_int(); auto_inc = table->next_number_field->val_uint();
switch (error) { switch (error) {
case DB_DUPLICATE_KEY: case DB_DUPLICATE_KEY:
@ -9436,7 +9436,7 @@ ha_innobase::update_row(
ulonglong auto_inc; ulonglong auto_inc;
ulonglong col_max_value; ulonglong col_max_value;
auto_inc = table->next_number_field->val_int(); auto_inc = table->next_number_field->val_uint();
/* We need the upper limit of the col type to check for /* We need the upper limit of the col type to check for
whether we update the table autoinc counter or not. */ whether we update the table autoinc counter or not. */

View File

@ -74,7 +74,7 @@ UNIV_INTERN ibool row_rollback_on_timeout = FALSE;
/** Chain node of the list of tables to drop in the background. */ /** Chain node of the list of tables to drop in the background. */
struct row_mysql_drop_t{ struct row_mysql_drop_t{
char* table_name; /*!< table name */ table_id_t table_id; /*!< table id */
UT_LIST_NODE_T(row_mysql_drop_t)row_mysql_drop_list; UT_LIST_NODE_T(row_mysql_drop_t)row_mysql_drop_list;
/*!< list chain node */ /*!< list chain node */
}; };
@ -137,19 +137,6 @@ row_mysql_is_system_table(
|| 0 == strcmp(name + 6, "db")); || 0 == strcmp(name + 6, "db"));
} }
/*********************************************************************//**
If a table is not yet in the drop list, adds the table to the list of tables
which the master thread drops in background. We need this on Unix because in
ALTER TABLE MySQL may call drop table even if the table has running queries on
it. Also, if there are running foreign key checks on the table, we drop the
table lazily.
@return TRUE if the table was not yet in the drop list, and was added there */
static
ibool
row_add_table_to_background_drop_list(
/*==================================*/
const char* name); /*!< in: table name */
/*******************************************************************//** /*******************************************************************//**
Delays an INSERT, DELETE or UPDATE operation if the purge is lagging. */ Delays an INSERT, DELETE or UPDATE operation if the purge is lagging. */
static static
@ -2787,7 +2774,7 @@ loop:
mutex_enter(&row_drop_list_mutex); mutex_enter(&row_drop_list_mutex);
ut_a(row_mysql_drop_list_inited); ut_a(row_mysql_drop_list_inited);
next:
drop = UT_LIST_GET_FIRST(row_mysql_drop_list); drop = UT_LIST_GET_FIRST(row_mysql_drop_list);
n_tables = UT_LIST_GET_LEN(row_mysql_drop_list); n_tables = UT_LIST_GET_LEN(row_mysql_drop_list);
@ -2800,62 +2787,39 @@ loop:
return(n_tables + n_tables_dropped); return(n_tables + n_tables_dropped);
} }
DBUG_EXECUTE_IF("row_drop_tables_in_background_sleep", table = dict_table_open_on_id(drop->table_id, FALSE,
os_thread_sleep(5000000); DICT_TABLE_OP_NORMAL);
);
table = dict_table_open_on_name(drop->table_name, FALSE, FALSE, if (!table) {
DICT_ERR_IGNORE_NONE); n_tables_dropped++;
mutex_enter(&row_drop_list_mutex);
if (table == NULL) { UT_LIST_REMOVE(row_mysql_drop_list, row_mysql_drop_list, drop);
/* If for some reason the table has already been dropped MONITOR_DEC(MONITOR_BACKGROUND_DROP_TABLE);
through some other mechanism, do not try to drop it */ ut_free(drop);
goto next;
goto already_dropped;
}
if (!table->to_be_dropped) {
/* There is a scenario: the old table is dropped
just after it's added into drop list, and new
table with the same name is created, then we try
to drop the new table in background. */
dict_table_close(table, FALSE, FALSE);
goto already_dropped;
} }
ut_a(!table->can_be_evicted); ut_a(!table->can_be_evicted);
if (!table->to_be_dropped) {
dict_table_close(table, FALSE, FALSE);
mutex_enter(&row_drop_list_mutex);
UT_LIST_REMOVE(row_mysql_drop_list, row_mysql_drop_list, drop);
UT_LIST_ADD_LAST(row_mysql_drop_list, row_mysql_drop_list,
drop);
goto next;
}
dict_table_close(table, FALSE, FALSE); dict_table_close(table, FALSE, FALSE);
if (DB_SUCCESS != row_drop_table_for_mysql_in_background( if (DB_SUCCESS != row_drop_table_for_mysql_in_background(
drop->table_name)) { table->name)) {
/* If the DROP fails for some table, we return, and let the /* If the DROP fails for some table, we return, and let the
main thread retry later */ main thread retry later */
return(n_tables + n_tables_dropped); return(n_tables + n_tables_dropped);
} }
n_tables_dropped++;
already_dropped:
mutex_enter(&row_drop_list_mutex);
UT_LIST_REMOVE(row_mysql_drop_list, row_mysql_drop_list, drop);
MONITOR_DEC(MONITOR_BACKGROUND_DROP_TABLE);
ut_print_timestamp(stderr);
fputs(" InnoDB: Dropped table ", stderr);
ut_print_name(stderr, NULL, TRUE, drop->table_name);
fputs(" in background drop queue.\n", stderr);
mem_free(drop->table_name);
mem_free(drop);
mutex_exit(&row_drop_list_mutex);
goto loop; goto loop;
} }
@ -2887,14 +2851,13 @@ which the master thread drops in background. We need this on Unix because in
ALTER TABLE MySQL may call drop table even if the table has running queries on ALTER TABLE MySQL may call drop table even if the table has running queries on
it. Also, if there are running foreign key checks on the table, we drop the it. Also, if there are running foreign key checks on the table, we drop the
table lazily. table lazily.
@return TRUE if the table was not yet in the drop list, and was added there */ @return whether background DROP TABLE was scheduled for the first time */
static static
ibool bool
row_add_table_to_background_drop_list( row_add_table_to_background_drop_list(table_id_t table_id)
/*==================================*/
const char* name) /*!< in: table name */
{ {
row_mysql_drop_t* drop; row_mysql_drop_t* drop;
bool added = true;
mutex_enter(&row_drop_list_mutex); mutex_enter(&row_drop_list_mutex);
@ -2905,31 +2868,21 @@ row_add_table_to_background_drop_list(
drop != NULL; drop != NULL;
drop = UT_LIST_GET_NEXT(row_mysql_drop_list, drop)) { drop = UT_LIST_GET_NEXT(row_mysql_drop_list, drop)) {
if (strcmp(drop->table_name, name) == 0) { if (drop->table_id == table_id) {
/* Already in the list */ added = false;
goto func_exit;
mutex_exit(&row_drop_list_mutex);
return(FALSE);
} }
} }
drop = static_cast<row_mysql_drop_t*>( drop = static_cast<row_mysql_drop_t*>(ut_malloc(sizeof *drop));
mem_alloc(sizeof(row_mysql_drop_t))); drop->table_id = table_id;
drop->table_name = mem_strdup(name);
UT_LIST_ADD_LAST(row_mysql_drop_list, row_mysql_drop_list, drop); UT_LIST_ADD_LAST(row_mysql_drop_list, row_mysql_drop_list, drop);
MONITOR_INC(MONITOR_BACKGROUND_DROP_TABLE); MONITOR_INC(MONITOR_BACKGROUND_DROP_TABLE);
func_exit:
/* fputs("InnoDB: Adding table ", stderr);
ut_print_name(stderr, trx, TRUE, drop->table_name);
fputs(" to background drop list\n", stderr); */
mutex_exit(&row_drop_list_mutex); mutex_exit(&row_drop_list_mutex);
return added;
return(TRUE);
} }
/*********************************************************************//** /*********************************************************************//**
@ -4150,7 +4103,7 @@ row_drop_table_for_mysql(
DBUG_EXECUTE_IF("row_drop_table_add_to_background", DBUG_EXECUTE_IF("row_drop_table_add_to_background",
row_add_table_to_background_drop_list(table->name); row_add_table_to_background_drop_list(table->id);
err = DB_SUCCESS; err = DB_SUCCESS;
goto funct_exit; goto funct_exit;
); );
@ -4162,33 +4115,22 @@ row_drop_table_for_mysql(
checks take an IS or IX lock on the table. */ checks take an IS or IX lock on the table. */
if (table->n_foreign_key_checks_running > 0) { if (table->n_foreign_key_checks_running > 0) {
if (row_add_table_to_background_drop_list(table->id)) {
const char* save_tablename = table->name;
ibool added;
added = row_add_table_to_background_drop_list(save_tablename);
if (added) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fputs(" InnoDB: You are trying to drop table ", fputs(" InnoDB: You are trying to drop table ",
stderr); stderr);
ut_print_name(stderr, trx, TRUE, save_tablename); ut_print_name(stderr, trx, TRUE, table->name);
fputs("\n" fputs("\n"
"InnoDB: though there is a" "InnoDB: though there is a"
" foreign key check running on it.\n" " foreign key check running on it.\n"
"InnoDB: Adding the table to" "InnoDB: Adding the table to"
" the background drop queue.\n", " the background drop queue.\n",
stderr); stderr);
}
/* We return DB_SUCCESS to MySQL though the drop will /* We return DB_SUCCESS to MySQL though the drop will
happen lazily later */ happen lazily later */
err = DB_SUCCESS; err = DB_SUCCESS;
} else {
/* The table is already in the background drop list */
err = DB_ERROR;
}
goto funct_exit; goto funct_exit;
} }
@ -4213,11 +4155,7 @@ row_drop_table_for_mysql(
lock_remove_all_on_table(table, TRUE); lock_remove_all_on_table(table, TRUE);
ut_a(table->n_rec_locks == 0); ut_a(table->n_rec_locks == 0);
} else if (table->n_ref_count > 0 || table->n_rec_locks > 0) { } else if (table->n_ref_count > 0 || table->n_rec_locks > 0) {
ibool added; if (row_add_table_to_background_drop_list(table->id)) {
added = row_add_table_to_background_drop_list(table->name);
if (added) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fputs(" InnoDB: Warning: MySQL is" fputs(" InnoDB: Warning: MySQL is"
" trying to drop table ", stderr); " trying to drop table ", stderr);

View File

@ -13,7 +13,9 @@
# and probably others # and probably others
[Unit] [Unit]
Description=MariaDB database server Description=MariaDB @VERSION@ database server
Documentation=man:mysqld(8)
Documentation=https://mariadb.com/kb/en/library/systemd/
After=network.target After=network.target
After=syslog.target After=syslog.target
@ -76,7 +78,7 @@ ExecStartPre=/bin/sh -c "[ ! -e @bindir@/galera_recovery ] && VAR= || \
# Start main service # Start main service
# MYSQLD_OPTS here is for users to set in /etc/systemd/system/mariadb.service.d/MY_SPECIAL.conf # MYSQLD_OPTS here is for users to set in /etc/systemd/system/mariadb.service.d/MY_SPECIAL.conf
# Use the [service] section and Environment="MYSQLD_OPTS=...". # Use the [Service] section and Environment="MYSQLD_OPTS=...".
# This isn't a replacement for my.cnf. # This isn't a replacement for my.cnf.
# _WSREP_NEW_CLUSTER is for the exclusive use of the script galera_new_cluster # _WSREP_NEW_CLUSTER is for the exclusive use of the script galera_new_cluster
ExecStart=@sbindir@/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION ExecStart=@sbindir@/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION
@ -103,7 +105,8 @@ UMask=007
## ##
## ##
## by creating a file in /etc/systemd/system/mariadb.service.d/MY_SPECIAL.conf ## by creating a file in /etc/systemd/system/mariadb.service.d/MY_SPECIAL.conf
## and adding/setting the following will override this file's settings. ## and adding/setting the following under [Service] will override this file's
## settings.
# Useful options not previously available in [mysqld_safe] # Useful options not previously available in [mysqld_safe]

View File

@ -18,7 +18,9 @@
# Inspired from https://gitweb.gentoo.org/repo/gentoo.git/tree/dev-db/mysql-init-scripts/files/mysqld_at.service # Inspired from https://gitweb.gentoo.org/repo/gentoo.git/tree/dev-db/mysql-init-scripts/files/mysqld_at.service
[Unit] [Unit]
Description=MariaDB database server Description=MariaDB @VERSION@ database server (multi-instance)
Documentation=man:mysqld(8)
Documentation=https://mariadb.com/kb/en/library/systemd/
After=network.target After=network.target
After=syslog.target After=syslog.target
@ -89,7 +91,7 @@ ExecStartPre=/bin/sh -c "[ ! -e @bindir@/galera_recovery ] && VAR= || \
# Start main service # Start main service
# MYSQLD_OPTS here is for users to set in /etc/systemd/system/mariadb@.service.d/MY_SPECIAL.conf # MYSQLD_OPTS here is for users to set in /etc/systemd/system/mariadb@.service.d/MY_SPECIAL.conf
# Use the [service] section and Environment="MYSQLD_OPTS=...". # Use the [Service] section and Environment="MYSQLD_OPTS=...".
# This isn't a replacement for my.cnf. # This isn't a replacement for my.cnf.
# _WSREP_NEW_CLUSTER is for the exclusive use of the script galera_new_cluster # _WSREP_NEW_CLUSTER is for the exclusive use of the script galera_new_cluster
@ -124,7 +126,8 @@ UMask=007
## ##
## ##
## by creating a file in /etc/systemd/system/mariadb.service.d/MY_SPECIAL.conf ## by creating a file in /etc/systemd/system/mariadb.service.d/MY_SPECIAL.conf
## and adding/setting the following will override this file's settings. ## and adding/setting the following below [Service] will override this file's
## settings.
# Useful options not previously available in [mysqld_safe] # Useful options not previously available in [mysqld_safe]