Type:
Task
Priority:
Major
Resolution:
Fixed
In some cases the code in *.yy files related to expression parsed in their own LEX is hard to modify: reset_lex() and its correspoding restore_lex() reside in different grammar rules or different LEX methods.
In order to simplify this (and later join sql_yacc.yy and sql_yacc_ora.yy easier), let's add a class representing an expression (Item) pointer and its LEX (that was used to parse this expression).
Additionally, let's
Move a few methods from LEX to sp_expr_lex
Add a new sp_expr_lex method sp_repeat_loop_finalize()
Add a new sp_expr_lex method sp_if_expr()
The tentative class structure is:
class sp_expr_lex: public sp_lex_local
{
Item *m_item; // The expression
public :
sp_expr_lex(THD *thd, LEX *oldlex)
:sp_lex_local(thd, oldlex),
m_item(NULL)
{ }
void set_item(Item *item)
{
m_item= item;
}
Item *get_item() const
{
return m_item;
}
// The following methods are to be moved from LEX
bool sp_continue_when_statement(THD *thd);
bool sp_continue_when_statement(THD *thd, const LEX_CSTRING *label_name);
int case_stmt_action_expr();
int case_stmt_action_when( bool simple);
bool sp_while_loop_expression(THD *thd)
{
return LEX::sp_while_loop_expression(thd, get_item());
}
// The following methods are new, to simpify the code in *.yy:
bool sp_repeat_loop_finalize(THD *thd);
bool sp_if_expr(THD *thd);
};
The new rule that creates sp_expr_lex (i.e. LEX+Item) will look like this:
expr_lex:
{
DBUG_ASSERT(Lex->sphead);
if (unlikely(!($<expr_lex>$= new (thd->mem_root)
sp_expr_lex(thd, thd->lex))))
MYSQL_YYABORT;
Lex->sphead->reset_lex(thd, $<expr_lex>$);
}
expr
{
$$= $<expr_lex>1;
$$->sp_lex_in_use= true ;
$$->set_item($2);
if ($$->sphead->restore_lex(thd))
MYSQL_YYABORT;
}
;
After these changes, it will be much easier to move grammar rules, because reset_lex() and its corresponding restore_lex() will reside inside the same rule expr_lex . A lot of restore_lex() calls will be gone.
blocks
MDEV-12518
Unify sql_yacc.yy and sql_yacc_ora.yy
Closed
{"report":{"fcp":1017.8999996185303,"ttfb":223,"pageVisibility":"visible","entityId":80481,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"448f76f7-6d9f-47e5-b4b4-6ba66e6628a3","navigationType":0,"readyForUser":1099.0999994277954,"redirectCount":0,"resourceLoadedEnd":1174.0999994277954,"resourceLoadedStart":229.19999980926514,"resourceTiming":[{"duration":268.69999980926514,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":229.19999980926514,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":229.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":497.8999996185303,"responseStart":0,"secureConnectionStart":0},{"duration":268.80000019073486,"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":229.39999961853027,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":229.39999961853027,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":498.19999980926514,"responseStart":0,"secureConnectionStart":0},{"duration":277.80000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":229.5999994277954,"connectEnd":229.5999994277954,"connectStart":229.5999994277954,"domainLookupEnd":229.5999994277954,"domainLookupStart":229.5999994277954,"fetchStart":229.5999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":229.5999994277954,"responseEnd":507.3999996185303,"responseStart":507.3999996185303,"secureConnectionStart":229.5999994277954},{"duration":305.69999980926514,"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":229.80000019073486,"connectEnd":229.80000019073486,"connectStart":229.80000019073486,"domainLookupEnd":229.80000019073486,"domainLookupStart":229.80000019073486,"fetchStart":229.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":229.80000019073486,"responseEnd":535.5,"responseStart":535.5,"secureConnectionStart":229.80000019073486},{"duration":310.19999980926514,"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":230,"connectEnd":230,"connectStart":230,"domainLookupEnd":230,"domainLookupStart":230,"fetchStart":230,"redirectEnd":0,"redirectStart":0,"requestStart":230,"responseEnd":540.1999998092651,"responseStart":540.1999998092651,"secureConnectionStart":230},{"duration":311.19999980926514,"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":230.30000019073486,"connectEnd":230.30000019073486,"connectStart":230.30000019073486,"domainLookupEnd":230.30000019073486,"domainLookupStart":230.30000019073486,"fetchStart":230.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":230.30000019073486,"responseEnd":541.5,"responseStart":541.5,"secureConnectionStart":230.30000019073486},{"duration":313.3999996185303,"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":230.5,"connectEnd":230.5,"connectStart":230.5,"domainLookupEnd":230.5,"domainLookupStart":230.5,"fetchStart":230.5,"redirectEnd":0,"redirectStart":0,"requestStart":230.5,"responseEnd":543.8999996185303,"responseStart":543.8999996185303,"secureConnectionStart":230.5},{"duration":453.5,"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":230.69999980926514,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":230.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":684.1999998092651,"responseStart":0,"secureConnectionStart":0},{"duration":314.69999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":230.80000019073486,"connectEnd":230.80000019073486,"connectStart":230.80000019073486,"domainLookupEnd":230.80000019073486,"domainLookupStart":230.80000019073486,"fetchStart":230.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":230.80000019073486,"responseEnd":545.5,"responseStart":545.5,"secureConnectionStart":230.80000019073486},{"duration":453.3999996185303,"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":231,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":231,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":684.3999996185303,"responseStart":0,"secureConnectionStart":0},{"duration":317.8999996185303,"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":231.19999980926514,"connectEnd":231.19999980926514,"connectStart":231.19999980926514,"domainLookupEnd":231.19999980926514,"domainLookupStart":231.19999980926514,"fetchStart":231.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":231.19999980926514,"responseEnd":549.0999994277954,"responseStart":549.0999994277954,"secureConnectionStart":231.19999980926514},{"duration":566.6000003814697,"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":232.19999980926514,"connectEnd":232.19999980926514,"connectStart":232.19999980926514,"domainLookupEnd":232.19999980926514,"domainLookupStart":232.19999980926514,"fetchStart":232.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":232.19999980926514,"responseEnd":798.8000001907349,"responseStart":798.8000001907349,"secureConnectionStart":232.19999980926514},{"duration":941.7999992370605,"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":232.30000019073486,"connectEnd":232.30000019073486,"connectStart":232.30000019073486,"domainLookupEnd":232.30000019073486,"domainLookupStart":232.30000019073486,"fetchStart":232.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":232.30000019073486,"responseEnd":1174.0999994277954,"responseStart":1174.0999994277954,"secureConnectionStart":232.30000019073486},{"duration":320.8999996185303,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":756.6999998092651,"connectEnd":756.6999998092651,"connectStart":756.6999998092651,"domainLookupEnd":756.6999998092651,"domainLookupStart":756.6999998092651,"fetchStart":756.6999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":756.6999998092651,"responseEnd":1077.5999994277954,"responseStart":1077.5999994277954,"secureConnectionStart":756.6999998092651}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":60,"responseStart":223,"responseEnd":227,"domLoading":227,"domInteractive":1194,"domContentLoadedEventStart":1194,"domContentLoadedEventEnd":1235,"domComplete":2056,"loadEventStart":2057,"loadEventEnd":2058,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1176.0999994277954},{"name":"bigPipe.sidebar-id.end","time":1177},{"name":"bigPipe.activity-panel-pipe-id.start","time":1177.1999998092651},{"name":"bigPipe.activity-panel-pipe-id.end","time":1179.8000001907349},{"name":"activityTabFullyLoaded","time":1242.0999994277954}],"measures":[],"correlationId":"9e8d3b1c83f2ba","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":95,"dbReadsTimeInMs":10,"dbConnsTimeInMs":18,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}