Commit 64c58c13 authored by Annamalai Gurusami's avatar Annamalai Gurusami

Bug #14017206 WITH CONSISTENT SNAPSHOT DOES NOT WORK WITH ISOLATION LEVEL

SERIALIZABLE

Problem:

The documentation claims that WITH CONSISTENT SNAPSHOT will work for both
REPEATABLE READ and SERIALIZABLE isolation levels.  But it will work only
for REPEATABLE READ isolation level.  Also, the clause WITH CONSISTENT
SNAPSHOT is silently ignored when it is not applicable to the given isolation
level.  

Solution:

Generate a warning when the clause WITH CONSISTENT SNAPSHOT is ignored.

rb#2797 approved by Kevin.

Note: Support team wanted to push this to 5.5+.
parent 49056074
...@@ -3552,6 +3552,10 @@ extern "C" unsigned long thd_get_thread_id(const MYSQL_THD thd) ...@@ -3552,6 +3552,10 @@ extern "C" unsigned long thd_get_thread_id(const MYSQL_THD thd)
return((unsigned long)thd->thread_id); 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 #ifdef INNODB_COMPATIBILITY_HOOKS
extern "C" struct charset_info_st *thd_charset(MYSQL_THD thd) extern "C" struct charset_info_st *thd_charset(MYSQL_THD thd)
......
...@@ -87,6 +87,9 @@ extern "C" { ...@@ -87,6 +87,9 @@ extern "C" {
#include "ha_prototypes.h" #include "ha_prototypes.h"
#include "ut0mem.h" #include "ut0mem.h"
#include "ibuf0ibuf.h" #include "ibuf0ibuf.h"
enum_tx_isolation thd_get_trx_isolation(const THD* thd);
} }
#include "ha_innodb.h" #include "ha_innodb.h"
...@@ -391,6 +394,15 @@ innobase_alter_table_flags( ...@@ -391,6 +394,15 @@ innobase_alter_table_flags(
/*=======================*/ /*=======================*/
uint 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"; static const char innobase_hton_name[]= "InnoDB";
/*************************************************************//** /*************************************************************//**
...@@ -2705,9 +2717,22 @@ innobase_start_trx_and_assign_read_view( ...@@ -2705,9 +2717,22 @@ innobase_start_trx_and_assign_read_view(
trx_start_if_not_started(trx); 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 */ /* Set the MySQL flag to mark that there is an active transaction */
......
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