Skip to content

Commit 473cfdf

Browse files
author
guilhem@mysql.com
committed
Merge mysql.com:/home/mysql_src/mysql-5.0
into mysql.com:/home/mysql_src/mysql-5.1-new; will fix manually sp_head.cc and mysqld.cc later soon.
2 parents 46620c4 + 37c1744 commit 473cfdf

9 files changed

+109
-18
lines changed

mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,5 +250,36 @@ show binlog events from 102;
250250
do release_lock("lock1");
251251
drop table t0,t2;
252252

253-
254253
# End of 4.1 tests
254+
255+
# Test for BUG#16559 (ROLLBACK should always have a zero error code in
256+
# binlog). Has to be here and not earlier, as the SELECTs influence
257+
# XIDs differently between normal and ps-protocol (and SHOW BINLOG
258+
# EVENTS above read XIDs).
259+
260+
connect (con4,localhost,root,,);
261+
connection con3;
262+
reset master;
263+
create table t1 (a int) engine=innodb;
264+
create table t2 (a int) engine=myisam;
265+
select get_lock("a",10);
266+
begin;
267+
insert into t1 values(8);
268+
insert into t2 select * from t1;
269+
disconnect con3;
270+
271+
connection con4;
272+
select get_lock("a",10); # wait for rollback to finish
273+
274+
# we check that the error code of the "ROLLBACK" event is 0 and not
275+
# ER_SERVER_SHUTDOWN (i.e. disconnection just rolls back transaction
276+
# and does not make slave to stop)
277+
--exec $MYSQL_BINLOG --start-position=547 $MYSQL_TEST_DIR/var/log/master-bin.000001 > var/tmp/mix_innodb_myisam_binlog.output
278+
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
279+
eval select
280+
(@a:=load_file("$MYSQL_TEST_DIR/var/tmp/mix_innodb_myisam_binlog.output"))
281+
is not null;
282+
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
283+
eval select
284+
@a like "%#%error_code=0%ROLLBACK;%ROLLBACK /* added by mysqlbinlog */;%",
285+
@a not like "%#%error_code=%error_code=%";

mysql-test/r/binlog_stm_mix_innodb_myisam.result

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,3 +256,26 @@ master-bin.000001 1654 Query 1 # use `test`; create table t2 (n int) engine=inno
256256
master-bin.000001 1754 Query 1 # use `test`; DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `test`.`t1`,`test`.`ti`
257257
do release_lock("lock1");
258258
drop table t0,t2;
259+
reset master;
260+
create table t1 (a int) engine=innodb;
261+
create table t2 (a int) engine=myisam;
262+
select get_lock("a",10);
263+
get_lock("a",10)
264+
1
265+
begin;
266+
insert into t1 values(8);
267+
insert into t2 select * from t1;
268+
select get_lock("a",10);
269+
get_lock("a",10)
270+
1
271+
select
272+
(@a:=load_file("MYSQL_TEST_DIR/var/tmp/mix_innodb_myisam_binlog.output"))
273+
is not null;
274+
(@a:=load_file("MYSQL_TEST_DIR/var/tmp/mix_innodb_myisam_binlog.output"))
275+
is not null
276+
1
277+
select
278+
@a like "%#%error_code=0%ROLLBACK;%ROLLBACK /* added by mysqlbinlog */;%",
279+
@a not like "%#%error_code=%error_code=%";
280+
@a like "%#%error_code=0%ROLLBACK;%ROLLBACK /* added by mysqlbinlog */;%" @a not like "%#%error_code=%error_code=%"
281+
1 1

mysql-test/r/rpl_sp.result

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -233,20 +233,25 @@ end @ # #
233233
delete from t2;
234234
alter table t2 add unique (a);
235235
drop function fn1;
236-
create function fn1()
236+
create function fn1(x int)
237237
returns int
238238
begin
239-
insert into t2 values(20),(20);
239+
insert into t2 values(x),(x);
240240
return 10;
241241
end|
242-
select fn1();
242+
do fn1(100);
243+
Warnings:
244+
Error 1062 Duplicate entry '100' for key 1
245+
select fn1(20);
243246
ERROR 23000: Duplicate entry '20' for key 1
244247
select * from t2;
245248
a
246249
20
250+
100
247251
select * from t2;
248252
a
249253
20
254+
100
250255
create trigger trg before insert on t1 for each row set new.a= 10;
251256
ERROR 42000: Access denied; you need the SUPER privilege for this operation
252257
delete from t1;
@@ -324,7 +329,7 @@ insert into t1 values (x);
324329
return x+2;
325330
end
326331
master-bin.000001 # Query 1 # use `mysqltest1`; delete t1,t2 from t1,t2
327-
master-bin.000001 # Query 1 # use `mysqltest1`; DO `fn1`(20)
332+
master-bin.000001 # Query 1 # use `mysqltest1`; SELECT `fn1`(20)
328333
master-bin.000001 # Query 1 # use `mysqltest1`; insert into t2 values(fn1(21))
329334
master-bin.000001 # Query 1 # use `mysqltest1`; drop function fn1
330335
master-bin.000001 # Query 1 # use `mysqltest1`; create function fn1()
@@ -351,13 +356,14 @@ end
351356
master-bin.000001 # Query 1 # use `mysqltest1`; delete from t2
352357
master-bin.000001 # Query 1 # use `mysqltest1`; alter table t2 add unique (a)
353358
master-bin.000001 # Query 1 # use `mysqltest1`; drop function fn1
354-
master-bin.000001 # Query 1 # use `mysqltest1`; create function fn1()
359+
master-bin.000001 # Query 1 # use `mysqltest1`; create function fn1(x int)
355360
returns int
356361
begin
357-
insert into t2 values(20),(20);
362+
insert into t2 values(x),(x);
358363
return 10;
359364
end
360-
master-bin.000001 # Query 1 # use `mysqltest1`; DO `fn1`()
365+
master-bin.000001 # Query 1 # use `mysqltest1`; SELECT `fn1`(100)
366+
master-bin.000001 # Query 1 # use `mysqltest1`; SELECT `fn1`(20)
361367
master-bin.000001 # Query 1 # use `mysqltest1`; delete from t1
362368
master-bin.000001 # Query 1 # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` trigger trg before insert on t1 for each row set new.a= 10
363369
master-bin.000001 # Query 1 # use `mysqltest1`; insert into t1 values (1)
@@ -415,4 +421,3 @@ col
415421
test
416422
DROP PROCEDURE p1;
417423
drop table t1;
418-
reset master;

