mirror of
https://github.com/MariaDB/server.git
synced 2025-11-02 02:53:04 +03:00
Merge bk-internal.mysql.com:/data0/bk/mysql-5.1
into bk-internal.mysql.com:/data0/bk/mysql-5.1-opt
This commit is contained in:
@@ -474,6 +474,7 @@ CREATE TABLE t4 (a DATE);
|
||||
INSERT INTO t4 VALUES ('1972-02-06'), ('1972-07-29');
|
||||
SELECT * FROM t4 WHERE a IN ('1972-02-06','19772-07-29');
|
||||
a
|
||||
1972-02-06
|
||||
Warnings:
|
||||
Warning 1292 Incorrect date value: '19772-07-29' for column 'a' at row 1
|
||||
DROP TABLE t1,t2,t3,t4;
|
||||
|
||||
@@ -336,3 +336,25 @@ id f1
|
||||
0 test1
|
||||
DROP TABLE t1;
|
||||
SET SQL_MODE='';
|
||||
CREATE TABLE t1 (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
c1 CHAR(1) UNIQUE KEY,
|
||||
cnt INT DEFAULT 1
|
||||
);
|
||||
INSERT INTO t1 (c1) VALUES ('A'), ('B'), ('C');
|
||||
SELECT * FROM t1;
|
||||
id c1 cnt
|
||||
1 A 1
|
||||
2 B 1
|
||||
3 C 1
|
||||
INSERT INTO t1 (c1) VALUES ('A'), ('X'), ('Y'), ('Z')
|
||||
ON DUPLICATE KEY UPDATE cnt=cnt+1;
|
||||
SELECT * FROM t1;
|
||||
id c1 cnt
|
||||
1 A 2
|
||||
2 B 1
|
||||
3 C 1
|
||||
4 X 1
|
||||
5 Y 1
|
||||
6 Z 1
|
||||
DROP TABLE t1;
|
||||
|
||||
@@ -174,6 +174,25 @@ f2
|
||||
2
|
||||
SET @@SQL_MODE=@OLD_SQL_MODE;
|
||||
drop table t1,t2;
|
||||
create table t1(f1 int, f2 timestamp not null default current_timestamp);
|
||||
create table t2(f1 int);
|
||||
insert into t2 values(1),(2);
|
||||
Warnings:
|
||||
Warning 1261 Row 1 doesn't contain data for all columns
|
||||
Warning 1261 Row 2 doesn't contain data for all columns
|
||||
select f1 from t1 where f2 <> '0000-00-00 00:00:00' order by f1;
|
||||
f1
|
||||
1
|
||||
2
|
||||
delete from t1;
|
||||
Warnings:
|
||||
Warning 1261 Row 1 doesn't contain data for all columns
|
||||
Warning 1261 Row 2 doesn't contain data for all columns
|
||||
select f1 from t1 where f2 <> '0000-00-00 00:00:00' order by f1;
|
||||
f1
|
||||
1
|
||||
2
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1 (a int);
|
||||
INSERT INTO t1 VALUES (1);
|
||||
SET NAMES latin1;
|
||||
|
||||
@@ -264,6 +264,52 @@ f2
|
||||
SELECT 1 from dual where NOW() BETWEEN CURRENT_DATE() - INTERVAL 1 DAY AND CURRENT_DATE();
|
||||
1
|
||||
drop table t1;
|
||||
create table t1 (f1 date);
|
||||
insert into t1 values('01-01-01'),('01-01-02'),('01-01-03');
|
||||
select * from t1 where f1 in ('01-01-01','2001-01-02','2001-01-03 00:00:00');
|
||||
f1
|
||||
2001-01-01
|
||||
2001-01-02
|
||||
2001-01-03
|
||||
create table t2(f2 datetime);
|
||||
insert into t2 values('01-01-01 00:00:00'),('01-02-03 12:34:56'),('02-04-06 11:22:33');
|
||||
select * from t2 where f2 in ('01-01-01','01-02-03 12:34:56','01-02-03');
|
||||
f2
|
||||
2001-01-01 00:00:00
|
||||
2001-02-03 12:34:56
|
||||
select * from t1,t2 where '01-01-02' in (f1, cast(f2 as date));
|
||||
f1 f2
|
||||
2001-01-02 2001-01-01 00:00:00
|
||||
2001-01-02 2001-02-03 12:34:56
|
||||
2001-01-02 2002-04-06 11:22:33
|
||||
select * from t1,t2 where '01-01-01' in (f1, '01-02-03');
|
||||
f1 f2
|
||||
2001-01-01 2001-01-01 00:00:00
|
||||
2001-01-01 2001-02-03 12:34:56
|
||||
2001-01-01 2002-04-06 11:22:33
|
||||
select * from t1,t2 where if(1,'01-02-03 12:34:56','') in (f1, f2);
|
||||
f1 f2
|
||||
2001-01-01 2001-02-03 12:34:56
|
||||
2001-01-02 2001-02-03 12:34:56
|
||||
2001-01-03 2001-02-03 12:34:56
|
||||
create table t3(f3 varchar(20));
|
||||
insert into t3 select * from t2;
|
||||
select * from t2,t3 where f2 in (f3,'03-04-05');
|
||||
f2 f3
|
||||
2001-01-01 00:00:00 2001-01-01 00:00:00
|
||||
2001-02-03 12:34:56 2001-02-03 12:34:56
|
||||
2002-04-06 11:22:33 2002-04-06 11:22:33
|
||||
select f1,f2,f3 from t1,t2,t3 where (f1,'1') in ((f2,'1'),(f3,'1'));
|
||||
f1 f2 f3
|
||||
2001-01-01 2001-01-01 00:00:00 2001-01-01 00:00:00
|
||||
2001-01-01 2001-02-03 12:34:56 2001-01-01 00:00:00
|
||||
2001-01-01 2002-04-06 11:22:33 2001-01-01 00:00:00
|
||||
2001-01-01 2001-01-01 00:00:00 2001-02-03 12:34:56
|
||||
2001-01-01 2001-01-01 00:00:00 2002-04-06 11:22:33
|
||||
select f1 from t1 where ('1',f1) in (('1','01-01-01'),('1','2001-1-1 0:0:0'),('1','02-02-02'));
|
||||
f1
|
||||
2001-01-01
|
||||
drop table t1,t2,t3;
|
||||
select least(cast('01-01-01' as date), '01-01-02');
|
||||
least(cast('01-01-01' as date), '01-01-02')
|
||||
2001-01-01
|
||||
@@ -279,6 +325,12 @@ greatest(cast('01-01-01' as date), '01-01-02') + 0
|
||||
select least(cast('01-01-01' as datetime), '01-01-02') + 0;
|
||||
least(cast('01-01-01' as datetime), '01-01-02') + 0
|
||||
20010101000000
|
||||
select cast(least(cast('01-01-01' as datetime), '01-01-02') as signed);
|
||||
cast(least(cast('01-01-01' as datetime), '01-01-02') as signed)
|
||||
20010101000000
|
||||
select cast(least(cast('01-01-01' as datetime), '01-01-02') as decimal(16,2));
|
||||
cast(least(cast('01-01-01' as datetime), '01-01-02') as decimal(16,2))
|
||||
20010101000000.00
|
||||
DROP PROCEDURE IF EXISTS test27759 ;
|
||||
CREATE PROCEDURE test27759()
|
||||
BEGIN
|
||||
|
||||
@@ -247,3 +247,20 @@ REPLACE INTO t1 VALUES (0,"test1",null);
|
||||
SELECT id, f1 FROM t1;
|
||||
DROP TABLE t1;
|
||||
SET SQL_MODE='';
|
||||
|
||||
#
|
||||
# Bug#27954: multi-row INSERT ... ON DUPLICATE with duplicated
|
||||
# row at the first place into table with AUTO_INCREMENT and
|
||||
# additional UNIQUE key.
|
||||
#
|
||||
CREATE TABLE t1 (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
c1 CHAR(1) UNIQUE KEY,
|
||||
cnt INT DEFAULT 1
|
||||
);
|
||||
INSERT INTO t1 (c1) VALUES ('A'), ('B'), ('C');
|
||||
SELECT * FROM t1;
|
||||
INSERT INTO t1 (c1) VALUES ('A'), ('X'), ('Y'), ('Z')
|
||||
ON DUPLICATE KEY UPDATE cnt=cnt+1;
|
||||
SELECT * FROM t1;
|
||||
DROP TABLE t1;
|
||||
|
||||
@@ -156,6 +156,32 @@ select * from t2;
|
||||
--exec rm $MYSQLTEST_VARDIR/tmp/t1
|
||||
SET @@SQL_MODE=@OLD_SQL_MODE;
|
||||
drop table t1,t2;
|
||||
|
||||
#
|
||||
# Bug#27670: LOAD DATA does not set CURRENT_TIMESTAMP default value for a
|
||||
# TIMESTAMP field when no value has been provided.
|
||||
#
|
||||
create table t1(f1 int, f2 timestamp not null default current_timestamp);
|
||||
create table t2(f1 int);
|
||||
insert into t2 values(1),(2);
|
||||
disable_query_log;
|
||||
eval select * into outfile '$MYSQLTEST_VARDIR/tmp/t2' from t2;
|
||||
eval load data infile '$MYSQLTEST_VARDIR/tmp/t2' into table t1;
|
||||
enable_query_log;
|
||||
select f1 from t1 where f2 <> '0000-00-00 00:00:00' order by f1;
|
||||
--exec rm $MYSQLTEST_VARDIR/tmp/t2
|
||||
delete from t1;
|
||||
disable_query_log;
|
||||
eval SELECT * INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/t2'
|
||||
FIELDS TERMINATED BY '' OPTIONALLY ENCLOSED BY '' LINES TERMINATED BY '\r\n'
|
||||
FROM t2;
|
||||
eval load data infile '$MYSQLTEST_VARDIR/tmp/t2' into table t1
|
||||
FIELDS TERMINATED BY '' OPTIONALLY ENCLOSED BY '' LINES TERMINATED BY '\r\n';
|
||||
enable_query_log;
|
||||
select f1 from t1 where f2 <> '0000-00-00 00:00:00' order by f1;
|
||||
--exec rm $MYSQLTEST_VARDIR/tmp/t2
|
||||
drop table t1,t2;
|
||||
|
||||
# End of 5.0 tests
|
||||
|
||||
|
||||
|
||||
@@ -179,6 +179,25 @@ select f2 from t1 where DATE(f2) between "2001-4-15" AND "01-4-15";
|
||||
SELECT 1 from dual where NOW() BETWEEN CURRENT_DATE() - INTERVAL 1 DAY AND CURRENT_DATE();
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# Bug#28133: Wrong DATE/DATETIME comparison in IN() function.
|
||||
#
|
||||
create table t1 (f1 date);
|
||||
insert into t1 values('01-01-01'),('01-01-02'),('01-01-03');
|
||||
select * from t1 where f1 in ('01-01-01','2001-01-02','2001-01-03 00:00:00');
|
||||
create table t2(f2 datetime);
|
||||
insert into t2 values('01-01-01 00:00:00'),('01-02-03 12:34:56'),('02-04-06 11:22:33');
|
||||
select * from t2 where f2 in ('01-01-01','01-02-03 12:34:56','01-02-03');
|
||||
select * from t1,t2 where '01-01-02' in (f1, cast(f2 as date));
|
||||
select * from t1,t2 where '01-01-01' in (f1, '01-02-03');
|
||||
select * from t1,t2 where if(1,'01-02-03 12:34:56','') in (f1, f2);
|
||||
create table t3(f3 varchar(20));
|
||||
insert into t3 select * from t2;
|
||||
select * from t2,t3 where f2 in (f3,'03-04-05');
|
||||
select f1,f2,f3 from t1,t2,t3 where (f1,'1') in ((f2,'1'),(f3,'1'));
|
||||
select f1 from t1 where ('1',f1) in (('1','01-01-01'),('1','2001-1-1 0:0:0'),('1','02-02-02'));
|
||||
drop table t1,t2,t3;
|
||||
|
||||
#
|
||||
# Bug#27759: Wrong DATE/DATETIME comparison in LEAST()/GREATEST() functions.
|
||||
#
|
||||
@@ -187,6 +206,8 @@ select greatest(cast('01-01-01' as date), '01-01-02');
|
||||
select least(cast('01-01-01' as date), '01-01-02') + 0;
|
||||
select greatest(cast('01-01-01' as date), '01-01-02') + 0;
|
||||
select least(cast('01-01-01' as datetime), '01-01-02') + 0;
|
||||
select cast(least(cast('01-01-01' as datetime), '01-01-02') as signed);
|
||||
select cast(least(cast('01-01-01' as datetime), '01-01-02') as decimal(16,2));
|
||||
--disable_warnings
|
||||
DROP PROCEDURE IF EXISTS test27759 ;
|
||||
--enable_warnings
|
||||
|
||||
Reference in New Issue
Block a user