The idea discussed during a meeting: move args[0]->charset_for_protocol() call to the preparation phase (fix_fields()) and remember the charset returned:
So we can safely set used_tables() to return 0 and avoid referring to arguments (args[0]) during the execution phase (call to val_str() is made during the execution).
Oleg Smirnov
added a comment - The idea discussed during a meeting: move args [0] ->charset_for_protocol() call to the preparation phase ( fix_fields() ) and remember the charset returned:
String *Item_func_charset::val_str(String *str)
{
DBUG_ASSERT(fixed());
uint dummy_errors;
CHARSET_INFO *cs= args[0]->charset_for_protocol();
null_value= 0;
str->copy(cs->cs_name.str, cs->cs_name.length,
&my_charset_latin1, collation.collation, &dummy_errors);
return str;
}
So we can safely set used_tables() to return 0 and avoid referring to arguments (args [0] ) during the execution phase (call to val_str() is made during the execution).
I have just one small suggestion: Please change the data type of the new member from:
CHARSET_INFO *m_cached_charset_info;
to
LEX_CSTRING m_cached_charset_info;
to avoid strlen() evaluation per row by evaluating it during fix_length_and_dec() instead.
Note, starting from 10.6 CHARSET_INFO was modified:
const char *csname;
was changed to:
LEX_CSTRING cs_name;
So starting from 10.6 strlen() won't be needed even in fix_length_and_dec().
Alexander Barkov
added a comment - Hi oleg.smirnov ,
the patch is OK to push.
I have just one small suggestion: Please change the data type of the new member from:
CHARSET_INFO *m_cached_charset_info;
to
LEX_CSTRING m_cached_charset_info;
to avoid strlen() evaluation per row by evaluating it during fix_length_and_dec() instead.
Note, starting from 10.6 CHARSET_INFO was modified:
const char *csname;
was changed to:
LEX_CSTRING cs_name;
So starting from 10.6 strlen() won't be needed even in fix_length_and_dec().
Note for the changelog: if a query used a derived table DT (a CTE or a
mergeable VIEW would work as well) and the WHERE clause compared columns
of DT with the value of CHARSET() or COERCIBILITY() function, the query
could produce wrong result or crash. The cause was incorrect processing
of these functions by derived condition pushdown optimization ( https://mariadb.com/kb/en/condition-pushdown-into-derived-table-optimization/)
Sergei Petrunia
added a comment - Note for the changelog: if a query used a derived table DT (a CTE or a
mergeable VIEW would work as well) and the WHERE clause compared columns
of DT with the value of CHARSET() or COERCIBILITY() function, the query
could produce wrong result or crash. The cause was incorrect processing
of these functions by derived condition pushdown optimization (
https://mariadb.com/kb/en/condition-pushdown-into-derived-table-optimization/ )
People
Oleg Smirnov
John Jove
Votes:
0Vote for this issue
Watchers:
7Start watching this issue
Dates
Created:
Updated:
Resolved:
Git Integration
Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.
{"report":{"fcp":1556.2999999523163,"ttfb":454.6999999284744,"pageVisibility":"visible","entityId":126908,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"2d65f8b3-877e-431c-b4cb-57a7bcafeacb","navigationType":0,"readyForUser":1646,"redirectCount":0,"resourceLoadedEnd":2179,"resourceLoadedStart":490.59999990463257,"resourceTiming":[{"duration":569.4000000953674,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":490.59999990463257,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":490.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1060,"responseStart":0,"secureConnectionStart":0},{"duration":569.3999999761581,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/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&whisper-enabled=true","startTime":490.89999997615814,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":490.89999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1060.2999999523163,"responseStart":0,"secureConnectionStart":0},{"duration":578.4000000953674,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":491.09999990463257,"connectEnd":491.09999990463257,"connectStart":491.09999990463257,"domainLookupEnd":491.09999990463257,"domainLookupStart":491.09999990463257,"fetchStart":491.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":491.09999990463257,"responseEnd":1069.5,"responseStart":1069.5,"secureConnectionStart":491.09999990463257},{"duration":629.7000000476837,"initiatorType":"script","name":"https://jira.mariadb.org/s/2d8175ec2fa4c816e8023260bd8c1786-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/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&whisper-enabled=true","startTime":491.2999999523163,"connectEnd":491.2999999523163,"connectStart":491.2999999523163,"domainLookupEnd":491.2999999523163,"domainLookupStart":491.2999999523163,"fetchStart":491.2999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":491.2999999523163,"responseEnd":1121,"responseStart":1121,"secureConnectionStart":491.2999999523163},{"duration":633.7999999523163,"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":491.5,"connectEnd":491.5,"connectStart":491.5,"domainLookupEnd":491.5,"domainLookupStart":491.5,"fetchStart":491.5,"redirectEnd":0,"redirectStart":0,"requestStart":491.5,"responseEnd":1125.2999999523163,"responseStart":1125.2999999523163,"secureConnectionStart":491.5},{"duration":634.2000000476837,"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":491.6999999284744,"connectEnd":491.6999999284744,"connectStart":491.6999999284744,"domainLookupEnd":491.6999999284744,"domainLookupStart":491.6999999284744,"fetchStart":491.6999999284744,"redirectEnd":0,"redirectStart":0,"requestStart":491.6999999284744,"responseEnd":1125.8999999761581,"responseStart":1125.8999999761581,"secureConnectionStart":491.6999999284744},{"duration":635.2000000476837,"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":491.7999999523163,"connectEnd":491.7999999523163,"connectStart":491.7999999523163,"domainLookupEnd":491.7999999523163,"domainLookupStart":491.7999999523163,"fetchStart":491.7999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":491.7999999523163,"responseEnd":1127,"responseStart":1127,"secureConnectionStart":491.7999999523163},{"duration":733.1999999284744,"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":492,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":492,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1225.1999999284744,"responseStart":0,"secureConnectionStart":0},{"duration":635.4000000953674,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":492.09999990463257,"connectEnd":492.09999990463257,"connectStart":492.09999990463257,"domainLookupEnd":492.09999990463257,"domainLookupStart":492.09999990463257,"fetchStart":492.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":492.09999990463257,"responseEnd":1127.5,"responseStart":1127.5,"secureConnectionStart":492.09999990463257},{"duration":733.1000000238419,"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":492.2999999523163,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":492.2999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1225.3999999761581,"responseStart":0,"secureConnectionStart":0},{"duration":635.7999999523163,"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":492.39999997615814,"connectEnd":492.39999997615814,"connectStart":492.39999997615814,"domainLookupEnd":492.39999997615814,"domainLookupStart":492.39999997615814,"fetchStart":492.39999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":492.39999997615814,"responseEnd":1128.1999999284744,"responseStart":1128.1999999284744,"secureConnectionStart":492.39999997615814},{"duration":1023.3999999761581,"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":493.1999999284744,"connectEnd":493.1999999284744,"connectStart":493.1999999284744,"domainLookupEnd":493.1999999284744,"domainLookupStart":493.1999999284744,"fetchStart":493.1999999284744,"redirectEnd":0,"redirectStart":0,"requestStart":493.1999999284744,"responseEnd":1516.5999999046326,"responseStart":1516.5999999046326,"secureConnectionStart":493.1999999284744},{"duration":1685.7000000476837,"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":493.2999999523163,"connectEnd":493.2999999523163,"connectStart":493.2999999523163,"domainLookupEnd":493.2999999523163,"domainLookupStart":493.2999999523163,"fetchStart":493.2999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":493.2999999523163,"responseEnd":2179,"responseStart":2179,"secureConnectionStart":493.2999999523163},{"duration":513.6000000238419,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":1238.7999999523163,"connectEnd":1238.7999999523163,"connectStart":1238.7999999523163,"domainLookupEnd":1238.7999999523163,"domainLookupStart":1238.7999999523163,"fetchStart":1238.7999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":1238.7999999523163,"responseEnd":1752.3999999761581,"responseStart":1752.3999999761581,"secureConnectionStart":1238.7999999523163},{"duration":705.7000000476837,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":1549.5999999046326,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1549.5999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":2255.2999999523163,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":275,"responseStart":455,"responseEnd":466,"domLoading":487,"domInteractive":2204,"domContentLoadedEventStart":2204,"domContentLoadedEventEnd":2251,"domComplete":2871,"loadEventStart":2871,"loadEventEnd":2872,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":2180.5999999046326},{"name":"bigPipe.sidebar-id.end","time":2181.2999999523163},{"name":"bigPipe.activity-panel-pipe-id.start","time":2181.5999999046326},{"name":"bigPipe.activity-panel-pipe-id.end","time":2183.5999999046326},{"name":"activityTabFullyLoaded","time":2267.7999999523163}],"measures":[],"correlationId":"b21f3feb6c69ef","effectiveType":"4g","downlink":9.3,"rtt":0,"serverDuration":113,"dbReadsTimeInMs":13,"dbConnsTimeInMs":26,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
The idea discussed during a meeting: move args[0]->charset_for_protocol() call to the preparation phase (fix_fields()) and remember the charset returned:
String *Item_func_charset::val_str(String *str)
{
DBUG_ASSERT(fixed());
uint dummy_errors;
CHARSET_INFO *cs= args[0]->charset_for_protocol();
null_value= 0;
str->copy(cs->cs_name.str, cs->cs_name.length,
&my_charset_latin1, collation.collation, &dummy_errors);
return str;
}
So we can safely set used_tables() to return 0 and avoid referring to arguments (args[0]) during the execution phase (call to val_str() is made during the execution).