summaryrefslogtreecommitdiff
path: root/sql/sys_vars.ic
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2020-08-24 22:55:39 +0400
committerAlexander Barkov <bar@mariadb.com>2020-08-24 22:55:39 +0400
commit329301d2e647db099e1554663578f0352125d1c9 (patch)
treed97c093fb667851ea40e437df140aad201fda4e9 /sql/sys_vars.ic
parent056766c042e975a91b016246357e9e6929b60b1a (diff)
downloadmariadb-git-329301d2e647db099e1554663578f0352125d1c9.tar.gz
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.
Diffstat (limited to 'sql/sys_vars.ic')
-rw-r--r--sql/sys_vars.ic6
1 files changed, 5 insertions, 1 deletions
diff --git a/sql/sys_vars.ic b/sql/sys_vars.ic
index 8e8ec4f00bc..94bfb3bb1bb 100644
--- a/sql/sys_vars.ic
+++ b/sql/sys_vars.ic
@@ -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
{