Skip to content
Permalink
Browse files
Merge 10.1 into 10.2
  • Loading branch information
dr-m committed May 29, 2018
2 parents 8a42ad7 + 6aa50ba commit 18934fb
Show file tree
Hide file tree
Showing 34 changed files with 293 additions and 222 deletions.
@@ -948,6 +948,8 @@ pthread_handler_t connection_thread(void *arg)

end_thread:
cn->query_done= 1;
mysql_close(cn->mysql);
cn->mysql= 0;
mysql_thread_end();
pthread_exit(0);
return 0;
@@ -2345,7 +2345,18 @@ CREATE TABLE t1 (i INT);
insert into t2 value (2);
DROP VIEW v1;
DROP TABLE t1,t2,t3;
End of 10.1 tests.
#
# MDEV-16093
# Assertion `global_status_var.global_memory_used == 0' failed or
# bytes lost after inserting into table with non-null blob and trigger
#
CREATE TABLE t1 (b BLOB NOT NULL);
CREATE TRIGGER tr BEFORE UPDATE ON t1 FOR EACH ROW BEGIN END;
INSERT INTO t1 VALUES ('foo');
DROP TABLE t1;
#
# End of 10.1 tests.
#
create table t1 (i int);
create trigger tr1 after insert on t1 for each row set @a=@a+1;
create trigger tr2 after insert on t1 for each row set @a=@a+1;
@@ -0,0 +1,10 @@
#
# MDEV-10679
# Server crashes in in mysql_create_frm_image upon query from
# performance schema in ps-protocol mode
#
CREATE TABLE t1 (i INT);
ALTER TABLE t1 ADD PARTITION (PARTITION p VALUES LESS THAN (1));
ERROR HY000: Partition management on a not partitioned table is not possible
SELECT * FROM performance_schema.events_stages_summary_by_user_by_event_name;
DROP TABLE t1;
@@ -0,0 +1,16 @@
--source include/have_perfschema.inc
--source include/have_partition.inc

--echo #
--echo # MDEV-10679
--echo # Server crashes in in mysql_create_frm_image upon query from
--echo # performance schema in ps-protocol mode
--echo #

CREATE TABLE t1 (i INT);
--error ER_PARTITION_MGMT_ON_NONPARTITIONED
ALTER TABLE t1 ADD PARTITION (PARTITION p VALUES LESS THAN (1));
--disable_result_log
SELECT * FROM performance_schema.events_stages_summary_by_user_by_event_name;
--enable_result_log
DROP TABLE t1;
@@ -2665,8 +2665,20 @@ insert into t2 value (2);
DROP VIEW v1;
DROP TABLE t1,t2,t3;

--echo #
--echo # MDEV-16093
--echo # Assertion `global_status_var.global_memory_used == 0' failed or
--echo # bytes lost after inserting into table with non-null blob and trigger
--echo #

CREATE TABLE t1 (b BLOB NOT NULL);
CREATE TRIGGER tr BEFORE UPDATE ON t1 FOR EACH ROW BEGIN END;
INSERT INTO t1 VALUES ('foo');
DROP TABLE t1;

--echo End of 10.1 tests.
--echo #
--echo # End of 10.1 tests.
--echo #

#
# MDEV-10915 Count number of executed triggers
@@ -1216,7 +1216,9 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
}
close_thread_tables(thd); // Shouldn't be needed
thd->mdl_context.release_transactional_locks();
#ifdef WITH_PARTITION_STORAGE_ENGINE
err2:
#endif
thd->resume_subsequent_commits(suspended_wfc);
DBUG_RETURN(TRUE);
}
@@ -263,8 +263,8 @@ bool Sql_cmd_alter_table::execute(THD *thd)
- For temporary MERGE tables we do not track if their child tables are
base or temporary. As result we can't guarantee that privilege check
which was done in presence of temporary child will stay relevant later
as this temporary table might be removed.
which was done in presence of temporary child will stay relevant
later as this temporary table might be removed.
If SELECT_ACL | UPDATE_ACL | DELETE_ACL privileges were not checked for
the underlying *base* tables, it would create a security breach as in
@@ -304,6 +304,9 @@ bool Sql_cmd_alter_table::execute(THD *thd)
create_info.data_file_name= create_info.index_file_name= NULL;

thd->enable_slow_log= opt_log_slow_admin_statements;
#ifdef WITH_PARTITION_STORAGE_ENGINE
thd->work_part_info= 0;
#endif

