Commit 329301d2 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-23562 Assertion `time_type == MYSQL_TIMESTAMP_DATETIME' failed upon...

MDEV-23562 Assertion `time_type == MYSQL_TIMESTAMP_DATETIME' failed upon SELECT from versioned table

The code in vers_select_conds_t::init_from_sysvar() assumed that
the value of the system_versioning_asof is DATETIME.
But it also could be DATE after a query like this:
  SET system_versioning_asof = DATE(NOW());

Fixing Sys_var_vers_asof::update() to convert the value
of the assignment source to DATETIME if it returned DATE.

Now vers_select_conds_t::init_from_sysvar() always gets a DATETIME value.
parent 056766c0
......@@ -186,4 +186,13 @@ SELECT @@global.system_versioning_asof;
@@global.system_versioning_asof
2002-01-01 00:00:00.000000
SET @@global.system_versioning_asof= DEFAULT;
#
# MDEV-23562 Assertion `time_type == MYSQL_TIMESTAMP_DATETIME' failed upon SELECT from versioned table
#
CREATE TABLE t1 (a INT) WITH SYSTEM VERSIONING;
SET system_versioning_asof= DATE(NOW());
SELECT * FROM t1;
a
DROP TABLE t1;
SET system_versioning_asof= DEFAULT;
# End of 10.4 tests
......@@ -138,4 +138,14 @@ SET @@global.system_versioning_asof= timestamp'2001-12-31 23:59:59.9999999';
SELECT @@global.system_versioning_asof;
SET @@global.system_versioning_asof= DEFAULT;
--echo #
--echo # MDEV-23562 Assertion `time_type == MYSQL_TIMESTAMP_DATETIME' failed upon SELECT from versioned table
--echo #
CREATE TABLE t1 (a INT) WITH SYSTEM VERSIONING;
SET system_versioning_asof= DATE(NOW());
SELECT * FROM t1;
DROP TABLE t1;
SET system_versioning_asof= DEFAULT;
--echo # End of 10.4 tests
......@@ -2669,7 +2669,11 @@ private:
Datetime::Options opt(TIME_CONV_NONE |
TIME_NO_ZERO_IN_DATE |
TIME_NO_ZERO_DATE, thd);
res= var->value->get_date(thd, &out.ltime, opt);
/*
var->value is allowed to return DATETIME and DATE
Make sure to convert DATE to DATETIME.
*/
res= Datetime(thd, var->value, opt).copy_to_mysql_time(&out.ltime);
}
else // set DEFAULT from global var
{
......
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