-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
extension: add extension API to listen stmt events #38789
Conversation
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
sessionctx/stmtctx/stmtctx.go
Outdated
@@ -104,6 +104,8 @@ func (warn *SQLWarn) UnmarshalJSON(data []byte) error { | |||
// StatementContext contains variables for a statement. | |||
// It should be reset before executing a statement. | |||
type StatementContext struct { | |||
// Expired will be true when a new query comes but the current StmtCtx is not reset yet | |||
Expired bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe we can hook RestStatementContext
? And use NotReset bool
instead of hooking Expired = true
everywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not easy to do this because after the first statement "reset" a stmt context and the stmt finished, we should change the NotReset
to false before RestStatementContext
of the next statement. It is the same of the current implement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still doubts this will race somehow. Maybe it is enough to copy some of the property instead of directly &sc
. Primitives like string or integer have little performance impact.
… github.com:lcwangchao/tidb into extension_stmt_events
/merge |
This pull request has been accepted and is ready to merge. Commit hash: ff9daff
|
TiDB MergeCI notify🔴 Bad News! New failing [1] after this pr merged.
|
What problem does this PR solve?
Issue Number: close #38788
What is changed and how it works?
add
OnStmtEvent
toSessionHandler
to handle stmt eventsCheck List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.