Commit e7f9daa5 authored by vasil's avatar vasil

branches/zip:

Merge 2537:2605 from branches/5.1:

  ------------------------------------------------------------------------
  r2545 | vasil | 2008-07-25 17:24:23 +0300 (Fri, 25 Jul 2008) | 37 lines
  Changed paths:
     M /branches/5.1/handler/ha_innodb.cc
  
  branches/5.1:
  
  Fix Bug#38185 ha_innobase::info can hold locks even when called with HA_STATUS_NO_LOCK
  
  The fix is to call fsp_get_available_space_in_free_extents() from
  ha_innobase::info() only if HA_STATUS_NO_LOCK is not present in the flag
  *AND*
  change get_schema_tables_record() in MySQL's sql/sql_show.cc to call
  ::info() *without* HA_STATUS_NO_LOCK whenever a user issues SELECT FROM
  information_schema.tables;
  
  Without the change to sql/sql_show.cc this patch would lead to Bug#32440
  resurfacing. I.e. delete_length would never be updated in ::info() and
  will remain 0 forever, resulting in the free space not being shown
  anywhere.
  
  This is the change to sql/sql_show.cc for reference, it needs to be
  committed to the MySQL repo before or at the same time with this change
  to ha_innodb.cc:
  
   --- patch begins here ---
   --- sql/sql_show.cc.orig	2008-07-23 09:32:14.000000000 +0300
   +++ sql/sql_show.cc	2008-07-23 09:32:19.000000000 +0300
   @@ -3549,8 +3549,7 @@ static int get_schema_tables_record(THD 
    
        if(file)
        {
   -      file->info(HA_STATUS_VARIABLE | HA_STATUS_TIME | HA_STATUS_AUTO |
   -                 HA_STATUS_NO_LOCK);
   +      file->info(HA_STATUS_VARIABLE | HA_STATUS_TIME | HA_STATUS_AUTO);
          enum row_type row_type = file->get_row_type();
          switch (row_type) {
          case ROW_TYPE_NOT_USED:
   --- patch ends here ---
  
  Approved by:	Heikki
  
  ------------------------------------------------------------------------
  r2603 | marko | 2008-08-21 16:25:05 +0300 (Thu, 21 Aug 2008) | 10 lines
  Changed paths:
     M /branches/5.1/handler/ha_innodb.cc
     M /branches/5.1/include/ha_prototypes.h
     M /branches/5.1/row/row0sel.c
  
  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.
  
  ------------------------------------------------------------------------
parent 157b8eeb
...@@ -641,6 +641,18 @@ thd_has_edited_nontrans_tables( ...@@ -641,6 +641,18 @@ thd_has_edited_nontrans_tables(
return((ibool) thd_non_transactional_update((THD*) thd)); 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. */ Obtain the InnoDB transaction of a MySQL thread. */
inline inline
...@@ -6659,9 +6671,21 @@ ha_innobase::info( ...@@ -6659,9 +6671,21 @@ ha_innobase::info(
stats.index_file_length = ((ulonglong) stats.index_file_length = ((ulonglong)
ib_table->stat_sum_of_other_index_sizes) ib_table->stat_sum_of_other_index_sizes)
* UNIV_PAGE_SIZE; * UNIV_PAGE_SIZE;
/* Since fsp_get_available_space_in_free_extents() is
acquiring latches inside InnoDB, we do not call it if we
are asked by MySQL to avoid locking. Another reason to
avoid the call is that it uses quite a lot of CPU.
See Bug#38185.
We do not update delete_length if no locking is requested
so the "old" value can remain. delete_length is initialized
to 0 in the ha_statistics' constructor. */
if (!(flag & HA_STATUS_NO_LOCK)) {
stats.delete_length = stats.delete_length =
fsp_get_available_space_in_free_extents( fsp_get_available_space_in_free_extents(
ib_table->space) * 1024; ib_table->space) * 1024;
}
stats.check_time = 0; stats.check_time = 0;
if (stats.records == 0) { if (stats.records == 0) {
......
...@@ -158,5 +158,15 @@ innobase_strcasecmp( ...@@ -158,5 +158,15 @@ innobase_strcasecmp(
/* out: 0 if a=b, <0 if a<b, >1 if a>b */ /* out: 0 if a=b, <0 if a<b, >1 if a>b */
const char* a, /* in: first string to compare */ const char* a, /* in: first string to compare */
const char* b); /* in: second string to compare */ const char* b); /* in: second string to compare */
/**********************************************************************
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
#endif #endif
...@@ -32,6 +32,7 @@ Created 12/19/1997 Heikki Tuuri ...@@ -32,6 +32,7 @@ Created 12/19/1997 Heikki Tuuri
#include "row0mysql.h" #include "row0mysql.h"
#include "read0read.h" #include "read0read.h"
#include "buf0lru.h" #include "buf0lru.h"
#include "ha_prototypes.h"
/* Maximum number of rows to prefetch; MySQL interface has another parameter */ /* Maximum number of rows to prefetch; MySQL interface has another parameter */
#define SEL_MAX_N_PREFETCH 16 #define SEL_MAX_N_PREFETCH 16
...@@ -3699,20 +3700,12 @@ shortcut_fails_too_big_rec: ...@@ -3699,20 +3700,12 @@ shortcut_fails_too_big_rec:
if (trx->isolation_level <= TRX_ISO_READ_COMMITTED if (trx->isolation_level <= TRX_ISO_READ_COMMITTED
&& prebuilt->select_lock_type != LOCK_NONE && prebuilt->select_lock_type != LOCK_NONE
&& trx->mysql_thd != NULL && trx->mysql_thd != NULL
&& trx->mysql_query_str != NULL && thd_is_select(trx->mysql_thd)) {
&& *trx->mysql_query_str != NULL) {
/* 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 /* It is a plain locking SELECT and the isolation
level is low: do not lock gaps */ 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 /* Note that if the search mode was GE or G, then the cursor
naturally moves upward (in fetch next) in alphabetical order, naturally moves upward (in fetch next) in alphabetical order,
......
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