Commit 53235cbb authored by Jacob Mathew's avatar Jacob Mathew

Updated spider/bg and spider/handler mtr suites.

parent f99b8357
......@@ -6,5 +6,7 @@ return "No Spider engine" unless $ENV{HA_SPIDER_SO};
return "Not run for embedded server" if $::opt_embedded_server;
return "Test needs --big-test" unless $::opt_big_test;
sub is_default { 1 }
bless { };
for master_1
for child2
child2_1
child2_2
child2_3
for child3
child3_1
child3_2
child3_3
drop and create databases
connection master_1;
DROP DATABASE IF EXISTS auto_test_local;
CREATE DATABASE auto_test_local;
USE auto_test_local;
connection child2_1;
DROP DATABASE IF EXISTS auto_test_remote;
CREATE DATABASE auto_test_remote;
USE auto_test_remote;
connection child2_2;
DROP DATABASE IF EXISTS auto_test_remote2;
CREATE DATABASE auto_test_remote2;
USE auto_test_remote2;
test select 1
connection master_1;
SELECT 1;
1
1
connection master_1;
DROP TABLE IF EXISTS tb_l;
CREATE TABLE tb_l (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a)
) MASTER_1_ENGINE2 MASTER_1_CHARSET2
INSERT INTO tb_l (a, b, c) VALUES
(1, 'f', '2008-07-01 10:21:39'),
(2, 'g', '2000-02-01 00:00:00'),
(3, 'j', '2007-05-04 20:03:11'),
(4, 'i', '2003-10-30 05:01:03'),
(5, 'h', '2001-10-31 23:59:59');
create table with partition and select test
connection master_1;
CREATE TABLE ta_l2 (
PRIMARY KEY(a)
) MASTER_1_ENGINE MASTER_1_COMMENT_P_2_1
SELECT a, b, c FROM tb_l
connection master_1;
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 f 2008-07-01 10:21:39
2 g 2000-02-01 00:00:00
3 j 2007-05-04 20:03:11
4 i 2003-10-30 05:01:03
5 h 2001-10-31 23:59:59
select partition using pushdown
connection master_1;
SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 a WHERE
a.b = 'g' ORDER BY a.a;
a b date_format(a.c, '%Y-%m-%d %H:%i:%s')
2 g 2000-02-01 00:00:00
select partition using index pushdown
connection master_1;
SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 a WHERE
a.a > 0 AND a.b = 'g' ORDER BY a.a;
a b date_format(a.c, '%Y-%m-%d %H:%i:%s')
2 g 2000-02-01 00:00:00
update partition pushdown
connection master_1;
UPDATE ta_l2 SET b = 'e', c = '2009-03-03 03:03:03' WHERE b = 'j';
connection master_1;
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 f 2008-07-01 10:21:39
2 g 2000-02-01 00:00:00
3 e 2009-03-03 03:03:03
4 i 2003-10-30 05:01:03
5 h 2001-10-31 23:59:59
update partition index pushdown
connection master_1;
UPDATE ta_l2 SET b = 'j', c = '2009-03-03 03:03:03' WHERE a > 0 AND b = 'e';
connection master_1;
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 f 2008-07-01 10:21:39
2 g 2000-02-01 00:00:00
3 j 2009-03-03 03:03:03
4 i 2003-10-30 05:01:03
5 h 2001-10-31 23:59:59
delete partition pushdown
TRUNCATE TABLE ta_l2;
INSERT INTO ta_l2 SELECT a, b, c FROM tb_l;
connection master_1;
DELETE FROM ta_l2 WHERE b = 'g';
connection master_1;
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 f 2008-07-01 10:21:39
3 j 2007-05-04 20:03:11
4 i 2003-10-30 05:01:03
5 h 2001-10-31 23:59:59
delete partition index pushdown
TRUNCATE TABLE ta_l2;
INSERT INTO ta_l2 SELECT a, b, c FROM tb_l;
connection master_1;
DELETE FROM ta_l2 WHERE a > 0 AND b = 'g';
connection master_1;
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 f 2008-07-01 10:21:39
3 j 2007-05-04 20:03:11
4 i 2003-10-30 05:01:03
5 h 2001-10-31 23:59:59
deinit
connection master_1;
DROP DATABASE IF EXISTS auto_test_local;
connection child2_1;
DROP DATABASE IF EXISTS auto_test_remote;
connection child2_2;
DROP DATABASE IF EXISTS auto_test_remote2;
for master_1
for child2
child2_1
child2_2
child2_3
for child3
child3_1
child3_2
child3_3
end of test
......@@ -9,22 +9,27 @@ child3_2
child3_3
drop and create databases
connection master_1;
DROP DATABASE IF EXISTS auto_test_local;
CREATE DATABASE auto_test_local;
USE auto_test_local;
connection child2_1;
DROP DATABASE IF EXISTS auto_test_remote;
CREATE DATABASE auto_test_remote;
USE auto_test_remote;
connection child2_2;
DROP DATABASE IF EXISTS auto_test_remote2;
CREATE DATABASE auto_test_remote2;
USE auto_test_remote2;
test select 1
connection master_1;
SELECT 1;
1
1
create table select test
connection master_1;
DROP TABLE IF EXISTS ta_l;
CREATE TABLE ta_l (
a INT,
......@@ -40,6 +45,7 @@ INSERT INTO ta_l (a, b, c) VALUES
(5, 'c', '2001-12-31 23:59:59');
direct_aggregating test
connection master_1;
SHOW STATUS LIKE 'Spider_direct_aggregate';
Variable_name Value
Spider_direct_aggregate 0
......@@ -48,76 +54,38 @@ COUNT(*)
5
SHOW STATUS LIKE 'Spider_direct_aggregate';
Variable_name Value
Spider_direct_aggregate 1
Spider_direct_aggregate 0
SELECT MAX(a) FROM ta_l;
MAX(a)
5
SHOW STATUS LIKE 'Spider_direct_aggregate';
Variable_name Value
Spider_direct_aggregate 2
Spider_direct_aggregate 0
SELECT MIN(a) FROM ta_l;
MIN(a)
1
SHOW STATUS LIKE 'Spider_direct_aggregate';
Variable_name Value
Spider_direct_aggregate 3
Spider_direct_aggregate 0
SELECT MAX(a) FROM ta_l WHERE a < 5;
MAX(a)
4
SHOW STATUS LIKE 'Spider_direct_aggregate';
Variable_name Value
Spider_direct_aggregate 4
Spider_direct_aggregate 0
SELECT MIN(a) FROM ta_l WHERE a > 1;
MIN(a)
2
SHOW STATUS LIKE 'Spider_direct_aggregate';
Variable_name Value
Spider_direct_aggregate 5
handler with partition test
CREATE TABLE ta_l2 (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a)
) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1
SHOW STATUS LIKE 'Spider_direct_aggregate';
Variable_name Value
Spider_direct_aggregate 5
SELECT COUNT(*) FROM ta_l2;
COUNT(*)
5
SHOW STATUS LIKE 'Spider_direct_aggregate';
Variable_name Value
Spider_direct_aggregate 7
SELECT MAX(a) FROM ta_l2;
MAX(a)
5
SHOW STATUS LIKE 'Spider_direct_aggregate';
Variable_name Value
Spider_direct_aggregate 9
SELECT MIN(a) FROM ta_l2;
MIN(a)
1
SHOW STATUS LIKE 'Spider_direct_aggregate';
Variable_name Value
Spider_direct_aggregate 11
SELECT MAX(a) FROM ta_l2 WHERE a < 5;
MAX(a)
4
SHOW STATUS LIKE 'Spider_direct_aggregate';
Variable_name Value
Spider_direct_aggregate 13
SELECT MIN(a) FROM ta_l2 WHERE a > 1;
MIN(a)
2
SHOW STATUS LIKE 'Spider_direct_aggregate';
Variable_name Value
Spider_direct_aggregate 15
Spider_direct_aggregate 0
deinit
connection master_1;
DROP DATABASE IF EXISTS auto_test_local;
connection child2_1;
DROP DATABASE IF EXISTS auto_test_remote;
connection child2_2;
DROP DATABASE IF EXISTS auto_test_remote2;
for master_1
for child2
......
for master_1
for child2
child2_1
child2_2
child2_3
for child3
child3_1
child3_2
child3_3
drop and create databases
connection master_1;
DROP DATABASE IF EXISTS auto_test_local;
CREATE DATABASE auto_test_local;
USE auto_test_local;
connection child2_1;
DROP DATABASE IF EXISTS auto_test_remote;
CREATE DATABASE auto_test_remote;
USE auto_test_remote;
connection child2_2;
DROP DATABASE IF EXISTS auto_test_remote2;
CREATE DATABASE auto_test_remote2;
USE auto_test_remote2;
test select 1
connection master_1;
SELECT 1;
1
1
with partition test
connection master_1;
CREATE TABLE ta_l2 (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a)
) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1
SHOW STATUS LIKE 'Spider_direct_aggregate';
Variable_name Value
Spider_direct_aggregate 0
SELECT COUNT(*) FROM ta_l2;
COUNT(*)
5
SHOW STATUS LIKE 'Spider_direct_aggregate';
Variable_name Value
Spider_direct_aggregate 0
SELECT MAX(a) FROM ta_l2;
MAX(a)
5
SHOW STATUS LIKE 'Spider_direct_aggregate';
Variable_name Value
Spider_direct_aggregate 0
SELECT MIN(a) FROM ta_l2;
MIN(a)
1
SHOW STATUS LIKE 'Spider_direct_aggregate';
Variable_name Value
Spider_direct_aggregate 0
SELECT MAX(a) FROM ta_l2 WHERE a < 5;
MAX(a)
4
SHOW STATUS LIKE 'Spider_direct_aggregate';
Variable_name Value
Spider_direct_aggregate 0
SELECT MIN(a) FROM ta_l2 WHERE a > 1;
MIN(a)
2
SHOW STATUS LIKE 'Spider_direct_aggregate';
Variable_name Value
Spider_direct_aggregate 0
deinit
connection master_1;
DROP DATABASE IF EXISTS auto_test_local;
connection child2_1;
DROP DATABASE IF EXISTS auto_test_remote;
connection child2_2;
DROP DATABASE IF EXISTS auto_test_remote2;
for master_1
for child2
child2_1
child2_2
child2_3
for child3
child3_1
child3_2
child3_3
end of test
......@@ -9,22 +9,27 @@ child3_2
child3_3
drop and create databases
connection master_1;
DROP DATABASE IF EXISTS auto_test_local;
CREATE DATABASE auto_test_local;
USE auto_test_local;
connection child2_1;
DROP DATABASE IF EXISTS auto_test_remote;
CREATE DATABASE auto_test_remote;
USE auto_test_remote;
connection child2_2;
DROP DATABASE IF EXISTS auto_test_remote2;
CREATE DATABASE auto_test_remote2;
USE auto_test_remote2;
test select 1
connection master_1;
SELECT 1;
1
1
create table select test
connection master_1;
DROP TABLE IF EXISTS ta_l;
CREATE TABLE ta_l (
a INT,
......@@ -40,9 +45,9 @@ INSERT INTO ta_l (a, b, c) VALUES
(5, 'c', '2001-12-31 23:59:59');
direct_updating test
connection master_1;
SHOW STATUS LIKE 'Spider_direct_update';
Variable_name Value
Spider_direct_update 0
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-01 10:21:39
......@@ -54,7 +59,6 @@ update all rows with function
UPDATE ta_l SET c = ADDDATE(c, 1);
SHOW STATUS LIKE 'Spider_direct_update';
Variable_name Value
Spider_direct_update 1
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-02 10:21:39
......@@ -66,7 +70,6 @@ update by primary key
UPDATE ta_l SET b = 'x' WHERE a = 3;
SHOW STATUS LIKE 'Spider_direct_update';
Variable_name Value
Spider_direct_update 2
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-02 10:21:39
......@@ -78,7 +81,6 @@ update by a column without index
UPDATE ta_l SET c = '2011-10-17' WHERE b = 'x';
SHOW STATUS LIKE 'Spider_direct_update';
Variable_name Value
Spider_direct_update 3
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-02 10:21:39
......@@ -90,7 +92,6 @@ update by primary key with order and limit
UPDATE ta_l SET c = ADDDATE(c, 1) WHERE a < 4 ORDER BY b DESC LIMIT 1;
SHOW STATUS LIKE 'Spider_direct_update';
Variable_name Value
Spider_direct_update 4
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-02 10:21:39
......@@ -102,7 +103,6 @@ delete by primary key with order and limit
DELETE FROM ta_l WHERE a < 4 ORDER BY c LIMIT 1;
SHOW STATUS LIKE 'Spider_direct_delete';
Variable_name Value
Spider_direct_delete 1
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-02 10:21:39
......@@ -113,7 +113,6 @@ delete by a column without index
DELETE FROM ta_l WHERE b = 'c';
SHOW STATUS LIKE 'Spider_direct_delete';
Variable_name Value
Spider_direct_delete 2
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-02 10:21:39
......@@ -123,111 +122,17 @@ delete by primary key
DELETE FROM ta_l WHERE a = 3;
SHOW STATUS LIKE 'Spider_direct_delete';
Variable_name Value
Spider_direct_delete 3
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-02 10:21:39
4 d 2003-12-01 05:01:03
handler with partition test
CREATE TABLE ta_l2 (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a)
) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1
SHOW STATUS LIKE 'Spider_direct_update';
Variable_name Value
Spider_direct_update 4
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-01 10:21:39
2 b 2000-01-01 00:00:00
3 e 2007-06-04 20:03:11
4 d 2003-11-30 05:01:03
5 c 2001-12-31 23:59:59
update all rows with function
UPDATE ta_l2 SET c = ADDDATE(c, 1);
SHOW STATUS LIKE 'Spider_direct_update';
Variable_name Value
Spider_direct_update 6
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-02 10:21:39
2 b 2000-01-02 00:00:00
3 e 2007-06-05 20:03:11
4 d 2003-12-01 05:01:03
5 c 2002-01-01 23:59:59
update by primary key
UPDATE ta_l2 SET b = 'x' WHERE a = 3;
SHOW STATUS LIKE 'Spider_direct_update';
Variable_name Value
Spider_direct_update 7
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-02 10:21:39
2 b 2000-01-02 00:00:00
3 x 2007-06-05 20:03:11
4 d 2003-12-01 05:01:03
5 c 2002-01-01 23:59:59
update by a column without index
UPDATE ta_l2 SET c = '2011-10-17' WHERE b = 'x';
SHOW STATUS LIKE 'Spider_direct_update';
Variable_name Value
Spider_direct_update 9
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-02 10:21:39
2 b 2000-01-02 00:00:00
3 x 2011-10-17 00:00:00
4 d 2003-12-01 05:01:03
5 c 2002-01-01 23:59:59
update by primary key with order and limit
UPDATE ta_l2 SET c = ADDDATE(c, 1) WHERE a < 4 ORDER BY b DESC LIMIT 1;
SHOW STATUS LIKE 'Spider_direct_update';
Variable_name Value
Spider_direct_update 10
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-02 10:21:39
2 b 2000-01-02 00:00:00
3 x 2011-10-18 00:00:00
4 d 2003-12-01 05:01:03
5 c 2002-01-01 23:59:59
delete by primary key with order and limit
DELETE FROM ta_l2 WHERE a < 4 ORDER BY c LIMIT 1;
SHOW STATUS LIKE 'Spider_direct_delete';
Variable_name Value
Spider_direct_delete 4
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-02 10:21:39
3 x 2011-10-18 00:00:00
4 d 2003-12-01 05:01:03
5 c 2002-01-01 23:59:59
delete by a column without index
DELETE FROM ta_l2 WHERE b = 'c';
SHOW STATUS LIKE 'Spider_direct_delete';
Variable_name Value
Spider_direct_delete 6
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-02 10:21:39
3 x 2011-10-18 00:00:00
4 d 2003-12-01 05:01:03
delete by primary key
DELETE FROM ta_l2 WHERE a = 3;
SHOW STATUS LIKE 'Spider_direct_delete';
Variable_name Value
Spider_direct_delete 7
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-02 10:21:39
4 d 2003-12-01 05:01:03
deinit
connection master_1;
DROP DATABASE IF EXISTS auto_test_local;
connection child2_1;
DROP DATABASE IF EXISTS auto_test_remote;
connection child2_2;
DROP DATABASE IF EXISTS auto_test_remote2;
for master_1
for child2
......
for master_1
for child2
child2_1
child2_2
child2_3
for child3
child3_1
child3_2
child3_3
drop and create databases
connection master_1;
DROP DATABASE IF EXISTS auto_test_local;
CREATE DATABASE auto_test_local;
USE auto_test_local;
connection child2_1;
DROP DATABASE IF EXISTS auto_test_remote;
CREATE DATABASE auto_test_remote;
USE auto_test_remote;
connection child2_2;
DROP DATABASE IF EXISTS auto_test_remote2;
CREATE DATABASE auto_test_remote2;
USE auto_test_remote2;
test select 1
connection master_1;
SELECT 1;
1
1
with partition test
connection master_1;
CREATE TABLE ta_l2 (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a)
) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1
SHOW STATUS LIKE 'Spider_direct_update';
Variable_name Value
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-01 10:21:39
2 b 2000-01-01 00:00:00
3 e 2007-06-04 20:03:11
4 d 2003-11-30 05:01:03
5 c 2001-12-31 23:59:59
update all rows with function
UPDATE ta_l2 SET c = ADDDATE(c, 1);
SHOW STATUS LIKE 'Spider_direct_update';
Variable_name Value
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-02 10:21:39
2 b 2000-01-02 00:00:00
3 e 2007-06-05 20:03:11
4 d 2003-12-01 05:01:03
5 c 2002-01-01 23:59:59
update by primary key
UPDATE ta_l2 SET b = 'x' WHERE a = 3;
SHOW STATUS LIKE 'Spider_direct_update';
Variable_name Value
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-02 10:21:39
2 b 2000-01-02 00:00:00
3 x 2007-06-05 20:03:11
4 d 2003-12-01 05:01:03
5 c 2002-01-01 23:59:59
update by a column without index
UPDATE ta_l2 SET c = '2011-10-17' WHERE b = 'x';
SHOW STATUS LIKE 'Spider_direct_update';
Variable_name Value
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-02 10:21:39
2 b 2000-01-02 00:00:00
3 x 2011-10-17 00:00:00
4 d 2003-12-01 05:01:03
5 c 2002-01-01 23:59:59
update by primary key with order and limit
UPDATE ta_l2 SET c = ADDDATE(c, 1) WHERE a < 4 ORDER BY b DESC LIMIT 1;
SHOW STATUS LIKE 'Spider_direct_update';
Variable_name Value
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-02 10:21:39
2 b 2000-01-02 00:00:00
3 x 2011-10-18 00:00:00
4 d 2003-12-01 05:01:03
5 c 2002-01-01 23:59:59
delete by primary key with order and limit
DELETE FROM ta_l2 WHERE a < 4 ORDER BY c LIMIT 1;
SHOW STATUS LIKE 'Spider_direct_delete';
Variable_name Value
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-02 10:21:39
3 x 2011-10-18 00:00:00
4 d 2003-12-01 05:01:03
5 c 2002-01-01 23:59:59
delete by a column without index
DELETE FROM ta_l2 WHERE b = 'c';
SHOW STATUS LIKE 'Spider_direct_delete';
Variable_name Value
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-02 10:21:39
3 x 2011-10-18 00:00:00
4 d 2003-12-01 05:01:03
delete by primary key
DELETE FROM ta_l2 WHERE a = 3;
SHOW STATUS LIKE 'Spider_direct_delete';
Variable_name Value
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-02 10:21:39
4 d 2003-12-01 05:01:03
deinit
connection master_1;
DROP DATABASE IF EXISTS auto_test_local;
connection child2_1;
DROP DATABASE IF EXISTS auto_test_remote;
connection child2_2;
DROP DATABASE IF EXISTS auto_test_remote2;
for master_1
for child2
child2_1
child2_2
child2_3
for child3
child3_1
child3_2
child3_3
end of test
......@@ -9,22 +9,27 @@ child3_2
child3_3
drop and create databases
connection master_1;
DROP DATABASE IF EXISTS auto_test_local;
CREATE DATABASE auto_test_local;
USE auto_test_local;
connection child2_1;
DROP DATABASE IF EXISTS auto_test_remote;
CREATE DATABASE auto_test_remote;
USE auto_test_remote;
connection child2_2;
DROP DATABASE IF EXISTS auto_test_remote2;
CREATE DATABASE auto_test_remote2;
USE auto_test_remote2;
test select 1
connection master_1;
SELECT 1;
1
1
in()
connection master_1;
CREATE TABLE t1 (
a VARCHAR(255),
PRIMARY KEY(a)
......@@ -41,12 +46,14 @@ insert into t1 select a + 128 from t1;
insert into t1 select a + 256 from t1;
insert into t1 select a + 512 from t1;
flush tables;
connection master_1;
select a from t1 where a in ('15', '120');
a
120
15
date_sub()
connection master_1;
DROP TABLE IF EXISTS ta_l;
CREATE TABLE ta_l (
a INT,
......@@ -124,6 +131,7 @@ a b date_format(c, '%Y-%m-%d %H:%i:%s')
4 d 2003-02-03 06:00:03
5 c 2001-03-07 00:58:59
UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 SECOND);
connection master_1;
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2007-10-07 11:20:40
......@@ -133,8 +141,11 @@ a b date_format(c, '%Y-%m-%d %H:%i:%s')
5 c 2001-03-07 00:59:00
deinit
connection master_1;
DROP DATABASE IF EXISTS auto_test_local;
connection child2_1;
DROP DATABASE IF EXISTS auto_test_remote;
connection child2_2;
DROP DATABASE IF EXISTS auto_test_remote2;
for master_1
for child2
......
for master_1
for child2
child2_1
child2_2
child2_3
for child3
child3_1
child3_2
child3_3
for master_1
for child2
child2_1
child2_2
child2_3
for child3
child3_1
child3_2
child3_3
drop and create databases
connection master_1;
DROP DATABASE IF EXISTS auto_test_local;
CREATE DATABASE auto_test_local;
USE auto_test_local;
connection child2_1;
DROP DATABASE IF EXISTS auto_test_remote;
CREATE DATABASE auto_test_remote;
USE auto_test_remote;
connection child2_2;
DROP DATABASE IF EXISTS auto_test_remote2;
CREATE DATABASE auto_test_remote2;
USE auto_test_remote2;
connection child2_3;
DROP DATABASE IF EXISTS auto_test_remote3;
CREATE DATABASE auto_test_remote3;
USE auto_test_remote3;
connection child3_1;
DROP DATABASE IF EXISTS auto_test_local;
CREATE DATABASE auto_test_local;
USE auto_test_local;
connection child3_2;
DROP DATABASE IF EXISTS auto_test_local;
CREATE DATABASE auto_test_local;
USE auto_test_local;
connection child3_3;
DROP DATABASE IF EXISTS auto_test_local;
CREATE DATABASE auto_test_local;
USE auto_test_local;
test select 1
connection master_1;
SELECT 1;
1
1
create table with partition test
connection master_1;
DROP TABLE IF EXISTS ta_l2;
CREATE TABLE ta_l2 (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_P_2_1
INSERT INTO ta_l2 (a, b, c) VALUES
(1, 'a', '2008-08-01 10:21:39'),
(2, 'b', '2000-01-01 00:00:00'),
(3, 'e', '2007-06-04 20:03:11'),
(4, 'd', '2003-11-30 05:01:03'),
(5, 'c', '2001-12-31 23:59:59');
select test
connection master_1;
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-01 10:21:39
2 b 2000-01-01 00:00:00
3 e 2007-06-04 20:03:11
4 d 2003-11-30 05:01:03
5 c 2001-12-31 23:59:59
fail-over test
connection master_1;
SHOW STATUS LIKE 'Spider_mon_table_cache_version%';
Variable_name Value
Spider_mon_table_cache_version 0
Spider_mon_table_cache_version_req 1
INSERT INTO ta_l2 (a, b, c) VALUES
(6, 'e', '2011-05-05 20:04:05');
ERROR HY000: Table 'auto_test_remote3.ta_r4' get a problem
SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables
ORDER BY db_name, table_name, link_id;
db_name table_name link_id link_status
auto_test_local ta_l2#P#pt1 0 1
auto_test_local ta_l2#P#pt1 1 1
auto_test_local ta_l2#P#pt2 0 1
auto_test_local ta_l2#P#pt2 1 3
SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log;
db_name table_name link_id
auto_test_local ta_l2#P#pt2 1
SHOW STATUS LIKE 'Spider_mon_table_cache_version%';
Variable_name Value
Spider_mon_table_cache_version 1
Spider_mon_table_cache_version_req 1
INSERT INTO ta_l2 (a, b, c) VALUES
(6, 'e', '2011-05-05 20:04:05');
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-01 10:21:39
2 b 2000-01-01 00:00:00
3 e 2007-06-04 20:03:11
4 d 2003-11-30 05:01:03
5 c 2001-12-31 23:59:59
6 e 2011-05-05 20:04:05
recovery test
connection master_1;
ALTER TABLE ta_l2
PARTITION BY KEY(a) (
PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3",
priority "1000"',
PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4",
priority "1000001", lst "0 2"'
);
SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables
ORDER BY db_name, table_name, link_id;
db_name table_name link_id link_status
auto_test_local ta_l2#P#pt1 0 1
auto_test_local ta_l2#P#pt1 1 1
auto_test_local ta_l2#P#pt2 0 1
auto_test_local ta_l2#P#pt2 1 2
SELECT spider_copy_tables('ta_l2#P#pt2', '0', '1');
spider_copy_tables('ta_l2#P#pt2', '0', '1')
1
connection master_1;
ALTER TABLE ta_l2
PARTITION BY KEY(a) (
PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3",
priority "1000"',
PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4",
priority "1000001", lst "0 1"'
);
SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables
ORDER BY db_name, table_name, link_id;
db_name table_name link_id link_status
auto_test_local ta_l2#P#pt1 0 1
auto_test_local ta_l2#P#pt1 1 1
auto_test_local ta_l2#P#pt2 0 1
auto_test_local ta_l2#P#pt2 1 1
INSERT INTO ta_l2 (a, b, c) VALUES
(8, 'g', '2011-05-05 21:33:30'),
(9, 'h', '2011-05-05 22:32:10');
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-01 10:21:39
2 b 2000-01-01 00:00:00
3 e 2007-06-04 20:03:11
4 d 2003-11-30 05:01:03
5 c 2001-12-31 23:59:59
6 e 2011-05-05 20:04:05
8 g 2011-05-05 21:33:30
9 h 2011-05-05 22:32:10
DROP TABLE ta_l2;
create table with partition test
connection master_1;
DROP TABLE IF EXISTS ta_l2;
CREATE TABLE ta_l2 (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_AS_P_2_1
INSERT INTO ta_l2 (a, b, c) VALUES
(1, 'a', '2008-08-01 10:21:39'),
(2, 'b', '2000-01-01 00:00:00'),
(3, 'e', '2007-06-04 20:03:11'),
(4, 'd', '2003-11-30 05:01:03'),
(5, 'c', '2001-12-31 23:59:59');
select test
connection master_1;
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-01 10:21:39
2 b 2000-01-01 00:00:00
3 e 2007-06-04 20:03:11
4 d 2003-11-30 05:01:03
5 c 2001-12-31 23:59:59
fail-over test
connection master_1;
SHOW STATUS LIKE 'Spider_mon_table_cache_version%';
Variable_name Value
Spider_mon_table_cache_version 1
Spider_mon_table_cache_version_req 1
INSERT INTO ta_l2 (a, b, c) VALUES
(6, 'e', '2011-05-05 20:04:05');
ERROR HY000: Table 'auto_test_remote.ta_r2' get a problem
SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables
ORDER BY db_name, table_name, link_id;
db_name table_name link_id link_status
auto_test_local ta_l2#P#pt1 0 1
auto_test_local ta_l2#P#pt1 1 1
auto_test_local ta_l2#P#pt2 0 3
auto_test_local ta_l2#P#pt2 1 1
SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log;
db_name table_name link_id
auto_test_local ta_l2#P#pt2 1
auto_test_local ta_l2#P#pt2 0
SHOW STATUS LIKE 'Spider_mon_table_cache_version%';
Variable_name Value
Spider_mon_table_cache_version 1
Spider_mon_table_cache_version_req 1
INSERT INTO ta_l2 (a, b, c) VALUES
(6, 'e', '2011-05-05 20:04:05');
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-01 10:21:39
3 e 2007-06-04 20:03:11
5 c 2001-12-31 23:59:59
6 e 2011-05-05 20:04:05
recovery test
connection master_1;
ALTER TABLE ta_l2
PARTITION BY KEY(a) (
PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3",
priority "1000"',
PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4",
priority "1000001", lst "1 0"'
);
SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables
ORDER BY db_name, table_name, link_id;
db_name table_name link_id link_status
auto_test_local ta_l2#P#pt1 0 1
auto_test_local ta_l2#P#pt1 1 1
auto_test_local ta_l2#P#pt2 0 1
auto_test_local ta_l2#P#pt2 1 1
INSERT INTO ta_l2 (a, b, c) VALUES
(8, 'g', '2011-05-05 21:33:30'),
(9, 'h', '2011-05-05 22:32:10');
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-01 10:21:39
3 e 2007-06-04 20:03:11
5 c 2001-12-31 23:59:59
8 g 2011-05-05 21:33:30
9 h 2011-05-05 22:32:10
DROP TABLE ta_l2;
deinit
connection master_1;
DROP DATABASE IF EXISTS auto_test_local;
connection child2_1;
DROP DATABASE IF EXISTS auto_test_remote;
connection child2_2;
DROP DATABASE IF EXISTS auto_test_remote2;
connection child2_3;
DROP DATABASE IF EXISTS auto_test_remote3;
connection child3_1;
DROP DATABASE IF EXISTS auto_test_local;
connection child3_2;
DROP DATABASE IF EXISTS auto_test_local;
connection child3_3;
DROP DATABASE IF EXISTS auto_test_local;
for master_1
for child2
child2_1
child2_2
child2_3
for child3
child3_1
child3_2
child3_3
for master_1
for child2
child2_1
child2_2
child2_3
for child3
child3_1
child3_2
child3_3
end of test
......@@ -10,26 +10,34 @@ child3_3
for slave1_1
drop and create databases
connection master_1;
DROP DATABASE IF EXISTS auto_test_local;
CREATE DATABASE auto_test_local;
USE auto_test_local;
connection slave1_1;
DROP DATABASE IF EXISTS auto_test_local;
CREATE DATABASE auto_test_local;
USE auto_test_local;
connection child2_1;
DROP DATABASE IF EXISTS auto_test_remote;
CREATE DATABASE auto_test_remote;
USE auto_test_remote;
connection child2_2;
DROP DATABASE IF EXISTS auto_test_remote2;
CREATE DATABASE auto_test_remote2;
USE auto_test_remote2;
test select 1
connection master_1;
SELECT 1;
1
1
3.1
auto_increment
connection master_1;
connection slave1_1;
connection master_1;
DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (
id int(11) NOT NULL AUTO_INCREMENT,
......@@ -198,6 +206,7 @@ LAST_INSERT_ID()
SELECT MAX(id) FROM t2;
MAX(id)
46
connection slave1_1;
SELECT id FROM t1 ORDER BY id;
id
2
......@@ -206,188 +215,16 @@ id
1554
2331
10000
auto_increment with partition
DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (
id int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1
CREATE TABLE t2 (
id int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1
MASTER_1_AUTO_INCREMENT_INCREMENT2
MASTER_1_AUTO_INCREMENT_OFFSET2
spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '',
'srv "s_2_1"')
1
spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '',
'srv "s_2_2"')
1
spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 2', '',
'srv "s_2_1"')
1
spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 3', '',
'srv "s_2_2"')
1
CREATE TABLE t1 (
id int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id)
) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_P_1
CREATE TABLE t2 (
id int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id)
) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_P_1
INSERT INTO t1 () VALUES ();
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
2
SELECT MAX(id) FROM t1;
MAX(id)
2
INSERT INTO t2 () VALUES ();
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
3
SELECT MAX(id) FROM t2;
MAX(id)
3
MASTER_1_AUTO_INCREMENT_OFFSET3
INSERT INTO t1 (id) VALUES (null);
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
7
SELECT MAX(id) FROM t1;
MAX(id)
7
MASTER_1_AUTO_INCREMENT_OFFSET4
INSERT INTO t2 (id) VALUES (null);
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
6
SELECT MAX(id) FROM t2;
MAX(id)
7
MASTER_1_AUTO_INCREMENT_OFFSET3
INSERT INTO t1 () VALUES (),(),(),();
Warnings:
Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
10
SELECT id FROM t1 ORDER BY id;
id
2
3
6
7
10
11
14
15
MASTER_1_AUTO_INCREMENT_OFFSET4
INSERT INTO t2 () VALUES (),(),(),();
Warnings:
Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
18
SELECT id FROM t2 ORDER BY id;
id
2
3
6
7
10
11
14
15
18
19
22
23
TRUNCATE TABLE t1;
TRUNCATE TABLE t2;
INSERT INTO t1 () VALUES (),(),(),();
Warnings:
Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
2
SELECT id FROM t1 ORDER BY id;
id
2
3
6
7
INSERT INTO t2 () VALUES (),(),(),();
Warnings:
Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
10
SELECT id FROM t2 ORDER BY id;
id
2
3
6
7
10
11
14
15
SET INSERT_ID=5000;
MASTER_1_AUTO_INCREMENT_OFFSET3
INSERT INTO t1 () VALUES ();
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
18
SELECT MAX(id) FROM t1;
MAX(id)
18
MASTER_1_AUTO_INCREMENT_OFFSET4
INSERT INTO t2 () VALUES ();
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
19
SELECT MAX(id) FROM t2;
MAX(id)
19
INSERT INTO t1 (id) VALUES (10000);
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
22
SELECT MAX(id) FROM t1;
MAX(id)
22
INSERT INTO t2 (id) VALUES (1000);
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
26
SELECT MAX(id) FROM t2;
MAX(id)
26
SELECT id FROM t1 ORDER BY id;
id
2
18
777
1554
2331
10000
connection master_1;
deinit
connection master_1;
DROP DATABASE IF EXISTS auto_test_local;
connection slave1_1;
DROP DATABASE IF EXISTS auto_test_local;
connection child2_1;
DROP DATABASE IF EXISTS auto_test_remote;
connection child2_2;
DROP DATABASE IF EXISTS auto_test_remote2;
for slave1_1
for master_1
......
for master_1
for child2
child2_1
child2_2
child2_3
for child3
child3_1
child3_2
child3_3
for slave1_1
drop and create databases
connection master_1;
DROP DATABASE IF EXISTS auto_test_local;
CREATE DATABASE auto_test_local;
USE auto_test_local;
connection slave1_1;
DROP DATABASE IF EXISTS auto_test_local;
CREATE DATABASE auto_test_local;
USE auto_test_local;
connection child2_1;
DROP DATABASE IF EXISTS auto_test_remote;
CREATE DATABASE auto_test_remote;
USE auto_test_remote;
connection child2_2;
DROP DATABASE IF EXISTS auto_test_remote2;
CREATE DATABASE auto_test_remote2;
USE auto_test_remote2;
test select 1
connection master_1;
SELECT 1;
1
1
auto_increment with partition
connection master_1;
connection slave1_1;
connection master_1;
DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (
id int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1
CREATE TABLE t2 (
id int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1
MASTER_1_AUTO_INCREMENT_INCREMENT2
MASTER_1_AUTO_INCREMENT_OFFSET2
spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '',
'srv "s_2_1"')
1
spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '',
'srv "s_2_2"')
1
spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 2', '',
'srv "s_2_1"')
1
spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 3', '',
'srv "s_2_2"')
1
CREATE TABLE t1 (
id int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id)
) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_P_1
CREATE TABLE t2 (
id int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id)
) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_P_1
INSERT INTO t1 () VALUES ();
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
3
SELECT MAX(id) FROM t1;
MAX(id)
3
INSERT INTO t2 () VALUES ();
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
7
SELECT MAX(id) FROM t2;
MAX(id)
7
MASTER_1_AUTO_INCREMENT_OFFSET3
INSERT INTO t1 (id) VALUES (null);
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
2
SELECT MAX(id) FROM t1;
MAX(id)
7
MASTER_1_AUTO_INCREMENT_OFFSET4
INSERT INTO t2 (id) VALUES (null);
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
6
SELECT MAX(id) FROM t2;
MAX(id)
7
MASTER_1_AUTO_INCREMENT_OFFSET3
INSERT INTO t1 () VALUES (),(),(),();
Warnings:
Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
10
SELECT id FROM t1 ORDER BY id;
id
2
3
6
7
10
11
14
15
MASTER_1_AUTO_INCREMENT_OFFSET4
INSERT INTO t2 () VALUES (),(),(),();
Warnings:
Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
18
SELECT id FROM t2 ORDER BY id;
id
2
3
6
7
10
11
14
15
18
19
22
23
TRUNCATE TABLE t1;
TRUNCATE TABLE t2;
INSERT INTO t1 () VALUES (),(),(),();
Warnings:
Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
2
SELECT id FROM t1 ORDER BY id;
id
2
3
6
7
INSERT INTO t2 () VALUES (),(),(),();
Warnings:
Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
10
SELECT id FROM t2 ORDER BY id;
id
2
3
6
7
10
11
14
15
SET INSERT_ID=5000;
MASTER_1_AUTO_INCREMENT_OFFSET3
INSERT INTO t1 () VALUES ();
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
18
SELECT MAX(id) FROM t1;
MAX(id)
18
MASTER_1_AUTO_INCREMENT_OFFSET4
INSERT INTO t2 () VALUES ();
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
19
SELECT MAX(id) FROM t2;
MAX(id)
19
INSERT INTO t1 (id) VALUES (10000);
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
22
SELECT MAX(id) FROM t1;
MAX(id)
22
INSERT INTO t2 (id) VALUES (1000);
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
26
SELECT MAX(id) FROM t2;
MAX(id)
26
connection slave1_1;
SELECT id FROM t1 ORDER BY id;
id
2
18
777
1554
2331
10000
connection master_1;
deinit
connection master_1;
DROP DATABASE IF EXISTS auto_test_local;
connection slave1_1;
DROP DATABASE IF EXISTS auto_test_local;
connection child2_1;
DROP DATABASE IF EXISTS auto_test_remote;
connection child2_2;
DROP DATABASE IF EXISTS auto_test_remote2;
for slave1_1
for master_1
for child2
child2_1
child2_2
child2_3
for child3
child3_1
child3_2
child3_3
end of test
for master_1
for child2
child2_1
child2_2
child2_3
for child3
child3_1
child3_2
child3_3
for slave1_1
drop and create databases
connection master_1;
DROP DATABASE IF EXISTS auto_test_local;
CREATE DATABASE auto_test_local;
USE auto_test_local;
connection slave1_1;
DROP DATABASE IF EXISTS auto_test_local;
CREATE DATABASE auto_test_local;
USE auto_test_local;
connection child2_1;
DROP DATABASE IF EXISTS auto_test_remote;
CREATE DATABASE auto_test_remote;
USE auto_test_remote;
connection child2_2;
DROP DATABASE IF EXISTS auto_test_remote2;
CREATE DATABASE auto_test_remote2;
USE auto_test_remote2;
test select 1
connection master_1;
SELECT 1;
1
1
connection master_1;
DROP TABLE IF EXISTS tb_l;
CREATE TABLE tb_l (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a)
) MASTER_1_ENGINE2 MASTER_1_CHARSET2
INSERT INTO tb_l (a, b, c) VALUES
(1, 'a', '2008-08-01 10:21:39'),
(2, 'b', '2000-01-01 00:00:00'),
(3, 'e', '2007-06-04 20:03:11'),
(4, 'd', '2003-11-30 05:01:03'),
(5, 'c', '2001-12-31 23:59:59');
2.17
partition with sort
connection master_1;
CREATE TABLE ta_l2 (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a)
) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1
INSERT INTO ta_l2 SELECT a, b, c FROM tb_l;
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 WHERE a > 1
ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
2 b 2000-01-01 00:00:00
3 e 2007-06-04 20:03:11
4 d 2003-11-30 05:01:03
5 c 2001-12-31 23:59:59
2.23
partition update with moving partition
connection master_1;
DROP TABLE IF EXISTS ta_l2;
connection master_1;
CREATE TABLE ta_l2 (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a)
) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1
INSERT INTO ta_l2 (a, b, c) VALUES (3, 'B', '2010-09-26 00:00:00');
UPDATE ta_l2 SET a = 4 WHERE a = 3;
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
4 B 2010-09-26 00:00:00
index merge with partition
connection master_1;
DROP TABLE IF EXISTS ta_l_int;
connection master_1;
CREATE TABLE ta_l_int (
a INT AUTO_INCREMENT,
b INT DEFAULT 10,
c INT DEFAULT 11,
PRIMARY KEY(a),
KEY idx1(b),
KEY idx2(c)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT3_P_2_1
INSERT INTO ta_l_int (a, b, c) VALUES (1, 2, 3);
INSERT INTO ta_l_int (a, b, c) SELECT a + 1, b + 1, c + 1 FROM ta_l_int;
INSERT INTO ta_l_int (a, b, c) SELECT a + 2, b + 2, c + 2 FROM ta_l_int;
INSERT INTO ta_l_int (a, b, c) SELECT a + 4, b + 4, c + 4 FROM ta_l_int;
INSERT INTO ta_l_int (a, b, c) SELECT a + 8, b + 8, c + 8 FROM ta_l_int;
connection master_1;
SELECT a, b, c FROM ta_l_int force index(primary, idx1, idx2)
WHERE a = 5 OR b = 5 OR c = 5 ORDER BY a;
a b c
3 4 5
4 5 6
5 6 7
2.26
auto_increment with partition
connection master_1;
connection slave1_1;
connection master_1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
id int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1
MASTER_1_AUTO_INCREMENT_INCREMENT2
MASTER_1_AUTO_INCREMENT_OFFSET2
spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '',
'srv "s_2_1"')
1
spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '',
'srv "s_2_2"')
1
spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 2', '',
'srv "s_2_1"')
1
spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 3', '',
'srv "s_2_2"')
1
CREATE TABLE t1 (
id int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id)
) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_P_1
INSERT INTO t1 () VALUES ();
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
3
SELECT MAX(id) FROM t1;
MAX(id)
3
INSERT INTO t1 () VALUES ();
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
2
SELECT MAX(id) FROM t1;
MAX(id)
3
INSERT INTO t1 (id) VALUES (null);
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
7
SELECT MAX(id) FROM t1;
MAX(id)
7
INSERT INTO t1 (id) VALUES (null);
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
6
SELECT MAX(id) FROM t1;
MAX(id)
7
INSERT INTO t1 () VALUES (),(),(),();
Warnings:
Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
10
SELECT id FROM t1 ORDER BY id;
id
2
3
6
7
10
11
14
15
SET INSERT_ID=5000;
INSERT INTO t1 () VALUES ();
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
18
SELECT MAX(id) FROM t1;
MAX(id)
18
INSERT INTO t1 (id) VALUES (10000);
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
22
SELECT MAX(id) FROM t1;
MAX(id)
22
INSERT INTO t1 (id) VALUES (1000);
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
26
SELECT MAX(id) FROM t1;
MAX(id)
26
connection slave1_1;
SELECT id FROM t1 ORDER BY id;
id
2
3
6
7
10
18
777
1000
1554
2331
10000
connection master_1;
deinit
connection master_1;
DROP DATABASE IF EXISTS auto_test_local;
connection slave1_1;
DROP DATABASE IF EXISTS auto_test_local;
connection child2_1;
DROP DATABASE IF EXISTS auto_test_remote;
connection child2_2;
DROP DATABASE IF EXISTS auto_test_remote2;
for slave1_1
for master_1
for child2
child2_1
child2_2
child2_3
for child3
child3_1
child3_2
child3_3
end of test
......@@ -9,22 +9,27 @@ child3_2
child3_3
drop and create databases
connection master_1;
DROP DATABASE IF EXISTS auto_test_local;
CREATE DATABASE auto_test_local;
USE auto_test_local;
connection child2_1;
DROP DATABASE IF EXISTS auto_test_remote;
CREATE DATABASE auto_test_remote;
USE auto_test_remote;
connection child2_2;
DROP DATABASE IF EXISTS auto_test_remote2;
CREATE DATABASE auto_test_remote2;
USE auto_test_remote2;
test select 1
connection master_1;
SELECT 1;
1
1
create table and insert
connection master_1;
DROP TABLE IF EXISTS tb_l;
CREATE TABLE tb_l (
a INT,
......@@ -46,26 +51,34 @@ INSERT INTO ta_l SELECT a, b, c FROM tb_l;
0.9
create different primary key table
connection master_1;
CREATE TABLE ta_l_int (
a INT DEFAULT 10,
b INT AUTO_INCREMENT,
c INT DEFAULT 11,
PRIMARY KEY(b)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1
connection master_1;
INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3);
create un-correspond primary key table
connection master_1;
DROP TABLE IF EXISTS ta_l_int;
connection master_1;
CREATE TABLE ta_l_int (
a INT DEFAULT 10,
b INT DEFAULT 12,
c INT DEFAULT 11,
PRIMARY KEY(c)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1
connection master_1;
INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3);
deinit
connection master_1;
DROP DATABASE IF EXISTS auto_test_local;
connection child2_1;
DROP DATABASE IF EXISTS auto_test_remote;
connection child2_2;
DROP DATABASE IF EXISTS auto_test_remote2;
for master_1
for child2
......
package My::Suite::Spider;
@ISA = qw(My::Suite);
return "No Spider engine" unless $ENV{HA_SPIDER_SO};
return "Not run for embedded server" if $::opt_embedded_server;
return "Test needs --big-test" unless $::opt_big_test;
sub is_default { 1 }
bless { };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment