Debian Codegraph @

mysql-test/suite/optimizer_unfixed_bugs/t/bug43618.test

raw
1 # test for BUG#43618 "MyISAM&Maria returns wrong results with
2 # 'between' on timestamp"
3
4 --source include/have_debug.inc
5
6 set @save_time_zone= @@time_zone;
7 set time_zone='+03:00';
8 # bug goes away with
9 #set session debug_dbug="+d,optimizer_no_icp";
10
11 ######## Running INSERT tests for TIMESTAMP ########
12
13 # Create tables
14 CREATE TABLE t1(c1 TIMESTAMP NOT NULL, c2 TIMESTAMP NULL, c3 DATE, c4 DATETIME, PRIMARY KEY(c1), UNIQUE INDEX(c2));
15
16 # Insert some rows with targeted values
17
18 # As a string in either 'YYYY-MM-DD HH:MM:SS', 'YY-MM-DD HH:MM:SS', 'YYYY-MM-DD' or 'YY-MM-DD' format
19 INSERT INTO t1 VALUES('98-12-31 11:30:45','98.12.31 11+30+45','98-12-31 11:30:45','98.12.31 11+30+45'),('98/12/30 11*30*45','98@12@30 11^30^45','98/12/30 11*30*45','98@12@30 11^30^45'),('98-12-29','98.12.29','98-12-29','98.12.29'),('98/12/28','98@12@28','98/12/28','98@12@28');
20
21 # As a string with no delimiters in either 'YYYYMMDDHHMMSS', 'YYMMDDHHMMSS', 'YYYYMMDD' or 'YYMMDD' format
22 INSERT INTO t1 VALUES('20070523091528','070523091528','20070524091528','070524091528'),('20070525','070525','20070526','070526');
23
24 # As a number in either YYYYMMDDHHMMSS, YYMMDDHHMMSS, YYYYMMDD or YYMMDD format
25 INSERT INTO t1 VALUES(19830905132800,830905132800,19830906132800,830906132800),(19830907,830907,19830908,830908);
26
27 # As the result of a function
28 SET TIMESTAMP=1233216687; # 2009-01-29 13:41:27
29 INSERT INTO t1 VALUES(NOW(),CURRENT_DATE,NOW(),CURRENT_DATE);
30
31 # Insert permissible NULLs
32 INSERT INTO t1 VALUES('2008-01-01',NULL,'08-01-02','08/01/03');
33
34 # Insert duplicate NULLs to unique column
35 INSERT INTO t1(c1,c2) VALUES('08/01/17',NULL);
36 DELETE FROM t1 WHERE c1='08/01/17' AND c2 IS NULL;
37
38 # Insert empty string '', would be converted to zero value of the appropriate type
39 INSERT IGNORE INTO t1 VALUES('','','08-01-04','08/01/05') /* Inserts zero dates for '' strings */;
40
41 INSERT INTO t1 VALUES('1971-01-01 00:00:01','1980-01-01 00:00:01','2009-01-01','2009-01-02'),('1990-01-01 00:00:01','2000-01-01 00:00:01','2009-01-03','2009-01-04'),('2038-01-09 03:14:07','2038-01-09 03:14:07','2009-01-05','2009-01-06');
42
43 --sorted_result
44 SELECT * FROM t1;
45 SELECT * FROM t1 WHERE c1 BETWEEN '0000-00-00' AND '2010-00-01 00:00:00' ORDER BY c1 DESC LIMIT 2;
46 SELECT * FROM t1 WHERE c2 BETWEEN '1971-01-01 00:00:01' AND '2010-10-00 00:00:00' ORDER BY c2 DESC LIMIT 2;
47 DROP TABLE t1;
48 set time_zone= @save_time_zone;
49