#ifdef WITH_WSREP
if ((!thd->is_current_stmt_binlog_format_row() ||
@@ -2962,10 +2962,6 @@ mysql_execute_command(THD *thd)
#endif
DBUG_ENTER("mysql_execute_command");

#ifdef WITH_PARTITION_STORAGE_ENGINE
thd->work_part_info= 0;
#endif

DBUG_ASSERT(thd->transaction.stmt.is_empty() || thd->in_sub_stmt);
/*
Each statement or replication event which might produce deadlock
@@ -3815,6 +3811,7 @@ mysql_execute_command(THD *thd)
}

#ifdef WITH_PARTITION_STORAGE_ENGINE
thd->work_part_info= 0;
{
partition_info *part_info= thd->lex->part_info;
if (part_info && !(part_info= part_info->get_clone(thd)))
@@ -187,7 +187,16 @@ bool String::copy(const char *str,size_t arg_length, CHARSET_INFO *cs)
if (alloc(arg_length))
return TRUE;
DBUG_ASSERT(arg_length < UINT_MAX32);
if ((str_length=arg_length))
if (Ptr == str && arg_length == uint32(str_length))
{
/*
This can happen in some cases. This code is here mainly to avoid
warnings from valgrind, but can also be an indication of error.
*/
DBUG_PRINT("warning", ("Copying string on itself: %p %zu",
str, arg_length));
}
else if ((str_length=uint32(arg_length)))
memcpy(Ptr,str,arg_length);
Ptr[arg_length]=0;
str_charset=cs;
@@ -6123,6 +6123,7 @@ handle_if_exists_options(THD *thd, TABLE *table, Alter_info *alter_info)
}

#ifdef WITH_PARTITION_STORAGE_ENGINE
DBUG_ASSERT(thd->work_part_info == 0);
partition_info *tab_part_info= table->part_info;
thd->work_part_info= thd->lex->part_info;
if (tab_part_info)
@@ -8719,6 +8720,10 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
{
DBUG_ENTER("mysql_alter_table");

#ifdef WITH_PARTITION_STORAGE_ENGINE
thd->work_part_info= 0; // Used by partitioning
#endif

/*
Check if we attempt to alter mysql.slow_log or
mysql.general_log table and return an error if
@@ -623,6 +623,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create)
#endif /* WITH_WSREP */
}


/**
Build stmt_query to write it in the bin-log, the statement to write in
the trigger file and the trigger definer.
@@ -1182,6 +1183,12 @@ Table_triggers_list::~Table_triggers_list()
}
}
}

/* Free blobs used in insert */
if (record0_field)
for (Field **fld_ptr= record0_field; *fld_ptr; fld_ptr++)
(*fld_ptr)->free();

if (record1_field)
for (Field **fld_ptr= record1_field; *fld_ptr; fld_ptr++)
delete *fld_ptr;
@@ -2663,6 +2663,9 @@ int TABLE_SHARE::init_from_sql_statement_string(THD *thd, bool write,
goto ret;

thd->lex->create_info.db_type= hton;
#ifdef WITH_PARTITION_STORAGE_ENGINE
thd->work_part_info= 0; // For partitioning
#endif

if (tabledef_version.str)
thd->lex->create_info.tabledef_version= tabledef_version;
@@ -2,7 +2,7 @@

Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
Copyright (c) 2017, MariaDB Corporation.
Copyright (c) 2017, 2018, MariaDB Corporation.

Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
@@ -1177,7 +1177,8 @@ btr_search_drop_page_hash_index(buf_block_t* block)
#endif
ut_ad(btr_search_enabled);

ut_ad(block->page.id.space() == index->space);
ut_ad(index->space == FIL_NULL
|| block->page.id.space() == index->space);
ut_a(index_id == index->id);
ut_a(!dict_index_is_ibuf(index));
#ifdef UNIV_DEBUG
@@ -1300,15 +1301,10 @@ btr_search_drop_page_hash_index(buf_block_t* block)
ut_free(folds);
}

