summaryrefslogtreecommitdiff
path: root/storage/connect/mysql-test/connect/t/mysql.test
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2013-04-19 07:07:06 +0200
committerSergei Golubchik <sergii@pisem.net>2013-04-19 07:07:06 +0200
commit53375573e32e77676f4a4338099e44698b1bfb45 (patch)
treef003abaaa4f5c501a9040529195da1716e3cad4e /storage/connect/mysql-test/connect/t/mysql.test
parent3975256685b084b39d6e1dd750c131ad98c069c2 (diff)
downloadmariadb-git-53375573e32e77676f4a4338099e44698b1bfb45.tar.gz
small mtr cleanup
and move the connect suite into storage/connect/
Diffstat (limited to 'storage/connect/mysql-test/connect/t/mysql.test')
-rw-r--r--storage/connect/mysql-test/connect/t/mysql.test471
1 files changed, 471 insertions, 0 deletions
diff --git a/storage/connect/mysql-test/connect/t/mysql.test b/storage/connect/mysql-test/connect/t/mysql.test
new file mode 100644
index 00000000000..004a2c21af7
--- /dev/null
+++ b/storage/connect/mysql-test/connect/t/mysql.test
@@ -0,0 +1,471 @@
+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 TABNAME='t1' OPTION_LIST='host=localhost,user=root,port=$PORT'
+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
+
+--echo #
+--echo # Testing FILE privilege
+--echo #
+GRANT ALL PRIVILEGES ON *.* TO user@localhost;
+REVOKE FILE ON *.* FROM user@localhost;
+--connect(user,localhost,user,,)
+--connection user
+SELECT user();
+--error ER_ACCESS_DENIED_ERROR
+CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=MySQL OPTION_LIST='host=localhost,user=root1,port=$PORT';
+--connection default
+SELECT user();
+CREATE TABLE t1remote (a INT NOT NULL);
+INSERT INTO t1remote VALUES (10),(20),(30);
+CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=MySQL TABNAME=t1remote OPTION_LIST='host=localhost,user=root,port=$PORT';
+SELECT * FROM t1;
+--connection user
+SELECT user();
+--error ER_ACCESS_DENIED_ERROR
+SELECT * FROM t1;
+--error ER_ACCESS_DENIED_ERROR
+INSERT INTO t1 VALUES ('xxx');
+--error ER_ACCESS_DENIED_ERROR
+DELETE FROM t1 WHERE a='xxx';
+--error ER_ACCESS_DENIED_ERROR
+UPDATE t1 SET a='yyy' WHERE a='xxx';
+--error ER_ACCESS_DENIED_ERROR
+TRUNCATE TABLE t1;
+--error ER_ACCESS_DENIED_ERROR
+ALTER TABLE t1 READONLY=1;
+--error ER_ACCESS_DENIED_ERROR
+CREATE VIEW v1 AS SELECT * FROM t1;
+
+--echo # Testing a VIEW created with FILE privileges but accessed with no FILE
+--connection default
+SELECT user();
+CREATE VIEW v1 AS SELECT * FROM t1;
+--connection user
+SELECT user();
+--error ER_ACCESS_DENIED_ERROR
+SELECT * FROM v1;
+--error ER_ACCESS_DENIED_ERROR
+INSERT INTO v1 VALUES (2);
+--error ER_ACCESS_DENIED_ERROR
+UPDATE v1 SET a=123;
+--error ER_ACCESS_DENIED_ERROR
+DELETE FROM v1;
+
+--disconnect user
+--connection default
+SELECT user();
+DROP VIEW v1;
+DROP TABLE t1, t1remote;
+DROP USER user@localhost;
+--echo #
+--echo # Testing FILE privileges done
+--echo #
+
+# TODO: remote VARCHAR is displayed as CHAR
+
+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 #
+
+# Bad user name
+# Suppress "mysql_real_connect failed:" (printed in _DEBUG build)
+--replace_result $PORT PORT "mysql_real_connect failed: " ""
+--error ER_UNKNOWN_ERROR
+--eval CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=localhost,user=root1,port=$PORT'
+
+# Bad database name
+--replace_result $PORT PORT "mysql_real_connect failed: " ""
+--error ER_UNKNOWN_ERROR
+--eval CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL DBNAME='unknown' TABNAME='t1' OPTION_LIST='host=localhost,user=root,port=$PORT'
+
+# Bad database name, with OPTION_LIST going first.
+--replace_result $PORT PORT "mysql_real_connect failed: " ""
+--error ER_UNKNOWN_ERROR
+--eval CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL OPTION_LIST='host=localhost,user=root,port=$PORT' DBNAME='unknown' TABNAME='t1'
+
+# Bad table name
+--replace_result $PORT PORT
+--error ER_UNKNOWN_ERROR
+--eval CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='unknown' OPTION_LIST='host=localhost,user=root,port=$PORT'
+--error ER_NO_SUCH_TABLE
+SHOW CREATE TABLE t2;
+
+# Bad column name
+--replace_result $PORT PORT
+--eval CREATE TABLE t2 (x int, y char(10)) ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=localhost,user=root,port=$PORT'
+--replace_result $PORT PORT
+SHOW CREATE TABLE t2;
+--error ER_GET_ERRMSG
+SELECT * FROM t2;
+DROP TABLE t2;
+
+# The remote table disappeared
+ALTER TABLE t1 RENAME t1backup;
+--error ER_NO_SUCH_TABLE
+SELECT * FROM t2;
+ALTER TABLE t1backup RENAME t1;
+
+
+
+--echo #
+--echo # Testing SELECT, etc.
+--echo #
+
+# Automatic table structure
+--replace_result $PORT PORT
+--eval CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=localhost,user=root,port=$PORT'
+--replace_result $PORT PORT
+SHOW CREATE TABLE t2;
+SELECT * FROM t2;
+DROP TABLE t2;
+
+
+# Explicit table structure
+--replace_result $PORT PORT
+--eval CREATE TABLE t2 (a int, b char(10)) ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=localhost,user=root,port=$PORT'
+--replace_result $PORT PORT
+SHOW CREATE TABLE t2;
+SELECT * FROM t2;
+DROP TABLE t2;
+
+
+# Explicit table structure: remote NULL, local NOT NULL
+--replace_result $PORT PORT
+--eval CREATE TABLE t2 (a INT NOT NULL, b CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=localhost,user=root,port=$PORT'
+--replace_result $PORT PORT
+SHOW CREATE TABLE t2;
+SELECT * FROM t2;
+DROP TABLE t2;
+
+
+# Explicit table structure with wrong column types
+--replace_result $PORT PORT
+--eval CREATE TABLE t2 (a char(10), b int) ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=localhost,user=root,port=$PORT'
+--replace_result $PORT PORT
+SHOW CREATE TABLE t2;
+SELECT * FROM t2;
+DROP TABLE t2;
+
+DROP TABLE t1;
+
+--echo #
+--echo # Testing numeric data types
+--echo #
+
+# TODO: tinyint is mapped to smallint
+#CREATE TABLE t1 (a tinyint);
+#--replace_result $PORT PORT
+#--eval CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=localhost,user=root,port=$PORT'
+#--replace_result $PORT PORT
+#SHOW CREATE TABLE t1;
+#--replace_result $PORT PORT
+#SHOW CREATE TABLE t2;
+#SELECT * FROM t2;
+#DROP TABLE t2, t1;
+
+# TODO: unsigned does not work
+#CREATE TABLE t1 (a tinyint unsigned);
+#--replace_result $PORT PORT
+#--eval CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=localhost,user=root,port=$PORT'
+#SHOW CREATE TABLE t1;
+#--replace_result $PORT PORT
+#SHOW CREATE TABLE t2;
+#SELECT * FROM t2;
+#DROP TABLE t2, t1;
+
+CREATE TABLE t1 (a smallint);
+--replace_result $PORT PORT
+--eval CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=localhost,user=root,port=$PORT'
+--replace_result $PORT PORT
+SHOW CREATE TABLE t1;
+--replace_result $PORT PORT
+SHOW CREATE TABLE t2;
+SELECT * FROM t2;
+DROP TABLE t2, t1;
+
+CREATE TABLE t1 (a mediumint);
+--replace_result $PORT PORT
+--eval CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=localhost,user=root,port=$PORT'
+--replace_result $PORT PORT
+SHOW CREATE TABLE t1;
+--replace_result $PORT PORT
+SHOW CREATE TABLE t2;
+SELECT * FROM t2;
+DROP TABLE t2, t1;
+
+CREATE TABLE t1 (a int);
+--replace_result $PORT PORT
+--eval CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=localhost,user=root,port=$PORT'
+--replace_result $PORT PORT
+SHOW CREATE TABLE t1;
+--replace_result $PORT PORT
+SHOW CREATE TABLE t2;
+SELECT * FROM t2;
+DROP TABLE t2, t1;
+
+
+# TODO: bigint is mapped to double(20,0)
+CREATE TABLE t1 (a bigint);
+--replace_result $PORT PORT
+--eval CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=localhost,user=root,port=$PORT'
+--replace_result $PORT PORT
+SHOW CREATE TABLE t1;
+--replace_result $PORT PORT
+SHOW CREATE TABLE t2;
+SELECT * FROM t2;
+DROP TABLE t2, t1;
+
+
+# TODO: ERROR 1439: Display width out of range for 'a' (max = 255)
+#CREATE TABLE t1 (a float);
+#--replace_result $PORT PORT
+#--eval CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=localhost,user=root,port=$PORT'
+#--replace_result $PORT PORT
+#SHOW CREATE TABLE t1;
+#--replace_result $PORT PORT
+#SHOW CREATE TABLE t2;
+#SELECT * FROM t2;
+#DROP TABLE t2, t1;
+
+# TODO: ERROR 1439: Display width out of range for 'a' (max = 255)
+#CREATE TABLE t1 (a double);
+#--replace_result $PORT PORT
+#--eval CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=localhost,user=root,port=$PORT'
+#--replace_result $PORT PORT
+#SHOW CREATE TABLE t1;
+#--replace_result $PORT PORT
+#SHOW CREATE TABLE t2;
+#SELECT * FROM t2;
+#DROP TABLE t2, t1;
+
+# TODO: decimal is converted to double
+#CREATE TABLE t1 (a decimal(20,5));
+#--replace_result $PORT PORT
+#--eval CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=localhost,user=root,port=$PORT'
+#--replace_result $PORT PORT
+#SHOW CREATE TABLE t1;
+#--replace_result $PORT PORT
+#SHOW CREATE TABLE t2;
+#SELECT * FROM t2;
+#DROP TABLE t2, t1;
+
+# TODO: add test for BIT
+
+--echo #
+--echo # Testing character data types
+--echo #
+
+# TODO: char is mapped to varchar
+CREATE TABLE t1 (a char(10));
+--replace_result $PORT PORT
+--eval CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=localhost,user=root,port=$PORT'
+--replace_result $PORT PORT
+SHOW CREATE TABLE t1;
+--replace_result $PORT PORT
+SHOW CREATE TABLE t2;
+SELECT * FROM t2;
+DROP TABLE t2, t1;
+
+CREATE TABLE t1 (a varchar(10));
+--replace_result $PORT PORT
+--eval CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=localhost,user=root,port=$PORT'
+--replace_result $PORT PORT
+SHOW CREATE TABLE t1;
+--replace_result $PORT PORT
+SHOW CREATE TABLE t2;
+SELECT * FROM t2;
+DROP TABLE t2, t1;
+
+# TODO: ERROR 1105: Unsupported column type tinytext
+#CREATE TABLE t1 (a tinytext);
+#--replace_result $PORT PORT
+#--eval CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=localhost,user=root,port=$PORT'
+#--replace_result $PORT PORT
+#SHOW CREATE TABLE t1;
+#--replace_result $PORT PORT
+#SHOW CREATE TABLE t2;
+#SELECT * FROM t2;
+#DROP TABLE t2, t1;
+
+# TODO: ERROR 1105: Unsupported column type mediumtext
+#CREATE TABLE t1 (a mediumtext);
+#--replace_result $PORT PORT
+#--eval CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=localhost,user=root,port=$PORT'
+#--replace_result $PORT PORT
+#SHOW CREATE TABLE t1;
+#--replace_result $PORT PORT
+#SHOW CREATE TABLE t2;
+#SELECT * FROM t2;
+#DROP TABLE t2, t1;
+
+# TODO: text is converted to varchar(256)
+#CREATE TABLE t1 (a text);
+#--replace_result $PORT PORT
+#--eval CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=localhost,user=root,port=$PORT'
+#--replace_result $PORT PORT
+#SHOW CREATE TABLE t1;
+#--replace_result $PORT PORT
+#SHOW CREATE TABLE t2;
+#SELECT * FROM t2;
+#DROP TABLE t2, t1;
+
+# TODO: ERROR 1105: Unsupported column type longtext
+#CREATE TABLE t1 (a longtext);
+#--replace_result $PORT PORT
+#--eval CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=localhost,user=root,port=$PORT'
+#--replace_result $PORT PORT
+#SHOW CREATE TABLE t1;
+#--replace_result $PORT PORT
+#SHOW CREATE TABLE t2;
+#SELECT * FROM t2;
+#DROP TABLE t2, 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 $PORT PORT
+#--eval CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=localhost,user=root,port=$PORT'
+#--replace_result $PORT PORT
+#SHOW CREATE TABLE t1;
+#--replace_result $PORT PORT
+#SHOW CREATE TABLE t2;
+#SELECT * FROM t2;
+#DROP TABLE t2, t1;
+
+# TODO: ERROR 1105: Unsupported column type varbinary
+#CREATE TABLE t1 (a varbinary(10));
+#--replace_result $PORT PORT
+#--eval CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=localhost,user=root,port=$PORT'
+#--replace_result $PORT PORT
+#SHOW CREATE TABLE t1;
+#--replace_result $PORT PORT
+#SHOW CREATE TABLE t2;
+#SELECT * FROM t2;
+#DROP TABLE t2, t1;
+
+# TODO: ERROR 1105: Unsupported column type tinyblob
+#CREATE TABLE t1 (a tinyblob);
+#--replace_result $PORT PORT
+#--eval CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=localhost,user=root,port=$PORT'
+#--replace_result $PORT PORT
+#SHOW CREATE TABLE t1;
+#--replace_result $PORT PORT
+#SHOW CREATE TABLE t2;
+#SELECT * FROM t2;
+#DROP TABLE t2, t1;
+
+# TODO: ERROR 1105: Unsupported column type mediumblob
+#CREATE TABLE t1 (a mediumblob);
+#--replace_result $PORT PORT
+#--eval CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=localhost,user=root,port=$PORT'
+#--replace_result $PORT PORT
+#SHOW CREATE TABLE t1;
+#--replace_result $PORT PORT
+#SHOW CREATE TABLE t2;
+#SELECT * FROM t2;
+#DROP TABLE t2, t1;
+
+# TODO: blob is converted to varchar(256)
+#CREATE TABLE t1 (a blob);
+#--replace_result $PORT PORT
+#--eval CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=localhost,user=root,port=$PORT'
+#--replace_result $PORT PORT
+#SHOW CREATE TABLE t1;
+#--replace_result $PORT PORT
+#SHOW CREATE TABLE t2;
+#SELECT * FROM t2;
+#DROP TABLE t2, t1;
+
+# TODO: ERROR 1105: Unsupported column type longblob
+#CREATE TABLE t1 (a longblob);
+#--replace_result $PORT PORT
+#--eval CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=localhost,user=root,port=$PORT'
+#--replace_result $PORT PORT
+#SHOW CREATE TABLE t1;
+#--replace_result $PORT PORT
+#SHOW CREATE TABLE t2;
+#SELECT * FROM t2;
+#DROP TABLE t2, t1;
+
+# TODO: ERROR 1105: Unsupported column type geometry
+#CREATE TABLE t1 (a geometry);
+#--replace_result $PORT PORT
+#--eval CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=localhost,user=root,port=$PORT'
+#--replace_result $PORT PORT
+#SHOW CREATE TABLE t1;
+#--replace_result $PORT PORT
+#SHOW CREATE TABLE t2;
+#SELECT * FROM t2;
+#DROP TABLE t2, t1;
+
+--echo #
+--echo # Testing temporal data types
+--echo #
+
+# TODO: time is converted to date
+#CREATE TABLE t1 (a time);
+#--replace_result $PORT PORT
+#--eval CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=localhost,user=root,port=$PORT'
+#--replace_result $PORT PORT
+#SHOW CREATE TABLE t1;
+#--replace_result $PORT PORT
+#SHOW CREATE TABLE t2;
+#SELECT * FROM t2;
+#DROP TABLE t2, t1;
+
+CREATE TABLE t1 (a date);
+--replace_result $PORT PORT
+--eval CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=localhost,user=root,port=$PORT'
+--replace_result $PORT PORT
+SHOW CREATE TABLE t1;
+--replace_result $PORT PORT
+SHOW CREATE TABLE t2;
+SELECT * FROM t2;
+DROP TABLE t2, t1;
+
+# TODO: datetime is converted to date
+#CREATE TABLE t1 (a datetime);
+#--replace_result $PORT PORT
+#--eval CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=localhost,user=root,port=$PORT'
+#--replace_result $PORT PORT
+#SHOW CREATE TABLE t1;
+#--replace_result $PORT PORT
+#SHOW CREATE TABLE t2;
+#SELECT * FROM t2;
+#DROP TABLE t2, t1;
+
+# TODO: timestamp is converted to date
+#CREATE TABLE t1 (a timestamp);
+#--replace_result $PORT PORT
+#--eval CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=localhost,user=root,port=$PORT'
+#--replace_result $PORT PORT
+#SHOW CREATE TABLE t1;
+#--replace_result $PORT PORT
+#SHOW CREATE TABLE t2;
+#SELECT * FROM t2;
+#DROP TABLE t2, t1;
+
+# TODO: add test for YEAR
+# TODO: add tests for fractional seconds
+