[MDEV-11437] JSON_QUOTE function does not quote and uses wrong character set Created: 2016-12-01  Updated: 2016-12-04  Resolved: 2016-12-04

Status: Closed
Project: MariaDB Server
Component/s: JSON
Affects Version/s: 10.2
Fix Version/s: 10.2.3

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

Issue Links:
Relates
relates to MDEV-9143 JSON_xxx functions Closed

 Description   

Function JSON_QUOTE is specified in MySQL manual as

Quotes a string as a JSON value by wrapping it with double quote characters and escaping interior quote and other characters, then returning the result as a utf8mb4 string.

It works in MySQL according to this specification:

+-------------------+
| JSON_QUOTE('foo') |
+-------------------+
| "foo"             |
+-------------------+
1 row in set (0.00 sec)
 
MySQL [test]> CREATE TABLE t AS SELECT JSON_QUOTE('foo');
Query OK, 1 row affected (0.48 sec)
Records: 1  Duplicates: 0  Warnings: 0
 
MySQL [test]> SHOW CREATE TABLE t \G
*************************** 1. row ***************************
       Table: t
Create Table: CREATE TABLE `t` (
  `JSON_QUOTE('foo')` varchar(56) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
1 row in set (0.00 sec)

However, in MariaDB it neither wraps the value in double quote marks, nor does it return result in utf8mb4

+-------------------+
| JSON_QUOTE('foo') |
+-------------------+
| foo               |
+-------------------+
1 row in set (0.00 sec)
 
MariaDB [test]> CREATE TABLE t SELECT JSON_QUOTE('foo');
Query OK, 1 row affected (0.49 sec)
Records: 1  Duplicates: 0  Warnings: 0
 
MariaDB [test]> SHOW CREATE TABLE t \G
*************************** 1. row ***************************
       Table: t
Create Table: CREATE TABLE `t` (
  `JSON_QUOTE('foo')` varchar(36) CHARACTER SET utf8 NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
1 row in set (0.00 sec)



 Comments   
Comment by Alexey Botchkov [ 2016-12-04 ]

http://lists.askmonty.org/pipermail/commits/2016-December/010184.html

Generated at Thu Feb 08 07:49:57 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.