提交 952239fb 编写于 作者: L liipx

daily update & fix some questions

上级 92006756
......@@ -3280,7 +3280,7 @@ func (idxAdv *IndexAdvisor) RuleMaxTextColsCount() Rule {
return rule
}
sqlparser.Walk(func(node sqlparser.SQLNode) (kontinue bool, err error) {
err := sqlparser.Walk(func(node sqlparser.SQLNode) (kontinue bool, err error) {
switch stmt := node.(type) {
case *sqlparser.DDL:
if stmt.Action != "alter" {
......@@ -3319,6 +3319,7 @@ func (idxAdv *IndexAdvisor) RuleMaxTextColsCount() Rule {
}
return true, nil
}, idxAdv.Ast)
common.LogIfError(err, "")
return rule
}
......
......@@ -210,7 +210,7 @@
}
[]ast.Token{
{Type:57348, Val:"select", i:0},
{Type:57589, Val:"sql_calc_found_rows", i:0},
{Type:57590, Val:"sql_calc_found_rows", i:0},
{Type:57396, Val:"col", i:0},
{Type:57353, Val:"from", i:0},
{Type:57396, Val:"tbl", i:0},
......
......@@ -49,8 +49,8 @@ func LoggerInit() {
"daily": false,
"maxdays": 0,
}
logConfigJson, _ := json.Marshal(logConfig)
err := Log.SetLogger(logs.AdapterFile, fmt.Sprintf(string(logConfigJson)))
logConfigJSON, _ := json.Marshal(logConfig)
err := Log.SetLogger(logs.AdapterFile, string(logConfigJSON))
if err != nil {
fmt.Println(err.Error())
}
......
......@@ -132,8 +132,8 @@ func getTrace(res *QueryResult) Trace {
var rows []TraceRow
for _, row := range res.Rows {
rows = append(rows, TraceRow{
Query: row.Str(0),
Trace: row.Str(1),
Query: row.Str(0),
Trace: row.Str(1),
MissingBytesBeyondMaxMemSize: row.Int(2),
InsufficientPrivileges: row.Int(3),
})
......
......@@ -550,6 +550,7 @@ type DropTableStmt struct {
IfExists bool
Tables []*TableName
IsView bool
}
// Restore implements Recoverable interface.
......@@ -887,6 +888,7 @@ const (
AlterTableAddPartitions
AlterTableCoalescePartitions
AlterTableDropPartition
AlterTableTruncatePartition
// TODO: Add more actions
)
......
......@@ -605,7 +605,8 @@ type IsNullExpr struct {
// Restore implements Recoverable interface.
func (n *IsNullExpr) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
n.Format(sb)
return nil
}
// Format the ExprNode into a Writer.
......
......@@ -94,6 +94,7 @@ func ValidCharsetAndCollation(cs string, co string) bool {
if co == "" {
return true
}
co = strings.ToLower(co)
_, ok = c.Collations[co]
if !ok {
return false
......
......@@ -29,55 +29,59 @@ type ActionType byte
// List DDL actions.
const (
ActionNone ActionType = 0
ActionCreateSchema ActionType = 1
ActionDropSchema ActionType = 2
ActionCreateTable ActionType = 3
ActionDropTable ActionType = 4
ActionAddColumn ActionType = 5
ActionDropColumn ActionType = 6
ActionAddIndex ActionType = 7
ActionDropIndex ActionType = 8
ActionAddForeignKey ActionType = 9
ActionDropForeignKey ActionType = 10
ActionTruncateTable ActionType = 11
ActionModifyColumn ActionType = 12
ActionRebaseAutoID ActionType = 13
ActionRenameTable ActionType = 14
ActionSetDefaultValue ActionType = 15
ActionShardRowID ActionType = 16
ActionModifyTableComment ActionType = 17
ActionRenameIndex ActionType = 18
ActionAddTablePartition ActionType = 19
ActionDropTablePartition ActionType = 20
ActionCreateView ActionType = 21
ActionNone ActionType = 0
ActionCreateSchema ActionType = 1
ActionDropSchema ActionType = 2
ActionCreateTable ActionType = 3
ActionDropTable ActionType = 4
ActionAddColumn ActionType = 5
ActionDropColumn ActionType = 6
ActionAddIndex ActionType = 7
ActionDropIndex ActionType = 8
ActionAddForeignKey ActionType = 9
ActionDropForeignKey ActionType = 10
ActionTruncateTable ActionType = 11
ActionModifyColumn ActionType = 12
ActionRebaseAutoID ActionType = 13
ActionRenameTable ActionType = 14
ActionSetDefaultValue ActionType = 15
ActionShardRowID ActionType = 16
ActionModifyTableComment ActionType = 17
ActionRenameIndex ActionType = 18
ActionAddTablePartition ActionType = 19
ActionDropTablePartition ActionType = 20
ActionCreateView ActionType = 21
ActionModifyTableCharsetAndCollate ActionType = 22
ActionTruncateTablePartition ActionType = 23
)
// AddIndexStr is a string related to the operation of "add index".
const AddIndexStr = "add index"
var actionMap = map[ActionType]string{
ActionCreateSchema: "create schema",
ActionDropSchema: "drop schema",
ActionCreateTable: "create table",
ActionDropTable: "drop table",
ActionAddColumn: "add column",
ActionDropColumn: "drop column",
ActionAddIndex: AddIndexStr,
ActionDropIndex: "drop index",
ActionAddForeignKey: "add foreign key",
ActionDropForeignKey: "drop foreign key",
ActionTruncateTable: "truncate table",
ActionModifyColumn: "modify column",
ActionRebaseAutoID: "rebase auto_increment ID",
ActionRenameTable: "rename table",
ActionSetDefaultValue: "set default value",
ActionShardRowID: "shard row ID",
ActionModifyTableComment: "modify table comment",
ActionRenameIndex: "rename index",
ActionAddTablePartition: "add partition",
ActionDropTablePartition: "drop table partition",
ActionCreateView: "create view",
ActionCreateSchema: "create schema",
ActionDropSchema: "drop schema",
ActionCreateTable: "create table",
ActionDropTable: "drop table",
ActionAddColumn: "add column",
ActionDropColumn: "drop column",
ActionAddIndex: AddIndexStr,
ActionDropIndex: "drop index",
ActionAddForeignKey: "add foreign key",
ActionDropForeignKey: "drop foreign key",
ActionTruncateTable: "truncate table",
ActionModifyColumn: "modify column",
ActionRebaseAutoID: "rebase auto_increment ID",
ActionRenameTable: "rename table",
ActionSetDefaultValue: "set default value",
ActionShardRowID: "shard row ID",
ActionModifyTableComment: "modify table comment",
ActionRenameIndex: "rename index",
ActionAddTablePartition: "add partition",
ActionDropTablePartition: "drop partition",
ActionCreateView: "create view",
ActionModifyTableCharsetAndCollate: "modify table charset and collate",
ActionTruncateTablePartition: "truncate partition",
}
// String return current ddl action in string
......
......@@ -1084,6 +1084,13 @@ AlterTableSpec:
Name: $3,
}
}
| "TRUNCATE" "PARTITION" Identifier
{
$$ = &ast.AlterTableSpec{
Tp: ast.AlterTableTruncatePartition,
Name: $3,
}
}
| "DROP" KeyOrIndex Identifier
{
$$ = &ast.AlterTableSpec{
......@@ -2349,17 +2356,22 @@ DropIndexStmt:
DropTableStmt:
"DROP" TableOrTables TableNameList RestrictOrCascadeOpt
{
$$ = &ast.DropTableStmt{Tables: $3.([]*ast.TableName)}
$$ = &ast.DropTableStmt{Tables: $3.([]*ast.TableName), IsView: false}
}
| "DROP" TableOrTables "IF" "EXISTS" TableNameList RestrictOrCascadeOpt
{
$$ = &ast.DropTableStmt{IfExists: true, Tables: $5.([]*ast.TableName)}
$$ = &ast.DropTableStmt{IfExists: true, Tables: $5.([]*ast.TableName), IsView: false}
}
DropViewStmt:
"DROP" "VIEW" "IF" "EXISTS" TableNameList
"DROP" "VIEW" TableNameList RestrictOrCascadeOpt
{
$$ = &ast.DropTableStmt{Tables: $3.([]*ast.TableName), IsView: true}
}
|
"DROP" "VIEW" "IF" "EXISTS" TableNameList RestrictOrCascadeOpt
{
$$ = &ast.DoStmt{}
$$ = &ast.DropTableStmt{IfExists: true, Tables: $5.([]*ast.TableName), IsView: true}
}
DropUserStmt:
......
......@@ -71,6 +71,14 @@ type StatementContext struct {
histogramsNotLoad bool
execDetails execdetails.ExecDetails
}
// PrevAffectedRows is the affected-rows value(DDL is 0, DML is the number of affected rows).
PrevAffectedRows int64
// PrevLastInsertID is the last insert ID of previous statement.
PrevLastInsertID uint64
// LastInsertID is the auto-generated ID in the current statement.
LastInsertID uint64
// InsertID is the given insert ID of an auto_increment column.
InsertID uint64
// Copied from SessionVars.TimeZone.
TimeZone *time.Location
......@@ -241,6 +249,8 @@ func (sc *StatementContext) ResetForRetry() {
sc.mu.foundRows = 0
sc.mu.warnings = nil
sc.mu.Unlock()
sc.TableIDs = sc.TableIDs[:0]
sc.IndexIDs = sc.IndexIDs[:0]
}
// MergeExecDetails merges a single region execution details into self, used to print
......
......@@ -40,6 +40,12 @@ func NewFieldType(tp byte) *FieldType {
}
}
// CloneFieldType clones the given FieldType.
func CloneFieldType(src *FieldType) *FieldType {
ft := *src
return &ft
}
// AggFieldType aggregates field types for a multi-argument function like `IF`, `IFNULL`, `COALESCE`
// whose return type is determined by the arguments' FieldTypes.
// Aggregation is performed by MergeFieldType function.
......@@ -123,11 +129,14 @@ func setTypeFlag(flag *uint, flagItem uint, on bool) {
func DefaultParamTypeForValue(value interface{}, tp *FieldType) {
switch value.(type) {
case nil:
tp.Tp = mysql.TypeUnspecified
tp.Tp = mysql.TypeVarString
tp.Flen = UnspecifiedLength
tp.Decimal = UnspecifiedLength
default:
DefaultTypeForValue(value, tp)
if tp.Tp == mysql.TypeUnspecified {
tp.Tp = mysql.TypeVarString
}
}
}
......
......@@ -105,106 +105,106 @@
"revisionTime": "2018-10-24T15:10:47Z"
},
{
"checksumSHA1": "V/4P8kb4QDozn9w++U8G+Kvt0+g=",
"checksumSHA1": "xbV0lm0Qw8rFC82Dttxbf5ypBjA=",
"path": "github.com/pingcap/parser",
"revision": "c563561800a23fd1edeae4a592400cc2d0b47f5f",
"revisionTime": "2018-12-05T02:39:50Z"
"revision": "4e6d047fcaae221376638de5f44c07cb6bf3eb44",
"revisionTime": "2018-12-11T02:45:40Z"
},
{
"checksumSHA1": "Fj3tju6yXL0IHhhu6pYwvU5xzJo=",
"checksumSHA1": "zrZ2JfaxdfwpArtuyiPjgH9GKeY=",
"path": "github.com/pingcap/parser/ast",
"revision": "c563561800a23fd1edeae4a592400cc2d0b47f5f",
"revisionTime": "2018-12-05T02:39:50Z"
"revision": "4e6d047fcaae221376638de5f44c07cb6bf3eb44",
"revisionTime": "2018-12-11T02:45:40Z"
},
{
"checksumSHA1": "skWGV4FNvD3vr+5olepaPPnylUw=",
"path": "github.com/pingcap/parser/auth",
"revision": "c563561800a23fd1edeae4a592400cc2d0b47f5f",
"revisionTime": "2018-12-05T02:39:50Z"
"revision": "4e6d047fcaae221376638de5f44c07cb6bf3eb44",
"revisionTime": "2018-12-11T02:45:40Z"
},
{
"checksumSHA1": "grkBf/zf8cTJRtI64P1jV6B+p/4=",
"checksumSHA1": "t4UHo966WzU9Z0IJkyGHRp0loOk=",
"path": "github.com/pingcap/parser/charset",
"revision": "c563561800a23fd1edeae4a592400cc2d0b47f5f",
"revisionTime": "2018-12-05T02:39:50Z"
"revision": "4e6d047fcaae221376638de5f44c07cb6bf3eb44",
"revisionTime": "2018-12-11T02:45:40Z"
},
{
"checksumSHA1": "SInoXbsRe0tnBwmatmtZYfSFbdk=",
"path": "github.com/pingcap/parser/format",
"revision": "c563561800a23fd1edeae4a592400cc2d0b47f5f",
"revisionTime": "2018-12-05T02:39:50Z"
"revision": "4e6d047fcaae221376638de5f44c07cb6bf3eb44",
"revisionTime": "2018-12-11T02:45:40Z"
},
{
"checksumSHA1": "+rJd1MX+3A1gwbrFZHFWbC8l8ao=",
"checksumSHA1": "reRV2qecd6NpB7tIW3JeK46K/sk=",
"path": "github.com/pingcap/parser/model",
"revision": "c563561800a23fd1edeae4a592400cc2d0b47f5f",
"revisionTime": "2018-12-05T02:39:50Z"
"revision": "4e6d047fcaae221376638de5f44c07cb6bf3eb44",
"revisionTime": "2018-12-11T02:45:40Z"
},
{
"checksumSHA1": "QBa9yiMDQNl2cLLwqlRoNTpCPNg=",
"path": "github.com/pingcap/parser/mysql",
"revision": "c563561800a23fd1edeae4a592400cc2d0b47f5f",
"revisionTime": "2018-12-05T02:39:50Z"
"revision": "4e6d047fcaae221376638de5f44c07cb6bf3eb44",
"revisionTime": "2018-12-11T02:45:40Z"
},
{
"checksumSHA1": "oNBCSwJRykKuzIKgPCttatB9hAo=",
"path": "github.com/pingcap/parser/opcode",
"revision": "c563561800a23fd1edeae4a592400cc2d0b47f5f",
"revisionTime": "2018-12-05T02:39:50Z"
"revision": "4e6d047fcaae221376638de5f44c07cb6bf3eb44",
"revisionTime": "2018-12-11T02:45:40Z"
},
{
"checksumSHA1": "XvnUllvwMYd6HrMvMiKnn4cGN2M=",
"path": "github.com/pingcap/parser/terror",
"revision": "c563561800a23fd1edeae4a592400cc2d0b47f5f",
"revisionTime": "2018-12-05T02:39:50Z"
"revision": "4e6d047fcaae221376638de5f44c07cb6bf3eb44",
"revisionTime": "2018-12-11T02:45:40Z"
},
{
"checksumSHA1": "s96v2EoeGKcWHO3mpMOQk/z2iaI=",
"path": "github.com/pingcap/parser/types",
"revision": "c563561800a23fd1edeae4a592400cc2d0b47f5f",
"revisionTime": "2018-12-05T02:39:50Z"
"revision": "4e6d047fcaae221376638de5f44c07cb6bf3eb44",
"revisionTime": "2018-12-11T02:45:40Z"
},
{
"checksumSHA1": "kO63T5plq+V7HWnkzB9WlOnp9Iw=",
"checksumSHA1": "fWqL/7jTYOiqDNmiUcQi3u45Hw0=",
"path": "github.com/pingcap/tidb/sessionctx/stmtctx",
"revision": "350a046975a1f86fa6f05f177e81ae838388f4bb",
"revisionTime": "2018-12-04T14:10:08Z"
"revision": "ef0ad26da8f99044a741fc0a781a0c4791446e8b",
"revisionTime": "2018-12-10T15:48:53Z"
},
{
"checksumSHA1": "SH/wISM1ueh/ENPJhiq1KssPLDA=",
"checksumSHA1": "U/TFas5WBPWG2DARj51bcfoN0xQ=",
"path": "github.com/pingcap/tidb/types",
"revision": "350a046975a1f86fa6f05f177e81ae838388f4bb",
"revisionTime": "2018-12-04T14:10:08Z"
"revision": "ef0ad26da8f99044a741fc0a781a0c4791446e8b",
"revisionTime": "2018-12-10T15:48:53Z"
},
{
"checksumSHA1": "DWVD7+ygtT66IQ+cqXmMJ5OVqUk=",
"path": "github.com/pingcap/tidb/types/json",
"revision": "350a046975a1f86fa6f05f177e81ae838388f4bb",
"revisionTime": "2018-12-04T14:10:08Z"
"revision": "ef0ad26da8f99044a741fc0a781a0c4791446e8b",
"revisionTime": "2018-12-10T15:48:53Z"
},
{
"checksumSHA1": "Zp5ME8OXNTmHnYTwJJUZlydN4/U=",
"path": "github.com/pingcap/tidb/types/parser_driver",
"revision": "350a046975a1f86fa6f05f177e81ae838388f4bb",
"revisionTime": "2018-12-04T14:10:08Z"
"revision": "ef0ad26da8f99044a741fc0a781a0c4791446e8b",
"revisionTime": "2018-12-10T15:48:53Z"
},
{
"checksumSHA1": "s709bhSrG2Ec35406mGtrySid4s=",
"path": "github.com/pingcap/tidb/util/execdetails",
"revision": "350a046975a1f86fa6f05f177e81ae838388f4bb",
"revisionTime": "2018-12-04T14:10:08Z"
"revision": "ef0ad26da8f99044a741fc0a781a0c4791446e8b",
"revisionTime": "2018-12-10T15:48:53Z"
},
{
"checksumSHA1": "nUC7zVoAMNR2a+z2iGqHoN2AkFE=",
"path": "github.com/pingcap/tidb/util/hack",
"revision": "350a046975a1f86fa6f05f177e81ae838388f4bb",
"revisionTime": "2018-12-04T14:10:08Z"
"revision": "ef0ad26da8f99044a741fc0a781a0c4791446e8b",
"revisionTime": "2018-12-10T15:48:53Z"
},
{
"checksumSHA1": "xSyepiuqsoaaeDch7cXeumvVHKM=",
"path": "github.com/pingcap/tidb/util/memory",
"revision": "350a046975a1f86fa6f05f177e81ae838388f4bb",
"revisionTime": "2018-12-04T14:10:08Z"
"revision": "ef0ad26da8f99044a741fc0a781a0c4791446e8b",
"revisionTime": "2018-12-10T15:48:53Z"
},
{
"checksumSHA1": "SmYeIK/fIYXNu8IKxD6HOVQVTuU=",
......@@ -401,62 +401,62 @@
{
"checksumSHA1": "aKn1oKcY74N8TRLm3Ayt7Q4bbI4=",
"path": "vitess.io/vitess/go/bytes2",
"revision": "5bec5a560c87897b5d973bbced81764f3cf0f330",
"revisionTime": "2018-12-05T00:00:15Z"
"revision": "be9745195a139422cd62fd32bdc3b7e0c28c9427",
"revisionTime": "2018-12-10T16:22:31Z"
},
{
"checksumSHA1": "JVCEN4UGRmg3TofIBdzZMZ3G0Ww=",
"path": "vitess.io/vitess/go/hack",
"revision": "5bec5a560c87897b5d973bbced81764f3cf0f330",
"revisionTime": "2018-12-05T00:00:15Z"
"revision": "be9745195a139422cd62fd32bdc3b7e0c28c9427",
"revisionTime": "2018-12-10T16:22:31Z"
},
{
"checksumSHA1": "e1WJ7vCnVrlQQQlc6n/FewCDMso=",
"path": "vitess.io/vitess/go/sqltypes",
"revision": "5bec5a560c87897b5d973bbced81764f3cf0f330",
"revisionTime": "2018-12-05T00:00:15Z"
"revision": "be9745195a139422cd62fd32bdc3b7e0c28c9427",
"revisionTime": "2018-12-10T16:22:31Z"
},
{
"checksumSHA1": "ntFIQYkBS51G6y+FEkjFW40+HOU=",
"path": "vitess.io/vitess/go/vt/log",
"revision": "5bec5a560c87897b5d973bbced81764f3cf0f330",
"revisionTime": "2018-12-05T00:00:15Z"
"revision": "be9745195a139422cd62fd32bdc3b7e0c28c9427",
"revisionTime": "2018-12-10T16:22:31Z"
},
{
"checksumSHA1": "tPQFPwbMdjuX0qjNl4Zl8zc37JQ=",
"path": "vitess.io/vitess/go/vt/proto/query",
"revision": "5bec5a560c87897b5d973bbced81764f3cf0f330",
"revisionTime": "2018-12-05T00:00:15Z"
"revision": "be9745195a139422cd62fd32bdc3b7e0c28c9427",
"revisionTime": "2018-12-10T16:22:31Z"
},
{
"checksumSHA1": "o0tR/c7lgr0pLkxk7CdvjiNDAKU=",
"path": "vitess.io/vitess/go/vt/proto/topodata",
"revision": "5bec5a560c87897b5d973bbced81764f3cf0f330",
"revisionTime": "2018-12-05T00:00:15Z"
"revision": "be9745195a139422cd62fd32bdc3b7e0c28c9427",
"revisionTime": "2018-12-10T16:22:31Z"
},
{
"checksumSHA1": "77UojBqi0yyeQvR70j7C3kcKclQ=",
"path": "vitess.io/vitess/go/vt/proto/vtgate",
"revision": "5bec5a560c87897b5d973bbced81764f3cf0f330",
"revisionTime": "2018-12-05T00:00:15Z"
"revision": "be9745195a139422cd62fd32bdc3b7e0c28c9427",
"revisionTime": "2018-12-10T16:22:31Z"
},
{
"checksumSHA1": "QpWGhoVDwM+8+sgYLI/YU+95iGU=",
"path": "vitess.io/vitess/go/vt/proto/vtrpc",
"revision": "5bec5a560c87897b5d973bbced81764f3cf0f330",
"revisionTime": "2018-12-05T00:00:15Z"
"revision": "be9745195a139422cd62fd32bdc3b7e0c28c9427",
"revisionTime": "2018-12-10T16:22:31Z"
},
{
"checksumSHA1": "CZ0WbR7TBTgF9HoY+aRxzOzVlSs=",
"checksumSHA1": "lENrUY/YyxwYFHYN+21TBH92P3U=",
"path": "vitess.io/vitess/go/vt/sqlparser",
"revision": "5bec5a560c87897b5d973bbced81764f3cf0f330",
"revisionTime": "2018-12-05T00:00:15Z"
"revision": "be9745195a139422cd62fd32bdc3b7e0c28c9427",
"revisionTime": "2018-12-10T16:22:31Z"
},
{
"checksumSHA1": "oF4XzuOzwvj1iduX/lYqNSyY/HM=",
"path": "vitess.io/vitess/go/vt/vterrors",
"revision": "5bec5a560c87897b5d973bbced81764f3cf0f330",
"revisionTime": "2018-12-05T00:00:15Z"
"revision": "be9745195a139422cd62fd32bdc3b7e0c28c9427",
"revisionTime": "2018-12-10T16:22:31Z"
}
],
"rootPath": "github.com/XiaoMi/soar"
......
......@@ -746,15 +746,18 @@ type DDL struct {
// DDL strings.
const (
CreateStr = "create"
AlterStr = "alter"
DropStr = "drop"
RenameStr = "rename"
TruncateStr = "truncate"
FlushStr = "flush"
CreateVindexStr = "create vindex"
AddColVindexStr = "add vindex"
DropColVindexStr = "drop vindex"
CreateStr = "create"
AlterStr = "alter"
DropStr = "drop"
RenameStr = "rename"
TruncateStr = "truncate"
FlushStr = "flush"
CreateVindexStr = "create vindex"
DropVindexStr = "drop vindex"
AddVschemaTableStr = "add vschema table"
DropVschemaTableStr = "drop vschema table"
AddColVindexStr = "on table add vindex"
DropColVindexStr = "on table drop vindex"
// Vindex DDL param to specify the owner of a vindex
VindexOwnerStr = "owner"
......@@ -791,9 +794,15 @@ func (node *DDL) Format(buf *TrackedBuffer) {
case FlushStr:
buf.Myprintf("%s", node.Action)
case CreateVindexStr:
buf.Myprintf("%s %v %v", node.Action, node.VindexSpec.Name, node.VindexSpec)
buf.Myprintf("alter vschema create vindex %v %v", node.VindexSpec.Name, node.VindexSpec)
case DropVindexStr:
buf.Myprintf("alter vschema drop vindex %v", node.VindexSpec.Name)
case AddVschemaTableStr:
buf.Myprintf("alter vschema add table %v", node.Table)
case DropVschemaTableStr:
buf.Myprintf("alter vschema drop table %v", node.Table)
case AddColVindexStr:
buf.Myprintf("alter table %v %s %v (", node.Table, node.Action, node.VindexSpec.Name)
buf.Myprintf("alter vschema on %v add vindex %v (", node.Table, node.VindexSpec.Name)
for i, col := range node.VindexCols {
if i != 0 {
buf.Myprintf(", %v", col)
......@@ -806,7 +815,7 @@ func (node *DDL) Format(buf *TrackedBuffer) {
buf.Myprintf(" %v", node.VindexSpec)
}
case DropColVindexStr:
buf.Myprintf("alter table %v %s %v", node.Table, node.Action, node.VindexSpec.Name)
buf.Myprintf("alter vschema on %v drop vindex %v", node.Table, node.VindexSpec.Name)
default:
buf.Myprintf("%s table %v", node.Action, node.Table)
}
......
......@@ -180,7 +180,7 @@ func skipToEnd(yylex interface{}) {
%token <bytes> NULLX AUTO_INCREMENT APPROXNUM SIGNED UNSIGNED ZEROFILL
// Supported SHOW tokens
%token <bytes> COLLATION DATABASES TABLES VITESS_KEYSPACES VITESS_SHARDS VITESS_TABLETS VSCHEMA_TABLES VITESS_TARGET FULL PROCESSLIST COLUMNS FIELDS ENGINES PLUGINS
%token <bytes> COLLATION DATABASES TABLES VITESS_KEYSPACES VITESS_SHARDS VITESS_TABLETS VSCHEMA VSCHEMA_TABLES VITESS_TARGET FULL PROCESSLIST COLUMNS FIELDS ENGINES PLUGINS
// SET tokens
%token <bytes> NAMES CHARSET GLOBAL SESSION ISOLATION LEVEL READ WRITE ONLY REPEATABLE COMMITTED UNCOMMITTED SERIALIZABLE
......@@ -570,14 +570,6 @@ create_statement:
{
$$ = &DDL{Action: CreateStr, Table: $5.ToViewName()}
}
| CREATE VINDEX sql_id vindex_type_opt vindex_params_opt
{
$$ = &DDL{Action: CreateVindexStr, VindexSpec: &VindexSpec{
Name: $3,
Type: $4,
Params: $5,
}}
}
| CREATE DATABASE not_exists_opt ID ddl_skip_to_end
{
$$ = &DBDDL{Action: CreateStr, DBName: string($4)}
......@@ -1300,7 +1292,47 @@ alter_statement:
{
$$ = &DDL{Action: AlterStr, Table: $4}
}
| ALTER ignore_opt TABLE table_name ADD VINDEX sql_id '(' column_list ')' vindex_type_opt vindex_params_opt
| ALTER ignore_opt TABLE table_name RENAME to_opt table_name
{
// Change this to a rename statement
$$ = &DDL{Action: RenameStr, FromTables: TableNames{$4}, ToTables: TableNames{$7}}
}
| ALTER ignore_opt TABLE table_name RENAME index_opt skip_to_end
{
// Rename an index can just be an alter
$$ = &DDL{Action: AlterStr, Table: $4}
}
| ALTER VIEW table_name ddl_skip_to_end
{
$$ = &DDL{Action: AlterStr, Table: $3.ToViewName()}
}
| ALTER ignore_opt TABLE table_name partition_operation
{
$$ = &DDL{Action: AlterStr, Table: $4, PartitionSpec: $5}
}
| ALTER VSCHEMA CREATE VINDEX sql_id vindex_type_opt vindex_params_opt
{
$$ = &DDL{Action: CreateVindexStr, VindexSpec: &VindexSpec{
Name: $5,
Type: $6,
Params: $7,
}}
}
| ALTER VSCHEMA DROP VINDEX sql_id
{
$$ = &DDL{Action: DropVindexStr, VindexSpec: &VindexSpec{
Name: $5,
}}
}
| ALTER VSCHEMA ADD TABLE table_name
{
$$ = &DDL{Action: AddVschemaTableStr, Table: $5}
}
| ALTER VSCHEMA DROP TABLE table_name
{
$$ = &DDL{Action: DropVschemaTableStr, Table: $5}
}
| ALTER VSCHEMA ON table_name ADD VINDEX sql_id '(' column_list ')' vindex_type_opt vindex_params_opt
{
$$ = &DDL{
Action: AddColVindexStr,
......@@ -1313,7 +1345,7 @@ alter_statement:
VindexCols: $9,
}
}
| ALTER ignore_opt TABLE table_name DROP VINDEX sql_id
| ALTER VSCHEMA ON table_name DROP VINDEX sql_id
{
$$ = &DDL{
Action: DropColVindexStr,
......@@ -1323,24 +1355,6 @@ alter_statement:
},
}
}
| ALTER ignore_opt TABLE table_name RENAME to_opt table_name
{
// Change this to a rename statement
$$ = &DDL{Action: RenameStr, FromTables: TableNames{$4}, ToTables: TableNames{$7}}
}
| ALTER ignore_opt TABLE table_name RENAME index_opt skip_to_end
{
// Rename an index can just be an alter
$$ = &DDL{Action: AlterStr, Table: $4}
}
| ALTER VIEW table_name ddl_skip_to_end
{
$$ = &DDL{Action: AlterStr, Table: $3.ToViewName()}
}
| ALTER ignore_opt TABLE table_name partition_operation
{
$$ = &DDL{Action: AlterStr, Table: $4, PartitionSpec: $5}
}
alter_object_type:
COLUMN
......@@ -1535,10 +1549,6 @@ show_statement:
{
$$ = &Show{Scope: $2, Type: string($3)}
}
| SHOW VINDEXES
{
$$ = &Show{Type: string($2)}
}
| SHOW COLLATION
{
$$ = &Show{Type: string($2)}
......@@ -1549,10 +1559,6 @@ show_statement:
showCollationFilterOpt := $4
$$ = &Show{Type: string($2), ShowCollationFilterOpt: &showCollationFilterOpt}
}
| SHOW VINDEXES ON table_name
{
$$ = &Show{Type: string($2), OnTable: $4}
}
| SHOW VITESS_KEYSPACES
{
$$ = &Show{Type: string($2)}
......@@ -1569,9 +1575,17 @@ show_statement:
{
$$ = &Show{Type: string($2)}
}
| SHOW VSCHEMA_TABLES
| SHOW VSCHEMA TABLES
{
$$ = &Show{Type: string($2)}
$$ = &Show{Type: string($2) + " " + string($3)}
}
| SHOW VSCHEMA VINDEXES
{
$$ = &Show{Type: string($2) + " " + string($3)}
}
| SHOW VSCHEMA VINDEXES ON table_name
{
$$ = &Show{Type: string($2) + " " + string($3), OnTable: $5}
}
| SHOW WARNINGS
{
......@@ -3351,6 +3365,7 @@ non_reserved_keyword:
| VITESS_KEYSPACES
| VITESS_SHARDS
| VITESS_TABLETS
| VSCHEMA
| VSCHEMA_TABLES
| VITESS_TARGET
| WARNINGS
......
......@@ -393,6 +393,7 @@ var keywords = map[string]int{
"vitess_shards": VITESS_SHARDS,
"vitess_tablets": VITESS_TABLETS,
"vitess_target": VITESS_TARGET,
"vschema": VSCHEMA,
"vschema_tables": VSCHEMA_TABLES,
"warnings": WARNINGS,
"when": WHEN,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册