mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
Merge tag '11.1' into 11.2
MariaDB 11.1.3 release
This commit is contained in:
@ -12,19 +12,13 @@ select json_value('{"key1":123}', '$.key1');
|
||||
select json_value('{"key1":[1,2,3]}', '$.key1');
|
||||
select json_value('{"key1": [1,2,3], "key1":123}', '$.key1');
|
||||
|
||||
#enable after fix MDEV-27871
|
||||
--disable_view_protocol
|
||||
select JSON_VALUE('{ "x": [0,1], "y": "[0,1]", "z": "Mon\\\"t\\\"y" }','$.z');
|
||||
--enable_view_protocol
|
||||
select JSON_VALUE('{ "x": [0,1], "y": "[0,1]", "z": "Mon\\\"t\\\"y" }','$.z') as exp;
|
||||
|
||||
select json_query('{"key1":{"a":1, "b":[1,2]}}', '$.key2');
|
||||
select json_query('{"key1":{"a":1, "b":[1,2]}}', '$.key1');
|
||||
select json_query('{"key1": 1}', '$.key1');
|
||||
select json_query('{"key1":123, "key1": [1,2,3]}', '$.key1');
|
||||
#enable after fix MDEV-27871
|
||||
--disable_view_protocol
|
||||
select json_query('{"key1":123, "key1": [1,2,3]}', concat('$', repeat('.k', 1000)));
|
||||
--enable_view_protocol
|
||||
select json_query('{"key1":123, "key1": [1,2,3]}', concat('$', repeat('.k', 1000))) as exp;
|
||||
|
||||
select json_array();
|
||||
select json_array(1);
|
||||
@ -41,15 +35,9 @@ select json_array_insert('["a", {"b": [1, 2]}, [3, 4]]', '$[1]', 'x');
|
||||
select json_array_insert('["a", {"b": [1, 2]}, [3, 4]]', '$[2]', 'x');
|
||||
select json_array_insert('["a", {"b": [1, 2]}, [3, 4]]', '$[3]', 'x');
|
||||
select json_array_insert('["a", {"b": [1, 2]}, [3, 4]]', '$[4]', 'x');
|
||||
#enable after fix MDEV-27871
|
||||
--disable_view_protocol
|
||||
select json_array_insert('["a", {"b": [1, 2]}, [3, 4]]', '$[1].b[0]', 'x');
|
||||
--enable_view_protocol
|
||||
select json_array_insert('["a", {"b": [1, 2]}, [3, 4]]', '$[1].b[0]', 'x') as exp;
|
||||
select json_array_insert('true', '$', 1);
|
||||
#enable after fix MDEV-27871
|
||||
--disable_view_protocol
|
||||
select json_array_insert('["a", {"b": [1, 2]}, [3, 4]]', '$[2][1]', 'y');
|
||||
--enable_view_protocol
|
||||
select json_array_insert('["a", {"b": [1, 2]}, [3, 4]]', '$[2][1]', 'y') as exp;
|
||||
|
||||
select json_contains('{"k1":123, "k2":345}', '123', '$.k1');
|
||||
select json_contains('"you"', '"you"');
|
||||
@ -74,45 +62,45 @@ select json_contains('{"a":1}', '{}');
|
||||
select json_contains('[1, {"a":1}]', '{}');
|
||||
select json_contains('[1, {"a":1}]', '{"a":1}');
|
||||
select json_contains('[{"abc":"def", "def":"abc"}]', '["foo","bar"]');
|
||||
#enable after fix MDEV-27871
|
||||
--disable_view_protocol
|
||||
select json_contains('[{"abc":"def", "def":"abc"}, "bar"]', '["bar", {}]');
|
||||
--disable_view_protocol
|
||||
select json_contains('[{"abc":"def", "def":"abc"}, "bar"]', '["bar", {}]') as exp;
|
||||
select json_contains('[{"a":"b"},{"c":"d"}]','{"c":"d"}');
|
||||
|
||||
select json_contains_path('{"key1":1, "key2":[2,3]}', "oNE", "$.key2[1]");
|
||||
select json_contains_path('{"key1":1, "key2":[2,3]}', "oNE", "$.key2[10]");
|
||||
select json_contains_path('{"key1":1, "key2":[2,3]}', "oNE", "$.ma");
|
||||
select json_contains_path('{"key1":1, "key2":[2,3]}', "one", "$.key1");
|
||||
select json_contains_path('{"key1":1, "key2":[2,3]}', "one", "$.key1", "$.ma");
|
||||
select json_contains_path('{"key1":1, "key2":[2,3]}', "aLl", "$.key1", "$.ma");
|
||||
select json_contains_path('{"key1":1, "key2":[2,3]}', "aLl", "$.key1", "$.key2");
|
||||
select json_contains_path('{ "a": true }', NULL, '$.a' );
|
||||
select json_contains_path('{ "a": true }', 'all', NULL );
|
||||
select json_contains_path('{"a":{"b":"c"}}', 'one', '$.a.*');
|
||||
select json_contains_path('{"key1":1, "key2":[2,3]}', "oNE", "$.key2[1]") as exp;
|
||||
select json_contains_path('{"key1":1, "key2":[2,3]}', "oNE", "$.key2[10]") as exp;
|
||||
select json_contains_path('{"key1":1, "key2":[2,3]}', "oNE", "$.ma") as exp;
|
||||
select json_contains_path('{"key1":1, "key2":[2,3]}', "one", "$.key1") as exp;
|
||||
select json_contains_path('{"key1":1, "key2":[2,3]}', "one", "$.key1", "$.ma") as exp;
|
||||
select json_contains_path('{"key1":1, "key2":[2,3]}', "aLl", "$.key1", "$.ma") as exp;
|
||||
select json_contains_path('{"key1":1, "key2":[2,3]}', "aLl", "$.key1", "$.key2") as exp;
|
||||
select json_contains_path('{ "a": true }', NULL, '$.a' ) as exp;
|
||||
select json_contains_path('{ "a": true }', 'all', NULL ) as exp;
|
||||
select json_contains_path('{"a":{"b":"c"}}', 'one', '$.a.*') as exp;
|
||||
|
||||
select json_extract('{"key1":"asd", "key2":[2,3]}', "$.key1");
|
||||
select json_extract('{"key1":"asd", "key2":[2,3]}', "$.keyX", "$.keyY");
|
||||
select json_extract('{"key1":"asd", "key2":[2,3]}', "$.key1", "$.key2");
|
||||
select json_extract('{"key1":5, "key2":[2,3]}', "$.key1", "$.key2");
|
||||
select json_extract('{"key0":true, "key1":"qwe"}', "$.key1");
|
||||
select json_extract(json_object('foo', 'foobar'),'$');
|
||||
select json_extract('[10, 20, [30, 40]]', '$[2][*]');
|
||||
select json_extract('[10, 20, [{"a":3}, 30, 40]]', '$[2][*]');
|
||||
select json_extract('1', '$');
|
||||
select json_extract('[10, 20, [30, 40], 1, 10]', '$[1]');
|
||||
select json_extract('[10, 20, [30, 40], 1, 10]', '$[1]', '$[25]');
|
||||
select json_extract( '[{"a": [3, 4]}, {"b": 2}]', '$[0].a', '$[1].a');
|
||||
select json_extract('{"key1":"asd", "key2":[2,3]}', "$.key1") as exp;
|
||||
select json_extract('{"key1":"asd", "key2":[2,3]}', "$.keyX", "$.keyY") as exp;
|
||||
select json_extract('{"key1":"asd", "key2":[2,3]}', "$.key1", "$.key2") as exp;
|
||||
select json_extract('{"key1":5, "key2":[2,3]}', "$.key1", "$.key2") as exp;
|
||||
select json_extract('{"key0":true, "key1":"qwe"}', "$.key1") as exp;
|
||||
select json_extract(json_object('foo', 'foobar'),'$') as exp;
|
||||
select json_extract('[10, 20, [30, 40]]', '$[2][*]') as exp;
|
||||
select json_extract('[10, 20, [{"a":3}, 30, 40]]', '$[2][*]') as exp;
|
||||
select json_extract('1', '$') as exp;
|
||||
select json_extract('[10, 20, [30, 40], 1, 10]', '$[1]') as exp;
|
||||
select json_extract('[10, 20, [30, 40], 1, 10]', '$[1]', '$[25]') as exp;
|
||||
select json_extract( '[{"a": [3, 4]}, {"b": 2}]', '$[0].a', '$[1].a') as exp;
|
||||
|
||||
select json_insert('{"a":1, "b":{"c":1}, "d":[1, 2]}', '$.b.k1', 'word');
|
||||
select json_insert('{"a":1, "b":{"c":1}, "d":[1, 2]}', '$.d[3]', 3);
|
||||
select json_insert('{"a":1, "b":{"c":1}, "d":[1, 2]}', '$.a[2]', 2);
|
||||
select json_insert('{"a":1, "b":{"c":1}, "d":[1, 2]}', '$.b.c', 'word');
|
||||
#enable after MDEV-32454 fix
|
||||
--disable_view_protocol
|
||||
select json_insert('{"a":1, "b":{"c":1}, "d":[1, 2]}', '$.b.k1', 'word') as exp;
|
||||
select json_insert('{"a":1, "b":{"c":1}, "d":[1, 2]}', '$.d[3]', 3) as exp;
|
||||
select json_insert('{"a":1, "b":{"c":1}, "d":[1, 2]}', '$.a[2]', 2) as exp;
|
||||
select json_insert('{"a":1, "b":{"c":1}, "d":[1, 2]}', '$.b.c', 'word') as exp;
|
||||
|
||||
select json_set('{ "a": 1, "b": [2, 3]}', '$.a', 10, '$.c', '[true, false]');
|
||||
select json_set('{ "a": 1, "b": [2, 3]}', '$.a', 10, '$.c', '[true, false]') as exp;
|
||||
--enable_view_protocol
|
||||
|
||||
select json_replace('{ "a": 1, "b": [2, 3]}', '$.a', 10, '$.c', '[true, false]');
|
||||
select json_replace('{ "a": 1, "b": [2, 3]}', '$.a', 10, '$.b', '[true, false]');
|
||||
select json_replace('{ "a": 1, "b": [2, 3]}', '$.a', 10, '$.c', '[true, false]') as exp;
|
||||
select json_replace('{ "a": 1, "b": [2, 3]}', '$.a', 10, '$.b', '[true, false]') as exp;
|
||||
|
||||
set @j = '["a", ["b", "c"], "d"]';
|
||||
select json_remove(@j, '$[0]');
|
||||
@ -129,9 +117,9 @@ show create table t1;
|
||||
select * from t1;
|
||||
drop table t1;
|
||||
|
||||
select json_exists('{"key1":"xxxx", "key2":[1, 2, 3]}', "$.key2");
|
||||
select json_exists('{"key1":"xxxx", "key2":[1, 2, 3]}', "$.key2[1]");
|
||||
select json_exists('{"key1":"xxxx", "key2":[1, 2, 3]}', "$.key2[10]");
|
||||
select json_exists('{"key1":"xxxx", "key2":[1, 2, 3]}', "$.key2") as ex;
|
||||
select json_exists('{"key1":"xxxx", "key2":[1, 2, 3]}', "$.key2[1]") as ex;
|
||||
select json_exists('{"key1":"xxxx", "key2":[1, 2, 3]}', "$.key2[10]") as ex;
|
||||
|
||||
select json_quote('"string"');
|
||||
create table t1 as select json_quote('foo');
|
||||
@ -151,11 +139,14 @@ select json_merge('a','b');
|
||||
select json_merge('{"a":"b"}','{"c":"d"}');
|
||||
SELECT JSON_MERGE('[1, 2]', '{"id": 47}');
|
||||
|
||||
#enable after MDEV-32454 fix
|
||||
--disable_view_protocol
|
||||
select json_type('{"k1":123, "k2":345}');
|
||||
select json_type('[123, "k2", 345]');
|
||||
select json_type("true");
|
||||
select json_type('123');
|
||||
select json_type('123.12');
|
||||
--enable_view_protocol
|
||||
|
||||
select json_keys('{"a":{"c":1, "d":2}, "b":2}');
|
||||
select json_keys('{"a":{"c":1, "d":2}, "b":2}', "$.a");
|
||||
@ -164,28 +155,31 @@ select json_keys('foo');
|
||||
#
|
||||
# mdev-12789 JSON_KEYS returns duplicate keys twice
|
||||
#
|
||||
select json_keys('{"a":{"c":1, "d":2}, "b":2, "c":1, "a":3, "b":1, "c":2}');
|
||||
select json_keys('{"c1": "value 1", "c1": "value 2"}');
|
||||
select json_keys('{"a":{"c":1, "d":2}, "b":2, "c":1, "a":3, "b":1, "c":2}') as ex;
|
||||
select json_keys('{"c1": "value 1", "c1": "value 2"}') as ex;
|
||||
|
||||
SET @j = '["abc", [{"k": "10"}, "def"], {"x":"abc"}, {"y":"bcd"}]';
|
||||
select json_search(@j, 'one', 'abc');
|
||||
select json_search(@j, 'all', 'abc');
|
||||
select json_search(@j, 'all', 'abc', NULL, '$[2]');
|
||||
select json_search(@j, 'all', 'abc', NULL, '$');
|
||||
select json_search(@j, 'all', '10', NULL, '$');
|
||||
select json_search(@j, 'all', '10', NULL, '$[*]');
|
||||
select json_search(@j, 'all', '10', NULL, '$[*][0].k');
|
||||
select json_search(@j, 'all', '10', NULL, '$**.k');
|
||||
select json_search(@j, 'one', 'abc') as ex;
|
||||
select json_search(@j, 'all', 'abc') as ex;
|
||||
select json_search(@j, 'all', 'abc', NULL, '$[2]') as ex;
|
||||
select json_search(@j, 'all', 'abc', NULL, '$') as ex;
|
||||
select json_search(@j, 'all', '10', NULL, '$') as ex;
|
||||
select json_search(@j, 'all', '10', NULL, '$[*]') as ex;
|
||||
select json_search(@j, 'all', '10', NULL, '$[*][0].k') as ex;
|
||||
select json_search(@j, 'all', '10', NULL, '$**.k') as ex;
|
||||
create table t1( json_col text );
|
||||
insert into t1 values
|
||||
('{ "a": "foobar" }'),
|
||||
('{ "a": "foobar", "b": "focus", "c": [ "arm", "foot", "shoulder" ] }');
|
||||
select json_search( json_col, 'all', 'foot' ) from t1;
|
||||
select json_search( json_col, 'all', 'foot' ) as ex from t1;
|
||||
drop table t1;
|
||||
|
||||
|
||||
#enable after MDEV-32454 fix
|
||||
--disable_view_protocol
|
||||
select json_unquote('"abc"');
|
||||
select json_unquote('abc');
|
||||
--enable_view_protocol
|
||||
#
|
||||
# MDEV-13703 Illegal mix of collations for operation 'json_object' on using JSON_UNQUOTE as an argument.
|
||||
#
|
||||
@ -195,9 +189,14 @@ insert into t1 values ('abc'),('def');
|
||||
select json_object('foo', json_unquote(json_object('bar', c)),'qux', c) as fld from t1;
|
||||
drop table t1;
|
||||
|
||||
|
||||
#enable after MDEV-32454 fix
|
||||
--disable_view_protocol
|
||||
select json_object("a", json_object("b", "abcd"));
|
||||
select json_object("a", '{"b": "abcd"}');
|
||||
select json_object("a", json_compact('{"b": "abcd"}'));
|
||||
--enable_view_protocol
|
||||
|
||||
|
||||
select json_compact(NULL);
|
||||
select json_depth(json_compact(NULL));
|
||||
@ -216,15 +215,15 @@ create table json (j INT);
|
||||
show create table json;
|
||||
drop table json;
|
||||
|
||||
select json_length( '[ 1, [ 2, 3, 4 ], 5 ]', '$[2]' );
|
||||
select json_length( '[ 1, [ 2, 3, 4 ], 5 ]', '$[2][0]' );
|
||||
select json_length( '[ 1, [ 2, 3, 4 ], 5 ]', '$[2][0][0]' );
|
||||
select json_length( '[ 1, [ 2, 3, 4 ], 5 ]', '$[2][0][0][0]' );
|
||||
select json_length( '[ 1, [ 2, 3, 4 ], {"a":5, "b":6} ]', '$[2]' );
|
||||
select json_length( '[ 1, [ 2, 3, 4 ], {"a":5, "b":6} ]', '$[2][0]' );
|
||||
select json_length( '[ 1, [ 2, 3, 4 ], {"a":5, "b":6} ]', '$[2][0][0]' );
|
||||
select json_length( '[ 1, [ 2, 3, 4 ], {"a":5, "b":6} ]', '$[2][0][0][0]' );
|
||||
select json_length( '{"a":{"b":{"d":1}}, "a":{"c":{"d":1, "j":2}}}', '$.a[0][0][0].c' );
|
||||
select json_length( '[ 1, [ 2, 3, 4 ], 5 ]', '$[2]' ) as ex;
|
||||
select json_length( '[ 1, [ 2, 3, 4 ], 5 ]', '$[2][0]' ) as ex;
|
||||
select json_length( '[ 1, [ 2, 3, 4 ], 5 ]', '$[2][0][0]' ) as ex;
|
||||
select json_length( '[ 1, [ 2, 3, 4 ], 5 ]', '$[2][0][0][0]' ) as ex;
|
||||
select json_length( '[ 1, [ 2, 3, 4 ], {"a":5, "b":6} ]', '$[2]' ) as ex;
|
||||
select json_length( '[ 1, [ 2, 3, 4 ], {"a":5, "b":6} ]', '$[2][0]' ) as ex;
|
||||
select json_length( '[ 1, [ 2, 3, 4 ], {"a":5, "b":6} ]', '$[2][0][0]' ) as ex;
|
||||
select json_length( '[ 1, [ 2, 3, 4 ], {"a":5, "b":6} ]', '$[2][0][0][0]' ) as ex;
|
||||
select json_length( '{"a":{"b":{"d":1}}, "a":{"c":{"d":1, "j":2}}}', '$.a[0][0][0].c' ) as ex;
|
||||
|
||||
select json_set('1', '$[0]', 100);
|
||||
select json_set('1', '$[0][0]', 100);
|
||||
@ -234,12 +233,12 @@ select json_set('{"a":12}', '$[0].a', 100);
|
||||
select json_set('{"a":12}', '$[0][0].a', 100);
|
||||
select json_set('{"a":12}', '$[0][1].a', 100);
|
||||
|
||||
select json_value('{"\\"key1":123}', '$."\\"key1"');
|
||||
select json_value('{"\\"key1\\"":123}', '$."\\"key1\\""');
|
||||
select json_value('{"key 1":123}', '$."key 1"');
|
||||
select json_value('{"\\"key1":123}', '$."\\"key1"') as ex;
|
||||
select json_value('{"\\"key1\\"":123}', '$."\\"key1\\""') as ex;
|
||||
select json_value('{"key 1":123}', '$."key 1"') as ex;
|
||||
|
||||
select json_contains_path('{"a":[{"c":[1,{"a":[0,1,2]},3]}], "b":[1,2,3]}', 'one', "$**.a[2]");
|
||||
select json_contains_path('{"a":[{"c":[1,{"a":[0,1,2]},3]}], "b":[1,2,3]}', 'one', "$**.a[3]");
|
||||
select json_contains_path('{"a":[{"c":[1,{"a":[0,1,2]},3]}], "b":[1,2,3]}', 'one', "$**.a[2]") as ex;
|
||||
select json_contains_path('{"a":[{"c":[1,{"a":[0,1,2]},3]}], "b":[1,2,3]}', 'one', "$**.a[3]") as ex;
|
||||
|
||||
select json_extract( '[1]', '$[0][0]' );
|
||||
select json_extract( '[1]', '$[1][0]' );
|
||||
@ -267,21 +266,24 @@ SELECT JSON_search( '{"": "a"}', "one", 'a');
|
||||
# MDEV-11858 json_merge() concatenates instead of merging.
|
||||
#
|
||||
|
||||
select json_merge('{"a":"b"}', '{"a":"c"}') ;
|
||||
select json_merge('{"a":{"x":"b"}}', '{"a":"c"}') ;
|
||||
select json_merge('{"a":{"u":12, "x":"b"}}', '{"a":{"x":"c"}}') ;
|
||||
select json_merge('{"a":{"u":12, "x":"b", "r":1}}', '{"a":{"x":"c", "r":2}}') ;
|
||||
select json_merge('{"a":"b"}', '{"a":"c"}') as ex ;
|
||||
select json_merge('{"a":{"x":"b"}}', '{"a":"c"}') as ex ;
|
||||
select json_merge('{"a":{"u":12, "x":"b"}}', '{"a":{"x":"c"}}') as ex ;
|
||||
select json_merge('{"a":{"u":12, "x":"b", "r":1}}', '{"a":{"x":"c", "r":2}}') as ex ;
|
||||
|
||||
select json_compact('{"a":1, "b":[1,2,3], "c":{"aa":"v1", "bb": "v2"}}');
|
||||
select json_loose('{"a":1, "b":[1,2,3], "c":{"aa":"v1", "bb": "v2"}}');
|
||||
select json_detailed('{"a":1, "b":[1,2,3], "c":{"aa":"v1", "bb": "v2"}}');
|
||||
select json_compact('{"a":1, "b":[1,2,3], "c":{"aa":"v1", "bb": "v2"}}') as ex;
|
||||
#enable after MDEV-32454 fix
|
||||
--disable_view_protocol
|
||||
select json_loose('{"a":1, "b":[1,2,3], "c":{"aa":"v1", "bb": "v2"}}') as ex;
|
||||
select json_detailed('{"a":1, "b":[1,2,3], "c":{"aa":"v1", "bb": "v2"}}') as ex;
|
||||
--enable_view_protocol
|
||||
|
||||
#
|
||||
# MDEV-11856 json_search doesn't search for values with double quotes character (")
|
||||
#
|
||||
|
||||
SELECT JSON_search( '{"x": "\\""}', "one", '"');
|
||||
SELECT JSON_search( '{"x": "\\""}', "one", '\\"');
|
||||
SELECT JSON_search( '{"x": "\\""}', "one", '"') as ex;
|
||||
SELECT JSON_search( '{"x": "\\""}', "one", '\\"') as ex;
|
||||
|
||||
#
|
||||
# MDEV-11833 JSON functions don't seem to respect max_allowed_packet.
|
||||
@ -295,8 +297,8 @@ set @@global.max_allowed_packet=2048;
|
||||
|
||||
show variables like 'net_buffer_length';
|
||||
show variables like 'max_allowed_packet';
|
||||
select json_array(repeat('a',1024),repeat('a',1024));
|
||||
select json_object("a", repeat('a',1024),"b", repeat('a',1024));
|
||||
select json_array(repeat('a',1024),repeat('a',1024)) as ex;
|
||||
select json_object("a", repeat('a',1024),"b", repeat('a',1024)) as ex;
|
||||
--connection default
|
||||
|
||||
set @@global.max_allowed_packet = @save_max_allowed_packet;
|
||||
@ -346,27 +348,30 @@ SELECT JSON_EXTRACT( '{"foo":"bar"}', '$[*]');
|
||||
# MDEV-12604 Comparison of JSON_EXTRACT result differs with Mysql.
|
||||
#
|
||||
|
||||
select JSON_EXTRACT('{"name":"value"}', '$.name') = 'value';
|
||||
select JSON_EXTRACT('{\"asdf\":true}', "$.\"asdf\"") = true;
|
||||
select JSON_EXTRACT('{\"asdf\":true}', "$.\"asdf\"") = false;
|
||||
select JSON_EXTRACT('{\"asdf\":true}', "$.\"asdf\"") = 1;
|
||||
select JSON_EXTRACT('{\"input1\":\"\\u00f6\"}', '$.\"input1\"');
|
||||
select JSON_EXTRACT('{"name":"value"}', '$.name') = 'value' as ex;
|
||||
select JSON_EXTRACT('{\"asdf\":true}', "$.\"asdf\"") = true as ex;
|
||||
select JSON_EXTRACT('{\"asdf\":true}', "$.\"asdf\"") = false as ex;
|
||||
select JSON_EXTRACT('{\"asdf\":true}', "$.\"asdf\"") = 1 as ex;
|
||||
select JSON_EXTRACT('{\"input1\":\"\\u00f6\"}', '$.\"input1\"') as ex;
|
||||
|
||||
#
|
||||
# MDEV-129892 JSON_EXTRACT returns data for invalid JSON
|
||||
#
|
||||
select JSON_EXTRACT('{"foo": "bar" foobar foo invalid ', '$.foo');
|
||||
select JSON_EXTRACT('{"foo": "bar" foobar foo invalid ', '$.foo') as ex;
|
||||
|
||||
#
|
||||
# MDEV-13138 JSON_OBJECT returns null with strings containing backticks.
|
||||
#
|
||||
SELECT JSON_OBJECT('foo', '`');
|
||||
SELECT JSON_OBJECT("foo", "bar`bar");
|
||||
SELECT JSON_OBJECT('foo', '`') as ex;
|
||||
SELECT JSON_OBJECT("foo", "bar`bar") as ex;
|
||||
|
||||
#
|
||||
# MDEV-13324 JSON_SET returns NULL instead of object.
|
||||
#
|
||||
#enable after MDEV-32454 fix
|
||||
--disable_view_protocol
|
||||
SELECT JSON_SET('{}', '$.age', 87);
|
||||
--enable_view_protocol
|
||||
|
||||
#
|
||||
# MDEV-13104 Json functions.
|
||||
@ -459,16 +464,19 @@ select json_array(1,user(),compress(5.140264e+307));
|
||||
create table t1(json_col TEXT) DEFAULT CHARSET=latin1;
|
||||
insert into t1 values (_latin1 X'7B226B657931223A2253EC227D');
|
||||
select JSON_VALUE(json_col, '$.key1')= _latin1 X'53EC' from t1;
|
||||
select REPLACE(JSON_VALUE(json_col, '$.key1'), 'null', '') = _latin1 X'53EC' from t1;
|
||||
select REPLACE(JSON_VALUE(json_col, '$.key1'), 'null', '') = _latin1 X'53EC' as exp from t1;
|
||||
drop table t1;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-16750 JSON_SET mishandles unicode every second pair of arguments.
|
||||
--echo #
|
||||
|
||||
SELECT JSON_SET('{}', '$.a', _utf8 0xC3B6);
|
||||
SELECT JSON_SET('{}', '$.a', _utf8 0xC3B6, '$.b', _utf8 0xC3B6);
|
||||
SELECT JSON_SET('{}', '$.a', _utf8 X'C3B6', '$.x', 1, '$.b', _utf8 X'C3B6');
|
||||
#enable after MDEV-32454 fix
|
||||
--disable_view_protocol
|
||||
SELECT JSON_SET('{}', '$.a', _utf8 0xC3B6) as exp;
|
||||
SELECT JSON_SET('{}', '$.a', _utf8 0xC3B6, '$.b', _utf8 0xC3B6) as exp;
|
||||
SELECT JSON_SET('{}', '$.a', _utf8 X'C3B6', '$.x', 1, '$.b', _utf8 X'C3B6') as exp;
|
||||
--enable_view_protocol
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-17121 JSON_ARRAY_APPEND
|
||||
@ -511,9 +519,9 @@ select JSON_VALID( '{"a":1]' );
|
||||
--echo #
|
||||
--echo # MDEV-18886 JSON_ARRAY() does not recognise JSON argument.
|
||||
--echo #
|
||||
SELECT JSON_ARRAY(_UTF8 'str', JSON_OBJECT(_LATIN1 'plugin', _LATIN1'unix_socket'));
|
||||
SELECT CHARSET(JSON_ARRAY());
|
||||
SELECT CHARSET(JSON_OBJECT());
|
||||
SELECT JSON_ARRAY(_UTF8 'str', JSON_OBJECT(_LATIN1 'plugin', _LATIN1'unix_socket')) as exp;
|
||||
SELECT CHARSET(JSON_ARRAY()) as exp;
|
||||
SELECT CHARSET(JSON_OBJECT()) as exp;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-13992 Implement JSON_MERGE_PATCH
|
||||
@ -547,17 +555,17 @@ SELECT id, target, patch,
|
||||
FROM merge_t ORDER BY id;
|
||||
DROP TABLE merge_t;
|
||||
|
||||
SELECT JSON_MERGE_PATCH('{"a":"b"}', NULL, '{"c":"d"}');
|
||||
SELECT JSON_MERGE_PATCH(NULL, '[1,2,3]');
|
||||
SELECT JSON_MERGE_PATCH(NULL, 'a');
|
||||
SELECT JSON_MERGE_PATCH('{"a":"b"}', NULL, '[1,2,3]', '{"c":null,"d":"e"}');
|
||||
SELECT JSON_MERGE_PATCH('{"a":"b"}', NULL, '{"c":"d"}') as exp;
|
||||
SELECT JSON_MERGE_PATCH(NULL, '[1,2,3]') as exp;
|
||||
SELECT JSON_MERGE_PATCH(NULL, 'a') as exp;
|
||||
SELECT JSON_MERGE_PATCH('{"a":"b"}', NULL, '[1,2,3]', '{"c":null,"d":"e"}') as exp;
|
||||
|
||||
--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
|
||||
SELECT JSON_MERGE_PATCH();
|
||||
SELECT JSON_MERGE_PATCH() as exp;
|
||||
--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
|
||||
SELECT JSON_MERGE_PATCH('{}');
|
||||
SELECT JSON_MERGE_PATCH('{', '[1,2,3]');
|
||||
SELECT JSON_MERGE_PATCH('{"a":"b"}', '[1,');
|
||||
SELECT JSON_MERGE_PATCH('{}') as exp;
|
||||
SELECT JSON_MERGE_PATCH('{', '[1,2,3]') as exp;
|
||||
SELECT JSON_MERGE_PATCH('{"a":"b"}', '[1,') as exp;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-22976 CAST(JSON_EXTRACT() AS DECIMAL) does not handle boolean values
|
||||
@ -603,6 +611,7 @@ DROP TABLE json_test;
|
||||
|
||||
--enable_metadata
|
||||
--disable_ps_protocol
|
||||
--disable_view_protocol
|
||||
|
||||
SELECT
|
||||
JSON_VALID('{"id": 1, "name": "Monty"}') AS json_valid,
|
||||
@ -614,6 +623,7 @@ SELECT
|
||||
JSON_LENGTH('{"a": 1, "b": {"c": 30}}') AS json_length,
|
||||
JSON_DEPTH('[10, {"a": 20}]') AS json_depnth;
|
||||
|
||||
--enable_view_protocol
|
||||
--enable_ps_protocol
|
||||
--disable_metadata
|
||||
|
||||
@ -676,10 +686,13 @@ SELECT JSON_EXTRACT('{"a":null, "b":10, "c":"null"}', '$.a');
|
||||
--echo #
|
||||
|
||||
--vertical_results
|
||||
#enable after fix MDEV-28649
|
||||
--disable_view_protocol
|
||||
SELECT
|
||||
JSON_OBJECT("cond", true) AS j1,
|
||||
JSON_OBJECT("cond", COALESCE(true, false)) j2,
|
||||
JSON_OBJECT("cond", COALESCE(COALESCE(true, false))) j3;
|
||||
--enable_view_protocol
|
||||
--horizontal_results
|
||||
|
||||
CREATE TABLE t1 (a INT);
|
||||
@ -744,7 +757,10 @@ INSERT INTO t1 VALUES (TRUE, TRUE), (TRUE, FALSE), (FALSE, TRUE), (FALSE, FALSE)
|
||||
SELECT JSON_VALID(JSON_ARRAYAGG(a)) FROM t1;
|
||||
SELECT JSON_ARRAYAGG(a), JSON_ARRAYAGG(b) FROM t1;
|
||||
SELECT JSON_ARRAYAGG(a), JSON_ARRAYAGG(b) FROM t1 GROUP BY b;
|
||||
#enable after MDEV-32454 fix
|
||||
--disable_view_protocol
|
||||
SELECT JSON_ARRAYAGG(TRUE), JSON_ARRAYAGG(FALSE) FROM t1;
|
||||
--enable_view_protocol
|
||||
DROP TABLE t1;
|
||||
|
||||
-- echo #
|
||||
@ -910,9 +926,9 @@ insert into t200 values
|
||||
}');
|
||||
|
||||
|
||||
select JSON_DETAILED(JSON_EXTRACT(a, '$**.analyzing_range_alternatives')) from t200;
|
||||
select JSON_PRETTY(JSON_EXTRACT(a, '$**.analyzing_range_alternatives')) from t200;
|
||||
select JSON_LOOSE(JSON_EXTRACT(a, '$**.analyzing_range_alternatives')) from t200;
|
||||
select JSON_DETAILED(JSON_EXTRACT(a, '$**.analyzing_range_alternatives')) as exp from t200;
|
||||
select JSON_PRETTY(JSON_EXTRACT(a, '$**.analyzing_range_alternatives')) as exp from t200;
|
||||
select JSON_LOOSE(JSON_EXTRACT(a, '$**.analyzing_range_alternatives')) as exp from t200;
|
||||
drop table t200;
|
||||
|
||||
--echo #
|
||||
@ -1021,9 +1037,12 @@ create table t1 (a varchar(254));
|
||||
insert into t1 values (concat('x64-', repeat('a', 60)));
|
||||
insert into t1 values (concat('x64-', repeat('b', 60)));
|
||||
insert into t1 values (concat('x64-', repeat('c', 60)));
|
||||
#enable after MDEV-32454 fix
|
||||
--disable_view_protocol
|
||||
--disable_ps2_protocol
|
||||
select json_arrayagg(a) from t1;
|
||||
--enable_ps2_protocol
|
||||
--enable_view_protocol
|
||||
drop table t1;
|
||||
SET group_concat_max_len= default;
|
||||
|
||||
@ -1070,8 +1089,8 @@ DROP TABLE t2;
|
||||
--echo # MDEV-27018 IF and COALESCE lose "json" property
|
||||
--echo #
|
||||
|
||||
SELECT json_object('a', if(1, json_object('b', 'c'), json_object('e', 'f')));
|
||||
SELECT json_object('a', coalesce(json_object('b', 'c')));
|
||||
SELECT json_object('a', if(1, json_object('b', 'c'), json_object('e', 'f'))) as exp;
|
||||
SELECT json_object('a', coalesce(json_object('b', 'c'))) as exp;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-26392: Crash with json_get_path_next and 10.5.12
|
||||
@ -1177,7 +1196,7 @@ SELECT JSON_OVERLAPS('{
|
||||
'{
|
||||
"A": 2,
|
||||
"B": "string1"
|
||||
}');
|
||||
}') as exp;
|
||||
SELECT JSON_OVERLAPS('{
|
||||
"A": 1,
|
||||
"B": "string1"
|
||||
@ -1185,7 +1204,7 @@ SELECT JSON_OVERLAPS('{
|
||||
'{
|
||||
"A": 2,
|
||||
"B": "string2"
|
||||
}');
|
||||
}') as exp;
|
||||
|
||||
--echo # Comparing nested object with other nested object
|
||||
SELECT JSON_OVERLAPS('{
|
||||
@ -1195,7 +1214,7 @@ SELECT JSON_OVERLAPS('{
|
||||
'{
|
||||
"A": 2,
|
||||
"B": {"C":1}
|
||||
}');
|
||||
}') as exp;
|
||||
SELECT JSON_OVERLAPS('{
|
||||
"A": 1,
|
||||
"B": {"C":2}
|
||||
@ -1203,7 +1222,7 @@ SELECT JSON_OVERLAPS('{
|
||||
'{
|
||||
"A": 2,
|
||||
"B": {"C":2}
|
||||
}');
|
||||
}') as exp;
|
||||
SELECT JSON_OVERLAPS('{
|
||||
"A": {
|
||||
"B": true
|
||||
@ -1214,32 +1233,32 @@ SELECT JSON_OVERLAPS('{
|
||||
"B": true,
|
||||
"C": false
|
||||
}
|
||||
}');
|
||||
}') as exp;
|
||||
SELECT JSON_OVERLAPS('{"A":1, "B":{"D":4, "E":5}}',
|
||||
'{"C":3, "B":{"E":5, "D":4}}');
|
||||
'{"C":3, "B":{"E":5, "D":4}}') as exp;
|
||||
SELECT JSON_OVERLAPS('{"A":1, "B":{"D":4, "E":[5, 6, 7]}}',
|
||||
'{"C":3, "B":{"E":5, "D":4}}');
|
||||
'{"C":3, "B":{"E":5, "D":4}}') as exp;
|
||||
SELECT JSON_OVERLAPS('{"A":1, "B":{"D":4, "E":[5, 6, 7]}}',
|
||||
'{"C":3, "B":{"E":[5, 6, 7], "D":4}}');
|
||||
'{"C":3, "B":{"E":[5, 6, 7], "D":4}}') as exp;
|
||||
SELECT JSON_OVERLAPS('{"A":1, "B":{"D":4, "E":[5, 6, 7]}}',
|
||||
'{"C":3, "B":{"E":[7, 6 ,5], "D":4}}');
|
||||
'{"C":3, "B":{"E":[7, 6 ,5], "D":4}}') as exp;
|
||||
SELECT JSON_OVERLAPS('{"A":1, "B":{"D":4, "E":[5, 6, 7]}}',
|
||||
'{"C":3, "F":{"E":[5, 6, 7], "D":4}}');
|
||||
'{"C":3, "F":{"E":[5, 6, 7], "D":4}}') as exp;
|
||||
|
||||
|
||||
--echo # Comparing array with array (non-nested)
|
||||
SELECT JSON_OVERLAPS('[1, 2, true, false, null]',
|
||||
'[3, 4, 1]');
|
||||
'[3, 4, 1]') as exp;
|
||||
SELECT JSON_OVERLAPS('[1, 2, true, false, null]',
|
||||
'[3, 4, 5]');
|
||||
SELECT JSON_OVERLAPS('[1,2,3]','[]');
|
||||
SELECT JSON_OVERLAPS('[1,2,3]','[]') as exp;
|
||||
|
||||
--echo # Comparing nested arrays
|
||||
SELECT JSON_OVERLAPS('[1, 2, true, false, null]',
|
||||
'[3, 4, [1]]');
|
||||
'[3, 4, [1]]') as exp;
|
||||
SELECT JSON_OVERLAPS('[1, 2, [true, false], null]',
|
||||
'[[1], [true, false]]');
|
||||
SELECT JSON_OVERLAPS('[1, 2, 3, [4, 5, 6]]','[7, 8, 9, [6, 5, 4]]');
|
||||
'[[1], [true, false]]') as exp;
|
||||
SELECT JSON_OVERLAPS('[1, 2, 3, [4, 5, 6]]','[7, 8, 9, [6, 5, 4]]') as exp;
|
||||
|
||||
|
||||
--echo # Comparing one non-scalar json datatypes with another non-scalar
|
||||
@ -1247,52 +1266,52 @@ SELECT JSON_OVERLAPS('[1, 2, 3, [4, 5, 6]]','[7, 8, 9, [6, 5, 4]]');
|
||||
|
||||
--echo # Comparing array with object
|
||||
SELECT JSON_OVERLAPS('[1, 2, true, false, null]',
|
||||
'{"A": 1}');
|
||||
'{"A": 1}') as exp;
|
||||
SELECT JSON_OVERLAPS('[1, 2, true, false, null, {"A":2}]',
|
||||
'{"A": 1}');
|
||||
'{"A": 1}') as exp;
|
||||
SELECT JSON_OVERLAPS('[1, {"A": 2}, {"A": 1}]',
|
||||
'{"A": 1}');
|
||||
'{"A": 1}') as exp;
|
||||
SELECT JSON_OVERLAPS('[1, 2, true, false, {"A": 1, "B": 2}]',
|
||||
'{"A": 1, "B": 2}');
|
||||
'{"A": 1, "B": 2}') as exp;
|
||||
SELECT JSON_OVERLAPS('[1, 2, true, false, {"A": 1, "B": 2}]',
|
||||
'{"A": 1, "B": 3}');
|
||||
'{"A": 1, "B": 3}') as exp;
|
||||
|
||||
-- echo # Comparing nested array with object
|
||||
SELECT JSON_OVERLAPS('[1, 2, true, false, [{"A": 1, "B": 2}]]',
|
||||
'{"A": 1, "B": 2}');
|
||||
'{"A": 1, "B": 2}') as exp;
|
||||
SELECT JSON_OVERLAPS('[1, 2, true, false, [{"A": 1, "B": 2}]]',
|
||||
'{"A": 1, "B": 3}');
|
||||
'{"A": 1, "B": 3}') as exp;
|
||||
SELECT JSON_OVERLAPS('[1, 2, true, false, [{"A": 1, "B": 2}]]',
|
||||
'{"A": 1}');
|
||||
'{"A": 1}') as exp;
|
||||
|
||||
--echo # Comparing array with nested object
|
||||
SELECT JSON_OVERLAPS('[1, 2, true, false, {"A": 1, "B": {"C": 12}}]',
|
||||
'{"A": 1, "B": {"C": 12}}');
|
||||
'{"A": 1, "B": {"C": 12}}') as exp;
|
||||
SELECT JSON_OVERLAPS('[1, 2, true, false, [{"A": 1, "B": {"C": 12}}]]',
|
||||
'{"A": 1, "B": {"C": 12}}');
|
||||
'{"A": 1, "B": {"C": 12}}') as exp;
|
||||
|
||||
--echo # Comparing nested array with nested objects
|
||||
SELECT JSON_OVERLAPS('[1, 2, true, false, [{"A": 1, "B": {"C": 12}}]]',
|
||||
'{"A": 1, "B":{"C": 12}}');
|
||||
'{"A": 1, "B":{"C": 12}}') as exp;
|
||||
SELECT JSON_OVERLAPS('[[1, 2, true, false, {"A": 1, "B": {"C": 12}}]]',
|
||||
'{"A": 1, "B": {"C": 12}}');
|
||||
'{"A": 1, "B": {"C": 12}}') as exp;
|
||||
|
||||
--echo # Comparing object with array
|
||||
SELECT JSON_OVERLAPS('{"A": 1, "B": 3}',
|
||||
'[1, 2, true, false, {"A": 1, "B": 2}]');
|
||||
'[1, 2, true, false, {"A": 1, "B": 2}]') as exp;
|
||||
SELECT JSON_OVERLAPS('{"A": 1, "B": 3}',
|
||||
'[1, 2, true, false, {"A": 1, "B": 3}]');
|
||||
'[1, 2, true, false, {"A": 1, "B": 3}]') as exp;
|
||||
SELECT JSON_OVERLAPS('{"A": 1, "B": 3}',
|
||||
'[1, 2, true, false, {"A": 1, "B": 2}, {"A": 1, "B": 3}]');
|
||||
'[1, 2, true, false, {"A": 1, "B": 2}, {"A": 1, "B": 3}]') as exp;
|
||||
SELECT JSON_OVERLAPS('{"A": 1, "B": [1, 2, 3]}',
|
||||
'[1, 2, true, false, {"A": 1, "B": 2}, {"A": 1, "B": [1, 2, 3]}]');
|
||||
'[1, 2, true, false, {"A": 1, "B": 2}, {"A": 1, "B": [1, 2, 3]}]') as exp;
|
||||
SELECT JSON_OVERLAPS('{"A": 1, "B": [1, 2, {"C": 3, "D": 5}]}',
|
||||
'[1, 2, true, false, {"A": 1, "B": 2}, {"A":1, "B":[1, 2, {"C": 3, "D": 5}]}]');
|
||||
'[1, 2, true, false, {"A": 1, "B": 2}, {"A":1, "B":[1, 2, {"C": 3, "D": 5}]}]') as exp;
|
||||
SELECT JSON_OVERLAPS('{"A": 1, "B": [1, 2, {"C": 3, "D": 5}]}',
|
||||
'[1, 2, true, false, {"A": 1, "B": 2},{"A": 1, "B": [1, 2, {"C": 3, "D": 4}]}]');
|
||||
'[1, 2, true, false, {"A": 1, "B": 2},{"A": 1, "B": [1, 2, {"C": 3, "D": 4}]}]') as exp;
|
||||
|
||||
--echo # Comparing object with nested array
|
||||
SELECT JSON_OVERLAPS('{"A": 1, "B": 3}','[1, 2, true, false, [{"A": 1, "B": 2}, {"A": 1, "B": 3}]]');
|
||||
SELECT JSON_OVERLAPS('{"A": 1, "B": 3}','[1, 2, true, false, [{"A": 1, "B": 2}, {"A": 1, "B": 3}]]') as exp;
|
||||
|
||||
--echo # Checking errors and warnings
|
||||
|
||||
@ -3638,7 +3657,9 @@ SELECT JSON_SCHEMA_VALID(@schema, '-#');
|
||||
SET @schema_array= '{"type":"array"}';
|
||||
SELECT JSON_SCHEMA_VALID(@schema_array, '[');
|
||||
|
||||
--disable_view_protocol
|
||||
SELECT JSON_SCHEMA_VALID(repeat('[', 100000), json_object());
|
||||
--enable_view_protocol
|
||||
|
||||
SELECT JSON_SCHEMA_VALID(json_object(), repeat('[', 10000000));
|
||||
|
||||
@ -3734,25 +3755,29 @@ FROM JSON_TABLE(
|
||||
JSON_KEY_VALUE('[[1, 2, 3], 2, 3]', '$[0][1]'), '$[*]'
|
||||
COLUMNS (k VARCHAR(20) PATH '$.key', v VARCHAR(20) PATH '$.value', id FOR ORDINALITY)) AS jt;
|
||||
|
||||
SELECT JSON_KEY_VALUE('[[1, {"key1":"val1", "key2":"val2"}, 3], 2, 3]', '$[0][1]');
|
||||
SELECT JSON_KEY_VALUE('[[1, {"key1":"val1", "key2":"val2"}, 3], 2, 3]',
|
||||
'$[0][1]') as exp;
|
||||
SELECT jt.*
|
||||
FROM JSON_TABLE(
|
||||
JSON_KEY_VALUE('[[1, {"key1":"val1", "key2":"val2"}, 3], 2, 3]', '$[0][1]'), '$[*]'
|
||||
COLUMNS (k VARCHAR(20) PATH '$.key', v VARCHAR(20) PATH '$.value', id FOR ORDINALITY)) AS jt;
|
||||
|
||||
SELECT JSON_KEY_VALUE('[[1, {"key1":"val1", "key2":"val2"}, 3], 2, 3]', '$[0][1].key1');
|
||||
SELECT JSON_KEY_VALUE('[[1, {"key1":"val1", "key2":"val2"}, 3], 2, 3]',
|
||||
'$[0][1].key1') as exp;
|
||||
SELECT jt.*
|
||||
FROM JSON_TABLE(
|
||||
JSON_KEY_VALUE('[[1, {"key1":"val1", "key2":"val2"}, 3], 2, 3]', '$[0][1].key1'), '$[*]'
|
||||
COLUMNS (k VARCHAR(20) PATH '$.key', v VARCHAR(20) PATH '$.value', id FOR ORDINALITY)) AS jt;
|
||||
|
||||
SELECT JSON_KEY_VALUE('[[1, [{"key1":"val1", "key2":"val2"}], 3], 2, 3]', '$[0][1]');
|
||||
SELECT JSON_KEY_VALUE('[[1, [{"key1":"val1", "key2":"val2"}], 3], 2, 3]',
|
||||
'$[0][1]') as exp;
|
||||
SELECT jt.*
|
||||
FROM JSON_TABLE(
|
||||
JSON_KEY_VALUE('[[1, [{"key1":"val1", "key2":"val2"}], 3], 2, 3]', '$[0][1]'), '$[*]'
|
||||
COLUMNS (k VARCHAR(20) PATH '$.key', v VARCHAR(20) PATH '$.value', id FOR ORDINALITY)) AS jt;
|
||||
|
||||
SELECT JSON_KEY_VALUE('[[1, [{"key1":"val1", "key2":"val2"}], 3], 2, 3]', '$[0][1][0]');
|
||||
SELECT JSON_KEY_VALUE('[[1, [{"key1":"val1", "key2":"val2"}], 3], 2, 3]',
|
||||
'$[0][1][0]') as exp;
|
||||
SELECT jt.*
|
||||
FROM JSON_TABLE(
|
||||
JSON_KEY_VALUE('[[1, [{"key1":"val1", "key2":"val2"}], 3], 2, 3]', '$[0][1][0]'), '$[*]'
|
||||
@ -3762,31 +3787,34 @@ FROM JSON_TABLE(
|
||||
|
||||
SELECT JSON_KEY_VALUE('{}', '$.key1');
|
||||
|
||||
SELECT JSON_KEY_VALUE('{"key1":"val1", "key2":"val2"}', '$');
|
||||
#enable after MDEV-32454 fix
|
||||
--disable_view_protocol
|
||||
SELECT JSON_KEY_VALUE('{"key1":"val1", "key2":"val2"}', '$') as exp;
|
||||
--enable_view_protocol
|
||||
SELECT jt.*
|
||||
FROM JSON_TABLE(
|
||||
JSON_KEY_VALUE('{"key1":"val1", "key2":"val2"}', '$'), '$[*]'
|
||||
COLUMNS (k VARCHAR(11) PATH '$.key', v VARCHAR(5) PATH '$.value', id FOR ORDINALITY)) AS jt;
|
||||
|
||||
SELECT JSON_KEY_VALUE('{"key1":"val1", "key2":"val2"}', '$.key1');
|
||||
SELECT JSON_KEY_VALUE('{"key1":"val1", "key2":"val2"}', '$.key1') as exp;
|
||||
SELECT jt.*
|
||||
FROM JSON_TABLE(
|
||||
JSON_KEY_VALUE('{"key1":"val1", "key2":"val2"}', '$.key1'), '$[*]'
|
||||
COLUMNS (k VARCHAR(11) PATH '$.key', v VARCHAR(5) PATH '$.value', id FOR ORDINALITY)) AS jt;
|
||||
|
||||
SELECT JSON_KEY_VALUE('{"key1":{"a":1, "b":2}, "key2":"val2"}', '$.key1');
|
||||
SELECT JSON_KEY_VALUE('{"key1":{"a":1, "b":2}, "key2":"val2"}', '$.key1') as exp;
|
||||
SELECT jt.*
|
||||
FROM JSON_TABLE(
|
||||
JSON_KEY_VALUE('{"key1":{"a":1, "b":2}, "key2":"val2"}', '$.key1'), '$[*]'
|
||||
COLUMNS (k VARCHAR(11) PATH '$.key', v VARCHAR(5) PATH '$.value', id FOR ORDINALITY)) AS jt;
|
||||
|
||||
SELECT JSON_KEY_VALUE('{"key1":{"a":1, "b": [1,2,3, {"some_key":"some_val", "c":3}]}, "key2":"val2"}', '$.key1.b[3]');
|
||||
SELECT JSON_KEY_VALUE('{"key1":{"a":1, "b": [1,2,3, {"some_key":"some_val", "c":3}]}, "key2":"val2"}', '$.key1.b[3]') as exp;
|
||||
SELECT jt.*
|
||||
FROM JSON_TABLE(
|
||||
JSON_KEY_VALUE('{"key1":{"a":1, "b": [1,2,3, {"some_key":"some_val", "c":3}]}, "key2":"val2"}', '$.key1.b[3]'), '$[*]'
|
||||
COLUMNS (k VARCHAR(20) PATH '$.key', v VARCHAR(20) PATH '$.value', id FOR ORDINALITY)) AS jt;
|
||||
|
||||
SELECT JSON_KEY_VALUE('{"key1":{"a":1, "b": [1,2,3, {"some_key":"some_val", "c":3}]}, "key2":"val2"}', '$.key1.b[0]');
|
||||
SELECT JSON_KEY_VALUE('{"key1":{"a":1, "b": [1,2,3, {"some_key":"some_val", "c":3}]}, "key2":"val2"}', '$.key1.b[0]') as exp;
|
||||
SELECT jt.*
|
||||
FROM JSON_TABLE(
|
||||
JSON_KEY_VALUE('{"key1":{"a":1, "b": [1,2,3, {"some_key":"some_val", "c":3}]}, "key2":"val2"}', '$.key1.b[0]'), '$[*]'
|
||||
|
Reference in New Issue
Block a user