Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
a80eb983
Commit
a80eb983
authored
Feb 12, 2023
by
Weijun Huang
Committed by
Daniel Black
Feb 14, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-24538: JSON_LENGTH does not return error upon wrong number of parameters
parent
cacea316
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
0 deletions
+21
-0
mysql-test/main/func_json.result
mysql-test/main/func_json.result
+7
-0
mysql-test/main/func_json.test
mysql-test/main/func_json.test
+9
-0
sql/item_jsonfunc.h
sql/item_jsonfunc.h
+5
-0
No files found.
mysql-test/main/func_json.result
View file @
a80eb983
...
...
@@ -1289,5 +1289,12 @@ JSON_LOOSE(JSON_EXTRACT(a, '$**.analyzing_range_alternatives'))
[{"range_scan_alternatives": [{"index": "a_b", "ranges": ["2 <= a <= 2 AND 4 <= b <= 4", "123"], "rowid_ordered": true, "using_mrr": false, "index_only": true, "rows": 1, "cost": 1.1752, "chosen": true}], "analyzing_roworder_intersect": {"cause": "too few roworder scans"}, "analyzing_index_merge_union": [], "test_one_line_array": ["123"]}]
drop table t200;
#
# MDEV-24538: JSON_LENGTH does not return error upon wrong number of parameters
#
SELECT JSON_LENGTH('{"a":"b"}','$','$', 'foo');
ERROR 42000: Incorrect parameter count in the call to native function 'json_length'
SELECT JSON_LENGTH();
ERROR 42000: Incorrect parameter count in the call to native function 'JSON_LENGTH'
#
# End of 10.4 tests
#
mysql-test/main/func_json.test
View file @
a80eb983
...
...
@@ -665,6 +665,7 @@ SELECT 1 + JSON_VALUE('{"nulltest": null}', '$.nulltest');
SELECT
NULL
;
SELECT
JSON_EXTRACT
(
'{"a":null, "b":10, "c":"null"}'
,
'$.a'
);
--
echo
#
--
echo
# End of 10.3 tests
--
echo
#
...
...
@@ -816,6 +817,14 @@ select JSON_PRETTY(JSON_EXTRACT(a, '$**.analyzing_range_alternatives')) from t20
select
JSON_LOOSE
(
JSON_EXTRACT
(
a
,
'$**.analyzing_range_alternatives'
))
from
t200
;
drop
table
t200
;
--
echo
#
--
echo
# MDEV-24538: JSON_LENGTH does not return error upon wrong number of parameters
--
echo
#
--
error
ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
SELECT
JSON_LENGTH
(
'{"a":"b"}'
,
'$'
,
'$'
,
'foo'
);
--
error
ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
SELECT
JSON_LENGTH
();
--
echo
#
--
echo
# End of 10.4 tests
--
echo
#
sql/item_jsonfunc.h
View file @
a80eb983
...
...
@@ -310,6 +310,11 @@ class Item_func_json_length: public Item_long_func
{
bool
check_arguments
()
const
{
if
(
arg_count
==
0
||
arg_count
>
2
)
{
my_error
(
ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
,
MYF
(
0
),
func_name
());
return
true
;
}
return
args
[
0
]
->
check_type_can_return_text
(
func_name
())
||
(
arg_count
>
1
&&
args
[
1
]
->
check_type_general_purpose_string
(
func_name
()));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment