Details
-
Task
-
Status: Open (View Workflow)
-
Minor
-
Resolution: Unresolved
-
None
-
None
-
None
Description
Implement some new functions (maybe UDF),
1)return a JSON object with token tree of SQL parser, example
SELECT SQL_TOKEN_TREE(
|
"SELECT * FROM (SELECT 1 AS a) AS b WHERE a=@var"
|
)
|
Result
{Query:[select, *, from, [select, var<1>, as, const<a>], as, const<b>, where, var<2>, =, var<3>], vars:{1:'1', 2:'a',3:'@var','@var':'qwert'}}
|
Or something more intelligent since i don't know how mysql parser works
2)SQL_TOKEN_SQL(sql tree)
Result a string removing consts with a willchar (like prepared statments)
SELECT * FROM TABLE WHERE A=1234
|
should return
SELECT * FROM TABLE WHERE A=?
|
this is something like percona tools, but it run inside server with server parse and not a third part parser:
$pt-fingerprint --query "/* -- S++ SU ABORTABLE -- spd_user: rspadim */SELECT SQL_SMALL_RESULT SQL_CACHE DISTINCT centro_atividade FROM est_dia WHERE unidade_id=1001 AND item_id=67 AND item_id_red=573"
|
 |
SELECT DISTINCT centro_atividade FROM est_dia WHERE unidade_id=? AND item_id=? AND item_id_red=?
|
3)Add a SQL_PARSER_OPTIMIZE(QUERY)
it parse the query and execute optimizations (opt_range and others)
example
SELECT * FROM TABLE WHERE A=1234 AND 0=0
|
rewrite to
SELECT * FROM TABLE WHERE A=1234
|
Attachments
Issue Links
- relates to
-
MDEV-5561 Query Rewrite Plugin API
- Open
-
MDEV-26634 Feature request: add STATEMENT_DIGEST_TEXT
- Closed
-
MDEV-6882 TOKENIZE query
- Open
-
MDEV-8943 Syntax check for SQL files or SQL queries
- Open