Commit 9933c3bd authored by unknown's avatar unknown

Merge mysql.com:/users/lthalmann/bkroot/mysql-5.1-new-rpl

into  mysql.com:/users/lthalmann/bk/MERGE/mysql-5.1-merge


mysql-test/r/binlog_row_mix_innodb_myisam.result:
  Auto merged
mysql-test/r/federated.result:
  Auto merged
mysql-test/r/innodb.result:
  Auto merged
mysql-test/extra/rpl_tests/rpl_ddl.test:
  Auto merged
mysql-test/r/rpl_ddl.result:
  Auto merged
mysql-test/r/sp-error.result:
  Auto merged
mysql-test/r/sp.result:
  Auto merged
mysql-test/r/rpl_ndb_charset.result:
  Auto merged
mysql-test/r/type_ranges.result:
  Auto merged
mysql-test/r/view.result:
  Auto merged
mysql-test/r/trigger-grant.result:
  Auto merged
mysql-test/t/archive.test:
  Auto merged
mysql-test/t/create.test:
  Auto merged
mysql-test/t/disabled.def:
  Auto merged
mysql-test/t/federated.test:
  Auto merged
mysql-test/t/innodb.test:
  Auto merged
mysql-test/t/innodb_mysql.test:
  Auto merged
mysql-test/t/sp.test:
  Auto merged
mysql-test/t/trigger-grant.test:
  Auto merged
mysql-test/t/view.test:
  Auto merged
sql/ha_innodb.cc:
  Auto merged
sql/log.cc:
  Auto merged
sql/log_event.cc:
  Auto merged
sql/set_var.cc:
  Auto merged
sql/set_var.h:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_class.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
mysql-test/r/create.result:
  Manual merge
mysql-test/r/innodb_mysql.result:
  Manual merge
sql/handler.cc:
  Manual merge
sql/share/errmsg.txt:
  Manual merge
sql/sql_class.h:
  Manual merge
sql/sql_delete.cc:
  Manual merge
sql/sql_insert.cc:
  Manual merge
sql/sql_table.cc:
  Manual merge
