mirror of
https://github.com/MariaDB/server.git
synced 2025-11-18 07:48:43 +03:00
Merge bk-internal:/home/bk/mysql-5.1-new
into neptunus.(none):/home/msvensson/mysql/mysql-5.1
This commit is contained in:
11
mysql-test/include/ndb_restore_slave_eoption.inc
Normal file
11
mysql-test/include/ndb_restore_slave_eoption.inc
Normal file
@@ -0,0 +1,11 @@
|
||||
######################################################
|
||||
# By JBM 2006-03-08 So that the code is not repeated #
|
||||
# in test cases and can be reused. #
|
||||
######################################################
|
||||
|
||||
--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT_SLAVE" -p 8 -b $the_backup_id -n 1 -m -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT
|
||||
|
||||
--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT_SLAVE" -p 8 -b $the_backup_id -n 2 -r -e --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT
|
||||
|
||||
|
||||
|
||||
@@ -262,6 +262,12 @@ sub collect_one_test_case($$$$$$$) {
|
||||
$tinfo->{'skip'}= 1;
|
||||
return;
|
||||
}
|
||||
if ( ! $::opt_with_ndbcluster )
|
||||
{
|
||||
# Ndb is not supported, skip them
|
||||
$tinfo->{'skip'}= 1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -2034,7 +2034,7 @@ sub run_testcase ($) {
|
||||
if ( $tinfo->{'master_restart'} or
|
||||
$master->[0]->{'running_master_is_special'} or
|
||||
# Stop if cluster is started but test cases does not need cluster
|
||||
( $tinfo->{'ndb_test'} != $using_ndbcluster_master ) )
|
||||
( $opt_with_ndbcluster && $tinfo->{'ndb_test'} != $using_ndbcluster_master ) )
|
||||
{
|
||||
stop_masters();
|
||||
$master->[0]->{'running_master_is_special'}= 0; # Forget why we stopped
|
||||
@@ -2087,7 +2087,7 @@ sub run_testcase ($) {
|
||||
|
||||
if ( $tinfo->{'component_id'} eq 'mysqld' and ! $opt_local_master )
|
||||
{
|
||||
if ( $master->[0]->{'ndbcluster'} )
|
||||
if ( $opt_with_ndbcluster and $master->[0]->{'ndbcluster'} )
|
||||
{
|
||||
# Cluster is not started
|
||||
|
||||
|
||||
@@ -680,7 +680,7 @@ drop procedure if exists fn3;
|
||||
create function fn3 () returns point return GeomFromText("point(1 1)");
|
||||
show create function fn3;
|
||||
Function sql_mode Create Function
|
||||
fn3 CREATE FUNCTION `fn3`() RETURNS point
|
||||
fn3 CREATE DEFINER=`root`@`localhost` FUNCTION `fn3`() RETURNS point
|
||||
return GeomFromText("point(1 1)")
|
||||
select astext(fn3());
|
||||
astext(fn3())
|
||||
|
||||
@@ -322,7 +322,7 @@ Function sql_mode Create Function
|
||||
sub1
|
||||
show create function sub2;
|
||||
Function sql_mode Create Function
|
||||
sub2 CREATE FUNCTION `sub2`(i int) RETURNS int(11)
|
||||
sub2 CREATE DEFINER=`mysqltest_1`@`localhost` FUNCTION `sub2`(i int) RETURNS int(11)
|
||||
return i+1
|
||||
show function status like "sub2";
|
||||
Db Name Type Definer Modified Created Security_type Comment
|
||||
@@ -330,7 +330,7 @@ test sub2 FUNCTION mysqltest_1@localhost # # DEFINER
|
||||
drop function sub2;
|
||||
show create procedure sel2;
|
||||
Procedure sql_mode Create Procedure
|
||||
sel2 CREATE PROCEDURE `sel2`()
|
||||
sel2 CREATE DEFINER=`root`@`localhost` PROCEDURE `sel2`()
|
||||
begin
|
||||
select * from t1;
|
||||
select * from t2;
|
||||
|
||||
@@ -2279,12 +2279,12 @@ UNLOCK TABLES;
|
||||
DELIMITER ;;
|
||||
/*!50003 DROP FUNCTION IF EXISTS `bug9056_func1` */;;
|
||||
/*!50003 SET SESSION SQL_MODE=""*/;;
|
||||
/*!50003 CREATE FUNCTION `bug9056_func1`(a INT, b INT) RETURNS int(11)
|
||||
/*!50003 CREATE*/ /*!50019 DEFINER=`root`@`localhost`*/ /*!50003 FUNCTION `bug9056_func1`(a INT, b INT) RETURNS int(11)
|
||||
RETURN a+b */;;
|
||||
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
|
||||
/*!50003 DROP FUNCTION IF EXISTS `bug9056_func2` */;;
|
||||
/*!50003 SET SESSION SQL_MODE=""*/;;
|
||||
/*!50003 CREATE FUNCTION `bug9056_func2`(f1 char binary) RETURNS char(1)
|
||||
/*!50003 CREATE*/ /*!50019 DEFINER=`root`@`localhost`*/ /*!50003 FUNCTION `bug9056_func2`(f1 char binary) RETURNS char(1)
|
||||
begin
|
||||
set f1= concat( 'hello', f1 );
|
||||
return f1;
|
||||
@@ -2292,17 +2292,17 @@ end */;;
|
||||
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
|
||||
/*!50003 DROP PROCEDURE IF EXISTS `a'b` */;;
|
||||
/*!50003 SET SESSION SQL_MODE="REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI"*/;;
|
||||
/*!50003 CREATE PROCEDURE "a'b"()
|
||||
/*!50003 CREATE*/ /*!50019 DEFINER="root"@"localhost"*/ /*!50003 PROCEDURE "a'b"()
|
||||
select 1 */;;
|
||||
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
|
||||
/*!50003 DROP PROCEDURE IF EXISTS `bug9056_proc1` */;;
|
||||
/*!50003 SET SESSION SQL_MODE=""*/;;
|
||||
/*!50003 CREATE PROCEDURE `bug9056_proc1`(IN a INT, IN b INT, OUT c INT)
|
||||
/*!50003 CREATE*/ /*!50019 DEFINER=`root`@`localhost`*/ /*!50003 PROCEDURE `bug9056_proc1`(IN a INT, IN b INT, OUT c INT)
|
||||
BEGIN SELECT a+b INTO c; end */;;
|
||||
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
|
||||
/*!50003 DROP PROCEDURE IF EXISTS `bug9056_proc2` */;;
|
||||
/*!50003 SET SESSION SQL_MODE=""*/;;
|
||||
/*!50003 CREATE PROCEDURE `bug9056_proc2`(OUT a INT)
|
||||
/*!50003 CREATE*/ /*!50019 DEFINER=`root`@`localhost`*/ /*!50003 PROCEDURE `bug9056_proc2`(OUT a INT)
|
||||
BEGIN
|
||||
select sum(id) from t1 into a;
|
||||
END */;;
|
||||
@@ -2724,11 +2724,11 @@ return 42 */|
|
||||
select 42 */|
|
||||
show create function f;
|
||||
Function sql_mode Create Function
|
||||
f CREATE FUNCTION `f`() RETURNS bigint(20)
|
||||
f CREATE DEFINER=`root`@`localhost` FUNCTION `f`() RETURNS bigint(20)
|
||||
return 42
|
||||
show create procedure p;
|
||||
Procedure sql_mode Create Procedure
|
||||
p CREATE PROCEDURE `p`()
|
||||
p CREATE DEFINER=`root`@`localhost` PROCEDURE `p`()
|
||||
select 42
|
||||
drop function f;
|
||||
drop procedure p;
|
||||
|
||||
@@ -78,49 +78,58 @@ S 7 a6bae0cfe6b45ff8c3c12d2ce577a1cd3931190f 107 39ee712b4b9e47f2cf3ba7c9790b2bf
|
||||
S 8 e139adcb7b2974ee7ff227fd405709e5cb7c896c 108 ba8073b0e1a281d4111bd2d82c7722b01574c00b NULL
|
||||
S 9 1fc5168fe4be566b17b658d94e7813f0b5032cdb NULL NULL NULL
|
||||
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: VERSION, Binlog ver: 4
|
||||
master-bin.000001 102 Query 1 239 use `test`; create table t1 (
|
||||
a int not null primary key,
|
||||
b text not null
|
||||
) engine=ndb
|
||||
master-bin.000001 239 Query 1 303 BEGIN
|
||||
master-bin.000001 303 Table_map 1 53 cluster.apply_status
|
||||
master-bin.000001 356 Write_rows 1 95
|
||||
master-bin.000001 398 Table_map 1 135 test.t1
|
||||
master-bin.000001 438 Write_rows 1 806
|
||||
master-bin.000001 1109 Write_rows 1 9841
|
||||
master-bin.000001 10144 Query 1 10209 COMMIT
|
||||
master-bin.000001 10209 Query 1 10273 BEGIN
|
||||
master-bin.000001 10273 Table_map 1 53 cluster.apply_status
|
||||
master-bin.000001 10326 Write_rows 1 95
|
||||
master-bin.000001 10368 Query 1 10433 COMMIT
|
||||
master-bin.000001 10433 Query 1 10509 use `test`; drop table t1
|
||||
master-bin.000001 10509 Query 1 10684 use `test`; create table t1 (
|
||||
a int not null primary key,
|
||||
b text not null,
|
||||
c int,
|
||||
d longblob,
|
||||
e tinyblob
|
||||
) engine=ndbcluster
|
||||
master-bin.000001 10684 Query 1 10748 BEGIN
|
||||
master-bin.000001 10748 Table_map 1 53 cluster.apply_status
|
||||
master-bin.000001 10801 Write_rows 1 95
|
||||
master-bin.000001 10843 Table_map 1 138 test.t1
|
||||
master-bin.000001 10886 Write_rows 1 48922
|
||||
master-bin.000001 59670 Write_rows 1 124424
|
||||
master-bin.000001 135172 Write_rows 1 124530
|
||||
master-bin.000001 135278 Write_rows 1 205949
|
||||
master-bin.000001 216697 Write_rows 1 224233
|
||||
master-bin.000001 234981 Write_rows 1 227511
|
||||
master-bin.000001 238259 Write_rows 1 242379
|
||||
master-bin.000001 253127 Write_rows 1 254075
|
||||
master-bin.000001 264823 Write_rows 1 304323
|
||||
master-bin.000001 315071 Write_rows 1 330415
|
||||
master-bin.000001 341163 Query 1 341228 COMMIT
|
||||
master-bin.000001 341228 Query 1 341292 BEGIN
|
||||
master-bin.000001 341292 Table_map 1 53 cluster.apply_status
|
||||
master-bin.000001 341345 Write_rows 1 95
|
||||
master-bin.000001 341387 Query 1 341452 COMMIT
|
||||
master-bin.000001 341452 Query 1 341528 use `test`; drop table t1
|
||||
CREATE TABLE IF NOT EXISTS t1 (
|
||||
db VARBINARY(63) NOT NULL,
|
||||
name VARBINARY(63) NOT NULL,
|
||||
slock BINARY(32) NOT NULL,
|
||||
query BLOB NOT NULL,
|
||||
node_id INT UNSIGNED NOT NULL,
|
||||
epoch BIGINT UNSIGNED NOT NULL,
|
||||
id INT UNSIGNED NOT NULL,
|
||||
version INT UNSIGNED NOT NULL,
|
||||
type INT UNSIGNED NOT NULL,
|
||||
PRIMARY KEY USING HASH (db,name))
|
||||
ENGINE=NDB;
|
||||
insert into t1 values ('test','t1',
|
||||
'abc',repeat(@s0,10), 11,12,13,14,15);
|
||||
insert into t1 values ('test','t2',
|
||||
'def',repeat(@s1,100), 21,22,23,24,25);
|
||||
insert into t1 values ('test','t3',
|
||||
'ghi',repeat(@s2,1000),31,32,33,34,35);
|
||||
insert into t1 values ('testtttttttttt','t1',
|
||||
'abc',repeat(@s0,10), 11,12,13,14,15);
|
||||
insert into t1 values ('testttttttttttt','t1',
|
||||
'def',repeat(@s1,100), 21,22,23,24,25);
|
||||
insert into t1 values ('testtttttttttttt','t1',
|
||||
'ghi',repeat(@s2,1000),31,32,33,34,35);
|
||||
insert into t1 values ('t','t11111111111',
|
||||
'abc',repeat(@s0,10), 11,12,13,14,15);
|
||||
insert into t1 values ('t','t111111111111',
|
||||
'def',repeat(@s1,100), 21,22,23,24,25);
|
||||
insert into t1 values ('t','t1111111111111',
|
||||
'ghi',repeat(@s2,1000),31,32,33,34,35);
|
||||
select 'M', db, name, sha1(query), node_id, epoch, id, version, type
|
||||
from t1 order by db, name;
|
||||
M db name sha1(query) node_id epoch id version type
|
||||
M t t11111111111 8fc937d303ee7e4795c0b964d4066cedd6d74cfd 11 12 13 14 15
|
||||
M t t111111111111 a5229e9f8977bc99afc3b3627c56f083e97e01bd 21 22 23 24 25
|
||||
M t t1111111111111 0820e6ad3eeb06ea60e5e04d0bfe36f286b91098 31 32 33 34 35
|
||||
M test t1 8fc937d303ee7e4795c0b964d4066cedd6d74cfd 11 12 13 14 15
|
||||
M test t2 a5229e9f8977bc99afc3b3627c56f083e97e01bd 21 22 23 24 25
|
||||
M test t3 0820e6ad3eeb06ea60e5e04d0bfe36f286b91098 31 32 33 34 35
|
||||
M testtttttttttt t1 8fc937d303ee7e4795c0b964d4066cedd6d74cfd 11 12 13 14 15
|
||||
M testttttttttttt t1 a5229e9f8977bc99afc3b3627c56f083e97e01bd 21 22 23 24 25
|
||||
M testtttttttttttt t1 0820e6ad3eeb06ea60e5e04d0bfe36f286b91098 31 32 33 34 35
|
||||
select 'S', db, name, sha1(query), node_id, epoch, id, version, type
|
||||
from t1 order by db, name;
|
||||
S db name sha1(query) node_id epoch id version type
|
||||
S t t11111111111 8fc937d303ee7e4795c0b964d4066cedd6d74cfd 11 12 13 14 15
|
||||
S t t111111111111 a5229e9f8977bc99afc3b3627c56f083e97e01bd 21 22 23 24 25
|
||||
S t t1111111111111 0820e6ad3eeb06ea60e5e04d0bfe36f286b91098 31 32 33 34 35
|
||||
S test t1 8fc937d303ee7e4795c0b964d4066cedd6d74cfd 11 12 13 14 15
|
||||
S test t2 a5229e9f8977bc99afc3b3627c56f083e97e01bd 21 22 23 24 25
|
||||
S test t3 0820e6ad3eeb06ea60e5e04d0bfe36f286b91098 31 32 33 34 35
|
||||
S testtttttttttt t1 8fc937d303ee7e4795c0b964d4066cedd6d74cfd 11 12 13 14 15
|
||||
S testttttttttttt t1 a5229e9f8977bc99afc3b3627c56f083e97e01bd 21 22 23 24 25
|
||||
S testtttttttttttt t1 0820e6ad3eeb06ea60e5e04d0bfe36f286b91098 31 32 33 34 35
|
||||
drop table t1;
|
||||
|
||||
421
mysql-test/r/rpl_ndb_dd_advance.result
Normal file
421
mysql-test/r/rpl_ndb_dd_advance.result
Normal file
@@ -0,0 +1,421 @@
|
||||
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 TABLE IF EXISTS t1, t2, t3;
|
||||
***** Test 1 RPL of CDD and Alter *****
|
||||
***** Test 1 setup *****
|
||||
CREATE LOGFILE GROUP lg1
|
||||
ADD UNDOFILE 'undofile.dat'
|
||||
INITIAL_SIZE 16M
|
||||
UNDO_BUFFER_SIZE = 1M
|
||||
ENGINE=NDB;
|
||||
ALTER LOGFILE GROUP lg1
|
||||
ADD UNDOFILE 'undofile02.dat'
|
||||
INITIAL_SIZE 4M
|
||||
ENGINE=NDB;
|
||||
CREATE TABLESPACE ts1
|
||||
ADD DATAFILE 'datafile.dat'
|
||||
USE LOGFILE GROUP lg1
|
||||
INITIAL_SIZE 12M
|
||||
ENGINE=NDB;
|
||||
ALTER TABLESPACE ts1
|
||||
ADD DATAFILE 'datafile02.dat'
|
||||
INITIAL_SIZE 4M
|
||||
ENGINE=NDB;
|
||||
CREATE TABLE t1
|
||||
(c1 INT NOT NULL PRIMARY KEY,
|
||||
c2 INT NOT NULL,
|
||||
c3 INT NOT NULL)
|
||||
TABLESPACE ts1 STORAGE DISK
|
||||
ENGINE=NDB;
|
||||
***** insert some data *****
|
||||
***** Select from Master *****
|
||||
SELECT * FROM t1 ORDER BY c1 LIMIT 5;
|
||||
c1 c2 c3
|
||||
1 2 4
|
||||
2 4 5
|
||||
3 6 6
|
||||
4 8 7
|
||||
5 10 8
|
||||
***** Select from Slave *****
|
||||
SELECT * FROM t1 ORDER BY c1 LIMIT 5;
|
||||
c1 c2 c3
|
||||
1 2 4
|
||||
2 4 5
|
||||
3 6 6
|
||||
4 8 7
|
||||
5 10 8
|
||||
FILE_NAME FILE_TYPE TABLESPACE_NAME LOGFILE_GROUP_NAME
|
||||
datafile.dat DATAFILE ts1 lg1
|
||||
datafile02.dat DATAFILE ts1 lg1
|
||||
undofile.dat UNDO LOG ts1 lg1
|
||||
undofile02.dat UNDO LOG ts1 lg1
|
||||
**** Do First Set of ALTERs in the master table ****
|
||||
CREATE INDEX t1_i ON t1(c2, c3);
|
||||
ALTER TABLE t1 ADD c4 TIMESTAMP;
|
||||
ALTER TABLE t1 ADD c5 DOUBLE;
|
||||
ALTER TABLE t1 ADD INDEX (c5);
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`c1` int(11) NOT NULL,
|
||||
`c2` int(11) NOT NULL,
|
||||
`c3` int(11) NOT NULL,
|
||||
`c4` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
`c5` double DEFAULT NULL,
|
||||
PRIMARY KEY (`c1`),
|
||||
KEY `t1_i` (`c2`,`c3`),
|
||||
KEY `c5` (`c5`)
|
||||
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY ()
|
||||
**** Show first set of ALTERs on SLAVE ****
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`c1` int(11) NOT NULL,
|
||||
`c2` int(11) NOT NULL,
|
||||
`c3` int(11) NOT NULL,
|
||||
`c4` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
`c5` double DEFAULT NULL,
|
||||
PRIMARY KEY (`c1`),
|
||||
KEY `t1_i` (`c2`,`c3`),
|
||||
KEY `c5` (`c5`)
|
||||
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY ()
|
||||
**** Second set of alters test 1 ****
|
||||
ALTER TABLE t1 RENAME t2;
|
||||
ALTER TABLE t2 DROP INDEX c5;
|
||||
CREATE TABLE t1(c1 INT)ENGINE=NDB;
|
||||
INSERT INTO t1 VALUES(1);
|
||||
DROP TABLE t1;
|
||||
ALTER TABLE t2 RENAME t1;
|
||||
**** Show second set of ALTERs on MASTER ****
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`c1` int(11) NOT NULL,
|
||||
`c2` int(11) NOT NULL,
|
||||
`c3` int(11) NOT NULL,
|
||||
`c4` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
`c5` double DEFAULT NULL,
|
||||
PRIMARY KEY (`c1`),
|
||||
KEY `t1_i` (`c2`,`c3`)
|
||||
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY ()
|
||||
**** Show second set of ALTERs on SLAVE ****
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`c1` int(11) NOT NULL,
|
||||
`c2` int(11) NOT NULL,
|
||||
`c3` int(11) NOT NULL,
|
||||
`c4` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
`c5` double DEFAULT NULL,
|
||||
PRIMARY KEY (`c1`),
|
||||
KEY `t1_i` (`c2`,`c3`)
|
||||
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY ()
|
||||
**** Third and last set of alters for test1 ****
|
||||
ALTER TABLE t1 CHANGE c1 c1 DOUBLE;
|
||||
ALTER TABLE t1 CHANGE c2 c2 DECIMAL(10,2);
|
||||
ALTER TABLE t1 DROP COLUMN c3;
|
||||
ALTER TABLE t1 CHANGE c4 c4 TEXT CHARACTER SET utf8;
|
||||
ALTER TABLE t1 CHANGE c4 c4 BLOB;
|
||||
ALTER TABLE t1 CHANGE c4 c3 BLOB;
|
||||
set @b1 = 'b1';
|
||||
set @b1 = concat(@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1);
|
||||
UPDATE t1 SET c3=@b1 where c1 = 1;
|
||||
UPDATE t1 SET c3=@b1 where c1 = 2;
|
||||
**** Show last set of ALTERs on MASTER ****
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`c1` double NOT NULL DEFAULT '0',
|
||||
`c2` decimal(10,2) DEFAULT NULL,
|
||||
`c3` blob,
|
||||
`c5` double DEFAULT NULL,
|
||||
PRIMARY KEY (`c1`),
|
||||
KEY `t1_i` (`c2`)
|
||||
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY ()
|
||||
SELECT * FROM t1 ORDER BY c1 LIMIT 5;
|
||||
c1 c2 c3 c5
|
||||
1 2.00 b1b1b1b1b1b1b1b1b1b1 NULL
|
||||
2 4.00 b1b1b1b1b1b1b1b1b1b1 NULL
|
||||
3 6.00 0000-00-00 00:00:00 NULL
|
||||
4 8.00 0000-00-00 00:00:00 NULL
|
||||
5 10.00 0000-00-00 00:00:00 NULL
|
||||
**** Show last set of ALTERs on SLAVE ****
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`c1` double NOT NULL DEFAULT '0',
|
||||
`c2` decimal(10,2) DEFAULT NULL,
|
||||
`c3` blob,
|
||||
`c5` double DEFAULT NULL,
|
||||
PRIMARY KEY (`c1`),
|
||||
KEY `t1_i` (`c2`)
|
||||
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY ()
|
||||
SELECT * FROM t1 where c1 = 1;
|
||||
c1 c2 c3 c5
|
||||
1 2.00 b1b1b1b1b1b1b1b1b1b1 NULL
|
||||
DROP TABLE t1;
|
||||
STOP SLAVE;
|
||||
RESET SLAVE;
|
||||
RESET MASTER;
|
||||
START SLAVE;
|
||||
******** Create additional TABLESPACE test 2 **************
|
||||
CREATE TABLESPACE ts2
|
||||
ADD DATAFILE 'datafile03.dat'
|
||||
USE LOGFILE GROUP lg1
|
||||
INITIAL_SIZE 12M
|
||||
ENGINE=NDB;
|
||||
ALTER TABLESPACE ts2
|
||||
ADD DATAFILE 'datafile04.dat'
|
||||
INITIAL_SIZE 12M
|
||||
ENGINE=NDB;
|
||||
DROP DATABASE IF EXISTS tpcb;
|
||||
Warnings:
|
||||
Note 1008 Can't drop database 'tpcb'; database doesn't exist
|
||||
CREATE DATABASE tpcb;
|
||||
DROP DATABASE IF EXISTS test;
|
||||
CREATE DATABASE test;
|
||||
*********** Create TPCB Tables *****************
|
||||
CREATE TABLE tpcb.account
|
||||
(id INT, bid INT, balance DECIMAL(10,2),
|
||||
filler CHAR(255), PRIMARY KEY(id))
|
||||
TABLESPACE ts1 STORAGE DISK
|
||||
ENGINE=NDB;
|
||||
CREATE TABLE tpcb.branch
|
||||
(bid INT, balance DECIMAL(10,2), filler VARCHAR(255),
|
||||
PRIMARY KEY(bid))
|
||||
ENGINE=NDB;
|
||||
CREATE TABLE tpcb.teller
|
||||
(tid INT, balance DECIMAL(10,2), filler VARCHAR(255),
|
||||
PRIMARY KEY(tid))
|
||||
TABLESPACE ts2 STORAGE DISK
|
||||
ENGINE=NDB;
|
||||
CREATE TABLE tpcb.history
|
||||
(id MEDIUMINT NOT NULL AUTO_INCREMENT,aid INT,
|
||||
tid INT, bid INT, amount DECIMAL(10,2),
|
||||
tdate DATETIME, teller CHAR(20), uuidf LONGBLOB,
|
||||
filler CHAR(80),PRIMARY KEY (id))
|
||||
TABLESPACE ts2 STORAGE DISK
|
||||
ENGINE=NDB;
|
||||
********* Create Procedures and Functions ************
|
||||
CREATE PROCEDURE tpcb.load()
|
||||
BEGIN
|
||||
DECLARE acct INT DEFAULT 1000;
|
||||
DECLARE brch INT DEFAULT 100;
|
||||
DECLARE tell INT DEFAULT 1000;
|
||||
DECLARE tmp INT DEFAULT 100;
|
||||
WHILE brch > 0 DO
|
||||
SET tmp = 100;
|
||||
WHILE tmp > 0 DO
|
||||
INSERT INTO tpcb.account VALUES (acct, brch, 0.0, "FRESH ACCOUNT");
|
||||
SET acct = acct - 1;
|
||||
SET tmp = tmp -1;
|
||||
END WHILE;
|
||||
INSERT INTO tpcb.branch VALUES (brch, 0.0, "FRESH BRANCH");
|
||||
SET brch = brch - 1;
|
||||
END WHILE;
|
||||
WHILE tell > 0 DO
|
||||
INSERT INTO tpcb.teller VALUES (tell, 0.0, "FRESH TELLER");
|
||||
SET tell = tell - 1;
|
||||
END WHILE;
|
||||
END|
|
||||
CREATE FUNCTION tpcb.account_id () RETURNS INT
|
||||
BEGIN
|
||||
DECLARE num INT;
|
||||
DECLARE ran INT;
|
||||
SELECT RAND() * 10 INTO ran;
|
||||
IF (ran < 2)
|
||||
THEN
|
||||
SELECT RAND() * 10 INTO num;
|
||||
ELSEIF (ran < 4)
|
||||
THEN
|
||||
SELECT RAND() * 100 INTO num;
|
||||
ELSE
|
||||
SELECT RAND() * 1000 INTO num;
|
||||
END IF;
|
||||
IF (num < 1)
|
||||
THEN
|
||||
RETURN 1;
|
||||
END IF;
|
||||
RETURN num;
|
||||
END|
|
||||
CREATE FUNCTION tpcb.teller_id () RETURNS INT
|
||||
BEGIN
|
||||
DECLARE num INT;
|
||||
DECLARE ran INT;
|
||||
SELECT RAND() * 10 INTO ran;
|
||||
IF (ran < 2)
|
||||
THEN
|
||||
SELECT RAND() * 10 INTO num;
|
||||
ELSEIF (ran < 5)
|
||||
THEN
|
||||
SELECT RAND() * 100 INTO num;
|
||||
ELSE
|
||||
SELECT RAND() * 1000 INTO num;
|
||||
END IF;
|
||||
IF (num < 1)
|
||||
THEN
|
||||
RETURN 1;
|
||||
END IF;
|
||||
RETURN num;
|
||||
END|
|
||||
CREATE PROCEDURE tpcb.trans()
|
||||
BEGIN
|
||||
DECLARE acct INT DEFAULT 0;
|
||||
DECLARE brch INT DEFAULT 0;
|
||||
DECLARE tell INT DEFAULT 0;
|
||||
DECLARE bal DECIMAL(10,2) DEFAULT 0.0;
|
||||
DECLARE amount DECIMAL(10,2) DEFAULT 1.00;
|
||||
DECLARE test INT DEFAULT 0;
|
||||
DECLARE bbal DECIMAL(10,2) DEFAULT 0.0;
|
||||
DECLARE tbal DECIMAL(10,2) DEFAULT 0.0;
|
||||
DECLARE local_uuid VARCHAR(255);
|
||||
DECLARE local_user VARCHAR(255);
|
||||
DECLARE local_time TIMESTAMP;
|
||||
SELECT RAND() * 10 INTO test;
|
||||
SELECT tpcb.account_id() INTO acct;
|
||||
SELECT tpcb.teller_id() INTO tell;
|
||||
SELECT account.balance INTO bal FROM tpcb.account WHERE id = acct;
|
||||
SELECT account.bid INTO brch FROM tpcb.account WHERE id = acct;
|
||||
SELECT teller.balance INTO tbal FROM tpcb.teller WHERE tid = tell;
|
||||
SELECT branch.balance INTO bbal FROM tpcb.branch WHERE bid = brch;
|
||||
IF (test < 5)
|
||||
THEN
|
||||
SET bal = bal + amount;
|
||||
SET bbal = bbal + amount;
|
||||
SET tbal = tbal + amount;
|
||||
UPDATE tpcb.account SET balance = bal, filler = 'account updated'
|
||||
WHERE id = acct;
|
||||
UPDATE tpcb.branch SET balance = bbal, filler = 'branch updated'
|
||||
WHERE bid = brch;
|
||||
UPDATE tpcb.teller SET balance = tbal, filler = 'teller updated'
|
||||
WHERE tid = tell;
|
||||
ELSE
|
||||
SET bal = bal - amount;
|
||||
SET bbal = bbal - amount;
|
||||
SET tbal = tbal - amount;
|
||||
UPDATE tpcb.account SET balance = bal, filler = 'account updated'
|
||||
WHERE id = acct;
|
||||
UPDATE tpcb.branch SET balance = bbal, filler = 'branch updated'
|
||||
WHERE bid = brch;
|
||||
UPDATE tpcb.teller SET balance = tbal, filler = 'teller updated'
|
||||
WHERE tid = tell;
|
||||
END IF;
|
||||
SET local_uuid=UUID();
|
||||
SET local_user=USER();
|
||||
SET local_time= NOW();
|
||||
INSERT INTO tpcb.history VALUES(NULL,acct,tell,brch,amount, local_time,local_user,
|
||||
local_uuid,'completed trans');
|
||||
END|
|
||||
****** TEST 2 test time *********************************
|
||||
USE tpcb;
|
||||
*********** Load up the database ******************
|
||||
CALL tpcb.load();
|
||||
********** Check load master and slave **************
|
||||
SELECT COUNT(*) FROM account;
|
||||
COUNT(*)
|
||||
10000
|
||||
USE tpcb;
|
||||
SELECT COUNT(*) FROM account;
|
||||
COUNT(*)
|
||||
10000
|
||||
******** Run in some transactions ***************
|
||||
***** Time to try slave sync ***********
|
||||
**** Must make sure slave is clean *****
|
||||
STOP SLAVE;
|
||||
RESET SLAVE;
|
||||
DROP PROCEDURE tpcb.load;
|
||||
DROP PROCEDURE tpcb.trans;
|
||||
DROP TABLE tpcb.account;
|
||||
DROP TABLE tpcb.teller;
|
||||
DROP TABLE tpcb.branch;
|
||||
DROP TABLE tpcb.history;
|
||||
DROP DATABASE tpcb;
|
||||
ALTER TABLESPACE ts1
|
||||
DROP DATAFILE 'datafile.dat'
|
||||
ENGINE=NDB;
|
||||
ALTER TABLESPACE ts1
|
||||
DROP DATAFILE 'datafile02.dat'
|
||||
ENGINE=NDB;
|
||||
DROP TABLESPACE ts1 ENGINE=NDB;
|
||||
ALTER TABLESPACE ts2
|
||||
DROP DATAFILE 'datafile03.dat'
|
||||
ENGINE=NDB;
|
||||
ALTER TABLESPACE ts2
|
||||
DROP DATAFILE 'datafile04.dat'
|
||||
ENGINE=NDB;
|
||||
DROP TABLESPACE ts2 ENGINE=NDB;
|
||||
DROP LOGFILE GROUP lg1 ENGINE=NDB;
|
||||
********** Take a backup of the Master *************
|
||||
SELECT COUNT(*) FROM history;
|
||||
COUNT(*)
|
||||
1000
|
||||
SELECT COUNT(*) FROM history;
|
||||
COUNT(*)
|
||||
2000
|
||||
CREATE TEMPORARY TABLE IF NOT EXISTS cluster.backup_info (id INT, backup_id INT) ENGINE = HEAP;
|
||||
DELETE FROM cluster.backup_info;
|
||||
LOAD DATA INFILE '../tmp.dat' INTO TABLE cluster.backup_info FIELDS TERMINATED BY ',';
|
||||
SELECT @the_backup_id:=backup_id FROM cluster.backup_info;
|
||||
@the_backup_id:=backup_id
|
||||
<the_backup_id>
|
||||
DROP TABLE IF EXISTS cluster.backup_info;
|
||||
************ Restore the slave ************************
|
||||
CREATE DATABASE tpcb;
|
||||
***** Check a few slave restore values ***************
|
||||
USE tpcb;
|
||||
SELECT COUNT(*) FROM account;
|
||||
COUNT(*)
|
||||
10000
|
||||
***** Add some more records to master *********
|
||||
***** Finsh the slave sync process *******
|
||||
* 1. *
|
||||
@the_epoch:=MAX(epoch)
|
||||
<the_epoch>
|
||||
* 2. *
|
||||
@the_pos:=Position @the_file:=SUBSTRING_INDEX(FILE, '/', -1)
|
||||
<the_pos> master-bin.000001
|
||||
* 3. *
|
||||
* 4. *
|
||||
* 5. *
|
||||
START SLAVE;
|
||||
**** We should be ready to continue on *************
|
||||
****** Let's make sure we match *******
|
||||
***** MASTER *******
|
||||
USE tpcb;
|
||||
SELECT COUNT(*) FROM history;
|
||||
COUNT(*)
|
||||
4050
|
||||
****** SLAVE ********
|
||||
USE tpcb;
|
||||
SELECT COUNT(*) FROM history;
|
||||
COUNT(*)
|
||||
4050
|
||||
*** DUMP MASTER & SLAVE FOR COMPARE ********
|
||||
*************** TEST 2 CLEANUP SECTION ********************
|
||||
DROP PROCEDURE tpcb.load;
|
||||
DROP PROCEDURE tpcb.trans;
|
||||
DROP TABLE tpcb.account;
|
||||
DROP TABLE tpcb.teller;
|
||||
DROP TABLE tpcb.branch;
|
||||
DROP TABLE tpcb.history;
|
||||
DROP DATABASE tpcb;
|
||||
ALTER TABLESPACE ts1
|
||||
DROP DATAFILE 'datafile.dat'
|
||||
ENGINE=NDB;
|
||||
ALTER TABLESPACE ts1
|
||||
DROP DATAFILE 'datafile02.dat'
|
||||
ENGINE=NDB;
|
||||
DROP TABLESPACE ts1 ENGINE=NDB;
|
||||
ALTER TABLESPACE ts2
|
||||
DROP DATAFILE 'datafile03.dat'
|
||||
ENGINE=NDB;
|
||||
ALTER TABLESPACE ts2
|
||||
DROP DATAFILE 'datafile04.dat'
|
||||
ENGINE=NDB;
|
||||
DROP TABLESPACE ts2 ENGINE=NDB;
|
||||
DROP LOGFILE GROUP lg1 ENGINE=NDB;
|
||||
****** Do dumps compare ************
|
||||
@@ -31,7 +31,7 @@ declare b int;
|
||||
set b = 8;
|
||||
insert into t1 values (b);
|
||||
insert into t1 values (unix_timestamp());
|
||||
end @ # #
|
||||
end root@localhost # #
|
||||
set timestamp=1000000000;
|
||||
call foo();
|
||||
select * from t1;
|
||||
@@ -118,7 +118,7 @@ select * from mysql.proc where name="foo4" and db='mysqltest1';
|
||||
db name type specific_name language sql_data_access is_deterministic security_type param_list returns body definer created modified sql_mode comment
|
||||
mysqltest1 foo4 PROCEDURE foo4 SQL CONTAINS_SQL YES DEFINER begin
|
||||
insert into t2 values(20),(20);
|
||||
end @ # #
|
||||
end root@localhost # #
|
||||
drop procedure foo4;
|
||||
select * from mysql.proc where name="foo4" and db='mysqltest1';
|
||||
db name type specific_name language sql_data_access is_deterministic security_type param_list returns body definer created modified sql_mode comment
|
||||
@@ -223,13 +223,13 @@ select * from mysql.proc where db='mysqltest1';
|
||||
db name type specific_name language sql_data_access is_deterministic security_type param_list returns body definer created modified sql_mode comment
|
||||
mysqltest1 fn1 FUNCTION fn1 SQL NO_SQL NO DEFINER int(11) begin
|
||||
return unix_timestamp();
|
||||
end @ # #
|
||||
end root@localhost # #
|
||||
mysqltest1 fn2 FUNCTION fn2 SQL NO_SQL NO DEFINER int(11) begin
|
||||
return unix_timestamp();
|
||||
end @ # #
|
||||
end zedjzlcsjhd@localhost # #
|
||||
mysqltest1 fn3 FUNCTION fn3 SQL READS_SQL_DATA NO DEFINER int(11) begin
|
||||
return 0;
|
||||
end @ # #
|
||||
end root@localhost # #
|
||||
delete from t2;
|
||||
alter table t2 add unique (a);
|
||||
drop function fn1;
|
||||
@@ -274,7 +274,7 @@ Log_name Pos Event_type Server_id End_log_pos Info
|
||||
master-bin.000001 # Query 1 # drop database if exists mysqltest1
|
||||
master-bin.000001 # Query 1 # create database mysqltest1
|
||||
master-bin.000001 # Query 1 # use `mysqltest1`; create table t1 (a varchar(100))
|
||||
master-bin.000001 # Query 1 # use `mysqltest1`; create procedure foo()
|
||||
master-bin.000001 # Query 1 # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` procedure foo()
|
||||
begin
|
||||
declare b int;
|
||||
set b = 8;
|
||||
@@ -284,19 +284,19 @@ end
|
||||
master-bin.000001 # Query 1 # use `mysqltest1`; insert into t1 values ( NAME_CONST('b',8))
|
||||
master-bin.000001 # Query 1 # use `mysqltest1`; insert into t1 values (unix_timestamp())
|
||||
master-bin.000001 # Query 1 # use `mysqltest1`; delete from t1
|
||||
master-bin.000001 # Query 1 # use `mysqltest1`; create procedure foo2()
|
||||
master-bin.000001 # Query 1 # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` procedure foo2()
|
||||
select * from mysqltest1.t1
|
||||
master-bin.000001 # Query 1 # use `mysqltest1`; alter procedure foo2 contains sql
|
||||
master-bin.000001 # Query 1 # use `mysqltest1`; drop table t1
|
||||
master-bin.000001 # Query 1 # use `mysqltest1`; create table t1 (a int)
|
||||
master-bin.000001 # Query 1 # use `mysqltest1`; create table t2 like t1
|
||||
master-bin.000001 # Query 1 # use `mysqltest1`; create procedure foo3()
|
||||
master-bin.000001 # Query 1 # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` procedure foo3()
|
||||
deterministic
|
||||
insert into t1 values (15)
|
||||
master-bin.000001 # Query 1 # use `mysqltest1`; grant CREATE ROUTINE, EXECUTE on mysqltest1.* to "zedjzlcsjhd"@127.0.0.1
|
||||
master-bin.000001 # Query 1 # use `mysqltest1`; grant SELECT on mysqltest1.t1 to "zedjzlcsjhd"@127.0.0.1
|
||||
master-bin.000001 # Query 1 # use `mysqltest1`; grant SELECT, INSERT on mysqltest1.t2 to "zedjzlcsjhd"@127.0.0.1
|
||||
master-bin.000001 # Query 1 # use `mysqltest1`; create procedure foo4()
|
||||
master-bin.000001 # Query 1 # use `mysqltest1`; CREATE DEFINER=`zedjzlcsjhd`@`127.0.0.1` procedure foo4()
|
||||
deterministic
|
||||
begin
|
||||
insert into t2 values(3);
|
||||
@@ -311,7 +311,7 @@ master-bin.000001 # Query 1 # use `mysqltest1`; insert into t1 values (5)
|
||||
master-bin.000001 # Query 1 # use `mysqltest1`; delete from t2
|
||||
master-bin.000001 # Query 1 # use `mysqltest1`; alter table t2 add unique (a)
|
||||
master-bin.000001 # Query 1 # use `mysqltest1`; drop procedure foo4
|
||||
master-bin.000001 # Query 1 # use `mysqltest1`; create procedure foo4()
|
||||
master-bin.000001 # Query 1 # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` procedure foo4()
|
||||
deterministic
|
||||
begin
|
||||
insert into t2 values(20),(20);
|
||||
@@ -321,7 +321,7 @@ master-bin.000001 # Query 1 # use `mysqltest1`; drop procedure foo4
|
||||
master-bin.000001 # Query 1 # use `mysqltest1`; drop procedure foo
|
||||
master-bin.000001 # Query 1 # use `mysqltest1`; drop procedure foo2
|
||||
master-bin.000001 # Query 1 # use `mysqltest1`; drop procedure foo3
|
||||
master-bin.000001 # Query 1 # use `mysqltest1`; create function fn1(x int)
|
||||
master-bin.000001 # Query 1 # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` function fn1(x int)
|
||||
returns int
|
||||
deterministic
|
||||
begin
|
||||
@@ -332,7 +332,7 @@ master-bin.000001 # Query 1 # use `mysqltest1`; delete t1,t2 from t1,t2
|
||||
master-bin.000001 # Query 1 # use `mysqltest1`; SELECT `fn1`(20)
|
||||
master-bin.000001 # Query 1 # use `mysqltest1`; insert into t2 values(fn1(21))
|
||||
master-bin.000001 # Query 1 # use `mysqltest1`; drop function fn1
|
||||
master-bin.000001 # Query 1 # use `mysqltest1`; create function fn1()
|
||||
master-bin.000001 # Query 1 # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` function fn1()
|
||||
returns int
|
||||
no sql
|
||||
begin
|
||||
@@ -340,13 +340,13 @@ return unix_timestamp();
|
||||
end
|
||||
master-bin.000001 # Query 1 # use `mysqltest1`; delete from t1
|
||||
master-bin.000001 # Query 1 # use `mysqltest1`; insert into t1 values(fn1())
|
||||
master-bin.000001 # Query 1 # use `mysqltest1`; create function fn2()
|
||||
master-bin.000001 # Query 1 # use `mysqltest1`; CREATE DEFINER=`zedjzlcsjhd`@`127.0.0.1` function fn2()
|
||||
returns int
|
||||
no sql
|
||||
begin
|
||||
return unix_timestamp();
|
||||
end
|
||||
master-bin.000001 # Query 1 # use `mysqltest1`; create function fn3()
|
||||
master-bin.000001 # Query 1 # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` function fn3()
|
||||
returns int
|
||||
not deterministic
|
||||
reads sql data
|
||||
@@ -356,7 +356,7 @@ end
|
||||
master-bin.000001 # Query 1 # use `mysqltest1`; delete from t2
|
||||
master-bin.000001 # Query 1 # use `mysqltest1`; alter table t2 add unique (a)
|
||||
master-bin.000001 # Query 1 # use `mysqltest1`; drop function fn1
|
||||
master-bin.000001 # Query 1 # use `mysqltest1`; create function fn1(x int)
|
||||
master-bin.000001 # Query 1 # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` function fn1(x int)
|
||||
returns int
|
||||
begin
|
||||
insert into t2 values(x),(x);
|
||||
|
||||
@@ -105,7 +105,7 @@ t1_first root@localhost
|
||||
SELECT routine_name, definer
|
||||
FROM information_schema.routines;
|
||||
routine_name definer
|
||||
bug12480 @
|
||||
bug12480 root@localhost
|
||||
SELECT trigger_name, definer
|
||||
FROM information_schema.triggers;
|
||||
trigger_name definer
|
||||
@@ -858,3 +858,44 @@ f3
|
||||
drop trigger trg11;
|
||||
drop table t21,t31;
|
||||
drop table t11;
|
||||
STOP SLAVE;
|
||||
FLUSH LOGS;
|
||||
RESET SLAVE;
|
||||
START SLAVE;
|
||||
SELECT MASTER_POS_WAIT('master-bin.000001', 513) >= 0;
|
||||
MASTER_POS_WAIT('master-bin.000001', 513) >= 0
|
||||
1
|
||||
SHOW TABLES LIKE 't_';
|
||||
Tables_in_test (t_)
|
||||
t1
|
||||
t2
|
||||
SHOW TRIGGERS;
|
||||
Trigger Event Table Statement Timing Created sql_mode Definer
|
||||
trg1 INSERT t1 INSERT INTO t2 VALUES(CURRENT_USER()) AFTER NULL
|
||||
SELECT * FROM t1;
|
||||
c
|
||||
1
|
||||
SELECT * FROM t2;
|
||||
s
|
||||
@
|
||||
INSERT INTO t1 VALUES(2);
|
||||
SELECT * FROM t1;
|
||||
c
|
||||
1
|
||||
2
|
||||
SELECT * FROM t2;
|
||||
s
|
||||
@
|
||||
root@localhost
|
||||
DROP TRIGGER trg1;
|
||||
Warnings:
|
||||
Warning 1454 No definer attribute for trigger 'test'.'trg1'. The trigger will be activated under the authorization of the invoker, which may have insufficient privileges. Please recreate the trigger.
|
||||
DROP TABLE t1;
|
||||
DROP TABLE t2;
|
||||
STOP SLAVE;
|
||||
RESET SLAVE;
|
||||
SHOW TABLES LIKE 't_';
|
||||
Tables_in_test (t_)
|
||||
SHOW TRIGGERS;
|
||||
Trigger Event Table Statement Timing Created sql_mode Definer
|
||||
RESET MASTER;
|
||||
|
||||
@@ -2,10 +2,6 @@ drop table if exists t1,v1;
|
||||
drop view if exists t1,v1;
|
||||
drop procedure if exists f1;
|
||||
use test;
|
||||
create table t1 (field1 INT);
|
||||
CREATE VIEW v1 AS SELECT field1 FROM t1;
|
||||
ERROR HY000: Definer is not fully qualified
|
||||
drop table t1;
|
||||
create procedure f1() select 1;
|
||||
drop procedure f1;
|
||||
create table t1 (a int);
|
||||
@@ -15,3 +11,20 @@ drop table t1;
|
||||
drop function if exists f1;
|
||||
Warnings:
|
||||
Note 1305 FUNCTION f1 does not exist
|
||||
DROP VIEW IF EXISTS v1;
|
||||
DROP VIEW IF EXISTS v2;
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1(c INT);
|
||||
CREATE TRIGGER t1_bi BEFORE INSERT ON t1
|
||||
FOR EACH ROW
|
||||
SET @a = 1;
|
||||
CREATE VIEW v1 AS SELECT * FROM t1;
|
||||
CREATE DEFINER=a@b TRIGGER ti_ai AFTER INSERT ON t1
|
||||
FOR EACH ROW
|
||||
SET @b = 1;
|
||||
CREATE DEFINER=a@b VIEW v2 AS SELECT * FROM t1;
|
||||
DROP TRIGGER t1_bi;
|
||||
DROP TRIGGER ti_ai;
|
||||
DROP VIEW v1;
|
||||
DROP VIEW v2;
|
||||
DROP TABLE t1;
|
||||
|
||||
@@ -323,3 +323,99 @@ Warning 1540 The syntax 'SHOW INNODB STATUS' is deprecated and will be removed i
|
||||
GRANT EXECUTE ON PROCEDURE p1 TO user_bug7787@localhost;
|
||||
DROP DATABASE db_bug7787;
|
||||
use test;
|
||||
|
||||
---> connection: root
|
||||
DROP DATABASE IF EXISTS mysqltest;
|
||||
CREATE DATABASE mysqltest;
|
||||
CREATE USER mysqltest_1@localhost;
|
||||
GRANT ALL PRIVILEGES ON mysqltest.* TO mysqltest_1@localhost;
|
||||
CREATE USER mysqltest_2@localhost;
|
||||
GRANT SUPER ON *.* TO mysqltest_2@localhost;
|
||||
GRANT ALL PRIVILEGES ON mysqltest.* TO mysqltest_2@localhost;
|
||||
|
||||
---> connection: mysqltest_2_con
|
||||
use mysqltest;
|
||||
CREATE PROCEDURE wl2897_p1() SELECT 1;
|
||||
CREATE FUNCTION wl2897_f1() RETURNS INT RETURN 1;
|
||||
|
||||
---> connection: mysqltest_1_con
|
||||
use mysqltest;
|
||||
CREATE DEFINER=root@localhost PROCEDURE wl2897_p2() SELECT 2;
|
||||
ERROR 42000: Access denied; you need the SUPER privilege for this operation
|
||||
CREATE DEFINER=root@localhost FUNCTION wl2897_f2() RETURNS INT RETURN 2;
|
||||
ERROR 42000: Access denied; you need the SUPER privilege for this operation
|
||||
|
||||
---> connection: mysqltest_2_con
|
||||
use mysqltest;
|
||||
CREATE DEFINER='a @ b @ c'@localhost PROCEDURE wl2897_p3() SELECT 3;
|
||||
Warnings:
|
||||
Note 1449 There is no 'a @ b @ c'@'localhost' registered
|
||||
CREATE DEFINER='a @ b @ c'@localhost FUNCTION wl2897_f3() RETURNS INT RETURN 3;
|
||||
Warnings:
|
||||
Note 1449 There is no 'a @ b @ c'@'localhost' registered
|
||||
|
||||
---> connection: con1root
|
||||
use mysqltest;
|
||||
SHOW CREATE PROCEDURE wl2897_p1;
|
||||
Procedure sql_mode Create Procedure
|
||||
wl2897_p1 CREATE DEFINER=`mysqltest_2`@`localhost` PROCEDURE `wl2897_p1`()
|
||||
SELECT 1
|
||||
SHOW CREATE PROCEDURE wl2897_p3;
|
||||
Procedure sql_mode Create Procedure
|
||||
wl2897_p3 CREATE DEFINER=`a @ b @ c`@`localhost` PROCEDURE `wl2897_p3`()
|
||||
SELECT 3
|
||||
SHOW CREATE FUNCTION wl2897_f1;
|
||||
Function sql_mode Create Function
|
||||
wl2897_f1 CREATE DEFINER=`mysqltest_2`@`localhost` FUNCTION `wl2897_f1`() RETURNS int(11)
|
||||
RETURN 1
|
||||
SHOW CREATE FUNCTION wl2897_f3;
|
||||
Function sql_mode Create Function
|
||||
wl2897_f3 CREATE DEFINER=`a @ b @ c`@`localhost` FUNCTION `wl2897_f3`() RETURNS int(11)
|
||||
RETURN 3
|
||||
DROP USER mysqltest_1@localhost;
|
||||
DROP USER mysqltest_2@localhost;
|
||||
DROP DATABASE mysqltest;
|
||||
|
||||
---> connection: root
|
||||
DROP DATABASE IF EXISTS mysqltest;
|
||||
CREATE DATABASE mysqltest;
|
||||
CREATE USER mysqltest_1@localhost;
|
||||
GRANT ALL PRIVILEGES ON mysqltest.* TO mysqltest_1@localhost;
|
||||
CREATE USER mysqltest_2@localhost;
|
||||
GRANT ALL PRIVILEGES ON mysqltest.* TO mysqltest_2@localhost;
|
||||
|
||||
---> connection: mysqltest_1_con
|
||||
use mysqltest;
|
||||
CREATE PROCEDURE bug13198_p1()
|
||||
SELECT 1;
|
||||
CREATE FUNCTION bug13198_f1() RETURNS INT
|
||||
RETURN 1;
|
||||
CALL bug13198_p1();
|
||||
1
|
||||
1
|
||||
SELECT bug13198_f1();
|
||||
bug13198_f1()
|
||||
1
|
||||
|
||||
---> connection: mysqltest_2_con
|
||||
use mysqltest;
|
||||
CALL bug13198_p1();
|
||||
1
|
||||
1
|
||||
SELECT bug13198_f1();
|
||||
bug13198_f1()
|
||||
1
|
||||
|
||||
---> connection: root
|
||||
DROP USER mysqltest_1@localhost;
|
||||
|
||||
---> connection: mysqltest_2_con
|
||||
use mysqltest;
|
||||
CALL bug13198_p1();
|
||||
ERROR HY000: There is no 'mysqltest_1'@'localhost' registered
|
||||
SELECT bug13198_f1();
|
||||
ERROR HY000: There is no 'mysqltest_1'@'localhost' registered
|
||||
|
||||
---> connection: root
|
||||
DROP USER mysqltest_2@localhost;
|
||||
DROP DATABASE mysqltest;
|
||||
|
||||
@@ -788,7 +788,7 @@ comment 'Characteristics procedure test'
|
||||
insert into t1 values ("chistics", 1)|
|
||||
show create procedure chistics|
|
||||
Procedure sql_mode Create Procedure
|
||||
chistics CREATE PROCEDURE `chistics`()
|
||||
chistics CREATE DEFINER=`root`@`localhost` PROCEDURE `chistics`()
|
||||
MODIFIES SQL DATA
|
||||
COMMENT 'Characteristics procedure test'
|
||||
insert into t1 values ("chistics", 1)
|
||||
@@ -800,7 +800,7 @@ delete from t1|
|
||||
alter procedure chistics sql security invoker|
|
||||
show create procedure chistics|
|
||||
Procedure sql_mode Create Procedure
|
||||
chistics CREATE PROCEDURE `chistics`()
|
||||
chistics CREATE DEFINER=`root`@`localhost` PROCEDURE `chistics`()
|
||||
MODIFIES SQL DATA
|
||||
SQL SECURITY INVOKER
|
||||
COMMENT 'Characteristics procedure test'
|
||||
@@ -815,7 +815,7 @@ comment 'Characteristics procedure test'
|
||||
return 42|
|
||||
show create function chistics|
|
||||
Function sql_mode Create Function
|
||||
chistics CREATE FUNCTION `chistics`() RETURNS int(11)
|
||||
chistics CREATE DEFINER=`root`@`localhost` FUNCTION `chistics`() RETURNS int(11)
|
||||
DETERMINISTIC
|
||||
SQL SECURITY INVOKER
|
||||
COMMENT 'Characteristics procedure test'
|
||||
@@ -828,7 +828,7 @@ no sql
|
||||
comment 'Characteristics function test'|
|
||||
show create function chistics|
|
||||
Function sql_mode Create Function
|
||||
chistics CREATE FUNCTION `chistics`() RETURNS int(11)
|
||||
chistics CREATE DEFINER=`root`@`localhost` FUNCTION `chistics`() RETURNS int(11)
|
||||
NO SQL
|
||||
DETERMINISTIC
|
||||
SQL SECURITY INVOKER
|
||||
@@ -1287,7 +1287,7 @@ end while;
|
||||
end|
|
||||
show create procedure opp|
|
||||
Procedure sql_mode Create Procedure
|
||||
opp CREATE PROCEDURE `opp`(n bigint unsigned, out pp bool)
|
||||
opp CREATE DEFINER=`root`@`localhost` PROCEDURE `opp`(n bigint unsigned, out pp bool)
|
||||
begin
|
||||
declare r double;
|
||||
declare b, s bigint unsigned default 0;
|
||||
@@ -1386,7 +1386,7 @@ alter procedure bar comment "3333333333"|
|
||||
alter procedure bar|
|
||||
show create procedure bar|
|
||||
Procedure sql_mode Create Procedure
|
||||
bar CREATE PROCEDURE `bar`(x char(16), y int)
|
||||
bar CREATE DEFINER=`root`@`localhost` PROCEDURE `bar`(x char(16), y int)
|
||||
COMMENT '3333333333'
|
||||
insert into test.t1 values (x, y)
|
||||
show procedure status like 'bar'|
|
||||
@@ -1966,13 +1966,13 @@ Db Name Type Definer Modified Created Security_type Comment
|
||||
test bug2267_4 FUNCTION root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
|
||||
call bug2267_3()|
|
||||
Procedure sql_mode Create Procedure
|
||||
bug2267_1 CREATE PROCEDURE `bug2267_1`()
|
||||
bug2267_1 CREATE DEFINER=`root`@`localhost` PROCEDURE `bug2267_1`()
|
||||
begin
|
||||
show procedure status;
|
||||
end
|
||||
call bug2267_4()|
|
||||
Function sql_mode Create Function
|
||||
bug2267_4 CREATE FUNCTION `bug2267_4`() RETURNS int(11)
|
||||
bug2267_4 CREATE DEFINER=`root`@`localhost` FUNCTION `bug2267_4`() RETURNS int(11)
|
||||
return 100
|
||||
drop procedure bug2267_1|
|
||||
drop procedure bug2267_2|
|
||||
@@ -2304,20 +2304,20 @@ return x || y$
|
||||
set @@sql_mode = ''|
|
||||
show create procedure bug2564_1|
|
||||
Procedure sql_mode Create Procedure
|
||||
bug2564_1 CREATE PROCEDURE `bug2564_1`()
|
||||
bug2564_1 CREATE DEFINER=`root`@`localhost` PROCEDURE `bug2564_1`()
|
||||
COMMENT 'Joe''s procedure'
|
||||
insert into `t1` values ("foo", 1)
|
||||
show create procedure bug2564_2|
|
||||
Procedure sql_mode Create Procedure
|
||||
bug2564_2 ANSI_QUOTES CREATE PROCEDURE "bug2564_2"()
|
||||
bug2564_2 ANSI_QUOTES CREATE DEFINER="root"@"localhost" PROCEDURE "bug2564_2"()
|
||||
insert into "t1" values ('foo', 1)
|
||||
show create function bug2564_3|
|
||||
Function sql_mode Create Function
|
||||
bug2564_3 CREATE FUNCTION `bug2564_3`(x int, y int) RETURNS int(11)
|
||||
bug2564_3 CREATE DEFINER=`root`@`localhost` FUNCTION `bug2564_3`(x int, y int) RETURNS int(11)
|
||||
return x || y
|
||||
show create function bug2564_4|
|
||||
Function sql_mode Create Function
|
||||
bug2564_4 REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI CREATE FUNCTION "bug2564_4"(x int, y int) RETURNS int(11)
|
||||
bug2564_4 REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI CREATE DEFINER="root"@"localhost" FUNCTION "bug2564_4"(x int, y int) RETURNS int(11)
|
||||
return x || y
|
||||
drop procedure bug2564_1|
|
||||
drop procedure bug2564_2|
|
||||
@@ -3989,7 +3989,7 @@ return 42;
|
||||
end */;;
|
||||
show create function bug14723;;
|
||||
Function sql_mode Create Function
|
||||
bug14723 CREATE FUNCTION `bug14723`() RETURNS bigint(20)
|
||||
bug14723 CREATE DEFINER=`root`@`localhost` FUNCTION `bug14723`() RETURNS bigint(20)
|
||||
main_loop: begin
|
||||
return 42;
|
||||
end
|
||||
@@ -4002,7 +4002,7 @@ select 42;
|
||||
end */;;
|
||||
show create procedure bug14723;;
|
||||
Procedure sql_mode Create Procedure
|
||||
bug14723 CREATE PROCEDURE `bug14723`()
|
||||
bug14723 CREATE DEFINER=`root`@`localhost` PROCEDURE `bug14723`()
|
||||
main_loop: begin
|
||||
select 42;
|
||||
end
|
||||
|
||||
@@ -427,23 +427,23 @@ SET @@SQL_MODE='';
|
||||
create function `foo` () returns int return 5;
|
||||
show create function `foo`;
|
||||
Function sql_mode Create Function
|
||||
foo CREATE FUNCTION `foo`() RETURNS int(11)
|
||||
foo CREATE DEFINER=`root`@`localhost` FUNCTION `foo`() RETURNS int(11)
|
||||
return 5
|
||||
SET @@SQL_MODE='ANSI_QUOTES';
|
||||
show create function `foo`;
|
||||
Function sql_mode Create Function
|
||||
foo CREATE FUNCTION `foo`() RETURNS int(11)
|
||||
foo CREATE DEFINER=`root`@`localhost` FUNCTION `foo`() RETURNS int(11)
|
||||
return 5
|
||||
drop function `foo`;
|
||||
create function `foo` () returns int return 5;
|
||||
show create function `foo`;
|
||||
Function sql_mode Create Function
|
||||
foo ANSI_QUOTES CREATE FUNCTION "foo"() RETURNS int(11)
|
||||
foo ANSI_QUOTES CREATE DEFINER="root"@"localhost" FUNCTION "foo"() RETURNS int(11)
|
||||
return 5
|
||||
SET @@SQL_MODE='';
|
||||
show create function `foo`;
|
||||
Function sql_mode Create Function
|
||||
foo ANSI_QUOTES CREATE FUNCTION "foo"() RETURNS int(11)
|
||||
foo ANSI_QUOTES CREATE DEFINER="root"@"localhost" FUNCTION "foo"() RETURNS int(11)
|
||||
return 5
|
||||
drop function `foo`;
|
||||
SET @@SQL_MODE='';
|
||||
|
||||
@@ -135,6 +135,7 @@ SET @new_sum = 0;
|
||||
Warnings:
|
||||
Note 1449 There is no 'mysqltest_nonexs'@'localhost' registered
|
||||
INSERT INTO t1 VALUES(6);
|
||||
ERROR HY000: There is no 'mysqltest_nonexs'@'localhost' registered
|
||||
SHOW TRIGGERS;
|
||||
Trigger Event Table Statement Timing Created sql_mode Definer
|
||||
trg1 INSERT t1 SET @new_sum = 0 BEFORE NULL mysqltest_inv@localhost
|
||||
|
||||
@@ -522,11 +522,16 @@ use test;
|
||||
drop user mysqltest_1@localhost;
|
||||
drop database mysqltest;
|
||||
create definer=some_user@`` sql security invoker view v1 as select 1;
|
||||
ERROR HY000: Definer is not fully qualified
|
||||
create definer=some_user@localhost sql security invoker view v1 as select 1;
|
||||
Warnings:
|
||||
Note 1449 There is no 'some_user'@'' registered
|
||||
create definer=some_user@localhost sql security invoker view v2 as select 1;
|
||||
Warnings:
|
||||
Note 1449 There is no 'some_user'@'localhost' registered
|
||||
show create view v1;
|
||||
View Create View
|
||||
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`some_user`@`localhost` SQL SECURITY INVOKER VIEW `v1` AS select 1 AS `1`
|
||||
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`some_user`@`` SQL SECURITY INVOKER VIEW `v1` AS select 1 AS `1`
|
||||
show create view v2;
|
||||
View Create View
|
||||
v2 CREATE ALGORITHM=UNDEFINED DEFINER=`some_user`@`localhost` SQL SECURITY INVOKER VIEW `v2` AS select 1 AS `1`
|
||||
drop view v1;
|
||||
drop view v2;
|
||||
|
||||
BIN
mysql-test/std_data/bug16266.000001
Normal file
BIN
mysql-test/std_data/bug16266.000001
Normal file
Binary file not shown.
@@ -9,10 +9,10 @@
|
||||
# Do not use any TAB characters for whitespace.
|
||||
#
|
||||
##############################################################################
|
||||
#ndb_alter_table_row : sometimes wrong error 1015!=1046
|
||||
events_bugs : test case unstable (race conditions). andrey will fix
|
||||
events_stress : test case unstable. andrey will fix
|
||||
events : test case unstable. andrey will fix
|
||||
#ndb_alter_table_row : sometimes wrong error 1015!=1046
|
||||
ndb_autodiscover : Needs to be fixed w.r.t binlog
|
||||
ndb_autodiscover2 : Needs to be fixed w.r.t binlog
|
||||
ndb_binlog_basic : Results are not deterministic, Tomas will fix
|
||||
@@ -33,9 +33,9 @@ rpl_ndb_insert_ignore : Bugs: #17431: INSERT IGNORE INTO returns failed: 1296
|
||||
rpl_ndb_myisam2ndb : Bugs#17400: delete & update of rows in table without pk fails
|
||||
rpl_ndb_log : result not deterministic
|
||||
rpl_ndb_relay_space : Bug#16993
|
||||
rpl_ndb_multi_update2 : BUG#17738 In progress
|
||||
rpl_ndb_multi_update3 : Bug#17400: delete & update of rows in table without pk fails
|
||||
rpl_ndb_sp007 : Bug #17290
|
||||
rpl_sp : Bug#16456
|
||||
rpl_until : Unstable test case, bug#15886
|
||||
sp-goto : GOTO is currently is disabled - will be fixed in the future
|
||||
rpl_ndb_multi_update2 : BUG#17738 In progress
|
||||
|
||||
@@ -83,11 +83,60 @@ from t1 order by a;
|
||||
drop table t1;
|
||||
--sync_slave_with_master
|
||||
|
||||
#
|
||||
# view the binlog
|
||||
#
|
||||
# table with varsize key (future cluster/schema)
|
||||
|
||||
# sql/ha_ndbcluster_binlog.cc
|
||||
--connection master
|
||||
CREATE TABLE IF NOT EXISTS t1 (
|
||||
db VARBINARY(63) NOT NULL,
|
||||
name VARBINARY(63) NOT NULL,
|
||||
slock BINARY(32) NOT NULL,
|
||||
query BLOB NOT NULL,
|
||||
node_id INT UNSIGNED NOT NULL,
|
||||
epoch BIGINT UNSIGNED NOT NULL,
|
||||
id INT UNSIGNED NOT NULL,
|
||||
version INT UNSIGNED NOT NULL,
|
||||
type INT UNSIGNED NOT NULL,
|
||||
PRIMARY KEY USING HASH (db,name))
|
||||
ENGINE=NDB;
|
||||
|
||||
insert into t1 values ('test','t1',
|
||||
'abc',repeat(@s0,10), 11,12,13,14,15);
|
||||
insert into t1 values ('test','t2',
|
||||
'def',repeat(@s1,100), 21,22,23,24,25);
|
||||
insert into t1 values ('test','t3',
|
||||
'ghi',repeat(@s2,1000),31,32,33,34,35);
|
||||
insert into t1 values ('testtttttttttt','t1',
|
||||
'abc',repeat(@s0,10), 11,12,13,14,15);
|
||||
insert into t1 values ('testttttttttttt','t1',
|
||||
'def',repeat(@s1,100), 21,22,23,24,25);
|
||||
insert into t1 values ('testtttttttttttt','t1',
|
||||
'ghi',repeat(@s2,1000),31,32,33,34,35);
|
||||
insert into t1 values ('t','t11111111111',
|
||||
'abc',repeat(@s0,10), 11,12,13,14,15);
|
||||
insert into t1 values ('t','t111111111111',
|
||||
'def',repeat(@s1,100), 21,22,23,24,25);
|
||||
insert into t1 values ('t','t1111111111111',
|
||||
'ghi',repeat(@s2,1000),31,32,33,34,35);
|
||||
|
||||
select 'M', db, name, sha1(query), node_id, epoch, id, version, type
|
||||
from t1 order by db, name;
|
||||
|
||||
--sync_slave_with_master
|
||||
--sleep 5
|
||||
--connection slave
|
||||
select 'S', db, name, sha1(query), node_id, epoch, id, version, type
|
||||
from t1 order by db, name;
|
||||
|
||||
--connection master
|
||||
let $VERSION=`select version()`;
|
||||
--replace_result $VERSION VERSION
|
||||
show binlog events;
|
||||
drop table t1;
|
||||
--sync_slave_with_master
|
||||
|
||||
#
|
||||
# view the binlog - not deterministic (mats)
|
||||
#
|
||||
|
||||
#--connection master
|
||||
#let $VERSION=`select version()`;
|
||||
#--replace_result $VERSION VERSION
|
||||
#show binlog events;
|
||||
|
||||
600
mysql-test/t/rpl_ndb_dd_advance.test
Normal file
600
mysql-test/t/rpl_ndb_dd_advance.test
Normal file
@@ -0,0 +1,600 @@
|
||||
###############################################
|
||||
# Author: JBM #
|
||||
# Date: 2006-03-07 #
|
||||
# Purpose: To test advance DD and replication #
|
||||
###############################################
|
||||
|
||||
#### Include Section ####
|
||||
--source include/have_ndb.inc
|
||||
--source include/have_binlog_format_row.inc
|
||||
#--source include/have_ndb_extra.inc
|
||||
--source include/master-slave.inc
|
||||
|
||||
#### Test start cleanup section #####
|
||||
--disable_warnings
|
||||
DROP TABLE IF EXISTS t1, t2, t3;
|
||||
--enable_warnings
|
||||
|
||||
######################################################
|
||||
# Requirment: Cluster DD and replication must be able#
|
||||
# to handle ALTER tables and indexes and must rpl #
|
||||
# to the slave correctly #
|
||||
######################################################
|
||||
|
||||
## Test #1 replication of CDD and Alter Tables #####
|
||||
--echo ***** Test 1 RPL of CDD and Alter *****
|
||||
--echo ***** Test 1 setup *****
|
||||
|
||||
CREATE LOGFILE GROUP lg1
|
||||
ADD UNDOFILE 'undofile.dat'
|
||||
INITIAL_SIZE 16M
|
||||
UNDO_BUFFER_SIZE = 1M
|
||||
ENGINE=NDB;
|
||||
|
||||
ALTER LOGFILE GROUP lg1
|
||||
ADD UNDOFILE 'undofile02.dat'
|
||||
INITIAL_SIZE 4M
|
||||
ENGINE=NDB;
|
||||
|
||||
CREATE TABLESPACE ts1
|
||||
ADD DATAFILE 'datafile.dat'
|
||||
USE LOGFILE GROUP lg1
|
||||
INITIAL_SIZE 12M
|
||||
ENGINE=NDB;
|
||||
|
||||
ALTER TABLESPACE ts1
|
||||
ADD DATAFILE 'datafile02.dat'
|
||||
INITIAL_SIZE 4M
|
||||
ENGINE=NDB;
|
||||
|
||||
CREATE TABLE t1
|
||||
(c1 INT NOT NULL PRIMARY KEY,
|
||||
c2 INT NOT NULL,
|
||||
c3 INT NOT NULL)
|
||||
TABLESPACE ts1 STORAGE DISK
|
||||
ENGINE=NDB;
|
||||
|
||||
--echo ***** insert some data *****
|
||||
|
||||
let $j= 900;
|
||||
--disable_query_log
|
||||
while ($j)
|
||||
{
|
||||
eval INSERT INTO t1 VALUES($j,$j*2,$j+3);
|
||||
dec $j;
|
||||
}
|
||||
--enable_query_log
|
||||
|
||||
--echo ***** Select from Master *****
|
||||
|
||||
SELECT * FROM t1 ORDER BY c1 LIMIT 5;
|
||||
|
||||
--echo ***** Select from Slave *****
|
||||
--sync_slave_with_master
|
||||
connection slave;
|
||||
SELECT * FROM t1 ORDER BY c1 LIMIT 5;
|
||||
|
||||
###################################
|
||||
# Just to some File Schema check #
|
||||
###################################
|
||||
|
||||
--disable_query_log
|
||||
SELECT DISTINCT FILE_NAME, FILE_TYPE, TABLESPACE_NAME, LOGFILE_GROUP_NAME
|
||||
FROM INFORMATION_SCHEMA.FILES
|
||||
WHERE ENGINE="ndbcluster" ORDER BY FILE_NAME;
|
||||
--enable_query_log
|
||||
|
||||
--echo **** Do First Set of ALTERs in the master table ****
|
||||
###################################################
|
||||
# On this first set of alters I expect:
|
||||
# 1. To be able to create and index on 2 columns
|
||||
# 2. To be able to create a unique index
|
||||
# 3. To be able to add two columns and have
|
||||
# it all replicated correctly to the slave cluster.
|
||||
###################################################
|
||||
connection master;
|
||||
CREATE INDEX t1_i ON t1(c2, c3);
|
||||
#Bug 18039
|
||||
#CREATE UNIQUE INDEX t1_i2 ON t1(c2);
|
||||
ALTER TABLE t1 ADD c4 TIMESTAMP;
|
||||
ALTER TABLE t1 ADD c5 DOUBLE;
|
||||
ALTER TABLE t1 ADD INDEX (c5);
|
||||
SHOW CREATE TABLE t1;
|
||||
|
||||
--echo **** Show first set of ALTERs on SLAVE ****
|
||||
--sync_slave_with_master
|
||||
connection slave;
|
||||
SHOW CREATE TABLE t1;
|
||||
|
||||
--echo **** Second set of alters test 1 ****
|
||||
############################################
|
||||
# With this next set of alters we have had
|
||||
# Some issues with renames of tables. So this
|
||||
# test renames our main table, drop and index off
|
||||
# of it, creates another table with then name
|
||||
# of the orginal table, inserts a row, drops
|
||||
# the table and renames the orginal table back.
|
||||
# I want to make sure that 1) the cluster does
|
||||
# okay with this and 2) that it is replicated
|
||||
# correctly.
|
||||
#############################################
|
||||
connection master;
|
||||
ALTER TABLE t1 RENAME t2;
|
||||
ALTER TABLE t2 DROP INDEX c5;
|
||||
CREATE TABLE t1(c1 INT)ENGINE=NDB;
|
||||
INSERT INTO t1 VALUES(1);
|
||||
DROP TABLE t1;
|
||||
ALTER TABLE t2 RENAME t1;
|
||||
|
||||
--echo **** Show second set of ALTERs on MASTER ****
|
||||
|
||||
SHOW CREATE TABLE t1;
|
||||
|
||||
--echo **** Show second set of ALTERs on SLAVE ****
|
||||
--sync_slave_with_master
|
||||
connection slave;
|
||||
SHOW CREATE TABLE t1;
|
||||
|
||||
--echo **** Third and last set of alters for test1 ****
|
||||
#########################################################
|
||||
# In this last set of alters, we are messing with the
|
||||
# cluster ability to rebuild indexes, drop a column that make up
|
||||
# an index with another column and change types several times in
|
||||
# a row. I have choosen the BLOB as it seems to have had many
|
||||
# issues in this release. I want to make sure that the cluster
|
||||
# deals with these radical changes and that the replication to
|
||||
# the slave cluster is dones correctly.
|
||||
###########################################################
|
||||
connection master;
|
||||
ALTER TABLE t1 CHANGE c1 c1 DOUBLE;
|
||||
ALTER TABLE t1 CHANGE c2 c2 DECIMAL(10,2);
|
||||
ALTER TABLE t1 DROP COLUMN c3;
|
||||
ALTER TABLE t1 CHANGE c4 c4 TEXT CHARACTER SET utf8;
|
||||
ALTER TABLE t1 CHANGE c4 c4 BLOB;
|
||||
ALTER TABLE t1 CHANGE c4 c3 BLOB;
|
||||
set @b1 = 'b1';
|
||||
set @b1 = concat(@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1);
|
||||
UPDATE t1 SET c3=@b1 where c1 = 1;
|
||||
UPDATE t1 SET c3=@b1 where c1 = 2;
|
||||
|
||||
--echo **** Show last set of ALTERs on MASTER ****
|
||||
|
||||
SHOW CREATE TABLE t1;
|
||||
SELECT * FROM t1 ORDER BY c1 LIMIT 5;
|
||||
|
||||
--echo **** Show last set of ALTERs on SLAVE ****
|
||||
--sync_slave_with_master
|
||||
connection slave;
|
||||
SHOW CREATE TABLE t1;
|
||||
# Bug 18094
|
||||
#SELECT * FROM t1 ORDER BY c1 LIMIT 5;
|
||||
SELECT * FROM t1 where c1 = 1;
|
||||
|
||||
connection master;
|
||||
DROP TABLE t1;
|
||||
--sync_slave_with_master
|
||||
connection slave;
|
||||
STOP SLAVE;
|
||||
RESET SLAVE;
|
||||
connection master;
|
||||
RESET MASTER;
|
||||
connection slave;
|
||||
START SLAVE;
|
||||
|
||||
################### TEST 2 TPCB for disk data ###########################
|
||||
# Requirement: To have Stored Procedures and Functions that are used to #
|
||||
# populate and post transactions to the data base using CDD that span #
|
||||
# 2 tables spaces and also use a memory only cluster tables. In addition#
|
||||
# The slave is to be stopped, cleaned and restored and synced with the #
|
||||
# Master cluster #
|
||||
#########################################################################
|
||||
|
||||
--echo ******** Create additional TABLESPACE test 2 **************
|
||||
|
||||
connection master;
|
||||
CREATE TABLESPACE ts2
|
||||
ADD DATAFILE 'datafile03.dat'
|
||||
USE LOGFILE GROUP lg1
|
||||
INITIAL_SIZE 12M
|
||||
ENGINE=NDB;
|
||||
|
||||
ALTER TABLESPACE ts2
|
||||
ADD DATAFILE 'datafile04.dat'
|
||||
INITIAL_SIZE 12M
|
||||
ENGINE=NDB;
|
||||
|
||||
###### CLEAN UP SECTION ##############
|
||||
DROP DATABASE IF EXISTS tpcb;
|
||||
CREATE DATABASE tpcb;
|
||||
DROP DATABASE IF EXISTS test;
|
||||
CREATE DATABASE test;
|
||||
######## Creat Table Section #########
|
||||
--echo *********** Create TPCB Tables *****************
|
||||
CREATE TABLE tpcb.account
|
||||
(id INT, bid INT, balance DECIMAL(10,2),
|
||||
filler CHAR(255), PRIMARY KEY(id))
|
||||
TABLESPACE ts1 STORAGE DISK
|
||||
ENGINE=NDB;
|
||||
|
||||
CREATE TABLE tpcb.branch
|
||||
(bid INT, balance DECIMAL(10,2), filler VARCHAR(255),
|
||||
PRIMARY KEY(bid))
|
||||
ENGINE=NDB;
|
||||
|
||||
CREATE TABLE tpcb.teller
|
||||
(tid INT, balance DECIMAL(10,2), filler VARCHAR(255),
|
||||
PRIMARY KEY(tid))
|
||||
TABLESPACE ts2 STORAGE DISK
|
||||
ENGINE=NDB;
|
||||
|
||||
CREATE TABLE tpcb.history
|
||||
(id MEDIUMINT NOT NULL AUTO_INCREMENT,aid INT,
|
||||
tid INT, bid INT, amount DECIMAL(10,2),
|
||||
tdate DATETIME, teller CHAR(20), uuidf LONGBLOB,
|
||||
filler CHAR(80),PRIMARY KEY (id))
|
||||
TABLESPACE ts2 STORAGE DISK
|
||||
ENGINE=NDB;
|
||||
|
||||
--echo ********* Create Procedures and Functions ************
|
||||
delimiter |;
|
||||
CREATE PROCEDURE tpcb.load()
|
||||
BEGIN
|
||||
DECLARE acct INT DEFAULT 1000;
|
||||
DECLARE brch INT DEFAULT 100;
|
||||
DECLARE tell INT DEFAULT 1000;
|
||||
DECLARE tmp INT DEFAULT 100;
|
||||
WHILE brch > 0 DO
|
||||
SET tmp = 100;
|
||||
WHILE tmp > 0 DO
|
||||
INSERT INTO tpcb.account VALUES (acct, brch, 0.0, "FRESH ACCOUNT");
|
||||
SET acct = acct - 1;
|
||||
SET tmp = tmp -1;
|
||||
END WHILE;
|
||||
INSERT INTO tpcb.branch VALUES (brch, 0.0, "FRESH BRANCH");
|
||||
SET brch = brch - 1;
|
||||
END WHILE;
|
||||
WHILE tell > 0 DO
|
||||
INSERT INTO tpcb.teller VALUES (tell, 0.0, "FRESH TELLER");
|
||||
SET tell = tell - 1;
|
||||
END WHILE;
|
||||
END|
|
||||
|
||||
CREATE FUNCTION tpcb.account_id () RETURNS INT
|
||||
BEGIN
|
||||
DECLARE num INT;
|
||||
DECLARE ran INT;
|
||||
SELECT RAND() * 10 INTO ran;
|
||||
IF (ran < 2)
|
||||
THEN
|
||||
SELECT RAND() * 10 INTO num;
|
||||
ELSEIF (ran < 4)
|
||||
THEN
|
||||
SELECT RAND() * 100 INTO num;
|
||||
ELSE
|
||||
SELECT RAND() * 1000 INTO num;
|
||||
END IF;
|
||||
IF (num < 1)
|
||||
THEN
|
||||
RETURN 1;
|
||||
END IF;
|
||||
RETURN num;
|
||||
END|
|
||||
|
||||
CREATE FUNCTION tpcb.teller_id () RETURNS INT
|
||||
BEGIN
|
||||
DECLARE num INT;
|
||||
DECLARE ran INT;
|
||||
SELECT RAND() * 10 INTO ran;
|
||||
IF (ran < 2)
|
||||
THEN
|
||||
SELECT RAND() * 10 INTO num;
|
||||
ELSEIF (ran < 5)
|
||||
THEN
|
||||
SELECT RAND() * 100 INTO num;
|
||||
ELSE
|
||||
SELECT RAND() * 1000 INTO num;
|
||||
END IF;
|
||||
IF (num < 1)
|
||||
THEN
|
||||
RETURN 1;
|
||||
END IF;
|
||||
RETURN num;
|
||||
END|
|
||||
|
||||
CREATE PROCEDURE tpcb.trans()
|
||||
BEGIN
|
||||
DECLARE acct INT DEFAULT 0;
|
||||
DECLARE brch INT DEFAULT 0;
|
||||
DECLARE tell INT DEFAULT 0;
|
||||
DECLARE bal DECIMAL(10,2) DEFAULT 0.0;
|
||||
DECLARE amount DECIMAL(10,2) DEFAULT 1.00;
|
||||
DECLARE test INT DEFAULT 0;
|
||||
DECLARE bbal DECIMAL(10,2) DEFAULT 0.0;
|
||||
DECLARE tbal DECIMAL(10,2) DEFAULT 0.0;
|
||||
DECLARE local_uuid VARCHAR(255);
|
||||
DECLARE local_user VARCHAR(255);
|
||||
DECLARE local_time TIMESTAMP;
|
||||
|
||||
SELECT RAND() * 10 INTO test;
|
||||
SELECT tpcb.account_id() INTO acct;
|
||||
SELECT tpcb.teller_id() INTO tell;
|
||||
|
||||
SELECT account.balance INTO bal FROM tpcb.account WHERE id = acct;
|
||||
SELECT account.bid INTO brch FROM tpcb.account WHERE id = acct;
|
||||
SELECT teller.balance INTO tbal FROM tpcb.teller WHERE tid = tell;
|
||||
SELECT branch.balance INTO bbal FROM tpcb.branch WHERE bid = brch;
|
||||
|
||||
IF (test < 5)
|
||||
THEN
|
||||
SET bal = bal + amount;
|
||||
SET bbal = bbal + amount;
|
||||
SET tbal = tbal + amount;
|
||||
UPDATE tpcb.account SET balance = bal, filler = 'account updated'
|
||||
WHERE id = acct;
|
||||
UPDATE tpcb.branch SET balance = bbal, filler = 'branch updated'
|
||||
WHERE bid = brch;
|
||||
UPDATE tpcb.teller SET balance = tbal, filler = 'teller updated'
|
||||
WHERE tid = tell;
|
||||
ELSE
|
||||
SET bal = bal - amount;
|
||||
SET bbal = bbal - amount;
|
||||
SET tbal = tbal - amount;
|
||||
UPDATE tpcb.account SET balance = bal, filler = 'account updated'
|
||||
WHERE id = acct;
|
||||
UPDATE tpcb.branch SET balance = bbal, filler = 'branch updated'
|
||||
WHERE bid = brch;
|
||||
UPDATE tpcb.teller SET balance = tbal, filler = 'teller updated'
|
||||
WHERE tid = tell;
|
||||
END IF;
|
||||
|
||||
SET local_uuid=UUID();
|
||||
SET local_user=USER();
|
||||
SET local_time= NOW();
|
||||
INSERT INTO tpcb.history VALUES(NULL,acct,tell,brch,amount, local_time,local_user,
|
||||
local_uuid,'completed trans');
|
||||
END|
|
||||
delimiter ;|
|
||||
|
||||
--echo ****** TEST 2 test time *********************************
|
||||
USE tpcb;
|
||||
|
||||
--echo *********** Load up the database ******************
|
||||
CALL tpcb.load();
|
||||
|
||||
--echo ********** Check load master and slave **************
|
||||
SELECT COUNT(*) FROM account;
|
||||
--sync_slave_with_master
|
||||
connection slave;
|
||||
USE tpcb;
|
||||
SELECT COUNT(*) FROM account;
|
||||
|
||||
--echo ******** Run in some transactions ***************
|
||||
|
||||
connection master;
|
||||
let $j= 1000;
|
||||
--disable_query_log
|
||||
while ($j)
|
||||
{
|
||||
CALL tpcb.trans();
|
||||
dec $j;
|
||||
}
|
||||
--enable_query_log
|
||||
|
||||
--echo ***** Time to try slave sync ***********
|
||||
--echo **** Must make sure slave is clean *****
|
||||
--connection slave
|
||||
STOP SLAVE;
|
||||
RESET SLAVE;
|
||||
DROP PROCEDURE tpcb.load;
|
||||
DROP PROCEDURE tpcb.trans;
|
||||
DROP TABLE tpcb.account;
|
||||
DROP TABLE tpcb.teller;
|
||||
DROP TABLE tpcb.branch;
|
||||
DROP TABLE tpcb.history;
|
||||
DROP DATABASE tpcb;
|
||||
|
||||
ALTER TABLESPACE ts1
|
||||
DROP DATAFILE 'datafile.dat'
|
||||
ENGINE=NDB;
|
||||
|
||||
ALTER TABLESPACE ts1
|
||||
DROP DATAFILE 'datafile02.dat'
|
||||
ENGINE=NDB;
|
||||
|
||||
DROP TABLESPACE ts1 ENGINE=NDB;
|
||||
|
||||
ALTER TABLESPACE ts2
|
||||
DROP DATAFILE 'datafile03.dat'
|
||||
ENGINE=NDB;
|
||||
|
||||
ALTER TABLESPACE ts2
|
||||
DROP DATAFILE 'datafile04.dat'
|
||||
ENGINE=NDB;
|
||||
|
||||
DROP TABLESPACE ts2 ENGINE=NDB;
|
||||
|
||||
DROP LOGFILE GROUP lg1 ENGINE=NDB;
|
||||
|
||||
--echo ********** Take a backup of the Master *************
|
||||
connection master;
|
||||
|
||||
SELECT COUNT(*) FROM history;
|
||||
|
||||
let $j= 1000;
|
||||
--disable_query_log
|
||||
while ($j)
|
||||
{
|
||||
CALL tpcb.trans();
|
||||
dec $j;
|
||||
}
|
||||
--enable_query_log
|
||||
|
||||
SELECT COUNT(*) FROM history;
|
||||
|
||||
#RESET MASTER;
|
||||
--exec $NDB_MGM --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -e "start backup" >> $NDB_TOOLS_OUTPUT
|
||||
|
||||
--exec $NDB_TOOLS_DIR/ndb_select_all --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -d sys --delimiter=',' SYSTAB_0 | grep 520093696 > $MYSQLTEST_VARDIR/tmp.dat
|
||||
|
||||
CREATE TEMPORARY TABLE IF NOT EXISTS cluster.backup_info (id INT, backup_id INT) ENGINE = HEAP;
|
||||
|
||||
DELETE FROM cluster.backup_info;
|
||||
|
||||
LOAD DATA INFILE '../tmp.dat' INTO TABLE cluster.backup_info FIELDS TERMINATED BY ',';
|
||||
|
||||
--replace_column 1 <the_backup_id>
|
||||
|
||||
SELECT @the_backup_id:=backup_id FROM cluster.backup_info;
|
||||
|
||||
let the_backup_id=`select @the_backup_id`;
|
||||
|
||||
DROP TABLE IF EXISTS cluster.backup_info;
|
||||
#RESET MASTER;
|
||||
|
||||
--echo ************ Restore the slave ************************
|
||||
connection slave;
|
||||
CREATE DATABASE tpcb;
|
||||
--source include/ndb_restore_slave_eoption.inc
|
||||
|
||||
--echo ***** Check a few slave restore values ***************
|
||||
connection slave;
|
||||
USE tpcb;
|
||||
SELECT COUNT(*) FROM account;
|
||||
|
||||
--echo ***** Add some more records to master *********
|
||||
connection master;
|
||||
let $j= 1000;
|
||||
--disable_query_log
|
||||
while ($j)
|
||||
{
|
||||
CALL tpcb.trans();
|
||||
dec $j;
|
||||
}
|
||||
--enable_query_log
|
||||
|
||||
#
|
||||
# now setup replication to continue from last epoch
|
||||
# 1. get apply_status epoch from slave
|
||||
# 2. get corresponding _next_ binlog postition from master
|
||||
# 3. change master on slave
|
||||
# 4. add some transaction for slave to process
|
||||
# 5. start the replication
|
||||
|
||||
--echo ***** Finsh the slave sync process *******
|
||||
# 1.
|
||||
--echo * 1. *
|
||||
connection slave;
|
||||
--disable_query_log
|
||||
--replace_column 1 <the_epoch>
|
||||
SELECT @the_epoch:=MAX(epoch) FROM cluster.apply_status;
|
||||
--let $the_epoch= `select @the_epoch`
|
||||
|
||||
# 2.
|
||||
--echo * 2. *
|
||||
connection master;
|
||||
--replace_column 1 <the_pos>
|
||||
eval SELECT @the_pos:=Position,@the_file:=SUBSTRING_INDEX(FILE, '/', -1)
|
||||
FROM cluster.binlog_index WHERE epoch > $the_epoch ORDER BY epoch ASC LIMIT 1;
|
||||
--let $the_pos= `SELECT @the_pos`
|
||||
--let $the_file= `SELECT @the_file`
|
||||
|
||||
# 3.
|
||||
--echo * 3. *
|
||||
connection slave;
|
||||
eval CHANGE MASTER TO
|
||||
master_log_file = '$the_file',
|
||||
master_log_pos = $the_pos;
|
||||
--enable_query_log
|
||||
|
||||
# 4.
|
||||
--echo * 4. *
|
||||
connection master;
|
||||
let $j= 1000;
|
||||
--disable_query_log
|
||||
while ($j)
|
||||
{
|
||||
CALL tpcb.trans();
|
||||
dec $j;
|
||||
}
|
||||
--enable_query_log
|
||||
|
||||
# 5.
|
||||
--echo * 5. *
|
||||
connection slave;
|
||||
START SLAVE;
|
||||
|
||||
--echo **** We should be ready to continue on *************
|
||||
|
||||
connection master;
|
||||
let $j= 50;
|
||||
--disable_query_log
|
||||
while ($j)
|
||||
{
|
||||
CALL tpcb.trans();
|
||||
dec $j;
|
||||
}
|
||||
--enable_query_log
|
||||
|
||||
--echo ****** Let's make sure we match *******
|
||||
--echo ***** MASTER *******
|
||||
USE tpcb;
|
||||
SELECT COUNT(*) FROM history;
|
||||
|
||||
--echo ****** SLAVE ********
|
||||
--sync_slave_with_master
|
||||
connection slave;
|
||||
USE tpcb;
|
||||
SELECT COUNT(*) FROM history;
|
||||
|
||||
--echo *** DUMP MASTER & SLAVE FOR COMPARE ********
|
||||
|
||||
--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert tpcb account teller branch history > $MYSQLTEST_VARDIR/tmp/RPL_DD_ADV_M.sql
|
||||
|
||||
--exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert tpcb account teller branch history > $MYSQLTEST_VARDIR/tmp/RPL_DD_ADV_S.sql
|
||||
|
||||
--echo *************** TEST 2 CLEANUP SECTION ********************
|
||||
connection master;
|
||||
DROP PROCEDURE tpcb.load;
|
||||
DROP PROCEDURE tpcb.trans;
|
||||
DROP TABLE tpcb.account;
|
||||
DROP TABLE tpcb.teller;
|
||||
DROP TABLE tpcb.branch;
|
||||
DROP TABLE tpcb.history;
|
||||
DROP DATABASE tpcb;
|
||||
|
||||
ALTER TABLESPACE ts1
|
||||
DROP DATAFILE 'datafile.dat'
|
||||
ENGINE=NDB;
|
||||
|
||||
ALTER TABLESPACE ts1
|
||||
DROP DATAFILE 'datafile02.dat'
|
||||
ENGINE=NDB;
|
||||
|
||||
DROP TABLESPACE ts1 ENGINE=NDB;
|
||||
|
||||
ALTER TABLESPACE ts2
|
||||
DROP DATAFILE 'datafile03.dat'
|
||||
ENGINE=NDB;
|
||||
|
||||
ALTER TABLESPACE ts2
|
||||
DROP DATAFILE 'datafile04.dat'
|
||||
ENGINE=NDB;
|
||||
|
||||
DROP TABLESPACE ts2 ENGINE=NDB;
|
||||
|
||||
DROP LOGFILE GROUP lg1 ENGINE=NDB;
|
||||
|
||||
--sync_slave_with_master
|
||||
|
||||
connection master;
|
||||
|
||||
--echo ****** Do dumps compare ************
|
||||
|
||||
--exec diff $MYSQLTEST_VARDIR/tmp/RPL_DD_ADV_M.sql $MYSQLTEST_VARDIR/tmp/RPL_DD_ADV_S.sql
|
||||
|
||||
## Note: Ths files should only get removed, if the above diff succeeds.
|
||||
|
||||
--exec rm $MYSQLTEST_VARDIR/tmp/RPL_DD_ADV_M.sql
|
||||
--exec rm $MYSQLTEST_VARDIR/tmp/RPL_DD_ADV_S.sql
|
||||
|
||||
# End 5.1 test case
|
||||
@@ -170,6 +170,7 @@ use test;
|
||||
drop table t1,t2;
|
||||
drop database other;
|
||||
|
||||
|
||||
#
|
||||
# Test specific triggers including SELECT into var with replication
|
||||
# BUG#13227:
|
||||
@@ -265,6 +266,79 @@ while ($rnd)
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# BUG#16266: Definer is not fully qualified error during replication.
|
||||
#
|
||||
# The idea of this test is to emulate replication of a trigger from the old
|
||||
# master (master w/o "DEFINER in triggers" support) to the new slave and check
|
||||
# that:
|
||||
# 1. the trigger on the slave will be replicated w/o errors;
|
||||
# 2. the trigger on the slave will be non-SUID (will have no DEFINER);
|
||||
# 3. the trigger can be activated later on the slave w/o errors.
|
||||
#
|
||||
# In order to emulate this kind of replication, we make the slave playing the binlog,
|
||||
# recorded by 5.0.16 master. This binlog contains the following statements:
|
||||
# CREATE TABLE t1(c INT);
|
||||
# CREATE TABLE t2(s CHAR(200));
|
||||
# CREATE TRIGGER trg1 AFTER INSERT ON t1
|
||||
# FOR EACH ROW
|
||||
# INSERT INTO t2 VALUES(CURRENT_USER());
|
||||
# INSERT INTO t1 VALUES(1);
|
||||
#
|
||||
|
||||
# 1. Check that the trigger's replication is succeeded.
|
||||
|
||||
# Stop the slave.
|
||||
|
||||
connection slave;
|
||||
STOP SLAVE;
|
||||
|
||||
# Replace master's binlog.
|
||||
|
||||
connection master;
|
||||
FLUSH LOGS;
|
||||
exec cp $MYSQL_TEST_DIR/std_data/bug16266.000001 $MYSQLTEST_VARDIR/log/master-bin.000001;
|
||||
|
||||
# Make the slave to replay the new binlog.
|
||||
|
||||
connection slave;
|
||||
RESET SLAVE;
|
||||
START SLAVE;
|
||||
|
||||
SELECT MASTER_POS_WAIT('master-bin.000001', 513) >= 0;
|
||||
|
||||
# Check that the replication succeeded.
|
||||
|
||||
SHOW TABLES LIKE 't_';
|
||||
SHOW TRIGGERS;
|
||||
SELECT * FROM t1;
|
||||
SELECT * FROM t2;
|
||||
|
||||
# 2. Check that the trigger is non-SUID on the slave;
|
||||
# 3. Check that the trigger can be activated on the slave.
|
||||
|
||||
INSERT INTO t1 VALUES(2);
|
||||
|
||||
SELECT * FROM t1;
|
||||
SELECT * FROM t2;
|
||||
|
||||
# That's all, cleanup.
|
||||
|
||||
DROP TRIGGER trg1;
|
||||
DROP TABLE t1;
|
||||
DROP TABLE t2;
|
||||
|
||||
STOP SLAVE;
|
||||
RESET SLAVE;
|
||||
|
||||
# The master should be clean.
|
||||
|
||||
connection master;
|
||||
SHOW TABLES LIKE 't_';
|
||||
SHOW TRIGGERS;
|
||||
|
||||
RESET MASTER;
|
||||
|
||||
|
||||
#
|
||||
# End of tests
|
||||
|
||||
@@ -8,14 +8,6 @@ drop procedure if exists f1;
|
||||
--enable_warnings
|
||||
use test;
|
||||
|
||||
#
|
||||
# test that we can create VIEW if privileges check switched off
|
||||
#
|
||||
create table t1 (field1 INT);
|
||||
-- error ER_MALFORMED_DEFINER
|
||||
CREATE VIEW v1 AS SELECT field1 FROM t1;
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# Test that we can create and drop procedure without warnings
|
||||
# see bug#9993
|
||||
@@ -33,3 +25,48 @@ drop table t1;
|
||||
|
||||
# BUG#17595: DROP FUNCTION IF EXISTS f1 crashes server
|
||||
drop function if exists f1;
|
||||
|
||||
#
|
||||
# BUG#16777: Can not create trigger nor view w/o definer if --skip-grant-tables
|
||||
# specified
|
||||
#
|
||||
# Also, a test that we can create VIEW if privileges check switched off has
|
||||
# been moved here.
|
||||
#
|
||||
|
||||
# Prepare.
|
||||
|
||||
--disable_warnings
|
||||
|
||||
DROP VIEW IF EXISTS v1;
|
||||
DROP VIEW IF EXISTS v2;
|
||||
|
||||
DROP TABLE IF EXISTS t1;
|
||||
|
||||
--enable_warnings
|
||||
|
||||
# Test case.
|
||||
|
||||
CREATE TABLE t1(c INT);
|
||||
|
||||
CREATE TRIGGER t1_bi BEFORE INSERT ON t1
|
||||
FOR EACH ROW
|
||||
SET @a = 1;
|
||||
|
||||
CREATE VIEW v1 AS SELECT * FROM t1;
|
||||
|
||||
CREATE DEFINER=a@b TRIGGER ti_ai AFTER INSERT ON t1
|
||||
FOR EACH ROW
|
||||
SET @b = 1;
|
||||
|
||||
CREATE DEFINER=a@b VIEW v2 AS SELECT * FROM t1;
|
||||
|
||||
# Cleanup.
|
||||
|
||||
DROP TRIGGER t1_bi;
|
||||
DROP TRIGGER ti_ai;
|
||||
|
||||
DROP VIEW v1;
|
||||
DROP VIEW v2;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
@@ -547,4 +547,200 @@ GRANT EXECUTE ON PROCEDURE p1 TO user_bug7787@localhost;
|
||||
DROP DATABASE db_bug7787;
|
||||
use test;
|
||||
|
||||
|
||||
#
|
||||
# WL#2897: Complete definer support in the stored routines.
|
||||
#
|
||||
# The following cases are tested:
|
||||
# 1. check that if DEFINER-clause is not explicitly specified, stored routines
|
||||
# are created with CURRENT_USER privileges;
|
||||
# 2. check that if DEFINER-clause specifies non-current user, SUPER privilege
|
||||
# is required to create a stored routine;
|
||||
# 3. check that if DEFINER-clause specifies non-existent user, a warning is
|
||||
# emitted.
|
||||
# 4. check that SHOW CREATE PROCEDURE | FUNCTION works correctly;
|
||||
#
|
||||
# The following cases are tested in other test suites:
|
||||
# - check that mysqldump dumps new attribute correctly;
|
||||
# - check that slave replicates CREATE-statements with explicitly specified
|
||||
# DEFINER correctly.
|
||||
#
|
||||
|
||||
# Setup the environment.
|
||||
|
||||
--echo
|
||||
--echo ---> connection: root
|
||||
--connection con1root
|
||||
|
||||
--disable_warnings
|
||||
DROP DATABASE IF EXISTS mysqltest;
|
||||
--enable_warnings
|
||||
|
||||
CREATE DATABASE mysqltest;
|
||||
|
||||
CREATE USER mysqltest_1@localhost;
|
||||
GRANT ALL PRIVILEGES ON mysqltest.* TO mysqltest_1@localhost;
|
||||
|
||||
CREATE USER mysqltest_2@localhost;
|
||||
GRANT SUPER ON *.* TO mysqltest_2@localhost;
|
||||
GRANT ALL PRIVILEGES ON mysqltest.* TO mysqltest_2@localhost;
|
||||
|
||||
--connect (mysqltest_2_con,localhost,mysqltest_2,,mysqltest)
|
||||
--connect (mysqltest_1_con,localhost,mysqltest_1,,mysqltest)
|
||||
|
||||
# test case (1).
|
||||
|
||||
--echo
|
||||
--echo ---> connection: mysqltest_2_con
|
||||
--connection mysqltest_2_con
|
||||
|
||||
use mysqltest;
|
||||
|
||||
CREATE PROCEDURE wl2897_p1() SELECT 1;
|
||||
|
||||
CREATE FUNCTION wl2897_f1() RETURNS INT RETURN 1;
|
||||
|
||||
# test case (2).
|
||||
|
||||
--echo
|
||||
--echo ---> connection: mysqltest_1_con
|
||||
--connection mysqltest_1_con
|
||||
|
||||
use mysqltest;
|
||||
|
||||
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
|
||||
CREATE DEFINER=root@localhost PROCEDURE wl2897_p2() SELECT 2;
|
||||
|
||||
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
|
||||
CREATE DEFINER=root@localhost FUNCTION wl2897_f2() RETURNS INT RETURN 2;
|
||||
|
||||
# test case (3).
|
||||
|
||||
--echo
|
||||
--echo ---> connection: mysqltest_2_con
|
||||
--connection mysqltest_2_con
|
||||
|
||||
use mysqltest;
|
||||
|
||||
CREATE DEFINER='a @ b @ c'@localhost PROCEDURE wl2897_p3() SELECT 3;
|
||||
|
||||
CREATE DEFINER='a @ b @ c'@localhost FUNCTION wl2897_f3() RETURNS INT RETURN 3;
|
||||
|
||||
# test case (4).
|
||||
|
||||
--echo
|
||||
--echo ---> connection: con1root
|
||||
--connection con1root
|
||||
|
||||
use mysqltest;
|
||||
|
||||
SHOW CREATE PROCEDURE wl2897_p1;
|
||||
SHOW CREATE PROCEDURE wl2897_p3;
|
||||
|
||||
SHOW CREATE FUNCTION wl2897_f1;
|
||||
SHOW CREATE FUNCTION wl2897_f3;
|
||||
|
||||
# Cleanup.
|
||||
|
||||
DROP USER mysqltest_1@localhost;
|
||||
DROP USER mysqltest_2@localhost;
|
||||
|
||||
DROP DATABASE mysqltest;
|
||||
|
||||
--disconnect mysqltest_1_con
|
||||
--disconnect mysqltest_2_con
|
||||
|
||||
|
||||
#
|
||||
# BUG#13198: SP executes if definer does not exist
|
||||
#
|
||||
|
||||
# Prepare environment.
|
||||
|
||||
--echo
|
||||
--echo ---> connection: root
|
||||
--connection con1root
|
||||
|
||||
--disable_warnings
|
||||
DROP DATABASE IF EXISTS mysqltest;
|
||||
--enable_warnings
|
||||
|
||||
CREATE DATABASE mysqltest;
|
||||
|
||||
CREATE USER mysqltest_1@localhost;
|
||||
GRANT ALL PRIVILEGES ON mysqltest.* TO mysqltest_1@localhost;
|
||||
|
||||
CREATE USER mysqltest_2@localhost;
|
||||
GRANT ALL PRIVILEGES ON mysqltest.* TO mysqltest_2@localhost;
|
||||
|
||||
--connect (mysqltest_1_con,localhost,mysqltest_1,,mysqltest)
|
||||
--connect (mysqltest_2_con,localhost,mysqltest_2,,mysqltest)
|
||||
|
||||
# Create a procedure/function under u1.
|
||||
|
||||
--echo
|
||||
--echo ---> connection: mysqltest_1_con
|
||||
--connection mysqltest_1_con
|
||||
|
||||
use mysqltest;
|
||||
|
||||
CREATE PROCEDURE bug13198_p1()
|
||||
SELECT 1;
|
||||
|
||||
CREATE FUNCTION bug13198_f1() RETURNS INT
|
||||
RETURN 1;
|
||||
|
||||
CALL bug13198_p1();
|
||||
|
||||
SELECT bug13198_f1();
|
||||
|
||||
# Check that u2 can call the procedure/function.
|
||||
|
||||
--echo
|
||||
--echo ---> connection: mysqltest_2_con
|
||||
--connection mysqltest_2_con
|
||||
|
||||
use mysqltest;
|
||||
|
||||
CALL bug13198_p1();
|
||||
|
||||
SELECT bug13198_f1();
|
||||
|
||||
# Drop user u1 (definer of the object);
|
||||
|
||||
--echo
|
||||
--echo ---> connection: root
|
||||
--connection con1root
|
||||
|
||||
--disconnect mysqltest_1_con
|
||||
|
||||
DROP USER mysqltest_1@localhost;
|
||||
|
||||
# Check that u2 can not call the procedure/function.
|
||||
|
||||
--echo
|
||||
--echo ---> connection: mysqltest_2_con
|
||||
--connection mysqltest_2_con
|
||||
|
||||
use mysqltest;
|
||||
|
||||
--error ER_NO_SUCH_USER
|
||||
CALL bug13198_p1();
|
||||
|
||||
--error ER_NO_SUCH_USER
|
||||
SELECT bug13198_f1();
|
||||
|
||||
# Cleanup.
|
||||
|
||||
--echo
|
||||
--echo ---> connection: root
|
||||
--connection con1root
|
||||
|
||||
--disconnect mysqltest_2_con
|
||||
|
||||
DROP USER mysqltest_2@localhost;
|
||||
|
||||
DROP DATABASE mysqltest;
|
||||
|
||||
|
||||
# End of 5.0 bugs.
|
||||
|
||||
@@ -317,10 +317,7 @@ CREATE DEFINER='mysqltest_nonexs'@'localhost'
|
||||
|
||||
# Check that trg2 will not be activated.
|
||||
|
||||
# --error ER_SPECIFIC_ACCESS_DENIED_ERROR
|
||||
#
|
||||
# TODO: Due to the BUG#13198(SP executes if definer does not exist) the
|
||||
# following statement does not fail as it should.
|
||||
--error ER_NO_SUCH_USER
|
||||
INSERT INTO t1 VALUES(6);
|
||||
|
||||
#
|
||||
|
||||
@@ -712,10 +712,11 @@ connection default;
|
||||
#
|
||||
# DEFINER information check
|
||||
#
|
||||
-- error ER_MALFORMED_DEFINER
|
||||
create definer=some_user@`` sql security invoker view v1 as select 1;
|
||||
create definer=some_user@localhost sql security invoker view v1 as select 1;
|
||||
create definer=some_user@localhost sql security invoker view v2 as select 1;
|
||||
show create view v1;
|
||||
show create view v2;
|
||||
drop view v1;
|
||||
drop view v2;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user