summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRucha Deodhar <rucha.deodhar@mariadb.com>2021-09-26 11:14:49 +0530
committerRucha Deodhar <rucha.deodhar@mariadb.com>2021-09-26 19:47:02 +0530
commit159700376b6d98597361e75c819b7dc642a7fddd (patch)
treee32d3f7b396ba8a7ae81ecff92485c84acf5c1b3
parentbe09524b00248393bba5f0b0a9385c17edf76365 (diff)
downloadmariadb-git-bb-10.7-MDEV-26684.tar.gz
MDEV-26684: Unexpected ERROR_INDEX in a condition raised by a diagnosticsbb-10.7-MDEV-26684
statement Not repeatable after MDEV-26606. Test case added.
-rw-r--r--mysql-test/main/get_diagnostics.result30
-rw-r--r--mysql-test/main/get_diagnostics.test24
-rw-r--r--sql/sql_error.cc2
-rw-r--r--sql/sql_error.h4
4 files changed, 57 insertions, 3 deletions
diff --git a/mysql-test/main/get_diagnostics.result b/mysql-test/main/get_diagnostics.result
index 7a07bb06516..f66acbcf1a4 100644
--- a/mysql-test/main/get_diagnostics.result
+++ b/mysql-test/main/get_diagnostics.result
@@ -1595,3 +1595,33 @@ SELECT @num, @msg;
2 Duplicate entry '1' for key 'PRIMARY'
DROP PROCEDURE sp;
DROP TABLE t1;
+#
+# MDEV-26684: Unexpected ERROR_INDEX in a condition raised by a diagnostics statement
+#
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1),(2);
+GET DIAGNOSTICS CONDITION 5 @msg = MESSAGE_TEXT;
+Warnings:
+Error 1758 Invalid condition number
+SHOW WARNINGS;
+Level Code Message
+Error 1758 Invalid condition number
+GET DIAGNOSTICS CONDITION 1 @ind = ERROR_INDEX, @msg = MESSAGE_TEXT;
+SELECT @ind, @msg;
+@ind @msg
+0 Invalid condition number
+INSERT INTO t1 VALUES (3),(4);
+GET DIAGNOSTICS CONDITION 1 @ind = ERROR_INDEX, @msg = MESSAGE_TEXT;
+Warnings:
+Error 1758 Invalid condition number
+SELECT @ind, @msg;
+@ind @msg
+0 Invalid condition number
+GET DIAGNOSTICS CONDITION 5 @ind = ERROR_INDEX, @msg = MESSAGE_TEXT;
+Warnings:
+Error 1758 Invalid condition number
+Error 1758 Invalid condition number
+SELECT @ind, @msg;
+@ind @msg
+0 Invalid condition number
+DROP TABLE t1;
diff --git a/mysql-test/main/get_diagnostics.test b/mysql-test/main/get_diagnostics.test
index eb8d2a23a45..54ea377aead 100644
--- a/mysql-test/main/get_diagnostics.test
+++ b/mysql-test/main/get_diagnostics.test
@@ -1481,3 +1481,27 @@ SELECT @num, @msg;
DROP PROCEDURE sp;
DROP TABLE t1;
+
+--echo #
+--echo # MDEV-26684: Unexpected ERROR_INDEX in a condition raised by a diagnostics statement
+--echo #
+
+CREATE TABLE t1 (a INT);
+
+INSERT INTO t1 VALUES (1),(2);
+
+GET DIAGNOSTICS CONDITION 5 @msg = MESSAGE_TEXT;
+SHOW WARNINGS;
+
+GET DIAGNOSTICS CONDITION 1 @ind = ERROR_INDEX, @msg = MESSAGE_TEXT;
+SELECT @ind, @msg;
+
+INSERT INTO t1 VALUES (3),(4);
+
+GET DIAGNOSTICS CONDITION 1 @ind = ERROR_INDEX, @msg = MESSAGE_TEXT;
+SELECT @ind, @msg;
+
+GET DIAGNOSTICS CONDITION 5 @ind = ERROR_INDEX, @msg = MESSAGE_TEXT;
+SELECT @ind, @msg;
+
+DROP TABLE t1;
diff --git a/sql/sql_error.cc b/sql/sql_error.cc
index 2c27fd13532..ca9da3dbf89 100644
--- a/sql/sql_error.cc
+++ b/sql/sql_error.cc
@@ -664,7 +664,7 @@ void Warning_info::reserve_space(THD *thd, uint count)
Sql_condition *Warning_info::push_warning(THD *thd,
const Sql_condition_identity *value,
const char *msg,
- ulonglong current_error_index)
+ ulong current_error_index)
{
Sql_condition *cond= NULL;
diff --git a/sql/sql_error.h b/sql/sql_error.h
index 0b7319a1e82..a3e00e8419d 100644
--- a/sql/sql_error.h
+++ b/sql/sql_error.h
@@ -748,7 +748,7 @@ private:
Sql_condition *push_warning(THD *thd,
const Sql_condition_identity *identity,
const char* msg,
- ulonglong current_error_index);
+ ulong current_error_index);
/**
Add a new SQL-condition to the current list and increment the respective
@@ -1180,7 +1180,7 @@ public:
Sql_condition::enum_warning_level level,
const Sql_user_condition_identity &ucid,
const char* msg,
- ulonglong current_error_index)
+ ulong current_error_index)
{
Sql_condition_identity tmp(sql_errno_arg, sqlstate, level, ucid);
return get_warning_info()->push_warning(thd, &tmp, msg,