Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugin: Support Pre-parse Query Rewrite for Audit plugins #10913

Open
kennytm opened this issue Jun 23, 2019 · 1 comment
Open

plugin: Support Pre-parse Query Rewrite for Audit plugins #10913

kennytm opened this issue Jun 23, 2019 · 1 comment
Assignees
Labels
component/plugin feature/accepted This feature request is accepted by product managers type/feature-request This is a feature requests on the product

Comments

@kennytm
Copy link
Contributor

kennytm commented Jun 23, 2019

Feature Request

Is your feature request related to a problem? Please describe:

In MySQL, Pre-parse Query rewrite plugin is the way to provide custom SQL syntax (example). Query rewrite plugin is a subtype of Audit plugin, and TiDB does support an OnParseEvent hook. Unfortunately OnParseEvent is not invoked anywhere, and is not in the correct shape to allow actual query rewriting.

Describe the feature you'd like:

Remove OnParseEvent, and introduce a RewriteSQL field for rewriting the query before parsing.

struct {
    RewriteSQL func(
        ctx context.Context, 
        sctx *variable.SessionVars, 
        sql string,
    ) (string, error)
}

The RewriteSQL for each plugin should be invoked inside session.Parse() before calling parser.New().

RewriteSQL should be expected to run for a long time (e.g. more than 1 week) as long as ctx is not done.

It is unspecified what should happen if multiple Query Rewrite plugins coexist.

Describe alternatives you've considered:

None.

If we want to support Post-parse Query rewrite plugins too, it could be named RewriteAST accepting those []ast.StmtNode.

Teachability, Documentation, Adoption, Migration Strategy:

@zz-jason zz-jason added type/feature-request This is a feature requests on the product and removed type/new-feature labels Apr 3, 2020
@zz-jason
Copy link
Member

zz-jason commented Apr 3, 2020

@lysu PTAL

@github-actions github-actions bot added this to Need Triage in Feature Request Kanban Apr 3, 2020
@zz-jason zz-jason moved this from Need Triage to Accepted: Priority/Unknown in Feature Request Kanban Jul 22, 2020
@zz-jason zz-jason added the feature/accepted This feature request is accepted by product managers label Jul 29, 2020
@scsldb scsldb moved this from Accepted: Priority/Unknown to Accepted in Feature Request Kanban Jul 29, 2020
@lysu lysu assigned bb7133 and unassigned lysu Sep 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/plugin feature/accepted This feature request is accepted by product managers type/feature-request This is a feature requests on the product
Projects
Development

No branches or pull requests

4 participants