mirror of
https://github.com/MariaDB/server.git
synced 2025-01-24 15:54:37 +01:00
branches/5.1: Identify SELECT statements by thd_sql_command() == SQLCOM_SELECT
instead of parsing the query string. This fixes MySQL Bug #37885 without us having to implement lexical analysis of SQL comments in yet another place. thd_is_select(): A new predicate. row_search_for_mysql(): Use thd_is_select(). Approved by Heikki.
This commit is contained in:
parent
d34b47d7dc
commit
06be45c3d1
3 changed files with 26 additions and 12 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue