Merge 10.2 into 10.3
This commit is contained in:
commit
f418661efa
4
mysql-test/main/create_replace_tmp.result
Normal file
4
mysql-test/main/create_replace_tmp.result
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
CREATE TEMPORARY TABLE t (i INT);
|
||||||
|
CREATE or replace TABLE t AS SELECT * FROM t;
|
||||||
|
DROP TEMPORARY TABLE t;
|
||||||
|
DROP TABLE t;
|
4
mysql-test/main/create_replace_tmp.test
Normal file
4
mysql-test/main/create_replace_tmp.test
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
CREATE TEMPORARY TABLE t (i INT);
|
||||||
|
CREATE or replace TABLE t AS SELECT * FROM t;
|
||||||
|
DROP TEMPORARY TABLE t;
|
||||||
|
DROP TABLE t;
|
23
mysql-test/main/cte_recursive_not_embedded.result
Normal file
23
mysql-test/main/cte_recursive_not_embedded.result
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#
|
||||||
|
# MDEV-15151: function with recursive CTE using no base tables
|
||||||
|
# (duplicate of MDEV-16661)
|
||||||
|
#
|
||||||
|
connection default;
|
||||||
|
CREATE TABLE t1 (id int KEY);
|
||||||
|
INSERT INTO t1 VALUES (0), (1),(2);
|
||||||
|
CREATE OR REPLACE FUNCTION func() RETURNS int
|
||||||
|
RETURN
|
||||||
|
(
|
||||||
|
WITH recursive cte AS
|
||||||
|
(SELECT 1 a UNION SELECT cte.* FROM cte natural join t1)
|
||||||
|
SELECT * FROM cte limit 1
|
||||||
|
);
|
||||||
|
connect con1,localhost,root,,test;
|
||||||
|
SELECT func();
|
||||||
|
connect con2,localhost,root,,test;
|
||||||
|
disconnect con2;
|
||||||
|
connection con1;
|
||||||
|
disconnect con1;
|
||||||
|
connection default;
|
||||||
|
DROP FUNCTION func;
|
||||||
|
DROP TABLE t1;
|
42
mysql-test/main/cte_recursive_not_embedded.test
Normal file
42
mysql-test/main/cte_recursive_not_embedded.test
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
--source include/not_embedded.inc
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-15151: function with recursive CTE using no base tables
|
||||||
|
--echo # (duplicate of MDEV-16661)
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
--connection default
|
||||||
|
|
||||||
|
CREATE TABLE t1 (id int KEY);
|
||||||
|
INSERT INTO t1 VALUES (0), (1),(2);
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION func() RETURNS int
|
||||||
|
RETURN
|
||||||
|
(
|
||||||
|
WITH recursive cte AS
|
||||||
|
(SELECT 1 a UNION SELECT cte.* FROM cte natural join t1)
|
||||||
|
SELECT * FROM cte limit 1
|
||||||
|
);
|
||||||
|
|
||||||
|
--connect (con1,localhost,root,,test)
|
||||||
|
|
||||||
|
--let $conid= `SELECT CONNECTION_ID()`
|
||||||
|
--send SELECT func()
|
||||||
|
|
||||||
|
--connect (con2,localhost,root,,test)
|
||||||
|
--disable_query_log
|
||||||
|
--eval KILL QUERY $conid
|
||||||
|
--enable_query_log
|
||||||
|
--disconnect con2
|
||||||
|
|
||||||
|
--disable_result_log
|
||||||
|
--connection con1
|
||||||
|
--error 0,ER_QUERY_INTERRUPTED
|
||||||
|
--reap
|
||||||
|
--disconnect con1
|
||||||
|
--enable_result_log
|
||||||
|
|
||||||
|
--connection default
|
||||||
|
|
||||||
|
DROP FUNCTION func;
|
||||||
|
DROP TABLE t1;
|
9
mysql-test/suite/rpl/r/rpl_15867.result
Normal file
9
mysql-test/suite/rpl/r/rpl_15867.result
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
include/master-slave.inc
|
||||||
|
[connection master]
|
||||||
|
CREATE TEMPORARY TABLE t (i INT);
|
||||||
|
CREATE TABLE t AS SELECT * FROM t;
|
||||||
|
connection slave;
|
||||||
|
connection master;
|
||||||
|
DROP TEMPORARY TABLE t;
|
||||||
|
DROP TABLE t;
|
||||||
|
include/rpl_end.inc
|
11
mysql-test/suite/rpl/t/rpl_15867.test
Normal file
11
mysql-test/suite/rpl/t/rpl_15867.test
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
--source include/master-slave.inc
|
||||||
|
CREATE TEMPORARY TABLE t (i INT);
|
||||||
|
CREATE TABLE t AS SELECT * FROM t;
|
||||||
|
|
||||||
|
--sync_slave_with_master
|
||||||
|
|
||||||
|
# Cleanup
|
||||||
|
--connection master
|
||||||
|
DROP TEMPORARY TABLE t;
|
||||||
|
DROP TABLE t;
|
||||||
|
--source include/rpl_end.inc
|
@ -1039,6 +1039,12 @@ retry:
|
|||||||
if (res->table && (res->table == table->table))
|
if (res->table && (res->table == table->table))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
/* Skip if table is tmp table */
|
||||||
|
if (check_flag & CHECK_DUP_SKIP_TEMP_TABLE &&
|
||||||
|
res->table && res->table->s->tmp_table != NO_TMP_TABLE)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (check_flag & CHECK_DUP_FOR_CREATE)
|
if (check_flag & CHECK_DUP_FOR_CREATE)
|
||||||
DBUG_RETURN(res);
|
DBUG_RETURN(res);
|
||||||
|
|
||||||
|
@ -64,6 +64,7 @@ enum find_item_error_report_type {REPORT_ALL_ERRORS, REPORT_EXCEPT_NOT_FOUND,
|
|||||||
/* Flag bits for unique_table() */
|
/* Flag bits for unique_table() */
|
||||||
#define CHECK_DUP_ALLOW_DIFFERENT_ALIAS 1
|
#define CHECK_DUP_ALLOW_DIFFERENT_ALIAS 1
|
||||||
#define CHECK_DUP_FOR_CREATE 2
|
#define CHECK_DUP_FOR_CREATE 2
|
||||||
|
#define CHECK_DUP_SKIP_TEMP_TABLE 4
|
||||||
|
|
||||||
uint get_table_def_key(const TABLE_LIST *table_list, const char **key);
|
uint get_table_def_key(const TABLE_LIST *table_list, const char **key);
|
||||||
TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type update,
|
TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type update,
|
||||||
|
@ -4196,7 +4196,8 @@ mysql_execute_command(THD *thd)
|
|||||||
TABLE_LIST *duplicate;
|
TABLE_LIST *duplicate;
|
||||||
if (unlikely((duplicate= unique_table(thd, lex->query_tables,
|
if (unlikely((duplicate= unique_table(thd, lex->query_tables,
|
||||||
lex->query_tables->next_global,
|
lex->query_tables->next_global,
|
||||||
CHECK_DUP_FOR_CREATE))))
|
CHECK_DUP_FOR_CREATE |
|
||||||
|
CHECK_DUP_SKIP_TEMP_TABLE))))
|
||||||
{
|
{
|
||||||
update_non_unique_table_error(lex->query_tables, "CREATE",
|
update_non_unique_table_error(lex->query_tables, "CREATE",
|
||||||
duplicate);
|
duplicate);
|
||||||
|
@ -570,10 +570,9 @@ static
|
|||||||
bool
|
bool
|
||||||
btr_search_update_block_hash_info(btr_search_t* info, buf_block_t* block)
|
btr_search_update_block_hash_info(btr_search_t* info, buf_block_t* block)
|
||||||
{
|
{
|
||||||
ut_ad(!btr_search_own_any(RW_LOCK_S));
|
ut_ad(!btr_search_own_any());
|
||||||
ut_ad(!btr_search_own_any(RW_LOCK_X));
|
ut_ad(rw_lock_own_flagged(&block->lock,
|
||||||
ut_ad(rw_lock_own(&block->lock, RW_LOCK_S)
|
RW_LOCK_FLAG_X | RW_LOCK_FLAG_S));
|
||||||
|| rw_lock_own(&block->lock, RW_LOCK_X));
|
|
||||||
|
|
||||||
info->last_hash_succ = FALSE;
|
info->last_hash_succ = FALSE;
|
||||||
|
|
||||||
@ -648,8 +647,8 @@ btr_search_update_hash_ref(
|
|||||||
|
|
||||||
ut_ad(cursor->flag == BTR_CUR_HASH_FAIL);
|
ut_ad(cursor->flag == BTR_CUR_HASH_FAIL);
|
||||||
ut_ad(rw_lock_own(btr_get_search_latch(cursor->index), RW_LOCK_X));
|
ut_ad(rw_lock_own(btr_get_search_latch(cursor->index), RW_LOCK_X));
|
||||||
ut_ad(rw_lock_own(&(block->lock), RW_LOCK_S)
|
ut_ad(rw_lock_own_flagged(&block->lock,
|
||||||
|| rw_lock_own(&(block->lock), RW_LOCK_X));
|
RW_LOCK_FLAG_X | RW_LOCK_FLAG_S));
|
||||||
ut_ad(page_align(btr_cur_get_rec(cursor)) == block->frame);
|
ut_ad(page_align(btr_cur_get_rec(cursor)) == block->frame);
|
||||||
ut_ad(page_is_leaf(block->frame));
|
ut_ad(page_is_leaf(block->frame));
|
||||||
assert_block_ahi_valid(block);
|
assert_block_ahi_valid(block);
|
||||||
@ -887,8 +886,8 @@ btr_search_guess_on_hash(
|
|||||||
btr_cur_t cursor2;
|
btr_cur_t cursor2;
|
||||||
btr_pcur_t pcur;
|
btr_pcur_t pcur;
|
||||||
#endif
|
#endif
|
||||||
ut_ad(!ahi_latch || rw_lock_own(ahi_latch, RW_LOCK_S)
|
ut_ad(!ahi_latch || rw_lock_own_flagged(
|
||||||
|| rw_lock_own(ahi_latch, RW_LOCK_X));
|
ahi_latch, RW_LOCK_FLAG_X | RW_LOCK_FLAG_S));
|
||||||
|
|
||||||
if (!btr_search_enabled) {
|
if (!btr_search_enabled) {
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
@ -1109,8 +1108,8 @@ retry:
|
|||||||
|
|
||||||
ut_ad(block->page.buf_fix_count == 0
|
ut_ad(block->page.buf_fix_count == 0
|
||||||
|| buf_block_get_state(block) == BUF_BLOCK_REMOVE_HASH
|
|| buf_block_get_state(block) == BUF_BLOCK_REMOVE_HASH
|
||||||
|| rw_lock_own(&block->lock, RW_LOCK_S)
|
|| rw_lock_own_flagged(&block->lock,
|
||||||
|| rw_lock_own(&block->lock, RW_LOCK_X));
|
RW_LOCK_FLAG_X | RW_LOCK_FLAG_S));
|
||||||
ut_ad(page_is_leaf(block->frame));
|
ut_ad(page_is_leaf(block->frame));
|
||||||
|
|
||||||
/* We must not dereference index here, because it could be freed
|
/* We must not dereference index here, because it could be freed
|
||||||
@ -1363,8 +1362,8 @@ btr_search_build_page_hash_index(
|
|||||||
ut_a(!dict_index_is_ibuf(index));
|
ut_a(!dict_index_is_ibuf(index));
|
||||||
ut_ad(page_is_leaf(block->frame));
|
ut_ad(page_is_leaf(block->frame));
|
||||||
|
|
||||||
ut_ad(rw_lock_own(&(block->lock), RW_LOCK_S)
|
ut_ad(rw_lock_own_flagged(&block->lock,
|
||||||
|| rw_lock_own(&(block->lock), RW_LOCK_X));
|
RW_LOCK_FLAG_X | RW_LOCK_FLAG_S));
|
||||||
|
|
||||||
rw_lock_s_lock(ahi_latch);
|
rw_lock_s_lock(ahi_latch);
|
||||||
|
|
||||||
@ -1531,8 +1530,8 @@ btr_search_info_update_slow(btr_search_t* info, btr_cur_t* cursor)
|
|||||||
{
|
{
|
||||||
rw_lock_t* ahi_latch = btr_get_search_latch(cursor->index);
|
rw_lock_t* ahi_latch = btr_get_search_latch(cursor->index);
|
||||||
|
|
||||||
ut_ad(!rw_lock_own(ahi_latch, RW_LOCK_S));
|
ut_ad(!rw_lock_own_flagged(ahi_latch,
|
||||||
ut_ad(!rw_lock_own(ahi_latch, RW_LOCK_X));
|
RW_LOCK_FLAG_X | RW_LOCK_FLAG_S));
|
||||||
|
|
||||||
buf_block_t* block = btr_cur_get_block(cursor);
|
buf_block_t* block = btr_cur_get_block(cursor);
|
||||||
|
|
||||||
|
@ -4498,8 +4498,9 @@ loop:
|
|||||||
case BUF_GET_IF_IN_POOL_OR_WATCH:
|
case BUF_GET_IF_IN_POOL_OR_WATCH:
|
||||||
case BUF_PEEK_IF_IN_POOL:
|
case BUF_PEEK_IF_IN_POOL:
|
||||||
case BUF_EVICT_IF_IN_POOL:
|
case BUF_EVICT_IF_IN_POOL:
|
||||||
ut_ad(!rw_lock_own(hash_lock, RW_LOCK_X));
|
ut_ad(!rw_lock_own_flagged(
|
||||||
ut_ad(!rw_lock_own(hash_lock, RW_LOCK_S));
|
hash_lock,
|
||||||
|
RW_LOCK_FLAG_X | RW_LOCK_FLAG_S));
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4840,8 +4841,8 @@ evict_from_pool:
|
|||||||
ut_ad(block == fix_block);
|
ut_ad(block == fix_block);
|
||||||
ut_ad(fix_block->page.buf_fix_count > 0);
|
ut_ad(fix_block->page.buf_fix_count > 0);
|
||||||
|
|
||||||
ut_ad(!rw_lock_own(hash_lock, RW_LOCK_X));
|
ut_ad(!rw_lock_own_flagged(hash_lock,
|
||||||
ut_ad(!rw_lock_own(hash_lock, RW_LOCK_S));
|
RW_LOCK_FLAG_X | RW_LOCK_FLAG_S));
|
||||||
|
|
||||||
ut_ad(buf_block_get_state(fix_block) == BUF_BLOCK_FILE_PAGE);
|
ut_ad(buf_block_get_state(fix_block) == BUF_BLOCK_FILE_PAGE);
|
||||||
|
|
||||||
@ -5015,8 +5016,8 @@ evict_from_pool:
|
|||||||
ut_a(ibuf_count_get(fix_block->page.id) == 0);
|
ut_a(ibuf_count_get(fix_block->page.id) == 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ut_ad(!rw_lock_own(hash_lock, RW_LOCK_X));
|
ut_ad(!rw_lock_own_flagged(hash_lock,
|
||||||
ut_ad(!rw_lock_own(hash_lock, RW_LOCK_S));
|
RW_LOCK_FLAG_X | RW_LOCK_FLAG_S));
|
||||||
|
|
||||||
return(fix_block);
|
return(fix_block);
|
||||||
}
|
}
|
||||||
@ -5688,8 +5689,8 @@ func_exit:
|
|||||||
ibuf_mtr_commit(&mtr);
|
ibuf_mtr_commit(&mtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
ut_ad(!rw_lock_own(hash_lock, RW_LOCK_X));
|
ut_ad(!rw_lock_own_flagged(hash_lock,
|
||||||
ut_ad(!rw_lock_own(hash_lock, RW_LOCK_S));
|
RW_LOCK_FLAG_X | RW_LOCK_FLAG_S));
|
||||||
ut_ad(!bpage || buf_page_in_file(bpage));
|
ut_ad(!bpage || buf_page_in_file(bpage));
|
||||||
|
|
||||||
return(bpage);
|
return(bpage);
|
||||||
|
@ -1629,8 +1629,8 @@ func_exit:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* buf_LRU_block_remove_hashed() releases the hash_lock */
|
/* buf_LRU_block_remove_hashed() releases the hash_lock */
|
||||||
ut_ad(!rw_lock_own(hash_lock, RW_LOCK_X)
|
ut_ad(!rw_lock_own_flagged(hash_lock,
|
||||||
&& !rw_lock_own(hash_lock, RW_LOCK_S));
|
RW_LOCK_FLAG_X | RW_LOCK_FLAG_S));
|
||||||
|
|
||||||
/* We have just freed a BUF_BLOCK_FILE_PAGE. If b != NULL
|
/* We have just freed a BUF_BLOCK_FILE_PAGE. If b != NULL
|
||||||
then it was a compressed page with an uncompressed frame and
|
then it was a compressed page with an uncompressed frame and
|
||||||
@ -2183,9 +2183,8 @@ buf_LRU_free_one_page(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* buf_LRU_block_remove_hashed() releases hash_lock and block_mutex */
|
/* buf_LRU_block_remove_hashed() releases hash_lock and block_mutex */
|
||||||
ut_ad(!rw_lock_own(hash_lock, RW_LOCK_X)
|
ut_ad(!rw_lock_own_flagged(hash_lock,
|
||||||
&& !rw_lock_own(hash_lock, RW_LOCK_S));
|
RW_LOCK_FLAG_X | RW_LOCK_FLAG_S));
|
||||||
|
|
||||||
ut_ad(!mutex_own(block_mutex));
|
ut_ad(!mutex_own(block_mutex));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,9 +257,8 @@ rtr_pcur_getnext_from_path(
|
|||||||
rtr_info->tree_savepoints[tree_idx] = mtr_set_savepoint(mtr);
|
rtr_info->tree_savepoints[tree_idx] = mtr_set_savepoint(mtr);
|
||||||
|
|
||||||
#ifdef UNIV_RTR_DEBUG
|
#ifdef UNIV_RTR_DEBUG
|
||||||
ut_ad(!(rw_lock_own(&btr_cur->page_cur.block->lock, RW_LOCK_X)
|
ut_ad(!(rw_lock_own_flagged(&btr_cur->page_cur.block->lock,
|
||||||
||
|
RW_LOCK_FLAG_X | RW_LOCK_FLAG_S))
|
||||||
rw_lock_own(&btr_cur->page_cur.block->lock, RW_LOCK_S))
|
|
||||||
|| my_latch_mode == BTR_MODIFY_TREE
|
|| my_latch_mode == BTR_MODIFY_TREE
|
||||||
|| my_latch_mode == BTR_CONT_MODIFY_TREE
|
|| my_latch_mode == BTR_CONT_MODIFY_TREE
|
||||||
|| !page_is_leaf(buf_block_get_frame(
|
|| !page_is_leaf(buf_block_get_frame(
|
||||||
|
@ -20680,7 +20680,6 @@ static TABLE* innodb_acquire_mdl(THD* thd, dict_table_t* table)
|
|||||||
|
|
||||||
if (!table_name_parse(table->name, db_buf, tbl_buf,
|
if (!table_name_parse(table->name, db_buf, tbl_buf,
|
||||||
db_buf_len, tbl_buf_len)) {
|
db_buf_len, tbl_buf_len)) {
|
||||||
ut_ad(!"invalid table name");
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -20716,7 +20715,6 @@ fail:
|
|||||||
|
|
||||||
if (!table_name_parse(table->name, db_buf1, tbl_buf1,
|
if (!table_name_parse(table->name, db_buf1, tbl_buf1,
|
||||||
db_buf1_len, tbl_buf1_len)) {
|
db_buf1_len, tbl_buf1_len)) {
|
||||||
ut_ad(!"invalid table name");
|
|
||||||
goto release_fail;
|
goto release_fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -20764,7 +20762,6 @@ static TABLE* innodb_find_table_for_vc(THD* thd, dict_table_t* table)
|
|||||||
|
|
||||||
if (!table_name_parse(table->name, db_buf, tbl_buf,
|
if (!table_name_parse(table->name, db_buf, tbl_buf,
|
||||||
db_buf_len, tbl_buf_len)) {
|
db_buf_len, tbl_buf_len)) {
|
||||||
ut_ad(!"invalid table name");
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,6 +171,9 @@ static inline bool btr_search_own_all(ulint mode);
|
|||||||
@retval true if owns any of them
|
@retval true if owns any of them
|
||||||
@retval false if owns no search latch */
|
@retval false if owns no search latch */
|
||||||
static inline bool btr_search_own_any(ulint mode);
|
static inline bool btr_search_own_any(ulint mode);
|
||||||
|
|
||||||
|
/** @return whether this thread holds any of the search latches */
|
||||||
|
static inline bool btr_search_own_any();
|
||||||
#endif /* UNIV_DEBUG */
|
#endif /* UNIV_DEBUG */
|
||||||
|
|
||||||
/** Unlock all search latches from shared mode. */
|
/** Unlock all search latches from shared mode. */
|
||||||
|
@ -144,6 +144,18 @@ static inline bool btr_search_own_any(ulint mode)
|
|||||||
}
|
}
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @return whether this thread holds any of the search latches */
|
||||||
|
static inline bool btr_search_own_any()
|
||||||
|
{
|
||||||
|
for (ulint i = btr_ahi_parts; i--; ) {
|
||||||
|
if (rw_lock_own_flagged(btr_search_latches[i],
|
||||||
|
RW_LOCK_FLAG_X | RW_LOCK_FLAG_S)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
#endif /* UNIV_DEBUG */
|
#endif /* UNIV_DEBUG */
|
||||||
|
|
||||||
/** Get the adaptive hash search index latch for a b-tree.
|
/** Get the adaptive hash search index latch for a b-tree.
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
|
|
||||||
Copyright (c) 1994, 2015, Oracle and/or its affiliates. All Rights Reserved.
|
Copyright (c) 1994, 2015, Oracle and/or its affiliates. All Rights Reserved.
|
||||||
|
Copyright (c) 2018, MariaDB Corporation.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it under
|
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 the Free Software
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
@ -137,11 +138,8 @@ hash_assert_can_search(
|
|||||||
if (table->type == HASH_TABLE_SYNC_MUTEX) {
|
if (table->type == HASH_TABLE_SYNC_MUTEX) {
|
||||||
ut_ad(mutex_own(hash_get_mutex(table, fold)));
|
ut_ad(mutex_own(hash_get_mutex(table, fold)));
|
||||||
} else if (table->type == HASH_TABLE_SYNC_RW_LOCK) {
|
} else if (table->type == HASH_TABLE_SYNC_RW_LOCK) {
|
||||||
# ifdef UNIV_DEBUG
|
ut_ad(rw_lock_own_flagged(hash_get_lock(table, fold),
|
||||||
rw_lock_t* lock = hash_get_lock(table, fold);
|
RW_LOCK_FLAG_X | RW_LOCK_FLAG_S));
|
||||||
ut_ad(rw_lock_own(lock, RW_LOCK_X)
|
|
||||||
|| rw_lock_own(lock, RW_LOCK_S));
|
|
||||||
# endif
|
|
||||||
} else {
|
} else {
|
||||||
ut_ad(table->type == HASH_TABLE_SYNC_NONE);
|
ut_ad(table->type == HASH_TABLE_SYNC_NONE);
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,7 @@ struct TABLE;
|
|||||||
/** Purge virtual column node information. */
|
/** Purge virtual column node information. */
|
||||||
struct purge_vcol_info_t
|
struct purge_vcol_info_t
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
/** Is there a possible need to evaluate virtual columns? */
|
/** Is there a possible need to evaluate virtual columns? */
|
||||||
bool requested;
|
bool requested;
|
||||||
/** Do we have to evaluate virtual columns (using mariadb_table)? */
|
/** Do we have to evaluate virtual columns (using mariadb_table)? */
|
||||||
@ -67,6 +68,7 @@ struct purge_vcol_info_t
|
|||||||
/** MariaDB table opened for virtual column computation. */
|
/** MariaDB table opened for virtual column computation. */
|
||||||
TABLE* mariadb_table;
|
TABLE* mariadb_table;
|
||||||
|
|
||||||
|
public:
|
||||||
/** Reset the state. */
|
/** Reset the state. */
|
||||||
void reset()
|
void reset()
|
||||||
{
|
{
|
||||||
@ -81,6 +83,29 @@ struct purge_vcol_info_t
|
|||||||
or doesn't try to calculate virtual column. */
|
or doesn't try to calculate virtual column. */
|
||||||
bool validate() const { return !used || mariadb_table; }
|
bool validate() const { return !used || mariadb_table; }
|
||||||
|
|
||||||
|
/** @return the table handle for evaluating virtual columns */
|
||||||
|
TABLE* table() const { return mariadb_table; }
|
||||||
|
|
||||||
|
/** Set the table handle for evaluating virtual columns.
|
||||||
|
@param[in] table table handle */
|
||||||
|
void set_table(TABLE* table)
|
||||||
|
{
|
||||||
|
ut_ad(!table || is_first_fetch());
|
||||||
|
mariadb_table = table;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Note that virtual column information may be needed. */
|
||||||
|
void set_requested()
|
||||||
|
{
|
||||||
|
ut_ad(!used);
|
||||||
|
ut_ad(!first_use);
|
||||||
|
ut_ad(!mariadb_table);
|
||||||
|
requested = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return whether the virtual column information may be needed */
|
||||||
|
bool is_requested() const { return requested; }
|
||||||
|
|
||||||
/** Note that the virtual column information is needed. */
|
/** Note that the virtual column information is needed. */
|
||||||
void set_used()
|
void set_used()
|
||||||
{
|
{
|
||||||
@ -92,7 +117,18 @@ struct purge_vcol_info_t
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
first_use = used = true;
|
if (!used) {
|
||||||
|
first_use = used = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return whether the virtual column information is needed */
|
||||||
|
bool is_used() const
|
||||||
|
{
|
||||||
|
ut_ad(!first_use || used);
|
||||||
|
ut_ad(!used || requested);
|
||||||
|
ut_ad(used || !mariadb_table);
|
||||||
|
return used;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Check whether it fetches mariadb table for the first time.
|
/** Check whether it fetches mariadb table for the first time.
|
||||||
@ -100,6 +136,8 @@ struct purge_vcol_info_t
|
|||||||
bool is_first_fetch() const
|
bool is_first_fetch() const
|
||||||
{
|
{
|
||||||
ut_ad(!first_use || used);
|
ut_ad(!first_use || used);
|
||||||
|
ut_ad(!used || requested);
|
||||||
|
ut_ad(used || !mariadb_table);
|
||||||
return first_use;
|
return first_use;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -279,8 +279,7 @@ rw_lock_s_lock_func(
|
|||||||
the threads which have s-locked a latch. This would use some CPU
|
the threads which have s-locked a latch. This would use some CPU
|
||||||
time. */
|
time. */
|
||||||
|
|
||||||
ut_ad(!rw_lock_own(lock, RW_LOCK_S)); /* see NOTE above */
|
ut_ad(!rw_lock_own_flagged(lock, RW_LOCK_FLAG_X | RW_LOCK_FLAG_S));
|
||||||
ut_ad(!rw_lock_own(lock, RW_LOCK_X));
|
|
||||||
|
|
||||||
if (!rw_lock_s_lock_low(lock, pass, file_name, line)) {
|
if (!rw_lock_s_lock_low(lock, pass, file_name, line)) {
|
||||||
|
|
||||||
|
@ -329,8 +329,8 @@ row_log_online_op(
|
|||||||
|
|
||||||
ut_ad(dtuple_validate(tuple));
|
ut_ad(dtuple_validate(tuple));
|
||||||
ut_ad(dtuple_get_n_fields(tuple) == dict_index_get_n_fields(index));
|
ut_ad(dtuple_get_n_fields(tuple) == dict_index_get_n_fields(index));
|
||||||
ut_ad(rw_lock_own(dict_index_get_lock(index), RW_LOCK_S)
|
ut_ad(rw_lock_own_flagged(&index->lock,
|
||||||
|| rw_lock_own(dict_index_get_lock(index), RW_LOCK_X));
|
RW_LOCK_FLAG_X | RW_LOCK_FLAG_S));
|
||||||
|
|
||||||
if (index->is_corrupted()) {
|
if (index->is_corrupted()) {
|
||||||
return;
|
return;
|
||||||
|
@ -137,7 +137,7 @@ row_purge_remove_clust_if_poss_low(
|
|||||||
rec_offs_init(offsets_);
|
rec_offs_init(offsets_);
|
||||||
|
|
||||||
ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_S)
|
ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_S)
|
||||||
|| node->vcol_info.used);
|
|| node->vcol_info.is_used());
|
||||||
|
|
||||||
index = dict_table_get_first_index(node->table);
|
index = dict_table_get_first_index(node->table);
|
||||||
|
|
||||||
@ -250,7 +250,7 @@ static void row_purge_store_vsec_cur(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
node->vcol_info.requested = true;
|
node->vcol_info.set_requested();
|
||||||
|
|
||||||
btr_pcur_store_position(sec_pcur, sec_mtr);
|
btr_pcur_store_position(sec_pcur, sec_mtr);
|
||||||
|
|
||||||
@ -318,16 +318,18 @@ row_purge_poss_sec(
|
|||||||
|
|
||||||
ut_ad(!dict_index_is_clust(index));
|
ut_ad(!dict_index_is_clust(index));
|
||||||
|
|
||||||
const bool store_cur = sec_mtr && !node->vcol_info.used
|
const bool store_cur = sec_mtr && !node->vcol_info.is_used()
|
||||||
&& dict_index_has_virtual(index);
|
&& dict_index_has_virtual(index);
|
||||||
|
|
||||||
if (store_cur) {
|
if (store_cur) {
|
||||||
row_purge_store_vsec_cur(node, index, sec_pcur, sec_mtr);
|
row_purge_store_vsec_cur(node, index, sec_pcur, sec_mtr);
|
||||||
|
ut_ad(sec_mtr->has_committed()
|
||||||
|
== node->vcol_info.is_requested());
|
||||||
|
|
||||||
/* The PRIMARY KEY value was not found in the clustered
|
/* The PRIMARY KEY value was not found in the clustered
|
||||||
index. The secondary index record found. We can purge
|
index. The secondary index record found. We can purge
|
||||||
the secondary index record. */
|
the secondary index record. */
|
||||||
if (!node->vcol_info.requested) {
|
if (!node->vcol_info.is_requested()) {
|
||||||
ut_ad(!node->found_clust);
|
ut_ad(!node->found_clust);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -344,7 +346,18 @@ retry_purge_sec:
|
|||||||
&node->vcol_info);
|
&node->vcol_info);
|
||||||
|
|
||||||
if (node->vcol_info.is_first_fetch()) {
|
if (node->vcol_info.is_first_fetch()) {
|
||||||
if (node->vcol_info.mariadb_table) {
|
ut_ad(store_cur);
|
||||||
|
|
||||||
|
const TABLE* t= node->vcol_info.table();
|
||||||
|
DBUG_LOG("purge", "retry " << t
|
||||||
|
<< (is_tree ? " tree" : " leaf")
|
||||||
|
<< index->name << "," << index->table->name
|
||||||
|
<< ": " << rec_printer(entry).str());
|
||||||
|
|
||||||
|
ut_ad(mtr.has_committed());
|
||||||
|
|
||||||
|
if (t) {
|
||||||
|
node->vcol_info.set_used();
|
||||||
goto retry_purge_sec;
|
goto retry_purge_sec;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -357,9 +370,11 @@ retry_purge_sec:
|
|||||||
if (node->found_clust) {
|
if (node->found_clust) {
|
||||||
btr_pcur_commit_specify_mtr(&node->pcur, &mtr);
|
btr_pcur_commit_specify_mtr(&node->pcur, &mtr);
|
||||||
} else {
|
} else {
|
||||||
mtr_commit(&mtr);
|
mtr.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ut_ad(mtr.has_committed());
|
||||||
|
|
||||||
if (store_cur && !row_purge_restore_vsec_cur(
|
if (store_cur && !row_purge_restore_vsec_cur(
|
||||||
node, index, sec_pcur, sec_mtr, is_tree)) {
|
node, index, sec_pcur, sec_mtr, is_tree)) {
|
||||||
return false;
|
return false;
|
||||||
@ -791,7 +806,7 @@ whose old history can no longer be observed.
|
|||||||
static void row_purge_reset_trx_id(purge_node_t* node, mtr_t* mtr)
|
static void row_purge_reset_trx_id(purge_node_t* node, mtr_t* mtr)
|
||||||
{
|
{
|
||||||
ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_S)
|
ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_S)
|
||||||
|| node->vcol_info.used);
|
|| node->vcol_info.is_used());
|
||||||
/* Reset DB_TRX_ID, DB_ROLL_PTR for old records. */
|
/* Reset DB_TRX_ID, DB_ROLL_PTR for old records. */
|
||||||
mtr->start();
|
mtr->start();
|
||||||
|
|
||||||
@ -867,7 +882,7 @@ row_purge_upd_exist_or_extern_func(
|
|||||||
mem_heap_t* heap;
|
mem_heap_t* heap;
|
||||||
|
|
||||||
ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_S)
|
ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_S)
|
||||||
|| node->vcol_info.used);
|
|| node->vcol_info.is_used());
|
||||||
ut_ad(!node->table->skip_alter_undo);
|
ut_ad(!node->table->skip_alter_undo);
|
||||||
|
|
||||||
if (node->rec_type == TRX_UNDO_UPD_DEL_REC
|
if (node->rec_type == TRX_UNDO_UPD_DEL_REC
|
||||||
@ -1228,7 +1243,7 @@ row_purge(
|
|||||||
bool purged = row_purge_record(
|
bool purged = row_purge_record(
|
||||||
node, undo_rec, thr, updated_extern);
|
node, undo_rec, thr, updated_extern);
|
||||||
|
|
||||||
if (!node->vcol_info.used) {
|
if (!node->vcol_info.is_used()) {
|
||||||
rw_lock_s_unlock(dict_operation_lock);
|
rw_lock_s_unlock(dict_operation_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1100,8 +1100,8 @@ sel_set_rtr_rec_lock(
|
|||||||
rw_lock_x_lock(&(match->block.lock));
|
rw_lock_x_lock(&(match->block.lock));
|
||||||
retry:
|
retry:
|
||||||
cur_block = btr_pcur_get_block(pcur);
|
cur_block = btr_pcur_get_block(pcur);
|
||||||
ut_ad(rw_lock_own(&(match->block.lock), RW_LOCK_X)
|
ut_ad(rw_lock_own_flagged(&match->block.lock,
|
||||||
|| rw_lock_own(&(match->block.lock), RW_LOCK_S));
|
RW_LOCK_FLAG_X | RW_LOCK_FLAG_S));
|
||||||
ut_ad(page_is_leaf(buf_block_get_frame(cur_block)));
|
ut_ad(page_is_leaf(buf_block_get_frame(cur_block)));
|
||||||
|
|
||||||
err = lock_sec_rec_read_check_and_lock(
|
err = lock_sec_rec_read_check_and_lock(
|
||||||
|
@ -222,8 +222,8 @@ row_undo_mod_clust(
|
|||||||
ut_ad(thr_get_trx(thr) == node->trx);
|
ut_ad(thr_get_trx(thr) == node->trx);
|
||||||
ut_ad(node->trx->dict_operation_lock_mode);
|
ut_ad(node->trx->dict_operation_lock_mode);
|
||||||
ut_ad(node->trx->in_rollback);
|
ut_ad(node->trx->in_rollback);
|
||||||
ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_S)
|
ut_ad(rw_lock_own_flagged(dict_operation_lock,
|
||||||
|| rw_lock_own(dict_operation_lock, RW_LOCK_X));
|
RW_LOCK_FLAG_X | RW_LOCK_FLAG_S));
|
||||||
|
|
||||||
log_free_check();
|
log_free_check();
|
||||||
pcur = &node->pcur;
|
pcur = &node->pcur;
|
||||||
|
@ -453,7 +453,7 @@ row_vers_build_clust_v_col(
|
|||||||
|
|
||||||
if (vcol_info != NULL) {
|
if (vcol_info != NULL) {
|
||||||
vcol_info->set_used();
|
vcol_info->set_used();
|
||||||
maria_table = vcol_info->mariadb_table;
|
maria_table = vcol_info->table();
|
||||||
}
|
}
|
||||||
|
|
||||||
innobase_allocate_row_for_vcol(thd, index,
|
innobase_allocate_row_for_vcol(thd, index,
|
||||||
@ -462,9 +462,8 @@ row_vers_build_clust_v_col(
|
|||||||
&record,
|
&record,
|
||||||
&vcol_storage);
|
&vcol_storage);
|
||||||
|
|
||||||
if (vcol_info && !vcol_info->mariadb_table) {
|
if (vcol_info && !vcol_info->table()) {
|
||||||
vcol_info->mariadb_table = maria_table;
|
vcol_info->set_table(maria_table);
|
||||||
ut_ad(!maria_table || vcol_info->is_first_fetch());
|
|
||||||
goto func_exit;
|
goto func_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -828,7 +827,7 @@ row_vers_build_cur_vrow(
|
|||||||
rec, *clust_offsets,
|
rec, *clust_offsets,
|
||||||
NULL, NULL, NULL, NULL, heap);
|
NULL, NULL, NULL, NULL, heap);
|
||||||
|
|
||||||
if (vcol_info && !vcol_info->used) {
|
if (vcol_info && !vcol_info->is_used()) {
|
||||||
mtr->commit();
|
mtr->commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -949,7 +948,7 @@ row_vers_old_has_index_entry(
|
|||||||
if (trx_undo_roll_ptr_is_insert(t_roll_ptr)
|
if (trx_undo_roll_ptr_is_insert(t_roll_ptr)
|
||||||
|| dbug_v_purge) {
|
|| dbug_v_purge) {
|
||||||
|
|
||||||
if (vcol_info && !vcol_info->used) {
|
if (vcol_info && !vcol_info->is_used()) {
|
||||||
mtr->commit();
|
mtr->commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
|
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
|
||||||
Copyright (c) 2008, Google Inc.
|
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
|
Portions of this file contain modifications contributed and copyrighted by
|
||||||
Google, Inc. Those modifications are gratefully acknowledged and are described
|
Google, Inc. Those modifications are gratefully acknowledged and are described
|
||||||
@ -1092,12 +1092,12 @@ rw_lock_own_flagged(
|
|||||||
|
|
||||||
const rw_lock_debug_t* info = *it;
|
const rw_lock_debug_t* info = *it;
|
||||||
|
|
||||||
ut_ad(os_thread_eq(info->thread_id, os_thread_get_curr_id()));
|
if (info->pass) {
|
||||||
|
|
||||||
if (info->pass != 0) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ut_ad(os_thread_eq(info->thread_id, os_thread_get_curr_id()));
|
||||||
|
|
||||||
switch (info->lock_type) {
|
switch (info->lock_type) {
|
||||||
case RW_LOCK_S:
|
case RW_LOCK_S:
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
|
|
||||||
Copyright (c) 2007, 2015, Oracle and/or its affiliates. All Rights Reserved.
|
Copyright (c) 2007, 2015, Oracle and/or its affiliates. All Rights Reserved.
|
||||||
Copyright (c) 2017, MariaDB Corporation.
|
Copyright (c) 2017, 2018, MariaDB Corporation.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it under
|
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 the Free Software
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
@ -1468,26 +1468,20 @@ cache_select_table(
|
|||||||
trx_i_s_cache_t* cache, /*!< in: whole cache */
|
trx_i_s_cache_t* cache, /*!< in: whole cache */
|
||||||
enum i_s_table table) /*!< in: which table */
|
enum i_s_table table) /*!< in: which table */
|
||||||
{
|
{
|
||||||
i_s_table_cache_t* table_cache;
|
ut_ad(rw_lock_own_flagged(cache->rw_lock,
|
||||||
|
RW_LOCK_FLAG_X | RW_LOCK_FLAG_S));
|
||||||
ut_ad(rw_lock_own(cache->rw_lock, RW_LOCK_S)
|
|
||||||
|| rw_lock_own(cache->rw_lock, RW_LOCK_X));
|
|
||||||
|
|
||||||
switch (table) {
|
switch (table) {
|
||||||
case I_S_INNODB_TRX:
|
case I_S_INNODB_TRX:
|
||||||
table_cache = &cache->innodb_trx;
|
return &cache->innodb_trx;
|
||||||
break;
|
|
||||||
case I_S_INNODB_LOCKS:
|
case I_S_INNODB_LOCKS:
|
||||||
table_cache = &cache->innodb_locks;
|
return &cache->innodb_locks;
|
||||||
break;
|
|
||||||
case I_S_INNODB_LOCK_WAITS:
|
case I_S_INNODB_LOCK_WAITS:
|
||||||
table_cache = &cache->innodb_lock_waits;
|
return &cache->innodb_lock_waits;
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ut_error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return(table_cache);
|
ut_error;
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************//**
|
/*******************************************************************//**
|
||||||
|
@ -358,7 +358,7 @@ ut_print_buf_hex(
|
|||||||
|
|
||||||
for (data = static_cast<const byte*>(buf), i = 0; i < len; i++) {
|
for (data = static_cast<const byte*>(buf), i = 0; i < len; i++) {
|
||||||
byte b = *data++;
|
byte b = *data++;
|
||||||
o << hexdigit[(int) b >> 16] << hexdigit[b & 15];
|
o << hexdigit[int(b) >> 4] << hexdigit[b & 15];
|
||||||
}
|
}
|
||||||
|
|
||||||
o << ")";
|
o << ")";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user