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

Optimize Join using Values Statement #16703

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from
Draft
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
3 changes: 3 additions & 0 deletions go/mysql/capabilities/capability.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const (
ReplicaTerminologyCapability // Supported in 8.0.26 and above, using SHOW REPLICA STATUS and all variations.
BinaryLogStatus // Supported in 8.2.0 and above, uses SHOW BINARY LOG STATUS
RestrictFKOnNonStandardKey // Supported in 8.4.0 and above, restricts usage of non-standard indexes for foreign keys.
ValuesRow // Supported in 8.0.19 and above: https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-19.html
)

type CapableOf func(capability FlavorCapability) (bool, error)
Expand Down Expand Up @@ -125,6 +126,8 @@ func MySQLVersionHasCapability(serverVersion string, capability FlavorCapability
return atLeast(8, 2, 0)
case RestrictFKOnNonStandardKey:
return atLeast(8, 4, 0)
case ValuesRow:
return atLeast(8, 0, 19)
default:
return false, nil
}
Expand Down
11 changes: 9 additions & 2 deletions go/vt/proto/query/query.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

125 changes: 70 additions & 55 deletions go/vt/sqlparser/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -725,58 +725,61 @@ type (
var _ OrderAndLimit = (*Select)(nil)
var _ OrderAndLimit = (*Update)(nil)
var _ OrderAndLimit = (*Delete)(nil)

func (*Union) iStatement() {}
func (*Select) iStatement() {}
func (*Stream) iStatement() {}
func (*VStream) iStatement() {}
func (*Insert) iStatement() {}
func (*Update) iStatement() {}
func (*Delete) iStatement() {}
func (*Set) iStatement() {}
func (*DropDatabase) iStatement() {}
func (*Flush) iStatement() {}
func (*Show) iStatement() {}
func (*Use) iStatement() {}
func (*Begin) iStatement() {}
func (*Commit) iStatement() {}
func (*Rollback) iStatement() {}
func (*SRollback) iStatement() {}
func (*Savepoint) iStatement() {}
func (*Release) iStatement() {}
func (*Analyze) iStatement() {}
func (*OtherAdmin) iStatement() {}
func (*CommentOnly) iStatement() {}
func (*Select) iSelectStatement() {}
func (*Union) iSelectStatement() {}
func (*Load) iStatement() {}
func (*CreateDatabase) iStatement() {}
func (*AlterDatabase) iStatement() {}
func (*CreateTable) iStatement() {}
func (*CreateView) iStatement() {}
func (*AlterView) iStatement() {}
func (*LockTables) iStatement() {}
func (*UnlockTables) iStatement() {}
func (*AlterTable) iStatement() {}
func (*AlterVschema) iStatement() {}
func (*AlterMigration) iStatement() {}
func (*RevertMigration) iStatement() {}
func (*ShowMigrationLogs) iStatement() {}
func (*ShowThrottledApps) iStatement() {}
func (*ShowThrottlerStatus) iStatement() {}
func (*DropTable) iStatement() {}
func (*DropView) iStatement() {}
func (*TruncateTable) iStatement() {}
func (*RenameTable) iStatement() {}
func (*CallProc) iStatement() {}
func (*ExplainStmt) iStatement() {}
func (*VExplainStmt) iStatement() {}
func (*ExplainTab) iStatement() {}
func (*PrepareStmt) iStatement() {}
func (*ExecuteStmt) iStatement() {}
func (*DeallocateStmt) iStatement() {}
func (*PurgeBinaryLogs) iStatement() {}
func (*Kill) iStatement() {}
var _ OrderAndLimit = (*ValuesStatement)(nil)

func (*Union) iStatement() {}
func (*Select) iStatement() {}
func (*ValuesStatement) iStatement() {}
func (*Stream) iStatement() {}
func (*VStream) iStatement() {}
func (*Insert) iStatement() {}
func (*Update) iStatement() {}
func (*Delete) iStatement() {}
func (*Set) iStatement() {}
func (*DropDatabase) iStatement() {}
func (*Flush) iStatement() {}
func (*Show) iStatement() {}
func (*Use) iStatement() {}
func (*Begin) iStatement() {}
func (*Commit) iStatement() {}
func (*Rollback) iStatement() {}
func (*SRollback) iStatement() {}
func (*Savepoint) iStatement() {}
func (*Release) iStatement() {}
func (*Analyze) iStatement() {}
func (*OtherAdmin) iStatement() {}
func (*CommentOnly) iStatement() {}
func (*Select) iSelectStatement() {}
func (*ValuesStatement) iSelectStatement() {}
func (*Union) iSelectStatement() {}
func (*Load) iStatement() {}
func (*CreateDatabase) iStatement() {}
func (*AlterDatabase) iStatement() {}
func (*CreateTable) iStatement() {}
func (*CreateView) iStatement() {}
func (*AlterView) iStatement() {}
func (*LockTables) iStatement() {}
func (*UnlockTables) iStatement() {}
func (*AlterTable) iStatement() {}
func (*AlterVschema) iStatement() {}
func (*AlterMigration) iStatement() {}
func (*RevertMigration) iStatement() {}
func (*ShowMigrationLogs) iStatement() {}
func (*ShowThrottledApps) iStatement() {}
func (*ShowThrottlerStatus) iStatement() {}
func (*DropTable) iStatement() {}
func (*DropView) iStatement() {}
func (*TruncateTable) iStatement() {}
func (*RenameTable) iStatement() {}
func (*CallProc) iStatement() {}
func (*ExplainStmt) iStatement() {}
func (*VExplainStmt) iStatement() {}
func (*ExplainTab) iStatement() {}
func (*PrepareStmt) iStatement() {}
func (*ExecuteStmt) iStatement() {}
func (*DeallocateStmt) iStatement() {}
func (*PurgeBinaryLogs) iStatement() {}
func (*Kill) iStatement() {}

func (*CreateView) iDDLStatement() {}
func (*AlterView) iDDLStatement() {}
Expand Down Expand Up @@ -1700,9 +1703,10 @@ type InsertRows interface {
SQLNode
}

func (*Select) iInsertRows() {}
func (*Union) iInsertRows() {}
func (Values) iInsertRows() {}
func (*Select) iInsertRows() {}
func (*Union) iInsertRows() {}
func (Values) iInsertRows() {}
func (*ValuesStatement) iInsertRows() {}

// OptLike works for create table xxx like xxx
type OptLike struct {
Expand Down Expand Up @@ -3573,6 +3577,17 @@ type Limit struct {
// Values represents a VALUES clause.
type Values []ValTuple

// ValuesStatement represents a VALUES statement, as in VALUES ROW(1, 2), ROW(3, 4)
type ValuesStatement struct {
With *With
// One but not both of these fields can be set.
Rows Values
ListArg ListArg

Order OrderBy
Limit *Limit
}

// UpdateExprs represents a list of update expressions.
type UpdateExprs []*UpdateExpr

Expand Down
21 changes: 21 additions & 0 deletions go/vt/sqlparser/ast_clone.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions go/vt/sqlparser/ast_copy_on_rewrite.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading