summaryrefslogtreecommitdiff
path: root/storage/innobase
diff options
context:
space:
mode:
Diffstat (limited to 'storage/innobase')
-rw-r--r--storage/innobase/handler/ha_innodb.cc12
-rw-r--r--storage/innobase/include/ha_prototypes.h9
-rw-r--r--storage/innobase/row/row0sel.c17
3 files changed, 26 insertions, 12 deletions
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 4b7c5b1246a..8a8d9698ac1 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -507,6 +507,18 @@ thd_has_edited_nontrans_tables(
return((ibool) thd_non_transactional_update((THD*) thd));
}
+/**********************************************************************
+Returns true if the thread is executing a SELECT statement. */
+extern "C"
+ibool
+thd_is_select(
+/*==========*/
+ /* out: true if thd is executing SELECT */
+ const void* thd) /* in: thread handle (THD*) */
+{
+ return(thd_sql_command((const THD*) thd) == SQLCOM_SELECT);
+}
+
/************************************************************************
Obtain the InnoDB transaction of a MySQL thread. */
inline
diff --git a/storage/innobase/include/ha_prototypes.h b/storage/innobase/include/ha_prototypes.h
index ef0722321af..6bfc43579b3 100644
--- a/storage/innobase/include/ha_prototypes.h
+++ b/storage/innobase/include/ha_prototypes.h
@@ -63,5 +63,14 @@ thd_has_edited_nontrans_tables(
been edited */
void* thd); /* in: thread handle (THD*) */
+/**********************************************************************
+Returns true if the thread is executing a SELECT statement. */
+
+ibool
+thd_is_select(
+/*==========*/
+ /* out: true if thd is executing SELECT */
+ const void* thd); /* in: thread handle (THD*) */
+
#endif
#endif
diff --git a/storage/innobase/row/row0sel.c b/storage/innobase/row/row0sel.c
index c6a93d4e0d5..79f107ce77d 100644
--- a/storage/innobase/row/row0sel.c
+++ b/storage/innobase/row/row0sel.c
@@ -32,6 +32,7 @@ Created 12/19/1997 Heikki Tuuri
#include "row0mysql.h"
#include "read0read.h"
#include "buf0lru.h"
+#include "ha_prototypes.h"
/* Maximum number of rows to prefetch; MySQL interface has another parameter */
#define SEL_MAX_N_PREFETCH 16
@@ -3578,19 +3579,11 @@ shortcut_fails_too_big_rec:
if (trx->isolation_level <= TRX_ISO_READ_COMMITTED
&& prebuilt->select_lock_type != LOCK_NONE
&& trx->mysql_thd != NULL
- && trx->mysql_query_str != NULL
- && *trx->mysql_query_str != NULL) {
+ && thd_is_select(trx->mysql_thd)) {
+ /* It is a plain locking SELECT and the isolation
+ level is low: do not lock gaps */
- /* Scan the MySQL query string; check if SELECT is the first
- word there */
-
- if (dict_str_starts_with_keyword(
- trx->mysql_thd, *trx->mysql_query_str, "SELECT")) {
- /* It is a plain locking SELECT and the isolation
- level is low: do not lock gaps */
-
- set_also_gap_locks = FALSE;
- }
+ set_also_gap_locks = FALSE;
}
/* Note that if the search mode was GE or G, then the cursor