[MDEV-26610] ERROR_INDEX isn't seen in the error message Created: 2021-09-15  Updated: 2021-09-29  Resolved: 2021-09-29

Status: Closed
Project: MariaDB Server
Component/s: Server
Affects Version/s: None
Fix Version/s: N/A

Type: Bug Priority: Critical
Reporter: Sergei Golubchik Assignee: Rucha Deodhar
Resolution: Won't Fix Votes: 0
Labels: None

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

 Description   

can be discussed

Is there a reason this row number cannot be a part of the error message itself (in addition to diagnostics property)?
It wouldn't be anything new, we already have it for some errors, e.g.

MariaDB [test]> insert into t1 values (1,'foo'),(2,'foobar');
ERROR 1406 (22001): Data too long for column 'c' at row 2

While diagnostics property is useful to detect the number of the flawed row programmatically, in interactive execution having it in the error text is clearly more user-friendly, especially when many values are involved:

MariaDB [test]> insert ignore into t1 values (1,'foo'),(2,'foobar'),(2,'bar'),(3,'a'),(4,'qux'),(4,'quux'),(5,'baz');
Query OK, 5 rows affected, 4 warnings (0.014 sec)
Records: 7  Duplicates: 2  Warnings: 4
 
MariaDB [test]> show warnings;
+---------+------+----------------------------------------+
| Level   | Code | Message                                |
+---------+------+----------------------------------------+
| Warning | 1265 | Data truncated for column 'c' at row 2 |
| Warning | 1062 | Duplicate entry '2' for key 'PRIMARY'  |
| Warning | 1265 | Data truncated for column 'c' at row 6 |
| Warning | 1062 | Duplicate entry '4' for key 'PRIMARY'  |
+---------+------+----------------------------------------+
4 rows in set (0.000 sec)



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

Discussed on slack with serg that ERROR_INDEX could most probably work for other statements but not sure which error messages can be used safely because there are some error messages that are not unique to statements.

Comment by Elena Stepanova [ 2021-09-19 ]

I'm not sure what "not unique to statements" in this context means, but anyway, indeed there are certainly error messages universal enough so that a row number doesn't make sense in all (or even most) cases. Here is one example, it's rather artificial, which is in itself proves the point.

MariaDB [test]> create table t1 (a int);
Query OK, 0 rows affected (0.026 sec)
 
MariaDB [test]> create trigger tr after insert on t1 for each row select * into outfile 'f1' from t1;
Query OK, 0 rows affected (0.017 sec)
 
MariaDB [test]> insert into t1 values (1),(2);
ERROR 1086 (HY000): File 'f1' already exists
MariaDB [test]> get diagnostics condition 1 @n=error_index; select @n;
Query OK, 0 rows affected (0.001 sec)
 
+------+
| @n   |
+------+
|    2 |
+------+
1 row in set (0.000 sec)

So, while for this specific weird usage a row number does make sense and extending the message to File 'f1' already exists for row 2 would look all right, of course in the majority of cases ER_FILE_EXISTS_ERROR happens on a higher level and row numbers are meaningless there.

I guess choosing which error messages can be extended with row numbers requires some tedious research of how the messages are used. In my opinion it's still worth doing, but probably it's well outside the scope of MDEV-10075, so it's okay with me if you close it or detach it from 10.7 preview activities.

Comment by Rucha Deodhar [ 2021-09-20 ]

elenst , I meant some error messages are used for more than one statements, example "data truncated for col 'a' row i" is used for alter, update and insert and some of them are not universal enough.

Comment by Sergei Golubchik [ 2021-09-20 ]

An example of "not unique to statements" is this error from the test case:

INSERT INTO t1 VALUES (5,'e',1.00105),(6,'f',1.79769313486232e+308);
ERROR 22007: Illegal double '1.79769313486232e+308' value found during parsing

while ERROR_INDEX is 2 here, the error about "invalid double" can happen anywhere, and in many cases the concept of "current row" won't be applicable.

Comment by Elena Stepanova [ 2021-09-20 ]

Right, got it. Same as in my example with ER_FILE_EXISTS_ERROR, then.
I just had read "not unique to statements" in a completely different way (as "used not only for statements, but also for something else"), and it was confusing.

Comment by Elena Stepanova [ 2021-09-29 ]

Changing resolution for clarity, as there have been no changes to fix this (upon all parties' agreement).

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