~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/insert.test

  • Committer: Monty Taylor
  • Date: 2008-12-18 07:24:54 UTC
  • mto: This revision was merged to the branch mainline in revision 714.
  • Revision ID: monty@bitters-20081218072454-8pnep622damjgqli
Fixed one more my_time thing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
#
20
20
 
21
21
create table t1 (id int not null auto_increment primary key, username varchar(32) not null, unique (username));
22
 
insert into t1 values (NULL,"mysql");
23
 
insert into t1 values (NULL,"mysql ab");
24
 
insert into t1 values (NULL,"mysql a");
25
 
insert into t1 values (NULL,"r1manic");
26
 
insert into t1 values (NULL,"r1man");
 
22
insert into t1 values (0,"mysql");
 
23
insert into t1 values (0,"mysql ab");
 
24
insert into t1 values (0,"mysql a");
 
25
insert into t1 values (0,"r1manic");
 
26
insert into t1 values (0,"r1man");
27
27
drop table t1;
28
28
 
29
29
#
30
30
# Test insert syntax
31
31
#
32
32
 
33
 
create table t1 (a int not null auto_increment, primary key (a), t timestamp null, c char(10) default "hello", i int);
34
 
insert into t1 values (default,default,default,default);
35
 
insert into t1 values (default,default,default,default);
36
 
--error ER_INVALID_TIMESTAMP_VALUE # Bad timestamp
37
 
insert into t1 values (4,0,"a",5);
38
 
insert into t1 values (default,default,default,default);
39
 
select a,t is not null,c,i from t1;
 
33
create table t1 (a int not null auto_increment, primary key (a), t timestamp, c char(10) default "hello", i int);
 
34
insert into t1 values (default,default,default,default), (default,default,default,default), (4,0,"a",5),(default,default,default,default);
 
35
select a,t>0,c,i from t1;
40
36
truncate table t1;
41
37
insert into t1 set a=default,t=default,c=default;
42
38
insert into t1 set a=default,t=default,c=default,i=default;
43
 
insert into t1 set a=4,t= NULL,c="a",i=5;
44
 
insert into t1 set a=5,t= NULL,c="a",i=null;
 
39
insert into t1 set a=4,t=0,c="a",i=5;
 
40
insert into t1 set a=5,t=0,c="a",i=null;
45
41
insert into t1 set a=default,t=default,c=default,i=default;
46
 
select a,t is not null,c,i from t1;
 
42
select a,t>0,c,i from t1;
47
43
drop table t1;
48
44
 
49
45
#
51
47
#
52
48
 
53
49
create table t1 (id int NOT NULL DEFAULT 8);
54
 
--error ER_BAD_NULL_ERROR
 
50
-- error 1048
55
51
insert into t1 values(NULL);
56
 
--error ER_BAD_NULL_ERROR
 
52
-- error 1048
57
53
insert into t1 values (1), (NULL), (2);
58
54
select * from t1;
59
55
drop table t1;
65
61
create table t1 (email varchar(50));
66
62
insert into t1 values ('sasha@mysql.com'),('monty@mysql.com'),('foo@hotmail.com'),('foo@aol.com'),('bar@aol.com');
67
63
create table t2(id int not null auto_increment primary key, t2 varchar(50), unique(t2));
68
 
insert into t2 (t2) select distinct substring(email, locate('@', email)+1) from t1;
 
64
insert delayed into t2 (t2) select distinct substring(email, locate('@', email)+1) from t1;
69
65
select * from t2;
70
66
drop table t1,t2;
71
67
 
94
90
create table t2(id2 int not null, t char(12));
95
91
create table t3(id3 int not null, t char(12), index(id3));
96
92
disable_query_log;
 
93
set autocommit=0;
97
94
begin;
98
95
let $1 = 100;
99
96
while ($1)
115
112
 }
116
113
enable_query_log;
117
114
select count(*) from t2;
118
 
--error ER_USE_SQL_BIG_RESULT
119
115
insert into  t2 select t1.* from t1, t2 t, t3 where  t1.id1 = t.id2 and t.id2 = t3.id3;
120
 
insert into  t2 select SQL_BIG_RESULT t1.* from t1, t2 t, t3 where  t1.id1 = t.id2 and t.id2 = t3.id3;
121
116
select count(*) from t2;
122
 
COMMIT;
123
117
drop table t1,t2,t3;
124
118
 
125
119
#
131
125
insert into t1 SET a=1, b=a+1;
132
126
insert into t1 (a,b) select 1,2;
133
127
INSERT INTO t1 ( a ) SELECT 0 ON DUPLICATE KEY UPDATE a = a + VALUES (a);
134
 
--error ER_FIELD_SPECIFIED_TWICE
 
128
--error 1110
135
129
replace into t1 (a,a) select 100, 'hundred';
136
 
--error ER_FIELD_SPECIFIED_TWICE
 
130
--error 1110
137
131
insert into t1 (a,b,b) values (1,1,1);
138
 
--error ER_WRONG_VALUE_COUNT_ON_ROW
 
132
--error 1136
139
133
insert into t1 (a,a) values (1,1,1);
140
 
--error ER_FIELD_SPECIFIED_TWICE
 
134
--error 1110
141
135
insert into t1 (a,a) values (1,1);
142
 
--error ER_FIELD_SPECIFIED_TWICE
 
136
--error 1110
143
137
insert into t1 SET a=1,b=2,a=1;
144
 
--error ER_FIELD_SPECIFIED_TWICE
 
138
--error 1110
145
139
insert into t1 (b,b) select 1,2;
146
 
--error ER_FIELD_SPECIFIED_TWICE
 
140
--error 1110
147
141
INSERT INTO t1 (b,b) SELECT 0,0 ON DUPLICATE KEY UPDATE a = a + VALUES (a);
148
142
drop table t1;
149
143