diff --git a/sql/sql_class.cc b/sql/sql_class.cc index fb4ed99b8bb..03b8cff3e25 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -3552,6 +3552,10 @@ extern "C" unsigned long thd_get_thread_id(const MYSQL_THD thd) return((unsigned long)thd->thread_id); } +extern "C" enum_tx_isolation thd_get_trx_isolation(const MYSQL_THD thd) +{ + return thd->tx_isolation; +} #ifdef INNODB_COMPATIBILITY_HOOKS extern "C" struct charset_info_st *thd_charset(MYSQL_THD thd) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 02bae038192..163c89d6cc5 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -87,6 +87,9 @@ extern "C" { #include "ha_prototypes.h" #include "ut0mem.h" #include "ibuf0ibuf.h" + +enum_tx_isolation thd_get_trx_isolation(const THD* thd); + } #include "ha_innodb.h" @@ -391,6 +394,15 @@ innobase_alter_table_flags( /*=======================*/ uint flags); +/******************************************************************//** +Maps a MySQL trx isolation level code to the InnoDB isolation level code +@return InnoDB isolation level */ +static inline +ulint +innobase_map_isolation_level( +/*=========================*/ + enum_tx_isolation iso); /*!< in: MySQL isolation level code */ + static const char innobase_hton_name[]= "InnoDB"; /*************************************************************//** @@ -2705,9 +2717,22 @@ innobase_start_trx_and_assign_read_view( trx_start_if_not_started(trx); - /* Assign a read view if the transaction does not have it yet */ + /* Assign a read view if the transaction does not have it yet. + Do this only if transaction is using REPEATABLE READ isolation + level. */ + trx->isolation_level = innobase_map_isolation_level( + thd_get_trx_isolation(thd)); - trx_assign_read_view(trx); + if (trx->isolation_level == TRX_ISO_REPEATABLE_READ) { + trx_assign_read_view(trx); + } else { + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + HA_ERR_UNSUPPORTED, + "InnoDB: WITH CONSISTENT SNAPSHOT " + "was ignored because this phrase " + "can only be used with " + "REPEATABLE READ isolation level."); + } /* Set the MySQL flag to mark that there is an active transaction */