Commit ce6505f8 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-18447 Assertion `!is_zero_datetime()' failed in Timestamp_or_zero_datetime::tv

parent 9f56dd73
...@@ -1164,5 +1164,14 @@ NULL ...@@ -1164,5 +1164,14 @@ NULL
NULL NULL
DROP TABLE t1, t2, t3; DROP TABLE t1, t2, t3;
# #
# MDEV-18447 Assertion `!is_zero_datetime()' failed in Timestamp_or_zero_datetime::tv
#
CREATE TABLE t1 (a TIMESTAMP DEFAULT 0, b TIMESTAMP DEFAULT 0, c TIME DEFAULT 0);
INSERT INTO t1 VALUES (0,0,0);
SELECT c IN (GREATEST(a,b)) FROM t1;
c IN (GREATEST(a,b))
0
DROP TABLE t1;
#
# End of 10.4 tests # End of 10.4 tests
# #
...@@ -760,6 +760,14 @@ CREATE TABLE t3 (pk INT PRIMARY KEY, b TIMESTAMP) ENGINE=MyISAM; ...@@ -760,6 +760,14 @@ CREATE TABLE t3 (pk INT PRIMARY KEY, b TIMESTAMP) ENGINE=MyISAM;
SELECT ( SELECT b FROM t1 LIMIT 1 ) AS sq FROM t2 LEFT JOIN t3 USING (pk); SELECT ( SELECT b FROM t1 LIMIT 1 ) AS sq FROM t2 LEFT JOIN t3 USING (pk);
DROP TABLE t1, t2, t3; DROP TABLE t1, t2, t3;
--echo #
--echo # MDEV-18447 Assertion `!is_zero_datetime()' failed in Timestamp_or_zero_datetime::tv
--echo #
CREATE TABLE t1 (a TIMESTAMP DEFAULT 0, b TIMESTAMP DEFAULT 0, c TIME DEFAULT 0);
INSERT INTO t1 VALUES (0,0,0);
SELECT c IN (GREATEST(a,b)) FROM t1;
DROP TABLE t1;
--echo # --echo #
--echo # End of 10.4 tests --echo # End of 10.4 tests
......
...@@ -2435,6 +2435,12 @@ class Timestamp_or_zero_datetime_native: ...@@ -2435,6 +2435,12 @@ class Timestamp_or_zero_datetime_native:
length(0); // safety length(0); // safety
} }
int save_in_field(Field *field, uint decimals) const; int save_in_field(Field *field, uint decimals) const;
Datetime to_datetime(THD *thd) const
{
return is_zero_datetime() ?
Datetime() :
Datetime(thd, Timestamp_or_zero_datetime(*this).tv());
}
bool is_zero_datetime() const bool is_zero_datetime() const
{ {
return length() == 0; return length() == 0;
...@@ -2459,7 +2465,7 @@ class Timestamp_or_zero_datetime_native_null: public Timestamp_or_zero_datetime_ ...@@ -2459,7 +2465,7 @@ class Timestamp_or_zero_datetime_native_null: public Timestamp_or_zero_datetime_
Datetime to_datetime(THD *thd) const Datetime to_datetime(THD *thd) const
{ {
return is_null() ? Datetime() : return is_null() ? Datetime() :
Datetime(thd, Timestamp_or_zero_datetime(*this).tv()); Timestamp_or_zero_datetime_native::to_datetime(thd);
} }
void to_TIME(THD *thd, MYSQL_TIME *to) void to_TIME(THD *thd, MYSQL_TIME *to)
{ {
......
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