Commit 0b9cee2c authored by Marko Mäkelä's avatar Marko Mäkelä

Merge 10.2 into 10.3

parents de2186dd fa929f7c
...@@ -109,6 +109,39 @@ ALTER TABLE t1 ADD UNIQUE KEY (f1); ...@@ -109,6 +109,39 @@ ALTER TABLE t1 ADD UNIQUE KEY (f1);
ERROR 23000: Duplicate entry 'foo' for key 'f1' ERROR 23000: Duplicate entry 'foo' for key 'f1'
ALTER TABLE t1 ADD KEY (f2); ALTER TABLE t1 ADD KEY (f2);
DROP TABLE t1; DROP TABLE t1;
#
# MDEV-10748 Server crashes in ha_maria::implicit_commit upon ALTER TABLE
#
CREATE TABLE t1 (a INT, b INT) ENGINE=Aria;
SELECT * FROM t1;
a b
CREATE TABLE t2 (c INT) ENGINE=Aria;
LOCK TABLE t2 READ, t1 WRITE;
ALTER TABLE t1 CHANGE b a INT;
ERROR 42S21: Duplicate column name 'a'
UNLOCK TABLES;
DROP TABLE t1, t2;
#
# MDEV-10748 Server crashes in ha_maria::implicit_commit upon ALTER TABLE
#
CREATE TABLE t1 (a INT) ENGINE=Aria;
CREATE TABLE t2 (b INT) ENGINE=Aria;
LOCK TABLES t1 WRITE, t2 AS t2a WRITE, t2 WRITE;
ALTER TABLE t2 CHANGE b c VARBINARY(30000), ALGORITHM=COPY;
UNLOCK TABLES;
DROP TABLE t1, t2;
# More complex test, from RQG
CREATE TABLE t1 (a INT) ENGINE=Aria;
CREATE TABLE t2 (b INT) ENGINE=Aria;
CREATE OR REPLACE VIEW v2 AS SELECT * FROM t2 ;
LOCK TABLES t1 WRITE, t2 AS t2a WRITE, v2 WRITE CONCURRENT, t2 WRITE;
ALTER TABLE t1 FORCE;
ALTER TABLE t2 CHANGE b c VARBINARY(30000), ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY
ALTER TABLE t2 CHANGE b c VARBINARY(30000), ALGORITHM=COPY;
UNLOCK TABLES;
DROP VIEW v2;
DROP TABLE t1, t2;
# End of 10.2 tests # End of 10.2 tests
# #
# MDEV-14669 Assertion `file->trn == trn' failed in ha_maria::start_stmt # MDEV-14669 Assertion `file->trn == trn' failed in ha_maria::start_stmt
......
...@@ -118,6 +118,52 @@ ALTER TABLE t1 ADD UNIQUE KEY (f1); ...@@ -118,6 +118,52 @@ ALTER TABLE t1 ADD UNIQUE KEY (f1);
ALTER TABLE t1 ADD KEY (f2); ALTER TABLE t1 ADD KEY (f2);
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # MDEV-10748 Server crashes in ha_maria::implicit_commit upon ALTER TABLE
--echo #
CREATE TABLE t1 (a INT, b INT) ENGINE=Aria;
SELECT * FROM t1;
CREATE TABLE t2 (c INT) ENGINE=Aria;
LOCK TABLE t2 READ, t1 WRITE;
--error ER_DUP_FIELDNAME
ALTER TABLE t1 CHANGE b a INT;
# Cleanup
UNLOCK TABLES;
DROP TABLE t1, t2;
--echo #
--echo # MDEV-10748 Server crashes in ha_maria::implicit_commit upon ALTER TABLE
--echo #
CREATE TABLE t1 (a INT) ENGINE=Aria;
CREATE TABLE t2 (b INT) ENGINE=Aria;
LOCK TABLES t1 WRITE, t2 AS t2a WRITE, t2 WRITE;
ALTER TABLE t2 CHANGE b c VARBINARY(30000), ALGORITHM=COPY;
UNLOCK TABLES;
DROP TABLE t1, t2;
--echo # More complex test, from RQG
CREATE TABLE t1 (a INT) ENGINE=Aria;
CREATE TABLE t2 (b INT) ENGINE=Aria;
CREATE OR REPLACE VIEW v2 AS SELECT * FROM t2 ;
LOCK TABLES t1 WRITE, t2 AS t2a WRITE, v2 WRITE CONCURRENT, t2 WRITE;
ALTER TABLE t1 FORCE;
--error ER_ALTER_OPERATION_NOT_SUPPORTED
ALTER TABLE t2 CHANGE b c VARBINARY(30000), ALGORITHM=INPLACE;
ALTER TABLE t2 CHANGE b c VARBINARY(30000), ALGORITHM=COPY;
UNLOCK TABLES;
DROP VIEW v2;
DROP TABLE t1, t2;
--echo # End of 10.2 tests --echo # End of 10.2 tests
--echo # --echo #
......
...@@ -68,7 +68,7 @@ uchar* find_named(I_List<NAMED_ILINK> *list, const char *name, size_t length, ...@@ -68,7 +68,7 @@ uchar* find_named(I_List<NAMED_ILINK> *list, const char *name, size_t length,
} }
bool NAMED_ILIST::delete_element(const char *name, size_t length, void (*free_element)(const char *name, uchar*)) bool NAMED_ILIST::delete_element(const char *name, size_t length, void (*free_element)(const char *name, void*))
{ {
I_List_iterator<NAMED_ILINK> it(*this); I_List_iterator<NAMED_ILINK> it(*this);
NAMED_ILINK *element; NAMED_ILINK *element;
...@@ -85,7 +85,7 @@ bool NAMED_ILIST::delete_element(const char *name, size_t length, void (*free_el ...@@ -85,7 +85,7 @@ bool NAMED_ILIST::delete_element(const char *name, size_t length, void (*free_el
DBUG_RETURN(1); DBUG_RETURN(1);
} }
void NAMED_ILIST::delete_elements(void (*free_element)(const char *name, uchar*)) void NAMED_ILIST::delete_elements(void (*free_element)(const char *name, void*))
{ {
NAMED_ILINK *element; NAMED_ILINK *element;
DBUG_ENTER("NAMED_ILIST::delete_elements"); DBUG_ENTER("NAMED_ILIST::delete_elements");
...@@ -157,9 +157,9 @@ KEY_CACHE *get_or_create_key_cache(const char *name, size_t length) ...@@ -157,9 +157,9 @@ KEY_CACHE *get_or_create_key_cache(const char *name, size_t length)
} }
void free_key_cache(const char *name, KEY_CACHE *key_cache) void free_key_cache(const char *name, void *key_cache)
{ {
end_key_cache(key_cache, 1); // Can never fail end_key_cache(static_cast<KEY_CACHE *>(key_cache), 1); // Can never fail
my_free(key_cache); my_free(key_cache);
} }
...@@ -221,13 +221,12 @@ Rpl_filter *get_or_create_rpl_filter(const char *name, size_t length) ...@@ -221,13 +221,12 @@ Rpl_filter *get_or_create_rpl_filter(const char *name, size_t length)
return filter; return filter;
} }
void free_rpl_filter(const char *name, Rpl_filter *filter) void free_rpl_filter(const char *name, void *filter)
{ {
delete filter; delete static_cast<Rpl_filter*>(filter);
filter= 0;
} }
void free_all_rpl_filters() void free_all_rpl_filters()
{ {
rpl_filters.delete_elements((void (*)(const char*, uchar*)) free_rpl_filter); rpl_filters.delete_elements(free_rpl_filter);
} }
...@@ -30,8 +30,8 @@ class NAMED_ILINK; ...@@ -30,8 +30,8 @@ class NAMED_ILINK;
class NAMED_ILIST: public I_List<NAMED_ILINK> class NAMED_ILIST: public I_List<NAMED_ILINK>
{ {
public: public:
void delete_elements(void (*free_element)(const char*, uchar*)); void delete_elements(void (*free_element)(const char*, void*));
bool delete_element(const char *name, size_t length, void (*free_element)(const char*, uchar*)); bool delete_element(const char *name, size_t length, void (*free_element)(const char*, void*));
}; };
/* For key cache */ /* For key cache */
...@@ -42,7 +42,7 @@ extern NAMED_ILIST key_caches; ...@@ -42,7 +42,7 @@ extern NAMED_ILIST key_caches;
KEY_CACHE *create_key_cache(const char *name, size_t length); KEY_CACHE *create_key_cache(const char *name, size_t length);
KEY_CACHE *get_key_cache(const LEX_CSTRING *cache_name); KEY_CACHE *get_key_cache(const LEX_CSTRING *cache_name);
KEY_CACHE *get_or_create_key_cache(const char *name, size_t length); KEY_CACHE *get_or_create_key_cache(const char *name, size_t length);
void free_key_cache(const char *name, KEY_CACHE *key_cache); void free_key_cache(const char *name, void *key_cache);
bool process_key_caches(process_key_cache_t func, void *param); bool process_key_caches(process_key_cache_t func, void *param);
/* For Rpl_filter */ /* For Rpl_filter */
...@@ -52,7 +52,6 @@ extern NAMED_ILIST rpl_filters; ...@@ -52,7 +52,6 @@ extern NAMED_ILIST rpl_filters;
Rpl_filter *create_rpl_filter(const char *name, size_t length); Rpl_filter *create_rpl_filter(const char *name, size_t length);
Rpl_filter *get_rpl_filter(LEX_CSTRING *filter_name); Rpl_filter *get_rpl_filter(LEX_CSTRING *filter_name);
Rpl_filter *get_or_create_rpl_filter(const char *name, size_t length); Rpl_filter *get_or_create_rpl_filter(const char *name, size_t length);
void free_rpl_filter(const char *name, Rpl_filter *filter);
void free_all_rpl_filters(void); void free_all_rpl_filters(void);
#endif /* KEYCACHES_INCLUDED */ #endif /* KEYCACHES_INCLUDED */
...@@ -2254,7 +2254,7 @@ void clean_up(bool print_message) ...@@ -2254,7 +2254,7 @@ void clean_up(bool print_message)
tdc_deinit(); tdc_deinit();
mdl_destroy(); mdl_destroy();
dflt_key_cache= 0; dflt_key_cache= 0;
key_caches.delete_elements((void (*)(const char*, uchar*)) free_key_cache); key_caches.delete_elements(free_key_cache);
wt_end(); wt_end();
multi_keycache_free(); multi_keycache_free();
sp_cache_end(); sp_cache_end();
......
...@@ -2494,6 +2494,7 @@ Locked_tables_list::reopen_tables(THD *thd, bool need_reopen) ...@@ -2494,6 +2494,7 @@ Locked_tables_list::reopen_tables(THD *thd, bool need_reopen)
{ {
thd->locked_tables_list.unlink_from_list(thd, table_list, false); thd->locked_tables_list.unlink_from_list(thd, table_list, false);
mysql_lock_remove(thd, thd->lock, *prev); mysql_lock_remove(thd, thd->lock, *prev);
(*prev)->file->extra(HA_EXTRA_PREPARE_FOR_FORCED_CLOSE);
close_thread_table(thd, prev); close_thread_table(thd, prev);
break; break;
} }
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 2014, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2014, 2019, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, 2019, MariaDB Corporation. Copyright (c) 2017, 2019, 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
...@@ -51,7 +51,7 @@ PageBulk::init() ...@@ -51,7 +51,7 @@ PageBulk::init()
m_heap = mem_heap_create(1000); m_heap = mem_heap_create(1000);
m_mtr.start(); m_mtr.start();
mtr_x_lock(&m_index->lock, &m_mtr);
if (m_flush_observer) { if (m_flush_observer) {
m_mtr.set_log_mode(MTR_LOG_NO_REDO); m_mtr.set_log_mode(MTR_LOG_NO_REDO);
m_mtr.set_flush_observer(m_flush_observer); m_mtr.set_flush_observer(m_flush_observer);
...@@ -609,22 +609,20 @@ PageBulk::storeExt( ...@@ -609,22 +609,20 @@ PageBulk::storeExt(
btr_pcur.pos_state = BTR_PCUR_IS_POSITIONED; btr_pcur.pos_state = BTR_PCUR_IS_POSITIONED;
btr_pcur.latch_mode = BTR_MODIFY_LEAF; btr_pcur.latch_mode = BTR_MODIFY_LEAF;
btr_pcur.btr_cur.index = m_index; btr_pcur.btr_cur.index = m_index;
btr_pcur.btr_cur.page_cur.index = m_index;
page_cur_t* page_cur = &btr_pcur.btr_cur.page_cur; btr_pcur.btr_cur.page_cur.rec = m_cur_rec;
page_cur->index = m_index; btr_pcur.btr_cur.page_cur.offsets = offsets;
page_cur->rec = m_cur_rec; btr_pcur.btr_cur.page_cur.block = m_block;
page_cur->offsets = offsets;
page_cur->block = m_block;
dberr_t err = btr_store_big_rec_extern_fields( dberr_t err = btr_store_big_rec_extern_fields(
&btr_pcur, offsets, big_rec, &m_mtr, BTR_STORE_INSERT_BULK); &btr_pcur, offsets, big_rec, &m_mtr, BTR_STORE_INSERT_BULK);
ut_ad(page_offset(m_cur_rec) == page_offset(page_cur->rec));
/* Reset m_block and m_cur_rec from page cursor, because /* Reset m_block and m_cur_rec from page cursor, because
block may be changed during blob insert. */ block may be changed during blob insert. (FIXME: Can it really?) */
m_block = page_cur->block; ut_ad(m_block == btr_pcur.btr_cur.page_cur.block);
m_cur_rec = page_cur->rec;
m_block = btr_pcur.btr_cur.page_cur.block;
m_cur_rec = btr_pcur.btr_cur.page_cur.rec;
m_page = buf_block_get_frame(m_block); m_page = buf_block_get_frame(m_block);
return(err); return(err);
...@@ -651,7 +649,7 @@ dberr_t ...@@ -651,7 +649,7 @@ dberr_t
PageBulk::latch() PageBulk::latch()
{ {
m_mtr.start(); m_mtr.start();
mtr_x_lock(&m_index->lock, &m_mtr);
if (m_flush_observer) { if (m_flush_observer) {
m_mtr.set_log_mode(MTR_LOG_NO_REDO); m_mtr.set_log_mode(MTR_LOG_NO_REDO);
m_mtr.set_flush_observer(m_flush_observer); m_mtr.set_flush_observer(m_flush_observer);
...@@ -756,6 +754,10 @@ BtrBulk::pageCommit( ...@@ -756,6 +754,10 @@ BtrBulk::pageCommit(
page_bulk->setNext(FIL_NULL); page_bulk->setNext(FIL_NULL);
} }
ut_ad(!rw_lock_own_flagged(&m_index->lock,
RW_LOCK_FLAG_X | RW_LOCK_FLAG_SX
| RW_LOCK_FLAG_S));
/* Compress page if it's a compressed table. */ /* Compress page if it's a compressed table. */
if (page_bulk->getPageZip() != NULL && !page_bulk->compress()) { if (page_bulk->getPageZip() != NULL && !page_bulk->compress()) {
return(pageSplit(page_bulk, next_page_bulk)); return(pageSplit(page_bulk, next_page_bulk));
......
...@@ -7206,7 +7206,7 @@ struct btr_blob_log_check_t { ...@@ -7206,7 +7206,7 @@ struct btr_blob_log_check_t {
ulint page_no = ULINT_UNDEFINED; ulint page_no = ULINT_UNDEFINED;
FlushObserver* observer = m_mtr->get_flush_observer(); FlushObserver* observer = m_mtr->get_flush_observer();
if (m_op == BTR_STORE_INSERT_BULK) { if (UNIV_UNLIKELY(m_op == BTR_STORE_INSERT_BULK)) {
offs = page_offset(*m_rec); offs = page_offset(*m_rec);
page_no = page_get_page_no( page_no = page_get_page_no(
buf_block_get_frame(*m_block)); buf_block_get_frame(*m_block));
...@@ -7229,8 +7229,7 @@ struct btr_blob_log_check_t { ...@@ -7229,8 +7229,7 @@ struct btr_blob_log_check_t {
index->set_modified(*m_mtr); index->set_modified(*m_mtr);
m_mtr->set_flush_observer(observer); m_mtr->set_flush_observer(observer);
if (m_op == BTR_STORE_INSERT_BULK) { if (UNIV_UNLIKELY(m_op == BTR_STORE_INSERT_BULK)) {
mtr_x_lock(dict_index_get_lock(index), m_mtr);
m_pcur->btr_cur.page_cur.block = btr_block_get( m_pcur->btr_cur.page_cur.block = btr_block_get(
page_id_t(index->table->space_id, page_no), page_id_t(index->table->space_id, page_no),
page_size_t(index->table->space->flags), page_size_t(index->table->space->flags),
...@@ -7259,9 +7258,10 @@ struct btr_blob_log_check_t { ...@@ -7259,9 +7258,10 @@ struct btr_blob_log_check_t {
*m_rec, *m_rec,
MTR_MEMO_PAGE_X_FIX | MTR_MEMO_PAGE_SX_FIX)); MTR_MEMO_PAGE_X_FIX | MTR_MEMO_PAGE_SX_FIX));
ut_ad(mtr_memo_contains_flagged(m_mtr, ut_ad((m_op == BTR_STORE_INSERT_BULK)
dict_index_get_lock(index), == !mtr_memo_contains_flagged(m_mtr, &index->lock,
MTR_MEMO_SX_LOCK | MTR_MEMO_X_LOCK)); MTR_MEMO_SX_LOCK
| MTR_MEMO_X_LOCK));
} }
}; };
...@@ -7315,8 +7315,10 @@ btr_store_big_rec_extern_fields( ...@@ -7315,8 +7315,10 @@ btr_store_big_rec_extern_fields(
ut_ad(rec_offs_validate(rec, index, offsets)); ut_ad(rec_offs_validate(rec, index, offsets));
ut_ad(rec_offs_any_extern(offsets)); ut_ad(rec_offs_any_extern(offsets));
ut_ad(mtr_memo_contains_flagged(btr_mtr, dict_index_get_lock(index), ut_ad(op == BTR_STORE_INSERT_BULK
MTR_MEMO_X_LOCK | MTR_MEMO_SX_LOCK)); || mtr_memo_contains_flagged(btr_mtr, &index->lock,
MTR_MEMO_X_LOCK
| MTR_MEMO_SX_LOCK));
ut_ad(mtr_memo_contains(btr_mtr, rec_block, MTR_MEMO_PAGE_X_FIX)); ut_ad(mtr_memo_contains(btr_mtr, rec_block, MTR_MEMO_PAGE_X_FIX));
ut_ad(buf_block_get_frame(rec_block) == page_align(rec)); ut_ad(buf_block_get_frame(rec_block) == page_align(rec));
ut_a(dict_index_is_clust(index)); ut_a(dict_index_is_clust(index));
...@@ -7441,7 +7443,7 @@ btr_store_big_rec_extern_fields( ...@@ -7441,7 +7443,7 @@ btr_store_big_rec_extern_fields(
mtr_t *alloc_mtr; mtr_t *alloc_mtr;
if (op == BTR_STORE_INSERT_BULK) { if (UNIV_UNLIKELY(op == BTR_STORE_INSERT_BULK)) {
mtr_bulk.start(); mtr_bulk.start();
mtr_bulk.set_spaces(mtr); mtr_bulk.set_spaces(mtr);
alloc_mtr = &mtr_bulk; alloc_mtr = &mtr_bulk;
...@@ -7464,7 +7466,7 @@ btr_store_big_rec_extern_fields( ...@@ -7464,7 +7466,7 @@ btr_store_big_rec_extern_fields(
index->table->space->release_free_extents(r_extents); index->table->space->release_free_extents(r_extents);
if (op == BTR_STORE_INSERT_BULK) { if (UNIV_UNLIKELY(op == BTR_STORE_INSERT_BULK)) {
mtr_bulk.commit(); mtr_bulk.commit();
} }
...@@ -7620,7 +7622,7 @@ btr_store_big_rec_extern_fields( ...@@ -7620,7 +7622,7 @@ btr_store_big_rec_extern_fields(
} }
/* We compress a page when finish bulk insert.*/ /* We compress a page when finish bulk insert.*/
if (op != BTR_STORE_INSERT_BULK) { if (UNIV_LIKELY(op != BTR_STORE_INSERT_BULK)) {
page_zip_write_blob_ptr( page_zip_write_blob_ptr(
page_zip, rec, index, offsets, page_zip, rec, index, offsets,
field_no, &mtr); field_no, &mtr);
......
...@@ -1766,8 +1766,6 @@ fil_crypt_rotate_page( ...@@ -1766,8 +1766,6 @@ fil_crypt_rotate_page(
return; return;
} }
ut_d(const bool was_free = fseg_page_is_free(space, (uint32_t)offset));
mtr_t mtr; mtr_t mtr;
mtr.start(); mtr.start();
if (buf_block_t* block = fil_crypt_get_page_throttle(state, if (buf_block_t* block = fil_crypt_get_page_throttle(state,
...@@ -1782,9 +1780,9 @@ fil_crypt_rotate_page( ...@@ -1782,9 +1780,9 @@ fil_crypt_rotate_page(
if (space->is_stopping()) { if (space->is_stopping()) {
/* The tablespace is closing (in DROP TABLE or /* The tablespace is closing (in DROP TABLE or
TRUNCATE TABLE or similar): avoid further access */ TRUNCATE TABLE or similar): avoid further access */
} else if (!*reinterpret_cast<uint32_t*>(FIL_PAGE_OFFSET } else if (!kv && !*reinterpret_cast<uint16_t*>
+ frame)) { (&frame[FIL_PAGE_TYPE])) {
/* It looks like this page was never /* It looks like this page is not
allocated. Because key rotation is accessing allocated. Because key rotation is accessing
pages in a pattern that is unlike the normal pages in a pattern that is unlike the normal
B-tree and undo log access pattern, we cannot B-tree and undo log access pattern, we cannot
...@@ -1794,9 +1792,20 @@ fil_crypt_rotate_page( ...@@ -1794,9 +1792,20 @@ fil_crypt_rotate_page(
tablespace latch before acquiring block->lock, tablespace latch before acquiring block->lock,
then the fseg_page_is_free() information then the fseg_page_is_free() information
could be stale already. */ could be stale already. */
ut_ad(was_free);
ut_ad(kv == 0); /* If the data file was originally created
ut_ad(page_get_space_id(frame) == 0); before MariaDB 10.0 or MySQL 5.6, some
allocated data pages could carry 0 in
FIL_PAGE_TYPE. The FIL_PAGE_TYPE on those
pages will be updated in
buf_flush_init_for_writing() when the page
is modified the next time.
Also, when the doublewrite buffer pages are
allocated on bootstrap in a non-debug build,
some dummy pages will be allocated, with 0 in
the FIL_PAGE_TYPE. Those pages should be
skipped from key rotation forever. */
} else if (fil_crypt_needs_rotation( } else if (fil_crypt_needs_rotation(
crypt_data, crypt_data,
kv, kv,
......
...@@ -267,10 +267,8 @@ row_undo_ins_remove_sec_low( ...@@ -267,10 +267,8 @@ row_undo_ins_remove_sec_low(
que_thr_t* thr) /*!< in: query thread */ que_thr_t* thr) /*!< in: query thread */
{ {
btr_pcur_t pcur; btr_pcur_t pcur;
btr_cur_t* btr_cur;
dberr_t err = DB_SUCCESS; dberr_t err = DB_SUCCESS;
mtr_t mtr; mtr_t mtr;
enum row_search_result search_result;
const bool modify_leaf = mode == BTR_MODIFY_LEAF; const bool modify_leaf = mode == BTR_MODIFY_LEAF;
row_mtr_start(&mtr, index, !modify_leaf); row_mtr_start(&mtr, index, !modify_leaf);
...@@ -295,12 +293,15 @@ row_undo_ins_remove_sec_low( ...@@ -295,12 +293,15 @@ row_undo_ins_remove_sec_low(
mode |= BTR_RTREE_UNDO_INS; mode |= BTR_RTREE_UNDO_INS;
} }
search_result = row_search_index_entry(index, entry, mode, switch (row_search_index_entry(index, entry, mode, &pcur, &mtr)) {
&pcur, &mtr); case ROW_BUFFERED:
case ROW_NOT_DELETED_REF:
switch (search_result) { /* These are invalid outcomes, because the mode passed
to row_search_index_entry() did not include any of the
flags BTR_INSERT, BTR_DELETE, or BTR_DELETE_MARK. */
ut_error;
case ROW_NOT_FOUND: case ROW_NOT_FOUND:
goto func_exit; break;
case ROW_FOUND: case ROW_FOUND:
if (dict_index_is_spatial(index) if (dict_index_is_spatial(index)
&& rec_get_deleted_flag( && rec_get_deleted_flag(
...@@ -310,31 +311,22 @@ row_undo_ins_remove_sec_low( ...@@ -310,31 +311,22 @@ row_undo_ins_remove_sec_low(
<< " is deleted marked on insert rollback."; << " is deleted marked on insert rollback.";
ut_ad(0); ut_ad(0);
} }
break;
case ROW_BUFFERED: btr_cur_t* btr_cur = btr_pcur_get_btr_cur(&pcur);
case ROW_NOT_DELETED_REF:
/* These are invalid outcomes, because the mode passed
to row_search_index_entry() did not include any of the
flags BTR_INSERT, BTR_DELETE, or BTR_DELETE_MARK. */
ut_error;
}
btr_cur = btr_pcur_get_btr_cur(&pcur);
if (modify_leaf) { if (modify_leaf) {
err = btr_cur_optimistic_delete(btr_cur, 0, &mtr) err = btr_cur_optimistic_delete(btr_cur, 0, &mtr)
? DB_SUCCESS : DB_FAIL; ? DB_SUCCESS : DB_FAIL;
} else { } else {
/* Passing rollback=false here, because we are /* Passing rollback=false here, because we are
deleting a secondary index record: the distinction deleting a secondary index record: the distinction
only matters when deleting a record that contains only matters when deleting a record that contains
externally stored columns. */ externally stored columns. */
ut_ad(!dict_index_is_clust(index)); btr_cur_pessimistic_delete(&err, FALSE, btr_cur, 0,
btr_cur_pessimistic_delete(&err, FALSE, btr_cur, 0, false, &mtr);
false, &mtr); }
} }
func_exit:
btr_pcur_close(&pcur); btr_pcur_close(&pcur);
func_exit_no_pcur: func_exit_no_pcur:
mtr_commit(&mtr); mtr_commit(&mtr);
......
...@@ -455,7 +455,7 @@ my_bool _ma_trnman_end_trans_hook(TRN *trn, my_bool commit, ...@@ -455,7 +455,7 @@ my_bool _ma_trnman_end_trans_hook(TRN *trn, my_bool commit,
MARIA_USED_TABLES *tables, *next; MARIA_USED_TABLES *tables, *next;
DBUG_ENTER("_ma_trnman_end_trans_hook"); DBUG_ENTER("_ma_trnman_end_trans_hook");
DBUG_PRINT("enter", ("trn: %p used_tables: %p", trn, trn->used_tables)); DBUG_PRINT("enter", ("trn: %p used_tables: %p", trn, trn->used_tables));
for (tables= (MARIA_USED_TABLES*) trn->used_tables; for (tables= (MARIA_USED_TABLES*) trn->used_tables;
tables; tables;
tables= next) tables= next)
...@@ -572,6 +572,7 @@ void _ma_remove_table_from_trnman(MARIA_HA *info) ...@@ -572,6 +572,7 @@ void _ma_remove_table_from_trnman(MARIA_HA *info)
TRN *trn= info->trn; TRN *trn= info->trn;
MARIA_USED_TABLES *tables, **prev; MARIA_USED_TABLES *tables, **prev;
MARIA_HA *handler, **prev_file; MARIA_HA *handler, **prev_file;
uint unlinked= 0;
DBUG_ENTER("_ma_remove_table_from_trnman"); DBUG_ENTER("_ma_remove_table_from_trnman");
DBUG_PRINT("enter", ("trn: %p used_tables: %p share: %p in_trans: %d", DBUG_PRINT("enter", ("trn: %p used_tables: %p share: %p in_trans: %d",
trn, trn->used_tables, share, share->in_trans)); trn, trn->used_tables, share, share->in_trans));
...@@ -580,7 +581,7 @@ void _ma_remove_table_from_trnman(MARIA_HA *info) ...@@ -580,7 +581,7 @@ void _ma_remove_table_from_trnman(MARIA_HA *info)
if (trn == &dummy_transaction_object) if (trn == &dummy_transaction_object)
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
/* First remove share from used_tables */ /* First remove share from used_tables */
for (prev= (MARIA_USED_TABLES**) (char*) &trn->used_tables; for (prev= (MARIA_USED_TABLES**) (char*) &trn->used_tables;
(tables= *prev); (tables= *prev);
...@@ -594,7 +595,7 @@ void _ma_remove_table_from_trnman(MARIA_HA *info) ...@@ -594,7 +595,7 @@ void _ma_remove_table_from_trnman(MARIA_HA *info)
break; break;
} }
} }
if (tables != 0) if (!tables)
{ {
/* /*
This can only happens in case of rename of intermediate table as This can only happens in case of rename of intermediate table as
...@@ -603,18 +604,21 @@ void _ma_remove_table_from_trnman(MARIA_HA *info) ...@@ -603,18 +604,21 @@ void _ma_remove_table_from_trnman(MARIA_HA *info)
DBUG_PRINT("warning", ("share: %p where not in used_tables_list", share)); DBUG_PRINT("warning", ("share: %p where not in used_tables_list", share));
} }
/* unlink table from used_instances */ /* unlink all instances of the table from used_instances */
for (prev_file= (MARIA_HA**) &trn->used_instances; prev_file= (MARIA_HA**) &trn->used_instances;
(handler= *prev_file); while ((handler= *prev_file))
prev_file= &handler->trn_next)
{ {
if (handler == info) if (handler->s == share)
{ {
*prev_file= info->trn_next; unlinked++;
break; *prev_file= handler->trn_next; /* Remove instance */
} }
else
prev_file= &handler->trn_next; /* Continue with next instance */
} }
if (handler != 0)
DBUG_PRINT("note", ("unlinked tables: %u", unlinked));
if (!unlinked)
{ {
/* /*
This can only happens in case of rename of intermediate table as This can only happens in case of rename of intermediate table as
......
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