提交 7944a57e 编写于 作者: martianzhang's avatar martianzhang

update vendor

上级 80baea18
...@@ -34,6 +34,7 @@ var ( ...@@ -34,6 +34,7 @@ var (
_ DDLNode = &DropTableStmt{} _ DDLNode = &DropTableStmt{}
_ DDLNode = &RenameTableStmt{} _ DDLNode = &RenameTableStmt{}
_ DDLNode = &TruncateTableStmt{} _ DDLNode = &TruncateTableStmt{}
_ DDLNode = &RepairTableStmt{}
_ Node = &AlterTableSpec{} _ Node = &AlterTableSpec{}
_ Node = &ColumnDef{} _ Node = &ColumnDef{}
...@@ -1247,7 +1248,7 @@ func (n *CreateViewStmt) Accept(v Visitor) (Node, bool) { ...@@ -1247,7 +1248,7 @@ func (n *CreateViewStmt) Accept(v Visitor) (Node, bool) {
if !ok { if !ok {
return n, false return n, false
} }
n.Select = selnode.(*SelectStmt) n.Select = selnode.(StmtNode)
return v.Leave(n) return v.Leave(n)
} }
...@@ -1559,6 +1560,46 @@ func (n *CleanupTableLockStmt) Restore(ctx *RestoreCtx) error { ...@@ -1559,6 +1560,46 @@ func (n *CleanupTableLockStmt) Restore(ctx *RestoreCtx) error {
return nil return nil
} }
// RepairTableStmt is a statement to repair tableInfo.
type RepairTableStmt struct {
ddlNode
Table *TableName
CreateStmt *CreateTableStmt
}
// Accept implements Node Accept interface.
func (n *RepairTableStmt) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
if skipChildren {
return v.Leave(newNode)
}
n = newNode.(*RepairTableStmt)
node, ok := n.Table.Accept(v)
if !ok {
return n, false
}
n.Table = node.(*TableName)
node, ok = n.CreateStmt.Accept(v)
if !ok {
return n, false
}
n.CreateStmt = node.(*CreateTableStmt)
return v.Leave(n)
}
// Restore implements Node interface.
func (n *RepairTableStmt) Restore(ctx *RestoreCtx) error {
ctx.WriteKeyWord("ADMIN REPAIR TABLE ")
if err := n.Table.Restore(ctx); err != nil {
return errors.Annotatef(err, "An error occurred while restore RepairTableStmt.table : [%v]", n.Table)
}
ctx.WritePlain(" ")
if err := n.CreateStmt.Restore(ctx); err != nil {
return errors.Annotatef(err, "An error occurred while restore RepairTableStmt.createStmt : [%v]", n.CreateStmt)
}
return nil
}
// TableOptionType is the type for TableOption // TableOptionType is the type for TableOption
type TableOptionType int type TableOptionType int
...@@ -1925,6 +1966,8 @@ const ( ...@@ -1925,6 +1966,8 @@ const (
AlterTableIndexInvisible AlterTableIndexInvisible
// TODO: Add more actions // TODO: Add more actions
AlterTableOrderByColumns AlterTableOrderByColumns
// AlterTableSetTiFlashReplica uses to set the table TiFlash replica.
AlterTableSetTiFlashReplica
) )
// LockType is the type for AlterTableSpec. // LockType is the type for AlterTableSpec.
...@@ -2019,6 +2062,12 @@ type AlterTableSpec struct { ...@@ -2019,6 +2062,12 @@ type AlterTableSpec struct {
WithValidation bool WithValidation bool
Num uint64 Num uint64
Visibility IndexVisibility Visibility IndexVisibility
TiFlashReplica *TiFlashReplicaSpec
}
type TiFlashReplicaSpec struct {
Count uint64
Labels []string
} }
// AlterOrderItem represents an item in order by at alter table stmt. // AlterOrderItem represents an item in order by at alter table stmt.
...@@ -2042,6 +2091,19 @@ func (n *AlterOrderItem) Restore(ctx *RestoreCtx) error { ...@@ -2042,6 +2091,19 @@ func (n *AlterOrderItem) Restore(ctx *RestoreCtx) error {
// Restore implements Node interface. // Restore implements Node interface.
func (n *AlterTableSpec) Restore(ctx *RestoreCtx) error { func (n *AlterTableSpec) Restore(ctx *RestoreCtx) error {
switch n.Tp { switch n.Tp {
case AlterTableSetTiFlashReplica:
ctx.WriteKeyWord("SET TIFLASH REPLICA ")
ctx.WritePlainf("%d", n.TiFlashReplica.Count)
if len(n.TiFlashReplica.Labels) == 0 {
break
}
ctx.WriteKeyWord(" LOCATION LABELS ")
for i, v := range n.TiFlashReplica.Labels {
if i > 0 {
ctx.WritePlain(", ")
}
ctx.WriteString(v)
}
case AlterTableOption: case AlterTableOption:
switch { switch {
case len(n.Options) == 2 && case len(n.Options) == 2 &&
......
...@@ -187,12 +187,15 @@ type TableName struct { ...@@ -187,12 +187,15 @@ type TableName struct {
} }
// Restore implements Node interface. // Restore implements Node interface.
func (n *TableName) Restore(ctx *RestoreCtx) error { func (n *TableName) restoreName(ctx *RestoreCtx) {
if n.Schema.String() != "" { if n.Schema.String() != "" {
ctx.WriteName(n.Schema.String()) ctx.WriteName(n.Schema.String())
ctx.WritePlain(".") ctx.WritePlain(".")
} }
ctx.WriteName(n.Name.String()) ctx.WriteName(n.Name.String())
}
func (n *TableName) restorePartitions(ctx *RestoreCtx) {
if len(n.PartitionNames) > 0 { if len(n.PartitionNames) > 0 {
ctx.WriteKeyWord(" PARTITION") ctx.WriteKeyWord(" PARTITION")
ctx.WritePlain("(") ctx.WritePlain("(")
...@@ -204,6 +207,9 @@ func (n *TableName) Restore(ctx *RestoreCtx) error { ...@@ -204,6 +207,9 @@ func (n *TableName) Restore(ctx *RestoreCtx) error {
} }
ctx.WritePlain(")") ctx.WritePlain(")")
} }
}
func (n *TableName) restoreIndexHints(ctx *RestoreCtx) error {
for _, value := range n.IndexHints { for _, value := range n.IndexHints {
ctx.WritePlain(" ") ctx.WritePlain(" ")
if err := value.Restore(ctx); err != nil { if err := value.Restore(ctx); err != nil {
...@@ -214,6 +220,12 @@ func (n *TableName) Restore(ctx *RestoreCtx) error { ...@@ -214,6 +220,12 @@ func (n *TableName) Restore(ctx *RestoreCtx) error {
return nil return nil
} }
func (n *TableName) Restore(ctx *RestoreCtx) error {
n.restoreName(ctx)
n.restorePartitions(ctx)
return n.restoreIndexHints(ctx)
}
// IndexHintType is the type for index hint use, ignore or force. // IndexHintType is the type for index hint use, ignore or force.
type IndexHintType int type IndexHintType int
...@@ -381,18 +393,40 @@ func (n *TableSource) Restore(ctx *RestoreCtx) error { ...@@ -381,18 +393,40 @@ func (n *TableSource) Restore(ctx *RestoreCtx) error {
case *SelectStmt, *UnionStmt: case *SelectStmt, *UnionStmt:
needParen = true needParen = true
} }
if needParen {
ctx.WritePlain("(") if tn, tnCase := n.Source.(*TableName); tnCase {
} if needParen {
if err := n.Source.Restore(ctx); err != nil { ctx.WritePlain("(")
return errors.Annotate(err, "An error occurred while restore TableSource.Source") }
}
if needParen { tn.restoreName(ctx)
ctx.WritePlain(")") tn.restorePartitions(ctx)
}
if asName := n.AsName.String(); asName != "" { if asName := n.AsName.String(); asName != "" {
ctx.WriteKeyWord(" AS ") ctx.WriteKeyWord(" AS ")
ctx.WriteName(asName) ctx.WriteName(asName)
}
if err := tn.restoreIndexHints(ctx); err != nil {
return errors.Annotate(err, "An error occurred while restore TableSource.Source.(*TableName).IndexHints")
}
if needParen {
ctx.WritePlain(")")
}
} else {
if needParen {
ctx.WritePlain("(")
}
if err := n.Source.Restore(ctx); err != nil {
return errors.Annotate(err, "An error occurred while restore TableSource.Source")
}
if needParen {
ctx.WritePlain(")")
}
if asName := n.AsName.String(); asName != "" {
ctx.WriteKeyWord(" AS ")
ctx.WriteName(asName)
}
} }
return nil return nil
...@@ -421,6 +455,7 @@ const ( ...@@ -421,6 +455,7 @@ const (
SelectLockNone SelectLockType = iota SelectLockNone SelectLockType = iota
SelectLockForUpdate SelectLockForUpdate
SelectLockInShareMode SelectLockInShareMode
SelectLockForUpdateNoWait
) )
// String implements fmt.Stringer. // String implements fmt.Stringer.
...@@ -432,6 +467,8 @@ func (slt SelectLockType) String() string { ...@@ -432,6 +467,8 @@ func (slt SelectLockType) String() string {
return "for update" return "for update"
case SelectLockInShareMode: case SelectLockInShareMode:
return "in share mode" return "in share mode"
case SelectLockForUpdateNoWait:
return "for update nowait"
} }
return "unsupported select lock type" return "unsupported select lock type"
} }
...@@ -881,7 +918,7 @@ func (n *SelectStmt) Restore(ctx *RestoreCtx) error { ...@@ -881,7 +918,7 @@ func (n *SelectStmt) Restore(ctx *RestoreCtx) error {
case SelectLockInShareMode: case SelectLockInShareMode:
ctx.WriteKeyWord(" LOCK ") ctx.WriteKeyWord(" LOCK ")
ctx.WriteKeyWord(n.LockTp.String()) ctx.WriteKeyWord(n.LockTp.String())
case SelectLockForUpdate: case SelectLockForUpdate, SelectLockForUpdateNoWait:
ctx.WritePlain(" ") ctx.WritePlain(" ")
ctx.WriteKeyWord(n.LockTp.String()) ctx.WriteKeyWord(n.LockTp.String())
} }
...@@ -2427,8 +2464,11 @@ func (n *FrameBound) Accept(v Visitor) (Node, bool) { ...@@ -2427,8 +2464,11 @@ func (n *FrameBound) Accept(v Visitor) (Node, bool) {
type SplitRegionStmt struct { type SplitRegionStmt struct {
dmlNode dmlNode
Table *TableName Table *TableName
IndexName model.CIStr IndexName model.CIStr
PartitionNames []model.CIStr
SplitSyntaxOpt *SplitSyntaxOption
SplitOpt *SplitOption SplitOpt *SplitOption
} }
...@@ -2440,11 +2480,39 @@ type SplitOption struct { ...@@ -2440,11 +2480,39 @@ type SplitOption struct {
ValueLists [][]ExprNode ValueLists [][]ExprNode
} }
type SplitSyntaxOption struct {
HasRegionFor bool
HasPartition bool
}
func (n *SplitRegionStmt) Restore(ctx *RestoreCtx) error { func (n *SplitRegionStmt) Restore(ctx *RestoreCtx) error {
ctx.WriteKeyWord("SPLIT TABLE ") ctx.WriteKeyWord("SPLIT ")
if n.SplitSyntaxOpt != nil {
if n.SplitSyntaxOpt.HasRegionFor {
ctx.WriteKeyWord("REGION FOR ")
}
if n.SplitSyntaxOpt.HasPartition {
ctx.WriteKeyWord("PARTITION ")
}
}
ctx.WriteKeyWord("TABLE ")
if err := n.Table.Restore(ctx); err != nil { if err := n.Table.Restore(ctx); err != nil {
return errors.Annotate(err, "An error occurred while restore SplitIndexRegionStmt.Table") return errors.Annotate(err, "An error occurred while restore SplitIndexRegionStmt.Table")
} }
if len(n.PartitionNames) > 0 {
ctx.WriteKeyWord(" PARTITION")
ctx.WritePlain("(")
for i, v := range n.PartitionNames {
if i != 0 {
ctx.WritePlain(", ")
}
ctx.WriteName(v.String())
}
ctx.WritePlain(")")
}
if len(n.IndexName.L) > 0 { if len(n.IndexName.L) > 0 {
ctx.WriteKeyWord(" INDEX ") ctx.WriteKeyWord(" INDEX ")
ctx.WriteName(n.IndexName.String()) ctx.WriteName(n.IndexName.String())
......
...@@ -246,6 +246,7 @@ const ( ...@@ -246,6 +246,7 @@ const (
Version = "version" Version = "version"
TiDBVersion = "tidb_version" TiDBVersion = "tidb_version"
TiDBIsDDLOwner = "tidb_is_ddl_owner" TiDBIsDDLOwner = "tidb_is_ddl_owner"
TiDBDecodePlan = "tidb_decode_plan"
// control functions // control functions
If = "if" If = "if"
......
...@@ -49,6 +49,7 @@ var ( ...@@ -49,6 +49,7 @@ var (
_ StmtNode = &KillStmt{} _ StmtNode = &KillStmt{}
_ StmtNode = &CreateBindingStmt{} _ StmtNode = &CreateBindingStmt{}
_ StmtNode = &DropBindingStmt{} _ StmtNode = &DropBindingStmt{}
_ StmtNode = &ShutdownStmt{}
_ Node = &PrivElem{} _ Node = &PrivElem{}
_ Node = &VariableAssignment{} _ Node = &VariableAssignment{}
...@@ -1500,6 +1501,7 @@ type AdminStmt struct { ...@@ -1500,6 +1501,7 @@ type AdminStmt struct {
HandleRanges []HandleRange HandleRanges []HandleRange
ShowSlow *ShowSlow ShowSlow *ShowSlow
Plugins []string Plugins []string
Where ExprNode
} }
// Restore implements Node interface. // Restore implements Node interface.
...@@ -1533,6 +1535,12 @@ func (n *AdminStmt) Restore(ctx *RestoreCtx) error { ...@@ -1533,6 +1535,12 @@ func (n *AdminStmt) Restore(ctx *RestoreCtx) error {
if n.JobNumber != 0 { if n.JobNumber != 0 {
ctx.WritePlainf(" %d", n.JobNumber) ctx.WritePlainf(" %d", n.JobNumber)
} }
if n.Where != nil {
ctx.WriteKeyWord(" WHERE ")
if err := n.Where.Restore(ctx); err != nil {
return errors.Annotate(err, "An error occurred while restore ShowStmt.Where")
}
}
case AdminShowNextRowID: case AdminShowNextRowID:
ctx.WriteKeyWord("SHOW ") ctx.WriteKeyWord("SHOW ")
if err := restoreTables(); err != nil { if err := restoreTables(); err != nil {
...@@ -1994,6 +2002,28 @@ func (n *GrantRoleStmt) SecureText() string { ...@@ -1994,6 +2002,28 @@ func (n *GrantRoleStmt) SecureText() string {
return text return text
} }
// ShutdownStmt is a statement to stop the TiDB server.
// See https://dev.mysql.com/doc/refman/5.7/en/shutdown.html
type ShutdownStmt struct {
stmtNode
}
// Restore implements Node interface.
func (n *ShutdownStmt) Restore(ctx *RestoreCtx) error {
ctx.WriteKeyWord("SHUTDOWN")
return nil
}
// Accept implements Node Accept interface.
func (n *ShutdownStmt) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
if skipChildren {
return v.Leave(newNode)
}
n = newNode.(*ShutdownStmt)
return v.Leave(n)
}
// Ident is the table identifier composed of schema name and table name. // Ident is the table identifier composed of schema name and table name.
type Ident struct { type Ident struct {
Schema model.CIStr Schema model.CIStr
......
...@@ -17,7 +17,7 @@ package ast ...@@ -17,7 +17,7 @@ package ast
func IsReadOnly(node Node) bool { func IsReadOnly(node Node) bool {
switch st := node.(type) { switch st := node.(type) {
case *SelectStmt: case *SelectStmt:
if st.LockTp == SelectLockForUpdate { if st.LockTp == SelectLockForUpdate || st.LockTp == SelectLockForUpdateNoWait {
return false return false
} }
......
...@@ -351,6 +351,7 @@ var tokenMap = map[string]int{ ...@@ -351,6 +351,7 @@ var tokenMap = map[string]int{
"KEY_BLOCK_SIZE": keyBlockSize, "KEY_BLOCK_SIZE": keyBlockSize,
"KEYS": keys, "KEYS": keys,
"KILL": kill, "KILL": kill,
"LABELS": labels,
"LAST": last, "LAST": last,
"LEADING": leading, "LEADING": leading,
"LEFT": left, "LEFT": left,
...@@ -365,6 +366,7 @@ var tokenMap = map[string]int{ ...@@ -365,6 +366,7 @@ var tokenMap = map[string]int{
"LOCAL": local, "LOCAL": local,
"LOCALTIME": localTime, "LOCALTIME": localTime,
"LOCALTIMESTAMP": localTs, "LOCALTIMESTAMP": localTs,
"LOCATION": location,
"LOCK": lock, "LOCK": lock,
"LONG": long, "LONG": long,
"LONGBLOB": longblobType, "LONGBLOB": longblobType,
...@@ -469,6 +471,7 @@ var tokenMap = map[string]int{ ...@@ -469,6 +471,7 @@ var tokenMap = map[string]int{
"REFERENCES": references, "REFERENCES": references,
"REGEXP": regexpKwd, "REGEXP": regexpKwd,
"REGIONS": regions, "REGIONS": regions,
"REGION": region,
"RELOAD": reload, "RELOAD": reload,
"REMOVE": remove, "REMOVE": remove,
"RENAME": rename, "RENAME": rename,
...@@ -478,6 +481,7 @@ var tokenMap = map[string]int{ ...@@ -478,6 +481,7 @@ var tokenMap = map[string]int{
"REPEATABLE": repeatable, "REPEATABLE": repeatable,
"REPLACE": replace, "REPLACE": replace,
"RESPECT": respect, "RESPECT": respect,
"REPLICA": replica,
"REPLICATION": replication, "REPLICATION": replication,
"REQUIRE": require, "REQUIRE": require,
"RESTRICT": restrict, "RESTRICT": restrict,
...@@ -510,6 +514,7 @@ var tokenMap = map[string]int{ ...@@ -510,6 +514,7 @@ var tokenMap = map[string]int{
"SHARE": share, "SHARE": share,
"SHARED": shared, "SHARED": shared,
"SHOW": show, "SHOW": show,
"SHUTDOWN": shutdown,
"SIGNED": signed, "SIGNED": signed,
"SIMPLE": simple, "SIMPLE": simple,
"SLAVE": slave, "SLAVE": slave,
...@@ -665,6 +670,7 @@ var tokenMap = map[string]int{ ...@@ -665,6 +670,7 @@ var tokenMap = map[string]int{
"BINDINGS": bindings, "BINDINGS": bindings,
"EXPR_PUSHDOWN_BLACKLIST": exprPushdownBlacklist, "EXPR_PUSHDOWN_BLACKLIST": exprPushdownBlacklist,
"OPT_RULE_BLACKLIST": optRuleBlacklist, "OPT_RULE_BLACKLIST": optRuleBlacklist,
"NOWAIT": nowait,
} }
// See https://dev.mysql.com/doc/refman/5.7/en/function-resolution.html for details // See https://dev.mysql.com/doc/refman/5.7/en/function-resolution.html for details
......
...@@ -58,6 +58,9 @@ const ( ...@@ -58,6 +58,9 @@ const (
ActionModifySchemaCharsetAndCollate ActionType = 26 ActionModifySchemaCharsetAndCollate ActionType = 26
ActionLockTable ActionType = 27 ActionLockTable ActionType = 27
ActionUnlockTable ActionType = 28 ActionUnlockTable ActionType = 28
ActionRepairTable ActionType = 29
ActionSetTiFlashReplica ActionType = 30
ActionUpdateTiFlashReplicaStatus ActionType = 31
) )
// AddIndexStr is a string related to the operation of "add index". // AddIndexStr is a string related to the operation of "add index".
...@@ -92,6 +95,9 @@ var actionMap = map[ActionType]string{ ...@@ -92,6 +95,9 @@ var actionMap = map[ActionType]string{
ActionModifySchemaCharsetAndCollate: "modify schema charset and collate", ActionModifySchemaCharsetAndCollate: "modify schema charset and collate",
ActionLockTable: "lock table", ActionLockTable: "lock table",
ActionUnlockTable: "unlock table", ActionUnlockTable: "unlock table",
ActionRepairTable: "repair table",
ActionSetTiFlashReplica: "set tiflash replica",
ActionUpdateTiFlashReplicaStatus: "update tiflash replica status",
} }
// String return current ddl action in string // String return current ddl action in string
......
...@@ -236,6 +236,9 @@ type TableInfo struct { ...@@ -236,6 +236,9 @@ type TableInfo struct {
// Version means the version of the table info. // Version means the version of the table info.
Version uint16 `json:"version"` Version uint16 `json:"version"`
// TiFlashReplica means the TiFlash replica info.
TiFlashReplica *TiFlashReplicaInfo `json:"tiflash_replica"`
} }
// TableLockInfo provides meta data describing a table lock. // TableLockInfo provides meta data describing a table lock.
...@@ -323,6 +326,13 @@ func (t TableLockType) String() string { ...@@ -323,6 +326,13 @@ func (t TableLockType) String() string {
return "" return ""
} }
// TiFlashReplicaInfo means the flash replica info.
type TiFlashReplicaInfo struct {
Count uint64
LocationLabels []string
Available bool
}
// GetPartitionInfo returns the partition information. // GetPartitionInfo returns the partition information.
func (t *TableInfo) GetPartitionInfo() *PartitionInfo { func (t *TableInfo) GetPartitionInfo() *PartitionInfo {
if t.Partition != nil && t.Partition.Enable { if t.Partition != nil && t.Partition.Enable {
......
...@@ -240,6 +240,9 @@ const ( ...@@ -240,6 +240,9 @@ const (
AlterRoutinePriv AlterRoutinePriv
EventPriv EventPriv
// ShutdownPriv the privilege to shutdown a server.
ShutdownPriv
// AllPriv is the privilege for all actions. // AllPriv is the privilege for all actions.
AllPriv AllPriv
) )
...@@ -311,6 +314,7 @@ var Priv2UserCol = map[PrivilegeType]string{ ...@@ -311,6 +314,7 @@ var Priv2UserCol = map[PrivilegeType]string{
CreateRoutinePriv: "Create_routine_priv", CreateRoutinePriv: "Create_routine_priv",
AlterRoutinePriv: "Alter_routine_priv", AlterRoutinePriv: "Alter_routine_priv",
EventPriv: "Event_priv", EventPriv: "Event_priv",
ShutdownPriv: "Shutdown_priv",
} }
// Col2PrivType is the privilege tables column name to privilege type. // Col2PrivType is the privilege tables column name to privilege type.
...@@ -340,6 +344,7 @@ var Col2PrivType = map[string]PrivilegeType{ ...@@ -340,6 +344,7 @@ var Col2PrivType = map[string]PrivilegeType{
"Create_routine_priv": CreateRoutinePriv, "Create_routine_priv": CreateRoutinePriv,
"Alter_routine_priv": AlterRoutinePriv, "Alter_routine_priv": AlterRoutinePriv,
"Event_priv": EventPriv, "Event_priv": EventPriv,
"Shutdown_priv": ShutdownPriv,
} }
// Command2Str is the command information to command name. // Command2Str is the command information to command name.
...@@ -405,6 +410,7 @@ var Priv2Str = map[PrivilegeType]string{ ...@@ -405,6 +410,7 @@ var Priv2Str = map[PrivilegeType]string{
CreateRoutinePriv: "CREATE ROUTINE", CreateRoutinePriv: "CREATE ROUTINE",
AlterRoutinePriv: "ALTER ROUTINE", AlterRoutinePriv: "ALTER ROUTINE",
EventPriv: "EVENT", EventPriv: "EVENT",
ShutdownPriv: "SHUTDOWN",
} }
// Priv2SetStr is the map for privilege to string. // Priv2SetStr is the map for privilege to string.
...@@ -423,6 +429,7 @@ var Priv2SetStr = map[PrivilegeType]string{ ...@@ -423,6 +429,7 @@ var Priv2SetStr = map[PrivilegeType]string{
ShowViewPriv: "Show View", ShowViewPriv: "Show View",
CreateRolePriv: "Create Role", CreateRolePriv: "Create Role",
DropRolePriv: "Drop Role", DropRolePriv: "Drop Role",
ShutdownPriv: "Shutdown Role",
} }
// SetStr2Priv is the map for privilege set string to privilege type. // SetStr2Priv is the map for privilege set string to privilege type.
...@@ -442,13 +449,13 @@ var SetStr2Priv = map[string]PrivilegeType{ ...@@ -442,13 +449,13 @@ var SetStr2Priv = map[string]PrivilegeType{
} }
// AllGlobalPrivs is all the privileges in global scope. // AllGlobalPrivs is all the privileges in global scope.
var AllGlobalPrivs = []PrivilegeType{SelectPriv, InsertPriv, UpdatePriv, DeletePriv, CreatePriv, DropPriv, ProcessPriv, GrantPriv, ReferencesPriv, AlterPriv, ShowDBPriv, SuperPriv, ExecutePriv, IndexPriv, CreateUserPriv, TriggerPriv, CreateViewPriv, ShowViewPriv, CreateRolePriv, DropRolePriv, CreateTMPTablePriv, LockTablesPriv, CreateRoutinePriv, AlterRoutinePriv, EventPriv} var AllGlobalPrivs = []PrivilegeType{SelectPriv, InsertPriv, UpdatePriv, DeletePriv, CreatePriv, DropPriv, ProcessPriv, ReferencesPriv, AlterPriv, ShowDBPriv, SuperPriv, ExecutePriv, IndexPriv, CreateUserPriv, TriggerPriv, CreateViewPriv, ShowViewPriv, CreateRolePriv, DropRolePriv, CreateTMPTablePriv, LockTablesPriv, CreateRoutinePriv, AlterRoutinePriv, EventPriv, ShutdownPriv}
// AllDBPrivs is all the privileges in database scope. // AllDBPrivs is all the privileges in database scope.
var AllDBPrivs = []PrivilegeType{SelectPriv, InsertPriv, UpdatePriv, DeletePriv, CreatePriv, DropPriv, GrantPriv, AlterPriv, ExecutePriv, IndexPriv, CreateViewPriv, ShowViewPriv} var AllDBPrivs = []PrivilegeType{SelectPriv, InsertPriv, UpdatePriv, DeletePriv, CreatePriv, DropPriv, AlterPriv, ExecutePriv, IndexPriv, CreateViewPriv, ShowViewPriv}
// AllTablePrivs is all the privileges in table scope. // AllTablePrivs is all the privileges in table scope.
var AllTablePrivs = []PrivilegeType{SelectPriv, InsertPriv, UpdatePriv, DeletePriv, CreatePriv, DropPriv, GrantPriv, AlterPriv, IndexPriv} var AllTablePrivs = []PrivilegeType{SelectPriv, InsertPriv, UpdatePriv, DeletePriv, CreatePriv, DropPriv, AlterPriv, IndexPriv}
// AllColumnPrivs is all the privileges in column scope. // AllColumnPrivs is all the privileges in column scope.
var AllColumnPrivs = []PrivilegeType{SelectPriv, InsertPriv, UpdatePriv} var AllColumnPrivs = []PrivilegeType{SelectPriv, InsertPriv, UpdatePriv}
......
...@@ -903,6 +903,7 @@ const ( ...@@ -903,6 +903,7 @@ const (
ErrBadUser = 3162 ErrBadUser = 3162
ErrInvalidEncryptionOption = 3184 ErrInvalidEncryptionOption = 3184
ErrRoleNotGranted = 3530 ErrRoleNotGranted = 3530
ErrLockAcquireFailAndNoWaitSet = 3572
ErrWindowNoSuchWindow = 3579 ErrWindowNoSuchWindow = 3579
ErrWindowCircularityInWindowGraph = 3580 ErrWindowCircularityInWindowGraph = 3580
ErrWindowNoChildPartitioning = 3581 ErrWindowNoChildPartitioning = 3581
......
...@@ -920,6 +920,7 @@ var MySQLErrName = map[uint16]string{ ...@@ -920,6 +920,7 @@ var MySQLErrName = map[uint16]string{
ErrWindowFunctionIgnoresFrame: "Window function '%s' ignores the frame clause of window '%s' and aggregates over the whole partition", ErrWindowFunctionIgnoresFrame: "Window function '%s' ignores the frame clause of window '%s' and aggregates over the whole partition",
ErrRoleNotGranted: "%s is is not granted to %s", ErrRoleNotGranted: "%s is is not granted to %s",
ErrMaxExecTimeExceeded: "Query execution was interrupted, max_execution_time exceeded.", ErrMaxExecTimeExceeded: "Query execution was interrupted, max_execution_time exceeded.",
ErrLockAcquireFailAndNoWaitSet: "Statement aborted because lock(s) could not be acquired immediately and NOWAIT is set.",
// MariaDB errors. // MariaDB errors.
ErrOnlyOneDefaultPartionAllowed: "Only one DEFAULT partition allowed", ErrOnlyOneDefaultPartionAllowed: "Only one DEFAULT partition allowed",
......
...@@ -369,11 +369,13 @@ import ( ...@@ -369,11 +369,13 @@ import (
ipc "IPC" ipc "IPC"
jsonType "JSON" jsonType "JSON"
keyBlockSize "KEY_BLOCK_SIZE" keyBlockSize "KEY_BLOCK_SIZE"
labels "LABELS"
last "LAST" last "LAST"
less "LESS" less "LESS"
level "LEVEL" level "LEVEL"
list "LIST" list "LIST"
local "LOCAL" local "LOCAL"
location "LOCATION"
master "MASTER" master "MASTER"
microsecond "MICROSECOND" microsecond "MICROSECOND"
minute "MINUTE" minute "MINUTE"
...@@ -425,6 +427,7 @@ import ( ...@@ -425,6 +427,7 @@ import (
repair "REPAIR" repair "REPAIR"
repeatable "REPEATABLE" repeatable "REPEATABLE"
respect "RESPECT" respect "RESPECT"
replica "REPLICA"
replication "REPLICATION" replication "REPLICATION"
reverse "REVERSE" reverse "REVERSE"
role "ROLE" role "ROLE"
...@@ -444,6 +447,7 @@ import ( ...@@ -444,6 +447,7 @@ import (
session "SESSION" session "SESSION"
share "SHARE" share "SHARE"
shared "SHARED" shared "SHARED"
shutdown "SHUTDOWN"
signed "SIGNED" signed "SIGNED"
simple "SIMPLE" simple "SIMPLE"
slave "SLAVE" slave "SLAVE"
...@@ -512,6 +516,7 @@ import ( ...@@ -512,6 +516,7 @@ import (
yearType "YEAR" yearType "YEAR"
x509 "X509" x509 "X509"
enforced "ENFORCED" enforced "ENFORCED"
nowait "NOWAIT"
/* The following tokens belong to NotKeywordToken. Notice: make sure these tokens are contained in NotKeywordToken. */ /* The following tokens belong to NotKeywordToken. Notice: make sure these tokens are contained in NotKeywordToken. */
addDate "ADDDATE" addDate "ADDDATE"
...@@ -611,6 +616,7 @@ import ( ...@@ -611,6 +616,7 @@ import (
split "SPLIT" split "SPLIT"
width "WIDTH" width "WIDTH"
regions "REGIONS" regions "REGIONS"
region "REGION"
builtinAddDate builtinAddDate
builtinBitAnd builtinBitAnd
...@@ -687,6 +693,7 @@ import ( ...@@ -687,6 +693,7 @@ import (
SignedLiteral "Literal or NumLiteral with sign" SignedLiteral "Literal or NumLiteral with sign"
DefaultValueExpr "DefaultValueExpr(Now or Signed Literal)" DefaultValueExpr "DefaultValueExpr(Now or Signed Literal)"
NowSymOptionFraction "NowSym with optional fraction part" NowSymOptionFraction "NowSym with optional fraction part"
CharsetNameOrDefault "Character set name or default"
%type <statement> %type <statement>
AdminStmt "Check table statement or show ddl statement" AdminStmt "Check table statement or show ddl statement"
...@@ -749,6 +756,7 @@ import ( ...@@ -749,6 +756,7 @@ import (
UpdateStmt "UPDATE statement" UpdateStmt "UPDATE statement"
UnionStmt "Union select state ment" UnionStmt "Union select state ment"
UseStmt "USE statement" UseStmt "USE statement"
ShutdownStmt "SHUTDOWN statement"
%type <item> %type <item>
AdminShowSlow "Admin Show Slow statement" AdminShowSlow "Admin Show Slow statement"
...@@ -798,6 +806,7 @@ import ( ...@@ -798,6 +806,7 @@ import (
ConstraintKeywordOpt "Constraint Keyword or empty" ConstraintKeywordOpt "Constraint Keyword or empty"
CreateTableOptionListOpt "create table option list opt" CreateTableOptionListOpt "create table option list opt"
CreateTableSelectOpt "Select/Union statement in CREATE TABLE ... SELECT" CreateTableSelectOpt "Select/Union statement in CREATE TABLE ... SELECT"
CreateViewSelectOpt "Select/Union statement in CREATE VIEW ... AS SELECT"
DatabaseOption "CREATE Database specification" DatabaseOption "CREATE Database specification"
DatabaseOptionList "CREATE Database specification list" DatabaseOptionList "CREATE Database specification list"
DatabaseOptionListOpt "CREATE Database specification list opt" DatabaseOptionListOpt "CREATE Database specification list opt"
...@@ -861,6 +870,7 @@ import ( ...@@ -861,6 +870,7 @@ import (
JoinTable "join table" JoinTable "join table"
JoinType "join type" JoinType "join type"
KillOrKillTiDB "Kill or Kill TiDB" KillOrKillTiDB "Kill or Kill TiDB"
LocationLabelList "location label name list"
LikeEscapeOpt "like escape option" LikeEscapeOpt "like escape option"
LikeTableWithOrWithoutParen "LIKE table_name or ( LIKE table_name )" LikeTableWithOrWithoutParen "LIKE table_name or ( LIKE table_name )"
LimitClause "LIMIT clause" LimitClause "LIMIT clause"
...@@ -954,6 +964,7 @@ import ( ...@@ -954,6 +964,7 @@ import (
ShowProfileType "Show profile type" ShowProfileType "Show profile type"
ShowProfileTypes "Show profile types" ShowProfileTypes "Show profile types"
SplitOption "Split Option" SplitOption "Split Option"
SplitSyntaxOption "Split syntax Option"
Starting "Starting by" Starting "Starting by"
StatementList "statement list" StatementList "statement list"
StatsPersistentVal "stats_persistent value" StatsPersistentVal "stats_persistent value"
...@@ -1195,7 +1206,7 @@ import ( ...@@ -1195,7 +1206,7 @@ import (
%right collate %right collate
%right encryption %right encryption
%left splitOptionPriv %left labels
%precedence '(' %precedence '('
%precedence quick %precedence quick
%precedence escape %precedence escape
...@@ -1262,6 +1273,16 @@ AlterTablePartitionOpt: ...@@ -1262,6 +1273,16 @@ AlterTablePartitionOpt:
parser.lastErrorAsWarn() parser.lastErrorAsWarn()
} }
LocationLabelList:
{
$$ = []string{}
}
| "LOCATION" "LABELS" StringList
{
$$ = $3
}
AlterTableSpec: AlterTableSpec:
TableOptionList %prec higherThanComma TableOptionList %prec higherThanComma
{ {
...@@ -1270,6 +1291,17 @@ AlterTableSpec: ...@@ -1270,6 +1291,17 @@ AlterTableSpec:
Options:$1.([]*ast.TableOption), Options:$1.([]*ast.TableOption),
} }
} }
| "SET" "TIFLASH" "REPLICA" LengthNum LocationLabelList
{
tiflashReplicaSpec := &ast.TiFlashReplicaSpec{
Count: $4.(uint64),
Labels: $5.([]string),
}
$$ = &ast.AlterTableSpec{
Tp: ast.AlterTableSetTiFlashReplica,
TiFlashReplica: tiflashReplicaSpec,
}
}
| "CONVERT" "TO" CharsetKw CharsetName OptCollate | "CONVERT" "TO" CharsetKw CharsetName OptCollate
{ {
op := &ast.AlterTableSpec{ op := &ast.AlterTableSpec{
...@@ -1982,19 +2014,23 @@ RecoverTableStmt: ...@@ -1982,19 +2014,23 @@ RecoverTableStmt:
* *
*******************************************************************/ *******************************************************************/
SplitRegionStmt: SplitRegionStmt:
"SPLIT" "TABLE" TableName SplitOption "SPLIT" SplitSyntaxOption "TABLE" TableName PartitionNameListOpt SplitOption
{ {
$$ = &ast.SplitRegionStmt{ $$ = &ast.SplitRegionStmt{
Table: $3.(*ast.TableName), SplitSyntaxOpt: $2.(*ast.SplitSyntaxOption),
SplitOpt: $4.(*ast.SplitOption), Table: $4.(*ast.TableName),
PartitionNames: $5.([]model.CIStr),
SplitOpt: $6.(*ast.SplitOption),
} }
} }
| "SPLIT" "TABLE" TableName "INDEX" Identifier SplitOption | "SPLIT" SplitSyntaxOption "TABLE" TableName PartitionNameListOpt "INDEX" Identifier SplitOption
{ {
$$ = &ast.SplitRegionStmt{ $$ = &ast.SplitRegionStmt{
Table: $3.(*ast.TableName), SplitSyntaxOpt: $2.(*ast.SplitSyntaxOption),
IndexName: model.NewCIStr($5), Table: $4.(*ast.TableName),
SplitOpt: $6.(*ast.SplitOption), PartitionNames: $5.([]model.CIStr),
IndexName: model.NewCIStr($7),
SplitOpt: $8.(*ast.SplitOption),
} }
} }
...@@ -2014,6 +2050,31 @@ SplitOption: ...@@ -2014,6 +2050,31 @@ SplitOption:
} }
} }
SplitSyntaxOption:
/* empty */
{
$$ = &ast.SplitSyntaxOption{}
}
| "REGION" "FOR"
{
$$ = &ast.SplitSyntaxOption{
HasRegionFor: true,
}
}
| "PARTITION"
{
$$ = &ast.SplitSyntaxOption{
HasPartition: true,
}
}
| "REGION" "FOR" "PARTITION"
{
$$ = &ast.SplitSyntaxOption{
HasRegionFor: true,
HasPartition: true,
}
}
/*******************************************************************************************/ /*******************************************************************************************/
AnalyzeTableStmt: AnalyzeTableStmt:
...@@ -3329,6 +3390,27 @@ CreateTableSelectOpt: ...@@ -3329,6 +3390,27 @@ CreateTableSelectOpt:
$$ = &ast.CreateTableStmt{Select: $1} $$ = &ast.CreateTableStmt{Select: $1}
} }
CreateViewSelectOpt:
SelectStmt
{
$$ = $1.(*ast.SelectStmt)
}
|
UnionStmt
{
$$ = $1.(*ast.UnionStmt)
}
|
'(' SelectStmt ')'
{
$$ = $2.(*ast.SelectStmt)
}
|
'(' UnionStmt ')'
{
$$ = $2.(*ast.UnionStmt)
}
LikeTableWithOrWithoutParen: LikeTableWithOrWithoutParen:
"LIKE" TableName "LIKE" TableName
{ {
...@@ -3349,10 +3431,10 @@ LikeTableWithOrWithoutParen: ...@@ -3349,10 +3431,10 @@ LikeTableWithOrWithoutParen:
* as select Col1,Col2 from table WITH LOCAL CHECK OPTION * as select Col1,Col2 from table WITH LOCAL CHECK OPTION
*******************************************************************/ *******************************************************************/
CreateViewStmt: CreateViewStmt:
"CREATE" OrReplace ViewAlgorithm ViewDefiner ViewSQLSecurity "VIEW" ViewName ViewFieldList "AS" SelectStmt ViewCheckOption "CREATE" OrReplace ViewAlgorithm ViewDefiner ViewSQLSecurity "VIEW" ViewName ViewFieldList "AS" CreateViewSelectOpt ViewCheckOption
{ {
startOffset := parser.startOffset(&yyS[yypt-1]) startOffset := parser.startOffset(&yyS[yypt-1])
selStmt := $10.(*ast.SelectStmt) selStmt := $10.(ast.StmtNode)
selStmt.SetText(strings.TrimSpace(parser.src[startOffset:])) selStmt.SetText(strings.TrimSpace(parser.src[startOffset:]))
x := &ast.CreateViewStmt { x := &ast.CreateViewStmt {
OrReplace: $2.(bool), OrReplace: $2.(bool),
...@@ -4351,7 +4433,7 @@ UnReservedKeyword: ...@@ -4351,7 +4433,7 @@ UnReservedKeyword:
| "COLUMNS" | "COMMIT" | "COMPACT" | "COMPRESSED" | "CONSISTENT" | "CURRENT" | "DATA" | "DATE" %prec lowerThanStringLitToken| "DATETIME" | "DAY" | "DEALLOCATE" | "DO" | "DUPLICATE" | "COLUMNS" | "COMMIT" | "COMPACT" | "COMPRESSED" | "CONSISTENT" | "CURRENT" | "DATA" | "DATE" %prec lowerThanStringLitToken| "DATETIME" | "DAY" | "DEALLOCATE" | "DO" | "DUPLICATE"
| "DYNAMIC" | "ENCRYPTION" | "END" | "ENFORCED" | "ENGINE" | "ENGINES" | "ENUM" | "ERRORS" | "ESCAPE" | "EXECUTE" | "FIELDS" | "FIRST" | "FIXED" | "FLUSH" | "FOLLOWING" | "FORMAT" | "FULL" |"GLOBAL" | "DYNAMIC" | "ENCRYPTION" | "END" | "ENFORCED" | "ENGINE" | "ENGINES" | "ENUM" | "ERRORS" | "ESCAPE" | "EXECUTE" | "FIELDS" | "FIRST" | "FIXED" | "FLUSH" | "FOLLOWING" | "FORMAT" | "FULL" |"GLOBAL"
| "HASH" | "HOUR" | "INSERT_METHOD" | "LESS" | "LOCAL" | "LAST" | "NAMES" | "OFFSET" | "PASSWORD" %prec lowerThanEq | "PREPARE" | "QUICK" | "REBUILD" | "REDUNDANT" | "REORGANIZE" | "HASH" | "HOUR" | "INSERT_METHOD" | "LESS" | "LOCAL" | "LAST" | "NAMES" | "OFFSET" | "PASSWORD" %prec lowerThanEq | "PREPARE" | "QUICK" | "REBUILD" | "REDUNDANT" | "REORGANIZE"
| "ROLE" |"ROLLBACK" | "SESSION" | "SIGNED" | "SNAPSHOT" | "START" | "STATUS" | "OPEN"| "SUBPARTITIONS" | "SUBPARTITION" | "TABLES" | "TABLESPACE" | "TEXT" | "THAN" | "TIME" %prec lowerThanStringLitToken | "ROLE" |"ROLLBACK" | "SESSION" | "SIGNED" | "SHUTDOWN" | "SNAPSHOT" | "START" | "STATUS" | "OPEN"| "SUBPARTITIONS" | "SUBPARTITION" | "TABLES" | "TABLESPACE" | "TEXT" | "THAN" | "TIME" %prec lowerThanStringLitToken
| "TIMESTAMP" %prec lowerThanStringLitToken | "TRACE" | "TRANSACTION" | "TRUNCATE" | "UNBOUNDED" | "UNKNOWN" | "VALUE" | "WARNINGS" | "YEAR" | "MODE" | "WEEK" | "ANY" | "SOME" | "USER" | "IDENTIFIED" | "TIMESTAMP" %prec lowerThanStringLitToken | "TRACE" | "TRANSACTION" | "TRUNCATE" | "UNBOUNDED" | "UNKNOWN" | "VALUE" | "WARNINGS" | "YEAR" | "MODE" | "WEEK" | "ANY" | "SOME" | "USER" | "IDENTIFIED"
| "COLLATION" | "COMMENT" | "AVG_ROW_LENGTH" | "CONNECTION" | "CHECKSUM" | "COMPRESSION" | "KEY_BLOCK_SIZE" | "MASTER" | "MAX_ROWS" | "COLLATION" | "COMMENT" | "AVG_ROW_LENGTH" | "CONNECTION" | "CHECKSUM" | "COMPRESSION" | "KEY_BLOCK_SIZE" | "MASTER" | "MAX_ROWS"
| "MIN_ROWS" | "NATIONAL" | "NCHAR" | "ROW_FORMAT" | "QUARTER" | "GRANTS" | "TRIGGERS" | "DELAY_KEY_WRITE" | "ISOLATION" | "JSON" | "MIN_ROWS" | "NATIONAL" | "NCHAR" | "ROW_FORMAT" | "QUARTER" | "GRANTS" | "TRIGGERS" | "DELAY_KEY_WRITE" | "ISOLATION" | "JSON"
...@@ -4363,12 +4445,13 @@ UnReservedKeyword: ...@@ -4363,12 +4445,13 @@ UnReservedKeyword:
| "RECOVER" | "CIPHER" | "SUBJECT" | "ISSUER" | "X509" | "NEVER" | "EXPIRE" | "ACCOUNT" | "INCREMENTAL" | "CPU" | "MEMORY" | "BLOCK" | "IO" | "CONTEXT" | "SWITCHES" | "PAGE" | "FAULTS" | "IPC" | "SWAPS" | "SOURCE" | "RECOVER" | "CIPHER" | "SUBJECT" | "ISSUER" | "X509" | "NEVER" | "EXPIRE" | "ACCOUNT" | "INCREMENTAL" | "CPU" | "MEMORY" | "BLOCK" | "IO" | "CONTEXT" | "SWITCHES" | "PAGE" | "FAULTS" | "IPC" | "SWAPS" | "SOURCE"
| "TRADITIONAL" | "SQL_BUFFER_RESULT" | "DIRECTORY" | "HISTORY" | "LIST" | "NODEGROUP" | "SYSTEM_TIME" | "PARTIAL" | "SIMPLE" | "REMOVE" | "PARTITIONING" | "STORAGE" | "DISK" | "STATS_SAMPLE_PAGES" | "SECONDARY_ENGINE" | "SECONDARY_LOAD" | "SECONDARY_UNLOAD" | "VALIDATION" | "TRADITIONAL" | "SQL_BUFFER_RESULT" | "DIRECTORY" | "HISTORY" | "LIST" | "NODEGROUP" | "SYSTEM_TIME" | "PARTIAL" | "SIMPLE" | "REMOVE" | "PARTITIONING" | "STORAGE" | "DISK" | "STATS_SAMPLE_PAGES" | "SECONDARY_ENGINE" | "SECONDARY_LOAD" | "SECONDARY_UNLOAD" | "VALIDATION"
| "WITHOUT" | "RTREE" | "EXCHANGE" | "COLUMN_FORMAT" | "REPAIR" | "IMPORT" | "DISCARD" | "TABLE_CHECKSUM" | "UNICODE" | "WITHOUT" | "RTREE" | "EXCHANGE" | "COLUMN_FORMAT" | "REPAIR" | "IMPORT" | "DISCARD" | "TABLE_CHECKSUM" | "UNICODE"
| "SQL_TSI_DAY" | "SQL_TSI_HOUR" | "SQL_TSI_MINUTE" | "SQL_TSI_MONTH" | "SQL_TSI_QUARTER" | "SQL_TSI_SECOND" | "SQL_TSI_WEEK" | "SQL_TSI_YEAR" | "INVISIBLE" | "VISIBLE" | "TYPE" | "SQL_TSI_DAY" | "SQL_TSI_HOUR" | "SQL_TSI_MINUTE" | "SQL_TSI_MONTH" | "SQL_TSI_QUARTER" | "SQL_TSI_SECOND" |
"SQL_TSI_WEEK" | "SQL_TSI_YEAR" | "INVISIBLE" | "VISIBLE" | "TYPE" | "NOWAIT" | "REPLICA" | "LOCATION" | "LABELS"
TiDBKeyword: TiDBKeyword:
"ADMIN" | "AGG_TO_COP" |"BUCKETS" | "BUILTINS" | "CANCEL" | "CMSKETCH" | "DDL" | "DEPTH" | "DRAINER" | "JOBS" | "JOB" | "NODE_ID" | "NODE_STATE" | "PUMP" | "SAMPLES" | "STATS" | "STATS_META" | "STATS_HISTOGRAMS" | "STATS_BUCKETS" | "STATS_HEALTHY" | "TIDB" "ADMIN" | "AGG_TO_COP" |"BUCKETS" | "BUILTINS" | "CANCEL" | "CMSKETCH" | "DDL" | "DEPTH" | "DRAINER" | "JOBS" | "JOB" | "NODE_ID" | "NODE_STATE" | "PUMP" | "SAMPLES" | "STATS" | "STATS_META" | "STATS_HISTOGRAMS" | "STATS_BUCKETS" | "STATS_HEALTHY" | "TIDB"
| "HASH_JOIN" | "SM_JOIN" | "INL_JOIN" | "HASH_AGG" | "STREAM_AGG" | "USE_INDEX" | "IGNORE_INDEX" | "USE_INDEX_MERGE" | "NO_INDEX_MERGE" | "USE_TOJA" | "ENABLE_PLAN_CACHE" | "USE_PLAN_CACHE" | "HASH_JOIN" | "SM_JOIN" | "INL_JOIN" | "HASH_AGG" | "STREAM_AGG" | "USE_INDEX" | "IGNORE_INDEX" | "USE_INDEX_MERGE" | "NO_INDEX_MERGE" | "USE_TOJA" | "ENABLE_PLAN_CACHE" | "USE_PLAN_CACHE"
| "READ_CONSISTENT_REPLICA" | "READ_FROM_STORAGE" | "QB_NAME" | "QUERY_TYPE" | "MEMORY_QUOTA" | "OLAP" | "OLTP" | "TOPN" | "TIKV" | "TIFLASH" | "SPLIT" | "OPTIMISTIC" | "PESSIMISTIC" | "WIDTH" | "REGIONS" | "READ_CONSISTENT_REPLICA" | "READ_FROM_STORAGE" | "QB_NAME" | "QUERY_TYPE" | "MEMORY_QUOTA" | "OLAP" | "OLTP" | "TOPN" | "TIKV" | "TIFLASH" | "SPLIT" | "OPTIMISTIC" | "PESSIMISTIC" | "WIDTH" | "REGIONS" | "REGION"
NotKeywordToken: NotKeywordToken:
"ADDDATE" | "BIT_AND" | "BIT_OR" | "BIT_XOR" | "CAST" | "COPY" | "COUNT" | "CURTIME" | "DATE_ADD" | "DATE_SUB" | "EXTRACT" | "GET_FORMAT" | "GROUP_CONCAT" "ADDDATE" | "BIT_AND" | "BIT_OR" | "BIT_XOR" | "CAST" | "COPY" | "COUNT" | "CURTIME" | "DATE_ADD" | "DATE_SUB" | "EXTRACT" | "GET_FORMAT" | "GROUP_CONCAT"
...@@ -5904,6 +5987,12 @@ RollbackStmt: ...@@ -5904,6 +5987,12 @@ RollbackStmt:
$$ = &ast.RollbackStmt{} $$ = &ast.RollbackStmt{}
} }
ShutdownStmt:
"SHUTDOWN"
{
$$ = &ast.ShutdownStmt{}
}
SelectStmtBasic: SelectStmtBasic:
"SELECT" SelectStmtOpts SelectStmtFieldList "SELECT" SelectStmtOpts SelectStmtFieldList
{ {
...@@ -6969,6 +7058,10 @@ SelectLockOpt: ...@@ -6969,6 +7058,10 @@ SelectLockOpt:
{ {
$$ = ast.SelectLockForUpdate $$ = ast.SelectLockForUpdate
} }
| "FOR" "UPDATE" "NOWAIT"
{
$$ = ast.SelectLockForUpdateNoWait
}
| "LOCK" "IN" "SHARE" "MODE" | "LOCK" "IN" "SHARE" "MODE"
{ {
$$ = ast.SelectLockInShareMode $$ = ast.SelectLockInShareMode
...@@ -7337,12 +7430,24 @@ VariableAssignment: ...@@ -7337,12 +7430,24 @@ VariableAssignment:
ExtendValue: ast.NewValueExpr($4.(string)), ExtendValue: ast.NewValueExpr($4.(string)),
} }
} }
| CharsetKw CharsetName | "NAMES" "DEFAULT"
{ {
$$ = &ast.VariableAssignment{ v := &ast.DefaultExpr{}
Name: ast.SetNames, $$ = &ast.VariableAssignment{Name: ast.SetNames, Value: v}
Value: ast.NewValueExpr($2.(string)), }
} | CharsetKw CharsetNameOrDefault
{
$$ = &ast.VariableAssignment{Name: ast.SetNames, Value: $2}
}
CharsetNameOrDefault:
CharsetName
{
$$ = ast.NewValueExpr($1.(string))
}
| "DEFAULT"
{
$$ = &ast.DefaultExpr{}
} }
CharsetName: CharsetName:
...@@ -7502,16 +7607,24 @@ AdminStmt: ...@@ -7502,16 +7607,24 @@ AdminStmt:
{ {
$$ = &ast.AdminStmt{Tp: ast.AdminShowDDL} $$ = &ast.AdminStmt{Tp: ast.AdminShowDDL}
} }
| "ADMIN" "SHOW" "DDL" "JOBS" | "ADMIN" "SHOW" "DDL" "JOBS" WhereClauseOptional
{ {
$$ = &ast.AdminStmt{Tp: ast.AdminShowDDLJobs} stmt := &ast.AdminStmt{Tp: ast.AdminShowDDLJobs}
if $5 != nil {
stmt.Where = $5.(ast.ExprNode)
}
$$ = stmt
} }
| "ADMIN" "SHOW" "DDL" "JOBS" NUM | "ADMIN" "SHOW" "DDL" "JOBS" NUM WhereClauseOptional
{ {
$$ = &ast.AdminStmt{ stmt := &ast.AdminStmt{
Tp: ast.AdminShowDDLJobs, Tp: ast.AdminShowDDLJobs,
JobNumber: $5.(int64), JobNumber: $5.(int64),
} }
if $6 != nil {
stmt.Where = $6.(ast.ExprNode)
}
$$ = stmt
} }
| "ADMIN" "SHOW" TableName "NEXT_ROW_ID" | "ADMIN" "SHOW" TableName "NEXT_ROW_ID"
{ {
...@@ -7620,6 +7733,13 @@ AdminStmt: ...@@ -7620,6 +7733,13 @@ AdminStmt:
Tables: $5.([]*ast.TableName), Tables: $5.([]*ast.TableName),
} }
} }
| "ADMIN" "REPAIR" "TABLE" TableName CreateTableStmt
{
$$ = &ast.RepairTableStmt{
Table: $4.(*ast.TableName),
CreateStmt: $5.(*ast.CreateTableStmt),
}
}
AdminShowSlow: AdminShowSlow:
"RECENT" NUM "RECENT" NUM
...@@ -8326,6 +8446,7 @@ Statement: ...@@ -8326,6 +8446,7 @@ Statement:
| UseStmt | UseStmt
| UnlockTablesStmt | UnlockTablesStmt
| LockTablesStmt | LockTablesStmt
| ShutdownStmt
TraceableStmt: TraceableStmt:
SelectStmt SelectStmt
...@@ -9975,6 +10096,10 @@ PrivType: ...@@ -9975,6 +10096,10 @@ PrivType:
{ {
$$ = mysql.EventPriv $$ = mysql.EventPriv
} }
| "SHUTDOWN"
{
$$ = mysql.ShutdownPriv
}
ObjectType: ObjectType:
{ {
......
...@@ -1227,6 +1227,7 @@ func (d *Datum) convertToMysqlYear(sc *stmtctx.StatementContext, target *FieldTy ...@@ -1227,6 +1227,7 @@ func (d *Datum) convertToMysqlYear(sc *stmtctx.StatementContext, target *FieldTy
s := d.GetString() s := d.GetString()
y, err = StrToInt(sc, s) y, err = StrToInt(sc, s)
if err != nil { if err != nil {
ret.SetInt64(0)
return ret, errors.Trace(err) return ret, errors.Trace(err)
} }
if len(s) != 4 && len(s) > 0 && s[0:1] == "0" { if len(s) != 4 && len(s) > 0 && s[0:1] == "0" {
...@@ -1239,16 +1240,18 @@ func (d *Datum) convertToMysqlYear(sc *stmtctx.StatementContext, target *FieldTy ...@@ -1239,16 +1240,18 @@ func (d *Datum) convertToMysqlYear(sc *stmtctx.StatementContext, target *FieldTy
default: default:
ret, err = d.convertToInt(sc, NewFieldType(mysql.TypeLonglong)) ret, err = d.convertToInt(sc, NewFieldType(mysql.TypeLonglong))
if err != nil { if err != nil {
return invalidConv(d, target.Tp) _, err = invalidConv(d, target.Tp)
ret.SetInt64(0)
return ret, err
} }
y = ret.GetInt64() y = ret.GetInt64()
} }
y, err = AdjustYear(y, adjust) y, err = AdjustYear(y, adjust)
if err != nil { if err != nil {
return invalidConv(d, target.Tp) _, err = invalidConv(d, target.Tp)
} }
ret.SetInt64(y) ret.SetInt64(y)
return ret, nil return ret, err
} }
func (d *Datum) convertToMysqlBit(sc *stmtctx.StatementContext, target *FieldType) (Datum, error) { func (d *Datum) convertToMysqlBit(sc *stmtctx.StatementContext, target *FieldType) (Datum, error) {
......
...@@ -250,21 +250,6 @@ func (d *MyDecimal) GetDigitsFrac() int8 { ...@@ -250,21 +250,6 @@ func (d *MyDecimal) GetDigitsFrac() int8 {
return d.digitsFrac return d.digitsFrac
} }
// Copy copies a new *MyDecimal from itself.
func (d *MyDecimal) Copy() *MyDecimal {
if d == nil {
return nil
}
dst := &MyDecimal{
digitsInt: d.digitsInt,
digitsFrac: d.digitsFrac,
resultFrac: d.resultFrac,
negative: d.negative,
}
copy(dst.wordBuf[:], d.wordBuf[:])
return dst
}
// String returns the decimal string representation rounded to resultFrac. // String returns the decimal string representation rounded to resultFrac.
func (d *MyDecimal) String() string { func (d *MyDecimal) String() string {
tmp := *d tmp := *d
...@@ -1500,6 +1485,7 @@ func DecimalNeg(from *MyDecimal) *MyDecimal { ...@@ -1500,6 +1485,7 @@ func DecimalNeg(from *MyDecimal) *MyDecimal {
// Note: DO NOT use `from1` or `from2` as `to` since the metadata // Note: DO NOT use `from1` or `from2` as `to` since the metadata
// of `to` may be changed during evaluating. // of `to` may be changed during evaluating.
func DecimalAdd(from1, from2, to *MyDecimal) error { func DecimalAdd(from1, from2, to *MyDecimal) error {
from1, from2, to = validateArgs(from1, from2, to)
to.resultFrac = myMaxInt8(from1.resultFrac, from2.resultFrac) to.resultFrac = myMaxInt8(from1.resultFrac, from2.resultFrac)
if from1.negative == from2.negative { if from1.negative == from2.negative {
return doAdd(from1, from2, to) return doAdd(from1, from2, to)
...@@ -1510,6 +1496,7 @@ func DecimalAdd(from1, from2, to *MyDecimal) error { ...@@ -1510,6 +1496,7 @@ func DecimalAdd(from1, from2, to *MyDecimal) error {
// DecimalSub subs one decimal from another, sets the result to 'to'. // DecimalSub subs one decimal from another, sets the result to 'to'.
func DecimalSub(from1, from2, to *MyDecimal) error { func DecimalSub(from1, from2, to *MyDecimal) error {
from1, from2, to = validateArgs(from1, from2, to)
to.resultFrac = myMaxInt8(from1.resultFrac, from2.resultFrac) to.resultFrac = myMaxInt8(from1.resultFrac, from2.resultFrac)
if from1.negative == from2.negative { if from1.negative == from2.negative {
_, err := doSub(from1, from2, to) _, err := doSub(from1, from2, to)
...@@ -1518,6 +1505,28 @@ func DecimalSub(from1, from2, to *MyDecimal) error { ...@@ -1518,6 +1505,28 @@ func DecimalSub(from1, from2, to *MyDecimal) error {
return doAdd(from1, from2, to) return doAdd(from1, from2, to)
} }
func validateArgs(f1, f2, to *MyDecimal) (*MyDecimal, *MyDecimal, *MyDecimal) {
if to == nil {
return f1, f2, to
}
if f1 == to {
tmp := *f1
f1 = &tmp
}
if f2 == to {
tmp := *f2
f2 = &tmp
}
to.digitsFrac = 0
to.digitsInt = 0
to.resultFrac = 0
to.negative = false
for i := range to.wordBuf {
to.wordBuf[i] = 0
}
return f1, f2, to
}
func doSub(from1, from2, to *MyDecimal) (cmp int, err error) { func doSub(from1, from2, to *MyDecimal) (cmp int, err error) {
var ( var (
wordsInt1 = digitsToWords(int(from1.digitsInt)) wordsInt1 = digitsToWords(int(from1.digitsInt))
...@@ -1838,6 +1847,7 @@ DecimalMul multiplies two decimals. ...@@ -1838,6 +1847,7 @@ DecimalMul multiplies two decimals.
digits, fast multiplication must be implemented. digits, fast multiplication must be implemented.
*/ */
func DecimalMul(from1, from2, to *MyDecimal) error { func DecimalMul(from1, from2, to *MyDecimal) error {
from1, from2, to = validateArgs(from1, from2, to)
var ( var (
err error err error
wordsInt1 = digitsToWords(int(from1.digitsInt)) wordsInt1 = digitsToWords(int(from1.digitsInt))
...@@ -1966,6 +1976,7 @@ func DecimalMul(from1, from2, to *MyDecimal) error { ...@@ -1966,6 +1976,7 @@ func DecimalMul(from1, from2, to *MyDecimal) error {
// to - quotient // to - quotient
// fracIncr - increment of fraction // fracIncr - increment of fraction
func DecimalDiv(from1, from2, to *MyDecimal, fracIncr int) error { func DecimalDiv(from1, from2, to *MyDecimal, fracIncr int) error {
from1, from2, to = validateArgs(from1, from2, to)
to.resultFrac = myMinInt8(from1.resultFrac+int8(fracIncr), mysql.MaxDecimalScale) to.resultFrac = myMinInt8(from1.resultFrac+int8(fracIncr), mysql.MaxDecimalScale)
return doDivMod(from1, from2, to, nil, fracIncr) return doDivMod(from1, from2, to, nil, fracIncr)
} }
...@@ -1995,6 +2006,7 @@ DecimalMod does modulus of two decimals. ...@@ -1995,6 +2006,7 @@ DecimalMod does modulus of two decimals.
thus, there's no requirement for M or N to be integers thus, there's no requirement for M or N to be integers
*/ */
func DecimalMod(from1, from2, to *MyDecimal) error { func DecimalMod(from1, from2, to *MyDecimal) error {
from1, from2, to = validateArgs(from1, from2, to)
to.resultFrac = myMaxInt8(from1.resultFrac, from2.resultFrac) to.resultFrac = myMaxInt8(from1.resultFrac, from2.resultFrac)
return doDivMod(from1, from2, nil, to, 0) return doDivMod(from1, from2, nil, to, 0)
} }
......
...@@ -2199,6 +2199,11 @@ func strToDate(t *MysqlTime, date string, format string, ctx map[string]int) boo ...@@ -2199,6 +2199,11 @@ func strToDate(t *MysqlTime, date string, format string, ctx map[string]int) boo
return true return true
} }
if len(date) == 0 {
ctx[token] = 0
return true
}
dateRemain, succ := matchDateWithToken(t, date, token, ctx) dateRemain, succ := matchDateWithToken(t, date, token, ctx)
if !succ { if !succ {
return false return false
...@@ -2316,21 +2321,14 @@ func GetFormatType(format string) (isDuration, isDate bool) { ...@@ -2316,21 +2321,14 @@ func GetFormatType(format string) (isDuration, isDate bool) {
isDuration, isDate = false, false isDuration, isDate = false, false
break break
} }
var durationTokens bool
var dateTokens bool
if len(token) >= 2 && token[0] == '%' { if len(token) >= 2 && token[0] == '%' {
switch token[1] { switch token[1] {
case 'h', 'H', 'i', 'I', 's', 'S', 'k', 'l': case 'h', 'H', 'i', 'I', 's', 'S', 'k', 'l', 'f':
durationTokens = true isDuration = true
case 'y', 'Y', 'm', 'M', 'c', 'b', 'D', 'd', 'e': case 'y', 'Y', 'm', 'M', 'c', 'b', 'D', 'd', 'e':
dateTokens = true isDate = true
} }
} }
if durationTokens {
isDuration = true
} else if dateTokens {
isDate = true
}
if isDuration && isDate { if isDuration && isDate {
break break
} }
......
...@@ -44,7 +44,9 @@ const ( ...@@ -44,7 +44,9 @@ const (
// DefaultSlowThreshold is the default slow log threshold in millisecond. // DefaultSlowThreshold is the default slow log threshold in millisecond.
DefaultSlowThreshold = 300 DefaultSlowThreshold = 300
// DefaultQueryLogMaxLen is the default max length of the query in the log. // DefaultQueryLogMaxLen is the default max length of the query in the log.
DefaultQueryLogMaxLen = 2048 DefaultQueryLogMaxLen = 4096
// DefaultRecordPlanInSlowLog is the default value for whether enable log query plan in the slow log.
DefaultRecordPlanInSlowLog = 1
) )
// EmptyFileLogConfig is an empty FileLogConfig. // EmptyFileLogConfig is an empty FileLogConfig.
...@@ -56,10 +58,9 @@ type FileLogConfig struct { ...@@ -56,10 +58,9 @@ type FileLogConfig struct {
} }
// NewFileLogConfig creates a FileLogConfig. // NewFileLogConfig creates a FileLogConfig.
func NewFileLogConfig(rotate bool, maxSize uint) FileLogConfig { func NewFileLogConfig(maxSize uint) FileLogConfig {
return FileLogConfig{FileLogConfig: zaplog.FileLogConfig{ return FileLogConfig{FileLogConfig: zaplog.FileLogConfig{
LogRotate: rotate, MaxSize: int(maxSize),
MaxSize: int(maxSize),
}, },
} }
} }
...@@ -292,9 +293,8 @@ func InitZapLogger(cfg *LogConfig) error { ...@@ -292,9 +293,8 @@ func InitZapLogger(cfg *LogConfig) error {
if len(cfg.SlowQueryFile) != 0 { if len(cfg.SlowQueryFile) != 0 {
sqfCfg := zaplog.FileLogConfig{ sqfCfg := zaplog.FileLogConfig{
LogRotate: cfg.File.LogRotate, MaxSize: cfg.File.MaxSize,
MaxSize: cfg.File.MaxSize, Filename: cfg.SlowQueryFile,
Filename: cfg.SlowQueryFile,
} }
sqCfg := &zaplog.Config{ sqCfg := &zaplog.Config{
Level: cfg.Level, Level: cfg.Level,
......
...@@ -129,118 +129,118 @@ ...@@ -129,118 +129,118 @@
"revisionTime": "2019-03-07T07:54:52Z" "revisionTime": "2019-03-07T07:54:52Z"
}, },
{ {
"checksumSHA1": "QR1zSwFP8BdkTjNFC+/5gTS8C6c=", "checksumSHA1": "2uDnUGEufCT0+kt4oKwe7G81+OQ=",
"path": "github.com/pingcap/parser", "path": "github.com/pingcap/parser",
"revision": "51a2e3b2e34b61a7519e7d3e17dac38f0e8684f7", "revision": "b10cc800c4e47e8ac3809c8549c4123a5271dcca",
"revisionTime": "2019-10-08T03:21:57Z" "revisionTime": "2019-10-22T01:55:17Z"
}, },
{ {
"checksumSHA1": "I4zlpjlOMFiWnRtAoSj50RSHsvk=", "checksumSHA1": "C7qqPFYLpVVMKb2EnxetcWvjv1M=",
"path": "github.com/pingcap/parser/ast", "path": "github.com/pingcap/parser/ast",
"revision": "51a2e3b2e34b61a7519e7d3e17dac38f0e8684f7", "revision": "b10cc800c4e47e8ac3809c8549c4123a5271dcca",
"revisionTime": "2019-10-08T03:21:57Z" "revisionTime": "2019-10-22T01:55:17Z"
}, },
{ {
"checksumSHA1": "xiv40YqnvHcbIhaEzJqjh5K7ehM=", "checksumSHA1": "xiv40YqnvHcbIhaEzJqjh5K7ehM=",
"path": "github.com/pingcap/parser/auth", "path": "github.com/pingcap/parser/auth",
"revision": "51a2e3b2e34b61a7519e7d3e17dac38f0e8684f7", "revision": "b10cc800c4e47e8ac3809c8549c4123a5271dcca",
"revisionTime": "2019-10-08T03:21:57Z" "revisionTime": "2019-10-22T01:55:17Z"
}, },
{ {
"checksumSHA1": "EvDXpplklIXmKqLclzWzaN/uHKQ=", "checksumSHA1": "EvDXpplklIXmKqLclzWzaN/uHKQ=",
"path": "github.com/pingcap/parser/charset", "path": "github.com/pingcap/parser/charset",
"revision": "51a2e3b2e34b61a7519e7d3e17dac38f0e8684f7", "revision": "b10cc800c4e47e8ac3809c8549c4123a5271dcca",
"revisionTime": "2019-10-08T03:21:57Z" "revisionTime": "2019-10-22T01:55:17Z"
}, },
{ {
"checksumSHA1": "Aao6Mul/qqogOwPwM2arBKZkYZs=", "checksumSHA1": "Aao6Mul/qqogOwPwM2arBKZkYZs=",
"path": "github.com/pingcap/parser/format", "path": "github.com/pingcap/parser/format",
"revision": "51a2e3b2e34b61a7519e7d3e17dac38f0e8684f7", "revision": "b10cc800c4e47e8ac3809c8549c4123a5271dcca",
"revisionTime": "2019-10-08T03:21:57Z" "revisionTime": "2019-10-22T01:55:17Z"
}, },
{ {
"checksumSHA1": "GAJ7IUg0t8DCKJbJQxJLkklEj2E=", "checksumSHA1": "p8oGDBAfGZ6nLZxwwKvMLuWCBh8=",
"path": "github.com/pingcap/parser/model", "path": "github.com/pingcap/parser/model",
"revision": "51a2e3b2e34b61a7519e7d3e17dac38f0e8684f7", "revision": "b10cc800c4e47e8ac3809c8549c4123a5271dcca",
"revisionTime": "2019-10-08T03:21:57Z" "revisionTime": "2019-10-22T01:55:17Z"
}, },
{ {
"checksumSHA1": "pN8v8r1syhLlLXw9TOq6bFgJfnY=", "checksumSHA1": "KSbc38GqBQdMUeDXRbC1m0cmkfI=",
"path": "github.com/pingcap/parser/mysql", "path": "github.com/pingcap/parser/mysql",
"revision": "51a2e3b2e34b61a7519e7d3e17dac38f0e8684f7", "revision": "b10cc800c4e47e8ac3809c8549c4123a5271dcca",
"revisionTime": "2019-10-08T03:21:57Z" "revisionTime": "2019-10-22T01:55:17Z"
}, },
{ {
"checksumSHA1": "olapD16WCMBU9vrA5PtlERGFfXw=", "checksumSHA1": "olapD16WCMBU9vrA5PtlERGFfXw=",
"path": "github.com/pingcap/parser/opcode", "path": "github.com/pingcap/parser/opcode",
"revision": "51a2e3b2e34b61a7519e7d3e17dac38f0e8684f7", "revision": "b10cc800c4e47e8ac3809c8549c4123a5271dcca",
"revisionTime": "2019-10-08T03:21:57Z" "revisionTime": "2019-10-22T01:55:17Z"
}, },
{ {
"checksumSHA1": "L6rzy3sJU1RPf7AkJN+0zcwW/YY=", "checksumSHA1": "L6rzy3sJU1RPf7AkJN+0zcwW/YY=",
"path": "github.com/pingcap/parser/terror", "path": "github.com/pingcap/parser/terror",
"revision": "51a2e3b2e34b61a7519e7d3e17dac38f0e8684f7", "revision": "b10cc800c4e47e8ac3809c8549c4123a5271dcca",
"revisionTime": "2019-10-08T03:21:57Z" "revisionTime": "2019-10-22T01:55:17Z"
}, },
{ {
"checksumSHA1": "u1Lmm4Fa3su4ElZMN4w0hPzFZl4=", "checksumSHA1": "u1Lmm4Fa3su4ElZMN4w0hPzFZl4=",
"path": "github.com/pingcap/parser/types", "path": "github.com/pingcap/parser/types",
"revision": "51a2e3b2e34b61a7519e7d3e17dac38f0e8684f7", "revision": "b10cc800c4e47e8ac3809c8549c4123a5271dcca",
"revisionTime": "2019-10-08T03:21:57Z" "revisionTime": "2019-10-22T01:55:17Z"
}, },
{ {
"checksumSHA1": "guCKXZsHObqyjp6P2BwLSUpcG+Y=", "checksumSHA1": "guCKXZsHObqyjp6P2BwLSUpcG+Y=",
"path": "github.com/pingcap/tidb/sessionctx/stmtctx", "path": "github.com/pingcap/tidb/sessionctx/stmtctx",
"revision": "7c776be85d4445edd894052cc7585c310be6fca6", "revision": "58fc7d44f73b65cc4cf9121bd540d905c774b588",
"revisionTime": "2019-10-08T05:59:24Z" "revisionTime": "2019-10-23T07:08:59Z"
}, },
{ {
"checksumSHA1": "DIDA04qsKrAzuwlq+uJrY3wTU2Y=", "checksumSHA1": "oz6sCtUOhry0rhxsqKbWaJX8Suk=",
"path": "github.com/pingcap/tidb/types", "path": "github.com/pingcap/tidb/types",
"revision": "7c776be85d4445edd894052cc7585c310be6fca6", "revision": "58fc7d44f73b65cc4cf9121bd540d905c774b588",
"revisionTime": "2019-10-08T05:59:24Z" "revisionTime": "2019-10-23T07:08:59Z"
}, },
{ {
"checksumSHA1": "OSOQVeP518zWu3RoYSDWoh7DIjg=", "checksumSHA1": "OSOQVeP518zWu3RoYSDWoh7DIjg=",
"path": "github.com/pingcap/tidb/types/json", "path": "github.com/pingcap/tidb/types/json",
"revision": "7c776be85d4445edd894052cc7585c310be6fca6", "revision": "58fc7d44f73b65cc4cf9121bd540d905c774b588",
"revisionTime": "2019-10-08T05:59:24Z" "revisionTime": "2019-10-23T07:08:59Z"
}, },
{ {
"checksumSHA1": "45zWX5Q6D6aTEWtc4p/lbD9WD4o=", "checksumSHA1": "45zWX5Q6D6aTEWtc4p/lbD9WD4o=",
"path": "github.com/pingcap/tidb/types/parser_driver", "path": "github.com/pingcap/tidb/types/parser_driver",
"revision": "7c776be85d4445edd894052cc7585c310be6fca6", "revision": "58fc7d44f73b65cc4cf9121bd540d905c774b588",
"revisionTime": "2019-10-08T05:59:24Z" "revisionTime": "2019-10-23T07:08:59Z"
}, },
{ {
"checksumSHA1": "oCrNchmOGNQTnrkjk5CxFZpu2rE=", "checksumSHA1": "oCrNchmOGNQTnrkjk5CxFZpu2rE=",
"path": "github.com/pingcap/tidb/util/execdetails", "path": "github.com/pingcap/tidb/util/execdetails",
"revision": "7c776be85d4445edd894052cc7585c310be6fca6", "revision": "58fc7d44f73b65cc4cf9121bd540d905c774b588",
"revisionTime": "2019-10-08T05:59:24Z" "revisionTime": "2019-10-23T07:08:59Z"
}, },
{ {
"checksumSHA1": "QGCTegCx13wJyB0isXsV7mNIljE=", "checksumSHA1": "QGCTegCx13wJyB0isXsV7mNIljE=",
"path": "github.com/pingcap/tidb/util/hack", "path": "github.com/pingcap/tidb/util/hack",
"revision": "7c776be85d4445edd894052cc7585c310be6fca6", "revision": "58fc7d44f73b65cc4cf9121bd540d905c774b588",
"revisionTime": "2019-10-08T05:59:24Z" "revisionTime": "2019-10-23T07:08:59Z"
}, },
{ {
"checksumSHA1": "SZhLPQR66Rd4kWkva6W3sJmSNLY=", "checksumSHA1": "NHsKdiYnPgrXvKeFN53WMH+SRwU=",
"path": "github.com/pingcap/tidb/util/logutil", "path": "github.com/pingcap/tidb/util/logutil",
"revision": "7c776be85d4445edd894052cc7585c310be6fca6", "revision": "58fc7d44f73b65cc4cf9121bd540d905c774b588",
"revisionTime": "2019-10-08T05:59:24Z" "revisionTime": "2019-10-23T07:08:59Z"
}, },
{ {
"checksumSHA1": "OveQu0ABBJmMEwmmthqSRQC2Ef0=", "checksumSHA1": "OveQu0ABBJmMEwmmthqSRQC2Ef0=",
"path": "github.com/pingcap/tidb/util/math", "path": "github.com/pingcap/tidb/util/math",
"revision": "7c776be85d4445edd894052cc7585c310be6fca6", "revision": "58fc7d44f73b65cc4cf9121bd540d905c774b588",
"revisionTime": "2019-10-08T05:59:24Z" "revisionTime": "2019-10-23T07:08:59Z"
}, },
{ {
"checksumSHA1": "EhvViFDlyohEB9dvepvISTP28Zg=", "checksumSHA1": "EhvViFDlyohEB9dvepvISTP28Zg=",
"path": "github.com/pingcap/tidb/util/memory", "path": "github.com/pingcap/tidb/util/memory",
"revision": "7c776be85d4445edd894052cc7585c310be6fca6", "revision": "58fc7d44f73b65cc4cf9121bd540d905c774b588",
"revisionTime": "2019-10-08T05:59:24Z" "revisionTime": "2019-10-23T07:08:59Z"
}, },
{ {
"checksumSHA1": "QPIBwDNUFF5Whrnd41S3mkKa4gQ=", "checksumSHA1": "QPIBwDNUFF5Whrnd41S3mkKa4gQ=",
...@@ -497,74 +497,74 @@ ...@@ -497,74 +497,74 @@
{ {
"checksumSHA1": "aKn1oKcY74N8TRLm3Ayt7Q4bbI4=", "checksumSHA1": "aKn1oKcY74N8TRLm3Ayt7Q4bbI4=",
"path": "vitess.io/vitess/go/bytes2", "path": "vitess.io/vitess/go/bytes2",
"revision": "2c8664c8005b440c11fd070d30357c90f749f140", "revision": "590a06f9277fd29d7c9f77d50c4b11f1ba48f41c",
"revisionTime": "2019-10-07T23:18:38Z" "revisionTime": "2019-10-19T20:56:25Z"
}, },
{ {
"checksumSHA1": "bhE6CGQgZTIgLPp9lnvlKW/47xc=", "checksumSHA1": "bhE6CGQgZTIgLPp9lnvlKW/47xc=",
"path": "vitess.io/vitess/go/hack", "path": "vitess.io/vitess/go/hack",
"revision": "2c8664c8005b440c11fd070d30357c90f749f140", "revision": "590a06f9277fd29d7c9f77d50c4b11f1ba48f41c",
"revisionTime": "2019-10-07T23:18:38Z" "revisionTime": "2019-10-19T20:56:25Z"
}, },
{ {
"checksumSHA1": "v2dgco7U/RQtQbdX9ULGEXsZw6k=", "checksumSHA1": "v2dgco7U/RQtQbdX9ULGEXsZw6k=",
"path": "vitess.io/vitess/go/sqltypes", "path": "vitess.io/vitess/go/sqltypes",
"revision": "2c8664c8005b440c11fd070d30357c90f749f140", "revision": "590a06f9277fd29d7c9f77d50c4b11f1ba48f41c",
"revisionTime": "2019-10-07T23:18:38Z" "revisionTime": "2019-10-19T20:56:25Z"
}, },
{ {
"checksumSHA1": "vAIRxI6MHsq3x1hLQwIyw5AvqtI=", "checksumSHA1": "a39Nes10plscGYzwVlSRgXFAITk=",
"path": "vitess.io/vitess/go/vt/log", "path": "vitess.io/vitess/go/vt/log",
"revision": "2c8664c8005b440c11fd070d30357c90f749f140", "revision": "590a06f9277fd29d7c9f77d50c4b11f1ba48f41c",
"revisionTime": "2019-10-07T23:18:38Z" "revisionTime": "2019-10-19T20:56:25Z"
}, },
{ {
"checksumSHA1": "pm6qqJ+px6ev0huIVSE73XKT/pM=", "checksumSHA1": "PTiZ/ErlpNltBWLO7WK7FI1c79c=",
"path": "vitess.io/vitess/go/vt/proto/binlogdata", "path": "vitess.io/vitess/go/vt/proto/binlogdata",
"revision": "2c8664c8005b440c11fd070d30357c90f749f140", "revision": "590a06f9277fd29d7c9f77d50c4b11f1ba48f41c",
"revisionTime": "2019-10-07T23:18:38Z" "revisionTime": "2019-10-19T20:56:25Z"
}, },
{ {
"checksumSHA1": "U2N66XbwVN2UbS7mI2fQqODKTFU=", "checksumSHA1": "U2N66XbwVN2UbS7mI2fQqODKTFU=",
"path": "vitess.io/vitess/go/vt/proto/query", "path": "vitess.io/vitess/go/vt/proto/query",
"revision": "2c8664c8005b440c11fd070d30357c90f749f140", "revision": "590a06f9277fd29d7c9f77d50c4b11f1ba48f41c",
"revisionTime": "2019-10-07T23:18:38Z" "revisionTime": "2019-10-19T20:56:25Z"
}, },
{ {
"checksumSHA1": "mioM1BFNP3voMMt6rvT6i9BMxTA=", "checksumSHA1": "mioM1BFNP3voMMt6rvT6i9BMxTA=",
"path": "vitess.io/vitess/go/vt/proto/topodata", "path": "vitess.io/vitess/go/vt/proto/topodata",
"revision": "2c8664c8005b440c11fd070d30357c90f749f140", "revision": "590a06f9277fd29d7c9f77d50c4b11f1ba48f41c",
"revisionTime": "2019-10-07T23:18:38Z" "revisionTime": "2019-10-19T20:56:25Z"
}, },
{ {
"checksumSHA1": "vFv/sVYQzHQFzLdxfLA3vX5Nz0U=", "checksumSHA1": "vFv/sVYQzHQFzLdxfLA3vX5Nz0U=",
"path": "vitess.io/vitess/go/vt/proto/vtgate", "path": "vitess.io/vitess/go/vt/proto/vtgate",
"revision": "2c8664c8005b440c11fd070d30357c90f749f140", "revision": "590a06f9277fd29d7c9f77d50c4b11f1ba48f41c",
"revisionTime": "2019-10-07T23:18:38Z" "revisionTime": "2019-10-19T20:56:25Z"
}, },
{ {
"checksumSHA1": "6Pzimtq+Jv8CI6kTqkAjMkPoZZI=", "checksumSHA1": "6Pzimtq+Jv8CI6kTqkAjMkPoZZI=",
"path": "vitess.io/vitess/go/vt/proto/vtrpc", "path": "vitess.io/vitess/go/vt/proto/vtrpc",
"revision": "2c8664c8005b440c11fd070d30357c90f749f140", "revision": "590a06f9277fd29d7c9f77d50c4b11f1ba48f41c",
"revisionTime": "2019-10-07T23:18:38Z" "revisionTime": "2019-10-19T20:56:25Z"
}, },
{ {
"checksumSHA1": "IpnM59xLwj3/Kv5sbEFXBUvcj0o=", "checksumSHA1": "IpnM59xLwj3/Kv5sbEFXBUvcj0o=",
"path": "vitess.io/vitess/go/vt/proto/vttime", "path": "vitess.io/vitess/go/vt/proto/vttime",
"revision": "2c8664c8005b440c11fd070d30357c90f749f140", "revision": "590a06f9277fd29d7c9f77d50c4b11f1ba48f41c",
"revisionTime": "2019-10-07T23:18:38Z" "revisionTime": "2019-10-19T20:56:25Z"
}, },
{ {
"checksumSHA1": "W6ID/pp1kmcssaxW+PtAD3flg5E=", "checksumSHA1": "kt8JHcyRpFLLC1IjaAMwY1ZnmFU=",
"path": "vitess.io/vitess/go/vt/sqlparser", "path": "vitess.io/vitess/go/vt/sqlparser",
"revision": "2c8664c8005b440c11fd070d30357c90f749f140", "revision": "590a06f9277fd29d7c9f77d50c4b11f1ba48f41c",
"revisionTime": "2019-10-07T23:18:38Z" "revisionTime": "2019-10-19T20:56:25Z"
}, },
{ {
"checksumSHA1": "z9+F/lA1Xrl5S16LKssUH8VL6hs=", "checksumSHA1": "FT4i3QIXo5VAM/jg8UK5uyigyQY=",
"path": "vitess.io/vitess/go/vt/vterrors", "path": "vitess.io/vitess/go/vt/vterrors",
"revision": "2c8664c8005b440c11fd070d30357c90f749f140", "revision": "590a06f9277fd29d7c9f77d50c4b11f1ba48f41c",
"revisionTime": "2019-10-07T23:18:38Z" "revisionTime": "2019-10-19T20:56:25Z"
} }
], ],
"rootPath": "github.com/XiaoMi/soar" "rootPath": "github.com/XiaoMi/soar"
......
/*
Copyright 2019 The Vitess Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// You can modify this file to hook up a different logging library instead of glog. // You can modify this file to hook up a different logging library instead of glog.
// If you adapt to a different logging framework, you may need to use that // If you adapt to a different logging framework, you may need to use that
// framework's equivalent of *Depth() functions so the file and line number printed // framework's equivalent of *Depth() functions so the file and line number printed
...@@ -7,6 +23,7 @@ package log ...@@ -7,6 +23,7 @@ package log
import ( import (
"flag" "flag"
"github.com/golang/glog" "github.com/golang/glog"
) )
......
...@@ -158,6 +158,23 @@ func IsDML(sql string) bool { ...@@ -158,6 +158,23 @@ func IsDML(sql string) bool {
return false return false
} }
// SplitAndExpression breaks up the Expr into AND-separated conditions
// and appends them to filters. Outer parenthesis are removed. Precedence
// should be taken into account if expressions are recombined.
func SplitAndExpression(filters []Expr, node Expr) []Expr {
if node == nil {
return filters
}
switch node := node.(type) {
case *AndExpr:
filters = SplitAndExpression(filters, node.Left)
return SplitAndExpression(filters, node.Right)
case *ParenExpr:
return SplitAndExpression(filters, node.Expr)
}
return append(filters, node)
}
// GetTableName returns the table name from the SimpleTableExpr // GetTableName returns the table name from the SimpleTableExpr
// only if it's a simple expression. Otherwise, it returns "". // only if it's a simple expression. Otherwise, it returns "".
func GetTableName(node SimpleTableExpr) TableIdent { func GetTableName(node SimpleTableExpr) TableIdent {
......
/*
Copyright 2019 The Vitess Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package sqlparser package sqlparser
import ( import (
...@@ -15,7 +31,7 @@ func replacer(s string) string { ...@@ -15,7 +31,7 @@ func replacer(s string) string {
return s[2:] return s[2:]
} }
result := strings.Replace(s, "%" ,".*", -1) result := strings.Replace(s, "%", ".*", -1)
result = strings.Replace(result, "_", ".", -1) result = strings.Replace(result, "_", ".", -1)
return result return result
......
/*
Copyright 2019 The Vitess Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package sqlparser package sqlparser
import querypb "vitess.io/vitess/go/vt/proto/query" import querypb "vitess.io/vitess/go/vt/proto/query"
......
...@@ -158,7 +158,7 @@ func skipToEnd(yylex interface{}) { ...@@ -158,7 +158,7 @@ func skipToEnd(yylex interface{}) {
// DDL Tokens // DDL Tokens
%token <bytes> CREATE ALTER DROP RENAME ANALYZE ADD FLUSH %token <bytes> CREATE ALTER DROP RENAME ANALYZE ADD FLUSH
%token <bytes> SCHEMA TABLE INDEX VIEW TO IGNORE IF UNIQUE PRIMARY COLUMN SPATIAL FULLTEXT KEY_BLOCK_SIZE %token <bytes> SCHEMA TABLE INDEX VIEW TO IGNORE IF UNIQUE PRIMARY COLUMN SPATIAL FULLTEXT KEY_BLOCK_SIZE CHECK
%token <bytes> ACTION CASCADE CONSTRAINT FOREIGN NO REFERENCES RESTRICT %token <bytes> ACTION CASCADE CONSTRAINT FOREIGN NO REFERENCES RESTRICT
%token <bytes> SHOW DESCRIBE EXPLAIN DATE ESCAPE REPAIR OPTIMIZE TRUNCATE %token <bytes> SHOW DESCRIBE EXPLAIN DATE ESCAPE REPAIR OPTIMIZE TRUNCATE
%token <bytes> MAXVALUE PARTITION REORGANIZE LESS THAN PROCEDURE TRIGGER %token <bytes> MAXVALUE PARTITION REORGANIZE LESS THAN PROCEDURE TRIGGER
...@@ -1378,7 +1378,8 @@ alter_statement: ...@@ -1378,7 +1378,8 @@ alter_statement:
} }
alter_object_type: alter_object_type:
COLUMN CHECK
| COLUMN
| CONSTRAINT | CONSTRAINT
| FOREIGN | FOREIGN
| FULLTEXT | FULLTEXT
...@@ -3324,6 +3325,7 @@ non_reserved_keyword: ...@@ -3324,6 +3325,7 @@ non_reserved_keyword:
| CHAR | CHAR
| CHARACTER | CHARACTER
| CHARSET | CHARSET
| CHECK
| COLLATION | COLLATION
| COLUMNS | COLUMNS
| COMMENT_KEYWORD | COMMENT_KEYWORD
......
...@@ -117,7 +117,7 @@ var keywords = map[string]int{ ...@@ -117,7 +117,7 @@ var keywords = map[string]int{
"char": CHAR, "char": CHAR,
"character": CHARACTER, "character": CHARACTER,
"charset": CHARSET, "charset": CHARSET,
"check": UNUSED, "check": CHECK,
"collate": COLLATE, "collate": COLLATE,
"collation": COLLATION, "collation": COLLATION,
"column": COLUMN, "column": COLUMN,
......
/*
Copyright 2019 The Vitess Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package vterrors package vterrors
/* This file is copied from https://github.com/pkg/errors/blob/v0.8.0/stack.go */ /* This file is copied from https://github.com/pkg/errors/blob/v0.8.0/stack.go */
......
/*
Copyright 2019 The Vitess Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Package vterrors provides simple error handling primitives for Vitess // Package vterrors provides simple error handling primitives for Vitess
// //
// In all Vitess code, errors should be propagated using vterrors.Wrapf() // In all Vitess code, errors should be propagated using vterrors.Wrapf()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册