Commit 06dd5ea4 authored by Alexander Barkov's avatar Alexander Barkov

Adding basic tests for TABLE_TYPE=fmt

      
added:
  mysql-test/suite/connect/r/fmt.result
  mysql-test/suite/connect/std_data/funny.txt
  mysql-test/suite/connect/std_data/funny2.txt
  mysql-test/suite/connect/t/fmt.test
parent 1b40c7c7
#
# Testing errors
#
CREATE TABLE t1
(
ID INT field_format=' %n%d%n'
) Engine=CONNECT table_type=FMT 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;
#
# Testing manual examples
#
CREATE TABLE t1
(
ID Integer(5) field_format=' %n%d%n',
NAME Char(16) field_format=" , '%n%[^']%n'",
DEPNO Integer(4) field_format=' , #%n%d%n',
SALARY Double(12,2) field_format=' ; %n%f%n'
) Engine=CONNECT table_type=FMT file_name='funny.txt';
SELECT * FROM t1;
ID NAME DEPNO SALARY
12345 BERTRAND 200 5009.13
56 POIROT-DELMOTTE 4256 18009.00
345 TRUCMUCHE 67 19000.25
DROP TABLE t1;
CREATE TABLE t1
(
ID Integer(5) field_format=' %n%d%n',
NAME Char(16) field_format=" , '%n%[^']%n'",
DEPNO Integer(4) field_format=' , #%n%d%n',
SALARY Double(12,2) field_format=' ; %n%f%n'
) Engine=CONNECT table_type=FMT file_name='funny2.txt';
SELECT * FROM t1;
ERROR HY000: Got error 122 'Bad format line 2 field 3 of t1' from CONNECT
DROP TABLE t1;
CREATE TABLE t1
(
ID Integer(5) field_format=' %n%d%n',
NAME Char(16) field_format=' , ''%n%[^'']%m',
DEPNO Integer(4) field_format=''' , #%n%d%m',
SALARY Double(12,2) field_format=' ; %n%f%n'
) Engine=CONNECT table_type=FMT file_name='funny2.txt';
SELECT * FROM t1;
ID NAME DEPNO SALARY
12345 BERTRAND 200 5009.13
56 POIROT-DELMOTTE 0 18009.00
345 67 19000.25
DROP TABLE t1;
12345,'BERTRAND',#200;5009.13
56, 'POIROT-DELMOTTE' ,#4256 ;18009
345 ,'TRUCMUCHE' , #67; 19000.25
12345,'BERTRAND',#200;5009.13
56, 'POIROT-DELMOTTE' ,# ;18009
345 ,'' , #67; 19000.25
let $MYSQLD_DATADIR= `select @@datadir`;
--copy_file $MYSQL_TEST_DIR/suite/connect/std_data/funny.txt $MYSQLD_DATADIR/test/funny.txt
--copy_file $MYSQL_TEST_DIR/suite/connect/std_data/funny2.txt $MYSQLD_DATADIR/test/funny2.txt
--echo #
--echo # Testing errors
--echo #
CREATE TABLE t1
(
ID INT field_format=' %n%d%n'
) Engine=CONNECT table_type=FMT 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;
--echo #
--echo # Testing manual examples
--echo #
CREATE TABLE t1
(
ID Integer(5) field_format=' %n%d%n',
NAME Char(16) field_format=" , '%n%[^']%n'",
DEPNO Integer(4) field_format=' , #%n%d%n',
SALARY Double(12,2) field_format=' ; %n%f%n'
) Engine=CONNECT table_type=FMT file_name='funny.txt';
SELECT * FROM t1;
DROP TABLE t1;
#
# TODO: shoudn't a warning instead of error be returned on bad format?
#
CREATE TABLE t1
(
ID Integer(5) field_format=' %n%d%n',
NAME Char(16) field_format=" , '%n%[^']%n'",
DEPNO Integer(4) field_format=' , #%n%d%n',
SALARY Double(12,2) field_format=' ; %n%f%n'
) Engine=CONNECT table_type=FMT file_name='funny2.txt';
--error ER_GET_ERRMSG
SELECT * FROM t1;
DROP TABLE t1;
CREATE TABLE t1
(
ID Integer(5) field_format=' %n%d%n',
NAME Char(16) field_format=' , ''%n%[^'']%m',
DEPNO Integer(4) field_format=''' , #%n%d%m',
SALARY Double(12,2) field_format=' ; %n%f%n'
) Engine=CONNECT table_type=FMT file_name='funny2.txt';
SELECT * FROM t1;
DROP TABLE t1;
#
# Clean up
#
--remove_file $MYSQLD_DATADIR/test/funny.txt
--remove_file $MYSQLD_DATADIR/test/funny2.txt
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment