Commit 7b33a6a1 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-18876 Assertion `is_valid_time_slow()' failed in Time::valid_MYSQL_TIME_to_valid_value

parent 62bfb2fe
...@@ -55,6 +55,12 @@ select * from t1; ...@@ -55,6 +55,12 @@ select * from t1;
delete from t1 where a < 20110101; delete from t1 where a < 20110101;
select * from t1; select * from t1;
if ($type == time)
{
delete from t1 where a is not null;
select * from t1;
}
# #
# create ... select # create ... select
# #
......
...@@ -188,7 +188,7 @@ create table t1(f1 time); ...@@ -188,7 +188,7 @@ create table t1(f1 time);
insert into t1 values ('23:38:57'); insert into t1 values ('23:38:57');
select f1, f1 = '2010-10-11 23:38:57' from t1; select f1, f1 = '2010-10-11 23:38:57' from t1;
f1 f1 = '2010-10-11 23:38:57' f1 f1 = '2010-10-11 23:38:57'
23:38:57 0 23:38:57 1
drop table t1; drop table t1;
# #
# MDEV-4634 Crash in CONVERT_TZ # MDEV-4634 Crash in CONVERT_TZ
...@@ -2186,5 +2186,27 @@ Warnings: ...@@ -2186,5 +2186,27 @@ Warnings:
Warning 1264 Out of range value for column 't' at row 1 Warning 1264 Out of range value for column 't' at row 1
DROP TABLE t1; DROP TABLE t1;
# #
# MDEV-18876 Assertion `is_valid_time_slow()' failed in Time::valid_MYSQL_TIME_to_valid_value
#
CREATE TABLE t1 (f INT);
INSERT INTO t1 VALUES (1),(2);
SELECT DISTINCT f FROM t1 ORDER BY 1 && ( '1972-11-06 16:58:58' BETWEEN CONVERT( 0, TIME ) AND '20:31:05' );
f
1
2
DROP TABLE t1;
CREATE OR REPLACE TABLE t1 (a VARCHAR(32));
INSERT INTO t1 VALUES ('1972-11-06 16:58:58');
SELECT * FROM t1 WHERE a < TIME'20:31:05';
a
1972-11-06 16:58:58
SELECT a < TIME'20:31:05' FROM t1;
a < TIME'20:31:05'
1
DROP TABLE t1;
SELECT '1972-11-06 16:58:58' < TIME'20:31:05';
'1972-11-06 16:58:58' < TIME'20:31:05'
1
#
# End of 10.4 tests # End of 10.4 tests
# #
...@@ -1430,6 +1430,23 @@ INSERT INTO t1 VALUES (3e19); ...@@ -1430,6 +1430,23 @@ INSERT INTO t1 VALUES (3e19);
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # MDEV-18876 Assertion `is_valid_time_slow()' failed in Time::valid_MYSQL_TIME_to_valid_value
--echo #
CREATE TABLE t1 (f INT);
INSERT INTO t1 VALUES (1),(2);
SELECT DISTINCT f FROM t1 ORDER BY 1 && ( '1972-11-06 16:58:58' BETWEEN CONVERT( 0, TIME ) AND '20:31:05' );
DROP TABLE t1;
CREATE OR REPLACE TABLE t1 (a VARCHAR(32));
INSERT INTO t1 VALUES ('1972-11-06 16:58:58');
SELECT * FROM t1 WHERE a < TIME'20:31:05';
SELECT a < TIME'20:31:05' FROM t1;
DROP TABLE t1;
SELECT '1972-11-06 16:58:58' < TIME'20:31:05';
--echo # --echo #
--echo # End of 10.4 tests --echo # End of 10.4 tests
--echo # --echo #
...@@ -67,8 +67,10 @@ a ...@@ -67,8 +67,10 @@ a
01:02:03.4567 01:02:03.4567
select extract(microsecond from a + interval 100 microsecond) from t1 where a>'2010-11-12 01:02:03.456'; select extract(microsecond from a + interval 100 microsecond) from t1 where a>'2010-11-12 01:02:03.456';
extract(microsecond from a + interval 100 microsecond) extract(microsecond from a + interval 100 microsecond)
456800
select a from t1 where a>'2010-11-12 01:02:03.456' group by a; select a from t1 where a>'2010-11-12 01:02:03.456' group by a;
a a
01:02:03.4567
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
...@@ -115,6 +117,11 @@ NULL ...@@ -115,6 +117,11 @@ NULL
delete from t1 where a < 20110101; delete from t1 where a < 20110101;
select * from t1; select * from t1;
a a
01:02:13.3332
NULL
delete from t1 where a is not null;
select * from t1;
a
NULL NULL
create table t2 select * from t1; create table t2 select * from t1;
create table t3 like t1; create table t3 like t1;
......
...@@ -129,6 +129,20 @@ longlong Item::val_datetime_packed_result(THD *thd) ...@@ -129,6 +129,20 @@ longlong Item::val_datetime_packed_result(THD *thd)
} }
longlong Item::val_time_packed_result(THD *thd)
{
MYSQL_TIME ltime;
if (get_date_result(thd, &ltime, Time::Options_cmp(thd)))
return 0;
if (ltime.time_type == MYSQL_TIMESTAMP_TIME)
return pack_time(&ltime);
int warn= 0;
Time tmp(&warn, &ltime, 0);
DBUG_ASSERT(tmp.is_valid_time());
return tmp.to_packed();
}
/* /*
For the items which don't have its own fast val_str_ascii() For the items which don't have its own fast val_str_ascii()
implementation we provide a generic slower version, implementation we provide a generic slower version,
......
...@@ -1708,12 +1708,7 @@ class Item: public Value_source, ...@@ -1708,12 +1708,7 @@ class Item: public Value_source,
return Time(thd, this, Time::Options_cmp(thd)).to_packed(); return Time(thd, this, Time::Options_cmp(thd)).to_packed();
} }
longlong val_datetime_packed_result(THD *thd); longlong val_datetime_packed_result(THD *thd);
longlong val_time_packed_result(THD *thd) longlong val_time_packed_result(THD *thd);
{
MYSQL_TIME ltime;
return get_date_result(thd, &ltime, Time::Options_cmp(thd)) ? 0 :
pack_time(&ltime);
}
virtual bool get_date_result(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) virtual bool get_date_result(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)
{ return get_date(thd, ltime,fuzzydate); } { return get_date(thd, ltime,fuzzydate); }
......
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