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

Optimise AST rewriting #17623

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
557 changes: 0 additions & 557 deletions go/vt/sqlparser/ast_rewriting.go

This file was deleted.

565 changes: 0 additions & 565 deletions go/vt/sqlparser/ast_rewriting_test.go

This file was deleted.

18 changes: 4 additions & 14 deletions go/vt/sqlparser/bind_var_needs.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,7 @@ type BindVarNeeds struct {
NeedSystemVariable,
// NeedUserDefinedVariables keeps track of all user defined variables a query is using
NeedUserDefinedVariables []string
otherRewrites bool
}

// MergeWith adds bind vars needs coming from sub scopes
func (bvn *BindVarNeeds) MergeWith(other *BindVarNeeds) {
bvn.NeedFunctionResult = append(bvn.NeedFunctionResult, other.NeedFunctionResult...)
bvn.NeedSystemVariable = append(bvn.NeedSystemVariable, other.NeedSystemVariable...)
bvn.NeedUserDefinedVariables = append(bvn.NeedUserDefinedVariables, other.NeedUserDefinedVariables...)
otherRewrites int
}

// AddFuncResult adds a function bindvar need
Expand Down Expand Up @@ -58,14 +51,11 @@ func (bvn *BindVarNeeds) NeedsSysVar(name string) bool {
}

func (bvn *BindVarNeeds) NoteRewrite() {
bvn.otherRewrites = true
bvn.otherRewrites++
}

func (bvn *BindVarNeeds) HasRewrites() bool {
return bvn.otherRewrites ||
len(bvn.NeedFunctionResult) > 0 ||
len(bvn.NeedUserDefinedVariables) > 0 ||
len(bvn.NeedSystemVariable) > 0
func (bvn *BindVarNeeds) NumberOfRewrites() int {
return len(bvn.NeedFunctionResult) + len(bvn.NeedUserDefinedVariables) + len(bvn.NeedSystemVariable) + bvn.otherRewrites
}

func contains(strings []string, name string) bool {
Expand Down
Loading
Loading