From 71be65dd114d0a2bd914bcdb1879015fd76ba2b4 Mon Sep 17 00:00:00 2001 From: Kristofer Pettersson Date: Thu, 19 Jun 2008 02:40:35 +0200 Subject: [PATCH 1/6] Bug#30087 Set query_cache_size, if the value is too small, get a unclear warning This bugs clarifies a warning message issued when the query cache data size becomes smaller than the minium allowed size. --- mysql-test/r/query_cache.result | 8 ++++---- sql/set_var.cc | 7 +------ sql/share/errmsg.txt | 14 +++++++------- sql/sql_cache.cc | 29 +++++++++++++++++++++++++++++ sql/sql_cache.h | 2 ++ 5 files changed, 43 insertions(+), 17 deletions(-) diff --git a/mysql-test/r/query_cache.result b/mysql-test/r/query_cache.result index fa80a44c177..c40e75fc29b 100644 --- a/mysql-test/r/query_cache.result +++ b/mysql-test/r/query_cache.result @@ -564,7 +564,7 @@ select * from t1; a set GLOBAL query_cache_size=1024; Warnings: -Warning 1282 Query cache failed to set size 1024; new query cache size is 0 +Warning 1282 Query cache failed to set size 1024 (minimal value: 41297); new query cache size is 0 show global variables like "query_cache_size"; Variable_name Value query_cache_size 0 @@ -572,7 +572,7 @@ select * from t1; a set GLOBAL query_cache_size=10240; Warnings: -Warning 1282 Query cache failed to set size 10240; new query cache size is 0 +Warning 1282 Query cache failed to set size 10240 (minimal value: 41297); new query cache size is 0 show global variables like "query_cache_size"; Variable_name Value query_cache_size 0 @@ -580,7 +580,7 @@ select * from t1; a set GLOBAL query_cache_size=20480; Warnings: -Warning 1282 Query cache failed to set size 20480; new query cache size is 0 +Warning 1282 Query cache failed to set size 20480 (minimal value: 41297); new query cache size is 0 show global variables like "query_cache_size"; Variable_name Value query_cache_size 0 @@ -588,7 +588,7 @@ select * from t1; a set GLOBAL query_cache_size=40960; Warnings: -Warning 1282 Query cache failed to set size 40960; new query cache size is 0 +Warning 1282 Query cache failed to set size 40960 (minimal value: 41297); new query cache size is 0 show global variables like "query_cache_size"; Variable_name Value query_cache_size 0 diff --git a/sql/set_var.cc b/sql/set_var.cc index 84766e511ca..fd9beff35b7 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -1342,12 +1342,7 @@ static void fix_net_retry_count(THD *thd __attribute__((unused)), static void fix_query_cache_size(THD *thd, enum_var_type type) { #ifdef HAVE_QUERY_CACHE - ulong requested= query_cache_size; - query_cache.resize(query_cache_size); - if (requested != query_cache_size) - push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, - ER_WARN_QC_RESIZE, ER(ER_WARN_QC_RESIZE), - requested, query_cache_size); + query_cache_size= query_cache.resize(query_cache_size); #endif } diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt index 7d345d633c6..0cb6672732c 100644 --- a/sql/share/errmsg.txt +++ b/sql/share/errmsg.txt @@ -4992,13 +4992,13 @@ ER_WRONG_NAME_FOR_CATALOG 42000 spa "Nombre de catalog incorrecto '%-.100s'" swe "Felaktigt katalog namn '%-.100s'" ER_WARN_QC_RESIZE - eng "Query cache failed to set size %lu; new query cache size is %lu" - ger "Änderung der Query-Cache-Größe auf %lu fehlgeschlagen; neue Query-Cache-Größe ist %lu" - por "Falha em Query cache para configurar tamanho %lu, novo tamanho de query cache é %lu" - rus "ëÅÛ ÚÁÐÒÏÓÏ× ÎÅ ÍÏÖÅÔ ÕÓÔÁÎÏ×ÉÔØ ÒÁÚÍÅÒ %lu, ÎÏ×ÙÊ ÒÁÚÍÅÒ ËÅÛÁ ÚÐÒÏÓÏ× - %lu" - spa "Query cache fallada para configurar tamaño %lu, nuevo tamaño de query cache es %lu" - swe "Storleken av "Query cache" kunde inte sättas till %lu, ny storlek är %lu" - ukr "ëÅÛ ÚÁÐÉÔ¦× ÎÅÓÐÒÏÍÏÖÅÎ ×ÓÔÁÎÏ×ÉÔÉ ÒÏÚÍ¦Ò %lu, ÎÏ×ÉÊ ÒÏÚÍ¦Ò ËÅÛÁ ÚÁÐÉÔ¦× - %lu" + eng "Query cache failed to set size %lu (minimal value: %lu); new query cache size is %lu" + ger "Änderung der Query-Cache-Größe auf %lu (Minimale Zahl: %lu) fehlgeschlagen; neue Query-Cache-Größe ist %lu" + por "Falha em Query cache para configurar tamanho %lu (Número mínimo: %lu), novo tamanho de query cache é %lu" + rus "ëÅÛ ÚÁÐÒÏÓÏ× ÎÅ ÍÏÖÅÔ ÕÓÔÁÎÏ×ÉÔØ ÒÁÚÍÅÒ %lu (minimal value: %lu), ÎÏ×ÙÊ ÒÁÚÍÅÒ ËÅÛÁ ÚÐÒÏÓÏ× - %lu" + spa "Query cache fallada para configurar tamaño %lu (Número mínimo: %lu), nuevo tamaño de query cache es %lu" + swe "Storleken av "Query cache" kunde inte sättas till %lu (minsta värde: %lu); ny storlek är %lu" + ukr "ëÅÛ ÚÁÐÉÔ¦× ÎÅÓÐÒÏÍÏÖÅÎ ×ÓÔÁÎÏ×ÉÔÉ ÒÏÚÍ¦Ò %lu (minimal value: %lu), ÎÏ×ÉÊ ÒÏÚÍ¦Ò ËÅÛÁ ÚÁÐÉÔ¦× - %lu" ER_BAD_FT_COLUMN eng "Column '%-.64s' cannot be part of FULLTEXT index" ger "Feld '%-.64s' kann nicht Teil eines FULLTEXT-Index sein" diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index f8906a17c12..cce5123aef3 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -816,6 +816,16 @@ ulong Query_cache::resize(ulong query_cache_size_arg) free_cache(); query_cache_size= query_cache_size_arg; ::query_cache_size= init_cache(); + + if (::query_cache_size != query_cache_size_arg) + { + push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_WARN_QC_RESIZE, ER(ER_WARN_QC_RESIZE), + query_cache_size_arg, + get_minimal_size_limit(), + ::query_cache_size); + } + STRUCT_UNLOCK(&structure_guard_mutex); DBUG_RETURN(::query_cache_size); } @@ -1614,6 +1624,25 @@ void Query_cache::init() } +/** + Return the lowest possible query cache size. +*/ + +ulong Query_cache::get_minimal_size_limit() +{ + ulong approx_additional_data_size= (sizeof(Query_cache) + + sizeof(gptr)*(def_query_hash_size+ + def_table_hash_size)); + + ulong data_size= (min_allocation_unit << QUERY_CACHE_MEM_BIN_STEP_PWR2 << + QUERY_CACHE_MEM_BIN_FIRST_STEP_PWR2) + + ALIGN_SIZE(1) - 1 + + (1 << QUERY_CACHE_MEM_BIN_STEP_PWR2) - 1 + + (1 << QUERY_CACHE_MEM_BIN_FIRST_STEP_PWR2) - 1; + + return(data_size + approx_additional_data_size); +} + ulong Query_cache::init_cache() { uint mem_bin_count, num, step; diff --git a/sql/sql_cache.h b/sql/sql_cache.h index 34fc3a5c8d5..c5d89780af3 100644 --- a/sql/sql_cache.h +++ b/sql/sql_cache.h @@ -245,6 +245,8 @@ private: void free_query_internal(Query_cache_block *point); + ulong get_minimal_size_limit(); + protected: /* The following mutex is locked when searching or changing global From 2f207e4a34b2ee851888304387faca13b5578d32 Mon Sep 17 00:00:00 2001 From: Gleb Shchepa Date: Tue, 15 Jul 2008 17:12:08 +0500 Subject: [PATCH 2/6] after-push patch: partial rollback of bug #37761 fix. Note: item->null_value is not updated before a call to item->store(), item->is_null() is not too (in common case). --- sql/item_cmpfunc.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 2db77eb7c56..28e55eef5bd 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -3758,8 +3758,6 @@ longlong Item_func_in::val_int() return (longlong) (!null_value && tmp != negated); } - if ((null_value= args[0]->null_value)) - return 0; have_null= 0; for (uint i= 1 ; i < arg_count ; i++) { @@ -3769,6 +3767,8 @@ longlong Item_func_in::val_int() if (!(value_added_map & (1 << (uint)cmp_type))) { in_item->store_value(args[0]); + if ((null_value= args[0]->null_value)) + return 0; value_added_map|= 1 << (uint)cmp_type; } if (!in_item->cmp(args[i]) && !args[i]->null_value) From b8579849f32f149cfc7885d06a1272bd832b6389 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Wed, 16 Jul 2008 16:29:22 -0600 Subject: [PATCH 3/6] Bug#30087 Set query_cache_size, if the value is too small, get a unclear warning Reverting the previous patch --- mysql-test/r/query_cache.result | 8 ++++---- sql/set_var.cc | 7 ++++++- sql/share/errmsg.txt | 14 +++++++------- sql/sql_cache.cc | 29 ----------------------------- sql/sql_cache.h | 2 -- 5 files changed, 17 insertions(+), 43 deletions(-) diff --git a/mysql-test/r/query_cache.result b/mysql-test/r/query_cache.result index c40e75fc29b..fa80a44c177 100644 --- a/mysql-test/r/query_cache.result +++ b/mysql-test/r/query_cache.result @@ -564,7 +564,7 @@ select * from t1; a set GLOBAL query_cache_size=1024; Warnings: -Warning 1282 Query cache failed to set size 1024 (minimal value: 41297); new query cache size is 0 +Warning 1282 Query cache failed to set size 1024; new query cache size is 0 show global variables like "query_cache_size"; Variable_name Value query_cache_size 0 @@ -572,7 +572,7 @@ select * from t1; a set GLOBAL query_cache_size=10240; Warnings: -Warning 1282 Query cache failed to set size 10240 (minimal value: 41297); new query cache size is 0 +Warning 1282 Query cache failed to set size 10240; new query cache size is 0 show global variables like "query_cache_size"; Variable_name Value query_cache_size 0 @@ -580,7 +580,7 @@ select * from t1; a set GLOBAL query_cache_size=20480; Warnings: -Warning 1282 Query cache failed to set size 20480 (minimal value: 41297); new query cache size is 0 +Warning 1282 Query cache failed to set size 20480; new query cache size is 0 show global variables like "query_cache_size"; Variable_name Value query_cache_size 0 @@ -588,7 +588,7 @@ select * from t1; a set GLOBAL query_cache_size=40960; Warnings: -Warning 1282 Query cache failed to set size 40960 (minimal value: 41297); new query cache size is 0 +Warning 1282 Query cache failed to set size 40960; new query cache size is 0 show global variables like "query_cache_size"; Variable_name Value query_cache_size 0 diff --git a/sql/set_var.cc b/sql/set_var.cc index fd9beff35b7..84766e511ca 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -1342,7 +1342,12 @@ static void fix_net_retry_count(THD *thd __attribute__((unused)), static void fix_query_cache_size(THD *thd, enum_var_type type) { #ifdef HAVE_QUERY_CACHE - query_cache_size= query_cache.resize(query_cache_size); + ulong requested= query_cache_size; + query_cache.resize(query_cache_size); + if (requested != query_cache_size) + push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_WARN_QC_RESIZE, ER(ER_WARN_QC_RESIZE), + requested, query_cache_size); #endif } diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt index 0cb6672732c..7d345d633c6 100644 --- a/sql/share/errmsg.txt +++ b/sql/share/errmsg.txt @@ -4992,13 +4992,13 @@ ER_WRONG_NAME_FOR_CATALOG 42000 spa "Nombre de catalog incorrecto '%-.100s'" swe "Felaktigt katalog namn '%-.100s'" ER_WARN_QC_RESIZE - eng "Query cache failed to set size %lu (minimal value: %lu); new query cache size is %lu" - ger "Änderung der Query-Cache-Größe auf %lu (Minimale Zahl: %lu) fehlgeschlagen; neue Query-Cache-Größe ist %lu" - por "Falha em Query cache para configurar tamanho %lu (Número mínimo: %lu), novo tamanho de query cache é %lu" - rus "ëÅÛ ÚÁÐÒÏÓÏ× ÎÅ ÍÏÖÅÔ ÕÓÔÁÎÏ×ÉÔØ ÒÁÚÍÅÒ %lu (minimal value: %lu), ÎÏ×ÙÊ ÒÁÚÍÅÒ ËÅÛÁ ÚÐÒÏÓÏ× - %lu" - spa "Query cache fallada para configurar tamaño %lu (Número mínimo: %lu), nuevo tamaño de query cache es %lu" - swe "Storleken av "Query cache" kunde inte sättas till %lu (minsta värde: %lu); ny storlek är %lu" - ukr "ëÅÛ ÚÁÐÉÔ¦× ÎÅÓÐÒÏÍÏÖÅÎ ×ÓÔÁÎÏ×ÉÔÉ ÒÏÚÍ¦Ò %lu (minimal value: %lu), ÎÏ×ÉÊ ÒÏÚÍ¦Ò ËÅÛÁ ÚÁÐÉÔ¦× - %lu" + eng "Query cache failed to set size %lu; new query cache size is %lu" + ger "Änderung der Query-Cache-Größe auf %lu fehlgeschlagen; neue Query-Cache-Größe ist %lu" + por "Falha em Query cache para configurar tamanho %lu, novo tamanho de query cache é %lu" + rus "ëÅÛ ÚÁÐÒÏÓÏ× ÎÅ ÍÏÖÅÔ ÕÓÔÁÎÏ×ÉÔØ ÒÁÚÍÅÒ %lu, ÎÏ×ÙÊ ÒÁÚÍÅÒ ËÅÛÁ ÚÐÒÏÓÏ× - %lu" + spa "Query cache fallada para configurar tamaño %lu, nuevo tamaño de query cache es %lu" + swe "Storleken av "Query cache" kunde inte sättas till %lu, ny storlek är %lu" + ukr "ëÅÛ ÚÁÐÉÔ¦× ÎÅÓÐÒÏÍÏÖÅÎ ×ÓÔÁÎÏ×ÉÔÉ ÒÏÚÍ¦Ò %lu, ÎÏ×ÉÊ ÒÏÚÍ¦Ò ËÅÛÁ ÚÁÐÉÔ¦× - %lu" ER_BAD_FT_COLUMN eng "Column '%-.64s' cannot be part of FULLTEXT index" ger "Feld '%-.64s' kann nicht Teil eines FULLTEXT-Index sein" diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index cce5123aef3..f8906a17c12 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -816,16 +816,6 @@ ulong Query_cache::resize(ulong query_cache_size_arg) free_cache(); query_cache_size= query_cache_size_arg; ::query_cache_size= init_cache(); - - if (::query_cache_size != query_cache_size_arg) - { - push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, - ER_WARN_QC_RESIZE, ER(ER_WARN_QC_RESIZE), - query_cache_size_arg, - get_minimal_size_limit(), - ::query_cache_size); - } - STRUCT_UNLOCK(&structure_guard_mutex); DBUG_RETURN(::query_cache_size); } @@ -1624,25 +1614,6 @@ void Query_cache::init() } -/** - Return the lowest possible query cache size. -*/ - -ulong Query_cache::get_minimal_size_limit() -{ - ulong approx_additional_data_size= (sizeof(Query_cache) + - sizeof(gptr)*(def_query_hash_size+ - def_table_hash_size)); - - ulong data_size= (min_allocation_unit << QUERY_CACHE_MEM_BIN_STEP_PWR2 << - QUERY_CACHE_MEM_BIN_FIRST_STEP_PWR2) + - ALIGN_SIZE(1) - 1 + - (1 << QUERY_CACHE_MEM_BIN_STEP_PWR2) - 1 + - (1 << QUERY_CACHE_MEM_BIN_FIRST_STEP_PWR2) - 1; - - return(data_size + approx_additional_data_size); -} - ulong Query_cache::init_cache() { uint mem_bin_count, num, step; diff --git a/sql/sql_cache.h b/sql/sql_cache.h index c5d89780af3..34fc3a5c8d5 100644 --- a/sql/sql_cache.h +++ b/sql/sql_cache.h @@ -245,8 +245,6 @@ private: void free_query_internal(Query_cache_block *point); - ulong get_minimal_size_limit(); - protected: /* The following mutex is locked when searching or changing global From c3c4c6b54cd2b22f222325f9969672f0b49411b9 Mon Sep 17 00:00:00 2001 From: Horst Hunger Date: Thu, 17 Jul 2008 11:03:17 +0200 Subject: [PATCH 5/6] Fix for bug#38164. Removed test of values larger than max int for 32 bits. --- .../include/query_prealloc_size_basic.inc | 118 ++++++++++-------- .../r/query_prealloc_size_basic_32.result | 32 ++--- .../r/query_prealloc_size_basic_64.result | 30 ++--- 3 files changed, 81 insertions(+), 99 deletions(-) diff --git a/mysql-test/include/query_prealloc_size_basic.inc b/mysql-test/include/query_prealloc_size_basic.inc index 1793d1874af..ac005b696fa 100644 --- a/mysql-test/include/query_prealloc_size_basic.inc +++ b/mysql-test/include/query_prealloc_size_basic.inc @@ -1,32 +1,35 @@ -############## mysql-test\t\query_prealloc_size_basic.test ############### -# # -# Variable Name: query_prealloc_size # -# Scope: GLOBAL | SESSION # -# Access Type: Dynamic # -# Data Type: numeric # -# Default Value: 8192 # -# Range: 8192-4294967295 # -# # -# # -# Creation Date: 2008-02-07 # -# Author: Rizwan # -# # -# Description: Test Cases of Dynamic System Variable query_prealloc_size # -# that checks the behavior of this variable in the following ways# -# * Default Value # -# * Valid & Invalid values # -# * Scope & Access method # -# * Data Integrity # -# # -# Reference: http://dev.mysql.com/doc/refman/5.1/en/ # -# server-system-variables.html # -# # -############################################################################### +################# mysql-test\t\query_prealloc_size_basic.test ################## +# # +# Variable Name: query_prealloc_size # +# Scope: GLOBAL | SESSION # +# Access Type: Dynamic # +# Data Type: numeric # +# Default Value: 8192 # +# Range: 8192-4294967295 # +# # +# # +# Creation Date: 2008-02-07 # +# Author: Rizwan # +# # +# Description: Test Cases of Dynamic System Variable query_prealloc_size # +# that checks the behavior of this variable in the following ways # +# * Default Value # +# * Valid & Invalid values # +# * Scope & Access method # +# * Data Integrity # +# # +# Reference: # +# http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html # +# # +# Last Modification: # +# 2008-07-14 hhunger removed values for 64 bit platforms. # +# # +################################################################################ --source include/load_sysvars.inc ######################################################################## -# START OF query_prealloc_size TESTS # +# START OF query_prealloc_size TESTS # ######################################################################## @@ -42,7 +45,7 @@ SELECT @start_session_value; --echo '#--------------------FN_DYNVARS_005_01-------------------------#' ######################################################################## -# Display the DEFAULT value of myisam_block_size # +# Display the DEFAULT value of myisam_block_size # ######################################################################## SET @@global.query_prealloc_size = 100; @@ -56,7 +59,7 @@ SELECT @@session.query_prealloc_size ; --echo '#--------------------FN_DYNVARS_005_02-------------------------#' ######################################################################## -# Check the DEFAULT value of query_prealloc_size # +# Check the DEFAULT value of query_prealloc_size # ######################################################################## SET @@global.query_prealloc_size = DEFAULT; @@ -67,30 +70,32 @@ SELECT @@session.query_prealloc_size = 8192; --echo '#--------------------FN_DYNVARS_005_03-------------------------#' -################################################################################## -# Change the value of query_prealloc_size to a valid value for GLOBAL Scope # -################################################################################## +################################################################################ +# Change the value of query_prealloc_size to a valid value for GLOBAL Scope # +################################################################################ SET @@global.query_prealloc_size = 8192; SELECT @@global.query_prealloc_size ; -SET @@global.query_prealloc_size = 4294967295; -SELECT @@global.query_prealloc_size ; +# Due to problems with 64 bit machines having less than 6 GB main memory. +#SET @@global.query_prealloc_size = 4294967295; +#SELECT @@global.query_prealloc_size ; SET @@global.query_prealloc_size = 655354; SELECT @@global.query_prealloc_size ; --echo '#--------------------FN_DYNVARS_005_04-------------------------#' -################################################################################### -# Change the value of query_prealloc_size to a valid value for SESSION Scope # -################################################################################### - +################################################################################## +# Change the value of query_prealloc_size to a valid value for SESSION Scope # +################################################################################## + SET @@session.query_prealloc_size = 8192; SELECT @@session.query_prealloc_size ; -SET @@session.query_prealloc_size = 4294967295; -SELECT @@session.query_prealloc_size ; +# Due to problems with 64 bit machines having less than 6 GB main memory. +#SET @@session.query_prealloc_size = 4294967295; +#SELECT @@session.query_prealloc_size ; SET @@session.query_prealloc_size = 655345; SELECT @@session.query_prealloc_size ; @@ -100,7 +105,7 @@ SELECT @@session.query_prealloc_size ; --echo '#------------------FN_DYNVARS_005_05-----------------------#' #################################################################### -# Change the value of query_prealloc_size to an invalid value # +# Change the value of query_prealloc_size to an invalid value # #################################################################### SET @@global.query_prealloc_size = 0; @@ -109,8 +114,9 @@ SELECT @@global.query_prealloc_size ; SET @@global.query_prealloc_size = -1024; SELECT @@global.query_prealloc_size ; -SET @@global.query_prealloc_size = 429496729533; -SELECT @@global.query_prealloc_size ; +# Due to problems with 64 bit machines having less than 6 GB main memory. +#SET @@global.query_prealloc_size = 429496729533; +#SELECT @@global.query_prealloc_size ; --Error ER_PARSE_ERROR @@ -161,8 +167,8 @@ SELECT @@session.query_prealloc_size ; #################################################################### -SELECT @@global.query_prealloc_size = VARIABLE_VALUE -FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES +SELECT @@global.query_prealloc_size = VARIABLE_VALUE +FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='query_prealloc_size '; --echo '#------------------FN_DYNVARS_005_07-----------------------#' @@ -170,8 +176,8 @@ WHERE VARIABLE_NAME='query_prealloc_size '; # Check if the value in SESSION Table matches value in variable # #################################################################### -SELECT @@session.query_prealloc_size = VARIABLE_VALUE -FROM INFORMATION_SCHEMA.SESSION_VARIABLES +SELECT @@session.query_prealloc_size = VARIABLE_VALUE +FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME='query_prealloc_size '; @@ -188,18 +194,19 @@ SELECT @@global.query_prealloc_size ; --echo '#---------------------FN_DYNVARS_001_09----------------------#' -#################################################################################### -# Check if accessing variable with and without GLOBAL point to same variable # -#################################################################################### +################################################################################ +# Check if accessing variable with and without GLOBAL point to same variable # +################################################################################ SET @@global.query_prealloc_size = 10; SELECT @@query_prealloc_size = @@global.query_prealloc_size ; --echo '#---------------------FN_DYNVARS_001_10----------------------#' -######################################################################################################## -# Check if accessing variable with SESSION,LOCAL and without SCOPE points to same session variable # -######################################################################################################## +############################################################################## +# Check if accessing variable with SESSION,LOCAL and without SCOPE points to # +# to the same session variable # +############################################################################## SET @@query_prealloc_size = 100; SELECT @@query_prealloc_size = @@local.query_prealloc_size ; @@ -207,9 +214,9 @@ SELECT @@local.query_prealloc_size = @@session.query_prealloc_size ; --echo '#---------------------FN_DYNVARS_001_11----------------------#' -################################################################################### -# Check if query_prealloc_size can be accessed with and without @@ sign # -################################################################################### +################################################################################ +# Check if query_prealloc_size can be accessed with and without @@ sign # +################################################################################ SET query_prealloc_size = 1; SELECT @@query_prealloc_size ; @@ -235,5 +242,6 @@ SELECT @@session.query_prealloc_size ; ############################################################# -# END OF query_prealloc_size TESTS # +# END OF query_prealloc_size TESTS # ############################################################# + diff --git a/mysql-test/r/query_prealloc_size_basic_32.result b/mysql-test/r/query_prealloc_size_basic_32.result index 176e4fb810a..fe8aba990a7 100644 --- a/mysql-test/r/query_prealloc_size_basic_32.result +++ b/mysql-test/r/query_prealloc_size_basic_32.result @@ -35,10 +35,6 @@ SET @@global.query_prealloc_size = 8192; SELECT @@global.query_prealloc_size ; @@global.query_prealloc_size 8192 -SET @@global.query_prealloc_size = 4294967295; -SELECT @@global.query_prealloc_size ; -@@global.query_prealloc_size -4294966272 SET @@global.query_prealloc_size = 655354; SELECT @@global.query_prealloc_size ; @@global.query_prealloc_size @@ -48,10 +44,6 @@ SET @@session.query_prealloc_size = 8192; SELECT @@session.query_prealloc_size ; @@session.query_prealloc_size 8192 -SET @@session.query_prealloc_size = 4294967295; -SELECT @@session.query_prealloc_size ; -@@session.query_prealloc_size -4294966272 SET @@session.query_prealloc_size = 655345; SELECT @@session.query_prealloc_size ; @@session.query_prealloc_size @@ -69,37 +61,31 @@ Warning 1292 Truncated incorrect query_prealloc_size value: '0' SELECT @@global.query_prealloc_size ; @@global.query_prealloc_size 8192 -SET @@global.query_prealloc_size = 429496729533; -Warnings: -Warning 1292 Truncated incorrect query_prealloc_size value: '429496729533' -SELECT @@global.query_prealloc_size ; -@@global.query_prealloc_size -4294966272 SET @@global.query_prealloc_size = 65530.34.; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.' at line 1 SELECT @@global.query_prealloc_size ; @@global.query_prealloc_size -4294966272 +8192 SET @@global.query_prealloc_size = test; ERROR 42000: Incorrect argument type to variable 'query_prealloc_size' SELECT @@global.query_prealloc_size ; @@global.query_prealloc_size -4294966272 +8192 SET @@global.query_prealloc_size = "test"; ERROR 42000: Incorrect argument type to variable 'query_prealloc_size' SELECT @@global.query_prealloc_size ; @@global.query_prealloc_size -4294966272 +8192 SET @@global.query_prealloc_size = 'test'; ERROR 42000: Incorrect argument type to variable 'query_prealloc_size' SELECT @@global.query_prealloc_size ; @@global.query_prealloc_size -4294966272 +8192 SET @@global.query_prealloc_size = ON; ERROR 42000: Incorrect argument type to variable 'query_prealloc_size' SELECT @@global.query_prealloc_size ; @@global.query_prealloc_size -4294966272 +8192 SET @@session.query_prealloc_size = 0; Warnings: Warning 1292 Truncated incorrect query_prealloc_size value: '0' @@ -128,14 +114,14 @@ SELECT @@session.query_prealloc_size ; @@session.query_prealloc_size 8192 '#------------------FN_DYNVARS_005_06-----------------------#' -SELECT @@global.query_prealloc_size = VARIABLE_VALUE -FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES +SELECT @@global.query_prealloc_size = VARIABLE_VALUE +FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='query_prealloc_size '; @@global.query_prealloc_size = VARIABLE_VALUE 1 '#------------------FN_DYNVARS_005_07-----------------------#' -SELECT @@session.query_prealloc_size = VARIABLE_VALUE -FROM INFORMATION_SCHEMA.SESSION_VARIABLES +SELECT @@session.query_prealloc_size = VARIABLE_VALUE +FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME='query_prealloc_size '; @@session.query_prealloc_size = VARIABLE_VALUE 1 diff --git a/mysql-test/r/query_prealloc_size_basic_64.result b/mysql-test/r/query_prealloc_size_basic_64.result index 1c4f5885676..fe8aba990a7 100644 --- a/mysql-test/r/query_prealloc_size_basic_64.result +++ b/mysql-test/r/query_prealloc_size_basic_64.result @@ -35,10 +35,6 @@ SET @@global.query_prealloc_size = 8192; SELECT @@global.query_prealloc_size ; @@global.query_prealloc_size 8192 -SET @@global.query_prealloc_size = 4294967295; -SELECT @@global.query_prealloc_size ; -@@global.query_prealloc_size -4294966272 SET @@global.query_prealloc_size = 655354; SELECT @@global.query_prealloc_size ; @@global.query_prealloc_size @@ -48,10 +44,6 @@ SET @@session.query_prealloc_size = 8192; SELECT @@session.query_prealloc_size ; @@session.query_prealloc_size 8192 -SET @@session.query_prealloc_size = 4294967295; -SELECT @@session.query_prealloc_size ; -@@session.query_prealloc_size -4294966272 SET @@session.query_prealloc_size = 655345; SELECT @@session.query_prealloc_size ; @@session.query_prealloc_size @@ -69,35 +61,31 @@ Warning 1292 Truncated incorrect query_prealloc_size value: '0' SELECT @@global.query_prealloc_size ; @@global.query_prealloc_size 8192 -SET @@global.query_prealloc_size = 429496729533; -SELECT @@global.query_prealloc_size ; -@@global.query_prealloc_size -429496728576 SET @@global.query_prealloc_size = 65530.34.; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.' at line 1 SELECT @@global.query_prealloc_size ; @@global.query_prealloc_size -429496728576 +8192 SET @@global.query_prealloc_size = test; ERROR 42000: Incorrect argument type to variable 'query_prealloc_size' SELECT @@global.query_prealloc_size ; @@global.query_prealloc_size -429496728576 +8192 SET @@global.query_prealloc_size = "test"; ERROR 42000: Incorrect argument type to variable 'query_prealloc_size' SELECT @@global.query_prealloc_size ; @@global.query_prealloc_size -429496728576 +8192 SET @@global.query_prealloc_size = 'test'; ERROR 42000: Incorrect argument type to variable 'query_prealloc_size' SELECT @@global.query_prealloc_size ; @@global.query_prealloc_size -429496728576 +8192 SET @@global.query_prealloc_size = ON; ERROR 42000: Incorrect argument type to variable 'query_prealloc_size' SELECT @@global.query_prealloc_size ; @@global.query_prealloc_size -429496728576 +8192 SET @@session.query_prealloc_size = 0; Warnings: Warning 1292 Truncated incorrect query_prealloc_size value: '0' @@ -126,14 +114,14 @@ SELECT @@session.query_prealloc_size ; @@session.query_prealloc_size 8192 '#------------------FN_DYNVARS_005_06-----------------------#' -SELECT @@global.query_prealloc_size = VARIABLE_VALUE -FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES +SELECT @@global.query_prealloc_size = VARIABLE_VALUE +FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='query_prealloc_size '; @@global.query_prealloc_size = VARIABLE_VALUE 1 '#------------------FN_DYNVARS_005_07-----------------------#' -SELECT @@session.query_prealloc_size = VARIABLE_VALUE -FROM INFORMATION_SCHEMA.SESSION_VARIABLES +SELECT @@session.query_prealloc_size = VARIABLE_VALUE +FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME='query_prealloc_size '; @@session.query_prealloc_size = VARIABLE_VALUE 1 From e84c8815fa22f9f1542fc5e7f76e130a53fcdb1f Mon Sep 17 00:00:00 2001 From: Kristofer Pettersson Date: Thu, 17 Jul 2008 11:31:22 +0200 Subject: [PATCH 6/6] Reverting patch for bug30087 --- mysql-test/r/query_cache.result | 8 ++++---- sql/set_var.cc | 14 ++++++++++++- sql/share/errmsg.txt | 14 ++++++------- sql/sql_cache.cc | 35 +++++---------------------------- sql/sql_cache.h | 2 -- 5 files changed, 29 insertions(+), 44 deletions(-) diff --git a/mysql-test/r/query_cache.result b/mysql-test/r/query_cache.result index d44a9cd95b1..34c86d6c8c6 100644 --- a/mysql-test/r/query_cache.result +++ b/mysql-test/r/query_cache.result @@ -566,7 +566,7 @@ select * from t1; a set GLOBAL query_cache_size=1024; Warnings: -Warning 1282 Query cache failed to set size 1024 (minimal value: 41297); new query cache size is 0 +Warning 1282 Query cache failed to set size 1024; new query cache size is 0 show global variables like "query_cache_size"; Variable_name Value query_cache_size 0 @@ -574,7 +574,7 @@ select * from t1; a set GLOBAL query_cache_size=10240; Warnings: -Warning 1282 Query cache failed to set size 10240 (minimal value: 41297); new query cache size is 0 +Warning 1282 Query cache failed to set size 10240; new query cache size is 0 show global variables like "query_cache_size"; Variable_name Value query_cache_size 0 @@ -582,7 +582,7 @@ select * from t1; a set GLOBAL query_cache_size=20480; Warnings: -Warning 1282 Query cache failed to set size 20480 (minimal value: 41297); new query cache size is 0 +Warning 1282 Query cache failed to set size 20480; new query cache size is 0 show global variables like "query_cache_size"; Variable_name Value query_cache_size 0 @@ -590,7 +590,7 @@ select * from t1; a set GLOBAL query_cache_size=40960; Warnings: -Warning 1282 Query cache failed to set size 40960 (minimal value: 41297); new query cache size is 0 +Warning 1282 Query cache failed to set size 40960; new query cache size is 0 show global variables like "query_cache_size"; Variable_name Value query_cache_size 0 diff --git a/sql/set_var.cc b/sql/set_var.cc index 134a8564145..7d9d88f0281 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -1046,7 +1046,19 @@ static void fix_net_retry_count(THD *thd __attribute__((unused)), static void fix_query_cache_size(THD *thd, enum_var_type type) { #ifdef HAVE_QUERY_CACHE - query_cache_size= query_cache.resize(query_cache_size); + ulong new_cache_size= query_cache.resize(query_cache_size); + + /* + Note: query_cache_size is a global variable reflecting the + requested cache size. See also query_cache_size_arg + */ + + if (query_cache_size != new_cache_size) + push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_WARN_QC_RESIZE, ER(ER_WARN_QC_RESIZE), + query_cache_size, new_cache_size); + + query_cache_size= new_cache_size; #endif } diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt index 04fa1c57cd1..426290714eb 100644 --- a/sql/share/errmsg.txt +++ b/sql/share/errmsg.txt @@ -4995,13 +4995,13 @@ ER_WRONG_NAME_FOR_CATALOG 42000 spa "Nombre de catalog incorrecto '%-.100s'" swe "Felaktigt katalog namn '%-.100s'" ER_WARN_QC_RESIZE - eng "Query cache failed to set size %lu (minimal value: %lu); new query cache size is %lu" - ger "Änderung der Query-Cache-Größe auf %lu (Minimale Zahl: %lu) fehlgeschlagen; neue Query-Cache-Größe ist %lu" - por "Falha em Query cache para configurar tamanho %lu (Número mínimo: %lu), novo tamanho de query cache é %lu" - rus "ëÅÛ ÚÁÐÒÏÓÏ× ÎÅ ÍÏÖÅÔ ÕÓÔÁÎÏ×ÉÔØ ÒÁÚÍÅÒ %lu (minimal value: %lu), ÎÏ×ÙÊ ÒÁÚÍÅÒ ËÅÛÁ ÚÐÒÏÓÏ× - %lu" - spa "Query cache fallada para configurar tamaño %lu (Número mínimo: %lu), nuevo tamaño de query cache es %lu" - swe "Storleken av "Query cache" kunde inte sättas till %lu (minsta värde: %lu); ny storlek är %lu" - ukr "ëÅÛ ÚÁÐÉÔ¦× ÎÅÓÐÒÏÍÏÖÅÎ ×ÓÔÁÎÏ×ÉÔÉ ÒÏÚÍ¦Ò %lu (minimal value: %lu), ÎÏ×ÉÊ ÒÏÚÍ¦Ò ËÅÛÁ ÚÁÐÉÔ¦× - %lu" + eng "Query cache failed to set size %lu; new query cache size is %lu" + ger "Änderung der Query-Cache-Größe auf %lu fehlgeschlagen; neue Query-Cache-Größe ist %lu" + por "Falha em Query cache para configurar tamanho %lu, novo tamanho de query cache é %lu" + rus "ëÅÛ ÚÁÐÒÏÓÏ× ÎÅ ÍÏÖÅÔ ÕÓÔÁÎÏ×ÉÔØ ÒÁÚÍÅÒ %lu, ÎÏ×ÙÊ ÒÁÚÍÅÒ ËÅÛÁ ÚÐÒÏÓÏ× - %lu" + spa "Query cache fallada para configurar tamaño %lu, nuevo tamaño de query cache es %lu" + swe "Storleken av "Query cache" kunde inte sättas till %lu, ny storlek är %lu" + ukr "ëÅÛ ÚÁÐÉÔ¦× ÎÅÓÐÒÏÍÏÖÅÎ ×ÓÔÁÎÏ×ÉÔÉ ÒÏÚÍ¦Ò %lu, ÎÏ×ÉÊ ÒÏÚÍ¦Ò ËÅÛÁ ÚÁÐÉÔ¦× - %lu" ER_BAD_FT_COLUMN eng "Column '%-.192s' cannot be part of FULLTEXT index" ger "Feld '%-.192s' kann nicht Teil eines FULLTEXT-Index sein" diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index 38c429a56a4..375ffc882b4 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -942,25 +942,18 @@ ulong Query_cache::resize(ulong query_cache_size_arg) } while (block != queries_blocks); } free_cache(); - query_cache_size= query_cache_size_arg; - ::query_cache_size= init_cache(); - if (::query_cache_size != query_cache_size_arg) - { - push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, - ER_WARN_QC_RESIZE, ER(ER_WARN_QC_RESIZE), - query_cache_size_arg, - get_minimal_size_limit(), - ::query_cache_size); - } + query_cache_size= query_cache_size_arg; + new_query_cache_size= init_cache(); STRUCT_LOCK(&structure_guard_mutex); m_cache_status= Query_cache::NO_FLUSH_IN_PROGRESS; pthread_cond_signal(&COND_cache_status_changed); - + if (new_query_cache_size) + DBUG_EXECUTE("check_querycache",check_integrity(1);); STRUCT_UNLOCK(&structure_guard_mutex); - DBUG_RETURN(::query_cache_size); + DBUG_RETURN(new_query_cache_size); } @@ -1823,24 +1816,6 @@ void Query_cache::init() DBUG_VOID_RETURN; } -/** - Return the lowest possible query cache size. -*/ - -ulong Query_cache::get_minimal_size_limit() -{ - ulong approx_additional_data_size= (sizeof(Query_cache) + - sizeof(void*)*(def_query_hash_size+ - def_table_hash_size)); - - ulong data_size= (min_allocation_unit << QUERY_CACHE_MEM_BIN_STEP_PWR2 << - QUERY_CACHE_MEM_BIN_FIRST_STEP_PWR2) + - ALIGN_SIZE(1) - 1 + - (1 << QUERY_CACHE_MEM_BIN_STEP_PWR2) - 1 + - (1 << QUERY_CACHE_MEM_BIN_FIRST_STEP_PWR2) - 1; - - return(data_size + approx_additional_data_size); -} ulong Query_cache::init_cache() { diff --git a/sql/sql_cache.h b/sql/sql_cache.h index 6af1998a73e..f2c33eff614 100644 --- a/sql/sql_cache.h +++ b/sql/sql_cache.h @@ -282,8 +282,6 @@ private: void free_query_internal(Query_cache_block *point); void invalidate_table_internal(THD *thd, uchar *key, uint32 key_length); - ulong get_minimal_size_limit(); - protected: /* The following mutex is locked when searching or changing global