mysql-test/r/sql_mode.result

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,4 +460,20 @@ v1 CREATE ALGORITHM=UNDEFINED DEFINER="root"@"localhost" SQL SECURITY DEFINER VI
460460
create view v2 as select a from t2 where a in (select a from v1);
461461
drop view v2, v1;
462462
drop table t1, t2;
463+
select @@sql_mode;
464+
@@sql_mode
465+
ANSI_QUOTES
466+
set sql_mode=2097152;
467+
select @@sql_mode;
468+
@@sql_mode
469+
STRICT_TRANS_TABLES
470+
set sql_mode=16384+(65536*4);
471+
select @@sql_mode;
472+
@@sql_mode
473+
REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,NO_TABLE_OPTIONS,ANSI
474+
set sql_mode=2147483648;
475+
ERROR 42000: Variable 'sql_mode' can't be set to the value of '2147483648'
476+
select @@sql_mode;
477+
@@sql_mode
478+
REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,NO_TABLE_OPTIONS,ANSI
463479
SET @@SQL_MODE=@OLD_SQL_MODE;

mysql-test/t/rpl_sp-slave.opt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
--log_bin_trust_routine_creators=0 --slave-skip-errors=1062
1+
--log_bin_trust_routine_creators=0

mysql-test/t/rpl_sp.test

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -296,21 +296,19 @@ alter table t2 add unique (a);
296296
drop function fn1;
297297

298298
delimiter |;
299-
create function fn1()
299+
create function fn1(x int)
300300
returns int
301301
begin
302-
insert into t2 values(20),(20);
302+
insert into t2 values(x),(x);
303303
return 10;
304304
end|
305305

306306
delimiter ;|
307307

308-
# Because of BUG#14769 the following statement requires that we start
309-
# slave with --slave-skip-errors=1062. When that bug is fixed, that
310-
# option can be removed.
308+
do fn1(100);
311309

312310
--error 1062
313-
select fn1();
311+
select fn1(20);
314312

315313
select * from t2;
316314
sync_slave_with_master;

mysql-test/t/sql_mode.test

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,4 +255,13 @@ create view v2 as select a from t2 where a in (select a from v1);
255255
drop view v2, v1;
256256
drop table t1, t2;
257257

258+
select @@sql_mode;
259+
set sql_mode=2097152;
260+
select @@sql_mode;
261+
set sql_mode=16384+(65536*4);
262+
select @@sql_mode;
263+
--error 1231
264+
set sql_mode=2147483648; # that mode does not exist
265+
select @@sql_mode;
266+
258267
SET @@SQL_MODE=@OLD_SQL_MODE;

sql/log.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,7 @@ static int binlog_commit(THD *thd, bool all)
10991099
DBUG_RETURN(0);
11001100
}
11011101
Query_log_event qev(thd, STRING_WITH_LEN("COMMIT"), TRUE, FALSE);
1102+
qev.error_code= 0; // see comment in MYSQL_LOG::write(THD, IO_CACHE)
11021103
DBUG_RETURN(binlog_end_trans(thd, trx_data, &qev));
11031104
}
11041105

@@ -1125,6 +1126,7 @@ static int binlog_rollback(THD *thd, bool all)
11251126
if (unlikely(thd->options & OPTION_STATUS_NO_TRANS_UPDATE))
11261127
{
11271128
Query_log_event qev(thd, STRING_WITH_LEN("ROLLBACK"), TRUE, FALSE);
1129+
qev.error_code= 0; // see comment in MYSQL_LOG::write(THD, IO_CACHE)
11281130
error= binlog_end_trans(thd, trx_data, &qev);
11291131
}
11301132
else
@@ -3019,7 +3021,9 @@ bool MYSQL_LOG::write(THD *thd, IO_CACHE *cache, Log_event *commit_event)
30193021
Imagine this is rollback due to net timeout, after all statements of
30203022
the transaction succeeded. Then we want a zero-error code in BEGIN.
30213023
In other words, if there was a really serious error code it's already
3022-
in the statement's events.
3024+
in the statement's events, there is no need to put it also in this
3025+
internally generated event, and as this event is generated late it
3026+
would lead to false alarms.
30233027
This is safer than thd->clear_error() against kills at shutdown.
30243028
*/
30253029
qinfo.error_code= 0;

sql/set_var.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1621,7 +1621,12 @@ bool sys_var::check_set(THD *thd, set_var *var, TYPELIB *enum_names)
16211621
else
16221622
{
16231623
ulonglong tmp= var->value->val_int();
1624-
if (tmp >= enum_names->count)
1624+
/*
1625+
For when the enum is made to contain 64 elements, as 1ULL<<64 is
1626+
undefined, we guard with a "count<64" test.
1627+
*/
1628+
if (unlikely((tmp >= ((ULL(1)) << enum_names->count)) &&
1629+
(enum_names->count < 64)))
16251630
{
16261631
llstr(tmp, buff);
16271632
goto err;

0 commit comments

Comments
 (0)