From b0e07ff5b7b95b8d1bdb81121a8cb91eb5a12b6c Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Thu, 4 Apr 2013 01:14:26 +0200 Subject: [PATCH] - Commit added test on TBL tables + update dbf.result added: mysql-test/suite/connect/r/tbl.result mysql-test/suite/connect/t/tbl.test modified: mysql-test/suite/connect/r/dbf.result - Fix bug on generating default file name for TBL sub-tables modified: storage/connect/ha_connect.cc --- mysql-test/suite/connect/r/dbf.result | 2 - mysql-test/suite/connect/r/tbl.result | 123 ++++++++++++++++++++++++++ mysql-test/suite/connect/t/tbl.test | 46 ++++++++++ storage/connect/ha_connect.cc | 2 +- 4 files changed, 170 insertions(+), 3 deletions(-) create mode 100644 mysql-test/suite/connect/r/tbl.result create mode 100644 mysql-test/suite/connect/t/tbl.test diff --git a/mysql-test/suite/connect/r/dbf.result b/mysql-test/suite/connect/r/dbf.result index ca245410c6c..6aba237a478 100644 --- a/mysql-test/suite/connect/r/dbf.result +++ b/mysql-test/suite/connect/r/dbf.result @@ -639,8 +639,6 @@ Dec 0 Flags 00 -------- -------- ALTER TABLE t1 MODIFY a INT(10) NOT NULL; -Warnings: -Warning 1366 Incorrect integer value: '' for column 'a' at row 1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( diff --git a/mysql-test/suite/connect/r/tbl.result b/mysql-test/suite/connect/r/tbl.result new file mode 100644 index 00000000000..e59335a1da8 --- /dev/null +++ b/mysql-test/suite/connect/r/tbl.result @@ -0,0 +1,123 @@ +# +# Checking TBL tables +# +CREATE TABLE t1 ( +a INT NOT NULL, +message CHAR(10) NOT NULL) ENGINE=connect; +Warnings: +Warning 1105 No table_type. Was set to DOS +Warning 1105 No file name. Table will use t1.dos +INSERT INTO t1 VALUES (1,'Testing'),(2,'dos table'),(3,'t1'); +SELECT * FROM t1; +a message +1 Testing +2 dos table +3 t1 +CREATE TABLE t2 ( +a INT NOT NULL, +message CHAR(10) NOT NULL) ENGINE=connect TABLE_TYPE=BIN; +Warnings: +Warning 1105 No file name. Table will use t2.bin +INSERT INTO t2 VALUES (1,'Testing'),(2,'bin table'),(3,'t2'); +SELECT * FROM t2; +a message +1 Testing +2 bin table +3 t2 +CREATE TABLE t3 ( +a INT NOT NULL, +message CHAR(10) NOT NULL) ENGINE=connect TABLE_TYPE=CSV; +Warnings: +Warning 1105 No file name. Table will use t3.csv +INSERT INTO t3 VALUES (1,'Testing'),(2,'csv table'),(3,'t3'); +SELECT * FROM t3; +a message +1 Testing +2 csv table +3 t3 +CREATE TABLE total ( +tabname CHAR(8) NOT NULL SPECIAL='TABID', +ta TINYINT NOT NULL FLAG=1, +message CHAR(20) NOT NULL) +engine=CONNECT table_type=TBL table_list='t1,t2,t3'; +select * from total; +tabname ta message +t1 1 Testing +t1 2 dos table +t1 3 t1 +t2 1 Testing +t2 2 bin table +t2 3 t2 +t3 1 Testing +t3 2 csv table +t3 3 t3 +select * from total where tabname = 't2'; +tabname ta message +t2 1 Testing +t2 2 bin table +t2 3 t2 +select * from total where tabname = 't2' and ta = 3; +tabname ta message +t2 3 t2 +select * from total where tabname in ('t1','t3'); +tabname ta message +t1 1 Testing +t1 2 dos table +t1 3 t1 +t3 1 Testing +t3 2 csv table +t3 3 t3 +select * from total where ta = 3 and tabname in ('t1','t2'); +tabname ta message +t1 3 t1 +t2 3 t2 +select * from total where tabname <> 't2'; +tabname ta message +t1 1 Testing +t1 2 dos table +t1 3 t1 +t3 1 Testing +t3 2 csv table +t3 3 t3 +select * from total where tabname != 't2' and ta = 3; +tabname ta message +t1 3 t1 +t3 3 t3 +select * from total where tabname not in ('t2','t3'); +tabname ta message +t1 1 Testing +t1 2 dos table +t1 3 t1 +select * from total where ta = 3 and tabname in ('t2','t3'); +tabname ta message +t2 3 t2 +t3 3 t3 +select * from total where ta = 3 or tabname in ('t2','t3'); +tabname ta message +t1 3 t1 +t2 1 Testing +t2 2 bin table +t2 3 t2 +t3 1 Testing +t3 2 csv table +t3 3 t3 +select * from total where not tabname = 't2'; +tabname ta message +t1 1 Testing +t1 2 dos table +t1 3 t1 +t3 1 Testing +t3 2 csv table +t3 3 t3 +select * from total where tabname = 't2' or tabname = 't1'; +tabname ta message +t1 1 Testing +t1 2 dos table +t1 3 t1 +t2 1 Testing +t2 2 bin table +t2 3 t2 +DROP TABLE total; +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; diff --git a/mysql-test/suite/connect/t/tbl.test b/mysql-test/suite/connect/t/tbl.test new file mode 100644 index 00000000000..4a9e5ad707f --- /dev/null +++ b/mysql-test/suite/connect/t/tbl.test @@ -0,0 +1,46 @@ +let $MYSQLD_DATADIR= `select @@datadir`; + +--echo # +--echo # Checking TBL tables +--echo # +CREATE TABLE t1 ( +a INT NOT NULL, +message CHAR(10) NOT NULL) ENGINE=connect; +INSERT INTO t1 VALUES (1,'Testing'),(2,'dos table'),(3,'t1'); +SELECT * FROM t1; + +CREATE TABLE t2 ( +a INT NOT NULL, +message CHAR(10) NOT NULL) ENGINE=connect TABLE_TYPE=BIN; +INSERT INTO t2 VALUES (1,'Testing'),(2,'bin table'),(3,'t2'); +SELECT * FROM t2; + +CREATE TABLE t3 ( +a INT NOT NULL, +message CHAR(10) NOT NULL) ENGINE=connect TABLE_TYPE=CSV; +INSERT INTO t3 VALUES (1,'Testing'),(2,'csv table'),(3,'t3'); +SELECT * FROM t3; + +CREATE TABLE total ( +tabname CHAR(8) NOT NULL SPECIAL='TABID', +ta TINYINT NOT NULL FLAG=1, +message CHAR(20) NOT NULL) +engine=CONNECT table_type=TBL table_list='t1,t2,t3'; + +select * from total; +select * from total where tabname = 't2'; +select * from total where tabname = 't2' and ta = 3; +select * from total where tabname in ('t1','t3'); +select * from total where ta = 3 and tabname in ('t1','t2'); +select * from total where tabname <> 't2'; +select * from total where tabname != 't2' and ta = 3; +select * from total where tabname not in ('t2','t3'); +select * from total where ta = 3 and tabname in ('t2','t3'); +select * from total where ta = 3 or tabname in ('t2','t3'); +select * from total where not tabname = 't2'; +select * from total where tabname = 't2' or tabname = 't1'; + +DROP TABLE total; +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 565b5e1ebc7..7708045c493 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -1232,7 +1232,7 @@ const char *ha_connect::GetDBName(const char* name) const char *ha_connect::GetTableName(void) { - return table->s->table_name.str; + return (tshp) ? tshp->table_name.str : table->s->table_name.str; } // end of GetTableName /****************************************************************************/