Commit 770219c1 authored by thek@adventure.(none)'s avatar thek@adventure.(none)

Merge adventure.(none):/home/thek/Development/cpp/bug27792/my51-bug27792

into  adventure.(none):/home/thek/Development/cpp/mysql-5.1-runtime
parents b09ded41 902b02ec
...@@ -1343,3 +1343,97 @@ c1 ...@@ -1343,3 +1343,97 @@ c1
100 100
drop table t1; drop table t1;
set global query_cache_size=0; set global query_cache_size=0;
create table t1 (a int);
insert into t1 values (1),(2),(3);
set GLOBAL query_cache_type=1;
set GLOBAL query_cache_limit=10000;
set GLOBAL query_cache_min_res_unit=0;
set GLOBAL query_cache_size= 100000;
reset query cache;
set LOCAL default_week_format = 0;
select week('2007-01-04');
week('2007-01-04')
0
select week('2007-01-04') from t1;
week('2007-01-04')
0
0
0
select extract(WEEK FROM '2007-01-04') from t1;
extract(WEEK FROM '2007-01-04')
0
0
0
set LOCAL default_week_format = 2;
select week('2007-01-04');
week('2007-01-04')
53
select week('2007-01-04') from t1;
week('2007-01-04')
53
53
53
select extract(WEEK FROM '2007-01-04') from t1;
extract(WEEK FROM '2007-01-04')
53
53
53
reset query cache;
set LOCAL div_precision_increment=2;
select 1/7;
1/7
0.14
select 1/7 from t1;
1/7
0.14
0.14
0.14
set LOCAL div_precision_increment=4;
select 1/7;
1/7
0.1429
select 1/7 from t1;
1/7
0.1429
0.1429
0.1429
drop table t1;
CREATE TABLE t1 (a VARCHAR(200), b TEXT, FULLTEXT (a,b));
INSERT INTO t1 VALUES('MySQL has now support', 'for full-text search'),
('Full-text indexes', 'are called collections'),
('Only MyISAM tables','support collections'),
('Function MATCH ... AGAINST()','is used to do a search'),
('Full-text search in MySQL', 'implements vector space model');
set GLOBAL ft_boolean_syntax='+ -><()~*:""&|';
select *, MATCH(a,b) AGAINST("+called +collections" IN BOOLEAN MODE) as x from t1;
a b x
MySQL has now support for full-text search 0
Full-text indexes are called collections 1
Only MyISAM tables support collections 0
Function MATCH ... AGAINST() is used to do a search 0
Full-text search in MySQL implements vector space model 0
set GLOBAL ft_boolean_syntax='- +><()~*:""&|';
select *, MATCH(a,b) AGAINST("+called +collections" IN BOOLEAN MODE) as x from t1;
a b x
MySQL has now support for full-text search 0
Full-text indexes are called collections 0
Only MyISAM tables support collections 0
Function MATCH ... AGAINST() is used to do a search 0
Full-text search in MySQL implements vector space model 0
create function change_global() returns integer deterministic
begin
set global ft_boolean_syntax='+ -><()~*:""&|';
return 1;
end|
select *, change_global() from t1;
a b change_global()
MySQL has now support for full-text search 1
Full-text indexes are called collections 1
Only MyISAM tables support collections 1
Function MATCH ... AGAINST() is used to do a search 1
Full-text search in MySQL implements vector space model 1
drop function change_global;
set GLOBAL query_cache_type=default;
set GLOBAL query_cache_limit=default;
set GLOBAL query_cache_min_res_unit=default;
set GLOBAL query_cache_size= default;
...@@ -928,3 +928,75 @@ select * from t1; ...@@ -928,3 +928,75 @@ select * from t1;
drop table t1; drop table t1;
set global query_cache_size=0; set global query_cache_size=0;
#
# Query cache and changes to system variables
#
create table t1 (a int);
insert into t1 values (1),(2),(3);
set GLOBAL query_cache_type=1;
set GLOBAL query_cache_limit=10000;
set GLOBAL query_cache_min_res_unit=0;
set GLOBAL query_cache_size= 100000;
# default_week_format
reset query cache;
set LOCAL default_week_format = 0;
select week('2007-01-04');
select week('2007-01-04') from t1;
select extract(WEEK FROM '2007-01-04') from t1;
set LOCAL default_week_format = 2;
select week('2007-01-04');
select week('2007-01-04') from t1;
select extract(WEEK FROM '2007-01-04') from t1;
# div_precision_increment
reset query cache;
set LOCAL div_precision_increment=2;
select 1/7;
select 1/7 from t1;
set LOCAL div_precision_increment=4;
select 1/7;
select 1/7 from t1;
drop table t1;
CREATE TABLE t1 (a VARCHAR(200), b TEXT, FULLTEXT (a,b));
INSERT INTO t1 VALUES('MySQL has now support', 'for full-text search'),
('Full-text indexes', 'are called collections'),
('Only MyISAM tables','support collections'),
('Function MATCH ... AGAINST()','is used to do a search'),
('Full-text search in MySQL', 'implements vector space model');
set GLOBAL ft_boolean_syntax='+ -><()~*:""&|';
select *, MATCH(a,b) AGAINST("+called +collections" IN BOOLEAN MODE) as x from t1;
# swap +/-
set GLOBAL ft_boolean_syntax='- +><()~*:""&|';
select *, MATCH(a,b) AGAINST("+called +collections" IN BOOLEAN MODE) as x from t1;
# If in the future we need to cache queries with functions
# be sure not to cause dead lock if the query cache is flushed
# while inserting a query in the query cache.
delimiter |;
create function change_global() returns integer deterministic
begin
set global ft_boolean_syntax='+ -><()~*:""&|';
return 1;
end|
delimiter ;|
select *, change_global() from t1;
drop function change_global;
set GLOBAL query_cache_type=default;
set GLOBAL query_cache_limit=default;
set GLOBAL query_cache_min_res_unit=default;
set GLOBAL query_cache_size= default;
# End of 5.0 tests
...@@ -657,6 +657,8 @@ struct Query_cache_query_flags ...@@ -657,6 +657,8 @@ struct Query_cache_query_flags
ulong sql_mode; ulong sql_mode;
ulong max_sort_length; ulong max_sort_length;
ulong group_concat_max_len; ulong group_concat_max_len;
ulong default_week_format;
ulong div_precision_increment;
MY_LOCALE *lc_time_names; MY_LOCALE *lc_time_names;
}; };
#define QUERY_CACHE_FLAGS_SIZE sizeof(Query_cache_query_flags) #define QUERY_CACHE_FLAGS_SIZE sizeof(Query_cache_query_flags)
......
...@@ -1150,6 +1150,11 @@ static bool sys_update_ftb_syntax(THD *thd, set_var * var) ...@@ -1150,6 +1150,11 @@ static bool sys_update_ftb_syntax(THD *thd, set_var * var)
{ {
strmake(ft_boolean_syntax, var->value->str_value.c_ptr(), strmake(ft_boolean_syntax, var->value->str_value.c_ptr(),
sizeof(ft_boolean_syntax)-1); sizeof(ft_boolean_syntax)-1);
#ifdef HAVE_QUERY_CACHE
query_cache.flush();
#endif /* HAVE_QUERY_CACHE */
return 0; return 0;
} }
......
...@@ -867,11 +867,13 @@ void Query_cache::store_query(THD *thd, TABLE_LIST *tables_used) ...@@ -867,11 +867,13 @@ void Query_cache::store_query(THD *thd, TABLE_LIST *tables_used)
flags.max_sort_length= thd->variables.max_sort_length; flags.max_sort_length= thd->variables.max_sort_length;
flags.lc_time_names= thd->variables.lc_time_names; flags.lc_time_names= thd->variables.lc_time_names;
flags.group_concat_max_len= thd->variables.group_concat_max_len; flags.group_concat_max_len= thd->variables.group_concat_max_len;
flags.div_precision_increment= thd->variables.div_precincrement;
flags.default_week_format= thd->variables.default_week_format;
DBUG_PRINT("qcache", ("\ DBUG_PRINT("qcache", ("\
long %d, 4.1: %d, bin_proto: %d, more results %d, pkt_nr: %d, \ long %d, 4.1: %d, bin_proto: %d, more results %d, pkt_nr: %d, \
CS client: %u, CS result: %u, CS conn: %u, limit: %lu, TZ: 0x%lx, \ CS client: %u, CS result: %u, CS conn: %u, limit: %lu, TZ: 0x%lx, \
sql mode: 0x%lx, sort len: %lu, conncat len: %lu", sql mode: 0x%lx, sort len: %lu, conncat len: %lu, div_precision: %lu, \
(int)flags.client_long_flag, def_week_frmt: %lu",
(int)flags.client_protocol_41, (int)flags.client_protocol_41,
(int)flags.result_in_binary_protocol, (int)flags.result_in_binary_protocol,
(int)flags.more_results_exists, (int)flags.more_results_exists,
...@@ -883,7 +885,9 @@ sql mode: 0x%lx, sort len: %lu, conncat len: %lu", ...@@ -883,7 +885,9 @@ sql mode: 0x%lx, sort len: %lu, conncat len: %lu",
(ulong) flags.time_zone, (ulong) flags.time_zone,
flags.sql_mode, flags.sql_mode,
flags.max_sort_length, flags.max_sort_length,
flags.group_concat_max_len)); flags.group_concat_max_len,
flags.div_precision_increment,
flags.default_week_format));
/* /*
Make InnoDB to release the adaptive hash index latch before Make InnoDB to release the adaptive hash index latch before
acquiring the query cache mutex. acquiring the query cache mutex.
...@@ -1112,11 +1116,14 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length) ...@@ -1112,11 +1116,14 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
flags.sql_mode= thd->variables.sql_mode; flags.sql_mode= thd->variables.sql_mode;
flags.max_sort_length= thd->variables.max_sort_length; flags.max_sort_length= thd->variables.max_sort_length;
flags.group_concat_max_len= thd->variables.group_concat_max_len; flags.group_concat_max_len= thd->variables.group_concat_max_len;
flags.div_precision_increment= thd->variables.div_precincrement;
flags.default_week_format= thd->variables.default_week_format;
flags.lc_time_names= thd->variables.lc_time_names; flags.lc_time_names= thd->variables.lc_time_names;
DBUG_PRINT("qcache", ("\ DBUG_PRINT("qcache", ("\
long %d, 4.1: %d, bin_proto: %d, more results %d, pkt_nr: %d, \ long %d, 4.1: %d, bin_proto: %d, more results %d, pkt_nr: %d, \
CS client: %u, CS result: %u, CS conn: %u, limit: %lu, TZ: 0x%lx, \ CS client: %u, CS result: %u, CS conn: %u, limit: %lu, TZ: 0x%lx, \
sql mode: 0x%lx, sort len: %lu, conncat len: %lu", sql mode: 0x%lx, sort len: %lu, conncat len: %lu, div_precision: %lu, \
def_week_frmt: %lu",
(int)flags.client_long_flag, (int)flags.client_long_flag,
(int)flags.client_protocol_41, (int)flags.client_protocol_41,
(int)flags.result_in_binary_protocol, (int)flags.result_in_binary_protocol,
...@@ -1129,7 +1136,9 @@ sql mode: 0x%lx, sort len: %lu, conncat len: %lu", ...@@ -1129,7 +1136,9 @@ sql mode: 0x%lx, sort len: %lu, conncat len: %lu",
(ulong) flags.time_zone, (ulong) flags.time_zone,
flags.sql_mode, flags.sql_mode,
flags.max_sort_length, flags.max_sort_length,
flags.group_concat_max_len)); flags.group_concat_max_len,
flags.div_precision_increment,
flags.default_week_format));
memcpy((void *)(sql + (tot_length - QUERY_CACHE_FLAGS_SIZE)), memcpy((void *)(sql + (tot_length - QUERY_CACHE_FLAGS_SIZE)),
&flags, QUERY_CACHE_FLAGS_SIZE); &flags, QUERY_CACHE_FLAGS_SIZE);
query_block = (Query_cache_block *) hash_search(&queries, (byte*) sql, query_block = (Query_cache_block *) hash_search(&queries, (byte*) sql,
......
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