Skip to content
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
9 changes: 9 additions & 0 deletions go/test/endtoend/vtgate/misc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,15 @@ func TestCreateView(t *testing.T) {
assertMatches(t, conn, "select * from v1", `[[INT64(1) INT64(1)] [INT64(2) INT64(2)] [INT64(3) INT64(3)] [INT64(4) INT64(4)] [INT64(5) INT64(5)]]`)
}

func TestFlush(t *testing.T) {
defer cluster.PanicHandler(t)
ctx := context.Background()
conn, err := mysql.Connect(ctx, &vtParams)
require.NoError(t, err)
defer conn.Close()
exec(t, conn, "flush local tables t1, t2")
}

func assertMatches(t *testing.T, conn *mysql.Conn, query, expected string) {
t.Helper()
qr := exec(t, conn, query)
Expand Down
9 changes: 8 additions & 1 deletion go/vt/sqlparser/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const (
StmtVStream
StmtLockTables
StmtUnlockTables
StmtFlush
)

//ASTToStatementType returns a StatementType from an AST stmt
Expand Down Expand Up @@ -100,6 +101,8 @@ func ASTToStatementType(stmt Statement) StatementType {
return StmtLockTables
case *UnlockTables:
return StmtUnlockTables
case *Flush:
return StmtFlush
default:
return StmtUnknown
}
Expand Down Expand Up @@ -187,8 +190,10 @@ func Preview(sql string) StatementType {
return StmtRollback
}
switch loweredFirstWord {
case "create", "alter", "rename", "drop", "truncate", "flush":
case "create", "alter", "rename", "drop", "truncate":
return StmtDDL
case "flush":
return StmtFlush
case "set":
return StmtSet
case "show":
Expand Down Expand Up @@ -255,6 +260,8 @@ func (s StatementType) String() string {
return "LOCK_TABLES"
case StmtUnlockTables:
return "UNLOCK_TABLES"
case StmtFlush:
return "FLUSH"
default:
return "UNKNOWN"
}
Expand Down
1 change: 1 addition & 0 deletions go/vt/sqlparser/analyzer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func TestPreview(t *testing.T) {
{"grant", StmtPriv},
{"revoke", StmtPriv},
{"truncate", StmtDDL},
{"flush", StmtFlush},
{"unknown", StmtUnknown},

{"/* leading comment */ select ...", StmtSelect},
Expand Down
Loading