[MDEV-31159] Wrong encoding produced by JSON_ARRAYAGG Created: 2023-05-01  Updated: 2023-11-28

Status: Open
Project: MariaDB Server
Component/s: JSON
Affects Version/s: 10.11.2, 10.5, 10.6, 10.8, 10.9, 10.10, 10.11
Fix Version/s: 10.5, 10.6, 10.11

Type: Bug Priority: Major
Reporter: Lukas Eder Assignee: Alexey Botchkov
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Try this query:

select 
  json_arrayagg(json_array(ö)),
  json_arrayagg(json_object(ö, ö)), 
  json_arrayagg(ö)
from (select 'ö' ö) ö;

It produces

|json_arrayagg(json_array(ö))|json_arrayagg(json_object(ö, ö))|json_arrayagg(ö)|
|----------------------------|--------------------------------|----------------|
|[["ö"]]                     |[{"ö": "ö"}]                    |["�"]           |

So, when JSON is nested in JSON, then there's no encoding problem, but a string embedded directly into JSON_ARRAYAGG produces issues.



 Comments   
Comment by Lukas Eder [ 2023-05-01 ]

For the record:

SHOW VARIABLES LIKE '%collation%';

Produces:

|VARIABLE_NAME       |VARIABLE_VALUE    |
|--------------------|------------------|
|collation_connection|utf8mb4_general_ci|
|collation_database  |utf8mb3_bin       |
|collation_server    |utf8mb4_general_ci|

And

SHOW VARIABLES LIKE '%char%';

Produces

|VARIABLE_NAME           |VARIABLE_VALUE            |
|------------------------|--------------------------|
|character_set_client    |utf8mb4                   |
|character_set_connection|utf8mb4                   |
|character_set_database  |utf8mb3                   |
|character_set_filesystem|binary                    |
|character_set_results   |utf8mb4                   |
|character_set_server    |utf8mb4                   |
|character_set_system    |utf8mb3                   |
|character_sets_dir      |/usr/share/mysql/charsets/|

Generated at Thu Feb 08 10:21:44 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.