Merge bk-internal.mysql.com:/data0/bk/mysql-5.1

into  bk-internal.mysql.com:/data0/bk/mysql-5.1-kt
This commit is contained in:
rburnett@bk-internal.mysql.com 2006-06-21 17:51:54 +02:00
commit 8472ce9ff8
160 changed files with 5127 additions and 2523 deletions

File diff suppressed because it is too large Load Diff

View File

@ -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

View File

@ -142,6 +142,7 @@ set insert_id=5;
insert into t1 values (NULL, last_insert_id()), (NULL, last_insert_id());
--replace_result $VERSION VERSION
--replace_column 2 # 5 #
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
show binlog events;
select * from t1;
drop table t1;

View File

@ -0,0 +1,36 @@
#
# 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.test
let $format = MIXED;
let $stmt = TRUNCATE TABLE;
--source extra/rpl_tests/rpl_truncate_helper.test
let $format = ROW;
let $stmt = TRUNCATE TABLE;
--source extra/rpl_tests/rpl_truncate_helper.test
let $format = STATEMENT;
let $stmt = DELETE FROM;
--source extra/rpl_tests/rpl_truncate_helper.test
let $format = MIXED;
let $stmt = DELETE FROM;
--source extra/rpl_tests/rpl_truncate_helper.test
let $format = ROW;
let $stmt = DELETE FROM;
--source extra/rpl_tests/rpl_truncate_helper.test

View File

@ -0,0 +1,41 @@
--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 /\/\* xid=[0-9]+ \*\//\/* xid= *\// /table_id: [0-9]+/table_id: #/
SHOW BINLOG EVENTS;

View File

@ -0,0 +1,22 @@
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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -1,4 +1,10 @@
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,

View File

@ -1459,7 +1459,6 @@ UNLOCK TABLES;
/*!40000 ALTER TABLE `t2` ENABLE KEYS */;
DROP TABLE IF EXISTS `v2`;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
/*!50001 DROP TABLE IF EXISTS `v2`*/;
/*!50001 CREATE TABLE `v2` (
`a` varchar(30)
) */;
@ -1871,7 +1870,6 @@ UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
DROP TABLE IF EXISTS `v1`;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 DROP TABLE IF EXISTS `v1`*/;
/*!50001 CREATE TABLE `v1` (
`a` int(11)
) */;
@ -1929,7 +1927,6 @@ UNLOCK TABLES;
/*!40000 ALTER TABLE `t2` ENABLE KEYS */;
DROP TABLE IF EXISTS `v2`;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
/*!50001 DROP TABLE IF EXISTS `v2`*/;
/*!50001 CREATE TABLE `v2` (
`a` varchar(30)
) */;
@ -2022,7 +2019,6 @@ UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
DROP TABLE IF EXISTS `v1`;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 DROP TABLE IF EXISTS `v1`*/;
/*!50001 CREATE TABLE `v1` (
`a` int(11),
`b` int(11),
@ -2030,13 +2026,11 @@ DROP TABLE IF EXISTS `v1`;
) */;
DROP TABLE IF EXISTS `v2`;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
/*!50001 DROP TABLE IF EXISTS `v2`*/;
/*!50001 CREATE TABLE `v2` (
`a` int(11)
) */;
DROP TABLE IF EXISTS `v3`;
/*!50001 DROP VIEW IF EXISTS `v3`*/;
/*!50001 DROP TABLE IF EXISTS `v3`*/;
/*!50001 CREATE TABLE `v3` (
`a` int(11),
`b` int(11),
@ -2597,7 +2591,6 @@ UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
DROP TABLE IF EXISTS `v0`;
/*!50001 DROP VIEW IF EXISTS `v0`*/;
/*!50001 DROP TABLE IF EXISTS `v0`*/;
/*!50001 CREATE TABLE `v0` (
`a` int(11),
`b` varchar(32),
@ -2605,7 +2598,6 @@ DROP TABLE IF EXISTS `v0`;
) */;
DROP TABLE IF EXISTS `v1`;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 DROP TABLE IF EXISTS `v1`*/;
/*!50001 CREATE TABLE `v1` (
`a` int(11),
`b` varchar(32),
@ -2613,16 +2605,11 @@ DROP TABLE IF EXISTS `v1`;
) */;
DROP TABLE IF EXISTS `v2`;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
/*!50001 DROP TABLE IF EXISTS `v2`*/;
/*!50001 CREATE TABLE `v2` (
`a` int(11),
`b` varchar(32),
`c` varchar(32)
) */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `test`;
/*!50001 DROP TABLE IF EXISTS `v0`*/;
/*!50001 DROP VIEW IF EXISTS `v0`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
@ -3021,3 +3008,62 @@ third ee3 root@localhost ONE TIME 2030-12-31 22:01:23 NULL NULL NULL NULL ENABLE
drop database third;
set time_zone = 'SYSTEM';
use test;
create database mysqldump_test_db;
use mysqldump_test_db;
create table t1 (id int);
create view v1 as select * from t1;
insert into t1 values (1232131);
insert into t1 values (4711);
insert into t1 values (3231);
insert into t1 values (0815);
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
/*!40000 DROP DATABASE IF EXISTS `mysqldump_test_db`*/;
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqldump_test_db` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `mysqldump_test_db`;
DROP TABLE IF EXISTS `t1`;
CREATE TABLE `t1` (
`id` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE;
INSERT INTO `t1` VALUES (1232131),(4711),(3231),(815);
UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
DROP TABLE IF EXISTS `v1`;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 CREATE TABLE `v1` (
`id` int(11)
) */;
/*!50001 DROP TABLE IF EXISTS `v1`*/;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v1` AS select `t1`.`id` AS `id` from `t1` */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
drop view v1;
drop table t1;
drop database mysqldump_test_db;

View File

@ -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;

View File

@ -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;

View File

@ -0,0 +1,47 @@
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;
drop database if exists test1;
create database test1;
use test1;
CREATE TABLE `t1` (
`id` int(10) unsigned NOT NULL auto_increment,
`fname` varchar(100) default NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
INSERT INTO `t1` VALUES (1, 'blablabla');
CREATE TABLE `t2` (
`id` int(10) NOT NULL auto_increment,
`comment` varchar(255) NOT NULL default '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=3 ;
INSERT INTO `t2` VALUES (1, 'testtest 1');
INSERT INTO `t2` VALUES (2, 'test 2');
CREATE PROCEDURE simpleproc3 ()
NOT DETERMINISTIC
BEGIN
INSERT INTO t1 (fname) (SELECT t2.comment FROM t2 WHERE t2.id = '1');
INSERT INTO t1 (fname) VALUES('test');
END
$
CALL simpleproc3();
select * from t2;
id comment
1 testtest 1
2 test 2
TRUNCATE TABLE `t1`;
CALL simpleproc3();
select * from t1;
id fname
1 testtest 1
2 test
use test1;
select * from t1;
id fname
1 testtest 1
2 test
drop database test1;
drop database test1;

View File

@ -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 ########

View File

@ -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--

View File

@ -140,8 +140,8 @@ insert into t1 values (NULL, last_insert_id()), (NULL, last_insert_id());
show binlog events;
Log_name Pos Event_type Server_id End_log_pos Info
slave-bin.000001 # Format_desc 2 # Server ver: VERSION, Binlog ver: 4
slave-bin.000001 # Table_map 2 # table_id: 30 (test.t1)
slave-bin.000001 # Write_rows 2 # table_id: 30 flags: STMT_END_F
slave-bin.000001 # Table_map 2 # table_id: # (test.t1)
slave-bin.000001 # Write_rows 2 # table_id: # flags: STMT_END_F
select * from t1;
a b
1 1

View File

@ -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: SERVER_VERSION, 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

View File

@ -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--

View File

@ -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
)

View File

@ -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;

View File

@ -108,8 +108,8 @@ insert into t1 values (NULL, last_insert_id()), (NULL, last_insert_id());
show binlog events;
Log_name Pos Event_type Server_id End_log_pos Info
slave-bin.000001 # Format_desc 2 # Server ver: VERSION, Binlog ver: 4
slave-bin.000001 # Table_map 2 # table_id: 21 (test.t1)
slave-bin.000001 # Write_rows 2 # table_id: 21 flags: STMT_END_F
slave-bin.000001 # Table_map 2 # table_id: # (test.t1)
slave-bin.000001 # Write_rows 2 # table_id: # flags: STMT_END_F
select * from t1;
a b
1 1

View File

@ -116,8 +116,8 @@ insert into t1 values (NULL, last_insert_id()), (NULL, last_insert_id());
show binlog events;
Log_name Pos Event_type Server_id End_log_pos Info
slave-bin.000001 # Format_desc 2 # Server ver: VERSION, Binlog ver: 4
slave-bin.000001 # Table_map 2 # table_id: 21 (test.t1)
slave-bin.000001 # Write_rows 2 # table_id: 21 flags: STMT_END_F
slave-bin.000001 # Table_map 2 # table_id: # (test.t1)
slave-bin.000001 # Write_rows 2 # table_id: # flags: STMT_END_F
select * from t1;
a b
1 1

View File

@ -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;

View File

@ -0,0 +1,202 @@
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

View File

@ -0,0 +1,214 @@
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

View File

@ -0,0 +1,91 @@
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 610 use `test`; TRUNCATE TABLE t1
master-bin.000001 610 Query 1 686 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 610 use `test`; TRUNCATE TABLE t1
master-bin.000001 610 Query 1 686 use `test`; DROP TABLE t1
master-bin.000001 686 Query 1 803 use `test`; CREATE TABLE t1 (a INT PRIMARY KEY, b LONG) ENGINE=NDB
master-bin.000001 803 Query 1 867 BEGIN
master-bin.000001 867 Table_map 1 40 table_id: # (test.t1)
master-bin.000001 907 Table_map 1 93 table_id: # (cluster.apply_status)
master-bin.000001 960 Write_rows 1 135 table_id: #
master-bin.000001 1002 Write_rows 1 182 table_id: # flags: STMT_END_F
master-bin.000001 1049 Query 1 1114 COMMIT
master-bin.000001 1114 Query 1 1178 BEGIN
master-bin.000001 1178 Table_map 1 40 table_id: # (test.t1)
master-bin.000001 1218 Table_map 1 93 table_id: # (cluster.apply_status)
master-bin.000001 1271 Write_rows 1 135 table_id: #
master-bin.000001 1313 Delete_rows 1 174 table_id: # flags: STMT_END_F
master-bin.000001 1352 Query 1 1417 COMMIT
master-bin.000001 1417 Query 1 1493 use `test`; DROP TABLE t1

View File

@ -380,9 +380,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

View File

@ -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|

View File

@ -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
min 1 0
sum 22 0
avg 0 4.4
min 1 0
max 9 0
sum 22 0
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|

View File

@ -467,6 +467,10 @@ set sql_mode=2097152;
select @@sql_mode;
@@sql_mode
STRICT_TRANS_TABLES
set sql_mode=4194304;
select @@sql_mode;
@@sql_mode
STRICT_ALL_TABLES
set sql_mode=16384+(65536*4);
select @@sql_mode;
@@sql_mode

View File

@ -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'),

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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';

View File

@ -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

View File

@ -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;

View File

@ -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
#

View File

@ -36,8 +36,8 @@ 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
rpl_sp_effects : BUG#19862 2006-06-15 mkindahl
# the below testcase have been reworked to avoid the bug, test contains comment, keep bug open
#ndb_binlog_ddl_multi : BUG#18976 2006-04-10 kent CRBR: multiple binlog, second binlog may miss schema log events

View File

@ -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%`;

View File

@ -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). #
# #
#######################################################################

View File

@ -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 (

View File

@ -1252,3 +1252,20 @@ set time_zone = 'SYSTEM';
use test;
#####
#
# BUG#17201 Spurious 'DROP DATABASE' in output,
# also confusion between tables and views.
# Example code from Markus Popp
create database mysqldump_test_db;
use mysqldump_test_db;
create table t1 (id int);
create view v1 as select * from t1;
insert into t1 values (1232131);
insert into t1 values (4711);
insert into t1 values (3231);
insert into t1 values (0815);
--exec $MYSQL_DUMP --skip-comments --add-drop-database --databases mysqldump_test_db
drop view v1;
drop table t1;
drop database mysqldump_test_db;

View File

@ -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;

View File

@ -0,0 +1,63 @@
#
# Test of auto_increment
# BUG#11932
#
# Bug reported that master and slave get out of sync after TRUNCATE
# TABLE.
#
# Test supplied by Are Casilla
source include/master-slave.inc;
--disable_warnings
connection master;
drop database if exists test1;
--enable_warnings
create database test1;
use test1;
CREATE TABLE `t1` (
`id` int(10) unsigned NOT NULL auto_increment,
`fname` varchar(100) default NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
INSERT INTO `t1` VALUES (1, 'blablabla');
CREATE TABLE `t2` (
`id` int(10) NOT NULL auto_increment,
`comment` varchar(255) NOT NULL default '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=3 ;
INSERT INTO `t2` VALUES (1, 'testtest 1');
INSERT INTO `t2` VALUES (2, 'test 2');
DELIMITER $;
CREATE PROCEDURE simpleproc3 ()
NOT DETERMINISTIC
BEGIN
INSERT INTO t1 (fname) (SELECT t2.comment FROM t2 WHERE t2.id = '1');
INSERT INTO t1 (fname) VALUES('test');
END
$
DELIMITER ;$
CALL simpleproc3();
select * from t2;
TRUNCATE TABLE `t1`;
CALL simpleproc3();
select * from t1;
save_master_pos;
connection slave;
sync_with_master;
use test1;
select * from t1;
drop database test1;
connection master;
drop database test1;

View File

@ -1,3 +1,4 @@
-- source include/have_row_based.inc
-- source include/have_binlog_format_statement.inc
-- source include/master-slave.inc

View File

@ -2,6 +2,8 @@
--source include/have_binlog_format_row.inc
let $SERVER_VERSION=`select version()`;
#This test case is not written for NDB, the result files
#will not match when NDB is the default engine
-- source include/not_ndb_default.inc
@ -36,3 +38,19 @@ 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_result $SERVER_VERSION SERVER_VERSION
--replace_regex /table_id: [0-9]+/table_id: #/
SHOW BINLOG EVENTS;

View File

@ -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;

View File

@ -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

View File

@ -0,0 +1 @@
--replicate-ignore-table=test.t2

View File

@ -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;

View File

@ -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;

View File

@ -0,0 +1,4 @@
let $engine=MyISAM;
--source extra/rpl_tests/rpl_truncate.test

View File

@ -0,0 +1,5 @@
--source include/have_innodb.inc
let $engine=InnoDB;
--source extra/rpl_tests/rpl_truncate.test

View File

@ -0,0 +1,68 @@
--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 ****
# This is silly, but NDB doesn't add to the binlog fast enough
--real_sleep 10
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 /\/\* xid=[0-9]+ \*\//\/* xid= *\// /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;

View File

@ -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);

View File

@ -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|
#

View File

@ -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|

View File

@ -258,6 +258,9 @@ drop table t1, t2;
select @@sql_mode;
set sql_mode=2097152;
select @@sql_mode;
# BUG#14675
set sql_mode=4194304;
select @@sql_mode;
set sql_mode=16384+(65536*4);
select @@sql_mode;
--error 1231

View File

@ -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'),

View File

@ -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

View File

@ -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;
#

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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 */
{
if (!trx || !trx->mysql_thd) {
return(EOF);
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));
}
}
return(get_quote_char_for_identifier((THD*) trx->mysql_thd,
name, (int) namelen));
if (!trx || !trx->mysql_thd) {
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);
}
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 */

View File

@ -53,6 +53,8 @@ st_plugin_int *hton2plugin[MAX_HA];
static handlerton *installed_htons[128];
#define BITMAP_STACKBUF_SIZE (128/8)
KEY_CREATE_INFO default_key_create_info= { HA_KEY_ALG_UNDEF, 0, {NullS,0} };
/* static functions defined in this file */
@ -3234,35 +3236,128 @@ namespace {
}
}
template<class RowsEventT> int binlog_log_row(TABLE *table,
const byte *before_record,
const byte *after_record)
{
if (table->file->is_injective())
return 0;
bool error= 0;
if (check_table_binlog_row_based(table->in_use, table))
{
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);
}
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.
*/
Write table maps for all (manually or automatically) locked tables
to the binary log.
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 *);
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
{
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);
}
template<class RowsEventT> int
binlog_log_row(TABLE* table,
const byte *before_record,
const byte *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;
}
/*
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<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 +3367,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);
}

View File

@ -75,11 +75,17 @@ char *make_default_log_name(char *buff,const char* log_ext)
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;
@ -1195,6 +1201,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
@ -1214,6 +1221,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)
@ -3041,7 +3049,6 @@ bool MYSQL_BIN_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.
@ -3077,6 +3084,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;
@ -3255,9 +3263,9 @@ bool MYSQL_BIN_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*/
@ -3308,7 +3316,6 @@ bool MYSQL_BIN_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 &

View File

@ -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);
}

View File

@ -1328,15 +1328,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
*/
@ -1354,10 +1359,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
@ -1365,6 +1372,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");

View File

@ -913,15 +913,20 @@ public:
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;
};

View File

@ -5837,4 +5837,5 @@ ER_PARTITION_MERGE_ERROR
swe "%s kan inte användas i en partitionerad tabell"
ER_CANT_ACTIVATE_LOG
eng "Cannot activate '%-.64s' log."
ER_RBR_NOT_AVAILABLE
eng "The server was not built with row-based replication"

View File

@ -1526,17 +1526,37 @@ bool close_temporary_table(THD *thd, TABLE_LIST *table_list)
}
/*
Close temporary table and unlink from thd->temporary tables
unlink from thd->temporary tables and close temporary table
*/
void close_temporary_table(THD *thd, TABLE *table,
bool free_share, bool delete_table)
{
TABLE **prev= table->open_prev;
if ((*table->open_prev= table->next))
table->next->open_prev= prev;
if (table->prev)
{
table->prev->next= table->next;
if (table->prev->next)
table->next->prev= table->prev;
}
else
{
/* removing the item from the list */
DBUG_ASSERT(table == thd->temporary_tables);
/*
slave must reset its temporary list pointer to zero to exclude
passing non-zero value to end_slave via rli->save_temporary_tables
when no temp tables opened, see an invariant below.
*/
thd->temporary_tables= table->next;
if (thd->temporary_tables)
table->next->prev= 0;
}
if (thd->slave_thread)
{
/* natural invariant of temporary_tables */
DBUG_ASSERT(slave_open_temp_tables || !thd->temporary_tables);
slave_open_temp_tables--;
}
close_temporary(table, free_share, delete_table);
}
@ -3504,10 +3524,12 @@ TABLE *open_temporary_table(THD *thd, const char *path, const char *db,
if (link_in_list)
{
tmp_table->open_prev= &thd->temporary_tables;
if ((tmp_table->next= thd->temporary_tables))
thd->temporary_tables->open_prev= &tmp_table->next;
/* growing temp list at the head */
tmp_table->next= thd->temporary_tables;
if (tmp_table->next)
tmp_table->next->prev= tmp_table;
thd->temporary_tables= tmp_table;
thd->temporary_tables->prev= 0;
if (thd->slave_thread)
slave_open_temp_tables++;
}

View File

@ -2134,7 +2134,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;
@ -2642,31 +2644,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);
}
@ -2724,6 +2701,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)
{
/*
@ -2744,6 +2722,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:
/*
@ -2752,7 +2731,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

View File

@ -908,8 +908,10 @@ public:
/* 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
@ -939,7 +941,6 @@ public:
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
@ -960,12 +961,15 @@ public:
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
@ -1403,18 +1407,26 @@ public:
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*/
};
@ -1579,6 +1591,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;
};
@ -1588,7 +1603,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,
@ -1598,10 +1612,10 @@ public:
List<Item> &select_fields,enum_duplicates duplic, bool ignore)
:select_insert (NULL, NULL, &select_fields, 0, 0, duplic, ignore),
create_table(table), extra_fields(&fields_par),keys(&keys_par),
create_info(create_info_par),
lock(0)
create_info(create_info_par)
{}
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
void binlog_show_create_table(TABLE **tables, uint count);
void store_values(List<Item> &values);
void send_error(uint errcode,const char *err);

View File

@ -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 @@ cleanup:
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 @@ cleanup:
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);
@ -1006,6 +986,9 @@ trunc_by_del:
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);

View File

@ -2188,6 +2188,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));
@ -2375,7 +2376,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)
{
@ -2720,15 +2750,34 @@ private:
};
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)
@ -2764,7 +2813,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
@ -2783,9 +2834,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];
@ -2805,7 +2854,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)
{

View File

@ -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)

View File

@ -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

View File

@ -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 @@ loop:
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 @@ loop:
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 @@ loop:
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 @@ loop:
}
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;
}

View File

@ -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);
}
}

View File

@ -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;

View File

@ -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);
}
/*********************************************************************

View File

@ -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);
}
/*************************************************************************

View File

@ -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,\

View File

@ -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);
}

View File

@ -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);

View File

@ -26,6 +26,9 @@ Created 1/8/1996 Heikki Tuuri
#include "pars0sym.h"
#include "que0que.h"
#include "rem0cmp.h"
#ifndef UNIV_HOTBACKUP
# include "m_ctype.h" /* my_isspace() */
#endif /* !UNIV_HOTBACKUP */
dict_sys_t* dict_sys = NULL; /* the dictionary system */
@ -55,6 +58,42 @@ static char dict_ibfk[] = "_ibfk_";
#ifndef UNIV_HOTBACKUP
/**********************************************************************
Converts an identifier to a table name.
NOTE: the prototype of this function is copied from ha_innodb.cc! If you change
this function, you MUST change also the prototype here! */
extern
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;
should be at least 5 * strlen(to) + 1 */
/**********************************************************************
Converts an identifier to UTF-8.
NOTE: the prototype of this function is copied from ha_innodb.cc! If you change
this function, you MUST change also the prototype here! */
extern
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;
should be at least 3 * strlen(to) + 1 */
/**********************************************************************
Removes the filename encoding of a table or database name.
NOTE: the prototype of this function is copied from ha_innodb.cc! If you change
this function, you MUST change also the prototype here! */
extern
void
innobase_convert_from_filename(
/*===========================*/
char* s); /* in: identifier; out: decoded identifier */
/**********************************************************************
Compares NUL-terminated UTF-8 strings case insensitively.
NOTE: the prototype of this function is copied from ha_innodb.cc! If you change
@ -77,6 +116,17 @@ void
innobase_casedn_str(
/*================*/
char* a); /* in/out: string to put in lower case */
/**************************************************************************
Determines the connection character set.
NOTE: the prototype of this function is copied from ha_innodb.cc! If you change
this function, you MUST change also the prototype here! */
struct charset_info_st*
innobase_get_charset(
/*=================*/
/* out: connection character set */
void* mysql_thd); /* in: MySQL thread handle */
#endif /* !UNIV_HOTBACKUP */
/**************************************************************************
@ -607,7 +657,7 @@ dict_index_get_nth_field_pos(
}
/**************************************************************************
Returns a table object, based on table id, and memoryfixes it. */
Returns a table object based on table id. */
dict_table_t*
dict_table_get_on_id(
@ -629,12 +679,12 @@ dict_table_get_on_id(
ut_ad(mutex_own(&(dict_sys->mutex)));
#endif /* UNIV_SYNC_DEBUG */
return(dict_table_get_on_id_low(table_id, trx));
return(dict_table_get_on_id_low(table_id));
}
mutex_enter(&(dict_sys->mutex));
table = dict_table_get_on_id_low(table_id, trx);
table = dict_table_get_on_id_low(table_id);
mutex_exit(&(dict_sys->mutex));
@ -716,8 +766,7 @@ dict_init(void)
{
dict_sys = mem_alloc(sizeof(dict_sys_t));
mutex_create(&(dict_sys->mutex));
mutex_set_level(&(dict_sys->mutex), SYNC_DICT);
mutex_create(&dict_sys->mutex, SYNC_DICT);
dict_sys->table_hash = hash_create(buf_pool_get_max_size() /
(DICT_POOL_PER_TABLE_HASH *
@ -732,32 +781,28 @@ dict_init(void)
UT_LIST_INIT(dict_sys->table_LRU);
rw_lock_create(&dict_operation_lock);
rw_lock_set_level(&dict_operation_lock, SYNC_DICT_OPERATION);
rw_lock_create(&dict_operation_lock, SYNC_DICT_OPERATION);
dict_foreign_err_file = os_file_create_tmpfile();
ut_a(dict_foreign_err_file);
mutex_create(&dict_foreign_err_mutex);
mutex_set_level(&dict_foreign_err_mutex, SYNC_ANY_LATCH);
mutex_create(&dict_foreign_err_mutex, SYNC_ANY_LATCH);
}
/**************************************************************************
Returns a table object and memoryfixes it. NOTE! This is a high-level
function to be used mainly from outside the 'dict' directory. Inside this
directory dict_table_get_low is usually the appropriate function. */
Returns a table object. NOTE! This is a high-level function to be used
mainly from outside the 'dict' directory. Inside this directory
dict_table_get_low is usually the appropriate function. */
dict_table_t*
dict_table_get(
/*===========*/
/* out: table, NULL if
does not exist */
const char* table_name, /* in: table name */
trx_t* trx) /* in: transaction handle or NULL */
const char* table_name) /* in: table name */
{
dict_table_t* table;
UT_NOT_USED(trx);
mutex_enter(&(dict_sys->mutex));
table = dict_table_get_low(table_name);
@ -781,13 +826,10 @@ dict_table_get_and_increment_handle_count(
/*======================================*/
/* out: table, NULL if
does not exist */
const char* table_name, /* in: table name */
trx_t* trx) /* in: transaction handle or NULL */
const char* table_name) /* in: table name */
{
dict_table_t* table;
UT_NOT_USED(trx);
mutex_enter(&(dict_sys->mutex));
table = dict_table_get_low(table_name);
@ -819,6 +861,7 @@ dict_table_add_to_cache(
ulint fold;
ulint id_fold;
ulint i;
ulint row_len;
ut_ad(table);
#ifdef UNIV_SYNC_DEBUG
@ -866,6 +909,24 @@ dict_table_add_to_cache(
#error "DATA_N_SYS_COLS != 4"
#endif
row_len = 0;
for (i = 0; i < table->n_def; i++) {
ulint col_len = dtype_get_max_size(
dict_col_get_type(dict_table_get_nth_col(table, i)));
/* If we have a single unbounded field, or several gigantic
fields, mark the maximum row size as ULINT_MAX. */
if (ut_max(col_len, row_len) >= (ULINT_MAX / 2)) {
row_len = ULINT_MAX;
break;
}
row_len += col_len;
}
table->max_row_size = row_len;
/* Look for a table with the same name: error if such exists */
{
dict_table_t* table2;
@ -897,10 +958,7 @@ dict_table_add_to_cache(
/* Add table to LRU list of tables */
UT_LIST_ADD_FIRST(table_LRU, dict_sys->table_LRU, table);
/* If the dictionary cache grows too big, trim the table LRU list */
dict_sys->size += mem_heap_get_size(table->heap);
/* dict_table_LRU_trim(); */
}
/**************************************************************************
@ -1265,38 +1323,6 @@ dict_table_remove_from_cache(
dict_mem_table_free(table);
}
/**************************************************************************
Frees tables from the end of table_LRU if the dictionary cache occupies
too much space. Currently not used! */
void
dict_table_LRU_trim(void)
/*=====================*/
{
dict_table_t* table;
dict_table_t* prev_table;
ut_error;
#ifdef UNIV_SYNC_DEBUG
ut_ad(mutex_own(&(dict_sys->mutex)));
#endif /* UNIV_SYNC_DEBUG */
table = UT_LIST_GET_LAST(dict_sys->table_LRU);
while (table && (dict_sys->size >
buf_pool_get_max_size() / DICT_POOL_PER_VARYING)) {
prev_table = UT_LIST_GET_PREV(table_LRU, table);
if (table->mem_fix == 0) {
dict_table_remove_from_cache(table);
}
table = prev_table;
}
}
/**************************************************************************
Adds a column to the data dictionary hash table. */
static
@ -1443,6 +1469,7 @@ dict_index_add_to_cache(
ut_ad(mem_heap_validate(index->heap));
#ifdef UNIV_DEBUG
{
dict_index_t* index2;
index2 = UT_LIST_GET_FIRST(table->indexes);
@ -1452,10 +1479,11 @@ dict_index_add_to_cache(
index2 = UT_LIST_GET_NEXT(indexes, index2);
}
ut_a(UT_LIST_GET_LEN(table->indexes) == 0
|| (index->type & DICT_CLUSTERED) == 0);
}
#endif /* UNIV_DEBUG */
ut_a(!(index->type & DICT_CLUSTERED)
|| UT_LIST_GET_LEN(table->indexes) == 0);
success = dict_index_find_cols(table, index);
@ -1526,10 +1554,7 @@ dict_index_add_to_cache(
/* Add the index to the list of indexes stored in the tree */
tree->tree_index = new_index;
/* If the dictionary cache grows too big, trim the table LRU list */
dict_sys->size += mem_heap_get_size(new_index->heap);
/* dict_table_LRU_trim(); */
dict_mem_index_free(index);
@ -2091,6 +2116,7 @@ dict_foreign_find(
return(NULL);
}
#ifndef UNIV_HOTBACKUP
/*************************************************************************
Tries to find an index whose first fields are the columns in the array,
in the same order. */
@ -2108,7 +2134,6 @@ dict_foreign_find_index(
only has an effect if types_idx !=
NULL. */
{
#ifndef UNIV_HOTBACKUP
dict_index_t* index;
const char* col_name;
ulint i;
@ -2154,13 +2179,6 @@ dict_foreign_find_index(
}
return(NULL);
#else /* UNIV_HOTBACKUP */
/* This function depends on MySQL code that is not included in
InnoDB Hot Backup builds. Besides, this function should never
be called in InnoDB Hot Backup. */
ut_error;
return(NULL);
#endif /* UNIV_HOTBACKUP */
}
/**************************************************************************
@ -2196,7 +2214,7 @@ dict_foreign_error_report(
putc('\n', file);
if (fk->foreign_index) {
fputs("The index in the foreign key in table is ", file);
ut_print_name(file, NULL, fk->foreign_index->name);
ut_print_name(file, NULL, FALSE, fk->foreign_index->name);
fputs(
"\nSee http://dev.mysql.com/doc/mysql/en/InnoDB_foreign_key_constraints.html\n"
"for correct foreign key definition.\n",
@ -2359,12 +2377,13 @@ dict_scan_to(
/*************************************************************************
Accepts a specified string. Comparisons are case-insensitive. */
static
const char*
dict_accept(
/*========*/
/* out: if string was accepted, the pointer
is moved after that, else ptr is returned */
struct charset_info_st* cs,/* in: the character set of ptr */
const char* ptr, /* in: scan from this */
const char* string, /* in: accept only this string as the next
non-whitespace string */
@ -2375,7 +2394,7 @@ dict_accept(
*success = FALSE;
while (isspace(*ptr)) {
while (my_isspace(cs, *ptr)) {
ptr++;
}
@ -2400,12 +2419,15 @@ const char*
dict_scan_id(
/*=========*/
/* out: scanned to */
struct charset_info_st* cs,/* in: the character set of ptr */
const char* ptr, /* in: scanned to */
mem_heap_t* heap, /* in: heap where to allocate the id
(NULL=id will not be allocated, but it
will point to string near ptr) */
const char** id, /* out,own: the id; NULL if no id was
scannable */
ibool table_id,/* in: TRUE=convert the allocated id
as a table name; FALSE=convert to UTF-8 */
ibool accept_also_dot)
/* in: TRUE if also a dot can appear in a
non-quoted id; in a quoted id it can appear
@ -2414,13 +2436,12 @@ dict_scan_id(
char quote = '\0';
ulint len = 0;
const char* s;
char* d;
ulint id_len;
byte* b;
char* str;
char* dst;
*id = NULL;
while (isspace(*ptr)) {
while (my_isspace(cs, *ptr)) {
ptr++;
}
@ -2451,7 +2472,7 @@ dict_scan_id(
len++;
}
} else {
while (!isspace(*ptr) && *ptr != '(' && *ptr != ')'
while (!my_isspace(cs, *ptr) && *ptr != '(' && *ptr != ')'
&& (accept_also_dot || *ptr != '.')
&& *ptr != ',' && *ptr != '\0') {
@ -2461,43 +2482,50 @@ dict_scan_id(
len = ptr - s;
}
if (quote && heap) {
*id = d = mem_heap_alloc(heap, len + 1);
if (UNIV_UNLIKELY(!heap)) {
/* no heap given: id will point to source string */
*id = s;
return(ptr);
}
if (quote) {
char* d;
str = d = mem_heap_alloc(heap, len + 1);
while (len--) {
if ((*d++ = *s++) == quote) {
s++;
}
}
*d++ = 0;
ut_a(*s == quote);
ut_a(s + 1 == ptr);
} else if (heap) {
*id = mem_heap_strdupl(heap, s, len);
len = d - str;
ut_ad(*s == quote);
ut_ad(s + 1 == ptr);
} else {
/* no heap given: id will point to source string */
*id = s;
str = mem_heap_strdupl(heap, s, len);
}
if (heap && !quote) {
/* EMS MySQL Manager sometimes adds characters 0xA0 (in
latin1, a 'non-breakable space') to the end of a table name.
But isspace(0xA0) is not true, which confuses our foreign key
parser. After the UTF-8 conversion in ha_innodb.cc, bytes 0xC2
and 0xA0 are at the end of the string.
if (!table_id) {
convert_id:
/* Convert the identifier from connection character set
to UTF-8. */
len = 3 * len + 1;
*id = dst = mem_heap_alloc(heap, len);
TODO: we should lex the string using thd->charset_info, and
my_isspace(). Only after that, convert id names to UTF-8. */
innobase_convert_from_id(dst, str, len);
} else if (!strncmp(str, srv_mysql50_table_name_prefix,
sizeof srv_mysql50_table_name_prefix)) {
/* This is a pre-5.1 table name
containing chars other than [A-Za-z0-9].
Discard the prefix and use raw UTF-8 encoding. */
str += sizeof srv_mysql50_table_name_prefix;
len -= sizeof srv_mysql50_table_name_prefix;
goto convert_id;
} else {
/* Encode using filename-safe characters. */
len = 5 * len + 1;
*id = dst = mem_heap_alloc(heap, len);
b = (byte*)(*id);
id_len = strlen((char*) b);
if (id_len >= 3 && b[id_len - 1] == 0xA0
&& b[id_len - 2] == 0xC2) {
/* Strip the 2 last bytes */
b[id_len - 2] = '\0';
}
innobase_convert_from_table_id(dst, str, len);
}
return(ptr);
@ -2510,6 +2538,7 @@ const char*
dict_scan_col(
/*==========*/
/* out: scanned to */
struct charset_info_st* cs,/* in: the character set of ptr */
const char* ptr, /* in: scanned to */
ibool* success,/* out: TRUE if success */
dict_table_t* table, /* in: table in which the column is */
@ -2518,13 +2547,12 @@ dict_scan_col(
const char** name) /* out,own: the column name; NULL if no name
was scannable */
{
#ifndef UNIV_HOTBACKUP
dict_col_t* col;
ulint i;
*success = FALSE;
ptr = dict_scan_id(ptr, heap, name, TRUE);
ptr = dict_scan_id(cs, ptr, heap, name, FALSE, TRUE);
if (*name == NULL) {
@ -2552,13 +2580,6 @@ dict_scan_col(
}
return(ptr);
#else /* UNIV_HOTBACKUP */
/* This function depends on MySQL code that is not included in
InnoDB Hot Backup builds. Besides, this function should never
be called in InnoDB Hot Backup. */
ut_error;
return(NULL);
#endif /* UNIV_HOTBACKUP */
}
/*************************************************************************
@ -2568,6 +2589,7 @@ const char*
dict_scan_table_name(
/*=================*/
/* out: scanned to */
struct charset_info_st* cs,/* in: the character set of ptr */
const char* ptr, /* in: scanned to */
dict_table_t** table, /* out: table object or NULL */
const char* name, /* in: foreign key table name */
@ -2576,7 +2598,6 @@ dict_scan_table_name(
const char** ref_name)/* out,own: the table name;
NULL if no name was scannable */
{
#ifndef UNIV_HOTBACKUP
const char* database_name = NULL;
ulint database_name_len = 0;
const char* table_name = NULL;
@ -2587,7 +2608,7 @@ dict_scan_table_name(
*success = FALSE;
*table = NULL;
ptr = dict_scan_id(ptr, heap, &scan_name, FALSE);
ptr = dict_scan_id(cs, ptr, heap, &scan_name, TRUE, FALSE);
if (scan_name == NULL) {
@ -2602,7 +2623,7 @@ dict_scan_table_name(
database_name = scan_name;
database_name_len = strlen(database_name);
ptr = dict_scan_id(ptr, heap, &table_name, FALSE);
ptr = dict_scan_id(cs, ptr, heap, &table_name, TRUE, FALSE);
if (table_name == NULL) {
@ -2658,13 +2679,6 @@ dict_scan_table_name(
*table = dict_table_get_low(ref);
return(ptr);
#else /* UNIV_HOTBACKUP */
/* This function depends on MySQL code that is not included in
InnoDB Hot Backup builds. Besides, this function should never
be called in InnoDB Hot Backup. */
ut_error;
return(NULL);
#endif /* UNIV_HOTBACKUP */
}
/*************************************************************************
@ -2674,6 +2688,7 @@ const char*
dict_skip_word(
/*===========*/
/* out: scanned to */
struct charset_info_st* cs,/* in: the character set of ptr */
const char* ptr, /* in: scanned to */
ibool* success)/* out: TRUE if success, FALSE if just spaces
left in string or a syntax error */
@ -2682,7 +2697,7 @@ dict_skip_word(
*success = FALSE;
ptr = dict_scan_id(ptr, NULL, &start, TRUE);
ptr = dict_scan_id(cs, ptr, NULL, &start, FALSE, TRUE);
if (start) {
*success = TRUE;
@ -2860,6 +2875,7 @@ dict_create_foreign_constraints_low(
/* out: error code or DB_SUCCESS */
trx_t* trx, /* in: transaction */
mem_heap_t* heap, /* in: memory heap */
struct charset_info_st* cs,/* in: the character set of sql_string */
const char* sql_string,
/* in: CREATE TABLE or ALTER TABLE statement
where foreign keys are declared like:
@ -2917,14 +2933,14 @@ dict_create_foreign_constraints_low(
/* First check if we are actually doing an ALTER TABLE, and in that
case look for the table being altered */
ptr = dict_accept(ptr, "ALTER", &success);
ptr = dict_accept(cs, ptr, "ALTER", &success);
if (!success) {
goto loop;
}
ptr = dict_accept(ptr, "TABLE", &success);
ptr = dict_accept(cs, ptr, "TABLE", &success);
if (!success) {
@ -2933,7 +2949,7 @@ dict_create_foreign_constraints_low(
/* We are doing an ALTER TABLE: scan the table name we are altering */
ptr = dict_scan_table_name(ptr, &table_to_alter, name,
ptr = dict_scan_table_name(cs, ptr, &table_to_alter, name,
&success, heap, &referenced_table_name);
if (!success) {
fprintf(stderr,
@ -2973,21 +2989,22 @@ loop:
of the constraint to system tables. */
ptr = ptr1;
ptr = dict_accept(ptr, "CONSTRAINT", &success);
ptr = dict_accept(cs, ptr, "CONSTRAINT", &success);
ut_a(success);
if (!isspace(*ptr) && *ptr != '"' && *ptr != '`') {
if (!my_isspace(cs, *ptr) && *ptr != '"' && *ptr != '`') {
goto loop;
}
while (isspace(*ptr)) {
while (my_isspace(cs, *ptr)) {
ptr++;
}
/* read constraint name unless got "CONSTRAINT FOREIGN" */
if (ptr != ptr2) {
ptr = dict_scan_id(ptr, heap, &constraint_name, FALSE);
ptr = dict_scan_id(cs, ptr, heap,
&constraint_name, FALSE, FALSE);
}
} else {
ptr = ptr2;
@ -3002,7 +3019,8 @@ loop:
if so, immediately reject the command if the table is a
temporary one. For now, this kludge will work. */
if (reject_fks && (UT_LIST_GET_LEN(table->foreign_list) > 0)) {
return DB_CANNOT_ADD_CONSTRAINT;
return(DB_CANNOT_ADD_CONSTRAINT);
}
/**********************************************************/
@ -3016,28 +3034,28 @@ loop:
start_of_latest_foreign = ptr;
ptr = dict_accept(ptr, "FOREIGN", &success);
ptr = dict_accept(cs, ptr, "FOREIGN", &success);
if (!success) {
goto loop;
}
if (!isspace(*ptr)) {
if (!my_isspace(cs, *ptr)) {
goto loop;
}
ptr = dict_accept(ptr, "KEY", &success);
ptr = dict_accept(cs, ptr, "KEY", &success);
if (!success) {
goto loop;
}
ptr = dict_accept(ptr, "(", &success);
ptr = dict_accept(cs, ptr, "(", &success);
if (!success) {
/* MySQL allows also an index id before the '('; we
skip it */
ptr = dict_skip_word(ptr, &success);
ptr = dict_skip_word(cs, ptr, &success);
if (!success) {
dict_foreign_report_syntax_err(name,
@ -3046,7 +3064,7 @@ loop:
return(DB_CANNOT_ADD_CONSTRAINT);
}
ptr = dict_accept(ptr, "(", &success);
ptr = dict_accept(cs, ptr, "(", &success);
if (!success) {
/* We do not flag a syntax error here because in an
@ -3061,7 +3079,7 @@ loop:
/* Scan the columns in the first list */
col_loop1:
ut_a(i < (sizeof column_names) / sizeof *column_names);
ptr = dict_scan_col(ptr, &success, table, columns + i,
ptr = dict_scan_col(cs, ptr, &success, table, columns + i,
heap, column_names + i);
if (!success) {
mutex_enter(&dict_foreign_err_mutex);
@ -3075,13 +3093,13 @@ col_loop1:
i++;
ptr = dict_accept(ptr, ",", &success);
ptr = dict_accept(cs, ptr, ",", &success);
if (success) {
goto col_loop1;
}
ptr = dict_accept(ptr, ")", &success);
ptr = dict_accept(cs, ptr, ")", &success);
if (!success) {
dict_foreign_report_syntax_err(name, start_of_latest_foreign,
@ -3098,7 +3116,7 @@ col_loop1:
mutex_enter(&dict_foreign_err_mutex);
dict_foreign_error_report_low(ef, name);
fputs("There is no index in table ", ef);
ut_print_name(ef, NULL, name);
ut_print_name(ef, NULL, TRUE, name);
fprintf(ef, " where the columns appear\n"
"as the first columns. Constraint:\n%s\n"
"See http://dev.mysql.com/doc/mysql/en/InnoDB_foreign_key_constraints.html\n"
@ -3108,9 +3126,9 @@ col_loop1:
return(DB_CANNOT_ADD_CONSTRAINT);
}
ptr = dict_accept(ptr, "REFERENCES", &success);
ptr = dict_accept(cs, ptr, "REFERENCES", &success);
if (!success || !isspace(*ptr)) {
if (!success || !my_isspace(cs, *ptr)) {
dict_foreign_report_syntax_err(name, start_of_latest_foreign,
ptr);
return(DB_CANNOT_ADD_CONSTRAINT);
@ -3150,7 +3168,7 @@ col_loop1:
mem_heap_strdup(foreign->heap, columns[i]->name);
}
ptr = dict_scan_table_name(ptr, &referenced_table, name,
ptr = dict_scan_table_name(cs, ptr, &referenced_table, name,
&success, heap, &referenced_table_name);
/* Note that referenced_table can be NULL if the user has suppressed
@ -3169,7 +3187,7 @@ col_loop1:
return(DB_CANNOT_ADD_CONSTRAINT);
}
ptr = dict_accept(ptr, "(", &success);
ptr = dict_accept(cs, ptr, "(", &success);
if (!success) {
dict_foreign_free(foreign);
@ -3182,7 +3200,7 @@ col_loop1:
i = 0;
col_loop2:
ptr = dict_scan_col(ptr, &success, referenced_table, columns + i,
ptr = dict_scan_col(cs, ptr, &success, referenced_table, columns + i,
heap, column_names + i);
i++;
@ -3199,13 +3217,13 @@ col_loop2:
return(DB_CANNOT_ADD_CONSTRAINT);
}
ptr = dict_accept(ptr, ",", &success);
ptr = dict_accept(cs, ptr, ",", &success);
if (success) {
goto col_loop2;
}
ptr = dict_accept(ptr, ")", &success);
ptr = dict_accept(cs, ptr, ")", &success);
if (!success || foreign->n_fields != i) {
dict_foreign_free(foreign);
@ -3221,17 +3239,17 @@ col_loop2:
scan_on_conditions:
/* Loop here as long as we can find ON ... conditions */
ptr = dict_accept(ptr, "ON", &success);
ptr = dict_accept(cs, ptr, "ON", &success);
if (!success) {
goto try_find_index;
}
ptr = dict_accept(ptr, "DELETE", &success);
ptr = dict_accept(cs, ptr, "DELETE", &success);
if (!success) {
ptr = dict_accept(ptr, "UPDATE", &success);
ptr = dict_accept(cs, ptr, "UPDATE", &success);
if (!success) {
dict_foreign_free(foreign);
@ -3248,13 +3266,13 @@ scan_on_conditions:
n_on_deletes++;
}
ptr = dict_accept(ptr, "RESTRICT", &success);
ptr = dict_accept(cs, ptr, "RESTRICT", &success);
if (success) {
goto scan_on_conditions;
}
ptr = dict_accept(ptr, "CASCADE", &success);
ptr = dict_accept(cs, ptr, "CASCADE", &success);
if (success) {
if (is_on_delete) {
@ -3266,10 +3284,10 @@ scan_on_conditions:
goto scan_on_conditions;
}
ptr = dict_accept(ptr, "NO", &success);
ptr = dict_accept(cs, ptr, "NO", &success);
if (success) {
ptr = dict_accept(ptr, "ACTION", &success);
ptr = dict_accept(cs, ptr, "ACTION", &success);
if (!success) {
dict_foreign_free(foreign);
@ -3288,7 +3306,7 @@ scan_on_conditions:
goto scan_on_conditions;
}
ptr = dict_accept(ptr, "SET", &success);
ptr = dict_accept(cs, ptr, "SET", &success);
if (!success) {
dict_foreign_free(foreign);
@ -3297,7 +3315,7 @@ scan_on_conditions:
return(DB_CANNOT_ADD_CONSTRAINT);
}
ptr = dict_accept(ptr, "NULL", &success);
ptr = dict_accept(cs, ptr, "NULL", &success);
if (!success) {
dict_foreign_free(foreign);
@ -3407,6 +3425,25 @@ try_find_index:
goto loop;
}
/**************************************************************************
Determines whether a string starts with the specified keyword. */
ibool
dict_str_starts_with_keyword(
/*=========================*/
/* out: TRUE if str starts
with keyword */
void* mysql_thd, /* in: MySQL thread handle */
const char* str, /* in: string to scan for keyword */
const char* keyword) /* in: keyword to look for */
{
struct charset_info_st* cs = innobase_get_charset(mysql_thd);
ibool success;
dict_accept(cs, str, keyword, &success);
return(success);
}
/*************************************************************************
Scans a table create SQL string and adds to the data dictionary the foreign
key constraints declared in the string. This function should be called after
@ -3434,15 +3471,18 @@ dict_create_foreign_constraints(
code DB_CANNOT_ADD_CONSTRAINT if
any foreign keys are found. */
{
char* str;
ulint err;
mem_heap_t* heap;
char* str;
ulint err;
mem_heap_t* heap;
ut_a(trx && trx->mysql_thd);
str = dict_strip_comments(sql_string);
heap = mem_heap_create(10000);
err = dict_create_foreign_constraints_low(trx, heap, str, name,
reject_fks);
err = dict_create_foreign_constraints_low(trx, heap,
innobase_get_charset(trx->mysql_thd),
str, name, reject_fks);
mem_heap_free(heap);
mem_free(str);
@ -3469,12 +3509,17 @@ dict_foreign_parse_drop_constraints(
const char*** constraints_to_drop) /* out: id's of the
constraints to drop */
{
dict_foreign_t* foreign;
ibool success;
char* str;
const char* ptr;
const char* id;
FILE* ef = dict_foreign_err_file;
dict_foreign_t* foreign;
ibool success;
char* str;
const char* ptr;
const char* id;
FILE* ef = dict_foreign_err_file;
struct charset_info_st* cs;
ut_a(trx && trx->mysql_thd);
cs = innobase_get_charset(trx->mysql_thd);
*n = 0;
@ -3495,28 +3540,28 @@ loop:
return(DB_SUCCESS);
}
ptr = dict_accept(ptr, "DROP", &success);
ptr = dict_accept(cs, ptr, "DROP", &success);
if (!isspace(*ptr)) {
if (!my_isspace(cs, *ptr)) {
goto loop;
}
ptr = dict_accept(ptr, "FOREIGN", &success);
ptr = dict_accept(cs, ptr, "FOREIGN", &success);
if (!success) {
goto loop;
}
ptr = dict_accept(ptr, "KEY", &success);
ptr = dict_accept(cs, ptr, "KEY", &success);
if (!success) {
goto syntax_error;
}
ptr = dict_scan_id(ptr, heap, &id, TRUE);
ptr = dict_scan_id(cs, ptr, heap, &id, FALSE, TRUE);
if (id == NULL) {
@ -3549,12 +3594,12 @@ loop:
ut_print_timestamp(ef);
fputs(
" Error in dropping of a foreign key constraint of table ", ef);
ut_print_name(ef, NULL, table->name);
ut_print_name(ef, NULL, TRUE, table->name);
fputs(",\n"
"in SQL command\n", ef);
fputs(str, ef);
fputs("\nCannot find a constraint with the given id ", ef);
ut_print_name(ef, NULL, id);
ut_print_name(ef, NULL, FALSE, id);
fputs(".\n", ef);
mutex_exit(&dict_foreign_err_mutex);
@ -3571,7 +3616,7 @@ syntax_error:
ut_print_timestamp(ef);
fputs(
" Syntax error in dropping of a foreign key constraint of table ", ef);
ut_print_name(ef, NULL, table->name);
ut_print_name(ef, NULL, TRUE, table->name);
fprintf(ef, ",\n"
"close to:\n%s\n in SQL command\n%s\n", ptr, str);
mutex_exit(&dict_foreign_err_mutex);
@ -3580,6 +3625,7 @@ syntax_error:
return(DB_CANNOT_DROP_CONSTRAINT);
}
#endif /* UNIV_HOTBACKUP */
/*==================== END OF FOREIGN KEY PROCESSING ====================*/
@ -3653,9 +3699,7 @@ dict_tree_create(
tree->magic_n = DICT_TREE_MAGIC_N;
rw_lock_create(&(tree->lock));
rw_lock_set_level(&(tree->lock), SYNC_INDEX_TREE);
rw_lock_create(&tree->lock, SYNC_INDEX_TREE);
return(tree);
}
@ -4232,11 +4276,11 @@ dict_print_info_on_foreign_key_in_create_format(
}
fputs(" CONSTRAINT ", file);
ut_print_name(file, trx, stripped_id);
ut_print_name(file, trx, FALSE, stripped_id);
fputs(" FOREIGN KEY (", file);
for (i = 0;;) {
ut_print_name(file, trx, foreign->foreign_col_names[i]);
ut_print_name(file, trx, FALSE, foreign->foreign_col_names[i]);
if (++i < foreign->n_fields) {
fputs(", ", file);
} else {
@ -4249,7 +4293,7 @@ dict_print_info_on_foreign_key_in_create_format(
if (dict_tables_have_same_db(foreign->foreign_table_name,
foreign->referenced_table_name)) {
/* Do not print the database name of the referenced table */
ut_print_name(file, trx, dict_remove_db_name(
ut_print_name(file, trx, TRUE, dict_remove_db_name(
foreign->referenced_table_name));
} else {
/* Look for the '/' in the table name */
@ -4259,9 +4303,10 @@ dict_print_info_on_foreign_key_in_create_format(
i++;
}
ut_print_namel(file, trx, foreign->referenced_table_name, i);
ut_print_namel(file, trx, TRUE,
foreign->referenced_table_name, i);
putc('.', file);
ut_print_name(file, trx,
ut_print_name(file, trx, TRUE,
foreign->referenced_table_name + i + 1);
}
@ -4269,7 +4314,8 @@ dict_print_info_on_foreign_key_in_create_format(
putc('(', file);
for (i = 0;;) {
ut_print_name(file, trx, foreign->referenced_col_names[i]);
ut_print_name(file, trx, FALSE,
foreign->referenced_col_names[i]);
if (++i < foreign->n_fields) {
fputs(", ", file);
} else {
@ -4343,12 +4389,12 @@ dict_print_info_on_foreign_keys(
putc(' ', file);
}
ut_print_name(file, trx,
ut_print_name(file, trx, FALSE,
foreign->foreign_col_names[i]);
}
fputs(") REFER ", file);
ut_print_name(file, trx,
ut_print_name(file, trx, TRUE,
foreign->referenced_table_name);
putc('(', file);
@ -4356,7 +4402,7 @@ dict_print_info_on_foreign_keys(
if (i) {
putc(' ', file);
}
ut_print_name(file, trx,
ut_print_name(file, trx, FALSE,
foreign->referenced_col_names[i]);
}
@ -4403,7 +4449,7 @@ dict_index_name_print(
const dict_index_t* index) /* in: index to print */
{
fputs("index ", file);
ut_print_name(file, trx, index->name);
ut_print_name(file, trx, FALSE, index->name);
fputs(" of table ", file);
ut_print_name(file, trx, index->table_name);
ut_print_name(file, trx, TRUE, index->table_name);
}

View File

@ -184,7 +184,7 @@ loop:
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

View File

@ -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;

View File

@ -1050,8 +1050,7 @@ try_again:
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);

View File

@ -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;

View File

@ -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_create(&ibuf_pessimistic_insert_mutex,
SYNC_IBUF_PESS_INSERT_MUTEX);
mutex_set_level(&ibuf_pessimistic_insert_mutex,
SYNC_IBUF_PESS_INSERT_MUTEX);
mutex_create(&ibuf_mutex);
mutex_create(&ibuf_mutex, SYNC_IBUF_MUTEX);
mutex_set_level(&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 @@ count_later:
}
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);

View File

@ -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

View File

@ -44,18 +44,6 @@ dict_get_db_name_len(
/* out: database name length */
const char* name); /* in: table name in the form
dbname '/' tablename */
/*************************************************************************
Accepts a specified string. Comparisons are case-insensitive. */
const char*
dict_accept(
/*========*/
/* out: if string was accepted, the pointer
is moved after that, else ptr is returned */
const char* ptr, /* in: scan from this */
const char* string, /* in: accept only this string as the next
non-whitespace string */
ibool* success);/* out: TRUE if accepted */
/************************************************************************
Decrements the count of open MySQL handles to a table. */
@ -219,6 +207,17 @@ dict_table_referenced_by_foreign_key(
/* out: TRUE if table is referenced by a
foreign key */
dict_table_t* table); /* in: InnoDB table */
/**************************************************************************
Determines whether a string starts with the specified keyword. */
ibool
dict_str_starts_with_keyword(
/*=========================*/
/* out: TRUE if str starts
with keyword */
void* mysql_thd, /* in: MySQL thread handle */
const char* str, /* in: string to scan for keyword */
const char* keyword); /* in: keyword to look for */
/*************************************************************************
Scans a table create SQL string and adds to the data dictionary
the foreign key constraints declared in the string. This function
@ -265,17 +264,16 @@ dict_foreign_parse_drop_constraints(
const char*** constraints_to_drop); /* out: id's of the
constraints to drop */
/**************************************************************************
Returns a table object and memoryfixes it. NOTE! This is a high-level
function to be used mainly from outside the 'dict' directory. Inside this
directory dict_table_get_low is usually the appropriate function. */
Returns a table object. NOTE! This is a high-level function to be used
mainly from outside the 'dict' directory. Inside this directory
dict_table_get_low is usually the appropriate function. */
dict_table_t*
dict_table_get(
/*===========*/
/* out: table, NULL if
does not exist */
const char* table_name, /* in: table name */
trx_t* trx); /* in: transaction handle */
const char* table_name); /* in: table name */
/**************************************************************************
Returns a table object and increments MySQL open handle count on the table.
*/
@ -285,10 +283,9 @@ dict_table_get_and_increment_handle_count(
/*======================================*/
/* out: table, NULL if
does not exist */
const char* table_name, /* in: table name */
trx_t* trx); /* in: transaction handle or NULL */
const char* table_name); /* in: table name */
/**************************************************************************
Returns a table object, based on table id, and memoryfixes it. */
Returns a table object based on table id. */
dict_table_t*
dict_table_get_on_id(
@ -297,21 +294,13 @@ dict_table_get_on_id(
dulint table_id, /* in: table id */
trx_t* trx); /* in: transaction handle */
/**************************************************************************
Returns a table object, based on table id, and memoryfixes it. */
Returns a table object based on table id. */
UNIV_INLINE
dict_table_t*
dict_table_get_on_id_low(
/*=====================*/
/* out: table, NULL if does not exist */
dulint table_id, /* in: table id */
trx_t* trx); /* in: transaction handle */
/**************************************************************************
Releases a table from being memoryfixed. Currently this has no relevance. */
UNIV_INLINE
void
dict_table_release(
/*===============*/
dict_table_t* table); /* in: table to be released */
dulint table_id); /* in: table id */
/**************************************************************************
Checks if a table is in the dictionary cache. */
UNIV_INLINE

View File

@ -545,14 +545,13 @@ dict_table_get_low(
}
/**************************************************************************
Returns a table object, based on table id, and memoryfixes it. */
Returns a table object based on table id. */
UNIV_INLINE
dict_table_t*
dict_table_get_on_id_low(
/*=====================*/
/* out: table, NULL if does not exist */
dulint table_id, /* in: table id */
trx_t* trx) /* in: transaction handle */
dulint table_id) /* in: table id */
{
dict_table_t* table;
ulint fold;
@ -560,7 +559,6 @@ dict_table_get_on_id_low(
#ifdef UNIV_SYNC_DEBUG
ut_ad(mutex_own(&(dict_sys->mutex)));
#endif /* UNIV_SYNC_DEBUG */
UT_NOT_USED(trx);
/* Look for the table name in the hash table */
fold = ut_fold_dulint(table_id);
@ -571,32 +569,11 @@ dict_table_get_on_id_low(
table = dict_load_table_on_id(table_id);
}
if (table != NULL) {
table->mem_fix++;
/* lock_push(trx, table, LOCK_DICT_MEM_FIX) */
}
/* TODO: should get the type information from MySQL */
return(table);
}
/**************************************************************************
Releases a table from being memoryfixed. Currently this has no relevance. */
UNIV_INLINE
void
dict_table_release(
/*===============*/
dict_table_t* table) /* in: table to be released */
{
mutex_enter(&(dict_sys->mutex));
table->mem_fix--;
mutex_exit(&(dict_sys->mutex));
}
/**************************************************************************
Returns an index object. */
UNIV_INLINE

Some files were not shown because too many files have changed in this diff Show More