Merge tnurnberg@bk-internal.mysql.com:/home/bk/mysql-5.1-opt
into mysql.com:/misc/mysql/99999/51-99999
This commit is contained in:
commit
468c8ebde7
@ -27,3 +27,30 @@ SET GLOBAL example_enum_var= e2;
|
||||
SET GLOBAL example_enum_var= impossible;
|
||||
ERROR 42000: Variable 'enum_var' can't be set to the value of 'impossible'
|
||||
UNINSTALL PLUGIN example;
|
||||
INSTALL PLUGIN example SONAME 'ha_example.so';
|
||||
select @@session.sql_mode into @old_sql_mode;
|
||||
set session sql_mode='';
|
||||
set global example_ulong_var=500;
|
||||
select @@global.example_ulong_var;
|
||||
@@global.example_ulong_var
|
||||
500
|
||||
set global example_ulong_var=1111;
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect ulong_var value: '1111'
|
||||
select @@global.example_ulong_var;
|
||||
@@global.example_ulong_var
|
||||
1000
|
||||
set session sql_mode='STRICT_ALL_TABLES';
|
||||
set global example_ulong_var=500;
|
||||
select @@global.example_ulong_var;
|
||||
@@global.example_ulong_var
|
||||
500
|
||||
set global example_ulong_var=1111;
|
||||
ERROR 42000: Variable 'ulong_var' can't be set to the value of '1111'
|
||||
select @@global.example_ulong_var;
|
||||
@@global.example_ulong_var
|
||||
500
|
||||
set session sql_mode=@old_sql_mode;
|
||||
set session old=bla;
|
||||
ERROR HY000: Variable 'old' is a read only variable
|
||||
UNINSTALL PLUGIN example;
|
||||
|
@ -496,3 +496,13 @@ xb x
|
||||
xcx
|
||||
drop table t1;
|
||||
SET @@SQL_MODE=@OLD_SQL_MODE;
|
||||
create user mysqltest_32753@localhost;
|
||||
set @OLD_SQL_MODE=@@SESSION.SQL_MODE;
|
||||
set session sql_mode='PAD_CHAR_TO_FULL_LENGTH';
|
||||
flush privileges;
|
||||
select current_user();
|
||||
current_user()
|
||||
mysqltest_32753@localhost
|
||||
set session sql_mode=@OLD_SQL_MODE;
|
||||
flush privileges;
|
||||
drop user mysqltest_32753@localhost;
|
||||
|
@ -39,3 +39,38 @@ SET GLOBAL example_enum_var= e2;
|
||||
SET GLOBAL example_enum_var= impossible;
|
||||
|
||||
UNINSTALL PLUGIN example;
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Bug #32757 hang with sql_mode set when setting some global variables
|
||||
#
|
||||
INSTALL PLUGIN example SONAME 'ha_example.so';
|
||||
|
||||
select @@session.sql_mode into @old_sql_mode;
|
||||
|
||||
# first, try normal sql_mode (no error, send OK)
|
||||
set session sql_mode='';
|
||||
set global example_ulong_var=500;
|
||||
select @@global.example_ulong_var;
|
||||
# overflow -- correct value, but throw warning
|
||||
set global example_ulong_var=1111;
|
||||
select @@global.example_ulong_var;
|
||||
|
||||
# now, try STRICT (error occurrs, no message is sent, so send default)
|
||||
set session sql_mode='STRICT_ALL_TABLES';
|
||||
set global example_ulong_var=500;
|
||||
select @@global.example_ulong_var;
|
||||
# overflow -- throw warning, do NOT change value
|
||||
--error ER_WRONG_VALUE_FOR_VAR
|
||||
set global example_ulong_var=1111;
|
||||
select @@global.example_ulong_var;
|
||||
|
||||
set session sql_mode=@old_sql_mode;
|
||||
|
||||
# finally, show that conditions that already raised an error are not
|
||||
# adversely affected (error was already sent, do nothing)
|
||||
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
|
||||
set session old=bla;
|
||||
|
||||
UNINSTALL PLUGIN example;
|
||||
|
@ -279,3 +279,32 @@ select concat('x',b,'x') from t1;
|
||||
drop table t1;
|
||||
|
||||
SET @@SQL_MODE=@OLD_SQL_MODE;
|
||||
|
||||
|
||||
#
|
||||
# Bug #32753: PAD_CHAR_TO_FULL_LENGTH is not documented and interferes
|
||||
# with grant tables
|
||||
#
|
||||
|
||||
create user mysqltest_32753@localhost;
|
||||
|
||||
# try to make the user-table space-padded
|
||||
--connection default
|
||||
set @OLD_SQL_MODE=@@SESSION.SQL_MODE;
|
||||
set session sql_mode='PAD_CHAR_TO_FULL_LENGTH';
|
||||
flush privileges;
|
||||
|
||||
# if user-table is affected by PAD_CHAR_TO_FULL_LENGTH, our connect will fail
|
||||
# --error 1045
|
||||
connect (user_32753,localhost,mysqltest_32753,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
|
||||
select current_user();
|
||||
|
||||
# clean up
|
||||
--connection default
|
||||
set session sql_mode=@OLD_SQL_MODE;
|
||||
flush privileges;
|
||||
|
||||
--disconnect user_32753
|
||||
|
||||
--connection default
|
||||
drop user mysqltest_32753@localhost;
|
||||
|
@ -137,7 +137,8 @@ static void fix_trans_mem_root(THD *thd, enum_var_type type);
|
||||
static void fix_server_id(THD *thd, enum_var_type type);
|
||||
static ulonglong fix_unsigned(THD *, ulonglong, const struct my_option *);
|
||||
static bool get_unsigned(THD *thd, set_var *var);
|
||||
static void throw_bounds_warning(THD *thd, const char *name, ulonglong num);
|
||||
bool throw_bounds_warning(THD *thd, bool fixed, bool unsignd,
|
||||
const char *name, longlong val);
|
||||
static KEY_CACHE *create_key_cache(const char *name, uint length);
|
||||
void fix_sql_mode_var(THD *thd, enum_var_type type);
|
||||
static uchar *get_error_count(THD *thd);
|
||||
@ -1207,13 +1208,29 @@ static void fix_server_id(THD *thd, enum_var_type type)
|
||||
}
|
||||
|
||||
|
||||
static void throw_bounds_warning(THD *thd, const char *name, ulonglong num)
|
||||
bool throw_bounds_warning(THD *thd, bool fixed, bool unsignd,
|
||||
const char *name, longlong val)
|
||||
{
|
||||
char buf[22];
|
||||
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||
ER_TRUNCATED_WRONG_VALUE,
|
||||
ER(ER_TRUNCATED_WRONG_VALUE), name,
|
||||
ullstr(num, buf));
|
||||
if (fixed)
|
||||
{
|
||||
char buf[22];
|
||||
|
||||
if (unsignd)
|
||||
ullstr((ulonglong) val, buf);
|
||||
else
|
||||
llstr(val, buf);
|
||||
|
||||
if (thd->variables.sql_mode & MODE_STRICT_ALL_TABLES)
|
||||
{
|
||||
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, buf);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||
ER_TRUNCATED_WRONG_VALUE,
|
||||
ER(ER_TRUNCATED_WRONG_VALUE), name, buf);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static ulonglong fix_unsigned(THD *thd, ulonglong num,
|
||||
@ -1222,8 +1239,7 @@ static ulonglong fix_unsigned(THD *thd, ulonglong num,
|
||||
bool fixed= FALSE;
|
||||
ulonglong out= getopt_ull_limit_value(num, option_limits, &fixed);
|
||||
|
||||
if (fixed)
|
||||
throw_bounds_warning(thd, option_limits->name, num);
|
||||
throw_bounds_warning(thd, fixed, TRUE, option_limits->name, (longlong) num);
|
||||
return out;
|
||||
}
|
||||
|
||||
@ -1266,7 +1282,8 @@ bool sys_var_long_ptr_global::update(THD *thd, set_var *var)
|
||||
if (tmp > ULONG_MAX)
|
||||
{
|
||||
tmp= ULONG_MAX;
|
||||
throw_bounds_warning(thd, name, var->save_result.ulonglong_value);
|
||||
throw_bounds_warning(thd, TRUE, TRUE, name,
|
||||
(longlong) var->save_result.ulonglong_value);
|
||||
}
|
||||
#endif
|
||||
*value= (ulong) tmp;
|
||||
@ -1355,7 +1372,7 @@ bool sys_var_thd_ulong::update(THD *thd, set_var *var)
|
||||
/* Don't use bigger value than given with --maximum-variable-name=.. */
|
||||
if ((ulong) tmp > max_system_variables.*offset)
|
||||
{
|
||||
throw_bounds_warning(thd, name, tmp);
|
||||
throw_bounds_warning(thd, TRUE, TRUE, name, (longlong) tmp);
|
||||
tmp= max_system_variables.*offset;
|
||||
}
|
||||
|
||||
@ -1365,7 +1382,7 @@ bool sys_var_thd_ulong::update(THD *thd, set_var *var)
|
||||
else if (tmp > ULONG_MAX)
|
||||
{
|
||||
tmp= ULONG_MAX;
|
||||
throw_bounds_warning(thd, name, var->save_result.ulonglong_value);
|
||||
throw_bounds_warning(thd, TRUE, TRUE, name, (longlong) var->save_result.ulonglong_value);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -192,7 +192,7 @@ static void update_hostname(acl_host_and_ip *host, const char *hostname);
|
||||
static bool compare_hostname(const acl_host_and_ip *host,const char *hostname,
|
||||
const char *ip);
|
||||
static my_bool acl_load(THD *thd, TABLE_LIST *tables);
|
||||
static my_bool grant_load(TABLE_LIST *tables);
|
||||
static my_bool grant_load(THD *thd, TABLE_LIST *tables);
|
||||
|
||||
/*
|
||||
Convert scrambled password to binary form, according to scramble type,
|
||||
@ -314,8 +314,11 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables)
|
||||
bool check_no_resolve= specialflag & SPECIAL_NO_RESOLVE;
|
||||
char tmp_name[NAME_LEN+1];
|
||||
int password_length;
|
||||
ulong old_sql_mode= thd->variables.sql_mode;
|
||||
DBUG_ENTER("acl_load");
|
||||
|
||||
thd->variables.sql_mode&= ~MODE_PAD_CHAR_TO_FULL_LENGTH;
|
||||
|
||||
grant_version++; /* Privileges updated */
|
||||
|
||||
acl_cache->clear(1); // Clear locked hostname cache
|
||||
@ -622,6 +625,7 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables)
|
||||
return_val=0;
|
||||
|
||||
end:
|
||||
thd->variables.sql_mode= old_sql_mode;
|
||||
DBUG_RETURN(return_val);
|
||||
}
|
||||
|
||||
@ -3620,7 +3624,7 @@ end_unlock:
|
||||
@retval TRUE Error
|
||||
*/
|
||||
|
||||
static my_bool grant_load(TABLE_LIST *tables)
|
||||
static my_bool grant_load(THD *thd, TABLE_LIST *tables)
|
||||
{
|
||||
MEM_ROOT *memex_ptr;
|
||||
my_bool return_val= 1;
|
||||
@ -3628,7 +3632,11 @@ static my_bool grant_load(TABLE_LIST *tables)
|
||||
bool check_no_resolve= specialflag & SPECIAL_NO_RESOLVE;
|
||||
MEM_ROOT **save_mem_root_ptr= my_pthread_getspecific_ptr(MEM_ROOT**,
|
||||
THR_MALLOC);
|
||||
ulong old_sql_mode= thd->variables.sql_mode;
|
||||
DBUG_ENTER("grant_load");
|
||||
|
||||
thd->variables.sql_mode&= ~MODE_PAD_CHAR_TO_FULL_LENGTH;
|
||||
|
||||
(void) hash_init(&column_priv_hash,system_charset_info,
|
||||
0,0,0, (hash_get_key) get_grant_table,
|
||||
(hash_free_key) free_grant_table,0);
|
||||
@ -3680,6 +3688,7 @@ static my_bool grant_load(TABLE_LIST *tables)
|
||||
return_val=0; // Return ok
|
||||
|
||||
end_unlock:
|
||||
thd->variables.sql_mode= old_sql_mode;
|
||||
t_table->file->ha_index_end();
|
||||
my_pthread_setspecific_ptr(THR_MALLOC, save_mem_root_ptr);
|
||||
DBUG_RETURN(return_val);
|
||||
@ -3793,7 +3802,7 @@ my_bool grant_reload(THD *thd)
|
||||
old_mem= memex;
|
||||
init_sql_alloc(&memex, ACL_ALLOC_BLOCK_SIZE, 0);
|
||||
|
||||
if ((return_val= grant_load(tables)))
|
||||
if ((return_val= grant_load(thd, tables)))
|
||||
{ // Error. Revert to old hash
|
||||
DBUG_PRINT("error",("Reverting to old privileges"));
|
||||
grant_free(); /* purecov: deadcode */
|
||||
|
@ -3255,6 +3255,18 @@ end_with_restore_list:
|
||||
thd->one_shot_set|= lex->one_shot_set;
|
||||
send_ok(thd);
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
We encountered some sort of error, but no message was sent.
|
||||
Send something semi-generic here since we don't know which
|
||||
assignment in the list caused the error.
|
||||
*/
|
||||
if (!thd->is_error())
|
||||
my_error(ER_WRONG_ARGUMENTS,MYF(0),"SET");
|
||||
goto error;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -210,6 +210,8 @@ static void reap_plugins(void);
|
||||
|
||||
/* declared in set_var.cc */
|
||||
extern sys_var *intern_find_sys_var(const char *str, uint length, bool no_error);
|
||||
extern bool throw_bounds_warning(THD *thd, bool fixed, bool unsignd,
|
||||
const char *name, longlong val);
|
||||
|
||||
#ifdef EMBEDDED_LIBRARY
|
||||
/* declared in sql_base.cc */
|
||||
@ -1888,16 +1890,8 @@ static int check_func_int(THD *thd, struct st_mysql_sys_var *var,
|
||||
else
|
||||
*(int *)save= (int) getopt_ll_limit_value(tmp, &options, &fixed);
|
||||
|
||||
if (fixed)
|
||||
{
|
||||
char buf[22];
|
||||
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||
ER_TRUNCATED_WRONG_VALUE,
|
||||
ER(ER_TRUNCATED_WRONG_VALUE), var->name,
|
||||
ullstr(tmp, buf));
|
||||
}
|
||||
return (thd->variables.sql_mode & MODE_STRICT_ALL_TABLES) &&
|
||||
(*(int *)save != (int) tmp);
|
||||
return throw_bounds_warning(thd, fixed, var->flags & PLUGIN_VAR_UNSIGNED,
|
||||
var->name, (longlong) tmp);
|
||||
}
|
||||
|
||||
|
||||
@ -1916,16 +1910,8 @@ static int check_func_long(THD *thd, struct st_mysql_sys_var *var,
|
||||
else
|
||||
*(long *)save= (long) getopt_ll_limit_value(tmp, &options, &fixed);
|
||||
|
||||
if (fixed)
|
||||
{
|
||||
char buf[22];
|
||||
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||
ER_TRUNCATED_WRONG_VALUE,
|
||||
ER(ER_TRUNCATED_WRONG_VALUE), var->name,
|
||||
ullstr(tmp, buf));
|
||||
}
|
||||
return (thd->variables.sql_mode & MODE_STRICT_ALL_TABLES) &&
|
||||
(*(long *)save != (long) tmp);
|
||||
return throw_bounds_warning(thd, fixed, var->flags & PLUGIN_VAR_UNSIGNED,
|
||||
var->name, (longlong) tmp);
|
||||
}
|
||||
|
||||
|
||||
@ -1937,7 +1923,6 @@ static int check_func_longlong(THD *thd, struct st_mysql_sys_var *var,
|
||||
struct my_option options;
|
||||
value->val_int(value, &tmp);
|
||||
plugin_opt_set_limits(&options, var);
|
||||
*(ulonglong *)save= getopt_ull_limit_value(tmp, &options, &fixed);
|
||||
|
||||
if (var->flags & PLUGIN_VAR_UNSIGNED)
|
||||
*(ulonglong *)save= getopt_ull_limit_value((ulonglong) tmp, &options,
|
||||
@ -1945,16 +1930,8 @@ static int check_func_longlong(THD *thd, struct st_mysql_sys_var *var,
|
||||
else
|
||||
*(longlong *)save= getopt_ll_limit_value(tmp, &options, &fixed);
|
||||
|
||||
if (fixed)
|
||||
{
|
||||
char buf[22];
|
||||
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||
ER_TRUNCATED_WRONG_VALUE,
|
||||
ER(ER_TRUNCATED_WRONG_VALUE), var->name,
|
||||
ullstr(tmp, buf));
|
||||
}
|
||||
return (thd->variables.sql_mode & MODE_STRICT_ALL_TABLES) &&
|
||||
(*(long long *)save != tmp);
|
||||
return throw_bounds_warning(thd, fixed, var->flags & PLUGIN_VAR_UNSIGNED,
|
||||
var->name, (longlong) tmp);
|
||||
}
|
||||
|
||||
static int check_func_str(THD *thd, struct st_mysql_sys_var *var,
|
||||
|
@ -849,6 +849,7 @@ struct st_mysql_storage_engine example_storage_engine=
|
||||
{ MYSQL_HANDLERTON_INTERFACE_VERSION };
|
||||
|
||||
static ulong srv_enum_var= 0;
|
||||
static ulong srv_ulong_var= 0;
|
||||
|
||||
const char *enum_var_names[]=
|
||||
{
|
||||
@ -871,8 +872,21 @@ static MYSQL_SYSVAR_ENUM(
|
||||
0, // def
|
||||
&enum_var_typelib); // typelib
|
||||
|
||||
static MYSQL_SYSVAR_ULONG(
|
||||
ulong_var,
|
||||
srv_ulong_var,
|
||||
PLUGIN_VAR_RQCMDARG,
|
||||
"0..1000",
|
||||
NULL,
|
||||
NULL,
|
||||
8,
|
||||
0,
|
||||
1000,
|
||||
0);
|
||||
|
||||
static struct st_mysql_sys_var* example_system_variables[]= {
|
||||
MYSQL_SYSVAR(enum_var),
|
||||
MYSQL_SYSVAR(ulong_var),
|
||||
NULL
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user