[MDEV-26684] Unexpected ROW_NUMBER in a condition raised by a diagnostics statement Created: 2021-09-25  Updated: 2021-10-06  Resolved: 2021-10-06

Status: Closed
Project: MariaDB Server
Component/s: Server
Affects Version/s: 10.7
Fix Version/s: 10.7.1

Type: Bug Priority: Critical
Reporter: Elena Stepanova Assignee: Rucha Deodhar
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Problem/Incident
is caused by MDEV-10075 Provide index of error causing error ... Closed

 Description   

It appears that when a diagnostics statement raises a condition, it inherits the counter value from the previous statement (regardless whether it had conditions of its own or not) and uses it for ERROR_INDEX.

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;
 
# Cleanup
drop table t1;

10.7 d552e092

MariaDB [test]> get diagnostics condition 5 @msg = message_text;
Query OK, 0 rows affected, 1 warning (0.000 sec)
 
MariaDB [test]> show warnings;
+-------+------+--------------------------+
| Level | Code | Message                  |
+-------+------+--------------------------+
| Error | 1758 | Invalid condition number |
+-------+------+--------------------------+
1 row in set (0.000 sec)
 
MariaDB [test]> get diagnostics condition 1 @ind = error_index, @msg = message_text;
Query OK, 0 rows affected (0.000 sec)
 
MariaDB [test]> select @ind, @msg;
+------+--------------------------+
| @ind | @msg                     |
+------+--------------------------+
|    3 | Invalid condition number |
+------+--------------------------+
1 row in set (0.000 sec)



 Comments   
Comment by Rucha Deodhar [ 2021-09-26 ]

Patch:
https://github.com/MariaDB/server/commit/489678ba197b5f866c06af0faeb9dde324a8de84
https://github.com/MariaDB/server/commit/159700376b6d98597361e75c819b7dc642a7fddd
Not repeatable after MDEV-26606. Test case added.

Comment by Sergei Golubchik [ 2021-09-28 ]

this is ok

Generated at Thu Feb 08 09:47:10 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.