summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorunknown <bar@mysql.com/bar.intranet.mysql.r18.ru>2006-12-05 13:45:21 +0400
committerunknown <bar@mysql.com/bar.intranet.mysql.r18.ru>2006-12-05 13:45:21 +0400
commit4474cc8493fb999b1fea4da739177c146909ddef (patch)
tree3c3f0a63ce5f3cc7e3fdbeb1a7644ca2467b750a /mysql-test
parent248ab7c7eeede27c7750c5c309deb57c13952dde (diff)
downloadmariadb-git-4474cc8493fb999b1fea4da739177c146909ddef.tar.gz
Bug#22645 LC_TIME_NAMES: Statement not replicated
Problem: replication of LC_TIME_NAMES didn't work. Thus, INSERTS or UPDATES using date_format() always worked with en_US on the slave side. Fix: adding ONE_SHOT implementation for LC_TIME_NAMES. mysql-test/r/variables.result: Adding various tests with LC_TIME_NAMES and string and numeric constants and expressions. mysql-test/t/variables.test: Adding various tests with LC_TIME_NAMES and string and numeric constants and expressions. sql/log.cc: Adding ONE_SHOT trick for lc_time_names. sql/mysql_priv.h: Adding new member "number" - for unique locale IDs. Adding prototype for my_locale_by_number(). sql/set_var.cc: Modifying lc_time_names variable to understand both: - string valyes (using locale name) - number values (using locale IDs) sql/set_var.h: - Marking lc_time_names as ONE_SHOT capable. - Marking lc_time_names as INT_RESULT compatible. sql/sql_locale.cc: - adding local IDs - better layout for locale data declarations (splitting long lines into short ones) - adding DBUG_ASSERT into my_locale_by_name() and moving this function towards the end of file - after "my_locales" declaration - adding my_locale_by_number() implementation sql/sql_parse.cc: Adding initialization of lc_time_names to its default value (en_US) mysql-test/r/rpl_locale.result: Adding test case mysql-test/t/rpl_locale.test: Adding test case
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/rpl_locale.result16
-rw-r--r--mysql-test/r/variables.result57
-rw-r--r--mysql-test/t/rpl_locale.test22
-rw-r--r--mysql-test/t/variables.test44
4 files changed, 139 insertions, 0 deletions
diff --git a/mysql-test/r/rpl_locale.result b/mysql-test/r/rpl_locale.result
new file mode 100644
index 00000000000..5de5bab9a0b
--- /dev/null
+++ b/mysql-test/r/rpl_locale.result
@@ -0,0 +1,16 @@
+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;
diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result
index 0aa7ea7f83c..14f1eb7d306 100644
--- a/mysql-test/r/variables.result
+++ b/mysql-test/r/variables.result
@@ -499,6 +499,63 @@ set names latin1;
select @@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 @@query_prealloc_size = @test;
select @@query_prealloc_size = @test;
diff --git a/mysql-test/t/rpl_locale.test b/mysql-test/t/rpl_locale.test
new file mode 100644
index 00000000000..530a3d77636
--- /dev/null
+++ b/mysql-test/t/rpl_locale.test
@@ -0,0 +1,22 @@
+# 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
+
+
diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test
index 8322c0f84bd..808dc0973d4 100644
--- a/mysql-test/t/variables.test
+++ b/mysql-test/t/variables.test
@@ -397,6 +397,50 @@ set names latin1;
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
#
set @test = @@query_prealloc_size;