JSON_ARRAY_APPEND
|
------------------
|
10.6.18-dbg>set character_set_connection=ucs2;
|
Query OK, 0 rows affected (0.000 sec)
|
|
10.6.18-dbg>SET @json = '[1, 2, [3, 4]]';
|
Query OK, 0 rows affected (0.000 sec)
|
|
10.6.18-dbg>SELECT JSON_ARRAY_APPEND(@json, '$[0]', 5);
|
+-------------------------------------+
|
| JSON_ARRAY_APPEND(@json, '$[0]', 5) |
|
+-------------------------------------+
|
| NULL |
|
+-------------------------------------+
|
1 row in set, 1 warning (0.000 sec)
|
|
10.6.18-dbg>
|
|
JSON_ARRAY_INTERSECT
|
--------------------
|
11.5.0-opt>SET @json1= '[1,2,3]';
|
Query OK, 0 rows affected (0.000 sec)
|
|
11.5.0-opt>SET @json2= '[1,2,4]';
|
Query OK, 0 rows affected (0.000 sec)
|
|
11.5.0-opt>
|
11.5.0-opt>SELECT JSON_ARRAY_INTERSECT(@json1, @json2);
|
+--------------------------------------+
|
| json_array_intersect(@json1, @json2) |
|
+--------------------------------------+
|
| NULL |
|
+--------------------------------------+
|
1 row in set (0.001 sec)
|
|
JSON_INSERT
|
-----------
|
11.5.0-opt>SET @json = '{ "A": 0, "B": [1, 2]}';
|
Query OK, 0 rows affected (0.000 sec)
|
|
11.5.0-opt>
|
11.5.0-opt>SELECT JSON_INSERT(@json, '$.C', '[3, 4]');
|
+-------------------------------------+
|
| JSON_INSERT(@json, '$.C', '[3, 4]') |
|
+-------------------------------------+
|
| NULL |
|
+-------------------------------------+
|
1 row in set, 1 warning (0.000 sec)
|
|
11.5.0-opt>
|
|
JSON_MERGE
|
----------
|
11.5.0-opt>SET @json1 = '[1, 2]';
|
Query OK, 0 rows affected (0.000 sec)
|
|
11.5.0-opt>SET @json2 = '[3, 4]';
|
Query OK, 0 rows affected (0.000 sec)
|
|
11.5.0-opt>
|
11.5.0-opt>SELECT JSON_MERGE(@json1,@json2);
|
+---------------------------+
|
| JSON_MERGE(@json1,@json2) |
|
+---------------------------+
|
| NULL |
|
+---------------------------+
|
1 row in set, 1 warning (0.000 sec)
|
|
11.5.0-opt>
|
|
JSON_MERGE_PRESERVE
|
-------------------
|
11.5.0-opt>SET @json1 = '[1, 2]';
|
Query OK, 0 rows affected (0.000 sec)
|
|
11.5.0-opt>SET @json2 = '[2, 3]';
|
Query OK, 0 rows affected (0.000 sec)
|
|
11.5.0-opt>SELECT JSON_MERGE_PRESERVE(@json1,@json2);
|
+------------------------------------+
|
| JSON_MERGE_PRESERVE(@json1,@json2) |
|
+------------------------------------+
|
| NULL |
|
+------------------------------------+
|
1 row in set, 1 warning (0.000 sec)
|
|
11.5.0-opt>
|
|
JSON_OBJECT_FILTER_KEYS
|
-----------------------
|
11.5.0-opt>SET @obj1= '{ "a": 1, "b": 2, "c": 3}';
|
Query OK, 0 rows affected (0.000 sec)
|
|
11.5.0-opt>SET @obj2= '{"b" : 10, "c": 20, "d": 30}';
|
Query OK, 0 rows affected (0.000 sec)
|
|
11.5.0-opt>SELECT JSON_OBJECT_FILTER_KEYS (@obj1, JSON_ARRAY_INTERSECT(JSON_KEYS(@obj1), JSON_KEYS(@obj2)));
|
+-------------------------------------------------------------------------------------------+
|
| JSON_OBJECT_FILTER_KEYS (@obj1, JSON_ARRAY_INTERSECT(JSON_KEYS(@obj1), JSON_KEYS(@obj2))) |
|
+-------------------------------------------------------------------------------------------+
|
| NULL |
|
+-------------------------------------------------------------------------------------------+
|
1 row in set, 1 warning (0.000 sec)
|
|
11.5.0-opt>
|
|
JSON_OBJECT_TO_ARRAY
|
--------------------
|
11.5.0-opt>SET @obj1= '{ "a": [1, 2, 3], "b": { "key1":"val1", "key2": {"key3":"val3"} }}';
|
Query OK, 0 rows affected (0.000 sec)
|
|
11.5.0-opt>
|
11.5.0-opt>SELECT JSON_OBJECT_TO_ARRAY(@obj1);
|
+-----------------------------+
|
| JSON_OBJECT_TO_ARRAY(@obj1) |
|
+-----------------------------+
|
| NULL |
|
+-----------------------------+
|
1 row in set, 1 warning (0.000 sec)
|
|
11.5.0-opt>
|
|
JSON_OVERLAPS
|
--------------
|
11.5.0-opt>set character_set_connection=default;
|
Query OK, 0 rows affected (0.000 sec)
|
|
11.5.0-opt>SELECT JSON_OVERLAPS('{"A": 1, "B": {"C":2}}', '{"A": 2, "B": {"C":2}}') AS is_overlap;
|
+------------+
|
| is_overlap |
|
+------------+
|
| 1 |
|
+------------+
|
1 row in set (0.000 sec)
|
|
11.5.0-opt>set character_set_connection=ucs2;
|
Query OK, 0 rows affected (0.000 sec)
|
|
11.5.0-opt>SELECT JSON_OVERLAPS('{"A": 1, "B": {"C":2}}', '{"A": 2, "B": {"C":2}}') AS is_overlap;
|
+------------+
|
| is_overlap |
|
+------------+
|
| 0 |
|
+------------+
|
1 row in set (0.000 sec)
|
|
11.5.0-opt>
|
|
JSON_SCHEMA_VALID
|
-----------------
|
|
11.5.0-opt>SET @schema= '{
|
'> "properties" : {
|
'> "number1":{ "maximum":10 },
|
'> "string1" : { "maxLength": 3}
|
'> }
|
'> }';
|
Query OK, 0 rows affected (0.000 sec)
|
|
11.5.0-opt>
|
11.5.0-opt>SELECT JSON_SCHEMA_VALID(@schema, '{ "number1":25, "string1":"ab" }');
|
+----------------------------------------------------------------+
|
| JSON_SCHEMA_VALID(@schema, '{ "number1":25, "string1":"ab" }') |
|
+----------------------------------------------------------------+
|
| 1 |
|
+----------------------------------------------------------------+
|
1 row in set (0.000 sec)
|
|
11.5.0-opt>set character_set_connection=default;
|
Query OK, 0 rows affected (0.000 sec)
|
|
11.5.0-opt>SET @schema= '{
|
'> "properties" : {
|
'> "number1":{ "maximum":10 },
|
'> "string1" : { "maxLength": 3}
|
'> }
|
'> }';
|
Query OK, 0 rows affected (0.000 sec)
|
|
11.5.0-opt>
|
11.5.0-opt>SELECT JSON_SCHEMA_VALID(@schema, '{ "number1":25, "string1":"ab" }');
|
+----------------------------------------------------------------+
|
| JSON_SCHEMA_VALID(@schema, '{ "number1":25, "string1":"ab" }') |
|
+----------------------------------------------------------------+
|
| 0 |
|
+----------------------------------------------------------------+
|
1 row in set (0.000 sec)
|
|
11.5.0-opt>
|
|
JSON_SET
|
--------
|
|
11.5.0-opt>SELECT JSON_SET(Priv, '$.locked', 'true') FROM mysql.global_priv;
|
+------------------------------------+
|
| JSON_SET(Priv, '$.locked', 'true') |
|
+------------------------------------+
|
| NULL |
|
| NULL |
|
| NULL |
|
| NULL |
|
| NULL |
|
| NULL |
|
| NULL |
|
| NULL |
|
+------------------------------------+
|
8 rows in set, 8 warnings (0.040 sec)
|
|
11.5.0-opt>
|
rucha174 Following JSON functions also print NULL/incorrect value when character_sets is set with mbminlen > 1
JSON_ARRAY_APPEND
JSON_ARRAY_INTERSECT
JSON_INSERT
JSON_MERGE
JSON_MERGE_PRESERVE
JSON_OBJECT_FILTER_KEYS
JSON_OBJECT_TO_ARRAY
JSON_OVERLAPS
JSON_SCHEMA_VALID
JSON_SET
JSON_ARRAY_APPEND
------------------
10.6.18-dbg>
JSON_ARRAY_INTERSECT
--------------------
11.5.0-opt>
| json_array_intersect(@json1, @json2) |
JSON_INSERT
-----------
11.5.0-opt>
11.5.0-opt>
JSON_MERGE
----------
11.5.0-opt>
| JSON_MERGE(@json1,@json2) |
11.5.0-opt>
JSON_MERGE_PRESERVE
-------------------
| JSON_MERGE_PRESERVE(@json1,@json2) |
11.5.0-opt>
JSON_OBJECT_FILTER_KEYS
-----------------------
| JSON_OBJECT_FILTER_KEYS (@obj1, JSON_ARRAY_INTERSECT(JSON_KEYS(@obj1), JSON_KEYS(@obj2))) |
11.5.0-opt>
JSON_OBJECT_TO_ARRAY
--------------------
11.5.0-opt>
| JSON_OBJECT_TO_ARRAY(@obj1) |
11.5.0-opt>
JSON_OVERLAPS
--------------
| is_overlap |
| 1 |
| is_overlap |
| 0 |
11.5.0-opt>
JSON_SCHEMA_VALID
-----------------
Query OK, 0 rows affected (0.000 sec)
11.5.0-opt>
+----------------------------------------------------------------+
+----------------------------------------------------------------+
| 1 |
+----------------------------------------------------------------+
1 row in set (0.000 sec)
11.5.0-opt>set character_set_connection=default;
Query OK, 0 rows affected (0.000 sec)
11.5.0-opt>
| 0 |
11.5.0-opt>
JSON_SET
--------
11.5.0-opt>