[MDEV-26702] Unexpected ROW_NUMBER upon SELECT from JSON_TABLE with erroneous JSON doc Created: 2021-09-27  Updated: 2023-11-28

Status: Open
Project: MariaDB Server
Component/s: JSON, Server
Affects Version/s: 10.7
Fix Version/s: 10.11

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Rucha Deodhar
Resolution: Unresolved Votes: 0
Labels: None

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

 Description   

MariaDB [test]> SELECT * FROM JSON_TABLE('11x1', '$' COLUMNS(o FOR ORDINALITY)) AS jt;
ERROR 4038 (HY000): Syntax error in JSON text in argument 1 to function 'JSON_TABLE' at position 3
 
Query OK, 0 rows affected (0.000 sec)
 
Query OK, 0 rows affected (0.000 sec)
 
+------+
| @n   |
+------+
|    2 |
+------+
1 row in set (0.000 sec)

I don't know what to make out of it, clearly there is no 2nd row, but maybe it can be rationalized in some way based on internal JSON_TABLE implementation.
Also oddly, it doesn't apply to JSON docs which start erroneously, i.e.

MariaDB [test]> SELECT * FROM JSON_TABLE('x11', '$' COLUMNS(o FOR ORDINALITY)) AS jt;
ERROR 4038 (HY000): Syntax error in JSON text in argument 1 to function 'JSON_TABLE' at position 1
 
MariaDB [test]> set @n= null; get diagnostics condition 1 @n = error_index; select @n;
Query OK, 0 rows affected (0.000 sec)
 
Query OK, 0 rows affected (0.000 sec)
 
+------+
| @n   |
+------+
|    1 |
+------+
1 row in set (0.000 sec)

So, it looks like the counter is increased if the first symbol in the doc leaves hope that it is a valid document.

Maybe it's not ERROR_INDEX issue but the general counter's, but I haven't yet invented an example to verify it, so I'm keeping it a 10.7 / ERROR_INDEX issue for now.



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

Hi elenst , ERROR_INDEX is only for INSERT

Comment by Elena Stepanova [ 2021-09-27 ]

If it's not supported and not calculated for a statement, it should return a value indicating this. If it returns a value which makes sense in the context, and especially a value which changes depending on the context, then it will be reasonably considered as maintained.

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