Commit e646f8f2 authored by unknown's avatar unknown

Merge with 4.0


BitKeeper/deleted/.del-innodb-lock-master.opt~f76a4a1999728f87:
  Auto merged
innobase/include/trx0sys.h:
  Auto merged
innobase/srv/srv0srv.c:
  Auto merged
innobase/trx/trx0purge.c:
  Auto merged
innobase/trx/trx0rseg.c:
  Auto merged
mysql-test/r/innodb-lock.result:
  Auto merged
mysql-test/t/innodb-lock.test:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/set_var.cc:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/mysqld.cc:
  Use local version during merge
parents 55833fb4 3bdd7e77
...@@ -111,6 +111,7 @@ extern ibool srv_use_doublewrite_buf; ...@@ -111,6 +111,7 @@ extern ibool srv_use_doublewrite_buf;
extern ibool srv_set_thread_priorities; extern ibool srv_set_thread_priorities;
extern int srv_query_thread_priority; extern int srv_query_thread_priority;
extern ulint srv_max_purge_lag;
extern ibool srv_use_awe; extern ibool srv_use_awe;
extern ibool srv_use_adaptive_hash_indexes; extern ibool srv_use_adaptive_hash_indexes;
......
...@@ -881,6 +881,8 @@ srv_general_init(void) ...@@ -881,6 +881,8 @@ srv_general_init(void)
/*======================= InnoDB Server FIFO queue =======================*/ /*======================= InnoDB Server FIFO queue =======================*/
/* Maximum allowable purge history length. <=0 means 'infinite'. */
ulint srv_max_purge_lag = 0;
/************************************************************************* /*************************************************************************
Puts an OS thread to wait if there are too many concurrent threads Puts an OS thread to wait if there are too many concurrent threads
......
...@@ -1069,6 +1069,30 @@ trx_purge(void) ...@@ -1069,6 +1069,30 @@ trx_purge(void)
} }
} }
/* Determine how much data manipulation language (DML) statements
need to be delayed in order to reduce the lagging of the purge
thread. */
srv_dml_needed_delay = 0; /* in microseconds; default: no delay */
/* If we cannot advance the 'purge view' because of an old
'consistent read view', then the DML statements cannot be delayed.
Also, srv_max_purge_lag <= 0 means 'infinity'. */
if (srv_max_purge_lag > 0
&& !UT_LIST_GET_LAST(trx_sys->view_list)) {
float ratio = (float) trx_sys->rseg_history_len
/ srv_max_purge_lag;
if (ratio > ULINT_MAX / 10000) {
/* Avoid overflow: maximum delay is 4295 seconds */
srv_dml_needed_delay = ULINT_MAX;
} else if (ratio > 1) {
/* If the history list length exceeds the
innodb_max_purge_lag, the
data manipulation statements are delayed
by at least 5000 microseconds. */
srv_dml_needed_delay = (ulint) ((ratio - .5) * 10000);
}
}
purge_sys->view = read_view_oldest_copy_or_open_new(NULL, purge_sys->view = read_view_oldest_copy_or_open_new(NULL,
purge_sys->heap); purge_sys->heap);
mutex_exit(&kernel_mutex); mutex_exit(&kernel_mutex);
......
...@@ -791,6 +791,19 @@ Qcache_queries_in_cache 1 ...@@ -791,6 +791,19 @@ Qcache_queries_in_cache 1
unlock table; unlock table;
drop table t1,t2; drop table t1,t2;
set query_cache_wlock_invalidate=default; set query_cache_wlock_invalidate=default;
CREATE TABLE t1 (id INT PRIMARY KEY);
insert into t1 values (1),(2),(3);
select * from t1;
id
1
2
3
create temporary table t1 (a int not null auto_increment
primary key);
select * from t1;
a
drop table t1;
drop table t1;
SET NAMES koi8r; SET NAMES koi8r;
CREATE TABLE t1 (a char(1) character set koi8r); CREATE TABLE t1 (a char(1) character set koi8r);
INSERT INTO t1 VALUES (_koi8r''),(_koi8r''); INSERT INTO t1 VALUES (_koi8r''),(_koi8r'');
......
...@@ -561,6 +561,17 @@ unlock table; ...@@ -561,6 +561,17 @@ unlock table;
drop table t1,t2; drop table t1,t2;
set query_cache_wlock_invalidate=default; set query_cache_wlock_invalidate=default;
#
# hiding real table stored in query cache by temporary table
#
CREATE TABLE t1 (id INT PRIMARY KEY);
insert into t1 values (1),(2),(3);
select * from t1;
create temporary table t1 (a int not null auto_increment
primary key);
select * from t1;
drop table t1;
drop table t1;
# #
# Test character set related variables: # Test character set related variables:
......
...@@ -198,6 +198,7 @@ extern my_bool innobase_very_fast_shutdown; /* set this to 1 just before ...@@ -198,6 +198,7 @@ extern my_bool innobase_very_fast_shutdown; /* set this to 1 just before
is equivalent to a 'crash' */ is equivalent to a 'crash' */
extern "C" { extern "C" {
extern ulong srv_max_buf_pool_modified_pct; extern ulong srv_max_buf_pool_modified_pct;
extern ulong srv_max_purge_lag;
extern ulong srv_auto_extend_increment; extern ulong srv_auto_extend_increment;
extern ulong srv_max_purge_lag; extern ulong srv_max_purge_lag;
} }
......
...@@ -681,6 +681,7 @@ int mysql_ha_flush(THD *thd, TABLE_LIST *tables, uint mode_flags); ...@@ -681,6 +681,7 @@ int mysql_ha_flush(THD *thd, TABLE_LIST *tables, uint mode_flags);
#define MYSQL_HA_FLUSH_ALL 0x02 #define MYSQL_HA_FLUSH_ALL 0x02
/* sql_base.cc */ /* sql_base.cc */
#define TMP_TABLE_KEY_EXTRA 8
void set_item_name(Item *item,char *pos,uint length); void set_item_name(Item *item,char *pos,uint length);
bool add_field_to_list(THD *thd, char *field_name, enum enum_field_types type, bool add_field_to_list(THD *thd, char *field_name, enum enum_field_types type,
char *length, char *decimal, char *length, char *decimal,
......
...@@ -352,6 +352,8 @@ sys_var_thd_ulong sys_net_wait_timeout("wait_timeout", ...@@ -352,6 +352,8 @@ sys_var_thd_ulong sys_net_wait_timeout("wait_timeout",
#ifdef HAVE_INNOBASE_DB #ifdef HAVE_INNOBASE_DB
sys_var_long_ptr sys_innodb_max_dirty_pages_pct("innodb_max_dirty_pages_pct", sys_var_long_ptr sys_innodb_max_dirty_pages_pct("innodb_max_dirty_pages_pct",
&srv_max_buf_pool_modified_pct); &srv_max_buf_pool_modified_pct);
sys_var_long_ptr sys_innodb_max_purge_lag("innodb_max_purge_lag",
&srv_max_purge_lag);
sys_var_thd_bool sys_innodb_table_locks("innodb_table_locks", sys_var_thd_bool sys_innodb_table_locks("innodb_table_locks",
&SV::innodb_table_locks); &SV::innodb_table_locks);
sys_var_long_ptr sys_innodb_autoextend_increment("innodb_autoextend_increment", sys_var_long_ptr sys_innodb_autoextend_increment("innodb_autoextend_increment",
...@@ -608,6 +610,7 @@ sys_var *sys_variables[]= ...@@ -608,6 +610,7 @@ sys_var *sys_variables[]=
&sys_os, &sys_os,
#ifdef HAVE_INNOBASE_DB #ifdef HAVE_INNOBASE_DB
&sys_innodb_max_dirty_pages_pct, &sys_innodb_max_dirty_pages_pct,
&sys_innodb_max_purge_lag,
&sys_innodb_table_locks, &sys_innodb_table_locks,
&sys_innodb_max_purge_lag, &sys_innodb_max_purge_lag,
&sys_innodb_autoextend_increment, &sys_innodb_autoextend_increment,
...@@ -704,6 +707,7 @@ struct show_var_st init_vars[]= { ...@@ -704,6 +707,7 @@ struct show_var_st init_vars[]= {
{"innodb_log_files_in_group", (char*) &innobase_log_files_in_group, SHOW_LONG}, {"innodb_log_files_in_group", (char*) &innobase_log_files_in_group, SHOW_LONG},
{"innodb_log_group_home_dir", (char*) &innobase_log_group_home_dir, SHOW_CHAR_PTR}, {"innodb_log_group_home_dir", (char*) &innobase_log_group_home_dir, SHOW_CHAR_PTR},
{sys_innodb_max_dirty_pages_pct.name, (char*) &sys_innodb_max_dirty_pages_pct, SHOW_SYS}, {sys_innodb_max_dirty_pages_pct.name, (char*) &sys_innodb_max_dirty_pages_pct, SHOW_SYS},
{sys_innodb_max_purge_lag.name, (char*) &sys_innodb_max_purge_lag, SHOW_SYS},
{sys_innodb_table_locks.name, (char*) &sys_innodb_table_locks, SHOW_SYS}, {sys_innodb_table_locks.name, (char*) &sys_innodb_table_locks, SHOW_SYS},
{sys_innodb_max_purge_lag.name, (char*) &sys_innodb_max_purge_lag, SHOW_SYS}, {sys_innodb_max_purge_lag.name, (char*) &sys_innodb_max_purge_lag, SHOW_SYS},
{"innodb_mirrored_log_groups", (char*) &innobase_mirrored_log_groups, SHOW_LONG}, {"innodb_mirrored_log_groups", (char*) &innobase_mirrored_log_groups, SHOW_LONG},
......
...@@ -806,8 +806,9 @@ TABLE *open_table(THD *thd,const char *db,const char *table_name, ...@@ -806,8 +806,9 @@ TABLE *open_table(THD *thd,const char *db,const char *table_name,
for (table=thd->temporary_tables; table ; table=table->next) for (table=thd->temporary_tables; table ; table=table->next)
{ {
if (table->key_length == key_length+8 && if (table->key_length == key_length + TMP_TABLE_KEY_EXTRA &&
!memcmp(table->table_cache_key,key,key_length+8)) !memcmp(table->table_cache_key, key,
key_length + TMP_TABLE_KEY_EXTRA))
{ {
if (table->query_id == thd->query_id) if (table->query_id == thd->query_id)
{ {
......
...@@ -1025,9 +1025,38 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length) ...@@ -1025,9 +1025,38 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
for (; block_table != block_table_end; block_table++) for (; block_table != block_table_end; block_table++)
{ {
TABLE_LIST table_list; TABLE_LIST table_list;
bzero((char*) &table_list,sizeof(table_list)); TABLE *tmptable;
Query_cache_table *table = block_table->parent; Query_cache_table *table = block_table->parent;
/*
Check that we have not temporary tables with same names of tables
of this query. If we have such tables, we will not send data from
query cache, because temporary tables hide real tables by which
query in query cache was made.
*/
for (tmptable= thd->temporary_tables; tmptable ; tmptable= tmptable->next)
{
if (tmptable->key_length - TMP_TABLE_KEY_EXTRA == table->key_len() &&
!memcmp(tmptable->table_cache_key, table->data(),
table->key_len()))
{
DBUG_PRINT("qcache",
("Temporary table detected: '%s.%s'",
table_list.db, table_list.alias));
STRUCT_UNLOCK(&structure_guard_mutex);
/*
We should not store result of this query because it contain
temporary tables => assign following variable to make check
faster.
*/
thd->safe_to_cache_query=0;
BLOCK_UNLOCK_RD(query_block);
DBUG_RETURN(-1);
}
}
bzero((char*) &table_list,sizeof(table_list));
table_list.db = table->db(); table_list.db = table->db();
table_list.alias= table_list.real_name= table->table(); table_list.alias= table_list.real_name= table->table();
#ifndef NO_EMBEDDED_ACCESS_CHECKS #ifndef NO_EMBEDDED_ACCESS_CHECKS
......
...@@ -143,14 +143,14 @@ struct Query_cache_query ...@@ -143,14 +143,14 @@ struct Query_cache_query
struct Query_cache_table struct Query_cache_table
{ {
char *tbl; char *tbl;
uint key_len; uint32 key_len;
uint8 table_type; uint8 table_type;
inline char *db() { return (char *) data(); } inline char *db() { return (char *) data(); }
inline char *table() { return tbl; } inline char *table() { return tbl; }
inline void table(char *table) { tbl= table; } inline void table(char *table) { tbl= table; }
inline uint key_length() { return key_len; } inline uint32 key_length() { return key_len; }
inline void key_length(uint len) { key_len= len; } inline void key_length(uint32 len) { key_len= len; }
inline uint8 type() { return table_type; } inline uint8 type() { return table_type; }
inline void type(uint8 t) { table_type= t; } inline void type(uint8 t) { table_type= t; }
inline gptr data() inline gptr data()
......
...@@ -2471,7 +2471,7 @@ unsent_create_error: ...@@ -2471,7 +2471,7 @@ unsent_create_error:
if (lex->name && (!lex->name[0] || strlen(lex->name) > NAME_LEN)) if (lex->name && (!lex->name[0] || strlen(lex->name) > NAME_LEN))
{ {
net_printf(thd, ER_WRONG_TABLE_NAME, lex->name); net_printf(thd, ER_WRONG_TABLE_NAME, lex->name);
res=0; res= 1;
break; break;
} }
if (!select_lex->db) if (!select_lex->db)
......
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