1#
2# Testing errors
3#
4CREATE TABLE t1
5(
6ID INT NOT NULL
7) Engine=CONNECT TABLE_TYPE=DOS FILE_NAME='nonexistent.txt';
8SELECT * FROM t1;
9ID
10Warnings:
11Warning	1105	Open(rb) error 2 on DATADIR/test/nonexistent.txt: No such file or directory
12DROP TABLE t1;
13#
14# Testing READONLY tables
15#
16CREATE TABLE t1
17(
18id INT NOT NULL
19) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='t1.txt';
20INSERT INTO t1 VALUES (10);
21SELECT * FROM t1;
22id
2310
24ALTER TABLE t1 READONLY=1;
25SHOW CREATE TABLE t1;
26Table	Create Table
27t1	CREATE TABLE `t1` (
28  `id` int(11) NOT NULL
29) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`=FIX `FILE_NAME`='t1.txt' `READONLY`=1
30INSERT INTO t1 VALUES (20);
31ERROR HY000: Table 't1' is read only
32UPDATE t1 SET id=20 WHERE id=10;
33ERROR HY000: Got error 174 'Cannot modify this read/only protected table' from CONNECT
34DELETE FROM t1 WHERE id=10;
35ERROR HY000: Got error 174 'Cannot modify this read/only protected table' from CONNECT
36TRUNCATE TABLE t1;
37ERROR HY000: Table 't1' is read only
38ALTER TABLE t1 READONLY=0;
39SHOW CREATE TABLE t1;
40Table	Create Table
41t1	CREATE TABLE `t1` (
42  `id` int(11) NOT NULL
43) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`=FIX `FILE_NAME`='t1.txt' `READONLY`=0
44INSERT INTO t1 VALUES (20);
45SELECT * FROM t1;
46id
4710
4820
49DROP TABLE t1;
50#
51# Testing manual examples
52#
53CREATE TABLE t1
54(
55number   CHAR(4) not null,
56location CHAR(15) NOT NULL flag=5,
57director CHAR(5) NOT NULL flag=20,
58function CHAR(12) NOT NULL flag=26,
59name     CHAR(22) NOT NULL flag=38
60) ENGINE=CONNECT TABLE_TYPE=DOS FILE_NAME='dept.dat';
61SELECT * FROM t1;
62number	location	director	function	name
630318	KINGSTON	70012	SALES	Bank/Insurance
640021	ARMONK	87777	CHQ	Corporate headquarter
650319	HARRISON	40567	SALES	Federal Administration
662452	POUGHKEEPSIE	31416	DEVELOPMENT	Research & development
67DROP TABLE t1;
68CREATE TABLE t1
69(
70name char(12) not null,
71city char(11) not null,
72birth date not null date_format='DD/MM/YYYY',
73hired date not null date_format='DD/MM/YYYY' flag=36
74) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='boys.txt' ENDING=1;
75SELECT * FROM t1;
76name	city	birth	hired
77John	Boston	1986-01-25	2010-06-02
78Henry	Boston	1987-06-07	2008-04-01
79George	San Jose	1981-08-10	2010-06-02
80Sam	Chicago	1979-11-22	2007-10-10
81James	Dallas	1992-05-13	2009-12-14
82Bill	Boston	1986-09-11	2008-02-10
83DROP TABLE t1;
84CREATE TABLE t1
85(
86name char(12) not null,
87city char(11) not null,
88birth date not null date_format='DD/MM/YYYY',
89hired date not null date_format='DD/MM/YYYY' flag=36
90) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='boys.txt' LRECL=47 ENDING=1;
91SELECT * FROM t1;
92name	city	birth	hired
93John	Boston	1986-01-25	2010-06-02
94Henry	Boston	1987-06-07	2008-04-01
95George	San Jose	1981-08-10	2010-06-02
96Sam	Chicago	1979-11-22	2007-10-10
97James	Dallas	1992-05-13	2009-12-14
98Bill	Boston	1986-09-11	2008-02-10
99DROP TABLE t1;
100CREATE TABLE t1
101(
102name char(12) not null,
103city char(11) not null,
104birth date not null date_format='DD/MM/YYYY',
105hired date not null date_format='DD/MM/YYYY' flag=36
106) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='boyswin.txt' ENDING=2;
107SELECT * FROM t1;
108name	city	birth	hired
109John	Boston	1986-01-25	2010-06-02
110Henry	Boston	1987-06-07	2008-04-01
111George	San Jose	1981-08-10	2010-06-02
112Sam	Chicago	1979-11-22	2007-10-10
113James	Dallas	1992-05-13	2009-12-14
114Bill	Boston	1986-09-11	2008-02-10
115DROP TABLE t1;
116CREATE TABLE t1
117(
118name char(12) not null,
119city char(11) not null,
120birth date not null date_format='DD/MM/YYYY',
121hired date not null date_format='DD/MM/YYYY' flag=36
122) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='boyswin.txt' LRECL=47 ENDING=2;
123SELECT * FROM t1;
124name	city	birth	hired
125John	Boston	1986-01-25	2010-06-02
126Henry	Boston	1987-06-07	2008-04-01
127George	San Jose	1981-08-10	2010-06-02
128Sam	Chicago	1979-11-22	2007-10-10
129James	Dallas	1992-05-13	2009-12-14
130Bill	Boston	1986-09-11	2008-02-10
131DROP TABLE t1;
132