From dd9ee7d157bfaf4dc9d1d4495608f5e59fc00a5b Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Fri, 8 Feb 2013 12:22:26 +0400 Subject: [PATCH] Adding a test for TABLE_TYPE=BIN added: mysql-test/suite/connect/r/bin.result mysql-test/suite/connect/std_data/Testbal.dat mysql-test/suite/connect/t/bin.test --- mysql-test/suite/connect/r/bin.result | 51 ++++++++++++++++++ mysql-test/suite/connect/std_data/Testbal.dat | Bin 0 -> 78 bytes mysql-test/suite/connect/t/bin.test | 51 ++++++++++++++++++ 3 files changed, 102 insertions(+) create mode 100644 mysql-test/suite/connect/r/bin.result create mode 100644 mysql-test/suite/connect/std_data/Testbal.dat create mode 100644 mysql-test/suite/connect/t/bin.test diff --git a/mysql-test/suite/connect/r/bin.result b/mysql-test/suite/connect/r/bin.result new file mode 100644 index 00000000000..0b43809af9a --- /dev/null +++ b/mysql-test/suite/connect/r/bin.result @@ -0,0 +1,51 @@ +# +# Testing errors +# +CREATE TABLE t1 +( +ID INT +) Engine=CONNECT TABLE_TYPE=BIN FILE_NAME='nonexistent.txt'; +SELECT * FROM t1; +ID +Warnings: +Warning 1105 Open(rb) error 2 on DATADIR/test/nonexistent.txt: No such file or directory +DROP TABLE t1; +CREATE TABLE t1 +( +fig INT(4) NOT NULL FIELD_FORMAT='C', +name CHAR(10) not null, +birth DATE NOT NULL, +id CHAR(5) NOT NULL FIELD_FORMAT='S', +salary DOUBLE(9,2) NOT NULL DEFAULT 0.00 FIELD_FORMAT='F', +dept INT(4) NOT NULL FIELD_FORMAT='S' +) ENGINE=CONNECT TABLE_TYPE=BIN BLOCK_SIZE=5 FILE_NAME='Testbal.dat'; +SELECT * FROM t1; +fig name birth id salary dept +5500 ARCHIBALD 1980-01-25 3789 4380.50 318 +123 OLIVER 1953-08-10 23456 3400.68 2158 +3123 FOO 2002-07-23 888 0.00 318 +INSERT INTO t1 VALUES (55555,'RONALD','1980-02-26','3333',4444.44,555); +ERROR HY000: Got error 122 'Value too long for field fig (5 --> 4)' from CONNECT +INSERT INTO t1 VALUES (5555,'RONALD','1980-02-26','3333',4444.44,555); +SELECT * FROM t1; +fig name birth id salary dept +5500 ARCHIBALD 1980-01-25 3789 4380.50 318 +123 OLIVER 1953-08-10 23456 3400.68 2158 +3123 FOO 2002-07-23 888 0.00 318 +5555 RONALD 1980-02-26 3333 4444.44 555 +DROP TABLE t1; +# +# Testing that the underlying file is created +# +CREATE TABLE t1 +( +c CHAR(4) NOT NULL FIELD_FORMAT='C' +) ENGINE=CONNECT TABLE_TYPE=BIN FILE_NAME='bin2.dat'; +INSERT INTO t1 VALUES (10),(20),(300),(4000); +SELECT * FROM t1; +c +10 +20 +300 +4000 +DROP TABLE t1; diff --git a/mysql-test/suite/connect/std_data/Testbal.dat b/mysql-test/suite/connect/std_data/Testbal.dat new file mode 100644 index 0000000000000000000000000000000000000000..b3f0e26e5a52b4ad3f1041d4244567dc79455bf2 GIT binary patch literal 78 zcmXptH85}ta`y0aa`bUgVDNe;be50dNr$T)qoI+pg1?Vvm}`&%5HPILe7GR`VONN2 a9)~ed%FW*&Bn$)%b8KuYm>Gb;ju8N0Hxz~d literal 0 HcmV?d00001 diff --git a/mysql-test/suite/connect/t/bin.test b/mysql-test/suite/connect/t/bin.test new file mode 100644 index 00000000000..8038405a283 --- /dev/null +++ b/mysql-test/suite/connect/t/bin.test @@ -0,0 +1,51 @@ +let $MYSQLD_DATADIR= `select @@datadir`; +--copy_file $MYSQL_TEST_DIR/suite/connect/std_data/Testbal.dat $MYSQLD_DATADIR/test/Testbal.dat + +--echo # +--echo # Testing errors +--echo # +CREATE TABLE t1 +( + ID INT +) Engine=CONNECT TABLE_TYPE=BIN FILE_NAME='nonexistent.txt'; +--replace_regex /on .*test.nonexistent.txt/on DATADIR\/test\/nonexistent.txt/ +# TODO: check why this is needed for Windows +--replace_result Open(rt) Open(rb) +SELECT * FROM t1; +DROP TABLE t1; + + +CREATE TABLE t1 +( + fig INT(4) NOT NULL FIELD_FORMAT='C', + name CHAR(10) not null, + birth DATE NOT NULL, + id CHAR(5) NOT NULL FIELD_FORMAT='S', + salary DOUBLE(9,2) NOT NULL DEFAULT 0.00 FIELD_FORMAT='F', + dept INT(4) NOT NULL FIELD_FORMAT='S' +) ENGINE=CONNECT TABLE_TYPE=BIN BLOCK_SIZE=5 FILE_NAME='Testbal.dat'; +SELECT * FROM t1; + +--error ER_GET_ERRMSG +INSERT INTO t1 VALUES (55555,'RONALD','1980-02-26','3333',4444.44,555); +INSERT INTO t1 VALUES (5555,'RONALD','1980-02-26','3333',4444.44,555); +SELECT * FROM t1; + +DROP TABLE t1; + +--echo # +--echo # Testing that the underlying file is created +--echo # +CREATE TABLE t1 +( + c CHAR(4) NOT NULL FIELD_FORMAT='C' +) ENGINE=CONNECT TABLE_TYPE=BIN FILE_NAME='bin2.dat'; +INSERT INTO t1 VALUES (10),(20),(300),(4000); +SELECT * FROM t1; +DROP TABLE t1; + +# +# Clean up +# +--remove_file $MYSQLD_DATADIR/test/Testbal.dat +--remove_file $MYSQLD_DATADIR/test/bin2.dat