mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Merge tnurnberg@bk-internal.mysql.com:/home/bk/mysql-5.1-opt
into sin.intern.azundris.com:/misc/mysql/31588/51-31588
This commit is contained in:
@ -326,7 +326,8 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||||||
2 DERIVED t2 index PRIMARY PRIMARY 4 NULL 2 Using where; Using index
|
2 DERIVED t2 index PRIMARY PRIMARY 4 NULL 2 Using where; Using index
|
||||||
drop table t2;
|
drop table t2;
|
||||||
CREATE TABLE `t1` ( `itemid` int(11) NOT NULL default '0', `grpid` varchar(15) NOT NULL default '', `vendor` int(11) NOT NULL default '0', `date_` date NOT NULL default '0000-00-00', `price` decimal(12,2) NOT NULL default '0.00', PRIMARY KEY (`itemid`,`grpid`,`vendor`,`date_`), KEY `itemid` (`itemid`,`vendor`), KEY `itemid_2` (`itemid`,`date_`));
|
CREATE TABLE `t1` ( `itemid` int(11) NOT NULL default '0', `grpid` varchar(15) NOT NULL default '', `vendor` int(11) NOT NULL default '0', `date_` date NOT NULL default '0000-00-00', `price` decimal(12,2) NOT NULL default '0.00', PRIMARY KEY (`itemid`,`grpid`,`vendor`,`date_`), KEY `itemid` (`itemid`,`vendor`), KEY `itemid_2` (`itemid`,`date_`));
|
||||||
insert into t1 values (128, 'rozn', 2, now(), 10),(128, 'rozn', 1, now(), 10);
|
insert into t1 values (128, 'rozn', 2, curdate(), 10),
|
||||||
|
(128, 'rozn', 1, curdate(), 10);
|
||||||
SELECT MIN(price) min, MAX(price) max, AVG(price) avg FROM (SELECT SUBSTRING( MAX(concat(date_,";",price)), 12) price FROM t1 WHERE itemid=128 AND grpid='rozn' GROUP BY itemid, grpid, vendor) lastprices;
|
SELECT MIN(price) min, MAX(price) max, AVG(price) avg FROM (SELECT SUBSTRING( MAX(concat(date_,";",price)), 12) price FROM t1 WHERE itemid=128 AND grpid='rozn' GROUP BY itemid, grpid, vendor) lastprices;
|
||||||
min max avg
|
min max avg
|
||||||
10.00 10.00 10
|
10.00 10.00 10
|
||||||
|
@ -2973,11 +2973,13 @@ Warnings:
|
|||||||
Note 1265 Data truncated for column 'c13' at row 1
|
Note 1265 Data truncated for column 'c13' at row 1
|
||||||
Warning 1265 Data truncated for column 'c17' at row 1
|
Warning 1265 Data truncated for column 'c17' at row 1
|
||||||
Warnings:
|
Warnings:
|
||||||
|
Note 1265 Data truncated for column 'c13' at row 1
|
||||||
Warning 1265 Data truncated for column 'c17' at row 1
|
Warning 1265 Data truncated for column 'c17' at row 1
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1265 Data truncated for column 'c13' at row 1
|
Note 1265 Data truncated for column 'c13' at row 1
|
||||||
Warning 1265 Data truncated for column 'c17' at row 1
|
Warning 1265 Data truncated for column 'c17' at row 1
|
||||||
Warnings:
|
Warnings:
|
||||||
|
Note 1265 Data truncated for column 'c13' at row 1
|
||||||
Warning 1265 Data truncated for column 'c17' at row 1
|
Warning 1265 Data truncated for column 'c17' at row 1
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1265 Data truncated for column 'c13' at row 1
|
Note 1265 Data truncated for column 'c13' at row 1
|
||||||
@ -3011,7 +3013,6 @@ Warning 1265 Data truncated for column 'c15' at row 1
|
|||||||
Warning 1264 Out of range value for column 'c16' at row 1
|
Warning 1264 Out of range value for column 'c16' at row 1
|
||||||
Warning 1264 Out of range value for column 'c17' at row 1
|
Warning 1264 Out of range value for column 'c17' at row 1
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1265 Data truncated for column 'c13' at row 1
|
|
||||||
Warning 1265 Data truncated for column 'c15' at row 1
|
Warning 1265 Data truncated for column 'c15' at row 1
|
||||||
Warning 1264 Out of range value for column 'c16' at row 1
|
Warning 1264 Out of range value for column 'c16' at row 1
|
||||||
Warning 1264 Out of range value for column 'c17' at row 1
|
Warning 1264 Out of range value for column 'c17' at row 1
|
||||||
|
@ -2956,11 +2956,13 @@ Warnings:
|
|||||||
Note 1265 Data truncated for column 'c13' at row 1
|
Note 1265 Data truncated for column 'c13' at row 1
|
||||||
Warning 1265 Data truncated for column 'c17' at row 1
|
Warning 1265 Data truncated for column 'c17' at row 1
|
||||||
Warnings:
|
Warnings:
|
||||||
|
Note 1265 Data truncated for column 'c13' at row 1
|
||||||
Warning 1265 Data truncated for column 'c17' at row 1
|
Warning 1265 Data truncated for column 'c17' at row 1
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1265 Data truncated for column 'c13' at row 1
|
Note 1265 Data truncated for column 'c13' at row 1
|
||||||
Warning 1265 Data truncated for column 'c17' at row 1
|
Warning 1265 Data truncated for column 'c17' at row 1
|
||||||
Warnings:
|
Warnings:
|
||||||
|
Note 1265 Data truncated for column 'c13' at row 1
|
||||||
Warning 1265 Data truncated for column 'c17' at row 1
|
Warning 1265 Data truncated for column 'c17' at row 1
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1265 Data truncated for column 'c13' at row 1
|
Note 1265 Data truncated for column 'c13' at row 1
|
||||||
@ -2994,7 +2996,6 @@ Warning 1265 Data truncated for column 'c15' at row 1
|
|||||||
Warning 1264 Out of range value for column 'c16' at row 1
|
Warning 1264 Out of range value for column 'c16' at row 1
|
||||||
Warning 1264 Out of range value for column 'c17' at row 1
|
Warning 1264 Out of range value for column 'c17' at row 1
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1265 Data truncated for column 'c13' at row 1
|
|
||||||
Warning 1265 Data truncated for column 'c15' at row 1
|
Warning 1265 Data truncated for column 'c15' at row 1
|
||||||
Warning 1264 Out of range value for column 'c16' at row 1
|
Warning 1264 Out of range value for column 'c16' at row 1
|
||||||
Warning 1264 Out of range value for column 'c17' at row 1
|
Warning 1264 Out of range value for column 'c17' at row 1
|
||||||
|
@ -2957,11 +2957,13 @@ Warnings:
|
|||||||
Note 1265 Data truncated for column 'c13' at row 1
|
Note 1265 Data truncated for column 'c13' at row 1
|
||||||
Warning 1265 Data truncated for column 'c17' at row 1
|
Warning 1265 Data truncated for column 'c17' at row 1
|
||||||
Warnings:
|
Warnings:
|
||||||
|
Note 1265 Data truncated for column 'c13' at row 1
|
||||||
Warning 1265 Data truncated for column 'c17' at row 1
|
Warning 1265 Data truncated for column 'c17' at row 1
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1265 Data truncated for column 'c13' at row 1
|
Note 1265 Data truncated for column 'c13' at row 1
|
||||||
Warning 1265 Data truncated for column 'c17' at row 1
|
Warning 1265 Data truncated for column 'c17' at row 1
|
||||||
Warnings:
|
Warnings:
|
||||||
|
Note 1265 Data truncated for column 'c13' at row 1
|
||||||
Warning 1265 Data truncated for column 'c17' at row 1
|
Warning 1265 Data truncated for column 'c17' at row 1
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1265 Data truncated for column 'c13' at row 1
|
Note 1265 Data truncated for column 'c13' at row 1
|
||||||
@ -2995,7 +2997,6 @@ Warning 1265 Data truncated for column 'c15' at row 1
|
|||||||
Warning 1264 Out of range value for column 'c16' at row 1
|
Warning 1264 Out of range value for column 'c16' at row 1
|
||||||
Warning 1264 Out of range value for column 'c17' at row 1
|
Warning 1264 Out of range value for column 'c17' at row 1
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1265 Data truncated for column 'c13' at row 1
|
|
||||||
Warning 1265 Data truncated for column 'c15' at row 1
|
Warning 1265 Data truncated for column 'c15' at row 1
|
||||||
Warning 1264 Out of range value for column 'c16' at row 1
|
Warning 1264 Out of range value for column 'c16' at row 1
|
||||||
Warning 1264 Out of range value for column 'c17' at row 1
|
Warning 1264 Out of range value for column 'c17' at row 1
|
||||||
|
@ -2893,11 +2893,13 @@ Warnings:
|
|||||||
Note 1265 Data truncated for column 'c13' at row 1
|
Note 1265 Data truncated for column 'c13' at row 1
|
||||||
Warning 1265 Data truncated for column 'c17' at row 1
|
Warning 1265 Data truncated for column 'c17' at row 1
|
||||||
Warnings:
|
Warnings:
|
||||||
|
Note 1265 Data truncated for column 'c13' at row 1
|
||||||
Warning 1265 Data truncated for column 'c17' at row 1
|
Warning 1265 Data truncated for column 'c17' at row 1
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1265 Data truncated for column 'c13' at row 1
|
Note 1265 Data truncated for column 'c13' at row 1
|
||||||
Warning 1265 Data truncated for column 'c17' at row 1
|
Warning 1265 Data truncated for column 'c17' at row 1
|
||||||
Warnings:
|
Warnings:
|
||||||
|
Note 1265 Data truncated for column 'c13' at row 1
|
||||||
Warning 1265 Data truncated for column 'c17' at row 1
|
Warning 1265 Data truncated for column 'c17' at row 1
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1265 Data truncated for column 'c13' at row 1
|
Note 1265 Data truncated for column 'c13' at row 1
|
||||||
@ -2931,7 +2933,6 @@ Warning 1265 Data truncated for column 'c15' at row 1
|
|||||||
Warning 1264 Out of range value for column 'c16' at row 1
|
Warning 1264 Out of range value for column 'c16' at row 1
|
||||||
Warning 1264 Out of range value for column 'c17' at row 1
|
Warning 1264 Out of range value for column 'c17' at row 1
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1265 Data truncated for column 'c13' at row 1
|
|
||||||
Warning 1265 Data truncated for column 'c15' at row 1
|
Warning 1265 Data truncated for column 'c15' at row 1
|
||||||
Warning 1264 Out of range value for column 'c16' at row 1
|
Warning 1264 Out of range value for column 'c16' at row 1
|
||||||
Warning 1264 Out of range value for column 'c17' at row 1
|
Warning 1264 Out of range value for column 'c17' at row 1
|
||||||
@ -5914,11 +5915,13 @@ Warnings:
|
|||||||
Note 1265 Data truncated for column 'c13' at row 1
|
Note 1265 Data truncated for column 'c13' at row 1
|
||||||
Warning 1265 Data truncated for column 'c17' at row 1
|
Warning 1265 Data truncated for column 'c17' at row 1
|
||||||
Warnings:
|
Warnings:
|
||||||
|
Note 1265 Data truncated for column 'c13' at row 1
|
||||||
Warning 1265 Data truncated for column 'c17' at row 1
|
Warning 1265 Data truncated for column 'c17' at row 1
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1265 Data truncated for column 'c13' at row 1
|
Note 1265 Data truncated for column 'c13' at row 1
|
||||||
Warning 1265 Data truncated for column 'c17' at row 1
|
Warning 1265 Data truncated for column 'c17' at row 1
|
||||||
Warnings:
|
Warnings:
|
||||||
|
Note 1265 Data truncated for column 'c13' at row 1
|
||||||
Warning 1265 Data truncated for column 'c17' at row 1
|
Warning 1265 Data truncated for column 'c17' at row 1
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1265 Data truncated for column 'c13' at row 1
|
Note 1265 Data truncated for column 'c13' at row 1
|
||||||
@ -5952,7 +5955,6 @@ Warning 1265 Data truncated for column 'c15' at row 1
|
|||||||
Warning 1264 Out of range value for column 'c16' at row 1
|
Warning 1264 Out of range value for column 'c16' at row 1
|
||||||
Warning 1264 Out of range value for column 'c17' at row 1
|
Warning 1264 Out of range value for column 'c17' at row 1
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1265 Data truncated for column 'c13' at row 1
|
|
||||||
Warning 1265 Data truncated for column 'c15' at row 1
|
Warning 1265 Data truncated for column 'c15' at row 1
|
||||||
Warning 1264 Out of range value for column 'c16' at row 1
|
Warning 1264 Out of range value for column 'c16' at row 1
|
||||||
Warning 1264 Out of range value for column 'c17' at row 1
|
Warning 1264 Out of range value for column 'c17' at row 1
|
||||||
|
@ -1732,4 +1732,18 @@ Variable_name Value
|
|||||||
Qcache_queries_in_cache 1
|
Qcache_queries_in_cache 1
|
||||||
drop database db2;
|
drop database db2;
|
||||||
drop database db3;
|
drop database db3;
|
||||||
|
CREATE TABLE t1 (a ENUM('rainbow'));
|
||||||
|
INSERT INTO t1 VALUES (),(),(),(),();
|
||||||
|
SELECT 1 FROM t1 GROUP BY (SELECT 1 FROM t1 ORDER BY AVG(LAST_INSERT_ID()));
|
||||||
|
1
|
||||||
|
1
|
||||||
|
DROP TABLE t1;
|
||||||
|
CREATE TABLE t1 (a LONGBLOB);
|
||||||
|
INSERT INTO t1 SET a = 'aaaa';
|
||||||
|
INSERT INTO t1 SET a = 'aaaa';
|
||||||
|
SELECT 1 FROM t1 GROUP BY
|
||||||
|
(SELECT LAST_INSERT_ID() FROM t1 ORDER BY MIN(a) ASC LIMIT 1);
|
||||||
|
1
|
||||||
|
1
|
||||||
|
DROP TABLE t1;
|
||||||
End of 5.1 tests
|
End of 5.1 tests
|
||||||
|
@ -155,3 +155,33 @@ str_to_date( '', a )
|
|||||||
0000-00-00 00:00:00
|
0000-00-00 00:00:00
|
||||||
NULL
|
NULL
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
CREATE TABLE t1 (a DATE, b int, PRIMARY KEY (a,b));
|
||||||
|
INSERT INTO t1 VALUES (DATE(NOW()), 1);
|
||||||
|
SELECT COUNT(*) FROM t1 WHERE a = NOW();
|
||||||
|
COUNT(*)
|
||||||
|
0
|
||||||
|
EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW();
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||||
|
INSERT INTO t1 VALUES (DATE(NOW()), 2);
|
||||||
|
SELECT COUNT(*) FROM t1 WHERE a = NOW();
|
||||||
|
COUNT(*)
|
||||||
|
0
|
||||||
|
EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW();
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||||
|
SELECT COUNT(*) FROM t1 WHERE a = NOW() AND b = 1;
|
||||||
|
COUNT(*)
|
||||||
|
0
|
||||||
|
EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW() AND b = 1;
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||||
|
ALTER TABLE t1 DROP PRIMARY KEY;
|
||||||
|
SELECT COUNT(*) FROM t1 WHERE a = NOW();
|
||||||
|
COUNT(*)
|
||||||
|
0
|
||||||
|
EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW();
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
|
||||||
|
DROP TABLE t1;
|
||||||
|
End of 5.0 tests
|
||||||
|
@ -59,6 +59,8 @@ t
|
|||||||
drop table t1;
|
drop table t1;
|
||||||
CREATE TABLE t1 (a timestamp, b date, c time, d datetime);
|
CREATE TABLE t1 (a timestamp, b date, c time, d datetime);
|
||||||
insert into t1 (b,c,d) values(now(),curtime(),now());
|
insert into t1 (b,c,d) values(now(),curtime(),now());
|
||||||
|
Warnings:
|
||||||
|
Note 1265 Data truncated for column 'b' at row 1
|
||||||
select date_format(a,"%Y-%m-%d")=b,right(a+0,6)=c+0,a=d+0 from t1;
|
select date_format(a,"%Y-%m-%d")=b,right(a+0,6)=c+0,a=d+0 from t1;
|
||||||
date_format(a,"%Y-%m-%d")=b right(a+0,6)=c+0 a=d+0
|
date_format(a,"%Y-%m-%d")=b right(a+0,6)=c+0 a=d+0
|
||||||
1 1 1
|
1 1 1
|
||||||
|
@ -2956,11 +2956,13 @@ Warnings:
|
|||||||
Note 1265 Data truncated for column 'c13' at row 1
|
Note 1265 Data truncated for column 'c13' at row 1
|
||||||
Warning 1265 Data truncated for column 'c17' at row 1
|
Warning 1265 Data truncated for column 'c17' at row 1
|
||||||
Warnings:
|
Warnings:
|
||||||
|
Note 1265 Data truncated for column 'c13' at row 1
|
||||||
Warning 1265 Data truncated for column 'c17' at row 1
|
Warning 1265 Data truncated for column 'c17' at row 1
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1265 Data truncated for column 'c13' at row 1
|
Note 1265 Data truncated for column 'c13' at row 1
|
||||||
Warning 1265 Data truncated for column 'c17' at row 1
|
Warning 1265 Data truncated for column 'c17' at row 1
|
||||||
Warnings:
|
Warnings:
|
||||||
|
Note 1265 Data truncated for column 'c13' at row 1
|
||||||
Warning 1265 Data truncated for column 'c17' at row 1
|
Warning 1265 Data truncated for column 'c17' at row 1
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1265 Data truncated for column 'c13' at row 1
|
Note 1265 Data truncated for column 'c13' at row 1
|
||||||
@ -2994,7 +2996,6 @@ Warning 1265 Data truncated for column 'c15' at row 1
|
|||||||
Warning 1264 Out of range value for column 'c16' at row 1
|
Warning 1264 Out of range value for column 'c16' at row 1
|
||||||
Warning 1264 Out of range value for column 'c17' at row 1
|
Warning 1264 Out of range value for column 'c17' at row 1
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1265 Data truncated for column 'c13' at row 1
|
|
||||||
Warning 1265 Data truncated for column 'c15' at row 1
|
Warning 1265 Data truncated for column 'c15' at row 1
|
||||||
Warning 1264 Out of range value for column 'c16' at row 1
|
Warning 1264 Out of range value for column 'c16' at row 1
|
||||||
Warning 1264 Out of range value for column 'c17' at row 1
|
Warning 1264 Out of range value for column 'c17' at row 1
|
||||||
|
@ -211,7 +211,8 @@ drop table t2;
|
|||||||
# select list counter
|
# select list counter
|
||||||
#
|
#
|
||||||
CREATE TABLE `t1` ( `itemid` int(11) NOT NULL default '0', `grpid` varchar(15) NOT NULL default '', `vendor` int(11) NOT NULL default '0', `date_` date NOT NULL default '0000-00-00', `price` decimal(12,2) NOT NULL default '0.00', PRIMARY KEY (`itemid`,`grpid`,`vendor`,`date_`), KEY `itemid` (`itemid`,`vendor`), KEY `itemid_2` (`itemid`,`date_`));
|
CREATE TABLE `t1` ( `itemid` int(11) NOT NULL default '0', `grpid` varchar(15) NOT NULL default '', `vendor` int(11) NOT NULL default '0', `date_` date NOT NULL default '0000-00-00', `price` decimal(12,2) NOT NULL default '0.00', PRIMARY KEY (`itemid`,`grpid`,`vendor`,`date_`), KEY `itemid` (`itemid`,`vendor`), KEY `itemid_2` (`itemid`,`date_`));
|
||||||
insert into t1 values (128, 'rozn', 2, now(), 10),(128, 'rozn', 1, now(), 10);
|
insert into t1 values (128, 'rozn', 2, curdate(), 10),
|
||||||
|
(128, 'rozn', 1, curdate(), 10);
|
||||||
SELECT MIN(price) min, MAX(price) max, AVG(price) avg FROM (SELECT SUBSTRING( MAX(concat(date_,";",price)), 12) price FROM t1 WHERE itemid=128 AND grpid='rozn' GROUP BY itemid, grpid, vendor) lastprices;
|
SELECT MIN(price) min, MAX(price) max, AVG(price) avg FROM (SELECT SUBSTRING( MAX(concat(date_,";",price)), 12) price FROM t1 WHERE itemid=128 AND grpid='rozn' GROUP BY itemid, grpid, vendor) lastprices;
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
|
||||||
|
@ -1333,4 +1333,21 @@ show status like 'Qcache_queries_in_cache';
|
|||||||
drop database db2;
|
drop database db2;
|
||||||
drop database db3;
|
drop database db3;
|
||||||
|
|
||||||
|
#
|
||||||
|
# Bug #31157: Crash when select+order by the avg of some field within the
|
||||||
|
# group by
|
||||||
|
#
|
||||||
|
|
||||||
|
CREATE TABLE t1 (a ENUM('rainbow'));
|
||||||
|
INSERT INTO t1 VALUES (),(),(),(),();
|
||||||
|
SELECT 1 FROM t1 GROUP BY (SELECT 1 FROM t1 ORDER BY AVG(LAST_INSERT_ID()));
|
||||||
|
DROP TABLE t1;
|
||||||
|
CREATE TABLE t1 (a LONGBLOB);
|
||||||
|
INSERT INTO t1 SET a = 'aaaa';
|
||||||
|
INSERT INTO t1 SET a = 'aaaa';
|
||||||
|
SELECT 1 FROM t1 GROUP BY
|
||||||
|
(SELECT LAST_INSERT_ID() FROM t1 ORDER BY MIN(a) ASC LIMIT 1);
|
||||||
|
DROP TABLE t1;
|
||||||
|
|
||||||
|
|
||||||
--echo End of 5.1 tests
|
--echo End of 5.1 tests
|
||||||
|
@ -152,3 +152,25 @@ INSERT INTO t1 VALUES (NULL);
|
|||||||
|
|
||||||
SELECT str_to_date( '', a ) FROM t1;
|
SELECT str_to_date( '', a ) FROM t1;
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Bug #31221: Optimizer incorrectly identifies impossible WHERE clause
|
||||||
|
#
|
||||||
|
|
||||||
|
CREATE TABLE t1 (a DATE, b int, PRIMARY KEY (a,b));
|
||||||
|
INSERT INTO t1 VALUES (DATE(NOW()), 1);
|
||||||
|
SELECT COUNT(*) FROM t1 WHERE a = NOW();
|
||||||
|
EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW();
|
||||||
|
INSERT INTO t1 VALUES (DATE(NOW()), 2);
|
||||||
|
SELECT COUNT(*) FROM t1 WHERE a = NOW();
|
||||||
|
EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW();
|
||||||
|
SELECT COUNT(*) FROM t1 WHERE a = NOW() AND b = 1;
|
||||||
|
EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW() AND b = 1;
|
||||||
|
ALTER TABLE t1 DROP PRIMARY KEY;
|
||||||
|
SELECT COUNT(*) FROM t1 WHERE a = NOW();
|
||||||
|
EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW();
|
||||||
|
|
||||||
|
DROP TABLE t1;
|
||||||
|
|
||||||
|
--echo End of 5.0 tests
|
||||||
|
25
sql/field.cc
25
sql/field.cc
@ -5609,7 +5609,7 @@ int Field_newdate::store(const char *from,uint len,CHARSET_INFO *cs)
|
|||||||
{
|
{
|
||||||
tmp= l_time.day + l_time.month*32 + l_time.year*16*32;
|
tmp= l_time.day + l_time.month*32 + l_time.year*16*32;
|
||||||
if (!error && (ret != MYSQL_TIMESTAMP_DATE) &&
|
if (!error && (ret != MYSQL_TIMESTAMP_DATE) &&
|
||||||
thd->count_cuted_fields != CHECK_FIELD_IGNORE)
|
(l_time.hour || l_time.minute || l_time.second || l_time.second_part))
|
||||||
error= 3; // Datetime was cut (note)
|
error= 3; // Datetime was cut (note)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5657,10 +5657,16 @@ int Field_newdate::store(longlong nr, bool unsigned_val)
|
|||||||
else
|
else
|
||||||
tmp= l_time.day + l_time.month*32 + l_time.year*16*32;
|
tmp= l_time.day + l_time.month*32 + l_time.year*16*32;
|
||||||
|
|
||||||
|
if (!error && l_time.time_type != MYSQL_TIMESTAMP_DATE &&
|
||||||
|
(l_time.hour || l_time.minute || l_time.second || l_time.second_part))
|
||||||
|
error= 3;
|
||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
|
set_datetime_warning(error == 3 ? MYSQL_ERROR::WARN_LEVEL_NOTE :
|
||||||
error == 2 ? ER_WARN_DATA_OUT_OF_RANGE :
|
MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||||
WARN_DATA_TRUNCATED,nr,MYSQL_TIMESTAMP_DATE, 1);
|
error == 2 ?
|
||||||
|
ER_WARN_DATA_OUT_OF_RANGE : WARN_DATA_TRUNCATED,
|
||||||
|
nr,MYSQL_TIMESTAMP_DATE, 1);
|
||||||
|
|
||||||
int3store(ptr,tmp);
|
int3store(ptr,tmp);
|
||||||
return error;
|
return error;
|
||||||
@ -5688,6 +5694,17 @@ int Field_newdate::store_time(MYSQL_TIME *ltime,timestamp_type time_type)
|
|||||||
set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED,
|
set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED,
|
||||||
str.ptr(), str.length(), MYSQL_TIMESTAMP_DATE, 1);
|
str.ptr(), str.length(), MYSQL_TIMESTAMP_DATE, 1);
|
||||||
}
|
}
|
||||||
|
if (!error && ltime->time_type != MYSQL_TIMESTAMP_DATE &&
|
||||||
|
(ltime->hour || ltime->minute || ltime->second || ltime->second_part))
|
||||||
|
{
|
||||||
|
char buff[MAX_DATE_STRING_REP_LENGTH];
|
||||||
|
String str(buff, sizeof(buff), &my_charset_latin1);
|
||||||
|
make_datetime((DATE_TIME_FORMAT *) 0, ltime, &str);
|
||||||
|
set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_NOTE,
|
||||||
|
WARN_DATA_TRUNCATED,
|
||||||
|
str.ptr(), str.length(), MYSQL_TIMESTAMP_DATE, 1);
|
||||||
|
error= 3;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -3624,10 +3624,17 @@ longlong Item_func_last_insert_id::val_int()
|
|||||||
thd->first_successful_insert_id_in_prev_stmt= value;
|
thd->first_successful_insert_id_in_prev_stmt= value;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
|
|
||||||
return thd->read_first_successful_insert_id_in_prev_stmt();
|
return thd->read_first_successful_insert_id_in_prev_stmt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Item_func_last_insert_id::fix_fields(THD *thd, Item **ref)
|
||||||
|
{
|
||||||
|
thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
|
||||||
|
return Item_int_func::fix_fields(thd, ref);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* This function is just used to test speed of different functions */
|
/* This function is just used to test speed of different functions */
|
||||||
|
|
||||||
longlong Item_func_benchmark::val_int()
|
longlong Item_func_benchmark::val_int()
|
||||||
|
@ -935,6 +935,7 @@ public:
|
|||||||
if (arg_count)
|
if (arg_count)
|
||||||
max_length= args[0]->max_length;
|
max_length= args[0]->max_length;
|
||||||
}
|
}
|
||||||
|
bool fix_fields(THD *thd, Item **ref);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1651,8 +1651,7 @@ bool Item_func_now::get_date(MYSQL_TIME *res,
|
|||||||
int Item_func_now::save_in_field(Field *to, bool no_conversions)
|
int Item_func_now::save_in_field(Field *to, bool no_conversions)
|
||||||
{
|
{
|
||||||
to->set_notnull();
|
to->set_notnull();
|
||||||
to->store_time(<ime, MYSQL_TIMESTAMP_DATETIME);
|
return to->store_time(<ime, MYSQL_TIMESTAMP_DATETIME);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user