Commit 234e5562 authored by lars/lthalmann@dl145h.mysql.com's avatar lars/lthalmann@dl145h.mysql.com

Merge mysql.com:/nfsdisk1/lars/bkroot/mysql-5.1-new-rpl

into  mysql.com:/nfsdisk1/lars/MERGE/mysql-5.1-merge
parents 7d6f639d 11c9a13a
...@@ -380,7 +380,7 @@ select ...@@ -380,7 +380,7 @@ select
@a like "%#%error_code=0%ROLLBACK/*!*/;%ROLLBACK /* added by mysqlbinlog */;%" @a not like "%#%error_code=%error_code=%" @a like "%#%error_code=0%ROLLBACK/*!*/;%ROLLBACK /* added by mysqlbinlog */;%" @a not like "%#%error_code=%error_code=%"
1 1 1 1
drop table t1, t2; drop table t1, t2;
create table tt (a int unique); create temporary table tt (a int unique);
create table ti (a int) engine=innodb; create table ti (a int) engine=innodb;
reset master; reset master;
show master status; show master status;
...@@ -399,18 +399,18 @@ count(*) ...@@ -399,18 +399,18 @@ count(*)
show master status; show master status;
File Position Binlog_Do_DB Binlog_Ignore_DB File Position Binlog_Do_DB Binlog_Ignore_DB
master-bin.000001 515 master-bin.000001 515
show binlog events from 106; show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query 1 # use `test`; BEGIN master-bin.000001 # Query # # use `test`; BEGIN
master-bin.000001 # Query 1 # use `test`; insert into ti values (1) master-bin.000001 # Query # # use `test`; insert into ti values (1)
master-bin.000001 # Query 1 # use `test`; insert into ti values (2) master-bin.000001 # Query # # use `test`; insert into ti values (2)
master-bin.000001 # Query 1 # use `test`; insert into tt select * from ti master-bin.000001 # Query # # use `test`; insert into tt select * from ti
master-bin.000001 # Query 1 # use `test`; ROLLBACK master-bin.000001 # Query # # use `test`; ROLLBACK
select count(*) from ti /* zero */; select count(*) from ti /* zero */;
count(*) count(*)
0 0
insert into ti select * from tt; insert into ti select * from tt;
select * from ti /* that is what slave would miss - a bug */; select * from ti /* that is what slave would miss - bug#28960 */;
a a
1 1
2 2
...@@ -431,13 +431,13 @@ Warning 1196 Some non-transactional changed tables couldn't be rolled back ...@@ -431,13 +431,13 @@ Warning 1196 Some non-transactional changed tables couldn't be rolled back
show master status; show master status;
File Position Binlog_Do_DB Binlog_Ignore_DB File Position Binlog_Do_DB Binlog_Ignore_DB
master-bin.000001 589 master-bin.000001 589
show binlog events from 106; show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query 1 # use `test`; BEGIN master-bin.000001 # Query # # use `test`; BEGIN
master-bin.000001 # Query 1 # use `test`; insert into ti values (1) master-bin.000001 # Query # # use `test`; insert into ti values (1)
master-bin.000001 # Query 1 # use `test`; insert into ti values (2) /* to make the dup error in the following */ master-bin.000001 # Query # # use `test`; insert into ti values (2) /* to make the dup error in the following */
master-bin.000001 # Query 1 # use `test`; insert into tt select * from ti /* one affected and error */ master-bin.000001 # Query # # use `test`; insert into tt select * from ti /* one affected and error */
master-bin.000001 # Query 1 # use `test`; ROLLBACK master-bin.000001 # Query # # use `test`; ROLLBACK
select count(*) from ti /* zero */; select count(*) from ti /* zero */;
count(*) count(*)
0 0
...@@ -446,7 +446,7 @@ select * from tt /* that is what otherwise slave missed - the bug */; ...@@ -446,7 +446,7 @@ select * from tt /* that is what otherwise slave missed - the bug */;
a a
1 1
2 2
drop table ti,tt; drop table ti;
drop function if exists bug27417; drop function if exists bug27417;
drop table if exists t1,t2; drop table if exists t1,t2;
CREATE TABLE t1 (a int NOT NULL auto_increment primary key) ENGINE=MyISAM; CREATE TABLE t1 (a int NOT NULL auto_increment primary key) ENGINE=MyISAM;
...@@ -463,6 +463,11 @@ insert into t2 select bug27417(2); ...@@ -463,6 +463,11 @@ insert into t2 select bug27417(2);
reset master; reset master;
insert into t2 values (bug27417(2)); insert into t2 values (bug27417(2));
ERROR 23000: Duplicate entry '2' for key 'PRIMARY' ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Table_map # # table_id: # (test.t2)
master-bin.000001 # Table_map # # table_id: # (test.t1)
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
select count(*) from t1 /* must be 3 */; select count(*) from t1 /* must be 3 */;
count(*) count(*)
3 3
...@@ -474,6 +479,11 @@ delete from t2 where a=bug27417(3); ...@@ -474,6 +479,11 @@ delete from t2 where a=bug27417(3);
select count(*) from t2 /* nothing got deleted */; select count(*) from t2 /* nothing got deleted */;
count(*) count(*)
2 2
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Table_map # # table_id: # (test.t2)
master-bin.000001 # Table_map # # table_id: # (test.t1)
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
select count(*) from t1 /* must be 5 */; select count(*) from t1 /* must be 5 */;
count(*) count(*)
5 5
...@@ -482,6 +492,95 @@ affected rows: 0 ...@@ -482,6 +492,95 @@ affected rows: 0
select count(*) from t1 /* must be 7 */; select count(*) from t1 /* must be 7 */;
count(*) count(*)
7 7
drop function bug27417;
drop table t1,t2; drop table t1,t2;
CREATE TABLE t1 (a int NOT NULL auto_increment primary key) ENGINE=MyISAM;
CREATE TABLE t2 (a int, PRIMARY KEY (a)) ENGINE=InnoDB;
CREATE TABLE t3 (a int, PRIMARY KEY (a), b int unique);
insert into t2 values (1);
reset master;
insert into t2 values (bug27417(1));
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Table_map # # table_id: # (test.t2)
master-bin.000001 # Table_map # # table_id: # (test.t1)
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Query # # use `test`; ROLLBACK
select count(*) from t1 /* must be 1 */;
count(*)
1
delete from t1;
delete from t2;
insert into t2 values (2);
reset master;
insert into t2 select bug27417(1) union select bug27417(2);
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Table_map # # table_id: # (test.t2)
master-bin.000001 # Table_map # # table_id: # (test.t1)
master-bin.000001 # Write_rows # # table_id: #
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Query # # use `test`; ROLLBACK
select count(*) from t1 /* must be 2 */;
count(*)
2
delete from t1;
insert into t3 values (1,1),(2,3),(3,4);
reset master;
update t3 set b=b+bug27417(1);
ERROR 23000: Duplicate entry '4' for key 'b'
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Table_map # # table_id: # (test.t3)
master-bin.000001 # Table_map # # table_id: # (test.t1)
master-bin.000001 # Write_rows # # table_id: #
master-bin.000001 # Update_rows # # table_id: #
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
select count(*) from t1 /* must be 2 */;
count(*)
2
delete from t1;
delete from t2;
delete from t3;
insert into t2 values (1);
insert into t3 values (1,1);
create trigger trg_del before delete on t2 for each row
insert into t3 values (bug27417(1), 2);
reset master;
delete from t2;
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Table_map # # table_id: # (test.t2)
master-bin.000001 # Table_map # # table_id: # (test.t3)
master-bin.000001 # Table_map # # table_id: # (test.t1)
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Query # # use `test`; ROLLBACK
select count(*) from t1 /* must be 1 */;
count(*)
1
delete from t1;
create table t4 (a int default 0, b int primary key) engine=innodb;
insert into t4 values (0, 17);
reset master;
load data infile '../std_data_ln/rpl_loaddata.dat' into table t4 (a, @b) set b= @b + bug27417(2);
ERROR 23000: Duplicate entry '17' for key 'PRIMARY'
select * from t4;
a b
0 17
select count(*) from t1 /* must be 2 */;
count(*)
2
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Table_map # # table_id: # (test.t4)
master-bin.000001 # Table_map # # table_id: # (test.t1)
master-bin.000001 # Write_rows # # table_id: #
master-bin.000001 # Write_rows # # table_id: #
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Query # # use `test`; ROLLBACK
drop trigger trg_del;
drop table t1,t2,t3,t4;
drop function bug27417;
end of tests end of tests
...@@ -36,7 +36,7 @@ drop table t1, t2; ...@@ -36,7 +36,7 @@ drop table t1, t2;
# prepare # prepare
create table tt (a int unique); create temporary table tt (a int unique);
create table ti (a int) engine=innodb; create table ti (a int) engine=innodb;
reset master; reset master;
show master status; show master status;
...@@ -53,11 +53,10 @@ rollback; ...@@ -53,11 +53,10 @@ rollback;
select count(*) from tt /* 2 */; select count(*) from tt /* 2 */;
show master status; show master status;
--replace_column 2 # 5 # source include/show_binlog_events.inc;
show binlog events from 106;
select count(*) from ti /* zero */; select count(*) from ti /* zero */;
insert into ti select * from tt; insert into ti select * from tt;
select * from ti /* that is what slave would miss - a bug */; select * from ti /* that is what slave would miss - bug#28960 */;
## send_error() branch ## send_error() branch
...@@ -78,13 +77,12 @@ rollback; ...@@ -78,13 +77,12 @@ rollback;
# check # check
show master status; show master status;
--replace_column 2 # 5 # source include/show_binlog_events.inc;
show binlog events from 106;
select count(*) from ti /* zero */; select count(*) from ti /* zero */;
insert into ti select * from tt; insert into ti select * from tt;
select * from tt /* that is what otherwise slave missed - the bug */; select * from tt /* that is what otherwise slave missed - the bug */;
drop table ti,tt; drop table ti;
# #
...@@ -122,17 +120,15 @@ insert into t2 select bug27417(2); ...@@ -122,17 +120,15 @@ insert into t2 select bug27417(2);
reset master; reset master;
--error ER_DUP_ENTRY --error ER_DUP_ENTRY
insert into t2 values (bug27417(2)); insert into t2 values (bug27417(2));
#TODO: Andrei: enable this test after 23333 is pushed source include/show_binlog_events.inc; #only (!) with fixes for #23333 will show there is the query
#show master status; /* only (!) with fixes for #23333 will show there is the query */;
select count(*) from t1 /* must be 3 */; select count(*) from t1 /* must be 3 */;
reset master; reset master;
select count(*) from t2; select count(*) from t2;
delete from t2 where a=bug27417(3); delete from t2 where a=bug27417(3);
select count(*) from t2 /* nothing got deleted */; select count(*) from t2 /* nothing got deleted */;
#TODO: Andrei: enable this test after 23333 is pushed source include/show_binlog_events.inc; # the query must be in regardless of #23333
#show master status; /* the query must be in regardless of #23333 */;
select count(*) from t1 /* must be 5 */; select count(*) from t1 /* must be 5 */;
--enable_info --enable_info
...@@ -140,7 +136,125 @@ delete t2 from t2 where t2.a=bug27417(100) /* must not affect t2 */; ...@@ -140,7 +136,125 @@ delete t2 from t2 where t2.a=bug27417(100) /* must not affect t2 */;
--disable_info --disable_info
select count(*) from t1 /* must be 7 */; select count(*) from t1 /* must be 7 */;
drop function bug27417; # function bug27417 remains for the following testing of bug#23333
drop table t1,t2; drop table t1,t2;
#
# Bug#23333 using the patch (and the test) for bug#27471
# throughout the bug tests
# t1 - non-trans side effects gatherer;
# t2 - transactional table;
#
CREATE TABLE t1 (a int NOT NULL auto_increment primary key) ENGINE=MyISAM;
CREATE TABLE t2 (a int, PRIMARY KEY (a)) ENGINE=InnoDB;
CREATE TABLE t3 (a int, PRIMARY KEY (a), b int unique);
#
# INSERT
#
# prepare
insert into t2 values (1);
reset master;
# execute
--error ER_DUP_ENTRY
insert into t2 values (bug27417(1));
# check
source include/show_binlog_events.inc; # must be event of the query
select count(*) from t1 /* must be 1 */;
#
# INSERT SELECT
#
# prepare
delete from t1;
delete from t2;
insert into t2 values (2);
reset master;
# execute
--error ER_DUP_ENTRY
insert into t2 select bug27417(1) union select bug27417(2);
# check
source include/show_binlog_events.inc; # must be events of the query
select count(*) from t1 /* must be 2 */;
#
# UPDATE (multi-update see bug#27716)
#
# prepare
delete from t1;
insert into t3 values (1,1),(2,3),(3,4);
reset master;
# execute
--error ER_DUP_ENTRY
update t3 set b=b+bug27417(1);
# check
source include/show_binlog_events.inc; # must be events of the query
select count(*) from t1 /* must be 2 */;
#
# DELETE (for multi-delete see Bug #29136)
#
# prepare
delete from t1;
delete from t2;
delete from t3;
insert into t2 values (1);
insert into t3 values (1,1);
create trigger trg_del before delete on t2 for each row
insert into t3 values (bug27417(1), 2);
reset master;
# execute
--error ER_DUP_ENTRY
delete from t2;
# check
source include/show_binlog_events.inc; # must be events of the query
select count(*) from t1 /* must be 1 */;
#
# LOAD DATA
#
# prepare
delete from t1;
create table t4 (a int default 0, b int primary key) engine=innodb;
insert into t4 values (0, 17);
reset master;
# execute
--error ER_DUP_ENTRY
load data infile '../std_data_ln/rpl_loaddata.dat' into table t4 (a, @b) set b= @b + bug27417(2);
# check
select * from t4;
select count(*) from t1 /* must be 2 */;
source include/show_binlog_events.inc; # must be events of the query
#
# bug#23333 cleanup
#
drop trigger trg_del;
drop table t1,t2,t3,t4;
drop function bug27417;
--echo end of tests --echo end of tests
...@@ -27,6 +27,42 @@ STOP SLAVE; ...@@ -27,6 +27,42 @@ STOP SLAVE;
START SLAVE; START SLAVE;
CREATE TABLe `t1` (`f1` LONGTEXT) ENGINE=MyISAM; CREATE TABLe `t1` (`f1` LONGTEXT) ENGINE=MyISAM;
INSERT INTO `t1`(`f1`) VALUES ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa2048');
SHOW STATUS LIKE 'Slave_running'; show slave status;
Variable_name Value Slave_IO_State #
Slave_running OFF Master_Host 127.0.0.1
Master_User root
Master_Port MASTER_MYPORT
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 No
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 0
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_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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa2048');
# The slave I/O thread must stop after trying to read the above event # The slave I/O thread must stop after trying to read the above event
connection slave; connection slave;
--source include/wait_for_slave_io_to_stop.inc --source include/wait_for_slave_io_to_stop.inc
SHOW STATUS LIKE 'Slave_running'; --replace_result $MASTER_MYPORT MASTER_MYPORT
# import is only the 11th column Slave_IO_Running
# cleanup --replace_column 1 # 7 # 8 # 9 # 12 # 22 # 23 # 33 #
#connection master; query_vertical show slave status;
#drop table t1;
#connection slave;
#drop table t1;
# End of tests # End of tests
...@@ -6732,6 +6732,7 @@ const uint Field_varstring::MAX_SIZE= UINT_MAX16; ...@@ -6732,6 +6732,7 @@ const uint Field_varstring::MAX_SIZE= UINT_MAX16;
int Field_varstring::do_save_field_metadata(uchar *metadata_ptr) int Field_varstring::do_save_field_metadata(uchar *metadata_ptr)
{ {
char *ptr= (char *)metadata_ptr; char *ptr= (char *)metadata_ptr;
DBUG_ASSERT(field_length <= 65535);
int2store(ptr, field_length); int2store(ptr, field_length);
return 2; return 2;
} }
......
...@@ -6469,6 +6469,16 @@ void Rows_log_event::print_helper(FILE *file, ...@@ -6469,6 +6469,16 @@ void Rows_log_event::print_helper(FILE *file,
data) in the table map are initialized as zero (0). The array size is the data) in the table map are initialized as zero (0). The array size is the
same as the columns for the table on the slave. same as the columns for the table on the slave.
Additionally, values saved for field metadata on the master are saved as a
string of bytes (uchar) in the binlog. A field may require 1 or more bytes
to store the information. In cases where values require multiple bytes
(e.g. values > 255), the endian-safe methods are used to properly encode
the values on the master and decode them on the slave. When the field
metadata values are captured on the slave, they are stored in an array of
type uint16. This allows the least number of casts to prevent casting bugs
when the field metadata is used in comparisons of field attributes. When
the field metadata is used for calculating addresses in pointer math, the
type used is uint32.
*/ */
/** /**
......
...@@ -31,31 +31,34 @@ uint32 table_def::calc_field_size(uint col, uchar *master_data) const ...@@ -31,31 +31,34 @@ uint32 table_def::calc_field_size(uint col, uchar *master_data) const
switch (type(col)) { switch (type(col)) {
case MYSQL_TYPE_NEWDECIMAL: case MYSQL_TYPE_NEWDECIMAL:
length= my_decimal_get_binary_size(m_field_metadata[col] >> 8, length= my_decimal_get_binary_size(m_field_metadata[col] >> 8,
m_field_metadata[col] - ((m_field_metadata[col] >> 8) << 8)); m_field_metadata[col] & 0xff);
break; break;
case MYSQL_TYPE_DECIMAL: case MYSQL_TYPE_DECIMAL:
case MYSQL_TYPE_FLOAT: case MYSQL_TYPE_FLOAT:
case MYSQL_TYPE_DOUBLE: case MYSQL_TYPE_DOUBLE:
length= m_field_metadata[col]; length= m_field_metadata[col];
break; break;
/*
The cases for SET and ENUM are include for completeness, however
both are mapped to type MYSQL_TYPE_STRING and their real types
are encoded in the field metadata.
*/
case MYSQL_TYPE_SET: case MYSQL_TYPE_SET:
case MYSQL_TYPE_ENUM: case MYSQL_TYPE_ENUM:
case MYSQL_TYPE_STRING: case MYSQL_TYPE_STRING:
{ {
if (((m_field_metadata[col] & 0xff00) == (MYSQL_TYPE_SET << 8)) || uchar type= m_field_metadata[col] >> 8U;
((m_field_metadata[col] & 0xff00) == (MYSQL_TYPE_ENUM << 8))) if ((type == MYSQL_TYPE_SET) || (type == MYSQL_TYPE_ENUM))
length= m_field_metadata[col] & 0x00ff; length= m_field_metadata[col] & 0x00ff;
else else
{ {
length= m_field_metadata[col] & 0x00ff; /*
DBUG_ASSERT(length > 0); We are reading the actual size from the master_data record
if (length > 255) because this field has the actual lengh stored in the first
{ byte.
DBUG_ASSERT(uint2korr(master_data) > 0); */
length= uint2korr(master_data) + 2; length= (uint) *master_data + 1;
} DBUG_ASSERT(length != 0);
else
length= (uint) *master_data + 1;
} }
break; break;
} }
...@@ -95,6 +98,13 @@ uint32 table_def::calc_field_size(uint col, uchar *master_data) const ...@@ -95,6 +98,13 @@ uint32 table_def::calc_field_size(uint col, uchar *master_data) const
break; break;
case MYSQL_TYPE_BIT: case MYSQL_TYPE_BIT:
{ {
/*
Decode the size of the bit field from the master.
from_len is the length in bytes from the master
from_bit_len is the number of extra bits stored in the master record
If from_bit_len is not 0, add 1 to the length to account for accurate
number of bytes needed.
*/
uint from_len= (m_field_metadata[col] >> 8U) & 0x00ff; uint from_len= (m_field_metadata[col] >> 8U) & 0x00ff;
uint from_bit_len= m_field_metadata[col] & 0x00ff; uint from_bit_len= m_field_metadata[col] & 0x00ff;
DBUG_ASSERT(from_bit_len <= 7); DBUG_ASSERT(from_bit_len <= 7);
...@@ -136,7 +146,7 @@ uint32 table_def::calc_field_size(uint col, uchar *master_data) const ...@@ -136,7 +146,7 @@ uint32 table_def::calc_field_size(uint col, uchar *master_data) const
length= *master_data; length= *master_data;
break; break;
case 2: case 2:
length= sint2korr(master_data); length= uint2korr(master_data);
break; break;
case 3: case 3:
length= uint3korr(master_data); length= uint3korr(master_data);
......
...@@ -99,7 +99,7 @@ class table_def ...@@ -99,7 +99,7 @@ class table_def
/* /*
These types store a single byte. These types store a single byte.
*/ */
m_field_metadata[i]= (uchar)field_metadata[index]; m_field_metadata[i]= field_metadata[index];
index++; index++;
break; break;
} }
...@@ -107,14 +107,14 @@ class table_def ...@@ -107,14 +107,14 @@ class table_def
case MYSQL_TYPE_ENUM: case MYSQL_TYPE_ENUM:
case MYSQL_TYPE_STRING: case MYSQL_TYPE_STRING:
{ {
short int x= field_metadata[index++] << 8U; // real_type uint16 x= field_metadata[index++] << 8U; // real_type
x = x + field_metadata[index++]; // pack or field length x+= field_metadata[index++]; // pack or field length
m_field_metadata[i]= x; m_field_metadata[i]= x;
break; break;
} }
case MYSQL_TYPE_BIT: case MYSQL_TYPE_BIT:
{ {
short int x= field_metadata[index++]; uint16 x= field_metadata[index++];
x = x + (field_metadata[index++] << 8U); x = x + (field_metadata[index++] << 8U);
m_field_metadata[i]= x; m_field_metadata[i]= x;
break; break;
...@@ -125,14 +125,14 @@ class table_def ...@@ -125,14 +125,14 @@ class table_def
These types store two bytes. These types store two bytes.
*/ */
char *ptr= (char *)&field_metadata[index]; char *ptr= (char *)&field_metadata[index];
m_field_metadata[i]= sint2korr(ptr); m_field_metadata[i]= uint2korr(ptr);
index= index + 2; index= index + 2;
break; break;
} }
case MYSQL_TYPE_NEWDECIMAL: case MYSQL_TYPE_NEWDECIMAL:
{ {
short int x= field_metadata[index++] << 8U; // precision uint16 x= field_metadata[index++] << 8U; // precision
x = x + field_metadata[index++]; // decimals x+= field_metadata[index++]; // decimals
m_field_metadata[i]= x; m_field_metadata[i]= x;
break; break;
} }
......
...@@ -345,7 +345,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ...@@ -345,7 +345,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
thd->transaction.stmt.modified_non_trans_table= TRUE; thd->transaction.stmt.modified_non_trans_table= TRUE;
/* See similar binlogging code in sql_update.cc, for comments */ /* See similar binlogging code in sql_update.cc, for comments */
if ((error < 0) || (deleted && !transactional_table)) if ((error < 0) || thd->transaction.stmt.modified_non_trans_table)
{ {
if (mysql_bin_log.is_open()) if (mysql_bin_log.is_open())
{ {
...@@ -862,7 +862,8 @@ bool multi_delete::send_eof() ...@@ -862,7 +862,8 @@ bool multi_delete::send_eof()
{ {
query_cache_invalidate3(thd, delete_tables, 1); query_cache_invalidate3(thd, delete_tables, 1);
} }
if ((local_error == 0) || (deleted && normal_tables)) DBUG_ASSERT(!normal_tables || !deleted || thd->transaction.stmt.modified_non_trans_table);
if ((local_error == 0) || thd->transaction.stmt.modified_non_trans_table)
{ {
if (mysql_bin_log.is_open()) if (mysql_bin_log.is_open())
{ {
...@@ -879,7 +880,6 @@ bool multi_delete::send_eof() ...@@ -879,7 +880,6 @@ bool multi_delete::send_eof()
if (thd->transaction.stmt.modified_non_trans_table) if (thd->transaction.stmt.modified_non_trans_table)
thd->transaction.all.modified_non_trans_table= TRUE; thd->transaction.all.modified_non_trans_table= TRUE;
} }
DBUG_ASSERT(!normal_tables || !deleted || thd->transaction.stmt.modified_non_trans_table);
/* Commit or rollback the current SQL statement */ /* Commit or rollback the current SQL statement */
if (transactional_tables) if (transactional_tables)
......
...@@ -839,59 +839,58 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, ...@@ -839,59 +839,58 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
} }
transactional_table= table->file->has_transactions(); transactional_table= table->file->has_transactions();
if ((changed= (info.copied || info.deleted || info.updated)) || if ((changed= (info.copied || info.deleted || info.updated)))
was_insert_delayed)
{ {
/* /*
Invalidate the table in the query cache if something changed. Invalidate the table in the query cache if something changed.
For the transactional algorithm to work the invalidation must be For the transactional algorithm to work the invalidation must be
before binlog writing and ha_autocommit_or_rollback before binlog writing and ha_autocommit_or_rollback
*/ */
if (changed) query_cache_invalidate3(thd, table_list, 1);
query_cache_invalidate3(thd, table_list, 1); }
if (error <= 0 || !transactional_table) if (changed && error <= 0 || thd->transaction.stmt.modified_non_trans_table
|| was_insert_delayed)
{
if (mysql_bin_log.is_open())
{ {
if (mysql_bin_log.is_open()) if (error <= 0)
{ {
if (error <= 0) /*
{ [Guilhem wrote] Temporary errors may have filled
/* thd->net.last_error/errno. For example if there has
[Guilhem wrote] Temporary errors may have filled been a disk full error when writing the row, and it was
thd->net.last_error/errno. For example if there has MyISAM, then thd->net.last_error/errno will be set to
been a disk full error when writing the row, and it was "disk full"... and the my_pwrite() will wait until free
MyISAM, then thd->net.last_error/errno will be set to space appears, and so when it finishes then the
"disk full"... and the my_pwrite() will wait until free write_row() was entirely successful
space appears, and so when it finishes then the */
write_row() was entirely successful /* todo: consider removing */
*/ thd->clear_error();
/* todo: consider removing */ }
thd->clear_error(); /* bug#22725:
}
/* bug#22725: A query which per-row-loop can not be interrupted with
KILLED, like INSERT, and that does not invoke stored
A query which per-row-loop can not be interrupted with routines can be binlogged with neglecting the KILLED error.
KILLED, like INSERT, and that does not invoke stored
routines can be binlogged with neglecting the KILLED error. If there was no error (error == zero) until after the end of
inserting loop the KILLED flag that appeared later can be
If there was no error (error == zero) until after the end of disregarded since previously possible invocation of stored
inserting loop the KILLED flag that appeared later can be routines did not result in any error due to the KILLED. In
disregarded since previously possible invocation of stored such case the flag is ignored for constructing binlog event.
routines did not result in any error due to the KILLED. In */
such case the flag is ignored for constructing binlog event. DBUG_ASSERT(thd->killed != THD::KILL_BAD_DATA || error > 0);
*/ if (thd->binlog_query(THD::ROW_QUERY_TYPE,
DBUG_ASSERT(thd->killed != THD::KILL_BAD_DATA || error > 0); thd->query, thd->query_length,
if (thd->binlog_query(THD::ROW_QUERY_TYPE, transactional_table, FALSE,
thd->query, thd->query_length, (error>0) ? thd->killed : THD::NOT_KILLED) &&
transactional_table, FALSE, transactional_table)
(error>0) ? thd->killed : THD::NOT_KILLED) && {
transactional_table) error=1;
{ }
error=1;
}
}
if (thd->transaction.stmt.modified_non_trans_table)
thd->transaction.all.modified_non_trans_table= TRUE;
} }
if (thd->transaction.stmt.modified_non_trans_table)
thd->transaction.all.modified_non_trans_table= TRUE;
} }
DBUG_ASSERT(transactional_table || !changed || DBUG_ASSERT(transactional_table || !changed ||
thd->transaction.stmt.modified_non_trans_table); thd->transaction.stmt.modified_non_trans_table);
...@@ -3164,6 +3163,7 @@ void select_insert::abort() { ...@@ -3164,6 +3163,7 @@ void select_insert::abort() {
*/ */
if (table) if (table)
{ {
bool changed, transactional_table;
/* /*
If we are not in prelocked mode, we end the bulk insert started If we are not in prelocked mode, we end the bulk insert started
before. before.
...@@ -3185,20 +3185,20 @@ void select_insert::abort() { ...@@ -3185,20 +3185,20 @@ void select_insert::abort() {
If table creation failed, the number of rows modified will also be If table creation failed, the number of rows modified will also be
zero, so no check for that is made. zero, so no check for that is made.
*/ */
if (info.copied || info.deleted || info.updated) changed= (info.copied || info.deleted || info.updated);
transactional_table= table->file->has_transactions();
if (thd->transaction.stmt.modified_non_trans_table)
{ {
DBUG_ASSERT(table != NULL);
if (!table->file->has_transactions())
{
if (mysql_bin_log.is_open()) if (mysql_bin_log.is_open())
thd->binlog_query(THD::ROW_QUERY_TYPE, thd->query, thd->query_length, thd->binlog_query(THD::ROW_QUERY_TYPE, thd->query, thd->query_length,
table->file->has_transactions(), FALSE); transactional_table, FALSE);
if (!thd->current_stmt_binlog_row_based && !table->s->tmp_table && if (!thd->current_stmt_binlog_row_based && !can_rollback_data())
!can_rollback_data())
thd->transaction.all.modified_non_trans_table= TRUE; thd->transaction.all.modified_non_trans_table= TRUE;
query_cache_invalidate3(thd, table, 1); if (changed)
} query_cache_invalidate3(thd, table, 1);
} }
DBUG_ASSERT(transactional_table || !changed ||
thd->transaction.stmt.modified_non_trans_table);
table->file->ha_release_auto_increment(); table->file->ha_release_auto_increment();
} }
......
...@@ -445,7 +445,7 @@ bool mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, ...@@ -445,7 +445,7 @@ bool mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
/* If the file was not empty, wrote_create_file is true */ /* If the file was not empty, wrote_create_file is true */
if (lf_info.wrote_create_file) if (lf_info.wrote_create_file)
{ {
if ((info.copied || info.deleted) && !transactional_table) if (thd->transaction.stmt.modified_non_trans_table)
write_execute_load_query_log_event(thd, handle_duplicates, write_execute_load_query_log_event(thd, handle_duplicates,
ignore, transactional_table); ignore, transactional_table);
else else
......
...@@ -797,7 +797,7 @@ int mysql_update(THD *thd, ...@@ -797,7 +797,7 @@ int mysql_update(THD *thd,
Sometimes we want to binlog even if we updated no rows, in case user used Sometimes we want to binlog even if we updated no rows, in case user used
it to be sure master and slave are in same state. it to be sure master and slave are in same state.
*/ */
if ((error < 0) || (updated && !transactional_table)) if ((error < 0) || thd->transaction.stmt.modified_non_trans_table)
{ {
if (mysql_bin_log.is_open()) if (mysql_bin_log.is_open())
{ {
......
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