mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
- 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.test
This commit is contained in:
@@ -1308,6 +1308,9 @@ int ha_connect::MakeRecord(char *buf)
|
|||||||
case MYSQL_TYPE_TIME:
|
case MYSQL_TYPE_TIME:
|
||||||
fmt= "%H:%M:%S";
|
fmt= "%H:%M:%S";
|
||||||
break;
|
break;
|
||||||
|
case MYSQL_TYPE_YEAR:
|
||||||
|
fmt= "%Y";
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
fmt= "%Y-%m-%d %H:%M:%S";
|
fmt= "%Y-%m-%d %H:%M:%S";
|
||||||
break;
|
break;
|
||||||
@@ -1409,24 +1412,25 @@ int ha_connect::ScanRecord(PGLOBAL g, uchar *buf)
|
|||||||
value->SetValue(fp->val_real());
|
value->SetValue(fp->val_real());
|
||||||
break;
|
break;
|
||||||
case TYPE_DATE:
|
case TYPE_DATE:
|
||||||
if (!sdvalin) {
|
if (!sdvalin)
|
||||||
sdvalin= (DTVAL*)AllocateValue(xp->g, TYPE_DATE, 19);
|
sdvalin= (DTVAL*)AllocateValue(xp->g, TYPE_DATE, 19);
|
||||||
|
|
||||||
// Get date in the format produced by MySQL fields
|
// Get date in the format produced by MySQL fields
|
||||||
switch (fp->type()) {
|
switch (fp->type()) {
|
||||||
case MYSQL_TYPE_DATE:
|
case MYSQL_TYPE_DATE:
|
||||||
fmt= "YYYY-MM-DD";
|
fmt= "YYYY-MM-DD";
|
||||||
break;
|
break;
|
||||||
case MYSQL_TYPE_TIME:
|
case MYSQL_TYPE_TIME:
|
||||||
fmt= "hh:mm:ss";
|
fmt= "hh:mm:ss";
|
||||||
break;
|
break;
|
||||||
default:
|
case MYSQL_TYPE_YEAR:
|
||||||
fmt= "YYYY-MM-DD hh:mm:ss";
|
fmt= "YYYY";
|
||||||
} // endswitch type
|
break;
|
||||||
|
default:
|
||||||
((DTVAL*)sdvalin)->SetFormat(g, fmt, strlen(fmt));
|
fmt= "YYYY-MM-DD hh:mm:ss";
|
||||||
} // endif sdvalin
|
} // endswitch type
|
||||||
|
|
||||||
|
((DTVAL*)sdvalin)->SetFormat(g, fmt, strlen(fmt));
|
||||||
fp->val_str(&attribute);
|
fp->val_str(&attribute);
|
||||||
sdvalin->SetValue_psz(attribute.c_ptr_safe());
|
sdvalin->SetValue_psz(attribute.c_ptr_safe());
|
||||||
value->SetValue_pval(sdvalin);
|
value->SetValue_pval(sdvalin);
|
||||||
@@ -3867,7 +3871,9 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
|
|||||||
#endif // WIN32
|
#endif // WIN32
|
||||||
port= atoi(GetListOption(g, "port", topt->oplist, "0"));
|
port= atoi(GetListOption(g, "port", topt->oplist, "0"));
|
||||||
mxr= atoi(GetListOption(g,"maxerr", topt->oplist, "0"));
|
mxr= atoi(GetListOption(g,"maxerr", topt->oplist, "0"));
|
||||||
|
#if defined(PROMPT_OK)
|
||||||
cop= atoi(GetListOption(g, "checkdsn", topt->oplist, "0"));
|
cop= atoi(GetListOption(g, "checkdsn", topt->oplist, "0"));
|
||||||
|
#endif // PROMPT_OK
|
||||||
} else {
|
} else {
|
||||||
host= "localhost";
|
host= "localhost";
|
||||||
user= "root";
|
user= "root";
|
||||||
@@ -3925,14 +3931,16 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
|
|||||||
case TAB_ODBC:
|
case TAB_ODBC:
|
||||||
dsn= create_info->connect_string.str;
|
dsn= create_info->connect_string.str;
|
||||||
|
|
||||||
if (fnc & (FNC_DSN | FNC_DRIVER))
|
if (fnc & (FNC_DSN | FNC_DRIVER)) {
|
||||||
ok= true;
|
ok= true;
|
||||||
else if (!stricmp(thd->main_security_ctx.host, "localhost")
|
#if defined(PROMPT_OK)
|
||||||
|
} else if (!stricmp(thd->main_security_ctx.host, "localhost")
|
||||||
&& cop == 1) {
|
&& cop == 1) {
|
||||||
if ((dsn = ODBCCheckConnection(g, dsn, cop)) != NULL) {
|
if ((dsn = ODBCCheckConnection(g, dsn, cop)) != NULL) {
|
||||||
thd->make_lex_string(&create_info->connect_string, dsn, strlen(dsn));
|
thd->make_lex_string(&create_info->connect_string, dsn, strlen(dsn));
|
||||||
ok= true;
|
ok= true;
|
||||||
} // endif dsn
|
} // endif dsn
|
||||||
|
#endif // PROMPT_OK
|
||||||
|
|
||||||
} else if (!dsn)
|
} else if (!dsn)
|
||||||
sprintf(g->Message, "Missing %s connection string", topt->type);
|
sprintf(g->Message, "Missing %s connection string", topt->type);
|
||||||
@@ -4224,7 +4232,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
|
|||||||
rc= add_fields(g, thd, &alter_info, cnm, typ, len, dec,
|
rc= add_fields(g, thd, &alter_info, cnm, typ, len, dec,
|
||||||
tm, rem, 0, true);
|
tm, rem, 0, true);
|
||||||
#else // !NEW_WAY
|
#else // !NEW_WAY
|
||||||
if (add_field(&sql, cnm, typ, len, dec, tm, rem, 0, true, v))
|
if (add_field(&sql, cnm, typ, len, dec, tm, rem, 0, dbf, v))
|
||||||
rc= HA_ERR_OUT_OF_MEM;
|
rc= HA_ERR_OUT_OF_MEM;
|
||||||
#endif // !NEW_WAY
|
#endif // !NEW_WAY
|
||||||
} // endfor i
|
} // endfor i
|
||||||
|
@@ -182,7 +182,7 @@ PQRYRES MyColumns(PGLOBAL g, const char *host, const char *db,
|
|||||||
myc.Close();
|
myc.Close();
|
||||||
return NULL;
|
return NULL;
|
||||||
} else if (type == TYPE_STRING)
|
} else if (type == TYPE_STRING)
|
||||||
len = min(len, 255);
|
len = min(len, 4096);
|
||||||
|
|
||||||
crp = crp->Next; // Data_Type
|
crp = crp->Next; // Data_Type
|
||||||
crp->Kdata->SetValue(type, i);
|
crp->Kdata->SetValue(type, i);
|
||||||
|
15
storage/connect/mysql-test/connect/my.cnf
Normal file
15
storage/connect/mysql-test/connect/my.cnf
Normal file
@@ -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
|
42
storage/connect/mysql-test/connect/r/mysql_discovery.result
Normal file
42
storage/connect/mysql-test/connect/r/mysql_discovery.result
Normal file
@@ -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;
|
62
storage/connect/mysql-test/connect/r/mysql_exec.result
Normal file
62
storage/connect/mysql-test/connect/r/mysql_exec.result
Normal file
@@ -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;
|
218
storage/connect/mysql-test/connect/r/mysql_new.result
Normal file
218
storage/connect/mysql-test/connect/r/mysql_new.result
Normal file
@@ -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;
|
27
storage/connect/mysql-test/connect/t/myconn.inc
Normal file
27
storage/connect/mysql-test/connect/t/myconn.inc
Normal file
@@ -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;
|
9
storage/connect/mysql-test/connect/t/myconn_cleanup.inc
Normal file
9
storage/connect/mysql-test/connect/t/myconn_cleanup.inc
Normal file
@@ -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
|
33
storage/connect/mysql-test/connect/t/mysql_discovery.test
Normal file
33
storage/connect/mysql-test/connect/t/mysql_discovery.test
Normal file
@@ -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
|
||||||
|
|
45
storage/connect/mysql-test/connect/t/mysql_exec.test
Normal file
45
storage/connect/mysql-test/connect/t/mysql_exec.test
Normal file
@@ -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
|
||||||
|
|
325
storage/connect/mysql-test/connect/t/mysql_new.test
Normal file
325
storage/connect/mysql-test/connect/t/mysql_new.test
Normal file
@@ -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
|
||||||
|
|
@@ -56,9 +56,27 @@ int MYSQLtoPLG(char *typname, char *var)
|
|||||||
else
|
else
|
||||||
type = TYPE_ERROR;
|
type = TYPE_ERROR;
|
||||||
|
|
||||||
// This is to make the difference between CHAR and VARCHAR
|
if (var) {
|
||||||
if (var && type == TYPE_STRING && stricmp(typname, "char"))
|
// This is to make the difference between CHAR and VARCHAR
|
||||||
*var = 'V';
|
if (type == TYPE_STRING && stricmp(typname, "char"))
|
||||||
|
*var = 'V';
|
||||||
|
|
||||||
|
// This is to make the difference between temporal values
|
||||||
|
if (type == TYPE_DATE) {
|
||||||
|
if (!stricmp(typname, "date"))
|
||||||
|
*var = 'D';
|
||||||
|
else if (!stricmp(typname, "datetime"))
|
||||||
|
*var = 'A';
|
||||||
|
else if (!stricmp(typname, "timestamp"))
|
||||||
|
*var = 'S';
|
||||||
|
else if (!stricmp(typname, "time"))
|
||||||
|
*var = 'T';
|
||||||
|
else if (!stricmp(typname, "year"))
|
||||||
|
*var = 'Y';
|
||||||
|
|
||||||
|
} // endif type
|
||||||
|
|
||||||
|
} // endif var
|
||||||
|
|
||||||
return type;
|
return type;
|
||||||
} // end of MYSQLtoPLG
|
} // end of MYSQLtoPLG
|
||||||
@@ -102,14 +120,18 @@ enum enum_field_types PLGtoMYSQL(int type, bool dbf)
|
|||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/* Convert from PlugDB type to MySQL type name */
|
/* Convert from PlugDB type to MySQL type name */
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
const char *PLGtoMYSQLtype(int type, bool dbf, char var)
|
const char *PLGtoMYSQLtype(int type, bool dbf, char v)
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case TYPE_INT: return "INT";
|
case TYPE_INT: return "INT";
|
||||||
case TYPE_SHORT: return "SMALLINT";
|
case TYPE_SHORT: return "SMALLINT";
|
||||||
case TYPE_FLOAT: return "DOUBLE";
|
case TYPE_FLOAT: return "DOUBLE";
|
||||||
case TYPE_DATE: return dbf ? "DATE" : "DATETIME";
|
case TYPE_DATE: return dbf ? "DATE" :
|
||||||
case TYPE_STRING: return var ? "VARCHAR" : "CHAR";
|
(v == 'S') ? "TIMESTAMP" :
|
||||||
|
(v == 'D') ? "DATE" :
|
||||||
|
(v == 'T') ? "TIME" :
|
||||||
|
(v == 'Y') ? "YEAR" : "DATETIME";
|
||||||
|
case TYPE_STRING: return v ? "VARCHAR" : "CHAR";
|
||||||
case TYPE_BIGINT: return "BIGINT";
|
case TYPE_BIGINT: return "BIGINT";
|
||||||
case TYPE_TINY: return "TINYINT";
|
case TYPE_TINY: return "TINYINT";
|
||||||
default: return "CHAR(0)";
|
default: return "CHAR(0)";
|
||||||
|
@@ -1,7 +1,9 @@
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* ODBC catalog function prototypes. */
|
/* ODBC catalog function prototypes. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
|
#if defined(PROMPT_OK)
|
||||||
char *ODBCCheckConnection(PGLOBAL g, char *dsn, int cop);
|
char *ODBCCheckConnection(PGLOBAL g, char *dsn, int cop);
|
||||||
|
#endif // PROMPT_OK
|
||||||
PQRYRES ODBCDataSources(PGLOBAL g, bool info);
|
PQRYRES ODBCDataSources(PGLOBAL g, bool info);
|
||||||
PQRYRES ODBCColumns(PGLOBAL g, char *dsn, char *table,
|
PQRYRES ODBCColumns(PGLOBAL g, char *dsn, char *table,
|
||||||
char *colpat, bool info);
|
char *colpat, bool info);
|
||||||
|
@@ -174,6 +174,7 @@ int TranslateSQLType(int stp, int prec, int& len, char& v)
|
|||||||
return type;
|
return type;
|
||||||
} // end of TranslateSQLType
|
} // end of TranslateSQLType
|
||||||
|
|
||||||
|
#if defined(PROMPT_OK)
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* ODBCCheckConnection: Check completeness of connection string. */
|
/* ODBCCheckConnection: Check completeness of connection string. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -205,6 +206,7 @@ char *ODBCCheckConnection(PGLOBAL g, char *dsn, int cop)
|
|||||||
ocp->Close();
|
ocp->Close();
|
||||||
return newdsn; // Return complete connection string
|
return newdsn; // Return complete connection string
|
||||||
} // end of ODBCCheckConnection
|
} // end of ODBCCheckConnection
|
||||||
|
#endif // PROMPT_OK
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Allocate the structure used to refer to the result set. */
|
/* Allocate the structure used to refer to the result set. */
|
||||||
|
@@ -1263,7 +1263,7 @@ void MYSQLCOL::InitBind(PGLOBAL g)
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
void MYSQLCOL::ReadColumn(PGLOBAL g)
|
void MYSQLCOL::ReadColumn(PGLOBAL g)
|
||||||
{
|
{
|
||||||
char *buf;
|
char *p, *buf, tim[20];
|
||||||
int rc;
|
int rc;
|
||||||
PTDBMY tdbp = (PTDBMY)To_Tdb;
|
PTDBMY tdbp = (PTDBMY)To_Tdb;
|
||||||
|
|
||||||
@@ -1283,7 +1283,14 @@ void MYSQLCOL::ReadColumn(PGLOBAL g)
|
|||||||
if (trace)
|
if (trace)
|
||||||
htrc("MySQL ReadColumn: name=%s buf=%s\n", Name, buf);
|
htrc("MySQL ReadColumn: name=%s buf=%s\n", Name, buf);
|
||||||
|
|
||||||
Value->SetValue_char(buf, min((unsigned)Long, strlen(buf)));
|
// TODO: have a true way to differenciate temporal values
|
||||||
|
if (strlen(buf) == 8)
|
||||||
|
// This is a TIME value
|
||||||
|
p = strcat(strcpy(tim, "1970-01-01 "), buf);
|
||||||
|
else
|
||||||
|
p = buf;
|
||||||
|
|
||||||
|
Value->SetValue_char(p, strlen(p));
|
||||||
} else {
|
} else {
|
||||||
if (Nullable)
|
if (Nullable)
|
||||||
Value->SetNull(true);
|
Value->SetNull(true);
|
||||||
|
Reference in New Issue
Block a user