summaryrefslogtreecommitdiff
path: root/storage/innobase/handler/handler0alter.cc
diff options
context:
space:
mode:
Diffstat (limited to 'storage/innobase/handler/handler0alter.cc')
-rw-r--r--storage/innobase/handler/handler0alter.cc79
1 files changed, 45 insertions, 34 deletions
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index 05a69648720..3ffd7347472 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -1997,8 +1997,13 @@ static bool innobase_table_is_empty(const dict_table_t *table,
bool next_page= false;
mtr.start();
- btr_pcur_open_at_index_side(true, clust_index, BTR_SEARCH_LEAF,
- &pcur, true, 0, &mtr);
+ if (btr_pcur_open_at_index_side(true, clust_index, BTR_SEARCH_LEAF,
+ &pcur, true, 0, &mtr) != DB_SUCCESS)
+ {
+non_empty:
+ mtr.commit();
+ return false;
+ }
btr_pcur_move_to_next_user_rec(&pcur, &mtr);
if (!rec_is_metadata(btr_pcur_get_rec(&pcur), *clust_index))
btr_pcur_move_to_prev_on_page(&pcur);
@@ -2016,9 +2021,10 @@ next_page:
}
next_page= false;
- block= page_cur_get_block(cur);
block= btr_block_get(*clust_index, next_page_no, BTR_SEARCH_LEAF, false,
&mtr);
+ if (!block)
+ goto non_empty;
btr_leaf_page_release(page_cur_get_block(cur), BTR_SEARCH_LEAF, &mtr);
page_cur_set_before_first(block, cur);
page_cur_move_to_next(cur);
@@ -2029,9 +2035,7 @@ next_page:
{
if (ignore_delete_marked)
goto scan_leaf;
-non_empty:
- mtr.commit();
- return false;
+ goto non_empty;
}
else if (!page_rec_is_supremum(rec))
goto non_empty;
@@ -5899,8 +5903,19 @@ add_all_virtual:
mtr.start();
index->set_modified(mtr);
btr_pcur_t pcur;
- btr_pcur_open_at_index_side(true, index, BTR_MODIFY_TREE, &pcur, true,
- 0, &mtr);
+ dberr_t err = btr_pcur_open_at_index_side(true, index, BTR_MODIFY_TREE,
+ &pcur, true, 0, &mtr);
+ if (err != DB_SUCCESS) {
+func_exit:
+ mtr.commit();
+
+ if (err != DB_SUCCESS) {
+ my_error_innodb(err, table->s->table_name.str,
+ user_table->flags);
+ return true;
+ }
+ return false;
+ }
ut_ad(btr_pcur_is_before_first_on_page(&pcur));
btr_pcur_move_to_next_on_page(&pcur);
@@ -5913,7 +5928,6 @@ add_all_virtual:
NULL, trx, ctx->heap, NULL);
const bool is_root = block->page.id().page_no() == index->page;
- dberr_t err = DB_SUCCESS;
if (rec_is_metadata(rec, *index)) {
ut_ad(page_rec_is_user_rec(rec));
if (is_root
@@ -5930,8 +5944,11 @@ add_all_virtual:
/* Ensure that the root page is in the correct format. */
buf_block_t* root = btr_root_block_get(index, RW_X_LATCH,
- &mtr);
- DBUG_ASSERT(root);
+ &mtr, &err);
+ if (UNIV_UNLIKELY(!root)) {
+ goto func_exit;
+ }
+
if (fil_page_get_type(root->page.frame)
!= FIL_PAGE_TYPE_INSTANT) {
DBUG_ASSERT("wrong page type" == 0);
@@ -6022,10 +6039,12 @@ empty_table:
mtr.commit();
mtr.start();
index->set_modified(mtr);
- if (buf_block_t* root = btr_root_block_get(index, RW_SX_LATCH, &mtr)) {
+ if (buf_block_t* root = btr_root_block_get(index, RW_SX_LATCH, &mtr,
+ &err)) {
if (fil_page_get_type(root->page.frame) != FIL_PAGE_INDEX) {
DBUG_ASSERT("wrong page type" == 0);
- goto err_exit;
+ err = DB_CORRUPTION;
+ goto func_exit;
}
btr_set_instant(root, *index, &mtr);
@@ -6035,21 +6054,9 @@ empty_table:
err = row_ins_clust_index_entry_low(
BTR_NO_LOCKING_FLAG, BTR_MODIFY_TREE, index,
index->n_uniq, entry, 0, thr);
- } else {
-err_exit:
- err = DB_CORRUPTION;
- }
-
-func_exit:
- mtr.commit();
-
- if (err != DB_SUCCESS) {
- my_error_innodb(err, table->s->table_name.str,
- user_table->flags);
- return true;
}
- return false;
+ goto func_exit;
}
/** Adjust the create index column number from "New table" to
@@ -8557,6 +8564,11 @@ oom:
switch (error) {
KEY* dup_key;
+ default:
+ my_error_innodb(error,
+ table_share->table_name.str,
+ m_prebuilt->table->flags);
+ break;
all_done:
case DB_SUCCESS:
ut_d(dict_sys.freeze(SRW_LOCK_CALL));
@@ -8593,18 +8605,14 @@ oom:
get_error_key_name(m_prebuilt->trx->error_key_num,
ha_alter_info, m_prebuilt->table));
break;
- case DB_DECRYPTION_FAILED: {
+ case DB_DECRYPTION_FAILED:
String str;
const char* engine= table_type();
get_error_message(HA_ERR_DECRYPTION_FAILED, &str);
- my_error(ER_GET_ERRMSG, MYF(0), HA_ERR_DECRYPTION_FAILED, str.c_ptr(), engine);
+ my_error(ER_GET_ERRMSG, MYF(0), HA_ERR_DECRYPTION_FAILED,
+ str.c_ptr(), engine);
break;
}
- default:
- my_error_innodb(error,
- table_share->table_name.str,
- m_prebuilt->table->flags);
- }
/* prebuilt->table->n_ref_count can be anything here, given
that we hold at most a shared lock on the table. */
@@ -10433,7 +10441,10 @@ handle_error:
default:
sql_print_error("InnoDB: %s: %s\n", op,
ut_strerr(error));
- DBUG_ASSERT(0);
+ DBUG_ASSERT(error == DB_IO_ERROR
+ || error == DB_DECRYPTION_FAILED
+ || error == DB_PAGE_CORRUPTED
+ || error == DB_CORRUPTION);
my_error(ER_INTERNAL_ERROR, MYF(0), op);
}