Commit dd034279 authored by unknown's avatar unknown

Merge mysqldev@production.mysql.com:/data0/mysqldev/my/mysql-5.0-release

into  zippy.cornsilk.net:/home/cmiller/work/mysql/mysql-5.0-community


sql/item_func.cc:
  Auto merged
sql/sql_cache.cc:
  Auto merged
parents 1f65eef3 54619d5e
set autocommit=1;
reset master;
create table bug16206 (a int);
insert into bug16206 values(1);
start transaction;
insert into bug16206 values(2);
commit;
show binlog events;
Log_name Pos Event_type Server_id End_log_pos Info
f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4
f n Query 1 n use `test`; create table bug16206 (a int)
f n Query 1 n use `test`; insert into bug16206 values(1)
f n Query 1 n use `test`; insert into bug16206 values(2)
drop table bug16206;
reset master;
create table bug16206 (a int) engine= bdb;
insert into bug16206 values(0);
insert into bug16206 values(1);
start transaction;
insert into bug16206 values(2);
commit;
insert into bug16206 values(3);
show binlog events;
Log_name Pos Event_type Server_id End_log_pos Info
f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4
f n Query 1 n use `test`; create table bug16206 (a int) engine= bdb
f n Query 1 n use `test`; insert into bug16206 values(0)
f n Query 1 n use `test`; insert into bug16206 values(1)
f n Query 1 n use `test`; BEGIN
f n Query 1 n use `test`; insert into bug16206 values(2)
f n Query 1 n use `test`; COMMIT
f n Query 1 n use `test`; insert into bug16206 values(3)
drop table bug16206;
set autocommit=0;
End of 5.0 tests
......@@ -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
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_`));
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;
min max avg
10.00 10.00 10
......
......@@ -2973,11 +2973,13 @@ Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
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 adjusted for column 'c16' at row 1
Warning 1264 Out of range value adjusted for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c15' at row 1
Warning 1264 Out of range value adjusted for column 'c16' at row 1
Warning 1264 Out of range value adjusted for column 'c17' at row 1
......
......@@ -2956,11 +2956,13 @@ Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
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 adjusted for column 'c16' at row 1
Warning 1264 Out of range value adjusted for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c15' at row 1
Warning 1264 Out of range value adjusted for column 'c16' at row 1
Warning 1264 Out of range value adjusted for column 'c17' at row 1
......
......@@ -2957,11 +2957,13 @@ Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
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 adjusted for column 'c16' at row 1
Warning 1264 Out of range value adjusted for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c15' at row 1
Warning 1264 Out of range value adjusted for column 'c16' at row 1
Warning 1264 Out of range value adjusted for column 'c17' at row 1
......
......@@ -2893,11 +2893,13 @@ Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
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 adjusted for column 'c16' at row 1
Warning 1264 Out of range value adjusted for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c15' at row 1
Warning 1264 Out of range value adjusted for column 'c16' at row 1
Warning 1264 Out of range value adjusted for column 'c17' at row 1
......@@ -5914,11 +5915,13 @@ Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
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 adjusted for column 'c16' at row 1
Warning 1264 Out of range value adjusted for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c15' at row 1
Warning 1264 Out of range value adjusted for column 'c16' at row 1
Warning 1264 Out of range value adjusted for column 'c17' at row 1
......
......@@ -2956,11 +2956,13 @@ Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
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 adjusted for column 'c16' at row 1
Warning 1264 Out of range value adjusted for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c15' at row 1
Warning 1264 Out of range value adjusted for column 'c16' at row 1
Warning 1264 Out of range value adjusted for column 'c17' at row 1
......
......@@ -2956,11 +2956,13 @@ Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
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 adjusted for column 'c16' at row 1
Warning 1264 Out of range value adjusted for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c15' at row 1
Warning 1264 Out of range value adjusted for column 'c16' at row 1
Warning 1264 Out of range value adjusted for column 'c17' at row 1
......
......@@ -6389,4 +6389,180 @@ DROP TABLE t1;
DROP PROCEDURE p1;
DROP PROCEDURE p2;
#
# Bug#31035.
#
#
# - Prepare.
#
DROP TABLE IF EXISTS t1;
DROP FUNCTION IF EXISTS f1;
DROP FUNCTION IF EXISTS f2;
DROP FUNCTION IF EXISTS f3;
DROP FUNCTION IF EXISTS f4;
#
# - Create required objects.
#
CREATE TABLE t1(c1 INT);
INSERT INTO t1 VALUES (1), (2), (3);
CREATE FUNCTION f1()
RETURNS INT
NOT DETERMINISTIC
RETURN 1;
CREATE FUNCTION f2(p INT)
RETURNS INT
NOT DETERMINISTIC
RETURN 1;
CREATE FUNCTION f3()
RETURNS INT
DETERMINISTIC
RETURN 1;
CREATE FUNCTION f4(p INT)
RETURNS INT
DETERMINISTIC
RETURN 1;
#
# - Check.
#
SELECT f1() AS a FROM t1 GROUP BY a;
a
1
SELECT f2(@a) AS a FROM t1 GROUP BY a;
a
1
SELECT f3() AS a FROM t1 GROUP BY a;
a
1
SELECT f4(0) AS a FROM t1 GROUP BY a;
a
1
SELECT f4(@a) AS a FROM t1 GROUP BY a;
a
1
#
# - Cleanup.
#
DROP TABLE t1;
DROP FUNCTION f1;
DROP FUNCTION f2;
DROP FUNCTION f3;
DROP FUNCTION f4;
#
# Bug#31191.
#
#
# - Prepare.
#
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
DROP FUNCTION IF EXISTS f1;
#
# - Create required objects.
#
CREATE TABLE t1 (
id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
barcode INT(8) UNSIGNED ZEROFILL nOT NULL,
PRIMARY KEY (id),
UNIQUE KEY barcode (barcode)
);
INSERT INTO t1 (id, barcode) VALUES (1, 12345678);
INSERT INTO t1 (id, barcode) VALUES (2, 12345679);
CREATE TABLE test.t2 (
id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
barcode BIGINT(11) UNSIGNED ZEROFILL NOT NULL,
PRIMARY KEY (id)
);
INSERT INTO test.t2 (id, barcode) VALUES (1, 12345106708);
INSERT INTO test.t2 (id, barcode) VALUES (2, 12345106709);
CREATE FUNCTION f1(p INT(8))
RETURNS BIGINT(11) UNSIGNED
READS SQL DATA
RETURN FLOOR(p/1000)*1000000 + 100000 + FLOOR((p MOD 1000)/10)*100 + (p MOD 10);
#
# - Check.
#
SELECT DISTINCT t1.barcode, f1(t1.barcode)
FROM t1
INNER JOIN t2
ON f1(t1.barcode) = t2.barcode
WHERE t1.barcode=12345678;
barcode f1(t1.barcode)
12345678 12345106708
#
# - Cleanup.
#
DROP TABLE t1;
DROP TABLE t2;
DROP FUNCTION f1;
#
# Bug#31226.
#
#
# - Prepare.
#
DROP TABLE IF EXISTS t1;
DROP FUNCTION IF EXISTS f1;
#
# - Create required objects.
#
CREATE TABLE t1(id INT);
INSERT INTO t1 VALUES (1), (2), (3);
CREATE FUNCTION f1()
RETURNS DATETIME
NOT DETERMINISTIC NO SQL
RETURN NOW();
#
# - Check.
#
SELECT f1() FROM t1 GROUP BY 1;
f1()
<timestamp>
#
# - Cleanup.
#
DROP TABLE t1;
DROP FUNCTION f1;
End of 5.0 tests
......@@ -136,3 +136,33 @@ d dt ts
0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00
2001-11-11 2001-11-11 00:00:00 2001-11-11 00:00:00
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;
CREATE TABLE t1 (a timestamp, b date, c time, d datetime);
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;
date_format(a,"%Y-%m-%d")=b right(a+0,6)=c+0 a=d+0
1 1 1
......
-- source include/not_embedded.inc
-- source include/have_bdb.inc
#
# Bug #16206: Superfluous COMMIT event in binlog when updating BDB in autocommit mode
#
set autocommit=1;
let $VERSION=`select version()`;
reset master;
create table bug16206 (a int);
insert into bug16206 values(1);
start transaction;
insert into bug16206 values(2);
commit;
--replace_result $VERSION VERSION
--replace_column 1 f 2 n 5 n
show binlog events;
drop table bug16206;
reset master;
create table bug16206 (a int) engine= bdb;
insert into bug16206 values(0);
insert into bug16206 values(1);
start transaction;
insert into bug16206 values(2);
commit;
insert into bug16206 values(3);
--replace_result $VERSION VERSION
--replace_column 1 f 2 n 5 n
show binlog events;
drop table bug16206;
set autocommit=0;
--echo End of 5.0 tests
......@@ -211,7 +211,8 @@ drop table t2;
# 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_`));
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;
DROP TABLE t1;
......
......@@ -7387,4 +7387,294 @@ DROP TABLE t1;
DROP PROCEDURE p1;
DROP PROCEDURE p2;
###########################################################################
#
# Bug#31035: select from function, group by result crasher.
#
###########################################################################
--echo
--echo #
--echo # Bug#31035.
--echo #
--echo
--echo #
--echo # - Prepare.
--echo #
--echo
--disable_warnings
DROP TABLE IF EXISTS t1;
DROP FUNCTION IF EXISTS f1;
DROP FUNCTION IF EXISTS f2;
DROP FUNCTION IF EXISTS f3;
DROP FUNCTION IF EXISTS f4;
--enable_warnings
--echo
--echo #
--echo # - Create required objects.
--echo #
--echo
CREATE TABLE t1(c1 INT);
--echo
INSERT INTO t1 VALUES (1), (2), (3);
--echo
CREATE FUNCTION f1()
RETURNS INT
NOT DETERMINISTIC
RETURN 1;
--echo
CREATE FUNCTION f2(p INT)
RETURNS INT
NOT DETERMINISTIC
RETURN 1;
--echo
CREATE FUNCTION f3()
RETURNS INT
DETERMINISTIC
RETURN 1;
--echo
CREATE FUNCTION f4(p INT)
RETURNS INT
DETERMINISTIC
RETURN 1;
--echo
--echo #
--echo # - Check.
--echo #
--echo
# Not deterministic function, no arguments.
SELECT f1() AS a FROM t1 GROUP BY a;
--echo
# Not deterministic function, non-constant argument.
SELECT f2(@a) AS a FROM t1 GROUP BY a;
--echo
# Deterministic function, no arguments.
SELECT f3() AS a FROM t1 GROUP BY a;
--echo
# Deterministic function, constant argument.
SELECT f4(0) AS a FROM t1 GROUP BY a;
--echo
# Deterministic function, non-constant argument.
SELECT f4(@a) AS a FROM t1 GROUP BY a;
--echo
--echo #
--echo # - Cleanup.
--echo #
--echo
DROP TABLE t1;
DROP FUNCTION f1;
DROP FUNCTION f2;
DROP FUNCTION f3;
DROP FUNCTION f4;
--echo
###########################################################################
#
# Bug#31191: JOIN in combination with stored function crashes the server.
#
###########################################################################
--echo #
--echo # Bug#31191.
--echo #
--echo
--echo #
--echo # - Prepare.
--echo #
--echo
--disable_warnings
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
DROP FUNCTION IF EXISTS f1;
--enable_warnings
--echo
--echo #
--echo # - Create required objects.
--echo #
--echo
CREATE TABLE t1 (
id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
barcode INT(8) UNSIGNED ZEROFILL nOT NULL,
PRIMARY KEY (id),
UNIQUE KEY barcode (barcode)
);
--echo
INSERT INTO t1 (id, barcode) VALUES (1, 12345678);
INSERT INTO t1 (id, barcode) VALUES (2, 12345679);
--echo
CREATE TABLE test.t2 (
id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
barcode BIGINT(11) UNSIGNED ZEROFILL NOT NULL,
PRIMARY KEY (id)
);
--echo
INSERT INTO test.t2 (id, barcode) VALUES (1, 12345106708);
INSERT INTO test.t2 (id, barcode) VALUES (2, 12345106709);
--echo
CREATE FUNCTION f1(p INT(8))
RETURNS BIGINT(11) UNSIGNED
READS SQL DATA
RETURN FLOOR(p/1000)*1000000 + 100000 + FLOOR((p MOD 1000)/10)*100 + (p MOD 10);
--echo
--echo #
--echo # - Check.
--echo #
--echo
SELECT DISTINCT t1.barcode, f1(t1.barcode)
FROM t1
INNER JOIN t2
ON f1(t1.barcode) = t2.barcode
WHERE t1.barcode=12345678;
--echo
--echo #
--echo # - Cleanup.
--echo #
--echo
DROP TABLE t1;
DROP TABLE t2;
DROP FUNCTION f1;
--echo
###########################################################################
#
# Bug#31226: Group by function crashes mysql.
#
###########################################################################
--echo #
--echo # Bug#31226.
--echo #
--echo
--echo #
--echo # - Prepare.
--echo #
--echo
--disable_warnings
DROP TABLE IF EXISTS t1;
DROP FUNCTION IF EXISTS f1;
--enable_warnings
--echo
--echo #
--echo # - Create required objects.
--echo #
--echo
CREATE TABLE t1(id INT);
--echo
INSERT INTO t1 VALUES (1), (2), (3);
--echo
CREATE FUNCTION f1()
RETURNS DATETIME
NOT DETERMINISTIC NO SQL
RETURN NOW();
--echo
--echo #
--echo # - Check.
--echo #
--echo
--replace_column 1 <timestamp>
SELECT f1() FROM t1 GROUP BY 1;
--echo
--echo #
--echo # - Cleanup.
--echo #
--echo
DROP TABLE t1;
DROP FUNCTION f1;
--echo
###########################################################################
--echo End of 5.0 tests
......@@ -136,3 +136,24 @@ insert into t1 values (9912101,9912101,9912101);
insert into t1 values (11111,11111,11111);
select * from 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
......@@ -5272,7 +5272,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;
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)
}
......@@ -5319,10 +5319,16 @@ int Field_newdate::store(longlong nr, bool unsigned_val)
else
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)
set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
error == 2 ? ER_WARN_DATA_OUT_OF_RANGE :
WARN_DATA_TRUNCATED,nr,MYSQL_TIMESTAMP_DATE, 1);
set_datetime_warning(error == 3 ? MYSQL_ERROR::WARN_LEVEL_NOTE :
MYSQL_ERROR::WARN_LEVEL_WARN,
error == 2 ?
ER_WARN_DATA_OUT_OF_RANGE : WARN_DATA_TRUNCATED,
nr,MYSQL_TIMESTAMP_DATE, 1);
int3store(ptr,tmp);
return error;
......@@ -5349,6 +5355,17 @@ int Field_newdate::store_time(MYSQL_TIME *ltime, timestamp_type time_type)
set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED,
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
{
......
......@@ -5583,8 +5583,13 @@ Item_func_sp::fix_fields(THD *thd, Item **ref)
#endif /* ! NO_EMBEDDED_ACCESS_CHECKS */
}
if (!m_sp->m_chistics->detistic)
used_tables_cache |= RAND_TABLE_BIT;
{
used_tables_cache |= RAND_TABLE_BIT;
const_item_cache= FALSE;
}
DBUG_RETURN(res);
}
......@@ -5592,6 +5597,10 @@ Item_func_sp::fix_fields(THD *thd, Item **ref)
void Item_func_sp::update_used_tables()
{
Item_func::update_used_tables();
if (!m_sp->m_chistics->detistic)
used_tables_cache |= RAND_TABLE_BIT;
{
used_tables_cache |= RAND_TABLE_BIT;
const_item_cache= FALSE;
}
}
......@@ -1603,8 +1603,7 @@ bool Item_func_now::get_date(MYSQL_TIME *res,
int Item_func_now::save_in_field(Field *to, bool no_conversions)
{
to->set_notnull();
to->store_time(&ltime, MYSQL_TIMESTAMP_DATETIME);
return 0;
return to->store_time(&ltime, MYSQL_TIMESTAMP_DATETIME);
}
......
......@@ -1035,12 +1035,14 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
Query_cache_block_table *block_table, *block_table_end;
ulong tot_length;
Query_cache_query_flags flags;
#ifndef __WIN__
const uint spin_treshold= 50000;
const double lock_time_treshold= 0.1; /* Time in seconds */
uint spin_count= 0;
int lock_status= 0;
ulong new_time= 0;
ulong stop_time= 0;
#endif
DBUG_ENTER("Query_cache::send_result_to_client");
......@@ -1088,6 +1090,9 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
}
}
#ifdef __WIN__
STRUCT_LOCK(&structure_guard_mutex);
#else
stop_time= my_clock()+(ulong)lock_time_treshold*CLOCKS_PER_SEC;
while ((lock_status= pthread_mutex_trylock(&structure_guard_mutex)) == EBUSY
&& spin_count < spin_treshold
......@@ -1110,6 +1115,7 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
thd->lex->safe_to_cache_query= FALSE;
goto err;
}
#endif
if (query_cache_size == 0 || flush_in_progress)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment