Type:
Bug
Priority:
Major
Resolution:
Fixed
Affects Version/s:
10.6.7 , 10.7.3 , 10.8.2 , 10.8.3 , 10.9.1
Environment:
Rockylinux 8 arm64
Hi, I'm GSoC 2022 contributor, I'm working on the MCOL-785.
Now I have a problem: The JSON Function result is truncated when the function is called based on LONGTEXT field.
Take the JSON_ARRAY as an example:
MariaDB root@(none):test> create table t1(t TEXT, l LONGTEXT) engine=columnstore;
Query OK, 0 rows affected
Time: 0.147s
MariaDB root@(none):test> insert into t1 values('key1', 'key1');
Query OK, 1 row affected
Time: 0.179s
MariaDB root@(none):test> select json_array(t), json_array(l) from t1;
+---------------+---------------+
| json_array(t) | json_array(l) |
+---------------+---------------+
| ["key1"] | ["key |
+---------------+---------------+
1 row in set
Time: 0.097s
MariaDB root@(none):test>
After debugging, I found that such difference is caused by overflow error.
bool Item_func_json_array::fix_length_and_dec(THD *thd)
{
ulonglong char_length= 2;
...
for (n_arg=0 ; n_arg < arg_count ; n_arg++)
char_length+= args[n_arg]->max_char_length() + 4;
...
}
First, the return type of args[n_arg] - >max_char_length() is uint32, the max value of uint32 is 4,294,967,295.
When called based on LONGTEXT, the result of args[n_arg] - >max_char_length() is 4,294,967,295(Maximum value of LONGTEXT). So args[n_arg] ->max_char_length()+4 will be 3 due to overflow. And there is no overflow when calling based on TEXT.
I will make a patch to this issue. I would be very grateful if you can handle it soon.
same issues exist in JSON_OBJECT, JSON_ARRAY_APPEND(INSERT), JSON_INSERT(REPLACE|SET)
{"report":{"fcp":1138.8999998569489,"ttfb":229,"pageVisibility":"visible","entityId":113518,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"c8846098-c8a3-44ea-8cd8-07bad18f955a","navigationType":0,"readyForUser":1241.2000000476837,"redirectCount":0,"resourceLoadedEnd":1076.2000000476837,"resourceLoadedStart":236.59999990463257,"resourceTiming":[{"duration":372.90000009536743,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":236.59999990463257,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":236.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":609.5,"responseStart":0,"secureConnectionStart":0},{"duration":373.09999990463257,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2cib/820016/12ta74/2bf333562ca6724060a9d5f1535471f6/_/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":236.79999995231628,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":236.79999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":609.8999998569489,"responseStart":0,"secureConnectionStart":0},{"duration":382,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":237,"connectEnd":237,"connectStart":237,"domainLookupEnd":237,"domainLookupStart":237,"fetchStart":237,"redirectEnd":0,"redirectStart":0,"requestStart":237,"responseEnd":619,"responseStart":619,"secureConnectionStart":237},{"duration":511,"initiatorType":"script","name":"https://jira.mariadb.org/s/2d8175ec2fa4c816e8023260bd8c1786-CDN/lu2cib/820016/12ta74/2bf333562ca6724060a9d5f1535471f6/_/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":237.20000004768372,"connectEnd":237.20000004768372,"connectStart":237.20000004768372,"domainLookupEnd":237.20000004768372,"domainLookupStart":237.20000004768372,"fetchStart":237.20000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":237.20000004768372,"responseEnd":748.2000000476837,"responseStart":748.2000000476837,"secureConnectionStart":237.20000004768372},{"duration":515.3000001907349,"initiatorType":"script","name":"https://jira.mariadb.org/s/a9324d6758d385eb45c462685ad88f1d-CDN/lu2cib/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":237.39999985694885,"connectEnd":237.39999985694885,"connectStart":237.39999985694885,"domainLookupEnd":237.39999985694885,"domainLookupStart":237.39999985694885,"fetchStart":237.39999985694885,"redirectEnd":0,"redirectStart":0,"requestStart":237.39999985694885,"responseEnd":752.7000000476837,"responseStart":752.7000000476837,"secureConnectionStart":237.39999985694885},{"duration":515.6000001430511,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":237.59999990463257,"connectEnd":237.59999990463257,"connectStart":237.59999990463257,"domainLookupEnd":237.59999990463257,"domainLookupStart":237.59999990463257,"fetchStart":237.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":237.59999990463257,"responseEnd":753.2000000476837,"responseStart":753.2000000476837,"secureConnectionStart":237.59999990463257},{"duration":515.7999999523163,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":237.79999995231628,"connectEnd":237.79999995231628,"connectStart":237.79999995231628,"domainLookupEnd":237.79999995231628,"domainLookupStart":237.79999995231628,"fetchStart":237.79999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":237.79999995231628,"responseEnd":753.5999999046326,"responseStart":753.5999999046326,"secureConnectionStart":237.79999995231628},{"duration":542.6000001430511,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2cib/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":237.89999985694885,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":237.89999985694885,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":780.5,"responseStart":0,"secureConnectionStart":0},{"duration":516,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":238.09999990463257,"connectEnd":238.09999990463257,"connectStart":238.09999990463257,"domainLookupEnd":238.09999990463257,"domainLookupStart":238.09999990463257,"fetchStart":238.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":238.09999990463257,"responseEnd":754.0999999046326,"responseStart":754.0999999046326,"secureConnectionStart":238.09999990463257},{"duration":542.2999999523163,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2cib/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":238.29999995231628,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":238.29999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":780.5999999046326,"responseStart":0,"secureConnectionStart":0},{"duration":516.3000001907349,"initiatorType":"script","name":"https://jira.mariadb.org/s/5d5e8fe91fbc506585e83ea3b62ccc4b-CDN/lu2cib/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":238.39999985694885,"connectEnd":238.39999985694885,"connectStart":238.39999985694885,"domainLookupEnd":238.39999985694885,"domainLookupStart":238.39999985694885,"fetchStart":238.39999985694885,"redirectEnd":0,"redirectStart":0,"requestStart":238.39999985694885,"responseEnd":754.7000000476837,"responseStart":754.7000000476837,"secureConnectionStart":238.39999985694885},{"duration":686.7000000476837,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":244.09999990463257,"connectEnd":244.09999990463257,"connectStart":244.09999990463257,"domainLookupEnd":244.09999990463257,"domainLookupStart":244.09999990463257,"fetchStart":244.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":244.09999990463257,"responseEnd":930.7999999523163,"responseStart":930.7999999523163,"secureConnectionStart":244.09999990463257},{"duration":687.7999999523163,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":244.20000004768372,"connectEnd":244.20000004768372,"connectStart":244.20000004768372,"domainLookupEnd":244.20000004768372,"domainLookupStart":244.20000004768372,"fetchStart":244.20000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":244.20000004768372,"responseEnd":932,"responseStart":932,"secureConnectionStart":244.20000004768372},{"duration":56.200000047683716,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":795.7999999523163,"connectEnd":795.7999999523163,"connectStart":795.7999999523163,"domainLookupEnd":795.7999999523163,"domainLookupStart":795.7999999523163,"fetchStart":795.7999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":795.7999999523163,"responseEnd":852,"responseStart":852,"secureConnectionStart":795.7999999523163},{"duration":219.80000019073486,"initiatorType":"link","name":"https://jira.mariadb.org/s/d5715adaadd168a9002b108b2b039b50-CDN/lu2cib/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/css/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":856.3999998569489,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":856.3999998569489,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1076.2000000476837,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":68,"responseStart":229,"responseEnd":237,"domLoading":234,"domInteractive":1374,"domContentLoadedEventStart":1374,"domContentLoadedEventEnd":1432,"domComplete":2762,"loadEventStart":2762,"loadEventEnd":2764,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1356.3999998569489},{"name":"bigPipe.sidebar-id.end","time":1357.2999999523163},{"name":"bigPipe.activity-panel-pipe-id.start","time":1357.5},{"name":"bigPipe.activity-panel-pipe-id.end","time":1360.2000000476837},{"name":"activityTabFullyLoaded","time":1444.7000000476837}],"measures":[],"correlationId":"c54a043e050bd5","effectiveType":"4g","downlink":9.5,"rtt":0,"serverDuration":98,"dbReadsTimeInMs":10,"dbConnsTimeInMs":18,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}