-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Generating copy-on-rewrite logic #12135
Conversation
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
If a new flag is being introduced:
If a workflow is added or modified:
Bug fixes
Non-trivial changes
New/Existing features
Backward compatibility
|
go/vt/sqlparser/cow.go
Outdated
} | ||
) | ||
|
||
func CopyOnRewrite(node SQLNode, pre func(node, parent SQLNode) bool, post func(cursor *CopyOnWriteCursor)) SQLNode { |
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.
comment
Signed-off-by: Andres Taylor <[email protected]>
} | ||
|
||
// StopTreeWalk aborts the current tree walking. No more nodes will be visited, and the rewriter will exit out early | ||
func (c *CopyOnWriteCursor) StopTreeWalk() { |
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.
Maybe we should use a recovered panic here instead of setting a boolean and checking it 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.
I thought that recover
was a source of performance loss
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
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.
Looks great. I discussed with @systay the unified interface for pre
/post
and I think this is a great design!
Signed-off-by: Andres Taylor <[email protected]>
Description
Adds a new syntax tree rewrite utility. It makes it possible to share parts of the syntax tree with the original, so it should decrease memory pressure somewhat during planning. It also traverses the tree only once to do both operations, before we first needed to clone the full tree and only after could we rewrite it.
Additionally, it can report back to the user which nodes got cloned, which makes it possible to copy semantic information between the two trees.
Related Issue(s)
Checklist