mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / mysql-test / suite / engines / iuds / t / delete_time.test
blob113502a43ddd6c7c535e5cde7732bea28888a768
1 --disable_warnings
2 DROP TABLE IF EXISTS t1,t2,t3,t4;
3 --enable_warnings
4 # Create tables
5 CREATE TABLE t1(c1 TIME NOT NULL, c2 TIME NULL, PRIMARY KEY(c1));
6 CREATE TABLE t2(c1 TIME NOT NULL, c2 TIME NULL, PRIMARY KEY(c1,c2));
7 CREATE TABLE t3(c1 TIME NOT NULL, c2 TIME NULL, UNIQUE INDEX idx(c1,c2));
8 CREATE TABLE t4(c1 TIME NOT NULL, c2 TIME NULL);
10 # As a string in 'D HH:MM:SS.fraction' format 
12 INSERT INTO t1 VALUES ('00:00:00.00','00:00:00.00'),('01:01:01.01','01:01:01.00'),('838:59:59.00','838:59:59.00'),('00:00:01','00:00:01'),('02:02:02','02:02:02'),('838:59:58','838:59:58'),('-838:59:59','-838:59:59'),('00:03','00:03'),('03:03','03:03'),('838:58','838:58'),('00 00:00:04','00 00:00:04'),('04 04:04:04','04 04:04:04'),('34 22:59:57','34 22:59:57'),('00 00:04','00 00:04'),('05 05:05','05 05:05'),('34 22:56','34 22:56'),('05 05','05 05'),('06 06','06 06'),('34 22','34 22'),('07','07'),('59','59');
13 INSERT INTO t2 VALUES ('00:00:00.00','00:00:00.00'),('01:01:01.01','01:01:01.00'),('838:59:59.00','838:59:59.00'),('00:00:01','00:00:01'),('02:02:02','02:02:02'),('838:59:58','838:59:58'),('-838:59:59','-838:59:59'),('00:03','00:03'),('03:03','03:03'),('838:58','838:58'),('00 00:00:04','00 00:00:04'),('04 04:04:04','04 04:04:04'),('34 22:59:57','34 22:59:57'),('00 00:04','00 00:04'),('05 05:05','05 05:05'),('34 22:56','34 22:56'),('05 05','05 05'),('06 06','06 06'),('34 22','34 22'),('07','07'),('59','59');
14 INSERT INTO t3 VALUES ('00:00:00.00','00:00:00.00'),('01:01:01.01','01:01:01.00'),('838:59:59.00','838:59:59.00'),('00:00:01','00:00:01'),('02:02:02','02:02:02'),('838:59:58','838:59:58'),('-838:59:59','-838:59:59'),('00:03','00:03'),('03:03','03:03'),('838:58','838:58'),('00 00:00:04','00 00:00:04'),('04 04:04:04','04 04:04:04'),('34 22:59:57','34 22:59:57'),('00 00:04','00 00:04'),('05 05:05','05 05:05'),('34 22:56','34 22:56'),('05 05','05 05'),('06 06','06 06'),('34 22','34 22'),('07','07'),('59','59');
15 INSERT INTO t4 VALUES ('00:00:00.00','00:00:00.00'),('01:01:01.01','01:01:01.00'),('838:59:59.00','838:59:59.00'),('00:00:01','00:00:01'),('02:02:02','02:02:02'),('838:59:58','838:59:58'),('-838:59:59','-838:59:59'),('00:03','00:03'),('03:03','03:03'),('838:58','838:58'),('00 00:00:04','00 00:00:04'),('04 04:04:04','04 04:04:04'),('34 22:59:57','34 22:59:57'),('00 00:04','00 00:04'),('05 05:05','05 05:05'),('34 22:56','34 22:56'),('05 05','05 05'),('06 06','06 06'),('34 22','34 22'),('07','07'),('59','59');
17 #As a string with no delimiters in 'HHMMSS' format
19 INSERT INTO t1 VALUES('000008','000008'),('080808','080808'),('8385955','8385955'),('-8385955','-8385955'),('0009','0009'),('0909','0909'),('5454','5454'),('10','10'),('53','53');
20 INSERT INTO t2 VALUES('000008','000008'),('080808','080808'),('8385955','8385955'),('-8385955','-8385955'),('0009','0009'),('0909','0909'),('5454','5454'),('10','10'),('53','53');
21 INSERT INTO t3 VALUES('000008','000008'),('080808','080808'),('8385955','8385955'),('-8385955','-8385955'),('0009','0009'),('0909','0909'),('5454','5454'),('10','10'),('53','53');
22 INSERT INTO t4 VALUES('000008','000008'),('080808','080808'),('8385955','8385955'),('-8385955','-8385955'),('0009','0009'),('0909','0909'),('5454','5454'),('10','10'),('53','53');
24 #As a number in HHMMSS format
26 INSERT INTO t1 VALUES (000011.00,000011.00),(111111.11,111111.11),(8385952.00,8385952.00),(000012,000012),(121212,121212),(8385951,8385951),(1313,1313),(5151,5151),(14,14),(50,50);
27 INSERT INTO t2 VALUES (000011.00,000011.00),(111111.11,111111.11),(8385952.00,8385952.00),(000012,000012),(121212,121212),(8385951,8385951),(1313,1313),(5151,5151),(14,14),(50,50);
28 INSERT INTO t3 VALUES (000011.00,000011.00),(111111.11,111111.11),(8385952.00,8385952.00),(000012,000012),(121212,121212),(8385951,8385951),(1313,1313),(5151,5151),(14,14),(50,50);
29 INSERT INTO t4 VALUES (000011.00,000011.00),(111111.11,111111.11),(8385952.00,8385952.00),(000012,000012),(121212,121212),(8385951,8385951),(1313,1313),(5151,5151),(14,14),(50,50);
31 #As the result of a function that returns a value that is acceptable in a TIME context
32 SET TIMESTAMP=1233216687; # 2009-01-29 13:41:27
33 INSERT INTO t1 VALUES(CURRENT_TIME(),CURRENT_TIME());
34 INSERT INTO t2 VALUES(CURRENT_TIME(),CURRENT_TIME());
35 INSERT INTO t3 VALUES(CURRENT_TIME(),CURRENT_TIME());
36 INSERT INTO t4 VALUES(CURRENT_TIME(),CURRENT_TIME());
37 #Insert permissible NULLs
38 INSERT INTO t1 VALUES('123456',null);
39 #INSERT INTO t2 VALUES('123456',null);
40 INSERT INTO t3 VALUES('123456',null);
41 INSERT INTO t4 VALUES('123456',null);
42 --sorted_result
43 SELECT * FROM t1;
44 --sorted_result
45 SELECT * FROM t2;
46 --sorted_result
47 SELECT * FROM t3;
48 --sorted_result
49 SELECT * FROM t4;
50 #Deleting the table rows
51 --sorted_result
52 SELECT c1 FROM t1 WHERE c1='00:00:07';
53 DELETE FROM t1 WHERE c1='00:00:07';
54 --sorted_result
55 SELECT c1 FROM t1;
56 --sorted_result
57 SELECT c1 FROM t2 WHERE c1='-838:59:59' AND c2='-838:59:59';
58 DELETE FROM t2 WHERE c1='-838:59:59' AND c2='-838:59:59';
59 --sorted_result
60 SELECT c1 FROM t2;
62 #Deleting rowa with NULL attributes 
63 --sorted_result
64 SELECT c2 FROM t3 WHERE c2=null;
65 DELETE FROM t3 WHERE c2=null;
66 --sorted_result
67 SELECT c2 FROM t3;
69 #Delete by order by limit
70 --sorted_result
71 SELECT c1 FROM t4 WHERE c1 < '000009';
72 DELETE FROM t4 WHERE c1 < '000009' ORDER BY c1 LIMIT 3;
73 --sorted_result
74 SELECT c1 FROM t4;
76 #Delete by range values
77 DELETE FROM t1 WHERE c1='00:00:09' AND c1='01:01:01';
78 --sorted_result
79 SELECT c2 FROM t1;
80 DELETE FROM t2 WHERE c2=000400 OR c2= 000900;
81 --sorted_result
82 SELECT c1 FROM t2;
83 DELETE FROM t2 WHERE c1 IN ('100:04:04',005454,'2:2:2',111111) ORDER BY c1 LIMIT 2;
84 --sorted_result
85 SELECT c2 FROM t2;
87 #Multi table delete
88 DELETE t1,t2,t3,t4 FROM t1,t2,t3,t4 WHERE t1.c1='00:13:13' AND t2.c1=080808 AND t4.c1='00:04:00' AND t3.c2=020202;
90 #Delete using various access methods
92 # Delete using Const
93 # EXPLAIN SELECT * FROM t1 WHERE c1='00:09:09' AND c2='00:09:09';
94 DELETE FROM t1 WHERE c1='00:09:09' AND c2='00:09:09';
95 --sorted_result
96 SELECT * FROM t1;
98 # Delete using range
99 # EXPLAIN SELECT * FROM t1 WHERE c1 BETWEEN 080000 AND 100000;
100 DELETE FROM t1 WHERE c1 BETWEEN 080000 AND 100000;
101 --sorted_result
102 SELECT * FROM t1;
103 # EXPLAIN SELECT * FROM t1 WHERE c1 IN (222222,8385959,1500000);
104 DELETE FROM t1 WHERE c1 IN (222222,8385959,1500000);
105 --sorted_result
106 SELECT * FROM t1;
108 # Delete using eq_ref
109 # EXPLAIN SELECT * FROM t2,t3 WHERE t2.c1=t3.c1 AND t2.c3=t3.c3;
110 DELETE t1,t2 FROM t1,t2 WHERE t1.c1=t2.c1 AND t1.c2=t2.c2;
112 --sorted_result
113 SELECT * FROM t1;
114 --sorted_result
115 SELECT * FROM t2;
116 --sorted_result
117 SELECT * FROM t3;
118 --sorted_result
119 SELECT * FROM t4;
120 #Drop tables;
121 DROP TABLE IF EXISTS t1,t2,t3,t4;