summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/main/get_diagnostics.result30
-rw-r--r--mysql-test/main/get_diagnostics.test24
2 files changed, 54 insertions, 0 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;