mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Merge dl145s.mysql.com:/data/bk/team_tree_merge/MERGE/mysql-4.1-opt
into dl145s.mysql.com:/data/bk/team_tree_merge/MERGE/mysql-5.0-opt mysql-test/r/query_cache.result: Auto merged mysql-test/r/subselect.result: Auto merged mysql-test/r/type_date.result: Auto merged mysql-test/t/func_time.test: Auto merged mysql-test/t/insert_update.test: Auto merged sql/item.h: Auto merged sql/log.cc: Auto merged sql/sql_parse.cc: Auto merged sql/sql_yacc.yy: Auto merged
This commit is contained in:
@ -840,34 +840,34 @@ 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
|
||||
|
@ -63,9 +63,9 @@ Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,values(`test`.`t1`.`a`) AS `VALUES(a)` from `test`.`t1`
|
||||
explain extended select * from t1 where values(a);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1`
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where values(`test`.`t1`.`a`)
|
||||
DROP TABLE t1;
|
||||
create table t1(a int primary key, b int);
|
||||
insert into t1 values(1,1),(2,2),(3,3),(4,4),(5,5);
|
||||
@ -197,3 +197,25 @@ PRIMARY KEY (a)
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t1 ( a ) SELECT 0 ON DUPLICATE KEY UPDATE a = a + VALUES (a) ;
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1
|
||||
(
|
||||
a BIGINT UNSIGNED,
|
||||
b BIGINT UNSIGNED,
|
||||
PRIMARY KEY (a)
|
||||
);
|
||||
INSERT INTO t1 VALUES (45, 1) ON DUPLICATE KEY UPDATE b =
|
||||
IF(VALUES(b) > t1.b, VALUES(b), t1.b);
|
||||
SELECT * FROM t1;
|
||||
a b
|
||||
45 1
|
||||
INSERT INTO t1 VALUES (45, 2) ON DUPLICATE KEY UPDATE b =
|
||||
IF(VALUES(b) > t1.b, VALUES(b), t1.b);
|
||||
SELECT * FROM t1;
|
||||
a b
|
||||
45 2
|
||||
INSERT INTO t1 VALUES (45, 1) ON DUPLICATE KEY UPDATE b =
|
||||
IF(VALUES(b) > t1.b, VALUES(b), t1.b);
|
||||
SELECT * FROM t1;
|
||||
a b
|
||||
45 2
|
||||
DROP TABLE t1;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -115,4 +115,27 @@ INSERT INTO t1 ( a ) SELECT 0 ON DUPLICATE KEY UPDATE a = a + VALUES (a) ;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
#
|
||||
# Bug#21555: incorrect behavior with INSERT ... ON DUPL KEY UPDATE and VALUES
|
||||
#
|
||||
|
||||
|
||||
# End of 4.1 tests
|
||||
CREATE TABLE t1
|
||||
(
|
||||
a BIGINT UNSIGNED,
|
||||
b BIGINT UNSIGNED,
|
||||
PRIMARY KEY (a)
|
||||
);
|
||||
|
||||
INSERT INTO t1 VALUES (45, 1) ON DUPLICATE KEY UPDATE b =
|
||||
IF(VALUES(b) > t1.b, VALUES(b), t1.b);
|
||||
SELECT * FROM t1;
|
||||
INSERT INTO t1 VALUES (45, 2) ON DUPLICATE KEY UPDATE b =
|
||||
IF(VALUES(b) > t1.b, VALUES(b), t1.b);
|
||||
SELECT * FROM t1;
|
||||
INSERT INTO t1 VALUES (45, 1) ON DUPLICATE KEY UPDATE b =
|
||||
IF(VALUES(b) > t1.b, VALUES(b), t1.b);
|
||||
SELECT * FROM t1;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
@ -36,8 +36,8 @@ 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 "2000-1-2" AND datum - INTERVAL 100 DAY;
|
||||
SELECT * FROM t1 WHERE datum BETWEEN cast("2000-1-2" as date) AND cast("2000-1-4" as date);
|
||||
SELECT * FROM t1 WHERE datum BETWEEN cast("2000-1-2" as date) AND datum - INTERVAL 100 DAY;
|
||||
DROP TABLE t1;
|
||||
|
||||
#
|
||||
@ -115,4 +115,11 @@ INSERT INTO t1 VALUES ('abc');
|
||||
SELECT * FROM t1;
|
||||
DROP TABLE t1;
|
||||
|
||||
#
|
||||
# Bug#21677: Wrong result when comparing a DATE and a DATETIME in BETWEEN
|
||||
#
|
||||
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;
|
||||
drop table t1;
|
||||
# End of 4.1 tests
|
||||
|
Reference in New Issue
Block a user