Merge with 4.0 to get:
Fix for storing negative values in decimal fields Fix for FLUSH TABLE with HANDLER BitKeeper/etc/ignore: auto-union libmysql_r/Makefile.am: Auto merged myisam/mi_check.c: Auto merged mysql-test/r/bigint.result: Auto merged mysql-test/r/user_var.result: Auto merged mysql-test/t/bigint.test: Auto merged mysql-test/t/user_var.test: Auto merged mysql-test/r/rpl_loaddata.result: Merge with 4.0 sql/item.cc: Merge with 4.0 to get fix for storing negative values in decimal fields sql/item.h: Merge with 4.0 to get fix for storing negative values in decimal fields sql/sql_handler.cc: Merge with 4.0 to get fix for FLUSH TABLE with HANDLER sql/sql_repl.cc: Merge with 4.0 sql/sql_select.cc: Used original file. (Comments moved to sql/sql_select.h)
This commit is contained in:
commit
411b610e71
@ -19,7 +19,7 @@
|
||||
|
||||
target = libmysqlclient_r.la
|
||||
target_defs = -DDONT_USE_RAID @LIB_EXTRA_CCFLAGS@
|
||||
## LIBS = @LIBS@
|
||||
LIBS = @LIBS@ @openssl_libs@
|
||||
|
||||
INCLUDES = @MT_INCLUDES@ -I$(top_srcdir)/include $(openssl_includes)
|
||||
|
||||
|
@ -1143,6 +1143,9 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info,
|
||||
}
|
||||
param->testflag|=T_REP; /* for easy checking */
|
||||
|
||||
if (info->s->options & (HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD))
|
||||
param->testflag|=T_CALC_CHECKSUM;
|
||||
|
||||
if (!param->using_global_keycache)
|
||||
VOID(init_key_cache(dflt_key_cache, param->key_cache_block_size,
|
||||
param->use_buffers, 0, 0));
|
||||
@ -1356,6 +1359,7 @@ err:
|
||||
VOID(my_close(new_file,MYF(0)));
|
||||
VOID(my_raid_delete(param->temp_filename,info->s->base.raid_chunks,
|
||||
MYF(MY_WME)));
|
||||
info->rec_cache.file=-1; /* don't flush data to new_file, it's closed */
|
||||
}
|
||||
mi_mark_crashed_on_repair(info);
|
||||
}
|
||||
@ -1812,6 +1816,9 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
|
||||
}
|
||||
param->testflag|=T_REP; /* for easy checking */
|
||||
|
||||
if (info->s->options & (HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD))
|
||||
param->testflag|=T_CALC_CHECKSUM;
|
||||
|
||||
bzero((char*)&sort_info,sizeof(sort_info));
|
||||
bzero((char *)&sort_param, sizeof(sort_param));
|
||||
if (!(sort_info.key_block=
|
||||
@ -2183,6 +2190,9 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
|
||||
}
|
||||
param->testflag|=T_REP; /* for easy checking */
|
||||
|
||||
if (info->s->options & (HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD))
|
||||
param->testflag|=T_CALC_CHECKSUM;
|
||||
|
||||
bzero((char*)&sort_info,sizeof(sort_info));
|
||||
if (!(sort_info.key_block=
|
||||
alloc_key_blocks(param,
|
||||
@ -2848,8 +2858,8 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param)
|
||||
if (!(to=mi_alloc_rec_buff(info,block_info.rec_len,
|
||||
&(sort_param->rec_buff))))
|
||||
{
|
||||
mi_check_print_error(param,"Not enough memory for blob at %s",
|
||||
llstr(sort_param->start_recpos,llbuff));
|
||||
mi_check_print_error(param,"Not enough memory for blob at %s (need %lu)",
|
||||
llstr(sort_param->start_recpos,llbuff), block_info.rec_len);
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
}
|
||||
|
@ -70,3 +70,11 @@ select * from t1 limit 9999999999;
|
||||
id a
|
||||
9999999999 1
|
||||
drop table t1;
|
||||
CREATE TABLE t1 ( quantity decimal(60,0));
|
||||
insert into t1 values (10000000000000000000);
|
||||
insert into t1 values ('10000000000000000000');
|
||||
select * from t1;
|
||||
quantity
|
||||
10000000000000000000
|
||||
10000000000000000000
|
||||
drop table t1;
|
||||
|
32
mysql-test/r/rpl_change_master.result
Normal file
32
mysql-test/r/rpl_change_master.result
Normal file
@ -0,0 +1,32 @@
|
||||
slave stop;
|
||||
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;
|
||||
slave start;
|
||||
select get_lock("a",5);
|
||||
get_lock("a",5)
|
||||
1
|
||||
create table t1(n int);
|
||||
insert into t1 values(1+get_lock("a",10)*0);
|
||||
insert into t1 values(2);
|
||||
stop slave;
|
||||
select * from t1;
|
||||
n
|
||||
1
|
||||
show slave status;
|
||||
Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
|
||||
127.0.0.1 root 9306 1 master-bin.001 273 slave-relay-bin.002 255 master-bin.001 No No 0 0 214 314
|
||||
change master to master_user='root';
|
||||
show slave status;
|
||||
Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
|
||||
127.0.0.1 root 9306 1 master-bin.001 214 slave-relay-bin.001 4 master-bin.001 No No 0 0 214 4
|
||||
select release_lock("a");
|
||||
release_lock("a")
|
||||
1
|
||||
start slave;
|
||||
select * from t1;
|
||||
n
|
||||
1
|
||||
2
|
||||
drop table t1;
|
@ -43,7 +43,7 @@ change master to master_user='test';
|
||||
change master to master_user='root';
|
||||
show slave status;
|
||||
Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master
|
||||
# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 1442 slave-relay-bin.000001 4 master-bin.000001 No No 0 0 1442 4 None 0 No #
|
||||
# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 1419 slave-relay-bin.000001 4 master-bin.000001 No No 0 0 1419 4 None 0 No #
|
||||
set global sql_slave_skip_counter=1;
|
||||
start slave;
|
||||
set sql_log_bin=0;
|
||||
|
@ -101,3 +101,22 @@ drop table t1;
|
||||
select @a:=10, @b:=2, @a>@b, @a:="10", @b:="2", @a>@b, @a:=10, @b:=2, @a>@b, @a:="10", @b:="2", @a>@b;
|
||||
@a:=10 @b:=2 @a>@b @a:="10" @b:="2" @a>@b @a:=10 @b:=2 @a>@b @a:="10" @b:="2" @a>@b
|
||||
10 2 1 10 2 1 10 2 1 10 2 1
|
||||
create table t1 (i int not null);
|
||||
insert t1 values (1),(2),(2),(3),(3),(3);
|
||||
select @a:=0;
|
||||
@a:=0
|
||||
0
|
||||
select @a, @a:=@a+count(*), count(*), @a from t1 group by i;
|
||||
@a @a:=@a+count(*) count(*) @a
|
||||
0 1 1 0
|
||||
0 2 2 0
|
||||
0 3 3 0
|
||||
select @a:=0;
|
||||
@a:=0
|
||||
0
|
||||
select @a+0, @a:=@a+0+count(*), count(*), @a+0 from t1 group by i;
|
||||
@a+0 @a:=@a+0+count(*) count(*) @a+0
|
||||
0 1 1 0
|
||||
1 3 2 0
|
||||
3 6 3 0
|
||||
drop table t1;
|
||||
|
@ -54,3 +54,15 @@ insert into t1 values (null,1);
|
||||
select * from t1;
|
||||
select * from t1 limit 9999999999;
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# Item_uint::save_to_field()
|
||||
# BUG#1845
|
||||
#
|
||||
|
||||
CREATE TABLE t1 ( quantity decimal(60,0));
|
||||
insert into t1 values (10000000000000000000);
|
||||
insert into t1 values ('10000000000000000000');
|
||||
select * from t1;
|
||||
drop table t1;
|
||||
|
||||
|
26
mysql-test/t/rpl_change_master.test
Normal file
26
mysql-test/t/rpl_change_master.test
Normal file
@ -0,0 +1,26 @@
|
||||
source include/master-slave.inc;
|
||||
|
||||
connection slave;
|
||||
select get_lock("a",5);
|
||||
connection master;
|
||||
create table t1(n int);
|
||||
insert into t1 values(1+get_lock("a",10)*0);
|
||||
insert into t1 values(2);
|
||||
save_master_pos;
|
||||
connection slave;
|
||||
sleep 3; # can't sync_with_master as we should be blocked
|
||||
stop slave;
|
||||
select * from t1;
|
||||
show slave status;
|
||||
change master to master_user='root';
|
||||
show slave status;
|
||||
# Will restart from after the values(2), which is bug
|
||||
select release_lock("a");
|
||||
start slave;
|
||||
sync_with_master;
|
||||
select * from t1;
|
||||
connection master;
|
||||
drop table t1;
|
||||
save_master_pos;
|
||||
connection slave;
|
||||
sync_with_master;
|
@ -60,3 +60,14 @@ drop table t1;
|
||||
|
||||
# just for fun :)
|
||||
select @a:=10, @b:=2, @a>@b, @a:="10", @b:="2", @a>@b, @a:=10, @b:=2, @a>@b, @a:="10", @b:="2", @a>@b;
|
||||
|
||||
#
|
||||
# bug#1739
|
||||
# Item_func_set_user_var sets update_query_id, Item_func_get_user_var checks it
|
||||
#
|
||||
create table t1 (i int not null);
|
||||
insert t1 values (1),(2),(2),(3),(3),(3);
|
||||
select @a:=0; select @a, @a:=@a+count(*), count(*), @a from t1 group by i;
|
||||
select @a:=0; select @a+0, @a:=@a+0+count(*), count(*), @a+0 from t1 group by i;
|
||||
drop table t1;
|
||||
|
||||
|
15
sql/item.cc
15
sql/item.cc
@ -1190,6 +1190,21 @@ int Item_string::save_in_field(Field *field, bool no_conversions)
|
||||
-1 : 0;
|
||||
}
|
||||
|
||||
int Item_uint::save_in_field(Field *field, bool no_conversions)
|
||||
{
|
||||
longlong nr= val_int();
|
||||
int res;
|
||||
|
||||
if (null_value)
|
||||
return set_field_to_null(field);
|
||||
field->set_notnull();
|
||||
if (nr < 0)
|
||||
res= field->store(ulonglong2double(nr);
|
||||
else
|
||||
res= field->store(nr);
|
||||
return res ? -1 : 0;
|
||||
}
|
||||
|
||||
|
||||
int Item_int::save_in_field(Field *field, bool no_conversions)
|
||||
{
|
||||
|
@ -404,6 +404,7 @@ public:
|
||||
double val() { return ulonglong2double((ulonglong)value); }
|
||||
String *val_str(String*);
|
||||
Item *new_item() { return new Item_uint(name,max_length); }
|
||||
int save_in_field(Field *field, bool no_conversions);
|
||||
bool fix_fields(THD *thd, struct st_table_list *list, Item **item)
|
||||
{
|
||||
bool res= Item::fix_fields(thd, list, item);
|
||||
|
@ -297,7 +297,20 @@ static TABLE **find_table_ptr_by_name(THD *thd, const char *db,
|
||||
!my_strcasecmp(system_charset_info,
|
||||
(is_alias ? table->table_name : table->real_name),
|
||||
table_name))
|
||||
{
|
||||
if (table->version != refresh_version)
|
||||
{
|
||||
VOID(pthread_mutex_lock(&LOCK_open));
|
||||
if (close_thread_table(thd, ptr))
|
||||
{
|
||||
/* Tell threads waiting for refresh that something has happened */
|
||||
VOID(pthread_cond_broadcast(&COND_refresh));
|
||||
}
|
||||
VOID(pthread_mutex_unlock(&LOCK_open));
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
ptr= &(table->next);
|
||||
}
|
||||
return ptr;
|
||||
|
@ -961,8 +961,8 @@ void kill_zombie_dump_threads(uint32 slave_server_id)
|
||||
int change_master(THD* thd, MASTER_INFO* mi)
|
||||
{
|
||||
int thread_mask;
|
||||
const char* errmsg=0;
|
||||
bool need_relay_log_purge=1;
|
||||
const char* errmsg= 0;
|
||||
bool need_relay_log_purge= 1;
|
||||
DBUG_ENTER("change_master");
|
||||
|
||||
lock_slave_threads(mi);
|
||||
@ -1055,6 +1055,36 @@ int change_master(THD* thd, MASTER_INFO* mi)
|
||||
mi->rli.group_relay_log_pos= mi->rli.event_relay_log_pos= lex_mi->relay_log_pos;
|
||||
}
|
||||
|
||||
/*
|
||||
If user did specify neither host nor port nor any log name nor any log
|
||||
pos, i.e. he specified only user/password/master_connect_retry, he probably
|
||||
wants replication to resume from where it had left, i.e. from the
|
||||
coordinates of the **SQL** thread (imagine the case where the I/O is ahead
|
||||
of the SQL; restarting from the coordinates of the I/O would lose some
|
||||
events which is probably unwanted when you are just doing minor changes
|
||||
like changing master_connect_retry).
|
||||
A side-effect is that if only the I/O thread was started, this thread may
|
||||
restart from ''/4 after the CHANGE MASTER. That's a minor problem (it is a
|
||||
much more unlikely situation than the one we are fixing here).
|
||||
Note: coordinates of the SQL thread must be read here, before the
|
||||
'if (need_relay_log_purge)' block which resets them.
|
||||
*/
|
||||
if (!lex_mi->host && !lex_mi->port &&
|
||||
!lex_mi->log_file_name && !lex_mi->pos &&
|
||||
need_relay_log_purge)
|
||||
{
|
||||
/*
|
||||
Sometimes mi->rli.master_log_pos == 0 (it happens when the SQL thread is
|
||||
not initialized), so we use a max().
|
||||
What happens to mi->rli.master_log_pos during the initialization stages
|
||||
of replication is not 100% clear, so we guard against problems using
|
||||
max().
|
||||
*/
|
||||
mi->master_log_pos = max(BIN_LOG_HEADER_SIZE, mi->rli.master_log_pos);
|
||||
strmake(mi->master_log_name,mi->rli.master_log_name,
|
||||
sizeof(mi->master_log_name)-1);
|
||||
}
|
||||
|
||||
flush_master_info(mi);
|
||||
if (need_relay_log_purge)
|
||||
{
|
||||
@ -1087,10 +1117,21 @@ int change_master(THD* thd, MASTER_INFO* mi)
|
||||
}
|
||||
mi->rli.group_master_log_pos = mi->master_log_pos;
|
||||
DBUG_PRINT("info", ("master_log_pos: %d", (ulong) mi->master_log_pos));
|
||||
/* If changing RELAY_LOG_FILE or RELAY_LOG_POS, this will be nonsense: */
|
||||
|
||||
/*
|
||||
Coordinates in rli were spoilt by the 'if (need_relay_log_purge)' block,
|
||||
so restore them to good values. If we left them to ''/0, that would work;
|
||||
but that would fail in the case of 2 successive CHANGE MASTER (without a
|
||||
START SLAVE in between): because first one would set the coords in mi to
|
||||
the good values of those in rli, the set those in rli to ''/0, then
|
||||
second CHANGE MASTER would set the coords in mi to those of rli, i.e. to
|
||||
''/0: we have lost all copies of the original good coordinates.
|
||||
That's why we always save good coords in rli.
|
||||
*/
|
||||
mi->rli.group_master_log_pos= mi->master_log_pos;
|
||||
strmake(mi->rli.group_master_log_name,mi->master_log_name,
|
||||
sizeof(mi->rli.group_master_log_name)-1);
|
||||
|
||||
if (!mi->rli.group_master_log_name[0]) // uninitialized case
|
||||
mi->rli.group_master_log_pos=0;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user