mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
MDEV-23187: Assorted assertion failures in json_find_path with certain
collations Analysis: When we have negative index, the value in array_counter[] array is going to be -1 at some point ( because in case of negative index in json path, the initial value for a path with negative index is -<size_of_array>, and as we move forward in array while parsing it and finding path, this value increments). Since SKIPPED_STEP_MARK, is maximum uint value, it gets compared to some int value in the array and eventually equates to -1 and messes with path. Fix: Make SKIPPED_STEP_MARK maximum of INT32.
This commit is contained in:
@ -2578,5 +2578,29 @@ SELECT JSON_EXTRACT('{ "my-key": 1 }', '$.my-key');
|
|||||||
JSON_EXTRACT('{ "my-key": 1 }', '$.my-key')
|
JSON_EXTRACT('{ "my-key": 1 }', '$.my-key')
|
||||||
1
|
1
|
||||||
#
|
#
|
||||||
|
# MDEV-23187: Assorted assertion failures in json_find_path with certain collations
|
||||||
|
#
|
||||||
|
SET @save_collation_connection= @@collation_connection;
|
||||||
|
SET @json='{ "A": [ [{"k":"v"},[1]],true],"B": {"C": 1} }';
|
||||||
|
SELECT JSON_VALUE(@json,'$.A[last-1][last-1].key1');
|
||||||
|
JSON_VALUE(@json,'$.A[last-1][last-1].key1')
|
||||||
|
NULL
|
||||||
|
SET @json='{ "A": [ [{"k":"v"},[1]],true],"B": {"C": 1} }';
|
||||||
|
SET collation_connection='ucs2_bin';
|
||||||
|
SELECT JSON_VALUE(@json,'$.A[last-1][last-1].key1');
|
||||||
|
JSON_VALUE(@json,'$.A[last-1][last-1].key1')
|
||||||
|
NULL
|
||||||
|
SET @json='{ "A": [ [{"k":"v"},[15]],true],"B": {"C": 1} }';
|
||||||
|
SET sql_mode=0,character_set_connection=utf32;
|
||||||
|
SELECT JSON_VALUE(@json,'$.A[last-1][last-1].key1');
|
||||||
|
JSON_VALUE(@json,'$.A[last-1][last-1].key1')
|
||||||
|
NULL
|
||||||
|
SET @json='{ "A": [ [{"k":"v"},[15]],true],"B": {"C": 1} }';
|
||||||
|
SET sql_mode=0,character_set_connection=utf32;
|
||||||
|
SELECT JSON_VALUE(@json,'$.A[last-1][last-1].key1');
|
||||||
|
JSON_VALUE(@json,'$.A[last-1][last-1].key1')
|
||||||
|
NULL
|
||||||
|
SET @@collation_connection= @save_collation_connection;
|
||||||
|
#
|
||||||
# End of 10.9 Test
|
# End of 10.9 Test
|
||||||
#
|
#
|
||||||
|
@ -1772,6 +1772,32 @@ DROP TABLE t1;
|
|||||||
SELECT JSON_EXTRACT('{ "my-key": 1 }', '$."my-key"');
|
SELECT JSON_EXTRACT('{ "my-key": 1 }', '$."my-key"');
|
||||||
SELECT JSON_EXTRACT('{ "my-key": 1 }', '$.my-key');
|
SELECT JSON_EXTRACT('{ "my-key": 1 }', '$.my-key');
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-23187: Assorted assertion failures in json_find_path with certain collations
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
|
||||||
|
SET @save_collation_connection= @@collation_connection;
|
||||||
|
|
||||||
|
SET @json='{ "A": [ [{"k":"v"},[1]],true],"B": {"C": 1} }';
|
||||||
|
SELECT JSON_VALUE(@json,'$.A[last-1][last-1].key1');
|
||||||
|
|
||||||
|
SET @json='{ "A": [ [{"k":"v"},[1]],true],"B": {"C": 1} }';
|
||||||
|
SET collation_connection='ucs2_bin';
|
||||||
|
SELECT JSON_VALUE(@json,'$.A[last-1][last-1].key1');
|
||||||
|
|
||||||
|
SET @json='{ "A": [ [{"k":"v"},[15]],true],"B": {"C": 1} }';
|
||||||
|
SET sql_mode=0,character_set_connection=utf32;
|
||||||
|
SELECT JSON_VALUE(@json,'$.A[last-1][last-1].key1');
|
||||||
|
|
||||||
|
|
||||||
|
SET @json='{ "A": [ [{"k":"v"},[15]],true],"B": {"C": 1} }';
|
||||||
|
SET sql_mode=0,character_set_connection=utf32;
|
||||||
|
SELECT JSON_VALUE(@json,'$.A[last-1][last-1].key1');
|
||||||
|
|
||||||
|
SET @@collation_connection= @save_collation_connection;
|
||||||
|
|
||||||
|
|
||||||
--echo #
|
--echo #
|
||||||
--echo # End of 10.9 Test
|
--echo # End of 10.9 Test
|
||||||
--echo #
|
--echo #
|
||||||
|
@ -1324,7 +1324,7 @@ int json_skip_key(json_engine_t *j)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define SKIPPED_STEP_MARK ((int) ~0)
|
#define SKIPPED_STEP_MARK INT_MAX32
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Current step of the patch matches the JSON construction.
|
Current step of the patch matches the JSON construction.
|
||||||
|
Reference in New Issue
Block a user