Browse Source
- Fix good recognition of MYSQL table column types.
- Fix good recognition of MYSQL table column types.
modified: storage/connect/ha_connect.cc storage/connect/myconn.cpp storage/connect/myutil.cpp storage/connect/odbccat.h storage/connect/odbconn.cpp storage/connect/tabmysql.cpp - Add tests on new MYSQL features added: storage/connect/mysql-test/connect/my.cnf storage/connect/mysql-test/connect/r/mysql_discovery.result storage/connect/mysql-test/connect/r/mysql_exec.result storage/connect/mysql-test/connect/r/mysql_new.result storage/connect/mysql-test/connect/t/myconn.inc storage/connect/mysql-test/connect/t/myconn_cleanup.inc storage/connect/mysql-test/connect/t/mysql_discovery.test storage/connect/mysql-test/connect/t/mysql_exec.test storage/connect/mysql-test/connect/t/mysql_new.testpull/3/head
15 changed files with 844 additions and 27 deletions
-
44storage/connect/ha_connect.cc
-
2storage/connect/myconn.cpp
-
15storage/connect/mysql-test/connect/my.cnf
-
42storage/connect/mysql-test/connect/r/mysql_discovery.result
-
62storage/connect/mysql-test/connect/r/mysql_exec.result
-
218storage/connect/mysql-test/connect/r/mysql_new.result
-
27storage/connect/mysql-test/connect/t/myconn.inc
-
9storage/connect/mysql-test/connect/t/myconn_cleanup.inc
-
33storage/connect/mysql-test/connect/t/mysql_discovery.test
-
45storage/connect/mysql-test/connect/t/mysql_exec.test
-
325storage/connect/mysql-test/connect/t/mysql_new.test
-
34storage/connect/myutil.cpp
-
2storage/connect/odbccat.h
-
2storage/connect/odbconn.cpp
-
11storage/connect/tabmysql.cpp
@ -0,0 +1,15 @@ |
|||
# Use default setting for mysqld processes |
|||
!include include/default_mysqld.cnf |
|||
!include include/default_client.cnf |
|||
|
|||
[mysqld.1] |
|||
#log-bin= master-bin |
|||
|
|||
[mysqld.2] |
|||
|
|||
[ENV] |
|||
MASTER_MYPORT= @mysqld.1.port |
|||
MASTER_MYSOCK= @mysqld.1.socket |
|||
|
|||
SLAVE_MYPORT= @mysqld.2.port |
|||
SLAVE_MYSOCK= @mysqld.2.socket |
|||
@ -0,0 +1,42 @@ |
|||
CREATE DATABASE connect; |
|||
CREATE DATABASE connect; |
|||
CREATE TABLE t1 ( |
|||
`id` int(20) primary key, |
|||
`group` int NOT NULL default 1, |
|||
`a\\b` int NOT NULL default 2, |
|||
`a\\` int unsigned, |
|||
`name` varchar(32) default 'name') |
|||
DEFAULT CHARSET=latin1; |
|||
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=MYSQL |
|||
CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/test/t1'; |
|||
SHOW CREATE TABLE t1; |
|||
Table Create Table |
|||
t1 CREATE TABLE `t1` ( |
|||
`id` int(20) NOT NULL, |
|||
`group` int(11) NOT NULL, |
|||
`a\\b` int(11) NOT NULL, |
|||
`a\\` int(10) DEFAULT NULL, |
|||
`name` varchar(32) DEFAULT NULL |
|||
) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/test/t1' `TABLE_TYPE`='MYSQL' |
|||
INSERT INTO t1 (id, name) VALUES (1, 'foo'); |
|||
Warnings: |
|||
Warning 1364 Field 'group' doesn't have a default value |
|||
Warning 1364 Field 'a\\b' doesn't have a default value |
|||
INSERT INTO t1 (id, name) VALUES (2, 'fee'); |
|||
Warnings: |
|||
Warning 1364 Field 'group' doesn't have a default value |
|||
Warning 1364 Field 'a\\b' doesn't have a default value |
|||
SELECT * FROM t1; |
|||
id group a\\b a\\ name |
|||
1 1 2 NULL foo |
|||
2 1 2 NULL fee |
|||
DROP TABLE t1; |
|||
SELECT * FROM t1; |
|||
id group a\\b a\\ name |
|||
1 1 2 NULL foo |
|||
2 1 2 NULL fee |
|||
DROP TABLE t1; |
|||
DROP TABLE IF EXISTS connect.t1; |
|||
DROP DATABASE IF EXISTS connect; |
|||
DROP TABLE IF EXISTS connect.t1; |
|||
DROP DATABASE IF EXISTS connect; |
|||
@ -0,0 +1,62 @@ |
|||
CREATE DATABASE connect; |
|||
CREATE DATABASE connect; |
|||
# |
|||
# Checking Sending Commands |
|||
# |
|||
CREATE TABLE t1 ( |
|||
command VARCHAR(128) NOT NULL, |
|||
warnings INT(4) NOT NULL FLAG=3, |
|||
number INT(5) NOT NULL FLAG=1, |
|||
message VARCHAR(255) FLAG=2) |
|||
ENGINE=CONNECT TABLE_TYPE=MYSQL CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/test' OPTION_LIST='Execsrc=1,maxerr=2'; |
|||
SELECT * FROM t1 WHERE command IN ('Warning','Note', |
|||
'drop table if exists t1', |
|||
'create table t1 (id int key auto_increment, msg varchar(32) not null)', |
|||
"insert into t1(msg) values('One'),(NULL),('Three')", |
|||
"insert into t1 values(2,'Deux') on duplicate key update msg = 'Two'", |
|||
"insert into t1(message) values('Four'),('Five'),('Six')", |
|||
'insert into t1(id) values(NULL)', |
|||
"update t1 set msg = 'Four' where id = 4", |
|||
'select * from t1'); |
|||
command warnings number message |
|||
drop table if exists t1 1 0 Affected rows |
|||
Note 0 1051 Unknown table 'test.t1' |
|||
create table t1 (id int key auto_increment, msg varchar(32) not null) 0 0 Affected rows |
|||
insert into t1(msg) values('One'),(NULL),('Three') 1 3 Affected rows |
|||
Warning 0 1048 Column 'msg' cannot be null |
|||
insert into t1 values(2,'Deux') on duplicate key update msg = 'Two' 0 2 Affected rows |
|||
insert into t1(message) values('Four'),('Five'),('Six') 0 1054 Remote: Unknown column 'message' in 'field list' |
|||
insert into t1(id) values(NULL) 1 1 Affected rows |
|||
Warning 0 1364 Field 'msg' doesn't have a default value |
|||
update t1 set msg = 'Four' where id = 4 0 1 Affected rows |
|||
select * from t1 0 2 Result set columns |
|||
# |
|||
# Checking Using Procedure |
|||
# |
|||
DROP PROCEDURE IF EXISTS p1; |
|||
Warnings: |
|||
Note 1305 PROCEDURE test.p1 does not exist |
|||
CREATE PROCEDURE p1(cmd varchar(512)) |
|||
READS SQL DATA |
|||
SELECT * FROM t1 WHERE command IN ('Warning','Note',cmd); |
|||
CALL p1('insert into t1(id) values(NULL)'); |
|||
command warnings number message |
|||
insert into t1(id) values(NULL) 1 1 Affected rows |
|||
Warning 0 1364 Field 'msg' doesn't have a default value |
|||
CALL p1('update t1 set msg = "Five" where id = 5'); |
|||
command warnings number message |
|||
update t1 set msg = "Five" where id = 5 0 1 Affected rows |
|||
DROP PROCEDURE p1; |
|||
DROP TABLE t1; |
|||
SELECT * FROM t1; |
|||
id msg |
|||
1 One |
|||
2 Two |
|||
3 Three |
|||
4 Four |
|||
5 Five |
|||
DROP TABLE t1; |
|||
DROP TABLE IF EXISTS connect.t1; |
|||
DROP DATABASE IF EXISTS connect; |
|||
DROP TABLE IF EXISTS connect.t1; |
|||
DROP DATABASE IF EXISTS connect; |
|||
@ -0,0 +1,218 @@ |
|||
CREATE DATABASE connect; |
|||
CREATE DATABASE connect; |
|||
CREATE TABLE t1 (a int, b char(10)); |
|||
INSERT INTO t1 VALUES (NULL,NULL),(0,'test00'),(1,'test01'),(2,'test02'),(3,'test03'); |
|||
SELECT * FROM t1; |
|||
a b |
|||
NULL NULL |
|||
0 test00 |
|||
1 test01 |
|||
2 test02 |
|||
3 test03 |
|||
# |
|||
# Testing errors |
|||
# |
|||
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=MYSQL |
|||
CONNECTION='mysql://unknown@127.0.0.1:SLAVE_PORT/test/t1'; |
|||
ERROR HY000: (1045) Access denied for user 'unknown'@'localhost' (using password: NO) |
|||
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=MYSQL |
|||
CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/unknown/t1'; |
|||
ERROR HY000: (1049) Unknown database 'unknown' |
|||
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=MYSQL |
|||
OPTION_LIST='host=127.0.0.1,user=root,port=SLAVE_PORT' DBNAME='unknown' TABNAME='t1'; |
|||
ERROR HY000: (1049) Unknown database 'unknown' |
|||
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=MYSQL |
|||
CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/test/unknown'; |
|||
ERROR HY000: (1146) Table 'test.unknown' doesn't exist [SHOW FULL COLUMNS FROM unknown FROM test] |
|||
SHOW CREATE TABLE t1; |
|||
ERROR 42S02: Table 'test.t1' doesn't exist |
|||
CREATE TABLE t1 (x int, y char(10)) ENGINE=CONNECT TABLE_TYPE=MYSQL |
|||
CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/test/t1'; |
|||
SHOW CREATE TABLE t1; |
|||
Table Create Table |
|||
t1 CREATE TABLE `t1` ( |
|||
`x` int(11) DEFAULT NULL, |
|||
`y` char(10) DEFAULT NULL |
|||
) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/test/t1' `TABLE_TYPE`=MYSQL |
|||
SELECT * FROM t1; |
|||
ERROR HY000: Got error 174 '(1054) Unknown column 'x' in 'field list' [SELECT `x`, `y` FROM `t1`]' from CONNECT |
|||
DROP TABLE t1; |
|||
CREATE TABLE t1 (a int, b char(10)) ENGINE=CONNECT TABLE_TYPE=MYSQL |
|||
CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/test/t1'; |
|||
ALTER TABLE t1 RENAME t1backup; |
|||
SELECT * FROM t1; |
|||
ERROR HY000: Got error 174 '(1146) Table 'test.t1' doesn't exist [SELECT `a`, `b` FROM `t1`]' from CONNECT |
|||
ALTER TABLE t1backup RENAME t1; |
|||
DROP TABLE t1; |
|||
# |
|||
# Testing SELECT, etc. |
|||
# |
|||
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=MYSQL |
|||
CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/test/t1'; |
|||
SHOW CREATE TABLE t1; |
|||
Table Create Table |
|||
t1 CREATE TABLE `t1` ( |
|||
`a` int(11) DEFAULT NULL, |
|||
`b` char(10) DEFAULT NULL |
|||
) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/test/t1' `TABLE_TYPE`='MYSQL' |
|||
SELECT * FROM t1; |
|||
a b |
|||
NULL NULL |
|||
0 test00 |
|||
1 test01 |
|||
2 test02 |
|||
3 test03 |
|||
DROP TABLE t1; |
|||
CREATE TABLE t1 (a int, b char(10)) ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' |
|||
OPTION_LIST='host=127.0.0.1,user=root,port=SLAVE_PORT'; |
|||
SHOW CREATE TABLE t1; |
|||
Table Create Table |
|||
t1 CREATE TABLE `t1` ( |
|||
`a` int(11) DEFAULT NULL, |
|||
`b` char(10) DEFAULT NULL |
|||
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`=MYSQL `TABNAME`='t1' `OPTION_LIST`='host=127.0.0.1,user=root,port=SLAVE_PORT' |
|||
SELECT * FROM t1; |
|||
a b |
|||
NULL NULL |
|||
0 test00 |
|||
1 test01 |
|||
2 test02 |
|||
3 test03 |
|||
DROP TABLE t1; |
|||
CREATE TABLE t1 (a INT NOT NULL, b CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=MYSQL |
|||
OPTION_LIST='host=127.0.0.1,user=root,port=SLAVE_PORT'; |
|||
SHOW CREATE TABLE t1; |
|||
Table Create Table |
|||
t1 CREATE TABLE `t1` ( |
|||
`a` int(11) NOT NULL, |
|||
`b` char(10) NOT NULL |
|||
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`=MYSQL `OPTION_LIST`='host=127.0.0.1,user=root,port=SLAVE_PORT' |
|||
SELECT * FROM t1; |
|||
a b |
|||
0 |
|||
0 test00 |
|||
1 test01 |
|||
2 test02 |
|||
3 test03 |
|||
DROP TABLE t1; |
|||
CREATE TABLE t1 (a char(10), b int) ENGINE=CONNECT TABLE_TYPE=MYSQL |
|||
CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/test/t1'; |
|||
SHOW CREATE TABLE t1; |
|||
Table Create Table |
|||
t1 CREATE TABLE `t1` ( |
|||
`a` char(10) DEFAULT NULL, |
|||
`b` int(11) DEFAULT NULL |
|||
) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/test/t1' `TABLE_TYPE`=MYSQL |
|||
SELECT * FROM t1; |
|||
a b |
|||
NULL NULL |
|||
0 0 |
|||
1 0 |
|||
2 0 |
|||
3 0 |
|||
DROP TABLE t1; |
|||
DROP TABLE t1; |
|||
# |
|||
# Testing numeric data types |
|||
# |
|||
CREATE TABLE t1 (a tinyint, b smallint, c mediumint, d int, e bigint, f float, g double, h decimal(20,5)); |
|||
SHOW CREATE TABLE t1; |
|||
Table Create Table |
|||
t1 CREATE TABLE `t1` ( |
|||
`a` tinyint(4) DEFAULT NULL, |
|||
`b` smallint(6) DEFAULT NULL, |
|||
`c` mediumint(9) DEFAULT NULL, |
|||
`d` int(11) DEFAULT NULL, |
|||
`e` bigint(20) DEFAULT NULL, |
|||
`f` float DEFAULT NULL, |
|||
`g` double DEFAULT NULL, |
|||
`h` decimal(20,5) DEFAULT NULL |
|||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
|||
INSERT INTO t1 VALUES(100,3333,41235,1234567890,235000000000,3.14159265,3.14159265,3141.59265); |
|||
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=MYSQL |
|||
OPTION_LIST='host=127.0.0.1,user=root,port=SLAVE_PORT'; |
|||
SHOW CREATE TABLE t1; |
|||
Table Create Table |
|||
t1 CREATE TABLE `t1` ( |
|||
`a` tinyint(4) DEFAULT NULL, |
|||
`b` smallint(6) DEFAULT NULL, |
|||
`c` int(9) DEFAULT NULL, |
|||
`d` int(11) DEFAULT NULL, |
|||
`e` bigint(20) DEFAULT NULL, |
|||
`f` double DEFAULT NULL, |
|||
`g` double DEFAULT NULL, |
|||
`h` double(20,5) DEFAULT NULL |
|||
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`='MYSQL' `OPTION_LIST`='host=127.0.0.1,user=root,port=SLAVE_PORT' |
|||
SELECT * FROM t1; |
|||
a b c d e f g h |
|||
100 3333 41235 1234567890 235000000000 3.14159 3.14159265 3141.59265 |
|||
DROP TABLE t1; |
|||
DROP TABLE t1; |
|||
# |
|||
# Testing character data types |
|||
# |
|||
CREATE TABLE t1 (a char(12), b varchar(12)); |
|||
SHOW CREATE TABLE t1; |
|||
Table Create Table |
|||
t1 CREATE TABLE `t1` ( |
|||
`a` char(12) DEFAULT NULL, |
|||
`b` varchar(12) DEFAULT NULL |
|||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
|||
INSERT INTO t1 VALUES('Welcome','Hello, World'); |
|||
SELECT * FROM t1; |
|||
a b |
|||
Welcome Hello, World |
|||
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=MYSQL |
|||
CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT'; |
|||
SHOW CREATE TABLE t1; |
|||
Table Create Table |
|||
t1 CREATE TABLE `t1` ( |
|||
`a` char(12) DEFAULT NULL, |
|||
`b` varchar(12) DEFAULT NULL |
|||
) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT' `TABLE_TYPE`='MYSQL' |
|||
SELECT * FROM t1; |
|||
a b |
|||
Welcome Hello, World |
|||
DROP TABLE t1; |
|||
DROP TABLE t1; |
|||
# |
|||
# Testing temporal data types |
|||
# |
|||
CREATE TABLE t1 (a date, b datetime, c time, d timestamp, e year); |
|||
SHOW CREATE TABLE t1; |
|||
Table Create Table |
|||
t1 CREATE TABLE `t1` ( |
|||
`a` date DEFAULT NULL, |
|||
`b` datetime DEFAULT NULL, |
|||
`c` time DEFAULT NULL, |
|||
`d` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, |
|||
`e` year(4) DEFAULT NULL |
|||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
|||
INSERT INTO t1 VALUES('2003-05-27 10:45:23','2003-05-27 10:45:23','2003-05-27 10:45:23','2003-05-27 10:45:23','2003-05-27 10:45:23'); |
|||
Warnings: |
|||
Note 1265 Data truncated for column 'a' at row 1 |
|||
Note 1265 Data truncated for column 'c' at row 1 |
|||
Warning 1265 Data truncated for column 'e' at row 1 |
|||
SELECT * FROM t1; |
|||
a b c d e |
|||
2003-05-27 2003-05-27 10:45:23 10:45:23 2003-05-27 10:45:23 2003 |
|||
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=MYSQL |
|||
CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT'; |
|||
SHOW CREATE TABLE t1; |
|||
Table Create Table |
|||
t1 CREATE TABLE `t1` ( |
|||
`a` date DEFAULT NULL, |
|||
`b` datetime DEFAULT NULL, |
|||
`c` time DEFAULT NULL, |
|||
`d` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', |
|||
`e` year(4) DEFAULT NULL |
|||
) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT' `TABLE_TYPE`='MYSQL' |
|||
SELECT * FROM t1; |
|||
a b c d e |
|||
2003-05-27 2003-05-27 10:45:23 10:45:23 2003-05-27 10:45:23 2003 |
|||
DROP TABLE t1; |
|||
DROP TABLE t1; |
|||
DROP TABLE IF EXISTS connect.t1; |
|||
DROP DATABASE IF EXISTS connect; |
|||
DROP TABLE IF EXISTS connect.t1; |
|||
DROP DATABASE IF EXISTS connect; |
|||
@ -0,0 +1,27 @@ |
|||
--source include/not_embedded.inc |
|||
|
|||
let $PORT= `select @@port`; |
|||
|
|||
--disable_query_log |
|||
--replace_result $PORT PORT |
|||
--error 0,ER_UNKNOWN_ERROR |
|||
eval CREATE TABLE t1 (a INT) ENGINE=CONNECT TABLE_TYPE=MYSQL |
|||
CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/tx1'; |
|||
if (!`SELECT count(*) FROM INFORMATION_SCHEMA.TABLES |
|||
WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1' |
|||
AND ENGINE='CONNECT' |
|||
AND CREATE_OPTIONS LIKE '%`table_type`=MySQL%'`) |
|||
{ |
|||
Skip Need MySQL support; |
|||
} |
|||
DROP TABLE t1; |
|||
--enable_query_log |
|||
|
|||
connect (master,127.0.0.1,root,,test,$MASTER_MYPORT,); |
|||
connect (slave,127.0.0.1,root,,test,$SLAVE_MYPORT,); |
|||
|
|||
connection master; |
|||
CREATE DATABASE connect; |
|||
|
|||
connection slave; |
|||
CREATE DATABASE connect; |
|||
@ -0,0 +1,9 @@ |
|||
connection master; |
|||
--disable_warnings |
|||
DROP TABLE IF EXISTS connect.t1; |
|||
DROP DATABASE IF EXISTS connect; |
|||
|
|||
connection slave; |
|||
DROP TABLE IF EXISTS connect.t1; |
|||
DROP DATABASE IF EXISTS connect; |
|||
--enable_warnings |
|||
@ -0,0 +1,33 @@ |
|||
-- source myconn.inc |
|||
|
|||
connection slave; |
|||
|
|||
CREATE TABLE t1 ( |
|||
`id` int(20) primary key, |
|||
`group` int NOT NULL default 1, |
|||
`a\\b` int NOT NULL default 2, |
|||
`a\\` int unsigned, |
|||
`name` varchar(32) default 'name') |
|||
DEFAULT CHARSET=latin1; |
|||
|
|||
connection master; |
|||
|
|||
--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=MYSQL |
|||
CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1'; |
|||
|
|||
--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
SHOW CREATE TABLE t1; |
|||
INSERT INTO t1 (id, name) VALUES (1, 'foo'); |
|||
INSERT INTO t1 (id, name) VALUES (2, 'fee'); |
|||
--sorted_result |
|||
SELECT * FROM t1; |
|||
DROP TABLE t1; |
|||
|
|||
connection slave; |
|||
--sorted_result |
|||
SELECT * FROM t1; |
|||
DROP TABLE t1; |
|||
|
|||
-- source myconn_cleanup.inc |
|||
|
|||
@ -0,0 +1,45 @@ |
|||
-- source myconn.inc |
|||
|
|||
--echo # |
|||
--echo # Checking Sending Commands |
|||
--echo # |
|||
connection master; |
|||
|
|||
--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
eval CREATE TABLE t1 ( |
|||
command VARCHAR(128) NOT NULL, |
|||
warnings INT(4) NOT NULL FLAG=3, |
|||
number INT(5) NOT NULL FLAG=1, |
|||
message VARCHAR(255) FLAG=2) |
|||
ENGINE=CONNECT TABLE_TYPE=MYSQL CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/test' OPTION_LIST='Execsrc=1,maxerr=2'; |
|||
|
|||
SELECT * FROM t1 WHERE command IN ('Warning','Note', |
|||
'drop table if exists t1', |
|||
'create table t1 (id int key auto_increment, msg varchar(32) not null)', |
|||
"insert into t1(msg) values('One'),(NULL),('Three')", |
|||
"insert into t1 values(2,'Deux') on duplicate key update msg = 'Two'", |
|||
"insert into t1(message) values('Four'),('Five'),('Six')", |
|||
'insert into t1(id) values(NULL)', |
|||
"update t1 set msg = 'Four' where id = 4", |
|||
'select * from t1'); |
|||
|
|||
--echo # |
|||
--echo # Checking Using Procedure |
|||
--echo # |
|||
DROP PROCEDURE IF EXISTS p1; |
|||
CREATE PROCEDURE p1(cmd varchar(512)) |
|||
READS SQL DATA |
|||
SELECT * FROM t1 WHERE command IN ('Warning','Note',cmd); |
|||
|
|||
CALL p1('insert into t1(id) values(NULL)'); |
|||
CALL p1('update t1 set msg = "Five" where id = 5'); |
|||
DROP PROCEDURE p1; |
|||
DROP TABLE t1; |
|||
|
|||
connection slave; |
|||
--sorted_result |
|||
SELECT * FROM t1; |
|||
DROP TABLE t1; |
|||
|
|||
-- source myconn_cleanup.inc |
|||
|
|||
@ -0,0 +1,325 @@ |
|||
-- source myconn.inc |
|||
|
|||
# |
|||
# This test is run against a remote MySQL server |
|||
# |
|||
|
|||
connection slave; |
|||
|
|||
CREATE TABLE t1 (a int, b char(10)); |
|||
INSERT INTO t1 VALUES (NULL,NULL),(0,'test00'),(1,'test01'),(2,'test02'),(3,'test03'); |
|||
SELECT * FROM t1; |
|||
|
|||
--echo # |
|||
--echo # Testing errors |
|||
--echo # |
|||
connection master; |
|||
|
|||
# Bad user name |
|||
# Suppress "mysql_real_connect failed:" (printed in _DEBUG build) |
|||
--replace_result $SLAVE_MYPORT SLAVE_PORT "mysql_real_connect failed: " "" |
|||
--error ER_UNKNOWN_ERROR |
|||
eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=MYSQL |
|||
CONNECTION='mysql://unknown@127.0.0.1:$SLAVE_MYPORT/test/t1'; |
|||
|
|||
# Bad database name |
|||
--replace_result $SLAVE_MYPORT SLAVE_PORT "mysql_real_connect failed: " "" |
|||
--error ER_UNKNOWN_ERROR |
|||
eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=MYSQL |
|||
CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/unknown/t1'; |
|||
|
|||
# Bad database name, with OPTION_LIST going first. |
|||
--replace_result $SLAVE_MYPORT SLAVE_PORT "mysql_real_connect failed: " "" |
|||
--error ER_UNKNOWN_ERROR |
|||
eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=MYSQL |
|||
OPTION_LIST='host=127.0.0.1,user=root,port=$SLAVE_MYPORT' DBNAME='unknown' TABNAME='t1'; |
|||
|
|||
# Bad table name |
|||
--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
--error ER_UNKNOWN_ERROR |
|||
eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=MYSQL |
|||
CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/unknown'; |
|||
--error ER_NO_SUCH_TABLE |
|||
SHOW CREATE TABLE t1; |
|||
|
|||
# Bad column name |
|||
--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
eval CREATE TABLE t1 (x int, y char(10)) ENGINE=CONNECT TABLE_TYPE=MYSQL |
|||
CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1'; |
|||
--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
SHOW CREATE TABLE t1; |
|||
--error ER_GET_ERRMSG |
|||
SELECT * FROM t1; |
|||
DROP TABLE t1; |
|||
|
|||
# The remote table disappeared |
|||
--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
eval CREATE TABLE t1 (a int, b char(10)) ENGINE=CONNECT TABLE_TYPE=MYSQL |
|||
CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1'; |
|||
|
|||
connection slave; |
|||
ALTER TABLE t1 RENAME t1backup; |
|||
|
|||
connection master; |
|||
--error ER_GET_ERRMSG |
|||
SELECT * FROM t1; |
|||
|
|||
connection slave; |
|||
ALTER TABLE t1backup RENAME t1; |
|||
|
|||
connection master; |
|||
DROP TABLE t1; |
|||
|
|||
--echo # |
|||
--echo # Testing SELECT, etc. |
|||
--echo # |
|||
|
|||
# Automatic table structure |
|||
--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=MYSQL |
|||
CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1'; |
|||
--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
SHOW CREATE TABLE t1; |
|||
SELECT * FROM t1; |
|||
DROP TABLE t1; |
|||
|
|||
# Explicit table structure |
|||
--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
eval CREATE TABLE t1 (a int, b char(10)) ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' |
|||
OPTION_LIST='host=127.0.0.1,user=root,port=$SLAVE_MYPORT'; |
|||
--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
SHOW CREATE TABLE t1; |
|||
SELECT * FROM t1; |
|||
DROP TABLE t1; |
|||
|
|||
# Explicit table structure: remote NULL, local NOT NULL |
|||
--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
eval CREATE TABLE t1 (a INT NOT NULL, b CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=MYSQL |
|||
OPTION_LIST='host=127.0.0.1,user=root,port=$SLAVE_MYPORT'; |
|||
--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
SHOW CREATE TABLE t1; |
|||
SELECT * FROM t1; |
|||
DROP TABLE t1; |
|||
|
|||
# Explicit table structure with wrong column types |
|||
--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
eval CREATE TABLE t1 (a char(10), b int) ENGINE=CONNECT TABLE_TYPE=MYSQL |
|||
CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1'; |
|||
--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
SHOW CREATE TABLE t1; |
|||
SELECT * FROM t1; |
|||
DROP TABLE t1; |
|||
|
|||
connection slave; |
|||
DROP TABLE t1; |
|||
|
|||
--echo # |
|||
--echo # Testing numeric data types |
|||
--echo # |
|||
|
|||
# TODO: mediumint is converted to int, float is converted to double, decimal is converted to double |
|||
CREATE TABLE t1 (a tinyint, b smallint, c mediumint, d int, e bigint, f float, g double, h decimal(20,5)); |
|||
SHOW CREATE TABLE t1; |
|||
INSERT INTO t1 VALUES(100,3333,41235,1234567890,235000000000,3.14159265,3.14159265,3141.59265); |
|||
|
|||
connection master; |
|||
--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=MYSQL |
|||
OPTION_LIST='host=127.0.0.1,user=root,port=$SLAVE_MYPORT'; |
|||
--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
SHOW CREATE TABLE t1; |
|||
SELECT * FROM t1; |
|||
DROP TABLE t1; |
|||
|
|||
connection slave; |
|||
DROP TABLE t1; |
|||
|
|||
# TODO: unsigned does not work |
|||
#CREATE TABLE t1 (a tinyint unsigned); |
|||
#SHOW CREATE TABLE t1; |
|||
|
|||
#connection master; |
|||
#--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
#eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=127.0.0.1,user=root,port=$SLAVE_MYPORT'; |
|||
#--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
#SHOW CREATE TABLE t1; |
|||
#SELECT * FROM t1; |
|||
#DROP TABLE t1; |
|||
|
|||
#connection slave; |
|||
#DROP TABLE t1; |
|||
|
|||
# TODO: add test for BIT |
|||
|
|||
--echo # |
|||
--echo # Testing character data types |
|||
--echo # |
|||
|
|||
CREATE TABLE t1 (a char(12), b varchar(12)); |
|||
SHOW CREATE TABLE t1; |
|||
INSERT INTO t1 VALUES('Welcome','Hello, World'); |
|||
SELECT * FROM t1; |
|||
|
|||
connection master; |
|||
--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=MYSQL |
|||
CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT'; |
|||
--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
SHOW CREATE TABLE t1; |
|||
SELECT * FROM t1; |
|||
DROP TABLE t1; |
|||
|
|||
connection slave; |
|||
DROP TABLE t1; |
|||
|
|||
# TODO: ERROR 1105: Unsupported column type tinytext |
|||
#CREATE TABLE t1 (a tinytext); |
|||
#--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
#eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=127.0.0.1,user=root,port=$SLAVE_MYPORT' |
|||
#--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
#SHOW CREATE TABLE t1; |
|||
#--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
#SHOW CREATE TABLE t1; |
|||
#SELECT * FROM t1; |
|||
#DROP TABLE t1, t1; |
|||
|
|||
# TODO: ERROR 1105: Unsupported column type mediumtext |
|||
#CREATE TABLE t1 (a mediumtext); |
|||
#--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
#eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=127.0.0.1,user=root,port=$SLAVE_MYPORT' |
|||
#--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
#SHOW CREATE TABLE t1; |
|||
#--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
#SHOW CREATE TABLE t1; |
|||
#SELECT * FROM t1; |
|||
#DROP TABLE t1, t1; |
|||
|
|||
# TODO: text is converted to varchar(256) |
|||
#CREATE TABLE t1 (a text); |
|||
#--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
#eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=127.0.0.1,user=root,port=$SLAVE_MYPORT' |
|||
#--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
#SHOW CREATE TABLE t1; |
|||
#--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
#SHOW CREATE TABLE t1; |
|||
#SELECT * FROM t1; |
|||
#DROP TABLE t1, t1; |
|||
|
|||
# TODO: ERROR 1105: Unsupported column type longtext |
|||
#CREATE TABLE t1 (a longtext); |
|||
#--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
#eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=127.0.0.1,user=root,port=$SLAVE_MYPORT' |
|||
#--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
#SHOW CREATE TABLE t1; |
|||
#--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
#SHOW CREATE TABLE t1; |
|||
#SELECT * FROM t1; |
|||
#DROP TABLE t1, t1; |
|||
|
|||
#TODO: add tests for ENUM |
|||
#TODO: add tests for SET |
|||
|
|||
#--echo # |
|||
#--echo # Testing binary data types |
|||
#--echo # |
|||
|
|||
# TODO: ERROR 1105: Unsupported column type binary |
|||
#CREATE TABLE t1 (a binary(10)); |
|||
#--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
#eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=127.0.0.1,user=root,port=$SLAVE_MYPORT' |
|||
#--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
#SHOW CREATE TABLE t1; |
|||
#--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
#SHOW CREATE TABLE t1; |
|||
#SELECT * FROM t1; |
|||
#DROP TABLE t1, t1; |
|||
|
|||
# TODO: ERROR 1105: Unsupported column type varbinary |
|||
#CREATE TABLE t1 (a varbinary(10)); |
|||
#--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
#eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=127.0.0.1,user=root,port=$SLAVE_MYPORT' |
|||
#--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
#SHOW CREATE TABLE t1; |
|||
#--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
#SHOW CREATE TABLE t1; |
|||
#SELECT * FROM t1; |
|||
#DROP TABLE t1, t1; |
|||
|
|||
# TODO: ERROR 1105: Unsupported column type tinyblob |
|||
#CREATE TABLE t1 (a tinyblob); |
|||
#--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
#eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=127.0.0.1,user=root,port=$SLAVE_MYPORT' |
|||
#--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
#SHOW CREATE TABLE t1; |
|||
#--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
#SHOW CREATE TABLE t1; |
|||
#SELECT * FROM t1; |
|||
#DROP TABLE t1, t1; |
|||
|
|||
# TODO: ERROR 1105: Unsupported column type mediumblob |
|||
#CREATE TABLE t1 (a mediumblob); |
|||
#--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
#eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=127.0.0.1,user=root,port=$SLAVE_MYPORT' |
|||
#--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
#SHOW CREATE TABLE t1; |
|||
#--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
#SHOW CREATE TABLE t1; |
|||
#SELECT * FROM t1; |
|||
#DROP TABLE t1, t1; |
|||
|
|||
# TODO: blob is converted to varchar(256) |
|||
#CREATE TABLE t1 (a blob); |
|||
#--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
#eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=127.0.0.1,user=root,port=$SLAVE_MYPORT' |
|||
#--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
#SHOW CREATE TABLE t1; |
|||
#--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
#SHOW CREATE TABLE t1; |
|||
#SELECT * FROM t1; |
|||
#DROP TABLE t1, t1; |
|||
|
|||
# TODO: ERROR 1105: Unsupported column type longblob |
|||
#CREATE TABLE t1 (a longblob); |
|||
#--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
#eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=127.0.0.1,user=root,port=$SLAVE_MYPORT' |
|||
#--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
#SHOW CREATE TABLE t1; |
|||
#--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
#SHOW CREATE TABLE t1; |
|||
#SELECT * FROM t1; |
|||
#DROP TABLE t1, t1; |
|||
|
|||
# TODO: ERROR 1105: Unsupported column type geometry |
|||
#CREATE TABLE t1 (a geometry); |
|||
#--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
#eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=127.0.0.1,user=root,port=$SLAVE_MYPORT' |
|||
#--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
#SHOW CREATE TABLE t1; |
|||
#--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
#SHOW CREATE TABLE t1; |
|||
#SELECT * FROM t1; |
|||
#DROP TABLE t1, t1; |
|||
|
|||
--echo # |
|||
--echo # Testing temporal data types |
|||
--echo # |
|||
|
|||
CREATE TABLE t1 (a date, b datetime, c time, d timestamp, e year); |
|||
SHOW CREATE TABLE t1; |
|||
INSERT INTO t1 VALUES('2003-05-27 10:45:23','2003-05-27 10:45:23','2003-05-27 10:45:23','2003-05-27 10:45:23','2003-05-27 10:45:23'); |
|||
SELECT * FROM t1; |
|||
|
|||
connection master; |
|||
--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=MYSQL |
|||
CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT'; |
|||
--replace_result $SLAVE_MYPORT SLAVE_PORT |
|||
SHOW CREATE TABLE t1; |
|||
SELECT * FROM t1; |
|||
DROP TABLE t1; |
|||
|
|||
connection slave; |
|||
DROP TABLE t1; |
|||
|
|||
-- source myconn_cleanup.inc |
|||
|
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue