~vkolesnikov/pbxt/pbxt-07-diskfull

« back to all changes in this revision

Viewing changes to pbxt/mysql-test-update/mysql-test/t/loaddata.test

  • Committer: paul-mccullagh
  • Date: 2006-10-23 09:14:04 UTC
  • Revision ID: paul-mccullagh-918861e03d351978a9541168a96e58cc826734ee
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# Some simple test of load data
 
3
#
 
4
 
 
5
--disable_warnings
 
6
drop table if exists t1, t2;
 
7
--enable_warnings
 
8
 
 
9
create table t1 (a date, b date, c date not null, d date);
 
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;
 
12
SELECT * from t1;
 
13
truncate table t1;
 
14
 
 
15
load data infile '../std_data_ln/loaddata1.dat' into table t1 fields terminated by ',' LINES STARTING BY ',' (b,c,d);
 
16
SELECT * from t1;
 
17
drop table t1;
 
18
 
 
19
create table t1 (a text, b text);
 
20
load data infile '../std_data_ln/loaddata2.dat' into table t1 fields terminated by ',' enclosed by '''';
 
21
select concat('|',a,'|'), concat('|',b,'|') from t1;
 
22
drop table t1;
 
23
 
 
24
create table t1 (a int, b char(10));
 
25
load data infile '../std_data_ln/loaddata3.dat' into table t1 fields terminated by '' enclosed by '' ignore 1 lines;
 
26
select * from t1;
 
27
truncate table t1;
 
28
load data infile '../std_data_ln/loaddata4.dat' into table t1 fields terminated by '' enclosed by '' lines terminated by '' ignore 1 lines;
 
29
 
 
30
# The empty line last comes from the end line field in the file
 
31
select * from t1;
 
32
drop table t1;
 
33
 
 
34
#
 
35
# Bug #12053 LOAD DATA INFILE ignores NO_AUTO_VALUE_ON_ZERO setting
 
36
#
 
37
SET @OLD_SQL_MODE=@@SQL_MODE, @@SQL_MODE=NO_AUTO_VALUE_ON_ZERO;
 
38
create table t1(id integer not null auto_increment primary key);
 
39
insert into t1 values(0);
 
40
disable_query_log;
 
41
eval SELECT * INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/t1' from t1;
 
42
delete from t1;
 
43
eval load data infile '$MYSQLTEST_VARDIR/tmp/t1' into table t1;
 
44
enable_query_log;
 
45
select * from t1;
 
46
--exec rm $MYSQLTEST_VARDIR/tmp/t1
 
47
 
 
48
disable_query_log;
 
49
eval SELECT * INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/t1'
 
50
FIELDS TERMINATED BY '' OPTIONALLY ENCLOSED BY '' LINES TERMINATED BY '\r\n'
 
51
FROM t1;
 
52
delete from t1;
 
53
eval load data infile '$MYSQLTEST_VARDIR/tmp/t1' into table t1
 
54
FIELDS TERMINATED BY '' OPTIONALLY ENCLOSED BY '' LINES TERMINATED BY '\r\n';
 
55
enable_query_log;
 
56
select * from t1;
 
57
--exec rm $MYSQLTEST_VARDIR/tmp/t1
 
58
SET @@SQL_MODE=@OLD_SQL_MODE;
 
59
drop table t1;
 
60
 
 
61
#
 
62
# Bug #11203: LOAD DATA does not accept same characters for ESCAPED and
 
63
# ENCLOSED
 
64
#
 
65
create table t1 (a varchar(20), b varchar(20));
 
66
load data infile '../std_data_ln/loaddata_dq.dat' into table t1 fields terminated by ',' enclosed by '"' escaped by '"' (a,b);
 
67
select * from t1;
 
68
drop table t1;
 
69
 
 
70
# End of 4.1 tests
 
71
 
 
72
#
 
73
# Let us test extended LOAD DATA features
 
74
#
 
75
create table t1 (a int default 100, b int, c varchar(60));
 
76
# we can do something like this
 
77
load data infile '../std_data_ln/rpl_loaddata.dat' into table t1 (a, @b) set b=@b+10, c=concat("b=",@b);
 
78
select * from t1;
 
79
truncate table t1;
 
80
# we can use filled fields in expressions 
 
81
# we also assigning NULL value to field with non-NULL default here
 
82
load data infile '../std_data_ln/rpl_loaddata.dat' into table t1 (a, @b) set c= if(a is null,"oops",a);
 
83
select * from t1;
 
84
truncate table t1;
 
85
# we even can use variables in set clause, and missed columns will be set
 
86
# with default values
 
87
set @c:=123;
 
88
load data infile '../std_data_ln/rpl_loaddata.dat' into table t1 (@a, b) set c= if(@a is null,@c,b);
 
89
select * from t1;
 
90
# let us test side-effect of such load
 
91
load data infile '../std_data_ln/rpl_loaddata.dat' into table t1 (@a, @b);
 
92
select * from t1;
 
93
select @a, @b;
 
94
truncate table t1;
 
95
# Reading of all columns with set
 
96
load data infile '../std_data_ln/rpl_loaddata.dat' into table t1 set c=b;
 
97
select * from t1;
 
98
truncate table t1;
 
99
# now going to test fixed field-row file format
 
100
load data infile '../std_data_ln/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, b) set c="Wow";
 
101
select * from t1;
 
102
truncate table t1;
 
103
# this also should work
 
104
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));
 
105
select * from t1;
 
106
# and this should bark
 
107
--error 1409 
 
108
load data infile '../std_data_ln/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, @b);
 
109
 
 
110
# Now let us test LOAD DATA with subselect
 
111
create table t2 (num int primary key, str varchar(10));
 
112
insert into t2 values (10,'Ten'), (15,'Fifteen');
 
113
truncate table t1;
 
114
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);
 
115
select * from t1;
 
116
 
 
117
# cleanup
 
118
drop table t1, t2;
 
119
 
 
120
# End of 5.0 tests
 
121
 
 
122
 
 
123
#
 
124
# Bug#12448 LOAD DATA / SELECT INTO OUTFILE
 
125
# doesn't work with multibyte path name
 
126
#
 
127
CREATE TABLE t1 (a int);
 
128
INSERT INTO t1 VALUES (1);
 
129
SET NAMES latin1;
 
130
SET character_set_filesystem=filename;
 
131
select @@character_set_filesystem;
 
132
SELECT * INTO OUTFILE 't-1' FROM t1;
 
133
DELETE FROM t1;
 
134
LOAD DATA INFILE 't-1' INTO TABLE t1;
 
135
SELECT * FROM t1;
 
136
DELETE FROM t1;
 
137
SET character_set_filesystem=latin1;
 
138
select @@character_set_filesystem;
 
139
LOAD DATA INFILE 't@002d1' INTO TABLE t1;
 
140
SELECT * FROM t1;
 
141
DROP TABLE t1;
 
142
--exec rm $MYSQLTEST_VARDIR/master-data/test/t@002d1
 
143
SET character_set_filesystem=default;
 
144
select @@character_set_filesystem;