Commit 0847bd9c authored by unknown's avatar unknown
Browse files

type_date.result:

  Added the test case for bug#21677: Wrong result when comparing a DATE and a DATETIME in BETWEEN
  Corrected a test case after removal of fix for bug#16377
query_cache.result, func_time.test, view.result, view.test, func_time.result:
  Corrected a test case after removal of fix for bug#16377
type_date.test:
  Added the test case for bug#21677: Wrong result when comparing a DATE and a DATETIME in BETWEEN
   Corrected a test case after removal of fix for bug#16377
item_cmpfunc.cc:
  Removed changes to the Item_func_between::fix_length_and_dec() made in the fix for bug#16377


mysql-test/t/view.test:
  Corrected a test case after removal of fix for bug#16377
mysql-test/t/type_date.test:
  Added the test case for bug#21677: Wrong result when comparing a DATE and a DATETIME in BETWEEN
   Corrected a test case after removal of fix for bug#16377
mysql-test/t/func_time.test:
  Corrected a test case after removal of fix for bug#16377
mysql-test/r/view.result:
  Corrected a test case after removal of fix for bug#16377
mysql-test/r/type_date.result:
  Added the test case for bug#21677: Wrong result when comparing a DATE and a DATETIME in BETWEEN
  Corrected a test case after removal of fix for bug#16377
mysql-test/r/query_cache.result:
  Corrected a test case after removal of fix for bug#16377
mysql-test/r/func_time.result:
  Corrected a test case after removal of fix for bug#16377
sql/item_cmpfunc.cc:
  Removed changes to the Item_func_between::fix_length_and_dec() made in the fix for bug#16377
