Commit b93db097 authored by Olivier Bertrand's avatar Olivier Bertrand

No commit message

No commit message
parents 82e746ea 6bd0f5da
#
# 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;
#
# Testing errors
#
CREATE TABLE t1
(
ID INT
) Engine=CONNECT TABLE_TYPE=CSV 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 examples from the manual
#
CREATE TABLE t1
(
name CHAR(12),
birth DATE DATE_FORMAT='DD/MM/YY',
children SMALLINT(2)
) ENGINE=CONNECT TABLE_TYPE=CSV FILE_NAME='people.csv'
HEADER=1 SEP_CHAR=';' QUOTED=1;
SELECT * FROM t1;
name birth children
Archibald 2001-05-17 3
Nabucho 2003-08-12 2
INSERT INTO t1 VALUES ('RONALD','1980-02-26',4);
SELECT * FROM t1;
name birth children
Archibald 2001-05-17 3
Nabucho 2003-08-12 2
RONALD 1980-02-26 4
DROP TABLE t1;
SELECT REPLACE(LOAD_FILE('DATADIR/test/people.csv'),'\r\n','\n');;
REPLACE(LOAD_FILE('DATADIR/test/people.csv'),'\r\n','\n')
Name;birth;children
"Archibald";17/05/01;3
"Nabucho";12/08/03;2
"RONALD";26/02/80;4
#
# Testing that the underlying file is created
#
CREATE TABLE t1
(
c1 CHAR(12) NOT NULL,
c2 CHAR(12) NOT NULL
) ENGINE=CONNECT TABLE_TYPE=CSV FILE_NAME='tmp.csv'
HEADER=1 SEP_CHAR=',' QUOTED=1;
INSERT INTO t1 VALUES (10,10),(20,20),(300,300),(4000,4000), ('a b','c d');
SELECT * FROM t1;
c1 c2
10 10
20 20
300 300
4000 4000
a b c d
DROP TABLE t1;
SELECT REPLACE(LOAD_FILE('DATADIR/test/tmp.csv'),'\r\n','\n');;
REPLACE(LOAD_FILE('DATADIR/test/tmp.csv'),'\r\n','\n')
"c1","c2"
"10","10"
"20","20"
"300","300"
"4000","4000"
"a b","c d"
CREATE TABLE t1 (
path VARCHAR(256) flag=1,
fname VARCHAR(256),
ftype CHAR(4),
size DOUBLE(12,0) flag=5
) ENGINE=CONNECT TABLE_TYPE=DIR FILE_NAME='*.txt'
OPTION_LIST='subdir=1';
SELECT * FROM t1;
path fname ftype size
SELECT fname, ftype, size FROM t1;
fname ftype size
boys .txt 282
boyswin .txt 288
boys2 .txt 282
ALTER TABLE t1 OPTION_LIST='subdir=0';
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`path` varchar(256) DEFAULT NULL `flag`=1,
`fname` varchar(256) DEFAULT NULL,
`ftype` char(4) DEFAULT NULL,
`size` double(12,0) DEFAULT NULL `flag`=5
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`=DIR `FILE_NAME`='*.txt' `OPTION_LIST`='subdir=0'
SELECT fname, ftype, size FROM t1;
fname ftype size
boys .txt 282
boyswin .txt 288
INSERT INTO t1 VALUES ('','','','');
ERROR HY000: Got error 174 'COLBLK SetBuffer: undefined Access Method' from CONNECT
DROP TABLE t1;
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=DIR FILE_NAME='*.txt';
ERROR 42000: A table must have at least 1 column
#
# Testing errors
#
CREATE TABLE t1
(
ID INT
) Engine=CONNECT TABLE_TYPE=INI FILE_NAME='nonexistent.txt';
SELECT * FROM t1;
ID
DROP TABLE t1;
#
# Testing examples from the manual
#
CREATE TABLE t1
(
contact CHAR(16) flag=1,
name CHAR(20),
forename CHAR(32),
hired date date_format='DD/MM/YYYY',
address CHAR(64),
city CHAR(20),
zipcode CHAR(8),
tel CHAR(16)
) ENGINE=CONNECT TABLE_TYPE=INI FILE_NAME='contact.ini';
SELECT contact, name, hired, city, tel FROM t1;
contact name hired city tel
BER Bertrand 1970-01-01 Issy-les-Mlx 09.54.36.29.60
WEL Schmitt 1985-02-19 Berlin 03.43.377.360
UK1 Smith 2003-11-08 London
UPDATE t1 SET forename= 'Harry' where contact='UK1';
SELECT * FROM t1 WHERE contact='UK1';
contact name forename hired address city zipcode tel
UK1 Smith Harry 2003-11-08 143 Blum Rd. London NW1 2BP
INSERT INTO t1 (contact,forename) VALUES ('UK1','Harrison');
SELECT * FROM t1 WHERE contact='UK1';
contact name forename hired address city zipcode tel
UK1 Smith Harrison 2003-11-08 143 Blum Rd. London NW1 2BP
INSERT INTO t1 (contact,forename) VALUES ('UK2','John');
SELECT * FROM t1 WHERE contact='UK2';
contact name forename hired address city zipcode tel
UK2 John 1970-01-01
DROP TABLE t1;
SELECT REPLACE(REPLACE(LOAD_FILE('DATADIR/test/contact.ini'),'\r\n','\n'),'\n\n','\n');;
REPLACE(REPLACE(LOAD_FILE('DATADIR/test/contact.ini'),'\r\n','\n'),'\n\n','\n')
[BER]
name=Bertrand
forename=Olivier
address=21 rue Ferdinand Buisson
city=Issy-les-Mlx
zipcode=92130
tel=09.54.36.29.60
cell=06.70.06.04.16
[WEL]
name=Schmitt
forename=Bernard
hired=19/02/1985
address=64 tiergarten strasse
city=Berlin
zipcode=95013
tel=03.43.377.360
[UK1]
name=Smith
forename=Harrison
hired=08/11/2003
address=143 Blum Rd.
city=London
zipcode=NW1 2BP
[UK2]
forename=John
CREATE TABLE t1
(
section CHAR(16) flag=1,
keyname CHAR(16) flag=2,
value CHAR(32)
) ENGINE=CONNECT TABLE_TYPE=INI FILE_NAME='contact.ini'
OPTION_LIST='Layout=Row';
UPDATE t1 SET value='Paul' WHERE section='UK2' AND keyname='forename';
SELECT * FROM t1;
section keyname value
BER name Bertrand
BER forename Olivier
BER address 21 rue Ferdinand Buisson
BER city Issy-les-Mlx
BER zipcode 92130
BER tel 09.54.36.29.60
BER cell 06.70.06.04.16
WEL name Schmitt
WEL forename Bernard
WEL hired 19/02/1985
WEL address 64 tiergarten strasse
WEL city Berlin
WEL zipcode 95013
WEL tel 03.43.377.360
UK1 name Smith
UK1 forename Harrison
UK1 hired 08/11/2003
UK1 address 143 Blum Rd.
UK1 city London
UK1 zipcode NW1 2BP
UK2 forename Paul
DROP TABLE t1;
SELECT REPLACE(REPLACE(LOAD_FILE('DATADIR/test/contact.ini'),'\r\n','\n'),'\n\n','\n');;
REPLACE(REPLACE(LOAD_FILE('DATADIR/test/contact.ini'),'\r\n','\n'),'\n\n','\n')
[BER]
name=Bertrand
forename=Olivier
address=21 rue Ferdinand Buisson
city=Issy-les-Mlx
zipcode=92130
tel=09.54.36.29.60
cell=06.70.06.04.16
[WEL]
name=Schmitt
forename=Bernard
hired=19/02/1985
address=64 tiergarten strasse
city=Berlin
zipcode=95013
tel=03.43.377.360
[UK1]
name=Smith
forename=Harrison
hired=08/11/2003
address=143 Blum Rd.
city=London
zipcode=NW1 2BP
[UK2]
forename=Paul
#
# Testing that the underlying file is created
#
CREATE TABLE t1
(
contact CHAR(12) NOT NULL flag=1,
c2 CHAR(12) NOT NULL
) ENGINE=CONNECT TABLE_TYPE=INI FILE_NAME='tmp.ini';
INSERT INTO t1 VALUES (10,10),(20,20),(300,300),(4000,4000), ('a b','c d');
SELECT * FROM t1;
contact c2
10 10
20 20
300 300
4000 4000
a b c d
DROP TABLE t1;
SELECT REPLACE(REPLACE(LOAD_FILE('DATADIR/test/tmp.ini'),'\r\n','\n'),'\n\n','\n');;
REPLACE(REPLACE(LOAD_FILE('DATADIR/test/tmp.ini'),'\r\n','\n'),'\n\n','\n')
[10]
c2=10
[20]
c2=20
[300]
c2=300
[4000]
c2=4000
[a b]
c2=c d
[BER]
name=Bertrand
forename=Olivier
address=21 rue Ferdinand Buisson
city=Issy-les-Mlx
zipcode=92130
tel=09.54.36.29.60
cell=06.70.06.04.16
[WEL]
name=Schmitt
forename=Bernard
hired=19/02/1985
address=64 tiergarten strasse
city=Berlin
zipcode=95013
tel=03.43.377.360
[UK1]
name=Smith
forename=Henry
hired=08/11/2003
address=143 Blum Rd.
city=London
zipcode=NW1 2BP
Name;birth;children
"Archibald";17/05/01;3
"Nabucho";12/08/03;2
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
let $MYSQLD_DATADIR= `select @@datadir`;
--copy_file $MYSQL_TEST_DIR/suite/connect/std_data/people.csv $MYSQLD_DATADIR/test/people.csv
--echo #
--echo # Testing errors
--echo #
CREATE TABLE t1
(
ID INT
) Engine=CONNECT TABLE_TYPE=CSV 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 examples from the manual
--echo #
CREATE TABLE t1
(
name CHAR(12),
birth DATE DATE_FORMAT='DD/MM/YY',
children SMALLINT(2)
) ENGINE=CONNECT TABLE_TYPE=CSV FILE_NAME='people.csv'
HEADER=1 SEP_CHAR=';' QUOTED=1;
SELECT * FROM t1;
INSERT INTO t1 VALUES ('RONALD','1980-02-26',4);
SELECT * FROM t1;
DROP TABLE t1;
--chmod 0777 $MYSQLD_DATADIR/test/people.csv
--replace_result $MYSQLD_DATADIR DATADIR
--eval SELECT REPLACE(LOAD_FILE('$MYSQLD_DATADIR/test/people.csv'),'\r\n','\n');
--echo #
--echo # Testing that the underlying file is created
--echo #
CREATE TABLE t1
(
c1 CHAR(12) NOT NULL,
c2 CHAR(12) NOT NULL
) ENGINE=CONNECT TABLE_TYPE=CSV FILE_NAME='tmp.csv'
HEADER=1 SEP_CHAR=',' QUOTED=1;
INSERT INTO t1 VALUES (10,10),(20,20),(300,300),(4000,4000), ('a b','c d');
SELECT * FROM t1;
DROP TABLE t1;
--chmod 0777 $MYSQLD_DATADIR/test/tmp.csv
--replace_result $MYSQLD_DATADIR DATADIR
--eval SELECT REPLACE(LOAD_FILE('$MYSQLD_DATADIR/test/tmp.csv'),'\r\n','\n');
#
# Clean up
#
--remove_file $MYSQLD_DATADIR/test/people.csv
--remove_file $MYSQLD_DATADIR/test/tmp.csv
let $MYSQLD_DATADIR= `select @@datadir`;
CREATE TABLE t1 (
path VARCHAR(256) flag=1,
fname VARCHAR(256),
ftype CHAR(4),
size DOUBLE(12,0) flag=5
) ENGINE=CONNECT TABLE_TYPE=DIR FILE_NAME='*.txt'
OPTION_LIST='subdir=1';
--replace_result $MYSQLD_DATADIR DATADIR/
SELECT * FROM t1;
--copy_file $MYSQL_TEST_DIR/suite/connect/std_data/boys.txt $MYSQLD_DATADIR/test/boys.txt
--copy_file $MYSQL_TEST_DIR/suite/connect/std_data/boyswin.txt $MYSQLD_DATADIR/test/boyswin.txt
--mkdir $MYSQLD_DATADIR/test/subdir/
--copy_file $MYSQLD_DATADIR/test/boys.txt $MYSQLD_DATADIR/test/subdir/boys2.txt
--replace_result $MYSQLD_DATADIR DATADIR/
SELECT fname, ftype, size FROM t1;
ALTER TABLE t1 OPTION_LIST='subdir=0';
SHOW CREATE TABLE t1;
--replace_result $MYSQLD_DATADIR DATADIR/
SELECT fname, ftype, size FROM t1;
# TODO: add a better error message
--error ER_GET_ERRMSG
INSERT INTO t1 VALUES ('','','','');
DROP TABLE t1;
# TODO: automatically add columns
--error ER_TABLE_MUST_HAVE_COLUMNS
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=DIR FILE_NAME='*.txt';
#
# TODO: this fails on Linux
#
#CREATE TABLE t1 t1 (
# DRIVE CHAR(2),
# PATH VARCHAR(256),
# FNAME VARCHAR(256),
# FTYPE CHAR(4),
# SIZE DOUBLE(12,0) flag=5,
# MODIFIED datetime
#) engine=CONNECT table_type=DIR file_name='*.txt';
#SELECT * FROM t1;
#DROP TABLE t1;
--remove_file $MYSQLD_DATADIR/test/subdir/boys2.txt
--rmdir $MYSQLD_DATADIR/test/subdir/
--remove_file $MYSQLD_DATADIR/test/boys.txt
--remove_file $MYSQLD_DATADIR/test/boyswin.txt
let $MYSQLD_DATADIR= `select @@datadir`;
--copy_file $MYSQL_TEST_DIR/suite/connect/std_data/contact.ini $MYSQLD_DATADIR/test/contact.ini
--echo #
--echo # Testing errors
--echo #
CREATE TABLE t1
(
ID INT
) Engine=CONNECT TABLE_TYPE=INI 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 examples from the manual
--echo #
CREATE TABLE t1
(
contact CHAR(16) flag=1,
name CHAR(20),
forename CHAR(32),
hired date date_format='DD/MM/YYYY',
address CHAR(64),
city CHAR(20),
zipcode CHAR(8),
tel CHAR(16)
) ENGINE=CONNECT TABLE_TYPE=INI FILE_NAME='contact.ini';
SELECT contact, name, hired, city, tel FROM t1;
UPDATE t1 SET forename= 'Harry' where contact='UK1';
SELECT * FROM t1 WHERE contact='UK1';
INSERT INTO t1 (contact,forename) VALUES ('UK1','Harrison');
SELECT * FROM t1 WHERE contact='UK1';
INSERT INTO t1 (contact,forename) VALUES ('UK2','John');
SELECT * FROM t1 WHERE contact='UK2';
DROP TABLE t1;
--chmod 0777 $MYSQLD_DATADIR/test/contact.ini
--replace_result $MYSQLD_DATADIR DATADIR
--eval SELECT REPLACE(REPLACE(LOAD_FILE('$MYSQLD_DATADIR/test/contact.ini'),'\r\n','\n'),'\n\n','\n');
CREATE TABLE t1
(
section CHAR(16) flag=1,
keyname CHAR(16) flag=2,
value CHAR(32)
) ENGINE=CONNECT TABLE_TYPE=INI FILE_NAME='contact.ini'
OPTION_LIST='Layout=Row';
UPDATE t1 SET value='Paul' WHERE section='UK2' AND keyname='forename';
SELECT * FROM t1;
DROP TABLE t1;
--chmod 0777 $MYSQLD_DATADIR/test/contact.ini
--replace_result $MYSQLD_DATADIR DATADIR
--eval SELECT REPLACE(REPLACE(LOAD_FILE('$MYSQLD_DATADIR/test/contact.ini'),'\r\n','\n'),'\n\n','\n');
--echo #
--echo # Testing that the underlying file is created
--echo #
CREATE TABLE t1
(
contact CHAR(12) NOT NULL flag=1,
c2 CHAR(12) NOT NULL
) ENGINE=CONNECT TABLE_TYPE=INI FILE_NAME='tmp.ini';
INSERT INTO t1 VALUES (10,10),(20,20),(300,300),(4000,4000), ('a b','c d');
SELECT * FROM t1;
DROP TABLE t1;
--chmod 0777 $MYSQLD_DATADIR/test/tmp.ini
--replace_result $MYSQLD_DATADIR DATADIR
--eval SELECT REPLACE(REPLACE(LOAD_FILE('$MYSQLD_DATADIR/test/tmp.ini'),'\r\n','\n'),'\n\n','\n');
#
# Clean up
#
--remove_file $MYSQLD_DATADIR/test/contact.ini
--remove_file $MYSQLD_DATADIR/test/tmp.ini
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