[MDEV-22298] JSON_TABLE: EXISTS PATH value is converted to other types incorrectly Created: 2020-04-18  Updated: 2020-04-27  Resolved: 2020-04-27

Status: Closed
Project: MariaDB Server
Component/s: Data types, JSON
Affects Version/s: N/A
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Alexey Botchkov
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-22293 JSON_TABLE: Values for regular column... Closed
relates to MDEV-17399 Add support for JSON_TABLE Closed

 Description   

bb-10.5-hf 6dfb3fab2

MariaDB [test]> select * from json_table('{"a":"foo"}', '$' columns (f char(1) exists path '$.a')) as jt;
+------+
| f    |
+------+
|      |
+------+
1 row in set (0.002 sec)

MySQL 8.0.19

MySQL [test]> select * from json_table('{"a":"foo"}', '$' columns (f char(1) exists path '$.a')) as jt;
+------+
| f    |
+------+
| 1    |
+------+
1 row in set (0.001 sec)

I couldn't find specification of EXISTS PATH in the standard, but MySQL documentation explicitly says "type can be any valid MySQL data type" (even if it should be integer). And integer normally casts to char well, so it shouldn't be a problem.

Float is also wrong:

=bb-10.5-hf 6dfb3fab2

MariaDB [test]> select * from json_table('{"a":"foo"}', '$' columns (f float exists path '$.a')) as jt;
+------+
| f    |
+------+
|    0 |
+------+
1 row in set (0.002 sec)

MySQL 8.0.19

MySQL [test]> select * from json_table('{"a":"foo"}', '$' columns (f float exists path '$.a')) as jt;
+------+
| f    |
+------+
|    1 |
+------+
1 row in set (0.001 sec)



 Comments   
Comment by Elena Stepanova [ 2020-04-19 ]

I've just realized that it's most likely the same problem as MDEV-22293, and the values are just truncated incorrectly rather than wrongly converted.

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