~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/loaddata.test

This patch completes the first step in the splitting of
the XA resource manager API from the storage engine API,
as outlined in the specification here:

http://drizzle.org/wiki/XaStorageEngine

* Splits plugin::StorageEngine into a base StorageEngine
  class and two derived classes, TransactionalStorageEngine
  and XaStorageEngine.  XaStorageEngine derives from
  TransactionalStorageEngine and creates the XA Resource
  Manager API for storage engines.

  - The methods moved from StorageEngine to TransactionalStorageEngine
    include releaseTemporaryLatches(), startConsistentSnapshot(), 
    commit(), rollback(), setSavepoint(), releaseSavepoint(),
    rollbackToSavepoint() and hasTwoPhaseCommit()
  - The methods moved from StorageEngine to XaStorageEngine
    include recover(), commitXid(), rollbackXid(), and prepare()

* Places all static "EngineVector"s into their proper
  namespaces (typedefs belong in header files, not implementation files)
  and places all static methods corresponding
  to either only transactional engines or only XA engines
  into their respective files in /drizzled/plugin/

* Modifies the InnoDB "handler" files to extend plugin::XaStorageEngine
  and not plugin::StorageEngine

The next step, as outlined in the wiki spec page above, is to isolate
the XA Resource Manager API into its own plugin class and modify
plugin::XaStorageEngine to implement plugin::XaResourceManager via
composition.  This is necessary to enable building plugins which can
participate in an XA transaction *without having to have that plugin
implement the entire storage engine API*

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
--enable_warnings
8
8
 
9
9
create table t1 (a date, b date, c date not null, d date);
10
 
--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
11
 
eval load data infile '$DRIZZLETEST_VARDIR/std_data_ln/loaddata1.dat' into table t1 fields terminated by ',';
12
 
--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
13
 
eval load data infile '$DRIZZLETEST_VARDIR/std_data_ln/loaddata1.dat' into table t1 fields terminated by ',' IGNORE 2 LINES;
 
10
load data infile '../std_data_ln/loaddata1.dat' into table t1 fields terminated by ',';
 
11
load data infile '../std_data_ln/loaddata1.dat' into table t1 fields terminated by ',' IGNORE 2 LINES;
14
12
SELECT * from t1;
15
13
truncate table t1;
16
14
 
17
 
--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
18
 
eval load data infile '$DRIZZLETEST_VARDIR/std_data_ln/loaddata1.dat' into table t1 fields terminated by ',' LINES STARTING BY ',' (b,c,d);
 
15
load data infile '../std_data_ln/loaddata1.dat' into table t1 fields terminated by ',' LINES STARTING BY ',' (b,c,d);
19
16
SELECT * from t1;
20
17
drop table t1;
21
18
 
22
19
create table t1 (a text, b text);
23
 
--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
24
 
eval load data infile '$DRIZZLETEST_VARDIR/std_data_ln/loaddata2.dat' into table t1 fields terminated by ',' enclosed by '''';
 
20
load data infile '../std_data_ln/loaddata2.dat' into table t1 fields terminated by ',' enclosed by '''';
25
21
select concat('|',a,'|'), concat('|',b,'|') from t1;
26
22
drop table t1;
27
23
 
28
24
create table t1 (a int, b char(10));
29
 
--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
30
 
eval load data infile '$DRIZZLETEST_VARDIR/std_data_ln/loaddata3.dat' into table t1 fields terminated by '' enclosed by '' ignore 1 lines;
 
25
load data infile '../std_data_ln/loaddata3.dat' into table t1 fields terminated by '' enclosed by '' ignore 1 lines;
31
26
select * from t1;
32
27
truncate table t1;
33
28
 
40
35
# ENCLOSED
41
36
#
42
37
create table t1 (a varchar(20), b varchar(20));
43
 
--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
44
 
eval load data infile '$DRIZZLETEST_VARDIR/std_data_ln/loaddata_dq.dat' into table t1 fields terminated by ',' enclosed by '"' escaped by '"' (a,b);
 
38
load data infile '../std_data_ln/loaddata_dq.dat' into table t1 fields terminated by ',' enclosed by '"' escaped by '"' (a,b);
45
39
select * from t1;
46
40
drop table t1;
47
41
 
67
61
  ('.r.'), ('.rr.'), ('.rrr.'), ('.rrrr.');
68
62
SELECT * FROM t1;
69
63
 
70
 
--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
71
 
eval SELECT * INTO OUTFILE '$DRIZZLETEST_VARDIR/tmp/t1' FIELDS ENCLOSED BY 'r' FROM t1;
72
 
cat_file $DRIZZLETEST_VARDIR/tmp/t1;
 
64
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
 
65
eval SELECT * INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/t1' FIELDS ENCLOSED BY 'r' FROM t1;
 
66
cat_file $MYSQLTEST_VARDIR/tmp/t1;
73
67
 
74
 
--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
75
 
eval LOAD DATA INFILE '$DRIZZLETEST_VARDIR/tmp/t1' INTO TABLE t2 FIELDS ENCLOSED BY 'r';
 
68
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
 
69
eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/t1' INTO TABLE t2 FIELDS ENCLOSED BY 'r';
76
70
SELECT t1.id, c1, c2 FROM t1 LEFT  JOIN t2 ON t1.id=t2.id WHERE c1 != c2;
77
71
SELECT t1.id, c1, c2 FROM t1 RIGHT JOIN t2 ON t1.id=t2.id WHERE c1 != c2;
78
72
 
79
 
remove_file $DRIZZLETEST_VARDIR/tmp/t1;
 
73
remove_file $MYSQLTEST_VARDIR/tmp/t1;
80
74
DROP TABLE t1,t2;
81
75
 
82
76
# End of 4.1 tests
86
80
#
87
81
create table t1 (a int default 100, b int, c varchar(60));
88
82
# we can do something like this
89
 
--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
90
 
eval load data infile '$DRIZZLETEST_VARDIR/std_data_ln/rpl_loaddata.dat' into table t1 (a, @b) set b=@b+10, c=concat("b=",@b);
 
83
load data infile '../std_data_ln/rpl_loaddata.dat' into table t1 (a, @b) set b=@b+10, c=concat("b=",@b);
91
84
select * from t1;
92
85
truncate table t1;
93
86
# we can use filled fields in expressions 
94
87
# we also assigning NULL value to field with non-NULL default here
95
 
--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
96
 
eval load data infile '$DRIZZLETEST_VARDIR/std_data_ln/rpl_loaddata.dat' into table t1 (a, @b) set c= if(a is null,"oops",a);
 
88
load data infile '../std_data_ln/rpl_loaddata.dat' into table t1 (a, @b) set c= if(a is null,"oops",a);
97
89
select * from t1;
98
90
truncate table t1;
99
91
# we even can use variables in set clause, and missed columns will be set
100
92
# with default values
101
93
set @c:=123;
102
 
--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
103
 
eval load data infile '$DRIZZLETEST_VARDIR/std_data_ln/rpl_loaddata.dat' into table t1 (@a, b) set c= if(@a is null,@c,b);
 
94
load data infile '../std_data_ln/rpl_loaddata.dat' into table t1 (@a, b) set c= if(@a is null,@c,b);
104
95
select * from t1;
105
96
# let us test side-effect of such load
106
 
--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
107
 
eval load data infile '$DRIZZLETEST_VARDIR/std_data_ln/rpl_loaddata.dat' into table t1 (@a, @b);
 
97
load data infile '../std_data_ln/rpl_loaddata.dat' into table t1 (@a, @b);
108
98
select * from t1;
109
99
select @a, @b;
110
100
truncate table t1;
111
101
# now going to test fixed field-row file format
112
 
--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
113
 
eval load data infile '$DRIZZLETEST_VARDIR/std_data_ln/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, b) set c="Wow";
 
102
load data infile '../std_data_ln/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, b) set c="Wow";
114
103
select * from t1;
115
104
truncate table t1;
116
105
# this also should work
117
 
--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
118
 
eval load data infile '$DRIZZLETEST_VARDIR/std_data_ln/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, b) set c=concat(a,"+",b,"+",@c,"+",b,"+",if(c is null,"NIL",c));
 
106
load data infile '../std_data_ln/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, b) set c=concat(a,"+",b,"+",@c,"+",b,"+",if(c is null,"NIL",c));
119
107
select * from t1;
120
108
# and this should bark
121
 
--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
122
 
--error ER_LOAD_FROM_FIXED_SIZE_ROWS_TO_VAR 
123
 
eval load data infile '$DRIZZLETEST_VARDIR/std_data_ln/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, @b);
 
109
--error 1409 
 
110
load data infile '../std_data_ln/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, @b);
124
111
 
125
112
# Now let us test LOAD DATA with subselect
126
113
create table t2 (num int primary key, str varchar(10));
127
114
insert into t2 values (10,'Ten'), (15,'Fifteen');
128
115
truncate table t1;
129
 
--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
130
 
eval load data infile '$DRIZZLETEST_VARDIR/std_data_ln/rpl_loaddata.dat' into table t1 (@dummy,@n) set a= @n, c= (select str from t2 where num=@n);
 
116
load data infile '../std_data_ln/rpl_loaddata.dat' into table t1 (@dummy,@n) set a= @n, c= (select str from t2 where num=@n);
131
117
select * from t1;
132
118
 
133
119
#
135
121
#
136
122
# It should not be possible to load from a file outside of vardir
137
123
 
138
 
--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
 
124
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
139
125
show variables like "secure_file_pri%";
140
 
--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
 
126
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
141
127
select @@secure_file_priv;
142
 
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
 
128
--error 1238
143
129
set @@secure_file_priv= 0;
144
130
 
145
131
# Test "load data"
146
132
truncate table t1;
147
133
--replace_result $DRIZZLE_TEST_DIR DRIZZLE_TEST_DIR
148
 
--error ER_OPTION_PREVENTS_STATEMENT
 
134
--error 1290
149
135
eval load data infile '$DRIZZLE_TEST_DIR/t/loaddata.test' into table t1;
150
136
select * from t1;
151
137
 
 
138
# Test "load_file" returns NULL
152
139
--replace_result $DRIZZLE_TEST_DIR DRIZZLE_TEST_DIR
153
 
--error ER_OPTION_PREVENTS_STATEMENT
154
140
eval select load_file("$DRIZZLE_TEST_DIR/t/loaddata.test");
155
141
 
156
142
# cleanup
164
150
create table t2(f1 int);
165
151
insert into t2 values(1),(2);
166
152
disable_query_log;
167
 
eval select * into outfile '$DRIZZLETEST_VARDIR/tmp/t2' from t2;
168
 
--error ER_WARN_TOO_FEW_RECORDS
169
 
eval load data infile '$DRIZZLETEST_VARDIR/tmp/t2' into table t1;
 
153
eval select * into outfile '$MYSQLTEST_VARDIR/tmp/t2' from t2;
 
154
--error 1261
 
155
eval load data infile '$MYSQLTEST_VARDIR/tmp/t2' into table t1;
170
156
enable_query_log;
171
157
select f1 from t1 where f2 IS NOT NULL order by f1;
172
 
remove_file $DRIZZLETEST_VARDIR/tmp/t2;
 
158
remove_file $MYSQLTEST_VARDIR/tmp/t2;
173
159
delete from t1;
174
160
disable_query_log;
175
 
eval SELECT * INTO OUTFILE '$DRIZZLETEST_VARDIR/tmp/t2'
 
161
eval SELECT * INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/t2'
176
162
FIELDS TERMINATED BY '' OPTIONALLY ENCLOSED BY '' LINES TERMINATED BY '\r\n'
177
163
FROM t2;
178
 
--error ER_WARN_TOO_FEW_RECORDS
179
 
eval load data infile '$DRIZZLETEST_VARDIR/tmp/t2' into table t1
 
164
--error 1261
 
165
eval load data infile '$MYSQLTEST_VARDIR/tmp/t2' into table t1
180
166
FIELDS TERMINATED BY '' OPTIONALLY ENCLOSED BY '' LINES TERMINATED BY '\r\n';
181
167
enable_query_log;
182
168
select f1 from t1 where f2 IS NOT NULL order by f1;
183
 
remove_file $DRIZZLETEST_VARDIR/tmp/t2;
 
169
remove_file $MYSQLTEST_VARDIR/tmp/t2;
184
170
drop table t1,t2;
185
171
 
186
172
#
193
179
INSERT INTO t1 (c1, c2, c3, c4) VALUES (10, '1970-02-01 01:02:03', 1.1E-100, 1.1E+100);
194
180
SELECT * FROM t1;
195
181
 
196
 
--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
197
 
eval SELECT * INTO OUTFILE '$DRIZZLETEST_VARDIR/tmp/t1' FIELDS ENCLOSED BY '-' FROM t1;
198
 
#cat_file $DRIZZLETEST_VARDIR/tmp/t1;
 
182
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
 
183
eval SELECT * INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/t1' FIELDS ENCLOSED BY '-' FROM t1;
 
184
#cat_file $MYSQLTEST_VARDIR/tmp/t1;
199
185
echo EOF;
200
186
 
201
187
TRUNCATE t1;
202
188
 
203
 
--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
204
 
eval LOAD DATA INFILE '$DRIZZLETEST_VARDIR/tmp/t1' INTO TABLE t1 FIELDS ENCLOSED BY '-';
 
189
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
 
190
eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/t1' INTO TABLE t1 FIELDS ENCLOSED BY '-';
205
191
SELECT * FROM t1;
206
192
 
207
 
remove_file $DRIZZLETEST_VARDIR/tmp/t1;
 
193
remove_file $MYSQLTEST_VARDIR/tmp/t1;
208
194
DROP TABLE t1;