Commit 46a82c19 authored by unknown's avatar unknown

Merge romeo.(none):/home/bkroot/mysql-5.0-rpl

into  romeo.(none):/home/bk/merge-mysql-5.0


client/mysql.cc:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/set_var.cc:
  Auto merged
sql/slave.cc:
  Auto merged
sql/sql_class.cc:
  Auto merged
parents 4f3efddd ba95432e
......@@ -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
{
......
......@@ -71,4 +71,18 @@ insert into t1 values (1, 2, 'a&b a<b a>b');
<field name="NULL" xsi:nil="true" />
</row>
</resultset>
<?xml version="1.0"?>
<resultset statement="select 1 limit 0
" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"></resultset>
--------------
select 1 limit 0
--------------
<?xml version="1.0"?>
<resultset statement="select 1 limit 0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"></resultset>
Empty set
Bye
drop table t1;
......@@ -1480,6 +1480,49 @@ aa
xxx
yyy
DROP TABLE t1;
create table t1 (
a varchar(26) not null
) default character set utf8;
insert into t1 (a) values ('abcdefghijklmnopqrstuvwxyz');
select * from t1;
a
abcdefghijklmnopqrstuvwxyz
alter table t1 change a a varchar(20) character set utf8 not null;
Warnings:
Warning 1265 Data truncated for column 'a' at row 1
select * from t1;
a
abcdefghijklmnopqrst
alter table t1 change a a char(15) character set utf8 not null;
Warnings:
Warning 1265 Data truncated for column 'a' at row 1
select * from t1;
a
abcdefghijklmno
alter table t1 change a a char(10) character set utf8 not null;
Warnings:
Warning 1265 Data truncated for column 'a' at row 1
select * from t1;
a
abcdefghij
alter table t1 change a a varchar(5) character set utf8 not null;
Warnings:
Warning 1265 Data truncated for column 'a' at row 1
select * from t1;
a
abcde
drop table t1;
create table t1 (
a varchar(4000) not null
) default character set utf8;
insert into t1 values (repeat('a',4000));
alter table t1 change a a varchar(3000) character set utf8 not null;
Warnings:
Warning 1265 Data truncated for column 'a' at row 1
select length(a) from t1;
length(a)
3000
drop table t1;
set names utf8;
select hex(char(1 using utf8));
hex(char(1 using utf8))
......
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 (data LONGBLOB) ENGINE=MYISAM;
CREATE TABLE t2 (data LONGBLOB) ENGINE=MYISAM;
INSERT INTO t1 (data) VALUES (repeat('a',1024*1024));
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t2 SELECT * FROM t1;
KILL QUERY 2;
SELECT COUNT(*) FROM t2;
COUNT(*)
0
SHOW SLAVE STATUS;
Slave_IO_State #
Master_Host 127.0.0.1
Master_User root
Master_Port MASTER_PORT
Connect_Retry 1
Master_Log_File master-bin.000001
Read_Master_Log_Pos #
Relay_Log_File #
Relay_Log_Pos #
Relay_Master_Log_File master-bin.000001
Slave_IO_Running Yes
Slave_SQL_Running No
Replicate_Do_DB
Replicate_Ignore_DB
Replicate_Do_Table
Replicate_Ignore_Table
Replicate_Wild_Do_Table
Replicate_Wild_Ignore_Table
Last_Errno 1317
Last_Error #
Skip_Counter 0
Exec_Master_Log_Pos #
Relay_Log_Space #
Until_Condition None
Until_Log_File
Until_Log_Pos 0
Master_SSL_Allowed No
Master_SSL_CA_File
Master_SSL_CA_Path
Master_SSL_Cert
Master_SSL_Cipher
Master_SSL_Key
Seconds_Behind_Master #
......@@ -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;
......
......@@ -17,5 +17,7 @@ insert into t1 values (1, 2, 'a&b a<b a>b');
--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;
......@@ -1192,6 +1192,41 @@ SELECT DISTINCT id FROM t1 ORDER BY id;
DROP TABLE t1;
#
# Bug#20095 Changing length of VARCHAR field with UTF8
# collation does not truncate values
#
create table t1 (
a varchar(26) not null
) default character set utf8;
insert into t1 (a) values ('abcdefghijklmnopqrstuvwxyz');
select * from t1;
# varchar to varchar
alter table t1 change a a varchar(20) character set utf8 not null;
select * from t1;
# varchar to char
alter table t1 change a a char(15) character set utf8 not null;
select * from t1;
# char to char
alter table t1 change a a char(10) character set utf8 not null;
select * from t1;
# char to varchar
alter table t1 change a a varchar(5) character set utf8 not null;
select * from t1;
drop table t1;
#
# Check that do_varstring2_mb produces a warning
#
create table t1 (
a varchar(4000) not null
) default character set utf8;
insert into t1 values (repeat('a',4000));
alter table t1 change a a varchar(3000) character set utf8 not null;
select length(a) from t1;
drop table t1;
#
# Bug#10504: Character set does not support traditional mode
# Bug#14146: CHAR(...USING ...) and CONVERT(CHAR(...) USING...)
......
# Test for BUG#26551
#
# This test is unfortunately very fragile and very dependent on the
# load of the computer. The test is therefore disabled normally. It is
# entered here to demonstrate how to check that the bug is actually
# solved.
--echo Turn on parsing to run this test
disable_parsing;
source include/master-slave.inc;
connection master;
CREATE TABLE t1 (data LONGBLOB) ENGINE=MYISAM;
CREATE TABLE t2 (data LONGBLOB) ENGINE=MYISAM;
INSERT INTO t1 (data) VALUES (repeat('a',1024*1024));
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
sync_slave_with_master;
connection master;
send INSERT INTO t2 SELECT * FROM t1;
connection master1;
# This sleep is picked so that the query above has started to insert
# some rows into t2. If it hasn't the slave will not stop below.
sleep 4;
# SHOW PROCESSLIST;
# Code for the 5.1 server to get the thread id of the thread executing
# the query above.
#
#SET @id = 0;
#SELECT id INTO @id
# FROM information_schema.processlist
# WHERE info LIKE 'INSERT INTO t2%';
# This is the connection that is executing the INSERT INTO t2...
KILL QUERY 2;
connection slave;
# Here the slave will only stop if the query above actually started
# inserting some rows into t2. Otherwise, it will hang forever.
wait_for_slave_to_stop;
# The following should be 0
SELECT COUNT(*) FROM t2;
# ... and there the error code should be 1317 (ER_QUERY_INTERRUPTED)
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 7 # 8 # 9 # 20 # 22 # 23 # 33 #
query_vertical SHOW SLAVE STATUS;
enable_parsing;
......@@ -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
#
......
......@@ -434,6 +434,26 @@ static void do_varstring1(Copy_field *copy)
}
static void do_varstring1_mb(Copy_field *copy)
{
int well_formed_error;
CHARSET_INFO *cs= copy->from_field->charset();
uint from_length= (uint) *(uchar*) copy->from_ptr;
const char *from_ptr= copy->from_ptr + 1;
uint to_char_length= (copy->to_length - 1) / cs->mbmaxlen;
uint length= cs->cset->well_formed_len(cs, from_ptr, from_ptr + from_length,
to_char_length, &well_formed_error);
if (length < from_length)
{
if (current_thd->count_cuted_fields)
copy->to_field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
WARN_DATA_TRUNCATED, 1);
}
*(uchar*) copy->to_ptr= (uchar) length;
memcpy(copy->to_ptr + 1, from_ptr, length);
}
static void do_varstring2(Copy_field *copy)
{
uint length=uint2korr(copy->from_ptr);
......@@ -459,6 +479,12 @@ static void do_varstring2_mb(Copy_field *copy)
const char *from_beg= copy->from_ptr + HA_KEY_BLOB_LENGTH;
uint length= cs->cset->well_formed_len(cs, from_beg, from_beg + from_length,
char_length, &well_formed_error);
if (length < from_length)
{
if (current_thd->count_cuted_fields)
copy->to_field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
WARN_DATA_TRUNCATED, 1);
}
int2store(copy->to_ptr, length);
memcpy(copy->to_ptr+HA_KEY_BLOB_LENGTH, from_beg, length);
}
......@@ -634,8 +660,10 @@ void (*Copy_field::get_copy_func(Field *to,Field *from))(Copy_field*)
return do_field_string;
if (to_length != from_length)
return (((Field_varstring*) to)->length_bytes == 1 ?
do_varstring1 : (from->charset()->mbmaxlen == 1 ?
do_varstring2 : do_varstring2_mb));
(from->charset()->mbmaxlen == 1 ? do_varstring1 :
do_varstring1_mb) :
(from->charset()->mbmaxlen == 1 ? do_varstring2 :
do_varstring2_mb));
}
else if (to_length < from_length)
return (from->charset()->mbmaxlen == 1 ?
......
......@@ -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);
......
......@@ -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'", 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;
......
......@@ -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;
}
/*
......
......@@ -3099,6 +3099,7 @@ int check_expected_error(THD* thd, RELAY_LOG_INFO* rli, int expected_error)
switch (expected_error) {
case ER_NET_READ_ERROR:
case ER_NET_ERROR_ON_WRITE:
case ER_QUERY_INTERRUPTED:
case ER_SERVER_SHUTDOWN:
case ER_NEW_ABORTING_CONNECTION:
return 1;
......
......@@ -344,7 +344,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;
}
......
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