Commit 8750df43 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-20517 Assertion `!is_expensive()' failed in Item::value_depends_on_sql_mode_const_item

parent 39e5b76e
...@@ -1557,5 +1557,14 @@ numgtfmt ...@@ -1557,5 +1557,14 @@ numgtfmt
DROP VIEW v1; DROP VIEW v1;
DROP TABLE t1; DROP TABLE t1;
# #
# MDEV-20517 Assertion `!is_expensive()' failed in Item::value_depends_on_sql_mode_const_item
#
SELECT ( 1 LIKE GET_LOCK( 'foo', 0 ) ) - 2;
( 1 LIKE GET_LOCK( 'foo', 0 ) ) - 2
-1
SELECT RELEASE_LOCK('foo');
RELEASE_LOCK('foo')
1
#
# End of 10.2 tests # End of 10.2 tests
# #
...@@ -1192,6 +1192,12 @@ SELECT * FROM v1 WHERE numgtfmt = NAME_CONST('wnumgtfmt',_utf8'QEDITIONS' COLLA ...@@ -1192,6 +1192,12 @@ SELECT * FROM v1 WHERE numgtfmt = NAME_CONST('wnumgtfmt',_utf8'QEDITIONS' COLLA
DROP VIEW v1; DROP VIEW v1;
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # MDEV-20517 Assertion `!is_expensive()' failed in Item::value_depends_on_sql_mode_const_item
--echo #
SELECT ( 1 LIKE GET_LOCK( 'foo', 0 ) ) - 2;
SELECT RELEASE_LOCK('foo');
--echo # --echo #
--echo # End of 10.2 tests --echo # End of 10.2 tests
......
...@@ -1423,17 +1423,22 @@ bool Item_func_minus::fix_length_and_dec() ...@@ -1423,17 +1423,22 @@ bool Item_func_minus::fix_length_and_dec()
{ {
if (Item_num_op::fix_length_and_dec()) if (Item_num_op::fix_length_and_dec())
return TRUE; return TRUE;
m_sql_mode_dependency= Item_func::value_depends_on_sql_mode(); if ((m_depends_on_sql_mode_no_unsigned_subtraction= unsigned_flag) &&
if (unsigned_flag) (current_thd->variables.sql_mode & MODE_NO_UNSIGNED_SUBTRACTION))
{ unsigned_flag= false;
m_sql_mode_dependency|= Sql_mode_dependency(0,MODE_NO_UNSIGNED_SUBTRACTION);
if (current_thd->variables.sql_mode & MODE_NO_UNSIGNED_SUBTRACTION)
unsigned_flag= false;
}
return FALSE; return FALSE;
} }
Sql_mode_dependency Item_func_minus::value_depends_on_sql_mode() const
{
Sql_mode_dependency dep= Item_func_additive_op::value_depends_on_sql_mode();
if (m_depends_on_sql_mode_no_unsigned_subtraction)
dep|= Sql_mode_dependency(0, MODE_NO_UNSIGNED_SUBTRACTION);
return dep;
}
double Item_func_minus::real_op() double Item_func_minus::real_op()
{ {
double value= args[0]->val_real() - args[1]->val_real(); double value= args[0]->val_real() - args[1]->val_real();
......
...@@ -773,16 +773,15 @@ class Item_func_plus :public Item_func_additive_op ...@@ -773,16 +773,15 @@ class Item_func_plus :public Item_func_additive_op
class Item_func_minus :public Item_func_additive_op class Item_func_minus :public Item_func_additive_op
{ {
Sql_mode_dependency m_sql_mode_dependency; bool m_depends_on_sql_mode_no_unsigned_subtraction;
public: public:
Item_func_minus(THD *thd, Item *a, Item *b): Item_func_minus(THD *thd, Item *a, Item *b):
Item_func_additive_op(thd, a, b) {} Item_func_additive_op(thd, a, b),
m_depends_on_sql_mode_no_unsigned_subtraction(false)
{ }
const char *func_name() const { return "-"; } const char *func_name() const { return "-"; }
enum precedence precedence() const { return ADD_PRECEDENCE; } enum precedence precedence() const { return ADD_PRECEDENCE; }
Sql_mode_dependency value_depends_on_sql_mode() const Sql_mode_dependency value_depends_on_sql_mode() const;
{
return m_sql_mode_dependency;
}
longlong int_op(); longlong int_op();
double real_op(); double real_op();
my_decimal *decimal_op(my_decimal *); my_decimal *decimal_op(my_decimal *);
......
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