From 6d73282b136058deb992fdb758d8992fa186e73e Mon Sep 17 00:00:00 2001 From: Aleksey Midenkov Date: Wed, 21 Apr 2021 22:14:08 +0300 Subject: MDEV-25468 DELETE HISTORY may delete current data on system-versioned table Item_func_history (is_history()) is a bool function that checks if the row is the history row by checking row_end->is_max(). The argument to this function must be row_end system field. Added the above function to conjunction with SYSTEM_TIME_BEFORE versioning condition. --- sql/item_vers.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'sql/item_vers.cc') diff --git a/sql/item_vers.cc b/sql/item_vers.cc index cfedc6b0f81..76cda6a5ea2 100644 --- a/sql/item_vers.cc +++ b/sql/item_vers.cc @@ -26,6 +26,22 @@ #include "tztime.h" #include "item.h" +bool Item_func_history::val_bool() +{ + Item_field *f= static_cast(args[0]); + DBUG_ASSERT(f->fixed); + DBUG_ASSERT(f->field->flags & VERS_SYS_END_FLAG); + return !f->field->is_max(); +} + +void Item_func_history::print(String *str, enum_query_type query_type) +{ + str->append(func_name()); + str->append('('); + args[0]->print(str, query_type); + str->append(')'); +} + Item_func_trt_ts::Item_func_trt_ts(THD *thd, Item* a, TR_table::field_id_t _trt_field) : Item_datetimefunc(thd, a), trt_field(_trt_field) -- cgit v1.2.1