Bug #112053 | COALESCE a null value with a JSON object returns hex string | ||
---|---|---|---|
Submitted: | 12 Aug 2023 19:55 | Modified: | 16 Aug 2023 12:04 |
Reporter: | Douglas Sims | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: JSON | Severity: | S3 (Non-critical) |
Version: | 8.0 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[12 Aug 2023 19:55]
Douglas Sims
[14 Aug 2023 12:55]
MySQL Verification Team
Hi Mr. Sims, Thank you for your bug report. However, we can not repeat it with properly defined JSON values: set @choices= cast(' { "name": "Jackma" }' as json); Query OK, 0 rows affected (0.00 sec) mysql> select coalesce (NULL, @choices); +---------------------------+ | coalesce (NULL, @choices) | +---------------------------+ | {"name": "Jackma"} | +---------------------------+ Hence, this is not a bug. Can't repeat.
[14 Aug 2023 13:13]
MySQL Verification Team
Hi, One more additional information. According to the standard, '{}' can not be considered, since it's an object without any attributes. Not a bug.
[16 Aug 2023 12:04]
MySQL Verification Team
Hi Mr. Sims, It turns out that this is, actually, a low priority bug. I think the problem is related to incorrect assignment of collation for user variables that are assigned a NULL value. We can workaround the problem by giving the NULL user variable a proper collation: select coalesce(CAST(@choicesnull AS CHAR), @choices); This report is now a verified bug.
[21 Aug 2023 3:25]
huahua xu
Hi Douglas Sims, It could help you avoid your problem: mysql> set @choicesnull = cast(null as json); mysql> set @choices := cast( '{}' as json); mysql> select coalesce(@choicesnull, @choices); +----------------------------------+ | coalesce(@choicesnull, @choices) | +----------------------------------+ | {} | +----------------------------------+
[21 Aug 2023 12:36]
MySQL Verification Team
Thank you for the workaround .....