[MDEV-23781] Wrong value returned by JsonValue() function, Connect engine Created: 2020-09-21  Updated: 2023-04-27

Status: Open
Project: MariaDB Server
Component/s: OTHER
Affects Version/s: 10.0, 10.1, 10.2, 10.3, 10.4, 10.5
Fix Version/s: 10.4, 10.5

Type: Bug Priority: Minor
Reporter: Alice Sherepa Assignee: Sergei Golubchik
Resolution: Unresolved Votes: 0
Labels: None


 Description   

MariaDB [test]> SELECT JsonValue();
+-------------+
| JsonValue() |
+-------------+
| null        |
+-------------+
1 row in set (0.000 sec)
 
MariaDB [test]> SELECT JsonValue() union select NULL;
+-------------+
| JsonValue() |
+-------------+
| nu          |
| NULL        |
+-------------+
2 rows in set (0.001 sec)
 
MariaDB [test]> create view v1 as select JsonValue();
Query OK, 0 rows affected (0.007 sec)
 
MariaDB [test]> select * from v1;
+-------------+
| JsonValue() |
+-------------+
| nu          |
+-------------+
1 row in set (0.001 sec)
 



 Comments   
Comment by Olivier Bertrand [ 2020-09-22 ]

Hmmm... strange. Looking in debug mode, the function is returning the good value but it is sort of truncated by MariaDB out of Connect. For instance:

SELECT JsonValue() union select 'ab';
+-------------+
| JsonValue() |
+-------------+
| nu          |
| ab          |
+-------------+
SELECT JsonValue() union select 'abc';
+-------------+
| JsonValue() |
+-------------+
| nul         |
| abc         |
+-------------+
SELECT JsonValue() union select 'abcd';
+-------------+
| JsonValue() |
+-------------+
| null        |
| abcd        |
+-------------+

See? The union process (and also the view?) seem to change the length of an UDF function result. BTW this also happens with some other functions. For instance:

select Json_Make_object(NULL) JIRA union select 'abc';
+--------------+
| JIRA         |
+--------------+
| {"NULL":null |
| abc          |
+--------------+

Stripping the last '}' character.

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