Following on from the comment about the non-working example in MDEV-12877 that MySQL and MariaDB behave the same - they don't in that MySQL gives an error, MariaDB a warning. Is this desirable? Doesn't an error make more sense here?
MySQL 5.7:
SELECT JSON_SEARCH(@json, 'onee', 'AB');
|
ERROR 3154 (42000): The oneOrAll argument to json_search may take these values: 'one' or 'all'.
|
|
select json_extract(json_object('truc',json_array('machin',4,json_object('chose','XML'))),json_search(json_object('truc',json_array('machin',4,json_object('chose','XML'))),'one','XML')) as Result;
|
ERROR 3143 (42000): Invalid JSON path expression. The error is around character position 1.
|
MariaDB 10.2
SELECT JSON_SEARCH(@json, 'onee', 'AB');
|
+----------------------------------+
|
| JSON_SEARCH(@json, 'onee', 'AB') |
|
+----------------------------------+
|
| NULL |
|
+----------------------------------+
|
1 row in set, 1 warning (0.00 sec)
|
|
SHOW WARNINGS;
|
+---------+------+--------------------------------------------------------------+
|
| Level | Code | Message |
|
+---------+------+--------------------------------------------------------------+
|
| Warning | 4046 | Argument 2 to function 'json_search' must be "one" or "all". |
|
+---------+------+--------------------------------------------------------------+
|
|
select json_extract(json_object('truc',json_array('machin',4,json_object('chose','XML'))),json_search(json_object('truc',json_array('machin',4,json_object('chose','XML'))),'one','XML')) as Result;
|
+--------+
|
| Result |
|
+--------+
|
| NULL |
|
+--------+
|
1 row in set, 1 warning (0.00 sec)
|
|
mysql [localhost] {msandbox} (test) > SHOW WARNINGS;
|
+---------+------+----------------------------------------------------------------------------------+
|
| Level | Code | Message |
|
+---------+------+----------------------------------------------------------------------------------+
|
| Warning | 4042 | Syntax error in JSON path in argument 2 to function 'json_extract' at position 1 |
|
+---------+------+----------------------------------------------------------------------------------+
|
- relates to
-
MDEV-12877
Wrong result from JSON native function.
-
-
Closed
{"report":{"fcp":783.8999999761581,"ttfb":232.69999998807907,"pageVisibility":"visible","entityId":63120,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"511d12b1-d31e-4e97-9bad-b6431792e081","navigationType":0,"readyForUser":862.0999999642372,"redirectCount":0,"resourceLoadedEnd":525.0999999642372,"resourceLoadedStart":240.39999997615814,"resourceTiming":[{"duration":9.800000011920929,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bv2/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":240.39999997615814,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":240.39999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":250.19999998807907,"responseStart":0,"secureConnectionStart":0},{"duration":10.300000011920929,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2bv2/820016/12ta74/2380add21a9a1006587582385952de73/_/download/contextbatch/css/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":240.5999999642372,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":240.5999999642372,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":250.89999997615814,"responseStart":0,"secureConnectionStart":0},{"duration":154.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/e9b27a47da5fb0f74a35acd57e9847fb-CDN/lu2bv2/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":240.79999995231628,"connectEnd":240.79999995231628,"connectStart":240.79999995231628,"domainLookupEnd":240.79999995231628,"domainLookupStart":240.79999995231628,"fetchStart":240.79999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":255.5999999642372,"responseEnd":395.2999999523163,"responseStart":280.2999999523163,"secureConnectionStart":240.79999995231628},{"duration":261.89999997615814,"initiatorType":"script","name":"https://jira.mariadb.org/s/c32eb0da7ad9831253f8397e6cc26afd-CDN/lu2bv2/820016/12ta74/2380add21a9a1006587582385952de73/_/download/contextbatch/js/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true","startTime":241,"connectEnd":241,"connectStart":241,"domainLookupEnd":241,"domainLookupStart":241,"fetchStart":241,"redirectEnd":0,"redirectStart":0,"requestStart":256.2999999523163,"responseEnd":502.89999997615814,"responseStart":282,"secureConnectionStart":241},{"duration":44.19999998807907,"initiatorType":"script","name":"https://jira.mariadb.org/s/bc0bcb146314416123c992714ee00ff7-CDN/lu2bv2/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":241.0999999642372,"connectEnd":241.0999999642372,"connectStart":241.0999999642372,"domainLookupEnd":241.0999999642372,"domainLookupStart":241.0999999642372,"fetchStart":241.0999999642372,"redirectEnd":0,"redirectStart":0,"requestStart":257.19999998807907,"responseEnd":285.2999999523163,"responseStart":283.39999997615814,"secureConnectionStart":241.0999999642372},{"duration":46.19999998807907,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":241.39999997615814,"connectEnd":241.39999997615814,"connectStart":241.39999997615814,"domainLookupEnd":241.39999997615814,"domainLookupStart":241.39999997615814,"fetchStart":241.39999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":257.89999997615814,"responseEnd":287.5999999642372,"responseStart":284.0999999642372,"secureConnectionStart":241.39999997615814},{"duration":46.59999996423721,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":241.5,"connectEnd":241.5,"connectStart":241.5,"domainLookupEnd":241.5,"domainLookupStart":241.5,"fetchStart":241.5,"redirectEnd":0,"redirectStart":0,"requestStart":259.19999998807907,"responseEnd":288.0999999642372,"responseStart":285.5,"secureConnectionStart":241.5},{"duration":14.199999988079071,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2bv2/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":241.69999998807907,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":241.69999998807907,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":255.89999997615814,"responseStart":0,"secureConnectionStart":0},{"duration":46.5,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":241.89999997615814,"connectEnd":241.89999997615814,"connectStart":241.89999997615814,"domainLookupEnd":241.89999997615814,"domainLookupStart":241.89999997615814,"fetchStart":241.89999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":259.7999999523163,"responseEnd":288.39999997615814,"responseStart":286,"secureConnectionStart":241.89999997615814},{"duration":15.399999976158142,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2bv2/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/css/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.css?jira.create.linked.issue=true","startTime":242.19999998807907,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":242.19999998807907,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":257.5999999642372,"responseStart":0,"secureConnectionStart":0},{"duration":46.19999998807907,"initiatorType":"script","name":"https://jira.mariadb.org/s/719848dd97ebe0663199f49a3936487a-CDN/lu2bv2/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/js/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.js?jira.create.linked.issue=true&locale=en","startTime":242.39999997615814,"connectEnd":242.39999997615814,"connectStart":242.39999997615814,"domainLookupEnd":242.39999997615814,"domainLookupStart":242.39999997615814,"fetchStart":242.39999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":260.39999997615814,"responseEnd":288.5999999642372,"responseStart":286.39999997615814,"secureConnectionStart":242.39999997615814},{"duration":272.10000002384186,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":251.89999997615814,"connectEnd":251.89999997615814,"connectStart":251.89999997615814,"domainLookupEnd":251.89999997615814,"domainLookupStart":251.89999997615814,"fetchStart":251.89999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":276.69999998807907,"responseEnd":524,"responseStart":517.7999999523163,"secureConnectionStart":251.89999997615814},{"duration":268.0999999642372,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":257,"connectEnd":257,"connectStart":257,"domainLookupEnd":257,"domainLookupStart":257,"fetchStart":257,"redirectEnd":0,"redirectStart":0,"requestStart":277.19999998807907,"responseEnd":525.0999999642372,"responseStart":520.0999999642372,"secureConnectionStart":257},{"duration":116.30000001192093,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":542.6999999880791,"connectEnd":542.6999999880791,"connectStart":542.6999999880791,"domainLookupEnd":542.6999999880791,"domainLookupStart":542.6999999880791,"fetchStart":542.6999999880791,"redirectEnd":0,"redirectStart":0,"requestStart":618.2999999523163,"responseEnd":659,"responseStart":658.2999999523163,"secureConnectionStart":542.6999999880791}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":26,"responseStart":233,"responseEnd":257,"domLoading":236,"domInteractive":954,"domContentLoadedEventStart":954,"domContentLoadedEventEnd":997,"domComplete":1414,"loadEventStart":1414,"loadEventEnd":1414,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":936.1999999880791},{"name":"bigPipe.sidebar-id.end","time":937},{"name":"bigPipe.activity-panel-pipe-id.start","time":937.0999999642372},{"name":"bigPipe.activity-panel-pipe-id.end","time":938},{"name":"activityTabFullyLoaded","time":1016.5}],"measures":[],"correlationId":"a92b42c2ac3144","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":107,"dbReadsTimeInMs":19,"dbConnsTimeInMs":28,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
Unfortunately yes, this is intended.
Our justification is that we've decided to follow standard, which sets the default behavior to be NULL ON ERROR. Standard also describes non-default behavior, configured by ON ERROR clause, but it hasn't been implemented (yet?).
Since standard does not seem to prohibit warnings, our compromise was to at least produce warnings.
More discussion in
MDEV-11826.