Commit f0b4cad3 authored by unknown's avatar unknown

Merge mysql.com:/usr/home/bar/mysql-4.1.b22645

into  mysql.com:/usr/home/bar/mysql-5.0.b22645


mysql-test/r/variables.result:
  Auto merged
mysql-test/t/variables.test:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/log.cc:
  Removing one_shot from 5.0.
sql/sql_locale.cc:
  After merge fix
sql/set_var.cc:
  After merge fix
sql/set_var.h:
  After merge fix
parents eb717155 7627a342
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
create table t1 (s1 char(10));
set lc_time_names= 'de_DE';
insert into t1 values (date_format('2001-01-01','%W'));
select * from t1;
s1
Montag
select * from t1;
s1
Montag
drop table t1;
...@@ -580,6 +580,63 @@ set names latin1; ...@@ -580,6 +580,63 @@ set names latin1;
select @@have_innodb; select @@have_innodb;
@@have_innodb @@have_innodb
# #
*** Various tests with LC_TIME_NAMES
*** LC_TIME_NAMES: testing case insensitivity
set @@lc_time_names='ru_ru';
select @@lc_time_names;
@@lc_time_names
ru_RU
*** LC_TIME_NAMES: testing with a user variable
set @lc='JA_JP';
set @@lc_time_names=@lc;
select @@lc_time_names;
@@lc_time_names
ja_JP
*** LC_TIME_NAMES: testing with string expressions
set lc_time_names=concat('de','_','DE');
select @@lc_time_names;
@@lc_time_names
de_DE
set lc_time_names=concat('de','+','DE');
ERROR HY000: Unknown locale: 'de+DE'
select @@lc_time_names;
@@lc_time_names
de_DE
LC_TIME_NAMES: testing with numeric expressions
set @@lc_time_names=1+2;
select @@lc_time_names;
@@lc_time_names
sv_SE
set @@lc_time_names=1/0;
ERROR 42000: Incorrect argument type to variable 'lc_time_names'
select @@lc_time_names;
@@lc_time_names
sv_SE
set lc_time_names=en_US;
LC_TIME_NAMES: testing NULL and a negative number:
set lc_time_names=NULL;
ERROR 42000: Variable 'lc_time_names' can't be set to the value of 'NULL'
set lc_time_names=-1;
ERROR HY000: Unknown locale: '-1'
select @@lc_time_names;
@@lc_time_names
en_US
LC_TIME_NAMES: testing locale with the last ID:
set lc_time_names=108;
select @@lc_time_names;
@@lc_time_names
zh_HK
LC_TIME_NAMES: testing a number beyond the valid ID range:
set lc_time_names=109;
ERROR HY000: Unknown locale: '109'
select @@lc_time_names;
@@lc_time_names
zh_HK
LC_TIME_NAMES: testing that 0 is en_US:
set lc_time_names=0;
select @@lc_time_names;
@@lc_time_names
en_US
set @test = @@query_prealloc_size; set @test = @@query_prealloc_size;
set @@query_prealloc_size = @test; set @@query_prealloc_size = @test;
select @@query_prealloc_size = @test; select @@query_prealloc_size = @test;
......
# Replication of locale variables
source include/master-slave.inc;
#
# Bug#22645 LC_TIME_NAMES: Statement not replicated
#
connection master;
create table t1 (s1 char(10));
set lc_time_names= 'de_DE';
insert into t1 values (date_format('2001-01-01','%W'));
select * from t1;
sync_slave_with_master;
connection slave;
select * from t1;
connection master;
drop table t1;
sync_slave_with_master;
# End of 4.1 tests
...@@ -460,6 +460,50 @@ set names latin1; ...@@ -460,6 +460,50 @@ set names latin1;
--replace_column 1 # --replace_column 1 #
select @@have_innodb; select @@have_innodb;
#
# Tests for lc_time_names
# Note, when adding new locales, please fix ID accordingly:
# - to test the last ID (currently 108)
# - and the next after the last (currently 109)
#
--echo *** Various tests with LC_TIME_NAMES
--echo *** LC_TIME_NAMES: testing case insensitivity
set @@lc_time_names='ru_ru';
select @@lc_time_names;
--echo *** LC_TIME_NAMES: testing with a user variable
set @lc='JA_JP';
set @@lc_time_names=@lc;
select @@lc_time_names;
--echo *** LC_TIME_NAMES: testing with string expressions
set lc_time_names=concat('de','_','DE');
select @@lc_time_names;
--error 1105
set lc_time_names=concat('de','+','DE');
select @@lc_time_names;
--echo LC_TIME_NAMES: testing with numeric expressions
set @@lc_time_names=1+2;
select @@lc_time_names;
--error 1232
set @@lc_time_names=1/0;
select @@lc_time_names;
set lc_time_names=en_US;
--echo LC_TIME_NAMES: testing NULL and a negative number:
--error 1231
set lc_time_names=NULL;
--error 1105
set lc_time_names=-1;
select @@lc_time_names;
--echo LC_TIME_NAMES: testing locale with the last ID:
set lc_time_names=108;
select @@lc_time_names;
--echo LC_TIME_NAMES: testing a number beyond the valid ID range:
--error 1105
set lc_time_names=109;
select @@lc_time_names;
--echo LC_TIME_NAMES: testing that 0 is en_US:
set lc_time_names=0;
select @@lc_time_names;
# #
# Bug #13334: query_prealloc_size default less than minimum # Bug #13334: query_prealloc_size default less than minimum
# #
......
...@@ -109,6 +109,7 @@ enum Derivation ...@@ -109,6 +109,7 @@ enum Derivation
typedef struct my_locale_st typedef struct my_locale_st
{ {
uint number;
const char *name; const char *name;
const char *description; const char *description;
const bool is_ascii; const bool is_ascii;
...@@ -131,6 +132,7 @@ extern MY_LOCALE my_locale_en_US; ...@@ -131,6 +132,7 @@ extern MY_LOCALE my_locale_en_US;
extern MY_LOCALE *my_locales[]; extern MY_LOCALE *my_locales[];
MY_LOCALE *my_locale_by_name(const char *name); MY_LOCALE *my_locale_by_name(const char *name);
MY_LOCALE *my_locale_by_number(uint number);
/*************************************************************************** /***************************************************************************
Configuration parameters Configuration parameters
......
...@@ -2782,17 +2782,39 @@ byte *sys_var_max_user_conn::value_ptr(THD *thd, enum_var_type type, ...@@ -2782,17 +2782,39 @@ byte *sys_var_max_user_conn::value_ptr(THD *thd, enum_var_type type,
return (byte*) &(max_user_connections); return (byte*) &(max_user_connections);
} }
bool sys_var_thd_lc_time_names::check(THD *thd, set_var *var) bool sys_var_thd_lc_time_names::check(THD *thd, set_var *var)
{ {
char *locale_str =var->value->str_value.c_ptr(); MY_LOCALE *locale_match;
MY_LOCALE *locale_match= my_locale_by_name(locale_str);
if (locale_match == NULL) if (var->value->result_type() == INT_RESULT)
{ {
my_printf_error(ER_UNKNOWN_ERROR, if (!(locale_match= my_locale_by_number((uint) var->value->val_int())))
"Unknown locale: '%s'", MYF(0), locale_str); {
return 1; char buf[20];
int10_to_str((int) var->value->val_int(), buf, -10);
my_printf_error(ER_UNKNOWN_ERROR, "Unknown locale: '%s'", MYF(0), buf);
return 1;
}
}
else // STRING_RESULT
{
char buff[6];
String str(buff, sizeof(buff), &my_charset_latin1), *res;
if (!(res=var->value->val_str(&str)))
{
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, "NULL");
return 1;
}
const char *locale_str= res->c_ptr();
if (!(locale_match= my_locale_by_name(locale_str)))
{
my_printf_error(ER_UNKNOWN_ERROR,
"Unknown locale: '%s'", MYF(0), locale_str);
return 1;
}
} }
var->save_result.locale_value= locale_match; var->save_result.locale_value= locale_match;
return 0; return 0;
} }
......
...@@ -819,13 +819,17 @@ class sys_var_thd_lc_time_names :public sys_var_thd ...@@ -819,13 +819,17 @@ class sys_var_thd_lc_time_names :public sys_var_thd
{ {
public: public:
sys_var_thd_lc_time_names(const char *name_arg): sys_var_thd_lc_time_names(const char *name_arg):
sys_var_thd(name_arg) sys_var_thd(name_arg)
{} {
#if MYSQL_VERSION_ID < 50000
no_support_one_shot= 0;
#endif
}
bool check(THD *thd, set_var *var); bool check(THD *thd, set_var *var);
SHOW_TYPE type() { return SHOW_CHAR; } SHOW_TYPE type() { return SHOW_CHAR; }
bool check_update_type(Item_result type) bool check_update_type(Item_result type)
{ {
return type != STRING_RESULT; /* Only accept strings */ return ((type != STRING_RESULT) && (type != INT_RESULT));
} }
bool check_default(enum_var_type type) { return 0; } bool check_default(enum_var_type type) { return 0; }
bool update(THD *thd, set_var *var); bool update(THD *thd, set_var *var);
......
This diff is collapsed.
...@@ -2383,6 +2383,7 @@ static void reset_one_shot_variables(THD *thd) ...@@ -2383,6 +2383,7 @@ static void reset_one_shot_variables(THD *thd)
thd->update_charset(); thd->update_charset();
thd->variables.time_zone= thd->variables.time_zone=
global_system_variables.time_zone; global_system_variables.time_zone;
thd->variables.lc_time_names= &my_locale_en_US;
thd->one_shot_set= 0; thd->one_shot_set= 0;
} }
......
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