oceanbase
237 строк · 12.3 Кб
1--disable_query_log
2set @@session.explicit_defaults_for_timestamp=off;
3--enable_query_log
4#owner: link.zt
5#owner group: sql1
6
7--source mysql_test/include/index_quick_major.inc
8#case:int as idx
9--disable_warnings
10drop table if exists tbl1;
11--enable_warnings
12create table tbl1 (pk int,i1 int, v2 varchar(80), i3 char(20),i4 float, d4 datetime(6),i5 decimal(5,3),i6 bool, primary key(pk));
13insert into tbl1 values(1,1,'abc12','1agc',1.25,'2014-01-01 12:00:00',23.23,1),
14(2,10,'23abc12','4agc1',-0.25,'2015-11-01 12:00:00',-23.230,0),
15(3,201,'xx23abc12','cagc1',-2.25,'2015-11-21 11:20:10',3.231,1),
16(4,80,'zx23abc12','zcagc1',2.25,'2013-01-21 11:20:10',-3.231,1),
17(5,53,'cx23abc12','rcagc1',109.25,'2016-01-22 11:20:10',-13.131,0),
18(6,78,'tx23abc12','icagc1',-109.25,'2014-09-16 16:24:00',-13.531,1),
19(7,400,'yx23abc12','ocagc1',85.85,'2014-09-17 16:20:21',-93.131,0),
20(8,50,'vx23abc12','wcagc1',-85.85,'2014-09-10 16:20:21',93.131,1),
21(9,610,'ukx23abc12','pecagc1',-1.85,'2014-09-19 16:20:21',99.131,0),
22(10,42,'kx23abc12','ecagc1',-85.86,'2014-09-18 16:20:21',-99.131,1),
23(11,null,null,null,null,null,null,null);
24create unique index idx_1 on tbl1(i1);
25--source mysql_test/include/check_all_idx_ok.inc
26select date_sub(null, INTERVAL -6 DAY);
27select * from tbl1;
28update tbl1 set i1=i1-20 where pk<=11 limit 20;
29update tbl1 set i1=i1+20 where pk<=11 limit 20;
30select * from tbl1;
31update tbl1 set v2=concat(v2,'abc') where i1<=100 order by i1 limit 10;
32update tbl1 set v2=substr(v2,1,10) where i1<=100 order by i1 limit 10;
33select * from tbl1;
34#update tbl1 set i3=concat(v2,'abc') where i1 in (1,201,10,80,420,600) order by i1 asc limit 5;
35#update tbl1 set i3=substr(v2,1,10) where i1 in (1,201,10,80,420,600) order by i1 asc limit 5;
36update tbl1 set i3=concat(v2,'abc') where i1 in (1,201,10,80,420,600) limit 5;
37update tbl1 set i3=substr(v2,1,10) where i1 in (1,201,10,80,420,600) limit 5;
38--disable_parsing
39update tbl1 set i4=i4*2;
40update tbl1 set i4=i4/2;
41#update tbl1 set d4=date_sub(d4, INTERVAL -6 DAY) ;
42update tbl1 set d4=date_sub(d4, INTERVAL -6 DAY) where d4 is not null;
43#update tbl1 set d4=date_add(d4, INTERVAL -6 DAY) ;
44update tbl1 set d4=date_add(d4, INTERVAL -6 DAY) where d4 is not null;
45update tbl1 set i5=i5+0.05;
46update tbl1 set i5=i5-0.05;
47update tbl1 set i6=i6 and 1;
48select * from tbl1;
49select * from tbl1 where i1>10 and i1<=1000;
50select * from tbl1 where i1>10+1 and i1<1000;
51select * from tbl1 where i1 between 10+1 and 1000;
52prepare stmt1 from select * from tbl1 where i1>?+1 and i1<?-10;
53set @a=10;
54set @b=1000;
55execute stmt1 using @a, @b;
56set @a=10+1-1;
57set @b=1000-1+1;
58execute stmt1 using @a, @b;
59select * from tbl1 where i1>10 and i1<1000-10;
60select * from tbl1 where i1>10+1 and i1<1000-10;
61select * from tbl1 where i1>1*10+1 and i1<1000;
62select * from tbl1 where i1>10 and i1<=1000*2;
63select * from tbl1 where i1>10*2+3 and i1<=1000*2;
64select * from tbl1 where i1>1*50/5+1 and i1<=1000*2/2+1;
65select * from tbl1 where i1>50 and i1<=1000*2/2+1;
66select * from tbl1 where i1>50*1+3 and i1<=1000;
67select * from tbl1 where i1>(19 mod 10)+1 and i1<=1000;
68select * from tbl1 where i1>(19 mod 10)+1 and i1<=(1000 mod 1001) +10;
69prepare stmt1 from select * from tbl1 where i1>(? mod 10) and i1<(? mod 1005)-10;
70set @a=10;
71set @b=1001;
72execute stmt1 using @a, @b;
73set @a=10+1-1;
74set @b=1001-1+1;
75execute stmt1 using @a, @b;
76select * from tbl1 where i1>10 and i1<1000-10;
77select * from tbl1 where i1>10+1 and i1<1000-10;
78select * from tbl1 where i1>1*10+1 and i1<1000;
79select * from tbl1 where i1>10 and i1<=1000*2;
80select * from tbl1 where i1>10*2+3 and i1<=1000*2;
81update tbl1 set i1=i1+1-1 where i1>10*2+3 and i1<=1000*2;
82select * from tbl1 where i1>1*50/5+1 and i1<=1000*2/2+1;
83select * from tbl1 where i1>50 and i1<=1000*2/2+1;
84select * from tbl1 where i1>50*1+3 and i1<=1000;
85select * from tbl1 where i1>(19 mod 10)+1 and i1<=1000;
86select * from tbl1 where i1>(19 mod 10)+1 and i1<=(1000 mod 1001) +10;
87select * from tbl1 where i1>10 and i1<=(1000 mod 1001) +10;
88select * from tbl1 where i1>10+0 and i1<=(1000*1001) +10;
89select * from tbl1 where i1>=10+null and i1<=(1000*1001) +10;
90select * from tbl1 where i1>=10+1 and i1<=(1000*2) +null;
91select * from tbl1 where i1>=10+1 and i1<=(1000*2) or i1 is null;
92update tbl1 set i1=i1+1-1 where i1>=10+1 and i1<=(1000*2) or i1 is null;
93--error 1064
94select * from tbl1 where i1>=10+1 and i1<=(1000*2) or i1 is (null+1);
95--error 5083
96select * from tbl1 where i1>=10+1 and i1<=(1000*2) or i1 is null+1;
97select * from tbl1 where i1>=10+1 and i1<=(1000*2) and i1 is null;
98select * from tbl1 where i1>=10+1 and i1<=(1000*2) and i1 is not null;
99update tbl1 set i1=i1+100-100 where i1>=10+1 and i1<=(1000*2) and i1 is not null;
100select * from tbl1 where i1>=10+1 and i1<=(100*2) or i1 = 610;
101select * from tbl1 where i1>=10+1 and i1<=(100*2) or i3 = 'cx23abc12';
102select * from tbl1 where i1>=10+1 and i1<=(100*2) and i5 between 0 and 1000;
103prepare stmt1 from select * from tbl1 where i1>=?+1 and i1<=(?*2) and i5 between ? and ?;
104set @a=10;
105set @b=100;
106set @c=0;
107set @d=1000;
108execute stmt1 using @a, @b,@c,@d;
109set @a=10+1-1;
110set @b=1000-1+1;
111set @c=0+1000-1+1-1000;
112set @d=1000-1+1;
113execute stmt1 using @a, @b,@c,@d;
114prepare stmt1 from update tbl1 set i1=i1+15-15 where i1>=?+1 and i1<=(?*2) and i5 between ? and ?;
115set @a=10;
116set @b=100;
117set @c=0;
118set @d=1000;
119execute stmt1 using @a, @b,@c,@d;
120set @a=10+1-1;
121set @b=1000-1+1;
122set @c=0+1000-1+1-1000;
123set @d=1000-1+1;
124execute stmt1 using @a, @b,@c,@d;
125select * from tbl1 where i1>=10+1 and i1<=(100*10) and i5 between -100 and 1000;
126select * from tbl1 where i1 between 10+1 and (100*10) and i5 between -100 and 1000;
127select * from tbl1 where i1<=round(1000.5) and i1>=round(0.5);
128update tbl1 set i1=i1*2/2 where i1<=round(1000.5) and i1>=round(0.5);
129select * from tbl1 where i1>=0 and i1<=EXTRACT(DAY FROM '2014-09-30 12:00:00' )+600;
130select * from tbl1 where i1>=EXTRACT(DAY FROM '2014-09-30 12:00:00' )-29 and i1<=EXTRACT(DAY FROM '2014-09-30 12:00:00' )+600;
131update tbl1 set i1=i1+1-1 where i1>=EXTRACT(DAY FROM '2014-09-30 12:00:00' )-29 and i1<=EXTRACT(DAY FROM '2014-09-30 12:00:00' )+600;
132update tbl1 set i5=i5+1-1 where i1>=EXTRACT(DAY FROM '2014-09-30 12:00:00' )-29 and i1<=EXTRACT(DAY FROM '2014-09-30 12:00:00' )+600;
133#case:more than noe cloumn idx
134drop index idx_1 on tbl1;
135create index idx_12 on tbl1(i1,i5);
136--source mysql_test/include/check_all_idx_ok.inc
137select * from tbl1 where i1>10 and i1<=1000;
138select * from tbl1 where i1>10+1 and i1<1000;
139select * from tbl1 where i1>10 and i1<1000-10;
140select * from tbl1 where i1>10+1 and i1<1000-10;
141select * from tbl1 where i1>1*10+1 and i1<1000;
142select * from tbl1 where i1>10 and i1<=1000*2;
143select * from tbl1 where i1>10*2+3 and i1<=1000*2;
144select * from tbl1 where i1>10 and i1<=(1000 mod 1001) +10;
145select * from tbl1 where i1>10+0 and i1<=(1000*1001) +10;
146select * from tbl1 where i1>=10+null and i1<=(1000*1001) +10;
147select * from tbl1 where i1>=10+1 and i1<=(1000*2) +null;
148select * from tbl1 where i1>=10+1 and i1<=(1000*2) or i1 is null;
149select * from tbl1 where i1>=10+1 and i1<=(1000*2) and i1 is null;
150select * from tbl1 where i1>=10+1 and i1<=(1000*2) and i1 is not null;
151select * from tbl1 where i1>=10+1 and i1<=(100*2) or i1 = 610;
152select * from tbl1 where i1>=10+1 and i1<=(100*2) or i3 = 'cx23abc12';
153select * from tbl1 where i1>=10+1 and i1<=(100*2) and i5 between 0 and 1000;
154select * from tbl1 where i1>=10+1 and i1<=(100*10) and i5 between -100 and 1000;
155select * from tbl1 where i1<=round(1000.5) and i1>=round(0.5);
156select * from tbl1 where i1>=0 and i1<=EXTRACT(DAY FROM '2014-09-30 12:00:00' )+600;
157select * from tbl1 where i1>=EXTRACT(DAY FROM '2014-09-30 12:00:00' )-29 and i1<=EXTRACT(DAY FROM '2014-09-30 12:00:00' )+600;
158select * from tbl1 where i1 in(1,10,42,50,null,610,400);
159select * from tbl1 where (i1,i4) in((1,1.25),(10,-0.25),(80,2.25),(42,-85.85));
160select * from tbl1 where (i4,i1) in ((1.25,1),(-0.25,10),(-85.85,42),(2.25,80));
161#case:more than noe cloumn idx
162#drop index idx_1 on tbl1;
163create index idx_15 on tbl1(i1,i5);
164--source mysql_test/include/check_all_idx_ok.inc
165select * from tbl1 where i1>10 and i1<=1000;
166select * from tbl1 where i1>10+1 and i1<1000;
167select * from tbl1 where i1>10 and i1<1000-10;
168select * from tbl1 where i1>10+1 and i1<1000-10;
169select * from tbl1 where i1>1*10+1 and i1<1000;
170select * from tbl1 where i1>10 and i1<=1000*2;
171select * from tbl1 where i1>10*2+3 and i1<=1000*2;
172select * from tbl1 where i1>1*50/5+1 and i1<=1000*2/2+1;
173select * from tbl1 where i1>50 and i1<=1000*2/2+1;
174select * from tbl1 where i1>50*1+3 and i1<=1000;
175select * from tbl1 where i1>(19 mod 10)+1 and i1<=1000;
176select * from tbl1 where i1>(19 mod 10)+1 and i1<=(1000 mod 1001) +10;
177select * from tbl1 where i1>10 and i1<=(1000 mod 1001) +10;
178select * from tbl1 where i1>10+0 and i1<=(1000*1001) +10;
179select * from tbl1 where i1>=10+null and i1<=(1000*1001) +10;
180select * from tbl1 where i1>=10+1 and i1<=(1000*2) +null;
181select * from tbl1 where i1>=10+1 and i1<=(1000*2) or i1 is null;
182select * from tbl1 where i1>=10+1 and i1<=(1000*2) and i1 is null;
183select * from tbl1 where i1>=10+1 and i1<=(1000*2) and i1 is not null;
184select * from tbl1 where i1>=10+1 and i1<=(100*2) or i1 = 610;
185select * from tbl1 where i1>=10+1 and i1<=(100*2) or i3 = 'cx23abc12';
186select * from tbl1 where i1>=10+1 and i1<=(100*2) and i5 between 0 and 1000;
187select * from tbl1 where i1>=10+1 and i1<=(100*10) and i5 between -100 and 1000;
188select * from tbl1 where i1>10+1 and i1<1000 and pk<=10;
189select * from tbl1 where i1>-9999999999+1+0 and i1<10000000000-2+1-1+2-2+3-3+4-4+5-5+6-6+7-7+8-8+9-9+0-0+10-10 and pk<=10;
190select * from tbl1 where i1>-9999999999+1+0 and i1<10000000000-2+1-1+2-2+3-3+4-4+5-5+6-6+7-7+8-8+9-9+0-0+10-10 ;
191select * from tbl1 where i1>=10+1 and i1<=(100*10) and i5 between -100 and 1000;
192prepare stmt1 from select * from tbl1 where i1>=?+1 and i1<=(?*10) and i5 between ? and ?;
193set @a=10;
194set @b=100;
195set @c=-100;
196set @d=1000;
197execute stmt1 using @a, @b,@c,@d;
198set @a=10+1-1+10-10+1-1+1-1+1-1+1-1;
199set @b=100-1+1+10-10+10-10+1-1+10-10;
200set @c=-100+1-1+1-1+1-1+1-1+2-2+3-3+4-4+5-5+6-6+7-7+8-8+9-9+10-10;
201set @d=1000+1-1+1-1+1-1+1-1+2-2+3-3+4-4+5-5+6-6+7-7+8-8+9-9+10-10;
202execute stmt1 using @a, @b,@c,@d;
203select * from tbl1 where i1>=length('abc')-10 and i1<length('dagafdgafdgfg')+1000;
204set @a='agafgfdgfdghfdhadfh';
205set @b='adgfdagdfgggfgfdgfgfgfgfdgdfgadfghdfgfdg';
206prepare stmt1 from select * from tbl1 where i1>=length(?)-10 and i1<length(?)+1000;
207execute stmt1 using @a, @b;
208select * from tbl1 where (i1,i5) in ((1,23.23),(42,-99.131),(50,93.131),(610,99.131));
209select * from tbl1 where (i5,i1) in ((23.23,1),(-99.131,42),(93.131,50),(99.131,610));
210select * from tbl1 where (i1,i5,i4) in ((1,23.23,1.25),(610,99.131,-1.85),(42,-99.131,-85.85));
211select * from tbl1 where (i4,i1,i5) in ((1.25,1,23.23),(-1.85,610,99.131),(-85.85,42,-99.131));
212prepare stmt1 from select * from tbl1 where (i4,i1,i5) in ((1.25,?,23.23),(-1.85,?,99.131),(?,42,?));
213set @a=-99.131;
214set @b=610;
215set @c=1;
216set @d=-85.85;
217execute stmt1 using @c,@b,@d,@a;
218prepare stmt1 from select * from tbl1 where i1>=?*?+?+? and i1<=?*?+?-?;
219set @a=-10;
220set @b=2;
221set @c=1;
222set @d=-1;
223set @e=100;
224set @f=10;
225set @g=2;
226set @h=3;
227execute stmt1 using @a,@b,@c,@d,@e,@f,@g,@h;
228#test update
229update tbl1 set i1=i1+1-1 where i1>=EXTRACT(DAY FROM '2014-09-30 12:00:00' )-29 and i1<=EXTRACT(DAY FROM '2014-09-30 12:00:00' )+600;
230update tbl1 set i5=i5+1-1 where i1>=EXTRACT(DAY FROM '2014-09-30 12:00:00' )-29 and i1<=EXTRACT(DAY FROM '2014-09-30 12:00:00' )+600;
231update tbl1 set i5=round(i5) where i1>=EXTRACT(DAY FROM '2014-09-30 12:00:00' )-29 and i1<=EXTRACT(DAY FROM '2014-09-30 12:00:00' )+600;
232update tbl1 set d4=date_add(d4, INTERVAL -6 hour) where i1>=EXTRACT(DAY FROM '2014-09-30 12:00:00' )-29 and i1<=EXTRACT(DAY FROM '2014-09-30 12:00:00' )+600;
233select * from tbl1;
234delete from tbl1 where i1>=EXTRACT(DAY FROM '2014-09-30 12:00:00' )-29 and i1<=EXTRACT(DAY FROM '2014-09-30 12:00:00' )+600;
235select * from tbl1 where i1>=EXTRACT(DAY FROM '2014-09-30 12:00:00' )-29 and i1<=EXTRACT(DAY FROM '2014-09-30 12:00:00' )+600;
236select * from tbl1;
237--enable_parsing
238