Bug #86398 Allow tree visit for non-literals in Query Rewrite API
Submitted: 22 May 2017 8:10
Reporter: Daniël van Eeden (OCA) Email Updates:
Status: Open Impact on me:
None 
Category:MySQL Server: Parser Severity:S4 (Feature request)
Version:5.7.18 OS:Any
Assigned to: CPU Architecture:Any
Tags: post parser plugin, rewrite

[22 May 2017 8:10] Daniël van Eeden
Description:
It seems like mysql_parser_visit_tree() only allows one to visit the literals.
However it would be useful to be able to extract keywords after parsing.

e.g. for these queries:
/* sum */ select count(*) from dual;
select count(*) as sum from dual;
select `sum` from t1;
select sum(foo) from t1 group by bar;

If you only get the query string it is difficult to only replace/detect invocations of the sum functions and not other places. This could be used to replace sum() with a custom sum function/udf.

How to repeat:
Try to write a post parse plugin which acts on a function call in a query.