parents ed849efc 684bda9a
......@@ -228,15 +228,11 @@ let $my_master_commit= true;
let $my_slave_commit= true;
--source include/rpl_stmt_seq.inc
SELECT * FROM mysqltest1.t7;
connection slave;
--disable_query_log
SELECT '-------- switch to slave --------' as "";
--enable_query_log
--echo -------- switch to slave --------
sync_slave_with_master;
SELECT * FROM mysqltest1.t7;
--echo -------- switch to master -------
connection master;
--disable_query_log
SELECT '-------- switch to master -------' as "";
--enable_query_log
###############################################################
# Cases with LOCK/UNLOCK
......
#
# Copyright 2006 MySQL. All rights reserved.
#
# Test to check for the different version of truncating a table.
# The statements are "TRUNCATE tbl" and "DELETE FROM tbl". We check
# the behaviour of each possible value for BINLOG_FORMAT.
#
# Author(s): Mats Kindahl
--source include/have_row_based.inc
--source include/master-slave.inc
let $format = STATEMENT;
let $stmt = TRUNCATE TABLE;
--source extra/rpl_tests/rpl_truncate_helper.inc
let $format = MIXED;
let $stmt = TRUNCATE TABLE;
--source extra/rpl_tests/rpl_truncate_helper.inc
let $format = ROW;
let $stmt = TRUNCATE TABLE;
--source extra/rpl_tests/rpl_truncate_helper.inc
let $format = STATEMENT;
let $stmt = DELETE FROM;
--source extra/rpl_tests/rpl_truncate_helper.inc
let $format = MIXED;
let $stmt = DELETE FROM;
--source extra/rpl_tests/rpl_truncate_helper.inc
let $format = ROW;
let $stmt = DELETE FROM;
--source extra/rpl_tests/rpl_truncate_helper.inc
--disable_query_log
--disable_warnings
connection slave;
STOP SLAVE;
connection master;
DROP TABLE IF EXISTS t1;
RESET MASTER;
connection slave;
DROP TABLE IF EXISTS t1;
RESET SLAVE;
START SLAVE;
--enable_warnings
--enable_query_log
--echo **** On Master ****
connection master;
eval SET SESSION BINLOG_FORMAT=$format;
eval SET GLOBAL BINLOG_FORMAT=$format;
eval CREATE TABLE t1 (a INT, b LONG) ENGINE=$engine;
INSERT INTO t1 VALUES (1,1), (2,2);
SELECT * FROM t1;
--echo **** On Slave ****
sync_slave_with_master;
INSERT INTO t1 VALUE (3,3);
SELECT * FROM t1;
--echo **** On Master ****
connection master;
eval $stmt t1;
SELECT * FROM t1;
--echo **** On Slave ****
sync_slave_with_master;
# Should be empty
SELECT * FROM t1;
--echo **** On Master ****
connection master;
DROP TABLE t1;
--replace_result $SERVER_VERSION SERVER_VERSION
--replace_regex /table_id: [0-9]+/table_id: #/
SHOW BINLOG EVENTS;
connection slave;
#we expect STOP SLAVE to produce a warning as the slave is stopped
#(the server was started with skip-slave-start)
--disable_warnings
stop slave;
--wait_for_slave_to_stop
--enable_warnings
connection master;
--disable_warnings
--disable_query_log
use test;
--enable_query_log
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
--enable_warnings
reset master;
connection slave;
reset slave;
# Clean up old test tables
--disable_warnings
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
--enable_warnings
start slave;
......@@ -2,28 +2,8 @@ connect (master,127.0.0.1,root,,test,$MASTER_MYPORT,);
connect (master1,127.0.0.1,root,,test,$MASTER_MYPORT,);
connect (slave,127.0.0.1,root,,test,$SLAVE_MYPORT,);
connect (slave1,127.0.0.1,root,,test,$SLAVE_MYPORT,);
connection slave;
#we expect STOP SLAVE to produce a warning as the slave is stopped
#(the server was started with skip-slave-start)
--disable_warnings
stop slave;
--enable_warnings
--require r/slave-stopped.result
show status like 'Slave_running';
connection master;
--disable_warnings
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
--enable_warnings
reset master;
connection slave;
reset slave;
# Clean up old test tables
--disable_warnings
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
--enable_warnings
start slave;
--require r/slave-running.result
show status like 'Slave_running';
-- source include/master-slave-reset.inc
# Set the default connection to 'master'
connection master;
......@@ -118,12 +118,6 @@ master-bin.000001 # Query 1 # use `test`; COMMIT
master-bin.000001 # Table_map 1 # table_id: # (test.t1)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Query 1 # use `test`; COMMIT
master-bin.000001 # Table_map 1 # table_id: # (test.t1)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Query 1 # use `test`; COMMIT
master-bin.000001 # Table_map 1 # table_id: # (test.t1)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Query 1 # use `test`; COMMIT
master-bin.000001 # Query 1 # use `test`; create table t2 (a varchar(200)) engine=blackhole
master-bin.000001 # Table_map 1 # table_id: # (test.t2)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
......@@ -131,12 +125,6 @@ master-bin.000001 # Query 1 # use `test`; COMMIT
master-bin.000001 # Query 1 # use `test`; alter table t1 add b int
master-bin.000001 # Query 1 # use `test`; alter table t1 drop b
master-bin.000001 # Query 1 # use `test`; create table t3 like t1
master-bin.000001 # Table_map 1 # table_id: # (test.t1)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Query 1 # use `test`; COMMIT
master-bin.000001 # Table_map 1 # table_id: # (test.t1)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Query 1 # use `test`; COMMIT
drop table t1,t2,t3;
reset master;
create table t1 (a int) engine=blackhole;
......
......@@ -261,26 +261,21 @@ master-bin.000001 243 Table_map 1 # table_id: # (test.t1)
master-bin.000001 282 Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 316 Xid 1 # COMMIT /* xid= */
master-bin.000001 343 Table_map 1 # table_id: # (test.t1)
master-bin.000001 382 Query 1 # use `test`; delete from t1
master-bin.000001 459 Xid 1 # COMMIT /* xid= */
master-bin.000001 486 Table_map 1 # table_id: # (test.t2)
master-bin.000001 525 Query 1 # use `test`; delete from t2
master-bin.000001 602 Xid 1 # COMMIT /* xid= */
master-bin.000001 629 Query 1 # use `test`; alter table t2 engine=MyISAM
master-bin.000001 720 Table_map 1 # table_id: # (test.t1)
master-bin.000001 759 Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 793 Xid 1 # COMMIT /* xid= */
master-bin.000001 820 Query 1 # use `test`; BEGIN
master-bin.000001 888 Table_map 1 # table_id: # (test.t1)
master-bin.000001 927 Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 956 Xid 1 # COMMIT /* xid= */
master-bin.000001 983 Query 1 # use `test`; drop table t1,t2
master-bin.000001 1062 Query 1 # use `test`; create table t0 (n int)
master-bin.000001 1148 Table_map 1 # table_id: # (test.t0)
master-bin.000001 1187 Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 1221 Table_map 1 # table_id: # (test.t0)
master-bin.000001 1260 Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 1294 Query 1 # use `test`; create table t2 (n int) engine=innodb
master-bin.000001 382 Delete_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 421 Xid 1 # COMMIT /* xid= */
master-bin.000001 448 Query 1 # use `test`; alter table t2 engine=MyISAM
master-bin.000001 539 Table_map 1 # table_id: # (test.t1)
master-bin.000001 578 Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 612 Xid 1 # COMMIT /* xid= */
master-bin.000001 639 Table_map 1 # table_id: # (test.t2)
master-bin.000001 678 Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 712 Query 1 # use `test`; drop table t1,t2
master-bin.000001 791 Query 1 # use `test`; create table t0 (n int)
master-bin.000001 877 Table_map 1 # table_id: # (test.t0)
master-bin.000001 916 Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 950 Table_map 1 # table_id: # (test.t0)
master-bin.000001 989 Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 1023 Query 1 # use `test`; create table t2 (n int) engine=innodb
do release_lock("lock1");
drop table t0,t2;
set autocommit=0;
......
......@@ -780,12 +780,6 @@ t1 CREATE TABLE `t1` (
`i` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 MAX_ROWS=4294967295
drop table t1;
create table t1(f1 varchar(800) binary not null, key(f1)) engine = innodb
character set utf8 collate utf8_general_ci;
Warnings:
Warning 1071 Specified key was too long; max key length is 765 bytes
insert into t1 values('aaa');
drop table t1;
CREATE TABLE t1 (a int, b int);
insert into t1 values (1,1),(1,2);
CREATE TABLE t2 (primary key (a)) select * from t1;
......
......@@ -82,7 +82,7 @@ t2 CREATE TABLE `t2` (
) ENGINE=FEDERATED DEFAULT CHARSET=latin1 CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/federated/t1'
INSERT INTO federated.t2 (id, name) VALUES (1, 'foo');
INSERT INTO federated.t2 (id, name) VALUES (2, 'fee');
SELECT * FROM federated.t2;
SELECT * FROM federated.t2 ORDER BY id, name;
id name
1 foo
2 fee
......@@ -107,7 +107,7 @@ ENGINE="FEDERATED" DEFAULT CHARSET=latin1
CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/federated/t1%';
INSERT INTO federated.t1 (id, name) VALUES (1, 'foo');
INSERT INTO federated.t1 (id, name) VALUES (2, 'fee');
SELECT * FROM federated.t1;
SELECT * FROM federated.t1 ORDER BY id,name;
id name
1 foo
2 fee
......@@ -121,7 +121,7 @@ ENGINE="FEDERATED" DEFAULT CHARSET=latin1
CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/federated/t1%';
INSERT INTO federated.`t1%` (id, name) VALUES (1, 'foo');
INSERT INTO federated.`t1%` (id, name) VALUES (2, 'fee');
SELECT * FROM federated.`t1%`;
SELECT * FROM federated.`t1%` ORDER BY id, name;
id name
1 foo
2 fee
......
......@@ -1378,9 +1378,9 @@ insert into `t2`values ( 1 ) ;
create table `t3` (`id` int( 11 ) not null default '0',key `id` ( `id` ) ,constraint `t2_id_fk` foreign key ( `id` ) references `t2` (`id` )) engine = innodb;
insert into `t3`values ( 1 ) ;
delete t3,t2,t1 from t1,t2,t3 where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test/t2`, CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`))
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`))
update t1,t2,t3 set t3.id=5, t2.id=6, t1.id=7 where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test/t2`, CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`))
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`))
update t3 set t3.id=7 where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
ERROR 42S22: Unknown column 't1.id' in 'where clause'
drop table t3,t2,t1;
......@@ -1392,7 +1392,7 @@ foreign key(pid) references t1(id) on delete cascade) engine=innodb;
insert into t1 values(0,0),(1,0),(2,1),(3,2),(4,3),(5,4),(6,5),(7,6),
(8,7),(9,8),(10,9),(11,10),(12,11),(13,12),(14,13),(15,14);
delete from t1 where id=0;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test/t1`, CONSTRAINT `t1_ibfk_1` FOREIGN KEY (`pid`) REFERENCES `t1` (`id`) ON DELETE CASCADE)
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t1`, CONSTRAINT `t1_ibfk_1` FOREIGN KEY (`pid`) REFERENCES `t1` (`id`) ON DELETE CASCADE)
delete from t1 where id=15;
delete from t1 where id=0;
drop table t1;
......@@ -2633,18 +2633,18 @@ v INT,
CONSTRAINT c1 FOREIGN KEY (v) REFERENCES t1(id)
) ENGINE=InnoDB;
INSERT INTO t2 VALUES(2);
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test/t2`, CONSTRAINT `c1` FOREIGN KEY (`v`) REFERENCES `t1` (`id`))
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c1` FOREIGN KEY (`v`) REFERENCES `t1` (`id`))
INSERT INTO t1 VALUES(1);
INSERT INTO t2 VALUES(1);
DELETE FROM t1 WHERE id = 1;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test/t2`, CONSTRAINT `c1` FOREIGN KEY (`v`) REFERENCES `t1` (`id`))
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c1` FOREIGN KEY (`v`) REFERENCES `t1` (`id`))
DROP TABLE t1;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails
SET FOREIGN_KEY_CHECKS=0;
DROP TABLE t1;
SET FOREIGN_KEY_CHECKS=1;
INSERT INTO t2 VALUES(3);
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test/t2`, CONSTRAINT `c1` FOREIGN KEY (`v`) REFERENCES `t1` (`id`))
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c1` FOREIGN KEY (`v`) REFERENCES `t1` (`id`))
DROP TABLE t2;
create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
insert into t1 values (1),(2);
......@@ -2922,23 +2922,23 @@ create table t4(a int primary key,constraint foreign key(a)references t3(a)) row
insert into t1 values(1);
insert into t3 values(1);
insert into t2 values(2);
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test/t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`))
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`))
insert into t4 values(2);
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test/t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t3` (`a`))
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t3` (`a`))
insert into t2 values(1);
insert into t4 values(1);
update t1 set a=2;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test/t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`))
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`))
update t2 set a=2;
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test/t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`))
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`))
update t3 set a=2;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test/t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t3` (`a`))
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t3` (`a`))
update t4 set a=2;
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test/t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t3` (`a`))
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t3` (`a`))
truncate t1;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test/t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`))
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`))
truncate t3;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test/t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t3` (`a`))
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t3` (`a`))
truncate t2;
truncate t4;
truncate t1;
......@@ -2993,7 +2993,7 @@ create table t1 (a int primary key,s1 varbinary(3) not null unique) engine=innod
create table t2 (s1 binary(2) not null, constraint c foreign key(s1) references t1(s1) on update cascade) engine=innodb;
insert into t1 values(1,0x4100),(2,0x41),(3,0x4120),(4,0x42);
insert into t2 values(0x42);
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test/t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
insert into t2 values(0x41);
select hex(s1) from t2;
hex(s1)
......@@ -3003,11 +3003,11 @@ select hex(s1) from t2;
hex(s1)
4100
update t1 set s1=0x12 where a=1;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test/t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
update t1 set s1=0x12345678 where a=1;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test/t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
update t1 set s1=0x123457 where a=1;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test/t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
update t1 set s1=0x1220 where a=1;
select hex(s1) from t2;
hex(s1)
......@@ -3021,11 +3021,11 @@ select hex(s1) from t2;
hex(s1)
4200
delete from t1 where a=1;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test/t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
delete from t1 where a=2;
update t2 set s1=0x4120;
delete from t1;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test/t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
delete from t1 where a!=3;
select a,hex(s1) from t1;
a hex(s1)
......@@ -3051,7 +3051,7 @@ hex(s1)
12
delete from t1 where a=1;
delete from t1 where a=2;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test/t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
select a,hex(s1) from t1;
a hex(s1)
2 12
......
drop table if exists t1,t2,t1m,t1i,t2m,t2i,t4;
create table t1(f1 varchar(800) binary not null, key(f1)) engine = innodb
character set utf8 collate utf8_general_ci;
Warnings:
Warning 1071 Specified key was too long; max key length is 765 bytes
insert into t1 values('aaa');
drop table t1;
create table t1 (
c_id int(11) not null default '0',
org_id int(11) default null,
......
......@@ -7,6 +7,4 @@ insert into t1 values (1, 1);
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; drop table if exists t1
master-bin.000001 # Table_map # # table_id: # (mysql.proc)
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
drop database mysqltest;
......@@ -406,7 +406,7 @@ insert into t2(uid, name) values
(24, CHAR(64+24)),
(25, CHAR(64+25)),
(26, CHAR(64+26));
insert into t1(uid, name) select uid, name from t2;
insert into t1(uid, name) select uid, name from t2 order by uid;
delete from t2;
insert into t2(id, uid, name) select id, uid, name from t1;
select count(*) from t1;
......
......@@ -646,11 +646,9 @@ flush logs;
-------- switch to master -------
SELECT * FROM mysqltest1.t7;
f1
-------- switch to slave --------
SELECT * FROM mysqltest1.t7;
f1
-------- switch to master -------
######## LOCK TABLES mysqltest1.t1 WRITE, mysqltest1.t8 READ ########
......
......@@ -112,16 +112,10 @@ drop database mysqltest3;
show binlog events from 102;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query 1 # drop database if exists mysqltest2
master-bin.000001 # Table_map 1 # table_id: # (mysql.proc)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Query 1 # drop database if exists mysqltest3
master-bin.000001 # Table_map 1 # table_id: # (mysql.proc)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Query 1 # create database mysqltest2 character set latin2
master-bin.000001 # Query 1 # create database mysqltest3
master-bin.000001 # Query 1 # drop database mysqltest3
master-bin.000001 # Table_map 1 # table_id: # (mysql.proc)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Query 1 # create database mysqltest3
master-bin.000001 # Query 1 # use `mysqltest2`; create table t1 (a int auto_increment primary key, b varchar(100))
master-bin.000001 # Table_map 1 # table_id: # (mysqltest2.t1)
......@@ -147,11 +141,7 @@ master-bin.000001 # Query 1 # use `mysqltest2`; truncate table t1
master-bin.000001 # Table_map 1 # table_id: # (mysqltest2.t1)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Query 1 # drop database mysqltest2
master-bin.000001 # Table_map 1 # table_id: # (mysql.proc)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Query 1 # drop database mysqltest3
master-bin.000001 # Table_map 1 # table_id: # (mysql.proc)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
select "--- --global--" as "";
--- --global--
......
......@@ -44,3 +44,19 @@ t1
USE test_ignore;
ERROR 42000: Unknown database 'test_ignore'
DROP DATABASE test_ignore;
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 (a INT);
DELETE FROM t1;
INSERT INTO t1 VALUES (1),(2);
DELETE FROM t1 WHERE a = 0;
UPDATE t1 SET a=99 WHERE a = 0;
SHOW BINLOG EVENTS;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 4 Format_desc 1 102 Server ver: 5.1.11-beta-debug-log, Binlog ver: 4
master-bin.000001 102 Query 1 188 use `test`; CREATE TABLE t1 (a INT)
master-bin.000001 188 Table_map 1 227 table_id: # (test.t1)
master-bin.000001 227 Write_rows 1 266 table_id: # flags: STMT_END_F
......@@ -112,16 +112,10 @@ drop database mysqltest3;
show binlog events from 102;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query 1 # drop database if exists mysqltest2
master-bin.000001 # Table_map 1 # table_id: # (mysql.proc)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Query 1 # drop database if exists mysqltest3
master-bin.000001 # Table_map 1 # table_id: # (mysql.proc)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Query 1 # create database mysqltest2 character set latin2
master-bin.000001 # Query 1 # create database mysqltest3
master-bin.000001 # Query 1 # drop database mysqltest3
master-bin.000001 # Table_map 1 # table_id: # (mysql.proc)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Query 1 # create database mysqltest3
master-bin.000001 # Query 1 # use `mysqltest2`; create table t1 (a int auto_increment primary key, b varchar(100))
master-bin.000001 # Table_map 1 # table_id: # (mysqltest2.t1)
......@@ -147,11 +141,7 @@ master-bin.000001 # Query 1 # use `mysqltest2`; truncate table t1
master-bin.000001 # Table_map 1 # table_id: # (mysqltest2.t1)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Query 1 # drop database mysqltest2
master-bin.000001 # Table_map 1 # table_id: # (mysql.proc)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Query 1 # drop database mysqltest3
master-bin.000001 # Table_map 1 # table_id: # (mysql.proc)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
select "--- --global--" as "";
--- --global--
......
......@@ -127,7 +127,7 @@ NULL 5 10
NULL 6 12
CREATE TABLE t7 (UNIQUE(b)) SELECT a,b FROM tt3;
ERROR 23000: Duplicate entry '2' for key 'b'
SHOW BINLOG EVENTS FROM 1326;
SHOW BINLOG EVENTS FROM 1256;
Log_name Pos Event_type Server_id End_log_pos Info
CREATE TABLE t7 (a INT, b INT UNIQUE);
INSERT INTO t7 SELECT a,b FROM tt3;
......@@ -137,11 +137,11 @@ a b
1 2
2 4
3 6
SHOW BINLOG EVENTS FROM 1326;
SHOW BINLOG EVENTS FROM 1256;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 1326 Query 1 1426 use `test`; CREATE TABLE t7 (a INT, b INT UNIQUE)
master-bin.000001 1426 Table_map 1 1466 table_id: # (test.t7)
master-bin.000001 1466 Write_rows 1 1522 table_id: # flags: STMT_END_F
master-bin.000001 1256 Query 1 1356 use `test`; CREATE TABLE t7 (a INT, b INT UNIQUE)
master-bin.000001 1356 Table_map 1 1396 table_id: # (test.t7)
master-bin.000001 1396 Write_rows 1 1452 table_id: # flags: STMT_END_F
SELECT * FROM t7 ORDER BY a,b;
a b
1 2
......@@ -154,10 +154,10 @@ INSERT INTO t7 SELECT a,b FROM tt4;
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
SHOW BINLOG EVENTS FROM 1522;
SHOW BINLOG EVENTS FROM 1452;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 1522 Table_map 1 1562 table_id: # (test.t7)
master-bin.000001 1562 Write_rows 1 1618 table_id: # flags: STMT_END_F
master-bin.000001 1452 Table_map 1 1492 table_id: # (test.t7)
master-bin.000001 1492 Write_rows 1 1548 table_id: # flags: STMT_END_F
SELECT * FROM t7 ORDER BY a,b;
a b
1 2
......@@ -191,10 +191,10 @@ Create Table CREATE TABLE `t9` (
`a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SHOW BINLOG EVENTS FROM 1618;
SHOW BINLOG EVENTS FROM 1548;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 1618 Query 1 1704 use `test`; CREATE TABLE t8 LIKE t4
master-bin.000001 1704 Query 1 1843 use `test`; CREATE TABLE `t9` (
master-bin.000001 1548 Query 1 1634 use `test`; CREATE TABLE t8 LIKE t4
master-bin.000001 1634 Query 1 1773 use `test`; CREATE TABLE `t9` (
`a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL
)
......
......@@ -5,9 +5,18 @@ reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
create table t1 (a int not null primary key);
insert into t1 values (1);
create table t2 (a int);
insert into t2 values (1);
update t1, t2 set t1.a = 0 where t1.a = t2.a;
show tables;
Tables_in_test
t1
select * from t1;
a
0
drop table t1;
insert into t1 values (1);
insert into t1 values (2);
show slave status;
Slave_IO_State #
Master_Host 127.0.0.1
......@@ -24,13 +33,13 @@ Slave_SQL_Running No
Replicate_Do_DB
Replicate_Ignore_DB
Replicate_Do_Table
Replicate_Ignore_Table
Replicate_Ignore_Table test.t2
Replicate_Wild_Do_Table
Replicate_Wild_Ignore_Table
Last_Errno 1146
Last_Error Error 'Table 'test.t1' doesn't exist' on opening table `test`.`t1`
Skip_Counter 0
Exec_Master_Log_Pos 209
Exec_Master_Log_Pos 519
Relay_Log_Space #
Until_Condition None
Until_Log_File
......@@ -42,4 +51,4 @@ Master_SSL_Cert
Master_SSL_Cipher
Master_SSL_Key
Seconds_Behind_Master #
drop table t1;
drop table t1, t2;
......@@ -124,9 +124,9 @@ delete from t1;
delete from t2;
delete from t1;
insert into t2 values(1),(2);
create view v1 as select f1(a) from t2;
select * from v1;
f1(a)
create view v1 as select f1(a) as f from t2;
select * from v1 order by f;
f
2
3
SELECT 'master:',a FROM t1 ORDER BY a;
......
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;
**** On Master ****
SET SESSION BINLOG_FORMAT=STATEMENT;
SET GLOBAL BINLOG_FORMAT=STATEMENT;
CREATE TABLE t1 (a INT, b LONG) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1,1), (2,2);
SELECT * FROM t1;
a b
1 1
2 2
**** On Slave ****
INSERT INTO t1 VALUE (3,3);
SELECT * FROM t1;
a b
1 1
2 2
3 3
**** On Master ****
TRUNCATE TABLE t1;
SELECT * FROM t1;
a b
**** On Slave ****
SELECT * FROM t1;
a b
**** On Master ****
DROP TABLE t1;
SHOW BINLOG EVENTS;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 4 Format_desc 1 102 Server ver: SERVER_VERSION, Binlog ver: 4
master-bin.000001 102 Query 1 210 use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=MyISAM
master-bin.000001 210 Query 1 307 use `test`; INSERT INTO t1 VALUES (1,1), (2,2)
master-bin.000001 307 Query 1 387 use `test`; TRUNCATE TABLE t1
master-bin.000001 387 Query 1 463 use `test`; DROP TABLE t1
**** On Master ****
SET SESSION BINLOG_FORMAT=MIXED;
SET GLOBAL BINLOG_FORMAT=MIXED;
CREATE TABLE t1 (a INT, b LONG) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1,1), (2,2);
SELECT * FROM t1;
a b
1 1
2 2
**** On Slave ****
INSERT INTO t1 VALUE (3,3);
SELECT * FROM t1;
a b
1 1
2 2
3 3
**** On Master ****
TRUNCATE TABLE t1;
SELECT * FROM t1;
a b
**** On Slave ****
SELECT * FROM t1;
a b
**** On Master ****
DROP TABLE t1;
SHOW BINLOG EVENTS;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 4 Format_desc 1 102 Server ver: SERVER_VERSION, Binlog ver: 4
master-bin.000001 102 Query 1 210 use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=MyISAM
master-bin.000001 210 Query 1 307 use `test`; INSERT INTO t1 VALUES (1,1), (2,2)
master-bin.000001 307 Query 1 387 use `test`; TRUNCATE TABLE t1
master-bin.000001 387 Query 1 463 use `test`; DROP TABLE t1
**** On Master ****
SET SESSION BINLOG_FORMAT=ROW;
SET GLOBAL BINLOG_FORMAT=ROW;
CREATE TABLE t1 (a INT, b LONG) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1,1), (2,2);
SELECT * FROM t1;
a b
1 1
2 2
**** On Slave ****
INSERT INTO t1 VALUE (3,3);
SELECT * FROM t1;
a b
1 1
2 2
3 3
**** On Master ****
TRUNCATE TABLE t1;
SELECT * FROM t1;
a b
**** On Slave ****
SELECT * FROM t1;
a b
**** On Master ****
DROP TABLE t1;
SHOW BINLOG EVENTS;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 4 Format_desc 1 102 Server ver: SERVER_VERSION, Binlog ver: 4
master-bin.000001 102 Query 1 210 use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=MyISAM
master-bin.000001 210 Table_map 1 250 table_id: # (test.t1)
master-bin.000001 250 Write_rows 1 297 table_id: # flags: STMT_END_F
master-bin.000001 297 Query 1 377 use `test`; TRUNCATE TABLE t1
master-bin.000001 377 Query 1 453 use `test`; DROP TABLE t1
**** On Master ****
SET SESSION BINLOG_FORMAT=STATEMENT;
SET GLOBAL BINLOG_FORMAT=STATEMENT;
CREATE TABLE t1 (a INT, b LONG) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1,1), (2,2);
SELECT * FROM t1;
a b
1 1
2 2
**** On Slave ****
INSERT INTO t1 VALUE (3,3);
SELECT * FROM t1;
a b
1 1
2 2
3 3
**** On Master ****
DELETE FROM t1;
SELECT * FROM t1;
a b
**** On Slave ****
SELECT * FROM t1;
a b
**** On Master ****
DROP TABLE t1;
SHOW BINLOG EVENTS;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 4 Format_desc 1 102 Server ver: SERVER_VERSION, Binlog ver: 4
master-bin.000001 102 Query 1 210 use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=MyISAM
master-bin.000001 210 Query 1 307 use `test`; INSERT INTO t1 VALUES (1,1), (2,2)
master-bin.000001 307 Query 1 384 use `test`; DELETE FROM t1
master-bin.000001 384 Query 1 460 use `test`; DROP TABLE t1
**** On Master ****
SET SESSION BINLOG_FORMAT=MIXED;
SET GLOBAL BINLOG_FORMAT=MIXED;
CREATE TABLE t1 (a INT, b LONG) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1,1), (2,2);
SELECT * FROM t1;
a b
1 1
2 2
**** On Slave ****
INSERT INTO t1 VALUE (3,3);
SELECT * FROM t1;
a b
1 1
2 2
3 3
**** On Master ****
DELETE FROM t1;
SELECT * FROM t1;
a b
**** On Slave ****
SELECT * FROM t1;
a b
**** On Master ****
DROP TABLE t1;
SHOW BINLOG EVENTS;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 4 Format_desc 1 102 Server ver: SERVER_VERSION, Binlog ver: 4
master-bin.000001 102 Query 1 210 use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=MyISAM
master-bin.000001 210 Query 1 307 use `test`; INSERT INTO t1 VALUES (1,1), (2,2)
master-bin.000001 307 Query 1 384 use `test`; DELETE FROM t1
master-bin.000001 384 Query 1 460 use `test`; DROP TABLE t1
**** On Master ****
SET SESSION BINLOG_FORMAT=ROW;
SET GLOBAL BINLOG_FORMAT=ROW;
CREATE TABLE t1 (a INT, b LONG) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1,1), (2,2);
SELECT * FROM t1;
a b
1 1
2 2
**** On Slave ****
INSERT INTO t1 VALUE (3,3);
SELECT * FROM t1;
a b
1 1
2 2
3 3
**** On Master ****
DELETE FROM t1;
SELECT * FROM t1;
a b
**** On Slave ****
SELECT * FROM t1;
a b
3 3
**** On Master ****
DROP TABLE t1;
SHOW BINLOG EVENTS;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 4 Format_desc 1 102 Server ver: SERVER_VERSION, Binlog ver: 4
master-bin.000001 102 Query 1 210 use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=MyISAM
master-bin.000001 210 Table_map 1 250 table_id: # (test.t1)
master-bin.000001 250 Write_rows 1 297 table_id: # flags: STMT_END_F
master-bin.000001 297 Table_map 1 337 table_id: # (test.t1)
master-bin.000001 337 Delete_rows 1 384 table_id: # flags: STMT_END_F
master-bin.000001 384 Query 1 460 use `test`; DROP TABLE t1
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;
**** On Master ****
SET SESSION BINLOG_FORMAT=STATEMENT;
SET GLOBAL BINLOG_FORMAT=STATEMENT;
CREATE TABLE t1 (a INT, b LONG) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1,1), (2,2);
SELECT * FROM t1;
a b
1 1
2 2
**** On Slave ****
INSERT INTO t1 VALUE (3,3);
SELECT * FROM t1;
a b
1 1
2 2
3 3
**** On Master ****
TRUNCATE TABLE t1;
SELECT * FROM t1;
a b
**** On Slave ****
SELECT * FROM t1;
a b
**** On Master ****
DROP TABLE t1;
SHOW BINLOG EVENTS;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 4 Format_desc 1 102 Server ver: SERVER_VERSION, Binlog ver: 4
master-bin.000001 102 Query 1 210 use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=InnoDB
master-bin.000001 210 Query 1 97 use `test`; INSERT INTO t1 VALUES (1,1), (2,2)
master-bin.000001 307 Xid 1 334 COMMIT /* xid= */
master-bin.000001 334 Query 1 80 use `test`; TRUNCATE TABLE t1
master-bin.000001 414 Xid 1 441 COMMIT /* xid= */
master-bin.000001 441 Query 1 517 use `test`; DROP TABLE t1
**** On Master ****
SET SESSION BINLOG_FORMAT=MIXED;
SET GLOBAL BINLOG_FORMAT=MIXED;
CREATE TABLE t1 (a INT, b LONG) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1,1), (2,2);
SELECT * FROM t1;
a b
1 1
2 2
**** On Slave ****
INSERT INTO t1 VALUE (3,3);
SELECT * FROM t1;
a b
1 1
2 2
3 3
**** On Master ****
TRUNCATE TABLE t1;
SELECT * FROM t1;
a b
**** On Slave ****
SELECT * FROM t1;
a b
**** On Master ****
DROP TABLE t1;
SHOW BINLOG EVENTS;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 4 Format_desc 1 102 Server ver: SERVER_VERSION, Binlog ver: 4
master-bin.000001 102 Query 1 210 use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=InnoDB
master-bin.000001 210 Query 1 97 use `test`; INSERT INTO t1 VALUES (1,1), (2,2)
master-bin.000001 307 Xid 1 334 COMMIT /* xid= */
master-bin.000001 334 Query 1 80 use `test`; TRUNCATE TABLE t1
master-bin.000001 414 Xid 1 441 COMMIT /* xid= */
master-bin.000001 441 Query 1 517 use `test`; DROP TABLE t1
**** On Master ****
SET SESSION BINLOG_FORMAT=ROW;
SET GLOBAL BINLOG_FORMAT=ROW;
CREATE TABLE t1 (a INT, b LONG) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1,1), (2,2);
SELECT * FROM t1;
a b
1 1
2 2
**** On Slave ****
INSERT INTO t1 VALUE (3,3);
SELECT * FROM t1;
a b
1 1
2 2
3 3
**** On Master ****
TRUNCATE TABLE t1;
SELECT * FROM t1;
a b
**** On Slave ****
SELECT * FROM t1;
a b
**** On Master ****
DROP TABLE t1;
SHOW BINLOG EVENTS;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 4 Format_desc 1 102 Server ver: SERVER_VERSION, Binlog ver: 4
master-bin.000001 102 Query 1 210 use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=InnoDB
master-bin.000001 210 Table_map 1 40 table_id: # (test.t1)
master-bin.000001 250 Write_rows 1 87 table_id: # flags: STMT_END_F
master-bin.000001 297 Xid 1 324 COMMIT /* xid= */
master-bin.000001 324 Query 1 80 use `test`; TRUNCATE TABLE t1
master-bin.000001 404 Xid 1 431 COMMIT /* xid= */
master-bin.000001 431 Query 1 507 use `test`; DROP TABLE t1
**** On Master ****
SET SESSION BINLOG_FORMAT=STATEMENT;
SET GLOBAL BINLOG_FORMAT=STATEMENT;
CREATE TABLE t1 (a INT, b LONG) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1,1), (2,2);
SELECT * FROM t1;
a b
1 1
2 2
**** On Slave ****
INSERT INTO t1 VALUE (3,3);
SELECT * FROM t1;
a b
1 1
2 2
3 3
**** On Master ****
DELETE FROM t1;
SELECT * FROM t1;
a b
**** On Slave ****
SELECT * FROM t1;
a b
**** On Master ****
DROP TABLE t1;
SHOW BINLOG EVENTS;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 4 Format_desc 1 102 Server ver: SERVER_VERSION, Binlog ver: 4
master-bin.000001 102 Query 1 210 use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=InnoDB
master-bin.000001 210 Query 1 97 use `test`; INSERT INTO t1 VALUES (1,1), (2,2)
master-bin.000001 307 Xid 1 334 COMMIT /* xid= */
master-bin.000001 334 Query 1 77 use `test`; DELETE FROM t1
master-bin.000001 411 Xid 1 438 COMMIT /* xid= */
master-bin.000001 438 Query 1 514 use `test`; DROP TABLE t1
**** On Master ****
SET SESSION BINLOG_FORMAT=MIXED;
SET GLOBAL BINLOG_FORMAT=MIXED;
CREATE TABLE t1 (a INT, b LONG) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1,1), (2,2);
SELECT * FROM t1;
a b
1 1
2 2
**** On Slave ****
INSERT INTO t1 VALUE (3,3);
SELECT * FROM t1;
a b
1 1
2 2
3 3
**** On Master ****
DELETE FROM t1;
SELECT * FROM t1;
a b
**** On Slave ****
SELECT * FROM t1;
a b
**** On Master ****
DROP TABLE t1;
SHOW BINLOG EVENTS;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 4 Format_desc 1 102 Server ver: SERVER_VERSION, Binlog ver: 4
master-bin.000001 102 Query 1 210 use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=InnoDB
master-bin.000001 210 Query 1 97 use `test`; INSERT INTO t1 VALUES (1,1), (2,2)
master-bin.000001 307 Xid 1 334 COMMIT /* xid= */
master-bin.000001 334 Query 1 77 use `test`; DELETE FROM t1
master-bin.000001 411 Xid 1 438 COMMIT /* xid= */
master-bin.000001 438 Query 1 514 use `test`; DROP TABLE t1
**** On Master ****
SET SESSION BINLOG_FORMAT=ROW;
SET GLOBAL BINLOG_FORMAT=ROW;
CREATE TABLE t1 (a INT, b LONG) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1,1), (2,2);
SELECT * FROM t1;
a b
1 1
2 2
**** On Slave ****
INSERT INTO t1 VALUE (3,3);
SELECT * FROM t1;
a b
1 1
2 2
3 3
**** On Master ****
DELETE FROM t1;
SELECT * FROM t1;
a b
**** On Slave ****
SELECT * FROM t1;
a b
3 3
**** On Master ****
DROP TABLE t1;
SHOW BINLOG EVENTS;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 4 Format_desc 1 102 Server ver: SERVER_VERSION, Binlog ver: 4
master-bin.000001 102 Query 1 210 use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=InnoDB
master-bin.000001 210 Table_map 1 40 table_id: # (test.t1)
master-bin.000001 250 Write_rows 1 87 table_id: # flags: STMT_END_F
master-bin.000001 297 Xid 1 324 COMMIT /* xid= */
master-bin.000001 324 Table_map 1 40 table_id: # (test.t1)
master-bin.000001 364 Delete_rows 1 87 table_id: # flags: STMT_END_F
master-bin.000001 411 Xid 1 438 COMMIT /* xid= */
master-bin.000001 438 Query 1 514 use `test`; DROP TABLE t1
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;
**** On Master ****
CREATE TABLE t1 (a INT PRIMARY KEY, b LONG) ENGINE=NDB;
INSERT INTO t1 VALUES (1,1), (2,2);
SELECT * FROM t1 ORDER BY a,b;
a b
1 1
2 2
**** On Slave ****
INSERT INTO t1 VALUE (3,3);
SELECT * FROM t1 ORDER BY a,b;
a b
1 1
2 2
3 3
**** On Master ****
TRUNCATE TABLE t1;
SELECT * FROM t1 ORDER BY a,b;
a b
**** On Slave ****
SELECT * FROM t1 ORDER BY a,b;
a b
**** On Master ****
DROP TABLE t1;
SHOW BINLOG EVENTS;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 4 Format_desc 1 102 Server ver: SERVER_VERSION, Binlog ver: 4
master-bin.000001 102 Query 1 219 use `test`; CREATE TABLE t1 (a INT PRIMARY KEY, b LONG) ENGINE=NDB
master-bin.000001 219 Query 1 283 BEGIN
master-bin.000001 283 Table_map 1 40 table_id: # (test.t1)
master-bin.000001 323 Table_map 1 93 table_id: # (cluster.apply_status)
master-bin.000001 376 Write_rows 1 135 table_id: #
master-bin.000001 418 Write_rows 1 182 table_id: # flags: STMT_END_F
master-bin.000001 465 Query 1 530 COMMIT
master-bin.000001 530 Query 1 80 use `test`; TRUNCATE TABLE t1
master-bin.000001 610 Query 1 679 use `test`; COMMIT
master-bin.000001 679 Query 1 743 BEGIN
master-bin.000001 743 Table_map 1 40 table_id: # (test.t1)
master-bin.000001 783 Table_map 1 93 table_id: # (cluster.apply_status)
master-bin.000001 836 Write_rows 1 135 table_id: #
master-bin.000001 878 Delete_rows 1 174 table_id: # flags: STMT_END_F
master-bin.000001 917 Query 1 982 COMMIT
master-bin.000001 982 Query 1 1058 use `test`; DROP TABLE t1
**** On Master ****
CREATE TABLE t1 (a INT PRIMARY KEY, b LONG) ENGINE=NDB;
INSERT INTO t1 VALUES (1,1), (2,2);
SELECT * FROM t1 ORDER BY a,b;
a b
1 1
2 2
**** On Slave ****
INSERT INTO t1 VALUE (3,3);
SELECT * FROM t1 ORDER BY a,b;
a b
1 1
2 2
3 3
**** On Master ****
DELETE FROM t1;
SELECT * FROM t1 ORDER BY a,b;
a b
**** On Slave ****
SELECT * FROM t1 ORDER BY a,b;
a b
3 3
**** On Master ****
DROP TABLE t1;
SHOW BINLOG EVENTS;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 4 Format_desc 1 102 Server ver: SERVER_VERSION, Binlog ver: 4
master-bin.000001 102 Query 1 219 use `test`; CREATE TABLE t1 (a INT PRIMARY KEY, b LONG) ENGINE=NDB
master-bin.000001 219 Query 1 283 BEGIN
master-bin.000001 283 Table_map 1 40 table_id: # (test.t1)
master-bin.000001 323 Table_map 1 93 table_id: # (cluster.apply_status)
master-bin.000001 376 Write_rows 1 135 table_id: #
master-bin.000001 418 Write_rows 1 182 table_id: # flags: STMT_END_F
master-bin.000001 465 Query 1 530 COMMIT
master-bin.000001 530 Query 1 80 use `test`; TRUNCATE TABLE t1
master-bin.000001 610 Query 1 679 use `test`; COMMIT
master-bin.000001 679 Query 1 743 BEGIN
master-bin.000001 743 Table_map 1 40 table_id: # (test.t1)
master-bin.000001 783 Table_map 1 93 table_id: # (cluster.apply_status)
master-bin.000001 836 Write_rows 1 135 table_id: #
master-bin.000001 878 Delete_rows 1 174 table_id: # flags: STMT_END_F
master-bin.000001 917 Query 1 982 COMMIT
master-bin.000001 982 Query 1 1058 use `test`; DROP TABLE t1
master-bin.000001 1058 Query 1 1175 use `test`; CREATE TABLE t1 (a INT PRIMARY KEY, b LONG) ENGINE=NDB
master-bin.000001 1175 Query 1 1239 BEGIN
master-bin.000001 1239 Table_map 1 40 table_id: # (test.t1)
master-bin.000001 1279 Table_map 1 93 table_id: # (cluster.apply_status)
master-bin.000001 1332 Write_rows 1 135 table_id: #
master-bin.000001 1374 Write_rows 1 182 table_id: # flags: STMT_END_F
master-bin.000001 1421 Query 1 1486 COMMIT
master-bin.000001 1486 Query 1 1550 BEGIN
master-bin.000001 1550 Table_map 1 40 table_id: # (test.t1)
master-bin.000001 1590 Table_map 1 93 table_id: # (cluster.apply_status)
master-bin.000001 1643 Write_rows 1 135 table_id: #
master-bin.000001 1685 Delete_rows 1 174 table_id: # flags: STMT_END_F
master-bin.000001 1724 Query 1 1789 COMMIT
master-bin.000001 1789 Query 1 1865 use `test`; DROP TABLE t1
......@@ -382,9 +382,9 @@ Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length I
t1 MEMORY 10 Fixed 4 # # # # # NULL NULL NULL NULL latin1_swedish_ci NULL
t2 MEMORY 10 Fixed 4 # # # # # NULL NULL NULL NULL latin1_swedish_ci NULL
t3 MEMORY 10 Fixed 4 # # # # # NULL NULL NULL NULL latin1_swedish_ci NULL
delete from t1;
delete from t2;
delete from t3;
truncate table t1;
truncate table t2;
truncate table t3;
show table status;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 MEMORY 10 Fixed 0 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
......
......@@ -368,7 +368,7 @@ end|
insert into t1 values (666, 51.3)|
call bug2272()|
ERROR 42S22: Unknown column 'v' in 'field list'
delete from t1|
truncate table t1|
drop procedure bug2272|
create procedure bug2329_1()
begin
......@@ -520,7 +520,7 @@ declare exit handler for sqlexception select 'Error!';
open c;
fetch c into v;
end|
delete from t1|
truncate table t1|
call bug7299()|
ERROR 02000: No data - zero rows fetched, selected, or processed
drop procedure bug7299|
......@@ -621,7 +621,7 @@ val x bug8408()
3 3.14 3
7 7 3
drop function bug8408|
delete from t1|
truncate table t1|
drop procedure if exists bug10537|
create procedure bug10537()
load data local infile '/tmp/somefile' into table t1|
......
......@@ -78,7 +78,7 @@ replace t1 set data = data, id = "bar";
update t1 set id = "kaka", data = 3 where t1.data = data;
end|
call setcontext()|
select * from t1|
select * from t1 order by data|
id data
foo 1
kaka 3
......@@ -191,7 +191,7 @@ drop procedure if exists inc|
create procedure inc(inout io int)
set io = io + 1|
call iotest("io1", "io2", 1)|
select * from t1|
select * from t1 order by data desc|
id data
io2 2
io1 1
......@@ -224,7 +224,7 @@ set y2 = 4711;
insert into test.t1 values ("cbv2", y1);
end|
call cbv1()|
select * from t1|
select * from t1 order by data|
id data
cbv2 4
cbv1 4711
......@@ -251,7 +251,7 @@ call sub1("sub1c", (select i,d from t2 limit 1))|
ERROR 21000: Operand should contain 1 column(s)
call sub1("sub1d", (select 1 from (select 1) a))|
call sub2("sub2")|
select * from t1|
select * from t1 order by id|
id data
sub1a 7
sub1b 3
......@@ -272,7 +272,7 @@ set x = x-1;
insert into test.t1 values ("a0", x);
end while|
call a0(3)|
select * from t1|
select * from t1 order by data desc|
id data
a0 2
a0 1
......@@ -286,7 +286,7 @@ set x = x-1;
insert into test.t1 values ("a", x);
end while|
call a(3)|
select * from t1|
select * from t1 order by data desc|
id data
a 2
a 1
......@@ -300,7 +300,7 @@ insert into test.t1 values (repeat("b",3), x);
set x = x-1;
until x = 0 end repeat|
call b(3)|
select * from t1|
select * from t1 order by data desc|
id data
bbb 3
bbb 2
......@@ -323,7 +323,7 @@ iterate hmm;
insert into test.t1 values ("x", x);
end while hmm|
call c(3)|
select * from t1|
select * from t1 order by data desc|
id data
c 3
c 2
......@@ -354,7 +354,7 @@ insert into test.t1 values ("e", x);
set x = x-1;
end loop foo|
call e(3)|
select * from t1|
select * from t1 order by data desc|
id data
e 3
e 2
......@@ -373,7 +373,7 @@ end if|
call f(-2)|
call f(0)|
call f(4)|
select * from t1|
select * from t1 order by data|
id data
f 0
f 1
......@@ -393,7 +393,7 @@ end case|
call g(-42)|
call g(0)|
call g(1)|
select * from t1|
select * from t1 order by data|
id data
g 0
g 1
......@@ -413,7 +413,7 @@ end case|
call h(0)|
call h(1)|
call h(17)|
select * from t1|
select * from t1 order by data|
id data
h0 0
h1 1
......@@ -441,7 +441,7 @@ insert into t2 values ("x", 9, 4.1), ("y", -1, 19.2), ("z", 3, 2.2)|
drop procedure if exists sel1|
create procedure sel1()
begin
select * from t1;
select * from t1 order by data;
end|
call sel1()|
id data
......@@ -451,8 +451,8 @@ drop procedure sel1|
drop procedure if exists sel2|
create procedure sel2()
begin
select * from t1;
select * from t2;
select * from t1 order by data;
select * from t2 order by s;
end|
call sel2()|
id data
......@@ -473,7 +473,7 @@ select id,data into x,y from test.t1 limit 1;
insert into test.t1 values (concat(x, "2"), y+2);
end|
call into_test("into", 100)|
select * from t1|
select * from t1 order by data|
id data
into 100
into2 102
......@@ -487,7 +487,7 @@ select id,data into x,@z from test.t1 limit 1;
insert into test.t1 values (concat(x, "2"), y+2);
end|
call into_test2("into", 100)|
select id,data,@z from t1|
select id,data,@z from t1 order by data|
id data @z
into 100 100
into2 102 100
......@@ -619,14 +619,14 @@ insert into t2 values (append("a", "b"), mul(2,mul(3,4)), fun(1.7, 4, 6))|
select * from t2 where s = append("a", "b")|
s i d
ab 24 1324.36598821719
select * from t2 where i = mul(4,3) or i = mul(mul(3,4),2)|
select * from t2 where i = mul(4,3) or i = mul(mul(3,4),2) order by i|
s i d
xxxyyy 12 2.71828182845905
ab 24 1324.36598821719
select * from t2 where d = e()|
s i d
xxxyyy 12 2.71828182845905
select * from t2|
select * from t2 order by i|
s i d
xxxyyy 12 2.71828182845905
ab 24 1324.36598821719
......@@ -745,8 +745,8 @@ drop procedure if exists cur2|
create procedure cur2()
begin
declare done int default 0;
declare c1 cursor for select id,data from test.t1;
declare c2 cursor for select i from test.t2;
declare c1 cursor for select id,data from test.t1 order by id,data;
declare c2 cursor for select i from test.t2 order by i;
declare continue handler for sqlstate '02000' set done = 1;
open c1;
open c2;
......@@ -769,10 +769,10 @@ close c1;
close c2;
end|
call cur2()|
select * from t3|
select * from t3 order by i,s|
s i
foo 40
bar 3
foo 40
zap 663
delete from t1|
delete from t2|
......@@ -935,16 +935,16 @@ return (select sum(data) from t1)|
select f1()|
f1()
3
select id, f1() from t1|
select id, f1() from t1 order by id|
id f1()
a 3
b 3
create function f2() returns int
return (select data from t1 where data <= (select sum(data) from t1) limit 1)|
return (select data from t1 where data <= (select sum(data) from t1) order by data limit 1)|
select f2()|
f2()
1
select id, f2() from t1|
select id, f2() from t1 order by id|
id f2()
a 1
b 1
......@@ -959,14 +959,14 @@ end|
select f3()|
f3()
1
select id, f3() from t1|
select id, f3() from t1 order by id|
id f3()
a 1
b 1
select f1(), f3()|
f1() f3()
3 1
select id, f1(), f3() from t1|
select id, f1(), f3() from t1 order by id|
id f1() f3()
a 3 1
b 3 1
......@@ -975,7 +975,7 @@ return (select d from t1, t2 where t1.data = t2.i and t1.id= "b")|
select f4()|
f4()
2
select s, f4() from t2|
select s, f4() from t2 order by s|
s f4()
a 2
b 2
......@@ -1008,7 +1008,7 @@ return (select sum(data) from t1 where data <= f1())|
select f6()|
f6()
2
select id, f6() from t1|
select id, f6() from t1 order by id|
id f6()
a 2
b 2
......@@ -1016,7 +1016,7 @@ create view v1 (a) as select f1()|
select * from v1|
a
3
select id, a from t1, v1|
select id, a from t1, v1 order by id|
id a
a 3
b 3
......@@ -1027,7 +1027,7 @@ create view v2 (a) as select a*10 from v1|
select * from v2|
a
30
select id, a from t1, v2|
select id, a from t1, v2 order by id|
id a
a 30
b 30
......@@ -1072,7 +1072,7 @@ lock tables t1 read, t1 as t11 read|
select f3()|
f3()
1
select id, f3() from t1 as t11|
select id, f3() from t1 as t11 order by id|
id f3()
a 1
b 1
......@@ -1175,8 +1175,8 @@ drop function f12_2|
drop view v0|
drop view v1|
drop view v2|
delete from t1 |
delete from t2 |
truncate table t1 |
truncate table t2 |
drop table t4|
drop table if exists t3|
create table t3 (n int unsigned not null primary key, f bigint unsigned)|
......@@ -1355,7 +1355,7 @@ f
1
1
2
delete from t3|
truncate table t3|
insert into t3 values (0), (1)|
call fib(10)|
select * from t3 order by f asc|
......@@ -1814,7 +1814,7 @@ delete from t1|
call bug822('foo', 42)|
call bug822('foo', 42)|
call bug822('bar', 666)|
select * from t1|
select * from t1 order by data|
id data
foo 42
bar 666
......@@ -1837,7 +1837,7 @@ delete from t1 where id='foo'|
insert into t1 values ('bar', 7)|
call bug1495()|
delete from t1 where id='bar'|
select * from t1|
select * from t1 order by data|
id data
less 2
more 17
......@@ -1857,10 +1857,10 @@ end|
insert into t1 values ("foo", 12), ("bar", 7)|
call bug1547("foo")|
call bug1547("bar")|
select * from t1|
select * from t1 order by id|
id data
foo 12
bar 7
foo 12
less 2
more 17
delete from t1|
......@@ -1908,12 +1908,12 @@ insert into t2 values ("avg", 0, y);
end|
insert into t1 (data) values (3), (1), (5), (9), (4)|
call bug1874()|
select * from t2|
select * from t2 order by i|
s i d
max 9 0
avg 0 4.4
min 1 0
max 9 0
sum 22 0
avg 0 4.4
delete from t1|
delete from t2|
drop procedure bug1874|
......@@ -4466,7 +4466,7 @@ Error 1347 'test.v1' is not BASE TABLE
Error 1347 'test.v1' is not BASE TABLE
drop procedure bug13012|
drop view v1;
select * from t1|
select * from t1 order by data|
id data
aa 0
aa 1
......@@ -4819,7 +4819,7 @@ insert into t1 values ('c', 2), ('b', 3), ('a', 1)|
create procedure bug16474_1()
begin
declare x int;
select id from t1 order by x;
select id from t1 order by x, id;
end|
drop procedure if exists bug14945|
create table t3 (id int not null auto_increment primary key)|
......@@ -4833,30 +4833,30 @@ id
drop table t3|
drop procedure bug14945|
create procedure bug16474_2(x int)
select id from t1 order by x|
select id from t1 order by x, id|
call bug16474_1()|
id
c
b
a
b
c
call bug16474_2(1)|
id
c
b
a
b
c
call bug16474_2(2)|
id
c
b
a
b
c
drop procedure bug16474_1|
drop procedure bug16474_2|
set @x = 2|
select * from t1 order by @x|
select * from t1 order by @x, data|
id data
a 1
c 2
b 3
a 1
delete from t1|
drop function if exists bug15728|
drop table if exists t3|
......
......@@ -70,7 +70,7 @@ i ts
1067129999 2003-10-26 00:59:59
1067137200 2003-10-26 03:00:00
1067129999 2003-10-26 00:59:59
delete from t1;
truncate table t1;
set time_zone='Europe/Moscow';
insert into t1 (i, ts) values
(unix_timestamp('2004-01-01 00:00:00'),'2004-01-01 00:00:00'),
......@@ -85,7 +85,7 @@ i ts
1080428400 2004-03-28 03:00:00
1091304000 2003-08-01 00:00:00
1099175400 2004-10-31 02:30:00
delete from t1;
truncate table t1;
set time_zone='leap/Europe/Moscow';
insert into t1 (i, ts) values
(unix_timestamp('2004-01-01 00:00:00'),'2004-01-01 00:00:00'),
......@@ -100,7 +100,7 @@ i ts
1080428422 2004-03-28 03:00:00
1091304022 2003-08-01 00:00:00
1099175422 2004-10-31 02:30:00
delete from t1;
truncate table t1;
insert into t1 (i, ts) values
(unix_timestamp('1981-07-01 03:59:59'),'1981-07-01 03:59:59'),
(unix_timestamp('1981-07-01 04:00:00'),'1981-07-01 04:00:00');
......@@ -129,7 +129,7 @@ ts
1970-01-01 00:00:01
2037-12-31 23:59:59
0000-00-00 00:00:00
delete from t1;
truncate table t1;
set time_zone='MET';
insert into t1 values ('0000-00-00 00:00:00'),('1970-01-01 00:30:00'),
('1970-01-01 01:00:00'),('1970-01-01 01:00:01'),
......@@ -146,7 +146,7 @@ ts
1970-01-01 01:00:01
2038-01-01 00:59:59
0000-00-00 00:00:00
delete from t1;
truncate table t1;
set time_zone='+01:30';
insert into t1 values ('0000-00-00 00:00:00'),('1970-01-01 01:00:00'),
('1970-01-01 01:30:00'),('1970-01-01 01:30:01'),
......
......@@ -51,8 +51,8 @@ GRANT TRIGGER ON mysqltest_db1.t1 TO mysqltest_dfn@localhost;
---> connection: wl2818_definer_con
INSERT INTO t1 VALUES(0);
DROP TRIGGER trg1;
DELETE FROM t1;
DELETE FROM t2;
TRUNCATE TABLE t1;
TRUNCATE TABLE t2;
---> connection: default
REVOKE SUPER ON *.* FROM mysqltest_dfn@localhost;
......
......@@ -151,7 +151,7 @@ insert into t1 values ("0000-00-00 00:00:00 some trailer"),("2003-01-01 00:00:00
Warnings:
Warning 1264 Out of range value for column 't' at row 1
Warning 1264 Out of range value for column 't' at row 2
select * from t1;
select * from t1 order by t;
t
0000-00-00 00:00:00
2003-01-01 00:00:00
......
......@@ -323,7 +323,7 @@ select * from t3;
id_A id_B
1 1
2 NULL
delete from t3;
truncate table t3;
insert into t3 select t1.id as id_A, t2.id as id_B from t1 left join t2 on (t1.id = t2.id);
select * from t3;
id_A id_B
......
......@@ -59,7 +59,7 @@ ix+0
19990501000000
19991101000000
19990501000000
delete from t1;
truncate table t1;
insert into t1 values ("19991101000000"),("19990102030405"),("19990630232922"),("19990601000000");
select ix+0 from t1;
ix+0
......@@ -140,7 +140,7 @@ ix+0
0
0
0
delete from t1;
truncate table t1;
insert into t1 values ("00000000000000"),("20030101010160"),("20030101016001"),("20030101240101"),("20030132010101"),("20031301010101"),("20031200000000"),("20030000000000");
Warnings:
Warning 1265 Data truncated for column 'ix' at row 2
......@@ -160,7 +160,7 @@ ix+0
0
0
0
delete from t1;
truncate table t1;
insert into t1 values ("0000-00-00 00:00:00 some trailer"),("2003-01-01 00:00:00 some trailer");
Warnings:
Warning 1265 Data truncated for column 'ix' at row 1
......@@ -329,7 +329,7 @@ show columns from t1;
Field Type Null Key Default Extra
t1 timestamp YES CURRENT_TIMESTAMP
t2 datetime YES NULL
delete from t1;
truncate table t1;
insert into t1 values ('2004-04-01 00:00:00', '2004-04-01 00:00:00');
SET TIMESTAMP=1000000012;
update t1 set t1= '2004-04-02 00:00:00';
......
......@@ -1106,21 +1106,21 @@ insert ignore into v1 SELECT a from t2;
Warnings:
Error 1369 CHECK OPTION failed 'test.v1'
Error 1369 CHECK OPTION failed 'test.v1'
select * from t1;
select * from t1 order by a desc;
a
1
0
update v1 set a=-1 where a=0;
update v1 set a=2 where a=1;
ERROR HY000: CHECK OPTION failed 'test.v1'
select * from t1;
select * from t1 order by a desc;
a
1
-1
update v1 set a=0 where a=0;
insert into t2 values (1);
update v1,t2 set v1.a=v1.a-1 where v1.a=t2.a;
select * from t1;
select * from t1 order by a desc;
a
0
-1
......@@ -1310,12 +1310,12 @@ Warning 1264 Out of range value for column 'a' at row 3
Error 1369 CHECK OPTION failed 'test.v1'
Warning 1264 Out of range value for column 'a' at row 4
Error 1369 CHECK OPTION failed 'test.v1'
select * from t1;
select * from t1 order by a,b;
a b
1 row 1
2 row 2
3 row 3
select * from v1;
select * from v1 order by a,b;
a b
1 row 1
2 row 2
......
......@@ -3,6 +3,7 @@
# Taken FROM the select test
#
-- source include/have_archive.inc
-- source include/have_binlog_format_statement.inc
--disable_warnings
drop table if exists t1,t2,t3;
......
......@@ -670,14 +670,6 @@ alter table t1 max_rows=100000000000;
show create table t1;
drop table t1;
#
# Bug#17530: Incorrect key truncation on table creation caused server crash.
#
create table t1(f1 varchar(800) binary not null, key(f1)) engine = innodb
character set utf8 collate utf8_general_ci;
insert into t1 values('aaa');
drop table t1;
# End of 5.0 tests
#
......
......@@ -36,7 +36,6 @@ rpl_ndb_myisam2ndb : Bug #19710 Cluster replication to partition table fa
rpl_switch_stm_row_mixed : BUG#18590 2006-03-28 brian
rpl_row_blob_innodb : BUG#18980 2006-04-10 kent Test fails randomly
rpl_row_func003 : BUG#19074 2006-13-04 andrei test failed
rpl_row_inexist_tbl : BUG#18948 2006-03-09 mats Disabled since patch makes this test wait forever
rpl_sp : BUG#16456 2006-02-16 jmiller
# the below testcase have been reworked to avoid the bug, test contains comment, keep bug open
......
......@@ -83,7 +83,7 @@ eval SHOW CREATE TABLE federated.t2;
INSERT INTO federated.t2 (id, name) VALUES (1, 'foo');
INSERT INTO federated.t2 (id, name) VALUES (2, 'fee');
SELECT * FROM federated.t2;
SELECT * FROM federated.t2 ORDER BY id, name;
DROP TABLE federated.t2;
connection slave;
......@@ -110,7 +110,7 @@ eval CREATE TABLE federated.t1 (
INSERT INTO federated.t1 (id, name) VALUES (1, 'foo');
INSERT INTO federated.t1 (id, name) VALUES (2, 'fee');
SELECT * FROM federated.t1;
SELECT * FROM federated.t1 ORDER BY id,name;
DELETE FROM federated.t1;
DROP TABLE IF EXISTS federated.t1;
......@@ -125,7 +125,7 @@ eval CREATE TABLE federated.`t1%` (
INSERT INTO federated.`t1%` (id, name) VALUES (1, 'foo');
INSERT INTO federated.`t1%` (id, name) VALUES (2, 'fee');
SELECT * FROM federated.`t1%`;
SELECT * FROM federated.`t1%` ORDER BY id, name;
DELETE FROM federated.`t1%`;
DROP TABLE IF EXISTS federated.`t1%`;
......
......@@ -2510,3 +2510,16 @@ BEGIN;
INSERT INTO t1 VALUES (1);
OPTIMIZE TABLE t1;
DROP TABLE t1;
#######################################################################
# #
# Please, DO NOT TOUCH this file as well as the innodb.result file. #
# These files are to be modified ONLY BY INNOBASE guys. #
# #
# Use innodb_mysql.[test|result] files instead. #
# #
# If nevertheless you need to make some changes here, please, forward #
# your commit message To: dev@innodb.com Cc: dev-innodb@mysql.com #
# (otherwise your changes may be erased). #
# #
#######################################################################
......@@ -4,6 +4,14 @@
drop table if exists t1,t2,t1m,t1i,t2m,t2i,t4;
--enable_warnings
#
# Bug#17530: Incorrect key truncation on table creation caused server crash.
#
create table t1(f1 varchar(800) binary not null, key(f1)) engine = innodb
character set utf8 collate utf8_general_ci;
insert into t1 values('aaa');
drop table t1;
# BUG#16798: Uninitialized row buffer reads in ref-or-null optimizer
# (repeatable only w/innodb).
create table t1 (
......
......@@ -370,7 +370,7 @@ insert into t2(uid, name) values
(25, CHAR(64+25)),
(26, CHAR(64+26));
insert into t1(uid, name) select uid, name from t2;
insert into t1(uid, name) select uid, name from t2 order by uid;
delete from t2;
insert into t2(id, uid, name) select id, uid, name from t1;
......
-- source include/have_row_based.inc
-- source include/have_binlog_format_statement.inc
-- source include/master-slave.inc
......
......@@ -36,3 +36,18 @@ USE test_ignore;
connection master;
DROP DATABASE test_ignore;
sync_slave_with_master;
# Bug#19995: Extreneous table maps generated for statements that does
# not generate rows
--disable_query_log
--source include/master-slave-reset.inc
--enable_query_log
connection master;
CREATE TABLE t1 (a INT);
DELETE FROM t1;
INSERT INTO t1 VALUES (1),(2);
DELETE FROM t1 WHERE a = 0;
UPDATE t1 SET a=99 WHERE a = 0;
--replace_regex /table_id: [0-9]+/table_id: #/
SHOW BINLOG EVENTS;
......@@ -7,6 +7,7 @@
# partition tables with same engine (MyISAM) in both ends. #
############################################################
--source include/have_row_based.inc
--source include/have_partition.inc
--source include/master-slave.inc
connection master;
......
......@@ -67,7 +67,7 @@ connection master;
CREATE TABLE t7 (UNIQUE(b)) SELECT a,b FROM tt3;
# Shouldn't be written to the binary log
--replace_regex /table_id: [0-9]+/table_id: #/
SHOW BINLOG EVENTS FROM 1326;
SHOW BINLOG EVENTS FROM 1256;
# Test that INSERT-SELECT works the same way as for SBR.
CREATE TABLE t7 (a INT, b INT UNIQUE);
......@@ -76,7 +76,7 @@ INSERT INTO t7 SELECT a,b FROM tt3;
SELECT * FROM t7 ORDER BY a,b;
# Should be written to the binary log
--replace_regex /table_id: [0-9]+/table_id: #/
SHOW BINLOG EVENTS FROM 1326;
SHOW BINLOG EVENTS FROM 1256;
sync_slave_with_master;
SELECT * FROM t7 ORDER BY a,b;
......@@ -87,7 +87,7 @@ BEGIN;
INSERT INTO t7 SELECT a,b FROM tt4;
ROLLBACK;
--replace_regex /table_id: [0-9]+/table_id: #/
SHOW BINLOG EVENTS FROM 1522;
SHOW BINLOG EVENTS FROM 1452;
SELECT * FROM t7 ORDER BY a,b;
sync_slave_with_master;
SELECT * FROM t7 ORDER BY a,b;
......@@ -101,7 +101,7 @@ CREATE TEMPORARY TABLE tt6 LIKE tt4;
--query_vertical SHOW CREATE TABLE t8
--query_vertical SHOW CREATE TABLE t9
--replace_regex /table_id: [0-9]+/table_id: #/
SHOW BINLOG EVENTS FROM 1618;
SHOW BINLOG EVENTS FROM 1548;
sync_slave_with_master;
--echo **** On Slave ****
--query_vertical SHOW CREATE TABLE t8
......
--replicate-ignore-table=test.t2
......@@ -6,15 +6,23 @@ source include/master-slave.inc;
connection master;
create table t1 (a int not null primary key);
insert into t1 values (1);
create table t2 (a int);
insert into t2 values (1);
update t1, t2 set t1.a = 0 where t1.a = t2.a;
sync_slave_with_master;
# t2 should not have been replicated
# t1 should have been properly updated
show tables;
select * from t1;
drop table t1;
connection master;
insert into t1 values (1);
insert into t1 values (2);
connection slave;
# slave should have stopped because can't find table
# slave should have stopped because can't find table t1
wait_for_slave_to_stop;
# see if we have a good error message:
--replace_result $MASTER_MYPORT MASTER_MYPORT
......@@ -24,4 +32,4 @@ show slave status;
# cleanup
connection master;
drop table t1;
drop table t1, t2;
......@@ -106,8 +106,8 @@ delete from t2;
# 4. VIEWs
delete from t1;
insert into t2 values(1),(2);
create view v1 as select f1(a) from t2;
select * from v1;
create view v1 as select f1(a) as f from t2;
select * from v1 order by f;
SELECT 'master:',a FROM t1 ORDER BY a;
sync_slave_with_master;
......
let $engine=MyISAM;
--source extra/rpl_tests/rpl_truncate.test
--source include/have_innodb.inc
let $engine=InnoDB;
--source extra/rpl_tests/rpl_truncate.test
--source include/have_ndb.inc
--source include/master-slave.inc
--disable_query_log
--disable_warnings
connection slave;
STOP SLAVE;
connection master;
DROP TABLE IF EXISTS t1;
RESET MASTER;
connection slave;
DROP TABLE IF EXISTS t1;
RESET SLAVE;
START SLAVE;
--enable_warnings
--enable_query_log
--echo **** On Master ****
connection master;
CREATE TABLE t1 (a INT PRIMARY KEY, b LONG) ENGINE=NDB;
INSERT INTO t1 VALUES (1,1), (2,2);
SELECT * FROM t1 ORDER BY a,b;
--echo **** On Slave ****
sync_slave_with_master;
INSERT INTO t1 VALUE (3,3);
SELECT * FROM t1 ORDER BY a,b;
--echo **** On Master ****
connection master;
TRUNCATE TABLE t1;
SELECT * FROM t1 ORDER BY a,b;
--echo **** On Slave ****
sync_slave_with_master;
# Should be empty
SELECT * FROM t1 ORDER BY a,b;
--echo **** On Master ****
connection master;
DROP TABLE t1;
--replace_regex /table_id: [0-9]+/table_id: #/
--replace_result $SERVER_VERSION SERVER_VERSION
SHOW BINLOG EVENTS;
--echo **** On Master ****
connection master;
CREATE TABLE t1 (a INT PRIMARY KEY, b LONG) ENGINE=NDB;
INSERT INTO t1 VALUES (1,1), (2,2);
SELECT * FROM t1 ORDER BY a,b;
--echo **** On Slave ****
sync_slave_with_master;
INSERT INTO t1 VALUE (3,3);
SELECT * FROM t1 ORDER BY a,b;
--echo **** On Master ****
connection master;
DELETE FROM t1;
SELECT * FROM t1 ORDER BY a,b;
--echo **** On Slave ****
sync_slave_with_master;
# Should be empty
SELECT * FROM t1 ORDER BY a,b;
--echo **** On Master ****
connection master;
DROP TABLE t1;
--replace_regex /table_id: [0-9]+/table_id: #/
--replace_result $SERVER_VERSION SERVER_VERSION
SHOW BINLOG EVENTS;
......@@ -255,9 +255,9 @@ delete from t2 where b=3;
delete from t3 where a=3;
--replace_column 6 # 7 # 8 # 9 # 10 #
show table status;
delete from t1;
delete from t2;
delete from t3;
truncate table t1;
truncate table t2;
truncate table t3;
--replace_column 6 # 7 # 8 # 9 #
show table status;
insert into t1 values (5);
......
......@@ -508,7 +508,7 @@ end|
insert into t1 values (666, 51.3)|
--error 1054
call bug2272()|
delete from t1|
truncate table t1|
drop procedure bug2272|
#
......@@ -742,7 +742,7 @@ begin
fetch c into v;
end|
delete from t1|
truncate table t1|
--error ER_SP_FETCH_NO_DATA
call bug7299()|
drop procedure bug7299|
......@@ -871,7 +871,7 @@ insert into t1 value (2, 2.7), (3, 3.14), (7, 7.0)|
select *,bug8408() from t1|
drop function bug8408|
delete from t1|
truncate table t1|
#
......
......@@ -143,7 +143,7 @@ begin
end|
call setcontext()|
select * from t1|
select * from t1 order by data|
delete from t1|
drop procedure setcontext|
......@@ -287,7 +287,7 @@ create procedure inc(inout io int)
set io = io + 1|
call iotest("io1", "io2", 1)|
select * from t1|
select * from t1 order by data desc|
delete from t1|
drop procedure iotest|
drop procedure inc2|
......@@ -333,7 +333,7 @@ begin
end|
call cbv1()|
select * from t1|
select * from t1 order by data|
delete from t1|
drop procedure cbv1|
drop procedure cbv2|
......@@ -371,7 +371,7 @@ call sub1("sub1b", (select max(i) from t2))|
call sub1("sub1c", (select i,d from t2 limit 1))|
call sub1("sub1d", (select 1 from (select 1) a))|
call sub2("sub2")|
select * from t1|
select * from t1 order by id|
select sub3((select max(i) from t2))|
drop procedure sub1|
drop procedure sub2|
......@@ -392,7 +392,7 @@ while x do
end while|
call a0(3)|
select * from t1|
select * from t1 order by data desc|
delete from t1|
drop procedure a0|
......@@ -408,7 +408,7 @@ while x > 0 do
end while|
call a(3)|
select * from t1|
select * from t1 order by data desc|
delete from t1|
drop procedure a|
......@@ -424,7 +424,7 @@ repeat
until x = 0 end repeat|
call b(3)|
select * from t1|
select * from t1 order by data desc|
delete from t1|
drop procedure b|
......@@ -456,7 +456,7 @@ hmm: while x > 0 do
end while hmm|
call c(3)|
select * from t1|
select * from t1 order by data desc|
delete from t1|
drop procedure c|
......@@ -493,7 +493,7 @@ foo: loop
end loop foo|
call e(3)|
select * from t1|
select * from t1 order by data desc|
delete from t1|
drop procedure e|
......@@ -514,7 +514,7 @@ end if|
call f(-2)|
call f(0)|
call f(4)|
select * from t1|
select * from t1 order by data|
delete from t1|
drop procedure f|
......@@ -536,7 +536,7 @@ end case|
call g(-42)|
call g(0)|
call g(1)|
select * from t1|
select * from t1 order by data|
delete from t1|
drop procedure g|
......@@ -558,7 +558,7 @@ end case|
call h(0)|
call h(1)|
call h(17)|
select * from t1|
select * from t1 order by data|
delete from t1|
drop procedure h|
......@@ -592,7 +592,7 @@ drop procedure if exists sel1|
--enable_warnings
create procedure sel1()
begin
select * from t1;
select * from t1 order by data;
end|
call sel1()|
......@@ -603,8 +603,8 @@ drop procedure if exists sel2|
--enable_warnings
create procedure sel2()
begin
select * from t1;
select * from t2;
select * from t1 order by data;
select * from t2 order by s;
end|
call sel2()|
......@@ -624,7 +624,7 @@ begin
end|
call into_test("into", 100)|
select * from t1|
select * from t1 order by data|
delete from t1|
drop procedure into_test|
......@@ -641,7 +641,7 @@ begin
end|
call into_test2("into", 100)|
select id,data,@z from t1|
select id,data,@z from t1 order by data|
delete from t1|
drop procedure into_test2|
......@@ -819,9 +819,9 @@ insert into t2 values (append("a", "b"), mul(2,mul(3,4)), fun(1.7, 4, 6))|
# Disable PS because double's give a bit different values
--disable_ps_protocol
select * from t2 where s = append("a", "b")|
select * from t2 where i = mul(4,3) or i = mul(mul(3,4),2)|
select * from t2 where i = mul(4,3) or i = mul(mul(3,4),2) order by i|
select * from t2 where d = e()|
select * from t2|
select * from t2 order by i|
--enable_ps_protocol
delete from t2|
......@@ -976,8 +976,8 @@ drop procedure if exists cur2|
create procedure cur2()
begin
declare done int default 0;
declare c1 cursor for select id,data from test.t1;
declare c2 cursor for select i from test.t2;
declare c1 cursor for select id,data from test.t1 order by id,data;
declare c2 cursor for select i from test.t2 order by i;
declare continue handler for sqlstate '02000' set done = 1;
open c1;
......@@ -1003,7 +1003,7 @@ begin
end|
call cur2()|
select * from t3|
select * from t3 order by i,s|
delete from t1|
delete from t2|
drop table t3|
......@@ -1178,13 +1178,13 @@ create function f1() returns int
return (select sum(data) from t1)|
select f1()|
# This should work too (and give 2 rows as result)
select id, f1() from t1|
select id, f1() from t1 order by id|
# Function which uses two instances of table simultaneously
create function f2() returns int
return (select data from t1 where data <= (select sum(data) from t1) limit 1)|
return (select data from t1 where data <= (select sum(data) from t1) order by data limit 1)|
select f2()|
select id, f2() from t1|
select id, f2() from t1 order by id|
# Function which uses the same table twice in different queries
create function f3() returns int
......@@ -1196,17 +1196,17 @@ begin
return n < m;
end|
select f3()|
select id, f3() from t1|
select id, f3() from t1 order by id|
# Calling two functions using same table
select f1(), f3()|
select id, f1(), f3() from t1|
select id, f1(), f3() from t1 order by id|
# Function which uses two different tables
create function f4() returns double
return (select d from t1, t2 where t1.data = t2.i and t1.id= "b")|
select f4()|
select s, f4() from t2|
select s, f4() from t2 order by s|
# Recursive functions which due to this recursion require simultaneous
# access to several instance of the same table won't work
......@@ -1239,7 +1239,7 @@ end|
create function f7() returns int
return (select sum(data) from t1 where data <= f1())|
select f6()|
select id, f6() from t1|
select id, f6() from t1 order by id|
#
# Let us test how new locking work with views
......@@ -1247,12 +1247,12 @@ select id, f6() from t1|
# The most trivial view
create view v1 (a) as select f1()|
select * from v1|
select id, a from t1, v1|
select id, a from t1, v1 order by id|
select * from v1, v1 as v|
# A bit more complex construction
create view v2 (a) as select a*10 from v1|
select * from v2|
select id, a from t1, v2|
select id, a from t1, v2 order by id|
select * from v1, v2|
# Nice example where the same view is used on
......@@ -1297,7 +1297,7 @@ select *, f0() from v0|
lock tables t1 read, t1 as t11 read|
# These should work well
select f3()|
select id, f3() from t1 as t11|
select id, f3() from t1 as t11 order by id|
# Degenerate cases work too :)
select f0()|
select * from v0|
......@@ -1407,8 +1407,8 @@ drop function f12_2|
drop view v0|
drop view v1|
drop view v2|
delete from t1 |
delete from t2 |
truncate table t1 |
truncate table t2 |
drop table t4|
# End of non-bug tests
......@@ -1596,7 +1596,7 @@ call fib(3)|
select * from t3 order by f asc|
delete from t3|
truncate table t3|
# The original test, 20 levels, ran into memory limits on some machines
# and builds. Try 10 instead...
......@@ -1693,7 +1693,6 @@ begin
end if;
return x;
end|
select * from t1 where data = getcount("bar")|
select * from t3|
select getcount("zip")|
......@@ -2120,7 +2119,7 @@ delete from t1|
call bug822('foo', 42)|
call bug822('foo', 42)|
call bug822('bar', 666)|
select * from t1|
select * from t1 order by data|
delete from t1|
drop procedure bug822|
......@@ -2148,7 +2147,7 @@ delete from t1 where id='foo'|
insert into t1 values ('bar', 7)|
call bug1495()|
delete from t1 where id='bar'|
select * from t1|
select * from t1 order by data|
delete from t1|
drop procedure bug1495|
......@@ -2173,7 +2172,7 @@ end|
insert into t1 values ("foo", 12), ("bar", 7)|
call bug1547("foo")|
call bug1547("bar")|
select * from t1|
select * from t1 order by id|
delete from t1|
drop procedure bug1547|
......@@ -2240,7 +2239,7 @@ end|
insert into t1 (data) values (3), (1), (5), (9), (4)|
call bug1874()|
select * from t2|
select * from t2 order by i|
delete from t1|
delete from t2|
drop procedure bug1874|
......@@ -5260,7 +5259,7 @@ call bug13012()|
call bug13012()|
drop procedure bug13012|
drop view v1;
select * from t1|
select * from t1 order by data|
#
# A test case for Bug#15392 "Server crashes during prepared statement
......@@ -5669,7 +5668,7 @@ create procedure bug16474_1()
begin
declare x int;
select id from t1 order by x;
select id from t1 order by x, id;
end|
#
......@@ -5689,7 +5688,7 @@ drop procedure bug14945|
# This does NOT order by column index; variable is an expression.
create procedure bug16474_2(x int)
select id from t1 order by x|
select id from t1 order by x, id|
call bug16474_1()|
call bug16474_2(1)|
......@@ -5699,7 +5698,7 @@ drop procedure bug16474_2|
# For reference: user variables are expressions too and do not affect ordering.
set @x = 2|
select * from t1 order by @x|
select * from t1 order by @x, data|
delete from t1|
......
......@@ -69,7 +69,7 @@ set time_zone='UTC';
select * from t1;
delete from t1;
truncate table t1;
# Simple check for 'Europe/Moscow' time zone just for showing that it works
set time_zone='Europe/Moscow';
......@@ -79,7 +79,7 @@ insert into t1 (i, ts) values
(unix_timestamp('2004-08-01 00:00:00'),'2003-08-01 00:00:00'),
(unix_timestamp('2004-10-31 02:30:00'),'2004-10-31 02:30:00');
select * from t1;
delete from t1;
truncate table t1;
#
......@@ -94,7 +94,7 @@ insert into t1 (i, ts) values
(unix_timestamp('2004-08-01 00:00:00'),'2003-08-01 00:00:00'),
(unix_timestamp('2004-10-31 02:30:00'),'2004-10-31 02:30:00');
select * from t1;
delete from t1;
truncate table t1;
# Let us test leap jump
insert into t1 (i, ts) values
(unix_timestamp('1981-07-01 03:59:59'),'1981-07-01 03:59:59'),
......@@ -115,14 +115,14 @@ insert into t1 values ('0000-00-00 00:00:00'),('1969-12-31 23:59:59'),
('1970-01-01 00:00:00'),('1970-01-01 00:00:01'),
('2037-12-31 23:59:59'),('2038-01-01 00:00:00');
select * from t1;
delete from t1;
truncate table t1;
# MET time zone has range shifted by one hour
set time_zone='MET';
insert into t1 values ('0000-00-00 00:00:00'),('1970-01-01 00:30:00'),
('1970-01-01 01:00:00'),('1970-01-01 01:00:01'),
('2038-01-01 00:59:59'),('2038-01-01 01:00:00');
select * from t1;
delete from t1;
truncate table t1;
# same for +01:30 time zone
set time_zone='+01:30';
insert into t1 values ('0000-00-00 00:00:00'),('1970-01-01 01:00:00'),
......
......@@ -151,8 +151,8 @@ INSERT INTO t1 VALUES(0);
# Cleanup for further tests.
DROP TRIGGER trg1;
DELETE FROM t1;
DELETE FROM t2;
TRUNCATE TABLE t1;
TRUNCATE TABLE t2;
--disconnect wl2818_definer_con
......
......@@ -98,7 +98,7 @@ insert into t1 values
select * from t1;
delete from t1;
insert into t1 values ("0000-00-00 00:00:00 some trailer"),("2003-01-01 00:00:00 some trailer");
select * from t1;
select * from t1 order by t;
drop table t1;
#
......
......@@ -162,7 +162,7 @@ select t1.id as id_A, t2.id as id_B from t1 left join t2 on (t1.id = t2.id);
create table t3 (id_A integer unsigned not null, id_B integer unsigned null );
insert into t3 select t1.id as id_A, t2.id as id_B from t1 left join t2 using ( id );
select * from t3;
delete from t3;
truncate table t3;
insert into t3 select t1.id as id_A, t2.id as id_B from t1 left join t2 on (t1.id = t2.id);
select * from t3;
drop table t3;
......
......@@ -41,7 +41,7 @@ drop table t1;
create table t1 (ix timestamp);
insert into t1 values (19991101000000),(19990102030405),(19990630232922),(19990601000000),(19990930232922),(19990531232922),(19990501000000),(19991101000000),(19990501000000);
select ix+0 from t1;
delete from t1;
truncate table t1;
insert into t1 values ("19991101000000"),("19990102030405"),("19990630232922"),("19990601000000");
select ix+0 from t1;
drop table t1;
......@@ -82,10 +82,10 @@ drop table t1;
create table t1 (ix timestamp);
insert into t1 values (0),(20030101010160),(20030101016001),(20030101240101),(20030132010101),(20031301010101),(20031200000000),(20030000000000);
select ix+0 from t1;
delete from t1;
truncate table t1;
insert into t1 values ("00000000000000"),("20030101010160"),("20030101016001"),("20030101240101"),("20030132010101"),("20031301010101"),("20031200000000"),("20030000000000");
select ix+0 from t1;
delete from t1;
truncate table t1;
insert into t1 values ("0000-00-00 00:00:00 some trailer"),("2003-01-01 00:00:00 some trailer");
select ix+0 from t1;
drop table t1;
......@@ -186,7 +186,7 @@ insert into t1 (t1) values (default);
select * from t1;
show create table t1;
show columns from t1;
delete from t1;
truncate table t1;
#
# Let us test some cases when auto-set should be disabled or influence
......
......@@ -1035,18 +1035,18 @@ create table t2 (a int);
insert into t2 values (2),(3),(0);
# INSERT SELECT with ignore test
insert ignore into v1 SELECT a from t2;
select * from t1;
select * from t1 order by a desc;
#simple UPDATE test
update v1 set a=-1 where a=0;
-- error 1369
update v1 set a=2 where a=1;
select * from t1;
select * from t1 order by a desc;
# prepare data for next check
update v1 set a=0 where a=0;
insert into t2 values (1);
# multiupdate test
update v1,t2 set v1.a=v1.a-1 where v1.a=t2.a;
select * from t1;
select * from t1 order by a desc;
# prepare data for next check
update v1 set a=a+1;
# multiupdate with ignore test
......@@ -1226,8 +1226,8 @@ select * from t1;
select * from v1;
delete from t1;
load data infile '../std_data_ln/loaddata3.dat' ignore into table v1 fields terminated by '' enclosed by '' ignore 1 lines;
select * from t1;
select * from v1;
select * from t1 order by a,b;
select * from v1 order by a,b;
drop view v1;
drop table t1;
# variable length fields
......
......@@ -135,6 +135,7 @@ extern "C" {
#include "../storage/innobase/include/fil0fil.h"
#include "../storage/innobase/include/trx0xa.h"
#include "../storage/innobase/include/thr0loc.h"
#include "../storage/innobase/include/ha_prototypes.h"
}
#define HA_INNOBASE_ROWS_IN_TABLE 10000 /* to get optimization right */
......@@ -667,6 +668,61 @@ innobase_get_cset_width(
}
}
/**********************************************************************
Converts an identifier to a table name.
NOTE that the exact prototype of this function has to be in
/innobase/dict/dict0dict.c! */
extern "C"
void
innobase_convert_from_table_id(
/*===========================*/
char* to, /* out: converted identifier */
const char* from, /* in: identifier to convert */
ulint len) /* in: length of 'to', in bytes */
{
uint errors;
strconvert(current_thd->charset(), from,
&my_charset_filename, to, len, &errors);
}
/**********************************************************************
Converts an identifier to UTF-8.
NOTE that the exact prototype of this function has to be in
/innobase/dict/dict0dict.c! */
extern "C"
void
innobase_convert_from_id(
/*=====================*/
char* to, /* out: converted identifier */
const char* from, /* in: identifier to convert */
ulint len) /* in: length of 'to', in bytes */
{
uint errors;
strconvert(current_thd->charset(), from,
system_charset_info, to, len, &errors);
}
/**********************************************************************
Removes the filename encoding of a table or database name.
NOTE that the exact prototype of this function has to be in
/innobase/dict/dict0dict.c! */
extern "C"
void
innobase_convert_from_filename(
/*===========================*/
char* s) /* in: identifier; out: decoded identifier */
{
uint errors;
strconvert(&my_charset_filename, s,
system_charset_info, s, strlen(s), &errors);
}
/**********************************************************************
Compares NUL-terminated UTF-8 strings case insensitively.
......@@ -697,6 +753,21 @@ innobase_casedn_str(
my_casedn_str(system_charset_info, a);
}
/**************************************************************************
Determines the connection character set.
NOTE that the exact prototype of this function has to be in
/innobase/dict/dict0dict.c! */
extern "C"
struct charset_info_st*
innobase_get_charset(
/*=================*/
/* out: connection character set */
void* mysql_thd) /* in: MySQL thread handle */
{
return(((THD*) mysql_thd)->charset());
}
/*************************************************************************
Creates a temporary file. */
extern "C"
......@@ -742,6 +813,25 @@ innobase_mysql_tmpfile(void)
return(fd2);
}
/*************************************************************************
Wrapper around MySQL's copy_and_convert function, see it for
documentation. */
extern "C"
ulint
innobase_convert_string(
/*====================*/
void* to,
ulint to_length,
CHARSET_INFO* to_cs,
const void* from,
ulint from_length,
CHARSET_INFO* from_cs,
uint* errors)
{
return(copy_and_convert((char*)to, to_length, to_cs,
(const char*)from, from_length, from_cs, errors));
}
/*************************************************************************
Gets the InnoDB transaction handle for a MySQL handler object, creates
an InnoDB transaction struct if the corresponding MySQL thread struct still
......@@ -1076,23 +1166,69 @@ innobase_invalidate_query_cache(
}
/*********************************************************************
Get the quote character to be used in SQL identifiers.
Display an SQL identifier.
This definition must match the one in innobase/ut/ut0ut.c! */
extern "C"
int
mysql_get_identifier_quote_char(
/*============================*/
/* out: quote character to be
used in SQL identifiers; EOF if none */
void
innobase_print_identifier(
/*======================*/
FILE* f, /* in: output stream */
trx_t* trx, /* in: transaction */
ibool table_id,/* in: TRUE=decode table name */
const char* name, /* in: name to print */
ulint namelen)/* in: length of name */
{
const char* s = name;
char* qname = NULL;
int q;
if (table_id) {
/* Decode the table name. The filename_to_tablename()
function expects a NUL-terminated string. The input and
output strings buffers must not be shared. The function
only produces more output when the name contains other
characters than [0-9A-Z_a-z]. */
char* temp_name = my_malloc(namelen + 1, MYF(MY_WME));
uint qnamelen = namelen
+ (1 + sizeof srv_mysql50_table_name_prefix);
if (temp_name) {
qname = my_malloc(qnamelen, MYF(MY_WME));
if (qname) {
memcpy(temp_name, name, namelen);
temp_name[namelen] = 0;
s = qname;
namelen = filename_to_tablename(temp_name,
qname, qnamelen);
}
my_free(temp_name, MYF(0));
}
}
if (!trx || !trx->mysql_thd) {
return(EOF);
q = '"';
} else {
q = get_quote_char_for_identifier((THD*) trx->mysql_thd,
s, (int) namelen);
}
if (q == EOF) {
fwrite(s, 1, namelen, f);
} else {
const char* e = s + namelen;
putc(q, f);
while (s < e) {
int c = *s++;
if (c == q) {
putc(c, f);
}
putc(c, f);
}
putc(q, f);
}
return(get_quote_char_for_identifier((THD*) trx->mysql_thd,
name, (int) namelen));
my_free(qname, MYF(MY_ALLOW_ZERO_PTR));
}
/**************************************************************************
......@@ -1232,6 +1368,24 @@ innobase_init(void)
ut_a(DATA_MYSQL_TRUE_VARCHAR == (ulint)MYSQL_TYPE_VARCHAR);
#ifdef UNIV_DEBUG
static const char test_filename[] = "-@";
char test_tablename[sizeof test_filename
+ sizeof srv_mysql50_table_name_prefix];
if ((sizeof test_tablename) - 1
!= filename_to_tablename(test_filename, test_tablename,
sizeof test_tablename)
|| strncmp(test_tablename,
srv_mysql50_table_name_prefix,
sizeof srv_mysql50_table_name_prefix)
|| strcmp(test_tablename
+ sizeof srv_mysql50_table_name_prefix,
test_filename)) {
sql_print_error("tablename encoding has been changed");
goto error;
}
#endif /* UNIV_DEBUG */
/* Check that values don't overflow on 32-bit systems. */
if (sizeof(ulint) == 4) {
if (innobase_buffer_pool_size > UINT_MAX32) {
......@@ -2200,8 +2354,7 @@ ha_innobase::open(
/* Get pointer to a table object in InnoDB dictionary cache */
ib_table = dict_table_get_and_increment_handle_count(
norm_name, NULL);
ib_table = dict_table_get_and_increment_handle_count(norm_name);
if (NULL == ib_table) {
ut_print_timestamp(stderr);
......@@ -4116,6 +4269,9 @@ ha_innobase::index_prev(
mysql_byte* buf) /* in/out: buffer for previous row in MySQL
format */
{
statistic_increment(current_thd->status_var.ha_read_prev_count,
&LOCK_status);
return(general_fetch(buf, ROW_SEL_PREV, 0));
}
......@@ -4652,7 +4808,7 @@ ha_innobase::create(
/* Get the transaction associated with the current thd, or create one
if not yet created */
parent_trx = check_trx_exists(current_thd);
parent_trx = check_trx_exists(thd);
/* In case MySQL calls this in the middle of a SELECT query, release
possible adaptive hash latch to avoid deadlocks of threads */
......@@ -4748,20 +4904,9 @@ ha_innobase::create(
}
}
if (current_thd->query != NULL) {
LEX_STRING q;
if (thd->convert_string(&q, system_charset_info,
current_thd->query,
current_thd->query_length,
current_thd->charset())) {
error = HA_ERR_OUT_OF_MEM;
goto cleanup;
}
if (thd->query != NULL) {
error = row_table_add_foreign_constraints(trx,
q.str, norm_name,
thd->query, norm_name,
create_info->options & HA_LEX_CREATE_TMP_TABLE);
error = convert_error_code_to_mysql(error, NULL);
......@@ -4781,7 +4926,7 @@ ha_innobase::create(
log_buffer_flush_to_disk();
innobase_table = dict_table_get(norm_name, NULL);
innobase_table = dict_table_get(norm_name);
DBUG_ASSERT(innobase_table != 0);
......@@ -4917,7 +5062,7 @@ ha_innobase::delete_table(
/* Get the transaction associated with the current thd, or create one
if not yet created */
parent_trx = check_trx_exists(current_thd);
parent_trx = check_trx_exists(thd);
/* In case MySQL calls this in the middle of a SELECT query, release
possible adaptive hash latch to avoid deadlocks of threads */
......
......@@ -3234,35 +3234,128 @@ namespace {
}
}
template<class RowsEventT> int binlog_log_row(TABLE *table,
const byte *before_record,
const byte *after_record)
/*
Write table maps for all (manually or automatically) locked tables
to the binary log.
SYNOPSIS
write_locked_table_maps()
thd Pointer to THD structure
DESCRIPTION
This function will generate and write table maps for all tables
that are locked by the thread 'thd'. Either manually locked
(stored in THD::locked_tables) and automatically locked (stored
in THD::lock) are considered.
RETURN VALUE
0 All OK
1 Failed to write all table maps
SEE ALSO
THD::lock
THD::locked_tables
*/
namespace
{
if (table->file->is_injective())
return 0;
bool error= 0;
int write_locked_table_maps(THD *thd)
{
DBUG_ENTER("write_locked_table_maps");
DBUG_PRINT("enter", ("thd=%p, thd->lock=%p, thd->locked_tables=%p",
thd, thd->lock, thd->locked_tables));
if (thd->get_binlog_table_maps() == 0)
{
/*
Exactly one table has to be locked, otherwise this code is not
guaranteed to work.
*/
DBUG_ASSERT((thd->lock != NULL) + (thd->locked_tables != NULL) == 1);
MYSQL_LOCK *lock= thd->lock ? thd->lock : thd->locked_tables;
DBUG_ASSERT(lock->table_count > 0);
TABLE **const end_ptr= lock->table + lock->table_count;
for (TABLE **table_ptr= lock->table ;
table_ptr != end_ptr ;
++table_ptr)
{
TABLE *const table= *table_ptr;
DBUG_PRINT("info", ("Checking table %s", table->s->table_name));
if (table->current_lock == F_WRLCK &&
check_table_binlog_row_based(thd, table))
{
int const has_trans= table->file->has_transactions();
int const error= thd->binlog_write_table_map(table, has_trans);
/*
If an error occurs, it is the responsibility of the caller to
roll back the transaction.
*/
if (unlikely(error))
DBUG_RETURN(1);
}
}
}
DBUG_RETURN(0);
}
if (check_table_binlog_row_based(table->in_use, table))
template<class RowsEventT> int
binlog_log_row(TABLE* table,
const byte *before_record,
const byte *after_record)
{
error=
RowsEventT::binlog_row_logging_function(table->in_use, table,
table->file->has_transactions(),
&table->s->all_set,
table->s->fields,
before_record, after_record);
if (table->file->is_injective())
return 0;
bool error= 0;
THD *const thd= table->in_use;
if (check_table_binlog_row_based(thd, table))
{
MY_BITMAP cols;
/* Potential buffer on the stack for the bitmap */
uint32 bitbuf[BITMAP_STACKBUF_SIZE/sizeof(uint32)];
uint n_fields= table->s->fields;
my_bool use_bitbuf= n_fields <= sizeof(bitbuf)*8;
/*
If there are no table maps written to the binary log, this is
the first row handled in this statement. In that case, we need
to write table maps for all locked tables to the binary log.
*/
if (likely(!(error= bitmap_init(&cols,
use_bitbuf ? bitbuf : NULL,
(n_fields + 7) & ~7UL,
false))))
{
bitmap_set_all(&cols);
if (likely(!(error= write_locked_table_maps(thd))))
{
error=
RowsEventT::binlog_row_logging_function(thd, table,
table->file->has_transactions(),
&cols, table->s->fields,
before_record, after_record);
}
if (!use_bitbuf)
bitmap_free(&cols);
}
}
return error ? HA_ERR_RBR_LOGGING_FAILED : 0;
}
return error ? HA_ERR_RBR_LOGGING_FAILED : 0;
}
/*
Instantiate the versions we need for the above template function,
because we have -fno-implicit-template as compiling option.
*/
/*
Instantiate the versions we need for the above template function, because we
have -fno-implicit-template as compiling option.
*/
template int
binlog_log_row<Write_rows_log_event>(TABLE *, const byte *, const byte *);
template int binlog_log_row<Write_rows_log_event>(TABLE *, const byte *, const byte *);
template int binlog_log_row<Delete_rows_log_event>(TABLE *, const byte *, const byte *);
template int binlog_log_row<Update_rows_log_event>(TABLE *, const byte *, const byte *);
template int
binlog_log_row<Delete_rows_log_event>(TABLE *, const byte *, const byte *);
template int
binlog_log_row<Update_rows_log_event>(TABLE *, const byte *, const byte *);
}
#endif /* HAVE_ROW_BASED_REPLICATION */
......@@ -3272,41 +3365,6 @@ int handler::ha_external_lock(THD *thd, int lock_type)
int error;
if (unlikely(error= external_lock(thd, lock_type)))
DBUG_RETURN(error);
#ifdef HAVE_ROW_BASED_REPLICATION
if (table->file->is_injective())
DBUG_RETURN(0);
/*
There is a number of statements that are logged statement-based
but call external lock. For these, we do not need to generate a
table map.
TODO: The need for this switch is an indication that the model for
locking combined with row-based replication needs to be looked
over. Ideally, no such special handling should be needed.
*/
switch (thd->lex->sql_command) {
case SQLCOM_TRUNCATE:
case SQLCOM_ALTER_TABLE:
case SQLCOM_OPTIMIZE:
case SQLCOM_REPAIR:
DBUG_RETURN(0);
default:
break;
}
/*
If we are locking a table for writing, we generate a table map.
For all other kinds of locks, we don't do anything.
*/
if (lock_type == F_WRLCK && check_table_binlog_row_based(thd, table))
{
int const has_trans= table->file->has_transactions();
error= thd->binlog_write_table_map(table, has_trans);
if (unlikely(error))
DBUG_RETURN(error);
}
#endif
DBUG_RETURN(0);
}
......
......@@ -71,11 +71,17 @@ sql_print_message_func sql_print_message_handlers[3] =
struct binlog_trx_data {
bool empty() const
{
#ifdef HAVE_ROW_BASED_REPLICATION
return pending == NULL && my_b_tell(&trans_log) == 0;
#else
return my_b_tell(&trans_log) == 0;
#endif
}
binlog_trx_data() {}
IO_CACHE trans_log; // The transaction cache
#ifdef HAVE_ROW_BASED_REPLICATION
Rows_log_event *pending; // The pending binrows event
#endif
};
handlerton binlog_hton;
......@@ -1074,6 +1080,7 @@ binlog_end_trans(THD *thd, binlog_trx_data *trx_data, Log_event *end_ev)
#endif
error= mysql_bin_log.write(thd, trans_log, end_ev);
}
#ifdef HAVE_ROW_BASED_REPLICATION
else
{
#ifdef HAVE_ROW_BASED_REPLICATION
......@@ -1093,6 +1100,7 @@ binlog_end_trans(THD *thd, binlog_trx_data *trx_data, Log_event *end_ev)
transaction cache.
*/
mysql_bin_log.update_table_map_version();
#endif
statistic_increment(binlog_cache_use, &LOCK_status);
if (trans_log->disk_writes != 0)
......@@ -2605,7 +2613,6 @@ bool MYSQL_LOG::is_query_in_union(THD *thd, query_id_t query_id_param)
}
#ifdef HAVE_ROW_BASED_REPLICATION
/*
These functions are placed in this file since they need access to
binlog_hton, which has internal linkage.
......@@ -2641,6 +2648,7 @@ int THD::binlog_setup_trx_data()
engine has registered for the transaction.
*/
#ifdef HAVE_ROW_BASED_REPLICATION
int THD::binlog_write_table_map(TABLE *table, bool is_trans)
{
int error;
......@@ -2818,9 +2826,9 @@ bool MYSQL_LOG::write(Log_event *event_info)
we are inside a stored function, we do not end the statement since
this will close all tables on the slave.
*/
#ifdef HAVE_ROW_BASED_REPLICATION
bool const end_stmt=
thd->prelocked_mode && thd->lex->requires_prelocking();
#ifdef HAVE_ROW_BASED_REPLICATION
thd->binlog_flush_pending_rows_event(end_stmt);
#endif /*HAVE_ROW_BASED_REPLICATION*/
......@@ -2871,7 +2879,6 @@ bool MYSQL_LOG::write(Log_event *event_info)
(binlog_trx_data*) thd->ha_data[binlog_hton.slot];
IO_CACHE *trans_log= &trx_data->trans_log;
bool trans_log_in_use= my_b_tell(trans_log) != 0;
if (event_info->get_cache_stmt() && !trans_log_in_use)
trans_register_ha(thd,
(thd->options &
......
......@@ -5595,6 +5595,7 @@ int Rows_log_event::exec_event(st_relay_log_info *rli)
bool Rows_log_event::write_data_header(IO_CACHE *file)
{
byte buf[ROWS_HEADER_LEN]; // No need to init the buffer
DBUG_ASSERT(m_table_id != ~0UL);
DBUG_EXECUTE_IF("old_row_based_repl_4_byte_map_id_master",
{
int4store(buf + 0, m_table_id);
......@@ -5845,9 +5846,7 @@ int Table_map_log_event::exec_event(st_relay_log_info *rli)
/*
Open the table if it is not already open and add the table to table map.
If the table should not be replicated, we don't bother to do anything.
The table map will return NULL and the row-level event will effectively
be a no-op.
Note that for any table that should not be replicated, a filter is needed.
*/
uint count;
/*
......@@ -5863,34 +5862,14 @@ int Table_map_log_event::exec_event(st_relay_log_info *rli)
/*
Error reporting borrowed from Query_log_event with many excessive
simplifications (we don't honour --slave-skip-errors)
BUG: There can be extreneous table maps in the binary log,
so in case we fail to open the table, we just generate a
warning and do not add the table to the list of tables to
open and lock.
*/
uint actual_error= thd->net.last_errno;
switch (actual_error)
{
case ER_NO_SUCH_TABLE:
slave_print_msg(WARNING_LEVEL, rli, actual_error,
thd->net.last_error ?
thd->net.last_error :
"<no message>");
clear_all_errors(thd, rli);
rli->inc_event_relay_log_pos(); // Continue with next event
error= 0;
break;
default:
slave_print_msg(ERROR_LEVEL, rli, actual_error,
"Error '%s' on opening table `%s`.`%s`",
(actual_error ? thd->net.last_error :
"unexpected success or fatal error"),
table_list->db, table_list->table_name);
thd->query_error= 1;
break;
}
slave_print_msg(ERROR_LEVEL, rli, actual_error,
"Error '%s' on opening table `%s`.`%s`",
(actual_error ? thd->net.last_error :
"unexpected success or fatal error"),
table_list->db, table_list->table_name);
thd->query_error= 1;
}
DBUG_RETURN(error);
}
......
......@@ -1301,15 +1301,20 @@ bool sys_var_thd_binlog_format::is_readonly() const
if global or not here.
And this test will also prevent switching from RBR to RBR (a no-op which
should not happen too often).
If we don't have row-based replication compiled in, the variable
is always read-only.
*/
#ifdef HAVE_ROW_BASED_REPLICATION
#ifndef HAVE_ROW_BASED_REPLICATION
my_error(ER_RBR_NOT_AVAILABLE, MYF(0));
return 1;
#else
if ((thd->variables.binlog_format == BINLOG_FORMAT_ROW) &&
thd->temporary_tables)
{
my_error(ER_TEMP_TABLE_PREVENTS_SWITCH_OUT_OF_RBR, MYF(0));
return 1;
}
#endif /*HAVE_ROW_BASED_REPLICATION*/
/*
if in a stored function, it's too late to change mode
*/
......@@ -1327,10 +1332,12 @@ bool sys_var_thd_binlog_format::is_readonly() const
my_error(ER_NDB_CANT_SWITCH_BINLOG_FORMAT, MYF(0));
return 1;
}
#endif
#endif /* HAVE_NDB_BINLOG */
#endif /* HAVE_ROW_BASED_REPLICATION */
return sys_var_thd_enum::is_readonly();
}
void fix_binlog_format_after_update(THD *thd, enum_var_type type)
{
#ifdef HAVE_ROW_BASED_REPLICATION
......@@ -1338,6 +1345,7 @@ void fix_binlog_format_after_update(THD *thd, enum_var_type type)
#endif /*HAVE_ROW_BASED_REPLICATION*/
}
static void fix_max_binlog_size(THD *thd, enum_var_type type)
{
DBUG_ENTER("fix_max_binlog_size");
......
......@@ -881,15 +881,20 @@ class sys_var_event_scheduler :public sys_var_long_ptr
byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
};
#ifdef HAVE_ROW_BASED_REPLICATION
extern void fix_binlog_format_after_update(THD *thd, enum_var_type type);
#endif
class sys_var_thd_binlog_format :public sys_var_thd_enum
{
public:
sys_var_thd_binlog_format(const char *name_arg, ulong SV::*offset_arg)
:sys_var_thd_enum(name_arg, offset_arg,
&binlog_format_typelib,
fix_binlog_format_after_update)
&binlog_format_typelib
#ifdef HAVE_ROW_BASED_REPLICATION
, fix_binlog_format_after_update
#endif
)
{};
bool is_readonly() const;
};
......
......@@ -5835,3 +5835,5 @@ ER_EVENT_SET_VAR_ERROR
ER_PARTITION_MERGE_ERROR
eng "%s handler cannot be used in partitioned tables"
swe "%s kan inte anvndas i en partitionerad tabell"
ER_RBR_NOT_AVAILABLE
eng "The server was not built with row-based replication"
......@@ -2132,7 +2132,9 @@ void THD::reset_sub_statement_state(Sub_statement_state *backup,
if ((!lex->requires_prelocking() || is_update_query(lex->sql_command)) &&
!current_stmt_binlog_row_based)
{
options&= ~OPTION_BIN_LOG;
}
/* Disable result sets */
client_capabilities &= ~CLIENT_MULTI_RESULTS;
in_sub_stmt|= new_state;
......@@ -2638,31 +2640,6 @@ int THD::binlog_flush_pending_rows_event(bool stmt_end)
error= mysql_bin_log.flush_and_set_pending_rows_event(this, 0);
}
else if (stmt_end && binlog_table_maps > 0)
{ /* there is no pending event at this point */
/*
If pending is null and we are going to end the statement, we
have to write an extra, empty, binrow event so that the slave
knows to discard the tables it has received. Otherwise, the
table maps written this far will be included in the table maps
for the following statement.
TODO: Remove the need for a dummy event altogether. It can be
fixed if we can write table maps to a memory buffer before
writing the first binrow event. We can then flush and clear the
memory buffer with table map events before writing the first
binrow event. In the event of a crash, nothing is lost since
the table maps are only needed if there are binrow events.
*/
Rows_log_event *ev=
new Write_rows_log_event(this, 0, ~0UL, 0, FALSE);
ev->set_flags(Rows_log_event::STMT_END_F);
binlog_set_pending_rows_event(ev);
error= mysql_bin_log.flush_and_set_pending_rows_event(this, 0);
binlog_table_maps= 0;
}
DBUG_RETURN(error);
}
......@@ -2720,6 +2697,7 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype,
to how you treat this.
*/
case THD::ROW_QUERY_TYPE:
#ifdef HAVE_ROW_BASED_REPLICATION
if (current_stmt_binlog_row_based)
{
/*
......@@ -2740,6 +2718,7 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype,
#endif /*HAVE_ROW_BASED_REPLICATION*/
DBUG_RETURN(0);
}
#endif
/* Otherwise, we fall through */
case THD::STMT_QUERY_TYPE:
/*
......@@ -2748,7 +2727,9 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype,
*/
{
Query_log_event qinfo(this, query, query_len, is_trans, suppress_use);
#ifdef HAVE_ROW_BASED_REPLICATION
qinfo.flags|= LOG_EVENT_UPDATE_TABLE_MAP_VERSION_F;
#endif
/*
Binlog table maps will be irrelevant after a Query_log_event
(they are just removed on the slave side) so after the query
......
......@@ -907,8 +907,10 @@ class THD :public Statement,
/* container for handler's private per-connection data */
void *ha_data[MAX_HA];
#ifdef HAVE_ROW_BASED_REPLICATION
#ifndef MYSQL_CLIENT
int binlog_setup_trx_data();
#ifdef HAVE_ROW_BASED_REPLICATION
/*
Public interface to write RBR events to the binlog
......@@ -938,7 +940,6 @@ class THD :public Statement,
RowsEventT* hint);
Rows_log_event* binlog_get_pending_rows_event() const;
void binlog_set_pending_rows_event(Rows_log_event* ev);
int binlog_setup_trx_data();
my_size_t max_row_length_blob(TABLE* table, const byte *data) const;
my_size_t max_row_length(TABLE* table, const byte *data) const
......@@ -959,12 +960,15 @@ class THD :public Statement,
private:
uint binlog_table_maps; // Number of table maps currently in the binlog
public:
#endif
uint get_binlog_table_maps() const {
return binlog_table_maps;
}
#endif /* HAVE_ROW_BASED_REPLICATION */
#endif /* MYSQL_CLIENT */
#ifndef MYSQL_CLIENT
public:
enum enum_binlog_query_type {
/*
The query can be logged row-based or statement-based
......@@ -1402,18 +1406,26 @@ class THD :public Statement,
inline void set_current_stmt_binlog_row_based_if_mixed()
{
if (variables.binlog_format == BINLOG_FORMAT_MIXED)
current_stmt_binlog_row_based= 1;
current_stmt_binlog_row_based= TRUE;
}
inline void set_current_stmt_binlog_row_based()
{
current_stmt_binlog_row_based= 1;
current_stmt_binlog_row_based= TRUE;
}
inline void clear_current_stmt_binlog_row_based()
{
current_stmt_binlog_row_based= FALSE;
}
#endif
inline void reset_current_stmt_binlog_row_based()
{
current_stmt_binlog_row_based= test(variables.binlog_format ==
BINLOG_FORMAT_ROW);
#ifdef HAVE_ROW_BASED_REPLICATION
current_stmt_binlog_row_based=
test(variables.binlog_format == BINLOG_FORMAT_ROW);
#else
current_stmt_binlog_row_based= FALSE;
#endif
}
#endif /*HAVE_ROW_BASED_REPLICATION*/
};
......@@ -1578,6 +1590,9 @@ class select_insert :public select_result_interceptor {
bool send_eof();
/* not implemented: select_insert is never re-used in prepared statements */
void cleanup();
protected:
MYSQL_LOCK *lock;
};
......@@ -1587,7 +1602,6 @@ class select_create: public select_insert {
List<create_field> *extra_fields;
List<Key> *keys;
HA_CREATE_INFO *create_info;
MYSQL_LOCK *lock;
Field **field;
public:
select_create (TABLE_LIST *table,
......@@ -1601,7 +1615,10 @@ class select_create: public select_insert {
lock(0)
{}
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
#ifdef HAVE_ROW_BASED_REPLICATION
void binlog_show_create_table(TABLE **tables, uint count);
#endif
void store_values(List<Item> &values);
void send_error(uint errcode,const char *err);
bool send_eof();
......
......@@ -42,8 +42,6 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
ha_rows deleted= 0;
uint usable_index= MAX_KEY;
SELECT_LEX *select_lex= &thd->lex->select_lex;
bool ha_delete_all_rows= 0;
ulonglong const saved_options= thd->options;
DBUG_ENTER("mysql_delete");
if (open_and_lock_tables(thd, table_list))
......@@ -75,20 +73,19 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
Test if the user wants to delete all rows and deletion doesn't have
any side-effects (because of triggers), so we can use optimized
handler::delete_all_rows() method.
If row-based replication is used, we also delete the table row by
row.
*/
if (!using_limit && const_cond && (!conds || conds->val_int()) &&
!(specialflag & (SPECIAL_NO_NEW_FUNC | SPECIAL_SAFE_MODE)) &&
!(table->triggers && table->triggers->has_delete_triggers()))
!(table->triggers && table->triggers->has_delete_triggers()) &&
!thd->current_stmt_binlog_row_based)
{
/* Update the table->file->stats.records number */
table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
ha_rows const maybe_deleted= table->file->stats.records;
/*
If all rows shall be deleted, we (almost) always log this
statement-based (see [binlog], below), so we set this flag and
test it below.
*/
ha_delete_all_rows= 1;
DBUG_PRINT("debug", ("Trying to use delete_all_rows()"));
if (!(error=table->file->delete_all_rows()))
{
error= -1; // ok
......@@ -218,13 +215,6 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
thd->proc_info="updating";
will_batch= !table->file->start_bulk_delete();
/*
We saved the thread options above before clearing the
OPTION_BIN_LOG, and will restore below, effectively disabling the
binary log (unless it was already disabled, of course).
*/
if (ha_delete_all_rows)
thd->options&= ~static_cast<ulonglong>(OPTION_BIN_LOG);
table->mark_columns_needed_for_delete();
......@@ -318,12 +308,6 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
delete select;
transactional_table= table->file->has_transactions();
/*
Restore the saved value of the OPTION_BIN_LOG bit in the thread
options before executing binlog_query() below.
*/
thd->options|= (saved_options & OPTION_BIN_LOG);
/* See similar binlogging code in sql_update.cc, for comments */
if ((error < 0) || (deleted && !transactional_table))
{
......@@ -338,11 +322,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
statement-based; otherwise, 'ha_delete_row()' was used to
delete specific rows which we might log row-based.
*/
THD::enum_binlog_query_type const
query_type(ha_delete_all_rows && !table->file->is_injective() ?
THD::STMT_QUERY_TYPE :
THD::ROW_QUERY_TYPE);
int log_result= thd->binlog_query(query_type,
int log_result= thd->binlog_query(THD::ROW_QUERY_TYPE,
thd->query, thd->query_length,
transactional_table, FALSE);
......@@ -1004,6 +984,9 @@ bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok)
thd->options&= ~(ulong) (OPTION_BEGIN | OPTION_NOT_AUTOCOMMIT);
ha_enable_transaction(thd, FALSE);
mysql_init_select(thd->lex);
#ifdef HAVE_ROW_BASED_REPLICATION
thd->clear_current_stmt_binlog_row_based();
#endif
error= mysql_delete(thd, table_list, (COND*) 0, (SQL_LIST*) 0,
HA_POS_ERROR, LL(0), TRUE);
ha_enable_transaction(thd, TRUE);
......
......@@ -2183,6 +2183,7 @@ select_insert::select_insert(TABLE_LIST *table_list_par, TABLE *table_par,
bool ignore_check_option_errors)
:table_list(table_list_par), table(table_par), fields(fields_par),
last_insert_id(0),
lock(0),
insert_into_view(table_list_par && table_list_par->view != 0)
{
bzero((char*) &info,sizeof(info));
......@@ -2370,7 +2371,36 @@ bool select_insert::send_data(List<Item> &values)
DBUG_RETURN(1);
}
}
if (!(error= write_record(thd, table, &info)))
/*
The thd->lock lock contain the locks for the select part of the
statement and the 'lock' variable contain the write lock for the
currently locked table that is being created or inserted
into. However, the row-based replication will investigate the
thd->lock to decide what table maps are to be written, so this one
has to contain the tables locked for writing. To be able to write
table map for the table being created, we temporarily set
THD::lock to select_insert::lock while writing the record to the
storage engine. We cannot set this elsewhere, since the execution
of a stored function inside the select expression might cause the
lock structures to be NULL.
*/
{
MYSQL_LOCK *saved_lock= NULL;
if (lock)
{
saved_lock= thd->lock;
thd->lock= lock;
}
error= write_record(thd, table, &info);
if (lock)
thd->lock= saved_lock;
}
if (!error)
{
if (table->triggers || info.handle_duplicates == DUP_UPDATE)
{
......@@ -2715,15 +2745,34 @@ class MY_HOOKS : public TABLEOP_HOOKS
};
int select_create::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
int
select_create::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
{
MY_HOOKS hooks(this);
DBUG_ENTER("select_create::prepare");
TABLEOP_HOOKS *hook_ptr= NULL;
#ifdef HAVE_ROW_BASED_REPLICATION
class MY_HOOKS : public TABLEOP_HOOKS {
public:
MY_HOOKS(select_create *x) : ptr(x) { }
virtual void do_prelock(TABLE **tables, uint count)
{
if (ptr->get_thd()->current_stmt_binlog_row_based)
ptr->binlog_show_create_table(tables, count);
}
private:
select_create *ptr;
};
MY_HOOKS hooks(this);
hook_ptr= &hooks;
#endif
unit= u;
if (!(table= create_table_from_items(thd, create_info, create_table,
extra_fields, keys, &values, &lock,
&hooks)))
&hook_ptr)))
DBUG_RETURN(-1); // abort() deletes table
if (table->s->fields < values.elements)
......@@ -2759,7 +2808,9 @@ int select_create::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
}
void select_create::binlog_show_create_table(TABLE **tables, uint count)
#ifdef HAVE_ROW_BASED_REPLICATION
void
select_create::binlog_show_create_table(TABLE **tables, uint count)
{
/*
Note 1: In RBR mode, we generate a CREATE TABLE statement for the
......@@ -2778,9 +2829,7 @@ void select_create::binlog_show_create_table(TABLE **tables, uint count)
schema that will do a close_thread_tables(), destroying the
statement transaction cache.
*/
#ifdef HAVE_ROW_BASED_REPLICATION
DBUG_ASSERT(thd->current_stmt_binlog_row_based);
#endif
DBUG_ASSERT(tables && *tables && count > 0);
char buf[2048];
......@@ -2800,7 +2849,7 @@ void select_create::binlog_show_create_table(TABLE **tables, uint count)
/* is_trans */ TRUE,
/* suppress_use */ FALSE);
}
#endif // HAVE_ROW_BASED_REPLICATION
void select_create::store_values(List<Item> &values)
{
......
......@@ -32,4 +32,4 @@ ADD_LIBRARY(innobase btr/btr0btr.c btr/btr0cur.c btr/btr0pcur.c btr/btr0sea.c
thr/thr0loc.c
trx/trx0purge.c trx/trx0rec.c trx/trx0roll.c trx/trx0rseg.c trx/trx0sys.c trx/trx0trx.c trx/trx0undo.c
usr/usr0sess.c
ut/ut0byte.c ut/ut0dbg.c ut/ut0mem.c ut/ut0rnd.c ut/ut0ut.c ut/ut0vec.c)
ut/ut0byte.c ut/ut0dbg.c ut/ut0mem.c ut/ut0rnd.c ut/ut0ut.c ut/ut0vec.c ut/ut0list.c ut/ut0wqueue.c)
......@@ -76,7 +76,9 @@ EXTRA_DIST = include/btr0btr.h include/btr0btr.ic include/btr0cur.h include/btr
include/univ.i include/usr0sess.h include/usr0sess.ic include/usr0types.h \
include/ut0byte.h include/ut0byte.ic include/ut0dbg.h include/ut0lst.h \
include/ut0mem.h include/ut0mem.ic include/ut0rnd.h include/ut0rnd.ic \
include/ut0sort.h include/ut0ut.h include/ut0ut.ic include/ut0vec.h include/ut0vec.ic \
include/ut0sort.h include/ut0ut.h include/ut0ut.ic include/ut0vec.h include/ut0vec.ic include/ha_prototypes.h \
include/ut0list.h include/ut0list.ic \
include/ut0wqueue.h \
CMakeLists.txt
noinst_LIBRARIES = libinnobase.a
......
......@@ -190,6 +190,10 @@ btr_get_prev_user_rec(
|| (mtr_memo_contains(mtr, buf_block_align(prev_page),
MTR_MEMO_PAGE_X_FIX)));
ut_a(page_is_comp(prev_page) == page_is_comp(page));
#ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_next(prev_page, mtr)
== buf_frame_get_page_no(page));
#endif /* UNIV_BTR_DEBUG */
return(page_rec_get_prev(page_get_supremum_rec(prev_page)));
}
......@@ -237,6 +241,10 @@ btr_get_next_user_rec(
MTR_MEMO_PAGE_S_FIX))
|| (mtr_memo_contains(mtr, buf_block_align(next_page),
MTR_MEMO_PAGE_X_FIX)));
#ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_prev(next_page, mtr)
== buf_frame_get_page_no(page));
#endif /* UNIV_BTR_DEBUG */
ut_a(page_is_comp(next_page) == page_is_comp(page));
return(page_rec_get_next(page_get_infimum_rec(next_page)));
......@@ -597,9 +605,9 @@ btr_page_get_father_for_rec(
buf_page_print(buf_frame_align(node_ptr));
fputs("InnoDB: Corruption of an index tree: table ", stderr);
ut_print_name(stderr, NULL, index->table_name);
ut_print_name(stderr, NULL, TRUE, index->table_name);
fputs(", index ", stderr);
ut_print_name(stderr, NULL, index->name);
ut_print_name(stderr, NULL, FALSE, index->name);
fprintf(stderr, ",\n"
"InnoDB: father ptr page no %lu, child page no %lu\n",
(ulong)
......@@ -1518,6 +1526,10 @@ btr_attach_half_pages(
prev_page = btr_page_get(space, prev_page_no, RW_X_LATCH, mtr);
ut_a(page_is_comp(prev_page) == page_is_comp(page));
#ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_next(prev_page, mtr)
== buf_frame_get_page_no(page));
#endif /* UNIV_BTR_DEBUG */
btr_page_set_next(prev_page, lower_page_no, mtr);
}
......@@ -1805,6 +1817,10 @@ btr_level_list_remove(
prev_page = btr_page_get(space, prev_page_no, RW_X_LATCH, mtr);
ut_a(page_is_comp(prev_page) == page_is_comp(page));
#ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_next(prev_page, mtr)
== buf_frame_get_page_no(page));
#endif /* UNIV_BTR_DEBUG */
btr_page_set_next(prev_page, next_page_no, mtr);
}
......@@ -1813,6 +1829,10 @@ btr_level_list_remove(
next_page = btr_page_get(space, next_page_no, RW_X_LATCH, mtr);
ut_a(page_is_comp(next_page) == page_is_comp(page));
#ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_prev(next_page, mtr)
== buf_frame_get_page_no(page));
#endif /* UNIV_BTR_DEBUG */
btr_page_set_prev(next_page, prev_page_no, mtr);
}
......@@ -2032,16 +2052,24 @@ btr_compress(
/* Decide the page to which we try to merge and which will inherit
the locks */
if (left_page_no != FIL_NULL) {
is_left = left_page_no != FIL_NULL;
if (is_left) {
is_left = TRUE;
merge_page = btr_page_get(space, left_page_no, RW_X_LATCH,
mtr);
#ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_next(merge_page, mtr)
== buf_frame_get_page_no(page));
#endif /* UNIV_BTR_DEBUG */
} else if (right_page_no != FIL_NULL) {
is_left = FALSE;
merge_page = btr_page_get(space, right_page_no, RW_X_LATCH,
mtr);
#ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_prev(merge_page, mtr)
== buf_frame_get_page_no(page));
#endif /* UNIV_BTR_DEBUG */
} else {
/* The page is the only one on the level, lift the records
to the father */
......@@ -2203,7 +2231,6 @@ btr_discard_page(
ulint left_page_no;
ulint right_page_no;
page_t* merge_page;
ibool is_left;
page_t* page;
rec_t* node_ptr;
......@@ -2223,13 +2250,19 @@ btr_discard_page(
right_page_no = btr_page_get_next(page, mtr);
if (left_page_no != FIL_NULL) {
is_left = TRUE;
merge_page = btr_page_get(space, left_page_no, RW_X_LATCH,
mtr);
#ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_next(merge_page, mtr)
== buf_frame_get_page_no(page));
#endif /* UNIV_BTR_DEBUG */
} else if (right_page_no != FIL_NULL) {
is_left = FALSE;
merge_page = btr_page_get(space, right_page_no, RW_X_LATCH,
mtr);
#ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_prev(merge_page, mtr)
== buf_frame_get_page_no(page));
#endif /* UNIV_BTR_DEBUG */
} else {
btr_discard_only_page_on_level(tree, page, mtr);
......@@ -2256,11 +2289,11 @@ btr_discard_page(
/* Remove the page from the level list */
btr_level_list_remove(tree, page, mtr);
if (is_left) {
if (left_page_no != FIL_NULL) {
lock_update_discard(page_get_supremum_rec(merge_page), page);
} else {
lock_update_discard(page_rec_get_next(
page_get_infimum_rec(merge_page)), page);
page_get_infimum_rec(merge_page)), page);
}
/* Free the file page */
......@@ -2745,7 +2778,29 @@ btr_validate_level(
rec_t* right_rec;
right_page = btr_page_get(space, right_page_no, RW_X_LATCH,
&mtr);
ut_a(page_is_comp(right_page) == page_is_comp(page));
if (UNIV_UNLIKELY(btr_page_get_prev(right_page, &mtr)
!= buf_frame_get_page_no(page))) {
btr_validate_report2(index, level, page, right_page);
fputs("InnoDB: broken FIL_PAGE_NEXT"
" or FIL_PAGE_PREV links\n", stderr);
buf_page_print(page);
buf_page_print(right_page);
ret = FALSE;
}
if (UNIV_UNLIKELY(page_is_comp(right_page)
!= page_is_comp(page))) {
btr_validate_report2(index, level, page, right_page);
fputs("InnoDB: 'compact' flag mismatch\n", stderr);
buf_page_print(page);
buf_page_print(right_page);
ret = FALSE;
goto node_ptr_fails;
}
rec = page_rec_get_prev(page_get_supremum_rec(page));
right_rec = page_rec_get_next(
page_get_infimum_rec(right_page));
......@@ -2753,8 +2808,8 @@ btr_validate_level(
offsets, ULINT_UNDEFINED, &heap);
offsets2 = rec_get_offsets(right_rec, index,
offsets2, ULINT_UNDEFINED, &heap);
if (cmp_rec_rec(rec, right_rec, offsets, offsets2, index)
>= 0) {
if (UNIV_UNLIKELY(cmp_rec_rec(rec, right_rec,
offsets, offsets2, index) >= 0)) {
btr_validate_report2(index, level, page, right_page);
......@@ -2869,10 +2924,7 @@ btr_validate_level(
ut_a(node_ptr == page_rec_get_prev(
page_get_supremum_rec(father_page)));
ut_a(btr_page_get_next(father_page, &mtr) == FIL_NULL);
}
if (right_page_no != FIL_NULL) {
} else {
right_node_ptr = btr_page_get_father_node_ptr(tree,
right_page, &mtr);
if (page_rec_get_next(node_ptr) !=
......@@ -2934,14 +2986,15 @@ btr_validate_level(
}
node_ptr_fails:
/* Commit the mini-transaction to release the latch on 'page'.
Re-acquire the latch on right_page, which will become 'page'
on the next loop. The page has already been checked. */
mtr_commit(&mtr);
if (right_page_no != FIL_NULL) {
ulint comp = page_is_comp(page);
mtr_start(&mtr);
page = btr_page_get(space, right_page_no, RW_X_LATCH, &mtr);
ut_a(page_is_comp(page) == comp);
goto loop;
}
......
......@@ -157,6 +157,10 @@ btr_cur_latch_leaves(
if (left_page_no != FIL_NULL) {
get_page = btr_page_get(space, left_page_no,
RW_X_LATCH, mtr);
#ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_next(get_page, mtr)
== buf_frame_get_page_no(page));
#endif /* UNIV_BTR_DEBUG */
ut_a(page_is_comp(get_page) == page_is_comp(page));
buf_block_align(get_page)->check_index_page_at_flush =
TRUE;
......@@ -171,6 +175,10 @@ btr_cur_latch_leaves(
if (right_page_no != FIL_NULL) {
get_page = btr_page_get(space, right_page_no,
RW_X_LATCH, mtr);
#ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_prev(get_page, mtr)
== buf_frame_get_page_no(page));
#endif /* UNIV_BTR_DEBUG */
buf_block_align(get_page)->check_index_page_at_flush =
TRUE;
}
......@@ -183,6 +191,10 @@ btr_cur_latch_leaves(
if (left_page_no != FIL_NULL) {
cursor->left_page = btr_page_get(space, left_page_no,
RW_S_LATCH, mtr);
#ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_next(cursor->left_page, mtr)
== buf_frame_get_page_no(page));
#endif /* UNIV_BTR_DEBUG */
ut_a(page_is_comp(cursor->left_page) ==
page_is_comp(page));
buf_block_align(
......@@ -201,6 +213,10 @@ btr_cur_latch_leaves(
if (left_page_no != FIL_NULL) {
cursor->left_page = btr_page_get(space, left_page_no,
RW_X_LATCH, mtr);
#ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_next(cursor->left_page, mtr)
== buf_frame_get_page_no(page));
#endif /* UNIV_BTR_DEBUG */
ut_a(page_is_comp(cursor->left_page) ==
page_is_comp(page));
buf_block_align(
......@@ -1731,6 +1747,10 @@ btr_cur_pess_upd_restore_supremum(
ut_ad(prev_page_no != FIL_NULL);
prev_page = buf_page_get_with_no_latch(space, prev_page_no, mtr);
#ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_next(prev_page, mtr)
== buf_frame_get_page_no(page));
#endif /* UNIV_BTR_DEBUG */
/* We must already have an x-latch to prev_page! */
ut_ad(mtr_memo_contains(mtr, buf_block_align(prev_page),
......@@ -3771,11 +3791,6 @@ btr_copy_externally_stored_field(
page_no = btr_blob_get_next_page_no(blob_header);
/* On other BLOB pages except the first the BLOB header
always is at the page data start: */
offset = FIL_PAGE_DATA;
mtr_commit(&mtr);
if (page_no == FIL_NULL) {
......@@ -3786,6 +3801,11 @@ btr_copy_externally_stored_field(
return(buf);
}
/* On other BLOB pages except the first the BLOB header
always is at the page data start: */
offset = FIL_PAGE_DATA;
ut_a(copied_len < local_len + extern_len);
}
}
......
......@@ -397,6 +397,9 @@ btr_pcur_move_to_next_page(
ut_ad(next_page_no != FIL_NULL);
next_page = btr_page_get(space, next_page_no, cursor->latch_mode, mtr);
#ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_prev(next_page, mtr) == buf_frame_get_page_no(page));
#endif /* UNIV_BTR_DEBUG */
ut_a(page_is_comp(next_page) == page_is_comp(page));
buf_block_align(next_page)->check_index_page_at_flush = TRUE;
......
......@@ -136,13 +136,12 @@ btr_search_sys_create(
btr_search_latch_temp = mem_alloc(sizeof(rw_lock_t));
rw_lock_create(&btr_search_latch);
rw_lock_create(&btr_search_latch, SYNC_SEARCH_SYS);
btr_search_sys = mem_alloc(sizeof(btr_search_sys_t));
btr_search_sys->hash_index = ha_create(TRUE, hash_size, 0, 0);
rw_lock_set_level(&btr_search_latch, SYNC_SEARCH_SYS);
}
/*********************************************************************
......
......@@ -524,12 +524,11 @@ buf_block_init(
block->n_pointers = 0;
rw_lock_create(&(block->lock));
rw_lock_create(&block->lock, SYNC_LEVEL_VARYING);
ut_ad(rw_lock_validate(&(block->lock)));
#ifdef UNIV_SYNC_DEBUG
rw_lock_create(&(block->debug_latch));
rw_lock_set_level(&(block->debug_latch), SYNC_NO_ORDER_CHECK);
rw_lock_create(&block->debug_latch, SYNC_NO_ORDER_CHECK);
#endif /* UNIV_SYNC_DEBUG */
}
......@@ -572,8 +571,7 @@ buf_pool_init(
/* 1. Initialize general fields
---------------------------- */
mutex_create(&(buf_pool->mutex));
mutex_set_level(&(buf_pool->mutex), SYNC_BUF_POOL);
mutex_create(&buf_pool->mutex, SYNC_BUF_POOL);
mutex_enter(&(buf_pool->mutex));
......@@ -1856,7 +1854,6 @@ buf_page_io_complete(
buf_block_t* block) /* in: pointer to the block in question */
{
ulint io_type;
ulint read_page_no;
ut_ad(block);
......@@ -1866,18 +1863,36 @@ buf_page_io_complete(
if (io_type == BUF_IO_READ) {
/* If this page is not uninitialized and not in the
doublewrite buffer, then the page number should be the
same as in block */
read_page_no = mach_read_from_4((block->frame)
doublewrite buffer, then the page number and space id
should be the same as in block. */
ulint read_page_no = mach_read_from_4((block->frame)
+ FIL_PAGE_OFFSET);
if (read_page_no != 0
&& !trx_doublewrite_page_inside(read_page_no)
&& read_page_no != block->offset) {
ulint read_space_id = mach_read_from_4((block->frame)
+ FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
if (!block->space && trx_doublewrite_page_inside(
block->offset)) {
ut_print_timestamp(stderr);
fprintf(stderr,
"InnoDB: Error: page n:o stored in the page read in is %lu, should be %lu!\n",
(ulong) read_page_no, (ulong) block->offset);
" InnoDB: Error: reading page %lu\n"
"InnoDB: which is in the doublewrite buffer!\n",
(ulong) block->offset);
} else if (!read_space_id && !read_page_no) {
/* This is likely an uninitialized page. */
} else if ((block->space && block->space != read_space_id)
|| block->offset != read_page_no) {
/* We did not compare space_id to read_space_id
if block->space == 0, because the field on the
page may contain garbage in MySQL < 4.1.1,
which only supported block->space == 0. */
ut_print_timestamp(stderr);
fprintf(stderr,
" InnoDB: Error: space id and page n:o stored in the page\n"
"InnoDB: read in are %lu:%lu, should be %lu:%lu!\n",
(ulong) read_space_id, (ulong) read_page_no,
(ulong) block->space, (ulong) block->offset);
}
/* From version 3.23.38 up we store the page checksum
to the 4 first bytes of the page end lsn field */
......@@ -2233,7 +2248,8 @@ buf_get_latched_pages_number(void)
}
mutex_exit(&(buf_pool->mutex));
return fixed_pages_number;
return(fixed_pages_number);
}
/*************************************************************************
......
......@@ -26,7 +26,7 @@ Created 11/11/1995 Heikki Tuuri
#include "trx0sys.h"
#include "srv0srv.h"
/* When flushed, dirty blocks are searched in neigborhoods of this size, and
/* When flushed, dirty blocks are searched in neighborhoods of this size, and
flushed along with the original page. */
#define BUF_FLUSH_AREA ut_min(BUF_READ_AHEAD_AREA,\
......
......@@ -293,3 +293,35 @@ dtype_print(
fprintf(stderr, " len %lu prec %lu", (ulong) len, (ulong) type->prec);
}
/***************************************************************************
Returns the maximum size of a data type. Note: types in system tables may be
incomplete and return incorrect information. */
ulint
dtype_get_max_size(
/*===============*/
/* out: maximum size (ULINT_MAX for
unbounded types) */
const dtype_t* type) /* in: type */
{
switch (type->mtype) {
case DATA_SYS:
case DATA_CHAR:
case DATA_FIXBINARY:
case DATA_INT:
case DATA_FLOAT:
case DATA_DOUBLE:
case DATA_MYSQL:
case DATA_VARCHAR:
case DATA_BINARY:
case DATA_DECIMAL:
case DATA_VARMYSQL:
return(type->len);
case DATA_BLOB:
return(ULINT_MAX);
default:
ut_error;
}
return(ULINT_MAX);
}
......@@ -1250,9 +1250,9 @@ dict_foreign_eval_sql(
ut_print_timestamp(ef);
fputs(" Error in foreign key constraint creation for table ",
ef);
ut_print_name(ef, trx, table->name);
ut_print_name(ef, trx, TRUE, table->name);
fputs(".\nA foreign key constraint of name ", ef);
ut_print_name(ef, trx, foreign->id);
ut_print_name(ef, trx, FALSE, foreign->id);
fputs("\nalready exists."
" (Note that internally InnoDB adds 'databasename/'\n"
"in front of the user-defined constraint name).\n",
......@@ -1280,7 +1280,7 @@ dict_foreign_eval_sql(
ut_print_timestamp(ef);
fputs(" Internal error in foreign key constraint creation"
" for table ", ef);
ut_print_name(ef, trx, table->name);
ut_print_name(ef, trx, TRUE, table->name);
fputs(".\n"
"See the MySQL .err log in the datadir for more information.\n", ef);
mutex_exit(&dict_foreign_err_mutex);
......
This diff is collapsed.
......@@ -184,7 +184,7 @@ dict_print(void)
if (table == NULL) {
fputs("InnoDB: Failed to load table ", stderr);
ut_print_namel(stderr, NULL, (char*) field, len);
ut_print_namel(stderr, NULL, TRUE, (char*) field, len);
putc('\n', stderr);
} else {
/* The table definition was corrupt if there
......
......@@ -58,7 +58,6 @@ dict_mem_table_create(
table->tablespace_discarded = FALSE;
table->n_def = 0;
table->n_cols = n_cols + DATA_N_SYS_COLS;
table->mem_fix = 0;
table->n_mysql_handles_opened = 0;
table->n_foreign_key_checks_running = 0;
......@@ -83,8 +82,9 @@ dict_mem_table_create(
table->stat_modified_counter = 0;
mutex_create(&(table->autoinc_mutex));
mutex_set_level(&(table->autoinc_mutex), SYNC_DICT_AUTOINC_MUTEX);
table->max_row_size = 0;
mutex_create(&table->autoinc_mutex, SYNC_DICT_AUTOINC_MUTEX);
table->autoinc_inited = FALSE;
......
......@@ -1050,8 +1050,7 @@ fil_space_create(
space->ibuf_data = NULL;
rw_lock_create(&(space->latch));
rw_lock_set_level(&(space->latch), SYNC_FSP);
rw_lock_create(&space->latch, SYNC_FSP);
HASH_INSERT(fil_space_t, hash, system->spaces, id, space);
......@@ -1295,9 +1294,7 @@ fil_system_create(
system = mem_alloc(sizeof(fil_system_t));
mutex_create(&(system->mutex));
mutex_set_level(&(system->mutex), SYNC_ANY_LATCH);
mutex_create(&system->mutex, SYNC_ANY_LATCH);
system->spaces = hash_create(hash_size);
system->name_hash = hash_create(hash_size);
......
......@@ -144,9 +144,7 @@ hash_create_mutexes(
table->mutexes = mem_alloc(n_mutexes * sizeof(mutex_t));
for (i = 0; i < n_mutexes; i++) {
mutex_create(table->mutexes + i);
mutex_set_level(table->mutexes + i, sync_level);
mutex_create(table->mutexes + i, sync_level);
}
table->n_mutexes = n_mutexes;
......
......@@ -144,6 +144,7 @@ static ulint ibuf_rnd = 986058871;
ulint ibuf_flush_count = 0;
#ifdef UNIV_IBUF_DEBUG
/* Dimensions for the ibuf_count array */
#define IBUF_COUNT_N_SPACES 500
#define IBUF_COUNT_N_PAGES 2000
......@@ -152,6 +153,7 @@ ulint ibuf_flush_count = 0;
static ulint* ibuf_counts[IBUF_COUNT_N_SPACES];
static ibool ibuf_counts_inited = FALSE;
#endif
/* The start address for an insert buffer bitmap page bitmap */
#define IBUF_BITMAP PAGE_DATA
......@@ -314,6 +316,7 @@ ibuf_tree_root_get(
return(page);
}
#ifdef UNIV_IBUF_DEBUG
/**********************************************************************
Gets the ibuf count for a given page. */
......@@ -338,7 +341,6 @@ ibuf_count_get(
/**********************************************************************
Sets the ibuf count for a given page. */
#ifdef UNIV_IBUF_DEBUG
static
void
ibuf_count_set(
......@@ -389,23 +391,18 @@ ibuf_init_at_db_start(void)
ibuf_count_set(i, j, 0);
}
}
ibuf_counts_inited = TRUE;
}
#endif
mutex_create(&ibuf_pessimistic_insert_mutex);
mutex_set_level(&ibuf_pessimistic_insert_mutex,
SYNC_IBUF_PESS_INSERT_MUTEX);
mutex_create(&ibuf_mutex);
mutex_create(&ibuf_pessimistic_insert_mutex,
SYNC_IBUF_PESS_INSERT_MUTEX);
mutex_set_level(&ibuf_mutex, SYNC_IBUF_MUTEX);
mutex_create(&ibuf_mutex, SYNC_IBUF_MUTEX);
mutex_create(&ibuf_bitmap_mutex);
mutex_set_level(&ibuf_bitmap_mutex, SYNC_IBUF_BITMAP_MUTEX);
mutex_create(&ibuf_bitmap_mutex, SYNC_IBUF_BITMAP_MUTEX);
fil_ibuf_init_at_db_start();
ibuf_counts_inited = TRUE;
}
/**********************************************************************
......@@ -2348,6 +2345,10 @@ ibuf_get_volume_buffered(
}
prev_page = buf_page_get(0, prev_page_no, RW_X_LATCH, mtr);
#ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_next(prev_page, mtr)
== buf_frame_get_page_no(page));
#endif /* UNIV_BTR_DEBUG */
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(prev_page, SYNC_TREE_NODE);
......@@ -2411,6 +2412,10 @@ ibuf_get_volume_buffered(
}
next_page = buf_page_get(0, next_page_no, RW_X_LATCH, mtr);
#ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_prev(next_page, mtr)
== buf_frame_get_page_no(page));
#endif /* UNIV_BTR_DEBUG */
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(next_page, SYNC_TREE_NODE);
......
......@@ -330,6 +330,15 @@ dtype_get_min_size(
/* out: minimum size */
const dtype_t* type); /* in: type */
/***************************************************************************
Returns the maximum size of a data type. Note: types in system tables may be
incomplete and return incorrect information. */
ulint
dtype_get_max_size(
/*===============*/
/* out: maximum size (ULINT_MAX for
unbounded types) */
const dtype_t* type); /* in: type */
/***************************************************************************
Returns a stored SQL NULL size for a type. For fixed length types it is
the fixed length of the type, otherwise 0. */
UNIV_INLINE
......
This diff is collapsed.
This diff is collapsed.
......@@ -169,10 +169,6 @@ struct dict_tree_struct{
the same memory cache line */
rw_lock_t lock; /* read-write lock protecting the upper levels
of the index tree */
ulint mem_fix;/* count of how many times this tree
struct has been memoryfixed (by mini-
transactions wanting to access the index
tree) */
dict_index_t* tree_index; /* the index stored in the
index tree */
ulint magic_n;/* magic number */
......@@ -315,9 +311,6 @@ struct dict_table_struct{
which refer to this table */
UT_LIST_NODE_T(dict_table_t)
table_LRU; /* node of the LRU list of tables */
ulint mem_fix;/* count of how many times the table
and its indexes has been fixed in memory;
currently NOT used */
ulint n_mysql_handles_opened;
/* count of how many handles MySQL has opened
to this table; dropping of the table is
......@@ -348,6 +341,12 @@ struct dict_table_struct{
had an IX lock on */
UT_LIST_BASE_NODE_T(lock_t)
locks; /* list of locks on the table */
ulint max_row_size;
/* maximum size of a single row in the
table, not guaranteed to be especially
accurate. it's ULINT_MAX if there are
unbounded variable-width fields. initialized
in dict_table_add_to_cache. */
/*----------------------*/
ibool does_not_fit_in_memory;
/* this field is used to specify in simulations
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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