[MDEV-27018] IF and COALESCE lose "json" property Created: 2021-11-10 Updated: 2022-06-07 Resolved: 2022-01-21 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | JSON |
| Affects Version/s: | 10.2, 10.3, 10.4, 10.5, 10.6 |
| Fix Version/s: | 10.5.14, 10.6.6, 10.7.2, 10.8.1 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Sergei Golubchik | Assignee: | Alexander Barkov |
| Resolution: | Fixed | Votes: | 2 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| Description |
|
other functions (CASE, NULLIF, IFNULL) are likely affected too. |
| Comments |
| Comment by Alexander Keremidarski [ 2021-11-10 ] | ||||||||||||||||||
|
It seems all string functions are affected including no-op functions like CONCAT(x) and LOWER(x)
| ||||||||||||||||||
| Comment by Sergei Golubchik [ 2021-11-10 ] | ||||||||||||||||||
|
On the contrary, these two are not bugs, as explained in this comment. CONCAT(x) and LOWER(x) are not "no-op functions". Try
and you will see that CONCAT and LOWER change the argument, they convert it to a string. So, when you use CONCAT(json), this JSON value becomes a plain string, not a structured data type. It loses its "json-ness". And a plain string is correctly escaped when used as a JSON value. | ||||||||||||||||||
| Comment by Alexander Barkov [ 2021-12-06 ] | ||||||||||||||||||
|
julien.fritsch, yes this is a bug. I've marked it as Confirmed. | ||||||||||||||||||
| Comment by Alexander Barkov [ 2021-12-22 ] | ||||||||||||||||||
More bad behavior examplesSingle row subselect
Looks good so far. Now I pass the same statement as a subselect to abother json_object:
The value was erroneously escaped. If I run similar queries in Oracle, the value does not get escaped:
UNIONIt's now reported as a separate issue MDEV-27370 | ||||||||||||||||||
| Comment by Alexander Barkov [ 2021-12-27 ] | ||||||||||||||||||
|
serg, please review a patch: https://github.com/MariaDB/server/commit/734aee3cd3c59bb9a9050f32db406803f8237320 or can be found in this branch: https://github.com/mariadb/server/tree/bb-10.5-bar-MDEV-27018 Thanks. | ||||||||||||||||||
| Comment by Alexander Barkov [ 2021-12-30 ] | ||||||||||||||||||
|
serg, I replied to your review comments by email. Please have a look. | ||||||||||||||||||
| Comment by Sergei Golubchik [ 2022-01-20 ] | ||||||||||||||||||
|
0478f474020466 is ok to push |