diff --git a/client/mysql.cc b/client/mysql.cc index 510420fdf3d..6b37bb7b6f5 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -2117,6 +2117,17 @@ com_go(String *buffer,char *line __attribute__((unused))) if (!mysql_num_rows(result) && ! quick && !info_flag) { strmov(buff, "Empty set"); + if (opt_xml) + { + /* + We must print XML header and footer + to produce a well-formed XML even if + the result set is empty (Bug#27608). + */ + init_pager(); + print_table_data_xml(result); + end_pager(); + } } else { diff --git a/mysql-test/r/bdb_notembedded.result b/mysql-test/r/bdb_notembedded.result new file mode 100644 index 00000000000..14cb5fad915 --- /dev/null +++ b/mysql-test/r/bdb_notembedded.result @@ -0,0 +1,35 @@ +set autocommit=1; +reset master; +create table bug16206 (a int); +insert into bug16206 values(1); +start transaction; +insert into bug16206 values(2); +commit; +show binlog events; +Log_name Pos Event_type Server_id End_log_pos Info +f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4 +f n Query 1 n use `test`; create table bug16206 (a int) +f n Query 1 n use `test`; insert into bug16206 values(1) +f n Query 1 n use `test`; insert into bug16206 values(2) +drop table bug16206; +reset master; +create table bug16206 (a int) engine= bdb; +insert into bug16206 values(0); +insert into bug16206 values(1); +start transaction; +insert into bug16206 values(2); +commit; +insert into bug16206 values(3); +show binlog events; +Log_name Pos Event_type Server_id End_log_pos Info +f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4 +f n Query 1 n use `test`; create table bug16206 (a int) engine= bdb +f n Query 1 n use `test`; insert into bug16206 values(0) +f n Query 1 n use `test`; insert into bug16206 values(1) +f n Query 1 n use `test`; BEGIN +f n Query 1 n use `test`; insert into bug16206 values(2) +f n Query 1 n use `test`; COMMIT +f n Query 1 n use `test`; insert into bug16206 values(3) +drop table bug16206; +set autocommit=0; +End of 5.0 tests diff --git a/mysql-test/r/client_xml.result b/mysql-test/r/client_xml.result index 6a148954fcd..ed5e8f2c1b8 100644 --- a/mysql-test/r/client_xml.result +++ b/mysql-test/r/client_xml.result @@ -71,4 +71,18 @@ insert into t1 values (1, 2, 'a&b ab'); + + + +-------------- +select 1 limit 0 +-------------- + + + + +Empty set + +Bye drop table t1; diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index 60010183d32..3d76f8e4a90 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -637,6 +637,37 @@ set lc_time_names=0; select @@lc_time_names; @@lc_time_names en_US +select @@global.lc_time_names, @@lc_time_names; +@@global.lc_time_names @@lc_time_names +en_US en_US +set @@global.lc_time_names=fr_FR; +select @@global.lc_time_names, @@lc_time_names; +@@global.lc_time_names @@lc_time_names +fr_FR en_US +New connection +select @@global.lc_time_names, @@lc_time_names; +@@global.lc_time_names @@lc_time_names +fr_FR fr_FR +set @@lc_time_names=ru_RU; +select @@global.lc_time_names, @@lc_time_names; +@@global.lc_time_names @@lc_time_names +fr_FR ru_RU +Returnung to default connection +select @@global.lc_time_names, @@lc_time_names; +@@global.lc_time_names @@lc_time_names +fr_FR en_US +set lc_time_names=default; +select @@global.lc_time_names, @@lc_time_names; +@@global.lc_time_names @@lc_time_names +fr_FR fr_FR +set @@global.lc_time_names=default; +select @@global.lc_time_names, @@lc_time_names; +@@global.lc_time_names @@lc_time_names +en_US fr_FR +set @@lc_time_names=default; +select @@global.lc_time_names, @@lc_time_names; +@@global.lc_time_names @@lc_time_names +en_US en_US set @test = @@query_prealloc_size; set @@query_prealloc_size = @test; select @@query_prealloc_size = @test; diff --git a/mysql-test/t/bdb_notembedded.test b/mysql-test/t/bdb_notembedded.test new file mode 100644 index 00000000000..24e64ebbfb2 --- /dev/null +++ b/mysql-test/t/bdb_notembedded.test @@ -0,0 +1,38 @@ +-- source include/not_embedded.inc +-- source include/have_bdb.inc + +# +# Bug #16206: Superfluous COMMIT event in binlog when updating BDB in autocommit mode +# +set autocommit=1; + +let $VERSION=`select version()`; + +reset master; +create table bug16206 (a int); +insert into bug16206 values(1); +start transaction; +insert into bug16206 values(2); +commit; +--replace_result $VERSION VERSION +--replace_column 1 f 2 n 5 n +show binlog events; +drop table bug16206; + +reset master; +create table bug16206 (a int) engine= bdb; +insert into bug16206 values(0); +insert into bug16206 values(1); +start transaction; +insert into bug16206 values(2); +commit; +insert into bug16206 values(3); +--replace_result $VERSION VERSION +--replace_column 1 f 2 n 5 n +show binlog events; +drop table bug16206; + +set autocommit=0; + + +--echo End of 5.0 tests diff --git a/mysql-test/t/client_xml.test b/mysql-test/t/client_xml.test index 017b7a1569a..8ee63a6131b 100644 --- a/mysql-test/t/client_xml.test +++ b/mysql-test/t/client_xml.test @@ -17,5 +17,7 @@ insert into t1 values (1, 2, 'a&b ab'); --exec $MYSQL --xml test -e "select 1 > 2 from dual" --exec $MYSQL --xml test -e "select 1 & 3 from dual" --exec $MYSQL --xml test -e "select null from dual" +--exec $MYSQL --xml test -e "select 1 limit 0" +--exec $MYSQL --xml test -vv -e "select 1 limit 0" drop table t1; diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index 697e55945ef..0ad85a32568 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -504,6 +504,30 @@ select @@lc_time_names; set lc_time_names=0; select @@lc_time_names; +# +# Bug #22648 LC_TIME_NAMES: Setting GLOBAL has no effect +# +select @@global.lc_time_names, @@lc_time_names; +set @@global.lc_time_names=fr_FR; +select @@global.lc_time_names, @@lc_time_names; +--echo New connection +connect (con1,localhost,root,,); +connection con1; +select @@global.lc_time_names, @@lc_time_names; +set @@lc_time_names=ru_RU; +select @@global.lc_time_names, @@lc_time_names; +disconnect con1; +connection default; +--echo Returnung to default connection +select @@global.lc_time_names, @@lc_time_names; +set lc_time_names=default; +select @@global.lc_time_names, @@lc_time_names; +set @@global.lc_time_names=default; +select @@global.lc_time_names, @@lc_time_names; +set @@lc_time_names=default; +select @@global.lc_time_names, @@lc_time_names; + + # # Bug #13334: query_prealloc_size default less than minimum # diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 39f115f6fd5..d1f05fcb741 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -149,6 +149,7 @@ typedef struct my_locale_st extern MY_LOCALE my_locale_en_US; extern MY_LOCALE *my_locales[]; +extern MY_LOCALE *my_default_lc_time_names; MY_LOCALE *my_locale_by_name(const char *name); MY_LOCALE *my_locale_by_number(uint number); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index b0fc5a30ff5..2a42af8450f 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -315,6 +315,7 @@ static char *mysqld_user, *mysqld_chroot, *log_error_file_ptr; static char *opt_init_slave, *language_ptr, *opt_init_connect; static char *default_character_set_name; static char *character_set_filesystem_name; +static char *lc_time_names_name; static char *my_bind_addr_str; static char *default_collation_name; static char compiled_default_collation_name[]= MYSQL_DEFAULT_COLLATION_NAME; @@ -495,6 +496,8 @@ CHARSET_INFO *system_charset_info, *files_charset_info ; CHARSET_INFO *national_charset_info, *table_alias_charset; CHARSET_INFO *character_set_filesystem; +MY_LOCALE *my_default_lc_time_names; + SHOW_COMP_OPTION have_isam; SHOW_COMP_OPTION have_raid, have_ssl, have_symlink, have_query_cache; SHOW_COMP_OPTION have_geometry, have_rtree_keys, have_dlopen; @@ -2826,6 +2829,14 @@ static int init_common_variables(const char *conf_file_name, int argc, return 1; global_system_variables.character_set_filesystem= character_set_filesystem; + if (!(my_default_lc_time_names= + my_locale_by_name(lc_time_names_name))) + { + sql_print_error("Unknown locale: '%s'", MYF(0), lc_time_names_name); + return 1; + } + global_system_variables.lc_time_names= my_default_lc_time_names; + sys_init_connect.value_length= 0; if ((sys_init_connect.value= opt_init_connect)) sys_init_connect.value_length= strlen(opt_init_connect); @@ -4749,6 +4760,7 @@ enum options_mysqld OPT_DEFAULT_COLLATION, OPT_CHARACTER_SET_CLIENT_HANDSHAKE, OPT_CHARACTER_SET_FILESYSTEM, + OPT_LC_TIME_NAMES, OPT_INIT_CONNECT, OPT_INIT_SLAVE, OPT_SECURE_AUTH, @@ -5078,6 +5090,11 @@ Disable with --skip-innodb-doublewrite.", (gptr*) &innobase_use_doublewrite, "Client error messages in given language. May be given as a full path.", (gptr*) &language_ptr, (gptr*) &language_ptr, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"lc-time-names", OPT_LC_TIME_NAMES, + "Set the language used for the month names and the days of the week.", + (gptr*) &lc_time_names_name, + (gptr*) &lc_time_names_name, + 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, {"local-infile", OPT_LOCAL_INFILE, "Enable/disable LOAD DATA LOCAL INFILE (takes values 1|0).", (gptr*) &opt_local_infile, @@ -6552,7 +6569,7 @@ static void mysql_init_variables(void) default_collation_name= compiled_default_collation_name; sys_charset_system.value= (char*) system_charset_info->csname; character_set_filesystem_name= (char*) "binary"; - + lc_time_names_name= (char*) "en_US"; /* Set default values for some option variables */ global_system_variables.table_type= DB_TYPE_MYISAM; diff --git a/sql/set_var.cc b/sql/set_var.cc index 46c2a775d8a..d4dcfafe522 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -2825,7 +2825,10 @@ bool sys_var_thd_lc_time_names::check(THD *thd, set_var *var) bool sys_var_thd_lc_time_names::update(THD *thd, set_var *var) { - thd->variables.lc_time_names= var->save_result.locale_value; + if (var->type == OPT_GLOBAL) + global_system_variables.lc_time_names= var->save_result.locale_value; + else + thd->variables.lc_time_names= var->save_result.locale_value; return 0; } @@ -2833,13 +2836,18 @@ bool sys_var_thd_lc_time_names::update(THD *thd, set_var *var) byte *sys_var_thd_lc_time_names::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) { - return (byte *)(thd->variables.lc_time_names->name); + return type == OPT_GLOBAL ? + (byte *) global_system_variables.lc_time_names->name : + (byte *) thd->variables.lc_time_names->name; } void sys_var_thd_lc_time_names::set_default(THD *thd, enum_var_type type) { - thd->variables.lc_time_names = &my_locale_en_US; + if (type == OPT_GLOBAL) + global_system_variables.lc_time_names= my_default_lc_time_names; + else + thd->variables.lc_time_names= global_system_variables.lc_time_names; } /* diff --git a/sql/sql_class.cc b/sql/sql_class.cc index a94f903a47b..6f3b7433860 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -343,7 +343,6 @@ void THD::init(void) total_warn_count= 0; update_charset(); bzero((char *) &status_var, sizeof(status_var)); - variables.lc_time_names = &my_locale_en_US; }