summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRucha Deodhar <rucha.deodhar@mariadb.com>2020-08-04 13:21:54 +0530
committerRucha Deodhar <rucha.deodhar@mariadb.com>2020-08-04 14:45:23 +0530
commit28b3e0b2c5feec80f81403ff90b58f15a5d49e48 (patch)
tree8760924b2cc2bd8bc2583a0f0dfb7b12f82e4765
parente6cb263ef3ecc59510b62f7c7dd5dfcd78a613c7 (diff)
downloadmariadb-git-bb-10.1-MDEV-23209.tar.gz
MDEV-23209: Assertion `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())'bb-10.1-MDEV-23209
failed in Diagnostics_area::set_ok_status on INSERT Analysis: Error is not returned when strict mode is enabled and value is truncated because double is outside range. Fix: Return HA_ERR_AUTOINC_ERANGE if the error was reported when double is outside range.
-rw-r--r--mysql-test/r/sql_mode.result13
-rw-r--r--mysql-test/t/sql_mode.test17
-rw-r--r--sql/handler.cc7
3 files changed, 37 insertions, 0 deletions
diff --git a/mysql-test/r/sql_mode.result b/mysql-test/r/sql_mode.result
index d71748bd9b1..3aeb59d0eac 100644
--- a/mysql-test/r/sql_mode.result
+++ b/mysql-test/r/sql_mode.result
@@ -737,3 +737,16 @@ DROP FUNCTION test_function;
SET @@sql_mode= @org_mode;
#End of Test for Bug#12601974
+#
+# 10.1 TEST
+#
+# MDEV-23209: Assertion `!is_set() || (m_status == DA_OK_BULK &&
+# is_bulk_op())' failed in Diagnostics_area::set_ok_status on INSERT
+#
+set @old_mode= @@sql_mode;
+SET SQL_MODE='STRICT_TRANS_TABLES';
+CREATE TABLE t (a DOUBLE PRIMARY KEY AUTO_INCREMENT);
+INSERT INTO t VALUES (18446744073709551601);
+ERROR 22007: Truncated incorrect INTEGER value: '1.8446744073709552e19'
+SET @@sql_mode=@old_mode;
+DROP TABLE t;
diff --git a/mysql-test/t/sql_mode.test b/mysql-test/t/sql_mode.test
index 869bf45dbf3..44a5f0a74d5 100644
--- a/mysql-test/t/sql_mode.test
+++ b/mysql-test/t/sql_mode.test
@@ -513,3 +513,20 @@ SET @@sql_mode= @org_mode;
--echo
--echo #End of Test for Bug#12601974
+
+--echo #
+--echo # 10.1 TEST
+--echo #
+--echo # MDEV-23209: Assertion `!is_set() || (m_status == DA_OK_BULK &&
+--echo # is_bulk_op())' failed in Diagnostics_area::set_ok_status on INSERT
+--echo #
+set @old_mode= @@sql_mode;
+
+SET SQL_MODE='STRICT_TRANS_TABLES';
+CREATE TABLE t (a DOUBLE PRIMARY KEY AUTO_INCREMENT);
+
+--error ER_TRUNCATED_WRONG_VALUE
+INSERT INTO t VALUES (18446744073709551601);
+
+SET @@sql_mode=@old_mode;
+DROP TABLE t;
diff --git a/sql/handler.cc b/sql/handler.cc
index 76a187f4312..e5f65626d40 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -3065,6 +3065,13 @@ int handler::update_auto_increment()
(table->auto_increment_field_not_null &&
thd->variables.sql_mode & MODE_NO_AUTO_VALUE_ON_ZERO))
{
+
+ /*
+ There could be an error reported because value was truncated
+ when strict mode is enabled.
+ */
+ if (thd->is_error())
+ DBUG_RETURN(HA_ERR_AUTOINC_ERANGE);
/*
Update next_insert_id if we had already generated a value in this
statement (case of INSERT VALUES(null),(3763),(null):