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

VStream: mysql protocol #6670

Merged
merged 6 commits into from
Sep 9, 2020
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
3 changes: 3 additions & 0 deletions go/vt/discovery/healthcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,9 @@ func (hc *HealthCheckImpl) GetHealthyTabletStats(target *query.Target) []*Tablet
var result []*TabletHealth
hc.mu.Lock()
defer hc.mu.Unlock()
if target.Shard == "" {
target.Shard = "0"
}
return append(result, hc.healthy[hc.keyFromTarget(target)]...)
}

Expand Down
5 changes: 5 additions & 0 deletions go/vt/sqlparser/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const (
StmtSavepoint
StmtSRollback
StmtRelease
StmtVStream
)

//ASTToStatementType returns a StatementType from an AST stmt
Expand Down Expand Up @@ -138,6 +139,8 @@ func Preview(sql string) StatementType {
return StmtSelect
case "stream":
return StmtStream
case "vstream":
return StmtVStream
case "insert":
return StmtInsert
case "replace":
Expand Down Expand Up @@ -192,6 +195,8 @@ func (s StatementType) String() string {
return "SELECT"
case StmtStream:
return "STREAM"
case StmtVStream:
return "VSTREAM"
case StmtInsert:
return "INSERT"
case StmtReplace:
Expand Down
16 changes: 16 additions & 0 deletions go/vt/sqlparser/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,15 @@ type (
Lock string
}

// VStream represents a VSTREAM statement.
VStream struct {
Comments Comments
SelectExpr SelectExpr
Table TableName
Where *Where
Limit *Limit
}

// Stream represents a SELECT statement.
Stream struct {
Comments Comments
Expand Down Expand Up @@ -270,6 +279,7 @@ type (
func (*Union) iStatement() {}
func (*Select) iStatement() {}
func (*Stream) iStatement() {}
func (*VStream) iStatement() {}
func (*Insert) iStatement() {}
func (*Update) iStatement() {}
func (*Delete) iStatement() {}
Expand Down Expand Up @@ -921,6 +931,12 @@ func (node *UnionSelect) Format(buf *TrackedBuffer) {
buf.astPrintf(node, " %s %v", node.Type, node.Statement)
}

// Format formats the node.
func (node *VStream) Format(buf *TrackedBuffer) {
buf.astPrintf(node, "vstream %v%v from %v",
node.Comments, node.SelectExpr, node.Table)
}

// Format formats the node.
func (node *Stream) Format(buf *TrackedBuffer) {
buf.astPrintf(node, "stream %v%v from %v",
Expand Down
2 changes: 2 additions & 0 deletions go/vt/sqlparser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1588,6 +1588,8 @@ var (
input: "delete from t partition (p0) where a = 1",
}, {
input: "stream * from t",
}, {
input: "vstream * from t",
}, {
input: "stream /* comment */ * from t",
}, {
Expand Down
4 changes: 4 additions & 0 deletions go/vt/sqlparser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"errors"
"fmt"
"io"
"runtime/debug"
"sync"

"vitess.io/vitess/go/vt/log"
Expand Down Expand Up @@ -93,6 +94,7 @@ func Parse(sql string) (Statement, error) {
return nil, vterrors.New(vtrpcpb.Code_INVALID_ARGUMENT, tokenizer.LastError.Error())
}
if tokenizer.ParseTree == nil {
log.Infof("Empty Statement: %s", debug.Stack())
return nil, ErrEmpty
}
return tokenizer.ParseTree, nil
Expand All @@ -106,6 +108,8 @@ func ParseStrictDDL(sql string) (Statement, error) {
return nil, tokenizer.LastError
}
if tokenizer.ParseTree == nil {
log.Infof("Empty Statement DDL: %s", debug.Stack())

return nil, ErrEmpty
}
return tokenizer.ParseTree, nil
Expand Down
27 changes: 27 additions & 0 deletions go/vt/sqlparser/rewriter.go

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

Loading