From a449f72a4cd60fc74cb7941cfaadfe8aef217520 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 15 Sep 2017 17:25:38 +0300 Subject: [PATCH] Remove the redundant function row_table_got_default_clust_index() Use dict_index_is_auto_gen_clust() instead. --- storage/innobase/handler/ha_innodb.cc | 12 ++++-------- storage/innobase/handler/handler0alter.cc | 6 ++++-- storage/innobase/include/row0mysql.h | 9 --------- storage/innobase/row/row0mysql.cc | 16 ---------------- 4 files changed, 8 insertions(+), 35 deletions(-) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index fe931ce26168c..5e7904b2b8483 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -6689,11 +6689,8 @@ ha_innobase::open(const char* name, int, uint) a row in our table. Note that MySQL may also compare two row references for equality by doing a simple memcmp on the strings of length ref_length! */ - - if (!row_table_got_default_clust_index(ib_table)) { - - m_prebuilt->clust_index_was_generated = FALSE; - + if (!(m_prebuilt->clust_index_was_generated + = dict_index_is_auto_gen_clust(ib_table->indexes.start))) { if (m_primary_key >= MAX_KEY) { ib_table->dict_frm_mismatch = DICT_FRM_NO_PK; @@ -6759,8 +6756,6 @@ ha_innobase::open(const char* name, int, uint) ib_push_frm_error(thd, ib_table, table, 0, true); } - m_prebuilt->clust_index_was_generated = TRUE; - ref_length = DATA_ROW_ID_LEN; /* If we automatically created the clustered index, then @@ -14462,7 +14457,8 @@ innobase_get_mysql_key_number_for_index( i++; } - if (row_table_got_default_clust_index(index->table)) { + if (dict_index_is_clust(index) + && dict_index_is_auto_gen_clust(index)) { ut_a(i > 0); i--; } diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 1140cef8452e7..352b223ab6927 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -689,7 +689,8 @@ ha_innobase::check_if_supported_inplace_alter( /* See if MYSQL table has no pk but we do. */ if (UNIV_UNLIKELY(my_primary_key >= MAX_KEY) - && !row_table_got_default_clust_index(m_prebuilt->table)) { + && !dict_index_is_auto_gen_clust( + dict_table_get_first_index(m_prebuilt->table))) { ha_alter_info->unsupported_reason = innobase_get_err_msg( ER_PRIMARY_CANT_HAVE_NULL); DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED); @@ -4448,7 +4449,8 @@ prepare_inplace_alter_table_dict( index_defs = innobase_create_key_defs( ctx->heap, ha_alter_info, altered_table, ctx->num_to_add_index, num_fts_index, - row_table_got_default_clust_index(ctx->new_table), + dict_index_is_auto_gen_clust(dict_table_get_first_index( + ctx->new_table)), fts_doc_id_col, add_fts_doc_id, add_fts_doc_id_idx, old_table); diff --git a/storage/innobase/include/row0mysql.h b/storage/innobase/include/row0mysql.h index 8e93faf7286cc..2b0006039295e 100644 --- a/storage/innobase/include/row0mysql.h +++ b/storage/innobase/include/row0mysql.h @@ -262,15 +262,6 @@ row_get_prebuilt_update_vector( /*===========================*/ row_prebuilt_t* prebuilt); /*!< in: prebuilt struct in MySQL handle */ -/*********************************************************************//** -Checks if a table is such that we automatically created a clustered -index on it (on row id). -@return TRUE if the clustered index was generated automatically */ -ibool -row_table_got_default_clust_index( -/*==============================*/ - const dict_table_t* table); /*!< in: table */ - /** Does an update or delete of a row for MySQL. @param[in,out] prebuilt prebuilt struct in MySQL handle @return error code or DB_SUCCESS */ diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index db7f906b0cb52..4ceef6c918fbe 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -2283,22 +2283,6 @@ row_unlock_for_mysql( trx->op_info = ""; } -/*********************************************************************//** -Checks if a table is such that we automatically created a clustered -index on it (on row id). -@return TRUE if the clustered index was generated automatically */ -ibool -row_table_got_default_clust_index( -/*==============================*/ - const dict_table_t* table) /*!< in: table */ -{ - const dict_index_t* clust_index; - - clust_index = dict_table_get_first_index(table); - - return(dict_index_get_nth_col(clust_index, 0)->mtype == DATA_SYS); -} - /*********************************************************************//** Locks the data dictionary in shared mode from modifications, for performing foreign key check, rollback, or other operation invisible to MySQL. */