parent dbe0b91e
Loading
Loading
Loading
Loading
+11 −14
Original line number Diff line number Diff line
@@ -840,39 +840,36 @@ drop table t1;
create table t1(f1 date, f2 time, f3 datetime);
insert into t1 values ("2006-01-01", "12:01:01", "2006-01-01 12:01:01");
insert into t1 values ("2006-01-02", "12:01:02", "2006-01-02 12:01:02");
select f1 from t1 where f1 between "2006-1-1" and 20060101;
select f1 from t1 where f1 between CAST("2006-1-1" as date) and CAST(20060101 as date);
f1
2006-01-01
select f1 from t1 where f1 between "2006-1-1" and "2006.1.1";
select f1 from t1 where f1 between cast("2006-1-1" as date) and cast("2006.1.1" as date);
f1
2006-01-01
select f1 from t1 where date(f1) between "2006-1-1" and "2006.1.1";
select f1 from t1 where date(f1) between cast("2006-1-1" as date) and cast("2006.1.1" as date);
f1
2006-01-01
select f2 from t1 where f2 between "12:1:2" and "12:2:2";
select f2 from t1 where f2 between cast("12:1:2" as time) and cast("12:2:2" as time);
f2
12:01:02
select f2 from t1 where time(f2) between "12:1:2" and "12:2:2";
select f2 from t1 where time(f2) between cast("12:1:2" as time) and cast("12:2:2" as time);
f2
12:01:02
select f3 from t1 where f3 between "2006-1-1 12:1:1" and "2006-1-1 12:1:2";
select f3 from t1 where f3 between cast("2006-1-1 12:1:1" as datetime) and cast("2006-1-1 12:1:2" as datetime);
f3
2006-01-01 12:01:01
select f3 from t1 where timestamp(f3) between "2006-1-1 12:1:1" and "2006-1-1 12:1:2";
select f3 from t1 where timestamp(f3) between cast("2006-1-1 12:1:1" as datetime) and cast("2006-1-1 12:1:2" as datetime);
f3
2006-01-01 12:01:01
select f1 from t1 where "2006-1-1" between f1 and f3;
select f1 from t1 where cast("2006-1-1" as date) between f1 and f3;
f1
2006-01-01
select f1 from t1 where "2006-1-1" between date(f1) and date(f3);
select f1 from t1 where cast("2006-1-1" as date) between date(f1) and date(f3);
f1
2006-01-01
select f1 from t1 where "2006-1-1" between f1 and 'zzz';
select f1 from t1 where cast("2006-1-1" as date) between f1 and 'zzz';
f1
Warnings:
Warning	1292	Incorrect date value: 'zzz' for column 'f1' at row 1
Warning	1292	Truncated incorrect DOUBLE value: 'zzz'
Warning	1292	Truncated incorrect DOUBLE value: 'zzz'
2006-01-01
select f1 from t1 where makedate(2006,1) between date(f1) and date(f3);
f1
2006-01-01
+6 −6
Original line number Diff line number Diff line
@@ -947,24 +947,24 @@ COUNT(*)
Warnings:
Warning	1292	Incorrect datetime value: '20050327 invalid' for column 'date' at row 1
Warning	1292	Incorrect datetime value: '20050327 invalid' for column 'date' at row 1
Warning	1292	Truncated incorrect DOUBLE value: '20050327 invalid'
Warning	1292	Truncated incorrect DOUBLE value: '20050327 invalid'
Warning	1292	Truncated incorrect INTEGER value: '20050327 invalid'
Warning	1292	Truncated incorrect INTEGER value: '20050327 invalid'
SELECT COUNT(*) FROM t1 WHERE date BETWEEN '20050326' AND '20050328 invalid';
COUNT(*)
0
Warnings:
Warning	1292	Incorrect datetime value: '20050328 invalid' for column 'date' at row 1
Warning	1292	Incorrect datetime value: '20050328 invalid' for column 'date' at row 1
Warning	1292	Truncated incorrect DOUBLE value: '20050328 invalid'
Warning	1292	Truncated incorrect DOUBLE value: '20050328 invalid'
Warning	1292	Truncated incorrect INTEGER value: '20050328 invalid'
Warning	1292	Truncated incorrect INTEGER value: '20050328 invalid'
SELECT COUNT(*) FROM t1 WHERE date BETWEEN '20050326' AND '20050327 invalid';
COUNT(*)
0
Warnings:
Warning	1292	Incorrect datetime value: '20050327 invalid' for column 'date' at row 1
Warning	1292	Incorrect datetime value: '20050327 invalid' for column 'date' at row 1
Warning	1292	Truncated incorrect DOUBLE value: '20050327 invalid'
Warning	1292	Truncated incorrect DOUBLE value: '20050327 invalid'
Warning	1292	Truncated incorrect INTEGER value: '20050327 invalid'
Warning	1292	Truncated incorrect INTEGER value: '20050327 invalid'
show status like "Qcache_queries_in_cache";
Variable_name	Value
Qcache_queries_in_cache	0
+8 −2
Original line number Diff line number Diff line
@@ -27,12 +27,12 @@ INSERT INTO t1 VALUES ( "2000-1-2" );
INSERT INTO t1 VALUES ( "2000-1-3" );
INSERT INTO t1 VALUES ( "2000-1-4" );
INSERT INTO t1 VALUES ( "2000-1-5" );
SELECT * FROM t1 WHERE datum BETWEEN "2000-1-2" AND "2000-1-4";
SELECT * FROM t1 WHERE datum BETWEEN cast("2000-1-2" as date) AND cast("2000-1-4" as date);
datum
2000-01-02
2000-01-03
2000-01-04
SELECT * FROM t1 WHERE datum BETWEEN "2000-1-2" AND datum - INTERVAL 100 DAY;
SELECT * FROM t1 WHERE datum BETWEEN cast("2000-1-2" as date) AND datum - INTERVAL 100 DAY;
datum
DROP TABLE t1;
CREATE TABLE t1 (
@@ -104,3 +104,9 @@ SELECT * FROM t1;
y
0000
DROP TABLE t1;
create table t1(start_date date, end_date date);
insert into t1 values ('2000-01-01','2000-01-02');
select 1 from t1 where cast('2000-01-01 12:01:01' as datetime) between start_date and end_date;
1
1
drop table t1;
+2 −2
Original line number Diff line number Diff line
@@ -2586,13 +2586,13 @@ INSERT INTO t1 VALUES
(4, '2005-01-03'), (5, '2005-01-04'), (6, '2005-01-05'),
(7, '2005-01-05'), (8, '2005-01-05'), (9, '2005-01-06');
CREATE VIEW v1 AS SELECT * FROM t1;
SELECT * FROM t1 WHERE td BETWEEN '2005.01.02' AND '2005.01.04';
SELECT * FROM t1 WHERE td BETWEEN CAST('2005.01.02' AS DATE) AND CAST('2005.01.04' AS DATE);
id	td
2	2005-01-02
3	2005-01-02
4	2005-01-03
5	2005-01-04
SELECT * FROM v1 WHERE td BETWEEN '2005.01.02' AND '2005.01.04';
SELECT * FROM v1 WHERE td BETWEEN CAST('2005.01.02' AS DATE) AND CAST('2005.01.04' AS DATE);
id	td
2	2005-01-02
3	2005-01-02
+11 −11
Original line number Diff line number Diff line
@@ -419,20 +419,20 @@ drop table t1;
#
# Bug#16377 result of DATE/TIME functions were compared as strings which
#           can lead to a wrong result.
#
# Now wrong dates should be compared only with CAST()
create table t1(f1 date, f2 time, f3 datetime);
insert into t1 values ("2006-01-01", "12:01:01", "2006-01-01 12:01:01");
insert into t1 values ("2006-01-02", "12:01:02", "2006-01-02 12:01:02");
select f1 from t1 where f1 between "2006-1-1" and 20060101;
select f1 from t1 where f1 between "2006-1-1" and "2006.1.1";
select f1 from t1 where date(f1) between "2006-1-1" and "2006.1.1";
select f2 from t1 where f2 between "12:1:2" and "12:2:2";
select f2 from t1 where time(f2) between "12:1:2" and "12:2:2";
select f3 from t1 where f3 between "2006-1-1 12:1:1" and "2006-1-1 12:1:2";
select f3 from t1 where timestamp(f3) between "2006-1-1 12:1:1" and "2006-1-1 12:1:2";
select f1 from t1 where "2006-1-1" between f1 and f3;
select f1 from t1 where "2006-1-1" between date(f1) and date(f3);
select f1 from t1 where "2006-1-1" between f1 and 'zzz';
select f1 from t1 where f1 between CAST("2006-1-1" as date) and CAST(20060101 as date);
select f1 from t1 where f1 between cast("2006-1-1" as date) and cast("2006.1.1" as date);
select f1 from t1 where date(f1) between cast("2006-1-1" as date) and cast("2006.1.1" as date);
select f2 from t1 where f2 between cast("12:1:2" as time) and cast("12:2:2" as time);
select f2 from t1 where time(f2) between cast("12:1:2" as time) and cast("12:2:2" as time);
select f3 from t1 where f3 between cast("2006-1-1 12:1:1" as datetime) and cast("2006-1-1 12:1:2" as datetime);
select f3 from t1 where timestamp(f3) between cast("2006-1-1 12:1:1" as datetime) and cast("2006-1-1 12:1:2" as datetime);
select f1 from t1 where cast("2006-1-1" as date) between f1 and f3;
select f1 from t1 where cast("2006-1-1" as date) between date(f1) and date(f3);
select f1 from t1 where cast("2006-1-1" as date) between f1 and 'zzz';
select f1 from t1 where makedate(2006,1) between date(f1) and date(f3);
select f1 from t1 where makedate(2006,2) between date(f1) and date(f3);
drop table t1;
Loading