Commit bbd2fa5c authored by Alexander Barkov's avatar Alexander Barkov

MDEV-21278 Assertion `is_unsigned() == attr.unsigned_flag' or Assertion `field.is_sane()' failed

The type handler and unsigned_flag erroneously went out of sync in
Item_func_minus::fix_length_and_dec.
parent ce41a907
...@@ -2726,3 +2726,41 @@ DROP TABLE t1,t2; ...@@ -2726,3 +2726,41 @@ DROP TABLE t1,t2;
# #
# End of 10.4 tests # End of 10.4 tests
# #
#
# Start of 10.5 tests
#
#
# MDEV-21278 Assertion `is_unsigned() == attr.unsigned_flag' or Assertion `field.is_sane()' failed
#
CREATE TABLE t1 (a TIMESTAMP);
INSERT INTO t1 VALUES (NULL),(NULL);
SET SESSION SQL_MODE= 'NO_UNSIGNED_SUBTRACTION';
SELECT DISTINCT UUID_SHORT() - a FROM t1;
UUID_SHORT() - a
xxx
xxx
CREATE TABLE t2 AS SELECT DISTINCT UUID_SHORT() - a FROM t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`UUID_SHORT() - a` bigint(22) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2, t1;
SET sql_mode=DEFAULT;
CREATE TABLE t1 (a TIMESTAMP);
INSERT INTO t1 VALUES (NULL),(NULL);
SET SESSION SQL_MODE= 'NO_UNSIGNED_SUBTRACTION';
SELECT UUID_SHORT() - a FROM t1;
UUID_SHORT() - a
xxx
xxx
CREATE TABLE t2 AS SELECT UUID_SHORT() - a FROM t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`UUID_SHORT() - a` bigint(22) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2, t1;
#
# End of 10.5 tests
#
...@@ -1736,3 +1736,36 @@ DROP TABLE t1,t2; ...@@ -1736,3 +1736,36 @@ DROP TABLE t1,t2;
--echo # --echo #
--echo # End of 10.4 tests --echo # End of 10.4 tests
--echo # --echo #
--echo #
--echo # Start of 10.5 tests
--echo #
--echo #
--echo # MDEV-21278 Assertion `is_unsigned() == attr.unsigned_flag' or Assertion `field.is_sane()' failed
--echo #
CREATE TABLE t1 (a TIMESTAMP);
INSERT INTO t1 VALUES (NULL),(NULL);
SET SESSION SQL_MODE= 'NO_UNSIGNED_SUBTRACTION';
--replace_column 1 xxx
SELECT DISTINCT UUID_SHORT() - a FROM t1;
CREATE TABLE t2 AS SELECT DISTINCT UUID_SHORT() - a FROM t1;
SHOW CREATE TABLE t2;
DROP TABLE t2, t1;
SET sql_mode=DEFAULT;
CREATE TABLE t1 (a TIMESTAMP);
INSERT INTO t1 VALUES (NULL),(NULL);
SET SESSION SQL_MODE= 'NO_UNSIGNED_SUBTRACTION';
--replace_column 1 xxx
SELECT UUID_SHORT() - a FROM t1;
CREATE TABLE t2 AS SELECT UUID_SHORT() - a FROM t1;
SHOW CREATE TABLE t2;
DROP TABLE t2, t1;
--echo #
--echo # End of 10.5 tests
--echo #
...@@ -1235,9 +1235,8 @@ bool Item_func_minus::fix_length_and_dec() ...@@ -1235,9 +1235,8 @@ bool Item_func_minus::fix_length_and_dec()
if (Item_func_minus::type_handler()->Item_func_minus_fix_length_and_dec(this)) if (Item_func_minus::type_handler()->Item_func_minus_fix_length_and_dec(this))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
DBUG_PRINT("info", ("Type: %s", type_handler()->name().ptr())); DBUG_PRINT("info", ("Type: %s", type_handler()->name().ptr()));
if ((m_depends_on_sql_mode_no_unsigned_subtraction= unsigned_flag) && m_depends_on_sql_mode_no_unsigned_subtraction= unsigned_flag;
(current_thd->variables.sql_mode & MODE_NO_UNSIGNED_SUBTRACTION)) fix_unsigned_flag();
unsigned_flag= false;
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
} }
......
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