Commit 3826a01e authored by guilhem@mysql.com's avatar guilhem@mysql.com

A previous changeset by me today about SQL_LOG_BIN had the problem

that it tested the privilege in ::update() whereas it should be
in ::check() (see email from Serg, subject
"Re: bk commit - 4.1 tree (guilhem:1.1706)").
So I add instead a check_func function to sys_var_thd_bit.
I do the same addition to sys_var_thd_ulong, to unify handling
of PSEUDO_THREAD_ID with the one of SQL_LOG_BIN. So class
sys_var_pseudo_thread_id is not needed anymore, removing it.
parent 38013489
...@@ -5,10 +5,17 @@ reset slave; ...@@ -5,10 +5,17 @@ reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave; start slave;
reset master; reset master;
SET @@session.pseudo_thread_id=100; SET @save_select_limit=@@session.sql_select_limit;
SET @@session.sql_select_limit=10, @@session.pseudo_thread_id=100;
ERROR HY000: Access denied. You need the SUPER privilege for this operation ERROR HY000: Access denied. You need the SUPER privilege for this operation
SET @@session.sql_log_bin=0; SELECT @@session.sql_select_limit = @save_select_limit;
@@session.sql_select_limit = @save_select_limit
1
SET @@session.sql_select_limit=10, @@session.sql_log_bin=0;
ERROR HY000: Access denied. You need the SUPER privilege for this operation ERROR HY000: Access denied. You need the SUPER privilege for this operation
SELECT @@session.sql_select_limit = @save_select_limit;
@@session.sql_select_limit = @save_select_limit
1
SET @@session.pseudo_thread_id=100; SET @@session.pseudo_thread_id=100;
SET @@session.pseudo_thread_id=connection_id(); SET @@session.pseudo_thread_id=connection_id();
SET @@session.sql_log_bin=0; SET @@session.sql_log_bin=0;
......
...@@ -28,11 +28,14 @@ connect (con3,localhost,zedjzlcsjhd,,); ...@@ -28,11 +28,14 @@ connect (con3,localhost,zedjzlcsjhd,,);
# check that it requires the SUPER privilege. # check that it requires the SUPER privilege.
connection con3; connection con3;
SET @save_select_limit=@@session.sql_select_limit;
--error 1227 --error 1227
SET @@session.pseudo_thread_id=100; SET @@session.sql_select_limit=10, @@session.pseudo_thread_id=100;
SELECT @@session.sql_select_limit = @save_select_limit; #shouldn't have changed
# While we are here we also test that SQL_LOG_BIN can't be set # While we are here we also test that SQL_LOG_BIN can't be set
--error 1227 --error 1227
SET @@session.sql_log_bin=0; SET @@session.sql_select_limit=10, @@session.sql_log_bin=0;
SELECT @@session.sql_select_limit = @save_select_limit; #shouldn't have changed
# Now as root, to be sure it works # Now as root, to be sure it works
connection con2; connection con2;
SET @@session.pseudo_thread_id=100; SET @@session.pseudo_thread_id=100;
......
...@@ -85,7 +85,9 @@ static bool sys_update_init_slave(THD*, set_var*); ...@@ -85,7 +85,9 @@ static bool sys_update_init_slave(THD*, set_var*);
static void sys_default_init_slave(THD*, enum_var_type type); static void sys_default_init_slave(THD*, enum_var_type type);
static bool set_option_bit(THD *thd, set_var *var); static bool set_option_bit(THD *thd, set_var *var);
static bool set_option_autocommit(THD *thd, set_var *var); static bool set_option_autocommit(THD *thd, set_var *var);
static int check_log_update(THD *thd, set_var *var);
static bool set_log_update(THD *thd, set_var *var); static bool set_log_update(THD *thd, set_var *var);
static int check_pseudo_thread_id(THD *thd, set_var *var);
static void fix_low_priority_updates(THD *thd, enum_var_type type); static void fix_low_priority_updates(THD *thd, enum_var_type type);
static void fix_tx_isolation(THD *thd, enum_var_type type); static void fix_tx_isolation(THD *thd, enum_var_type type);
static void fix_net_read_timeout(THD *thd, enum_var_type type); static void fix_net_read_timeout(THD *thd, enum_var_type type);
...@@ -202,17 +204,14 @@ sys_var_thd_ulong sys_max_insert_delayed_threads("max_insert_delayed_threa ...@@ -202,17 +204,14 @@ sys_var_thd_ulong sys_max_insert_delayed_threads("max_insert_delayed_threa
&SV::max_insert_delayed_threads); &SV::max_insert_delayed_threads);
sys_var_thd_ulong sys_max_delayed_threads("max_delayed_threads", sys_var_thd_ulong sys_max_delayed_threads("max_delayed_threads",
&SV::max_insert_delayed_threads, &SV::max_insert_delayed_threads,
fix_max_connections); 0, fix_max_connections);
sys_var_thd_ulong sys_max_error_count("max_error_count", sys_var_thd_ulong sys_max_error_count("max_error_count",
&SV::max_error_count); &SV::max_error_count);
sys_var_thd_ulong sys_max_heap_table_size("max_heap_table_size", sys_var_thd_ulong sys_max_heap_table_size("max_heap_table_size",
&SV::max_heap_table_size); &SV::max_heap_table_size);
/* sys_var_thd_ulong sys_pseudo_thread_id("pseudo_thread_id",
sys_pseudo_thread_id has its own class (instead of sys_var_thd_ulong) because &SV::pseudo_thread_id,
we want a check() function. check_pseudo_thread_id, 0);
*/
sys_var_pseudo_thread_id sys_pseudo_thread_id("pseudo_thread_id",
&SV::pseudo_thread_id);
sys_var_thd_ha_rows sys_max_join_size("max_join_size", sys_var_thd_ha_rows sys_max_join_size("max_join_size",
&SV::max_join_size, &SV::max_join_size,
fix_max_join_size); fix_max_join_size);
...@@ -244,13 +243,13 @@ sys_var_thd_ulong sys_net_buffer_length("net_buffer_length", ...@@ -244,13 +243,13 @@ sys_var_thd_ulong sys_net_buffer_length("net_buffer_length",
&SV::net_buffer_length); &SV::net_buffer_length);
sys_var_thd_ulong sys_net_read_timeout("net_read_timeout", sys_var_thd_ulong sys_net_read_timeout("net_read_timeout",
&SV::net_read_timeout, &SV::net_read_timeout,
fix_net_read_timeout); 0, fix_net_read_timeout);
sys_var_thd_ulong sys_net_write_timeout("net_write_timeout", sys_var_thd_ulong sys_net_write_timeout("net_write_timeout",
&SV::net_write_timeout, &SV::net_write_timeout,
fix_net_write_timeout); 0, fix_net_write_timeout);
sys_var_thd_ulong sys_net_retry_count("net_retry_count", sys_var_thd_ulong sys_net_retry_count("net_retry_count",
&SV::net_retry_count, &SV::net_retry_count,
fix_net_retry_count); 0, fix_net_retry_count);
sys_var_thd_bool sys_new_mode("new", &SV::new_mode); sys_var_thd_bool sys_new_mode("new", &SV::new_mode);
sys_var_thd_bool sys_old_passwords("old_passwords", &SV::old_passwords); sys_var_thd_bool sys_old_passwords("old_passwords", &SV::old_passwords);
sys_var_thd_ulong sys_preload_buff_size("preload_buffer_size", sys_var_thd_ulong sys_preload_buff_size("preload_buffer_size",
...@@ -274,16 +273,16 @@ sys_var_thd_ulong sys_range_alloc_block_size("range_alloc_block_size", ...@@ -274,16 +273,16 @@ sys_var_thd_ulong sys_range_alloc_block_size("range_alloc_block_size",
&SV::range_alloc_block_size); &SV::range_alloc_block_size);
sys_var_thd_ulong sys_query_alloc_block_size("query_alloc_block_size", sys_var_thd_ulong sys_query_alloc_block_size("query_alloc_block_size",
&SV::query_alloc_block_size, &SV::query_alloc_block_size,
fix_thd_mem_root); 0, fix_thd_mem_root);
sys_var_thd_ulong sys_query_prealloc_size("query_prealloc_size", sys_var_thd_ulong sys_query_prealloc_size("query_prealloc_size",
&SV::query_prealloc_size, &SV::query_prealloc_size,
fix_thd_mem_root); 0, fix_thd_mem_root);
sys_var_thd_ulong sys_trans_alloc_block_size("transaction_alloc_block_size", sys_var_thd_ulong sys_trans_alloc_block_size("transaction_alloc_block_size",
&SV::trans_alloc_block_size, &SV::trans_alloc_block_size,
fix_trans_mem_root); 0, fix_trans_mem_root);
sys_var_thd_ulong sys_trans_prealloc_size("transaction_prealloc_size", sys_var_thd_ulong sys_trans_prealloc_size("transaction_prealloc_size",
&SV::trans_prealloc_size, &SV::trans_prealloc_size,
fix_trans_mem_root); 0, fix_trans_mem_root);
#ifdef HAVE_QUERY_CACHE #ifdef HAVE_QUERY_CACHE
sys_var_long_ptr sys_query_cache_limit("query_cache_limit", sys_var_long_ptr sys_query_cache_limit("query_cache_limit",
...@@ -348,50 +347,52 @@ sys_var_thd_date_time_format sys_datetime_format("datetime_format", ...@@ -348,50 +347,52 @@ sys_var_thd_date_time_format sys_datetime_format("datetime_format",
/* Variables that are bits in THD */ /* Variables that are bits in THD */
static sys_var_thd_bit sys_autocommit("autocommit", static sys_var_thd_bit sys_autocommit("autocommit", 0,
set_option_autocommit, set_option_autocommit,
OPTION_NOT_AUTOCOMMIT, OPTION_NOT_AUTOCOMMIT,
1); 1);
static sys_var_thd_bit sys_big_tables("big_tables", static sys_var_thd_bit sys_big_tables("big_tables", 0,
set_option_bit, set_option_bit,
OPTION_BIG_TABLES); OPTION_BIG_TABLES);
#ifndef TO_BE_DELETED /* Alias for big_tables */ #ifndef TO_BE_DELETED /* Alias for big_tables */
static sys_var_thd_bit sys_sql_big_tables("sql_big_tables", static sys_var_thd_bit sys_sql_big_tables("sql_big_tables", 0,
set_option_bit, set_option_bit,
OPTION_BIG_TABLES); OPTION_BIG_TABLES);
#endif #endif
static sys_var_thd_bit sys_big_selects("sql_big_selects", static sys_var_thd_bit sys_big_selects("sql_big_selects", 0,
set_option_bit, set_option_bit,
OPTION_BIG_SELECTS); OPTION_BIG_SELECTS);
static sys_var_thd_bit sys_log_off("sql_log_off", static sys_var_thd_bit sys_log_off("sql_log_off", 0,
set_option_bit, set_option_bit,
OPTION_LOG_OFF); OPTION_LOG_OFF);
static sys_var_thd_bit sys_log_update("sql_log_update", static sys_var_thd_bit sys_log_update("sql_log_update",
check_log_update,
set_log_update, set_log_update,
OPTION_UPDATE_LOG); OPTION_UPDATE_LOG);
static sys_var_thd_bit sys_log_binlog("sql_log_bin", static sys_var_thd_bit sys_log_binlog("sql_log_bin",
check_log_update,
set_log_update, set_log_update,
OPTION_BIN_LOG); OPTION_BIN_LOG);
static sys_var_thd_bit sys_sql_warnings("sql_warnings", static sys_var_thd_bit sys_sql_warnings("sql_warnings", 0,
set_option_bit, set_option_bit,
OPTION_WARNINGS); OPTION_WARNINGS);
static sys_var_thd_bit sys_auto_is_null("sql_auto_is_null", static sys_var_thd_bit sys_auto_is_null("sql_auto_is_null", 0,
set_option_bit, set_option_bit,
OPTION_AUTO_IS_NULL); OPTION_AUTO_IS_NULL);
static sys_var_thd_bit sys_safe_updates("sql_safe_updates", static sys_var_thd_bit sys_safe_updates("sql_safe_updates", 0,
set_option_bit, set_option_bit,
OPTION_SAFE_UPDATES); OPTION_SAFE_UPDATES);
static sys_var_thd_bit sys_buffer_results("sql_buffer_result", static sys_var_thd_bit sys_buffer_results("sql_buffer_result", 0,
set_option_bit, set_option_bit,
OPTION_BUFFER_RESULT); OPTION_BUFFER_RESULT);
static sys_var_thd_bit sys_quote_show_create("sql_quote_show_create", static sys_var_thd_bit sys_quote_show_create("sql_quote_show_create", 0,
set_option_bit, set_option_bit,
OPTION_QUOTE_SHOW_CREATE); OPTION_QUOTE_SHOW_CREATE);
static sys_var_thd_bit sys_foreign_key_checks("foreign_key_checks", static sys_var_thd_bit sys_foreign_key_checks("foreign_key_checks", 0,
set_option_bit, set_option_bit,
OPTION_NO_FOREIGN_KEY_CHECKS, OPTION_NO_FOREIGN_KEY_CHECKS,
1); 1);
static sys_var_thd_bit sys_unique_checks("unique_checks", static sys_var_thd_bit sys_unique_checks("unique_checks", 0,
set_option_bit, set_option_bit,
OPTION_RELAXED_UNIQUE_CHECKS, OPTION_RELAXED_UNIQUE_CHECKS,
1); 1);
...@@ -1170,6 +1171,11 @@ byte *sys_var_enum::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) ...@@ -1170,6 +1171,11 @@ byte *sys_var_enum::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
return (byte*) enum_names->type_names[*value]; return (byte*) enum_names->type_names[*value];
} }
bool sys_var_thd_ulong::check(THD *thd, set_var *var)
{
return (sys_var_thd::check(thd, var) ||
(check_func && (*check_func)(thd, var)));
}
bool sys_var_thd_ulong::update(THD *thd, set_var *var) bool sys_var_thd_ulong::update(THD *thd, set_var *var)
{ {
...@@ -1499,6 +1505,11 @@ byte *sys_var_thd_enum::value_ptr(THD *thd, enum_var_type type, ...@@ -1499,6 +1505,11 @@ byte *sys_var_thd_enum::value_ptr(THD *thd, enum_var_type type,
return (byte*) enum_names->type_names[tmp]; return (byte*) enum_names->type_names[tmp];
} }
bool sys_var_thd_bit::check(THD *thd, set_var *var)
{
return (check_enum(thd, var, &bool_typelib) ||
(check_func && (*check_func)(thd, var)));
}
bool sys_var_thd_bit::update(THD *thd, set_var *var) bool sys_var_thd_bit::update(THD *thd, set_var *var)
{ {
...@@ -2167,22 +2178,6 @@ byte *sys_var_insert_id::value_ptr(THD *thd, enum_var_type type, ...@@ -2167,22 +2178,6 @@ byte *sys_var_insert_id::value_ptr(THD *thd, enum_var_type type,
return (byte*) &thd->current_insert_id; return (byte*) &thd->current_insert_id;
} }
bool sys_var_pseudo_thread_id::check(THD *thd, set_var *var)
{
var->save_result.ulonglong_value= var->value->val_int();
#ifndef NO_EMBEDDED_ACCESS_CHECKS
if (thd->master_access & SUPER_ACL)
return 0;
else
{
my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), "SUPER");
return 1;
}
#else
return 0;
#endif
}
#ifdef HAVE_REPLICATION #ifdef HAVE_REPLICATION
bool sys_var_slave_skip_counter::check(THD *thd, set_var *var) bool sys_var_slave_skip_counter::check(THD *thd, set_var *var)
...@@ -2281,8 +2276,7 @@ static bool set_option_autocommit(THD *thd, set_var *var) ...@@ -2281,8 +2276,7 @@ static bool set_option_autocommit(THD *thd, set_var *var)
return 0; return 0;
} }
static int check_log_update(THD *thd, set_var *var)
static bool set_log_update(THD *thd, set_var *var)
{ {
#ifndef NO_EMBEDDED_ACCESS_CHECKS #ifndef NO_EMBEDDED_ACCESS_CHECKS
if (!(thd->master_access & SUPER_ACL)) if (!(thd->master_access & SUPER_ACL))
...@@ -2291,6 +2285,11 @@ static bool set_log_update(THD *thd, set_var *var) ...@@ -2291,6 +2285,11 @@ static bool set_log_update(THD *thd, set_var *var)
return 1; return 1;
} }
#endif #endif
return 0;
}
static bool set_log_update(THD *thd, set_var *var)
{
if (opt_sql_bin_update) if (opt_sql_bin_update)
((sys_var_thd_bit*) var->var)->bit_flag|= (OPTION_BIN_LOG | ((sys_var_thd_bit*) var->var)->bit_flag|= (OPTION_BIN_LOG |
OPTION_UPDATE_LOG); OPTION_UPDATE_LOG);
...@@ -2298,6 +2297,22 @@ static bool set_log_update(THD *thd, set_var *var) ...@@ -2298,6 +2297,22 @@ static bool set_log_update(THD *thd, set_var *var)
return 0; return 0;
} }
static int check_pseudo_thread_id(THD *thd, set_var *var)
{
var->save_result.ulonglong_value= var->value->val_int();
#ifndef NO_EMBEDDED_ACCESS_CHECKS
if (thd->master_access & SUPER_ACL)
return 0;
else
{
my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), "SUPER");
return 1;
}
#else
return 0;
#endif
}
static byte *get_warning_count(THD *thd) static byte *get_warning_count(THD *thd)
{ {
thd->sys_var_tmp.long_value= thd->sys_var_tmp.long_value=
......
...@@ -231,30 +231,23 @@ public: ...@@ -231,30 +231,23 @@ public:
class sys_var_thd_ulong :public sys_var_thd class sys_var_thd_ulong :public sys_var_thd
{ {
sys_check_func check_func;
public: public:
ulong SV::*offset; ulong SV::*offset;
sys_var_thd_ulong(const char *name_arg, ulong SV::*offset_arg) sys_var_thd_ulong(const char *name_arg, ulong SV::*offset_arg)
:sys_var_thd(name_arg), offset(offset_arg) :sys_var_thd(name_arg), check_func(0), offset(offset_arg)
{} {}
sys_var_thd_ulong(const char *name_arg, ulong SV::*offset_arg, sys_var_thd_ulong(const char *name_arg, ulong SV::*offset_arg,
sys_after_update_func func) sys_check_func c_func, sys_after_update_func au_func)
:sys_var_thd(name_arg,func), offset(offset_arg) :sys_var_thd(name_arg,au_func), check_func(c_func), offset(offset_arg)
{} {}
bool check(THD *thd, set_var *var);
bool update(THD *thd, set_var *var); bool update(THD *thd, set_var *var);
void set_default(THD *thd, enum_var_type type); void set_default(THD *thd, enum_var_type type);
SHOW_TYPE type() { return SHOW_LONG; } SHOW_TYPE type() { return SHOW_LONG; }
byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
}; };
class sys_var_pseudo_thread_id :public sys_var_thd_ulong
{
public:
sys_var_pseudo_thread_id(const char *name_arg, ulong SV::*offset_arg)
:sys_var_thd_ulong(name_arg, offset_arg)
{}
bool check(THD *thd, set_var *var);
};
class sys_var_thd_ha_rows :public sys_var_thd class sys_var_thd_ha_rows :public sys_var_thd
{ {
...@@ -402,19 +395,18 @@ public: ...@@ -402,19 +395,18 @@ public:
class sys_var_thd_bit :public sys_var_thd class sys_var_thd_bit :public sys_var_thd
{ {
sys_check_func check_func;
sys_update_func update_func; sys_update_func update_func;
public: public:
ulong bit_flag; ulong bit_flag;
bool reverse; bool reverse;
sys_var_thd_bit(const char *name_arg, sys_update_func func, ulong bit, sys_var_thd_bit(const char *name_arg,
bool reverse_arg=0) sys_check_func c_func, sys_update_func u_func,
:sys_var_thd(name_arg), update_func(func), bit_flag(bit), ulong bit, bool reverse_arg=0)
reverse(reverse_arg) :sys_var_thd(name_arg), check_func(c_func), update_func(u_func),
bit_flag(bit), reverse(reverse_arg)
{} {}
bool check(THD *thd, set_var *var) bool check(THD *thd, set_var *var);
{
return check_enum(thd, var, &bool_typelib);
}
bool update(THD *thd, set_var *var); bool update(THD *thd, set_var *var);
bool check_update_type(Item_result type) { return 0; } bool check_update_type(Item_result type) { return 0; }
bool check_type(enum_var_type type) { return type == OPT_GLOBAL; } bool check_type(enum_var_type type) { return type == OPT_GLOBAL; }
......
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