/** Drop any adaptive hash index entries that may point to an index
page that may be in the buffer pool, when a page is evicted from the
buffer pool or freed in a file segment.
@param[in] page_id page id
@param[in] page_size page size */
void
btr_search_drop_page_hash_when_freed(
const page_id_t& page_id,
const page_size_t& page_size)
/** Drop possible adaptive hash index entries when a page is evicted
from the buffer pool or freed in a file, or the index is being dropped.
@param[in] page_id page id */
void btr_search_drop_page_hash_when_freed(const page_id_t& page_id)
{
buf_block_t* block;
mtr_t mtr;
@@ -1324,7 +1320,7 @@ btr_search_drop_page_hash_when_freed(
are possibly holding, we cannot s-latch the page, but must
(recursively) x-latch it, even though we are only reading. */

block = buf_page_get_gen(page_id, page_size, RW_X_LATCH, NULL,
block = buf_page_get_gen(page_id, univ_page_size, RW_X_LATCH, NULL,
BUF_PEEK_IF_IN_POOL, __FILE__, __LINE__,
&mtr, &err);

@@ -4203,10 +4203,12 @@ buf_page_get_gen(
#ifdef UNIV_DEBUG
switch (mode) {
case BUF_EVICT_IF_IN_POOL:
case BUF_PEEK_IF_IN_POOL:
/* After DISCARD TABLESPACE, the tablespace would not exist,
but in IMPORT TABLESPACE, PageConverter::operator() must
replace any old pages, which were not evicted during DISCARD.
Skip the assertion on space_page_size. */
Similarly, btr_search_drop_page_hash_when_freed() must
remove any old pages. Skip the assertion on page_size. */
break;
default:
ut_error;
@@ -4215,7 +4217,6 @@ buf_page_get_gen(
/* fall through */
case BUF_GET:
case BUF_GET_IF_IN_POOL:
case BUF_PEEK_IF_IN_POOL:
case BUF_GET_IF_IN_POOL_OR_WATCH:
case BUF_GET_POSSIBLY_FREED:
bool found;
@@ -224,30 +224,21 @@ buf_LRU_evict_from_unzip_LRU(
/** Attempts to drop page hash index on a batch of pages belonging to a
particular space id.
@param[in] space_id space id
@param[in] page_size page size
@param[in] arr array of page_no
@param[in] count number of entries in array */
static
void
buf_LRU_drop_page_hash_batch(
ulint space_id,
const page_size_t& page_size,
const ulint* arr,
ulint count)
buf_LRU_drop_page_hash_batch(ulint space_id, const ulint* arr, ulint count)
{
ut_ad(count <= BUF_LRU_DROP_SEARCH_SIZE);

for (ulint i = 0; i < count; ++i, ++arr) {
for (const ulint* const end = arr + count; arr != end; ) {
/* While our only caller
buf_LRU_drop_page_hash_for_tablespace()
is being executed for DROP TABLE or similar,
the table cannot be evicted from the buffer pool.
Note: this should not be executed for DROP TABLESPACE,
because DROP TABLESPACE would be refused if tables existed
in the tablespace, and a previous DROP TABLE would have
already removed the AHI entries. */
the table cannot be evicted from the buffer pool. */
btr_search_drop_page_hash_when_freed(
page_id_t(space_id, *arr), page_size);
page_id_t(space_id, *arr++));
}
}

@@ -263,15 +254,6 @@ buf_LRU_drop_page_hash_for_tablespace(
buf_pool_t* buf_pool, /*!< in: buffer pool instance */
ulint id) /*!< in: space id */
{
bool found;
const page_size_t page_size(fil_space_get_page_size(id, &found));

if (!found) {
/* Somehow, the tablespace does not exist. Nothing to drop. */
ut_ad(0);
return;
}

ulint* page_arr = static_cast<ulint*>(ut_malloc_nokey(
sizeof(ulint) * BUF_LRU_DROP_SEARCH_SIZE));

@@ -338,8 +320,7 @@ buf_LRU_drop_page_hash_for_tablespace(
the latching order. */
buf_pool_mutex_exit(buf_pool);

buf_LRU_drop_page_hash_batch(
id, page_size, page_arr, num_entries);
buf_LRU_drop_page_hash_batch(id, page_arr, num_entries);

num_entries = 0;

@@ -371,9 +352,31 @@ buf_LRU_drop_page_hash_for_tablespace(
buf_pool_mutex_exit(buf_pool);

/* Drop any remaining batch of search hashed pages. */
buf_LRU_drop_page_hash_batch(id, page_size, page_arr, num_entries);
buf_LRU_drop_page_hash_batch(id, page_arr, num_entries);
ut_free(page_arr);
}

/** Drop the adaptive hash index for a tablespace.
@param[in,out] table table */
void buf_LRU_drop_page_hash_for_tablespace(dict_table_t* table)
{
for (dict_index_t* index = dict_table_get_first_index(table);
index != NULL;
index = dict_table_get_next_index(index)) {
if (btr_search_info_get_ref_count(btr_search_get_info(index),
index)) {
goto drop_ahi;
}
}

return;
drop_ahi:
ulint id = table->space;
for (ulint i = 0; i < srv_buf_pool_instances; i++) {
buf_LRU_drop_page_hash_for_tablespace(buf_pool_from_array(i),
id);
}
}
#endif /* BTR_CUR_HASH_ADAPT */

/******************************************************************//**
@@ -697,26 +700,13 @@ buf_flush_dirty_pages(
@param[in] id tablespace identifier
@param[in] observer flush observer,
or NULL if nothing is to be written */
void
buf_LRU_flush_or_remove_pages(
ulint id,
FlushObserver* observer
#ifdef BTR_CUR_HASH_ADAPT
, bool drop_ahi /*!< whether to drop the adaptive hash index */
#endif /* BTR_CUR_HASH_ADAPT */
)
void buf_LRU_flush_or_remove_pages(ulint id, FlushObserver* observer)
{
/* Pages in the system tablespace must never be discarded. */
ut_ad(id || observer);

for (ulint i = 0; i < srv_buf_pool_instances; i++) {
buf_pool_t* buf_pool = buf_pool_from_array(i);
#ifdef BTR_CUR_HASH_ADAPT
if (drop_ahi) {
buf_LRU_drop_page_hash_for_tablespace(buf_pool, id);
}
#endif /* BTR_CUR_HASH_ADAPT */
buf_flush_dirty_pages(buf_pool, id, observer);
buf_flush_dirty_pages(buf_pool_from_array(i), id, observer);
}

if (observer && !observer->is_interrupted()) {

0 comments on commit 18934fb

Please sign in to comment.