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

update vendor

上级 80baea18
......@@ -34,6 +34,7 @@ var (
_ DDLNode = &DropTableStmt{}
_ DDLNode = &RenameTableStmt{}
_ DDLNode = &TruncateTableStmt{}
_ DDLNode = &RepairTableStmt{}
_ Node = &AlterTableSpec{}
_ Node = &ColumnDef{}
......@@ -1247,7 +1248,7 @@ func (n *CreateViewStmt) Accept(v Visitor) (Node, bool) {
if !ok {
return n, false
}
n.Select = selnode.(*SelectStmt)
n.Select = selnode.(StmtNode)
return v.Leave(n)
}
......@@ -1559,6 +1560,46 @@ func (n *CleanupTableLockStmt) Restore(ctx *RestoreCtx) error {
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
type TableOptionType int
......@@ -1925,6 +1966,8 @@ const (
AlterTableIndexInvisible
// TODO: Add more actions
AlterTableOrderByColumns
// AlterTableSetTiFlashReplica uses to set the table TiFlash replica.
AlterTableSetTiFlashReplica
)
// LockType is the type for AlterTableSpec.
......@@ -2019,6 +2062,12 @@ type AlterTableSpec struct {
WithValidation bool
Num uint64
Visibility IndexVisibility
TiFlashReplica *TiFlashReplicaSpec
}
type TiFlashReplicaSpec struct {
Count uint64
Labels []string
}
// AlterOrderItem represents an item in order by at alter table stmt.
......@@ -2042,6 +2091,19 @@ func (n *AlterOrderItem) Restore(ctx *RestoreCtx) error {
// Restore implements Node interface.
func (n *AlterTableSpec) Restore(ctx *RestoreCtx) error {
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:
switch {
case len(n.Options) == 2 &&
......
......@@ -187,12 +187,15 @@ type TableName struct {
}
// Restore implements Node interface.
func (n *TableName) Restore(ctx *RestoreCtx) error {
func (n *TableName) restoreName(ctx *RestoreCtx) {
if n.Schema.String() != "" {
ctx.WriteName(n.Schema.String())
ctx.WritePlain(".")
}
ctx.WriteName(n.Name.String())
}
func (n *TableName) restorePartitions(ctx *RestoreCtx) {
if len(n.PartitionNames) > 0 {
ctx.WriteKeyWord(" PARTITION")
ctx.WritePlain("(")
......@@ -204,6 +207,9 @@ func (n *TableName) Restore(ctx *RestoreCtx) error {
}
ctx.WritePlain(")")
}
}
func (n *TableName) restoreIndexHints(ctx *RestoreCtx) error {
for _, value := range n.IndexHints {
ctx.WritePlain(" ")
if err := value.Restore(ctx); err != nil {
......@@ -214,6 +220,12 @@ func (n *TableName) Restore(ctx *RestoreCtx) error {
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.
type IndexHintType int
......@@ -381,18 +393,40 @@ func (n *TableSource) Restore(ctx *RestoreCtx) error {
case *SelectStmt, *UnionStmt:
needParen = true
}
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)
if tn, tnCase := n.Source.(*TableName); tnCase {
if needParen {
ctx.WritePlain("(")
}
tn.restoreName(ctx)
tn.restorePartitions(ctx)
if asName := n.AsName.String(); asName != "" {
ctx.WriteKeyWord(" AS ")
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
......@@ -421,6 +455,7 @@ const (
SelectLockNone SelectLockType = iota
SelectLockForUpdate
SelectLockInShareMode
SelectLockForUpdateNoWait
)
// String implements fmt.Stringer.
......@@ -432,6 +467,8 @@ func (slt SelectLockType) String() string {
return "for update"
case SelectLockInShareMode:
return "in share mode"
case SelectLockForUpdateNoWait:
return "for update nowait"
}
return "unsupported select lock type"
}
......@@ -881,7 +918,7 @@ func (n *SelectStmt) Restore(ctx *RestoreCtx) error {
case SelectLockInShareMode:
ctx.WriteKeyWord(" LOCK ")
ctx.WriteKeyWord(n.LockTp.String())
case SelectLockForUpdate:
case SelectLockForUpdate, SelectLockForUpdateNoWait:
ctx.WritePlain(" ")
ctx.WriteKeyWord(n.LockTp.String())
}
......@@ -2427,8 +2464,11 @@ func (n *FrameBound) Accept(v Visitor) (Node, bool) {
type SplitRegionStmt struct {
dmlNode
Table *TableName
IndexName model.CIStr
Table *TableName
IndexName model.CIStr
PartitionNames []model.CIStr
SplitSyntaxOpt *SplitSyntaxOption
SplitOpt *SplitOption
}
......@@ -2440,11 +2480,39 @@ type SplitOption struct {
ValueLists [][]ExprNode
}
type SplitSyntaxOption struct {
HasRegionFor bool
HasPartition bool
}
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 {
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 {
ctx.WriteKeyWord(" INDEX ")
ctx.WriteName(n.IndexName.String())
......
......@@ -246,6 +246,7 @@ const (
Version = "version"
TiDBVersion = "tidb_version"
TiDBIsDDLOwner = "tidb_is_ddl_owner"
TiDBDecodePlan = "tidb_decode_plan"
// control functions
If = "if"
......
......@@ -49,6 +49,7 @@ var (
_ StmtNode = &KillStmt{}
_ StmtNode = &CreateBindingStmt{}
_ StmtNode = &DropBindingStmt{}
_ StmtNode = &ShutdownStmt{}
_ Node = &PrivElem{}
_ Node = &VariableAssignment{}
......@@ -1500,6 +1501,7 @@ type AdminStmt struct {
HandleRanges []HandleRange
ShowSlow *ShowSlow
Plugins []string
Where ExprNode
}
// Restore implements Node interface.
......@@ -1533,6 +1535,12 @@ func (n *AdminStmt) Restore(ctx *RestoreCtx) error {
if n.JobNumber != 0 {
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:
ctx.WriteKeyWord("SHOW ")
if err := restoreTables(); err != nil {
......@@ -1994,6 +2002,28 @@ func (n *GrantRoleStmt) SecureText() string {
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.
type Ident struct {
Schema model.CIStr
......
......@@ -17,7 +17,7 @@ package ast
func IsReadOnly(node Node) bool {
switch st := node.(type) {
case *SelectStmt:
if st.LockTp == SelectLockForUpdate {
if st.LockTp == SelectLockForUpdate || st.LockTp == SelectLockForUpdateNoWait {
return false
}
......
......@@ -351,6 +351,7 @@ var tokenMap = map[string]int{
"KEY_BLOCK_SIZE": keyBlockSize,
"KEYS": keys,
"KILL": kill,
"LABELS": labels,
"LAST": last,
"LEADING": leading,
"LEFT": left,
......@@ -365,6 +366,7 @@ var tokenMap = map[string]int{
"LOCAL": local,
"LOCALTIME": localTime,
"LOCALTIMESTAMP": localTs,
"LOCATION": location,
"LOCK": lock,
"LONG": long,
"LONGBLOB": longblobType,
......@@ -469,6 +471,7 @@ var tokenMap = map[string]int{
"REFERENCES": references,
"REGEXP": regexpKwd,
"REGIONS": regions,
"REGION": region,
"RELOAD": reload,
"REMOVE": remove,
"RENAME": rename,
......@@ -478,6 +481,7 @@ var tokenMap = map[string]int{
"REPEATABLE": repeatable,
"REPLACE": replace,
"RESPECT": respect,
"REPLICA": replica,
"REPLICATION": replication,
"REQUIRE": require,
"RESTRICT": restrict,
......@@ -510,6 +514,7 @@ var tokenMap = map[string]int{
"SHARE": share,
"SHARED": shared,
"SHOW": show,
"SHUTDOWN": shutdown,
"SIGNED": signed,
"SIMPLE": simple,
"SLAVE": slave,
......@@ -665,6 +670,7 @@ var tokenMap = map[string]int{
"BINDINGS": bindings,
"EXPR_PUSHDOWN_BLACKLIST": exprPushdownBlacklist,
"OPT_RULE_BLACKLIST": optRuleBlacklist,
"NOWAIT": nowait,
}
// See https://dev.mysql.com/doc/refman/5.7/en/function-resolution.html for details
......
......@@ -58,6 +58,9 @@ const (
ActionModifySchemaCharsetAndCollate ActionType = 26
ActionLockTable ActionType = 27
ActionUnlockTable ActionType = 28
ActionRepairTable ActionType = 29
ActionSetTiFlashReplica ActionType = 30
ActionUpdateTiFlashReplicaStatus ActionType = 31
)
// AddIndexStr is a string related to the operation of "add index".
......@@ -92,6 +95,9 @@ var actionMap = map[ActionType]string{
ActionModifySchemaCharsetAndCollate: "modify schema charset and collate",
ActionLockTable: "lock table",
ActionUnlockTable: "unlock table",
ActionRepairTable: "repair table",
ActionSetTiFlashReplica: "set tiflash replica",
ActionUpdateTiFlashReplicaStatus: "update tiflash replica status",
}
// String return current ddl action in string
......
......@@ -236,6 +236,9 @@ type TableInfo struct {
// Version means the version of the table info.
Version uint16 `json:"version"`
// TiFlashReplica means the TiFlash replica info.
TiFlashReplica *TiFlashReplicaInfo `json:"tiflash_replica"`
}
// TableLockInfo provides meta data describing a table lock.
......@@ -323,6 +326,13 @@ func (t TableLockType) String() string {
return ""
}
// TiFlashReplicaInfo means the flash replica info.
type TiFlashReplicaInfo struct {
Count uint64
LocationLabels []string
Available bool
}
// GetPartitionInfo returns the partition information.
func (t *TableInfo) GetPartitionInfo() *PartitionInfo {
if t.Partition != nil && t.Partition.Enable {
......
......@@ -240,6 +240,9 @@ const (
AlterRoutinePriv
EventPriv
// ShutdownPriv the privilege to shutdown a server.
ShutdownPriv
// AllPriv is the privilege for all actions.
AllPriv
)
......@@ -311,6 +314,7 @@ var Priv2UserCol = map[PrivilegeType]string{
CreateRoutinePriv: "Create_routine_priv",
AlterRoutinePriv: "Alter_routine_priv",
EventPriv: "Event_priv",
ShutdownPriv: "Shutdown_priv",
}
// Col2PrivType is the privilege tables column name to privilege type.
......@@ -340,6 +344,7 @@ var Col2PrivType = map[string]PrivilegeType{
"Create_routine_priv": CreateRoutinePriv,
"Alter_routine_priv": AlterRoutinePriv,
"Event_priv": EventPriv,
"Shutdown_priv": ShutdownPriv,
}
// Command2Str is the command information to command name.
......@@ -405,6 +410,7 @@ var Priv2Str = map[PrivilegeType]string{
CreateRoutinePriv: "CREATE ROUTINE",
AlterRoutinePriv: "ALTER ROUTINE",
EventPriv: "EVENT",
ShutdownPriv: "SHUTDOWN",
}
// Priv2SetStr is the map for privilege to string.
......@@ -423,6 +429,7 @@ var Priv2SetStr = map[PrivilegeType]string{
ShowViewPriv: "Show View",
CreateRolePriv: "Create Role",
DropRolePriv: "Drop Role",
ShutdownPriv: "Shutdown Role",
}
// SetStr2Priv is the map for privilege set string to privilege type.
......@@ -442,13 +449,13 @@ var SetStr2Priv = map[string]PrivilegeType{
}
// 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.
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.
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.
var AllColumnPrivs = []PrivilegeType{SelectPriv, InsertPriv, UpdatePriv}
......
......@@ -903,6 +903,7 @@ const (
ErrBadUser = 3162
ErrInvalidEncryptionOption = 3184
ErrRoleNotGranted = 3530
ErrLockAcquireFailAndNoWaitSet = 3572
ErrWindowNoSuchWindow = 3579
ErrWindowCircularityInWindowGraph = 3580
ErrWindowNoChildPartitioning = 3581
......
......@@ -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",
ErrRoleNotGranted: "%s is is not granted to %s",
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.
ErrOnlyOneDefaultPartionAllowed: "Only one DEFAULT partition allowed",
......
......@@ -369,11 +369,13 @@ import (
ipc "IPC"
jsonType "JSON"
keyBlockSize "KEY_BLOCK_SIZE"
labels "LABELS"
last "LAST"
less "LESS"
level "LEVEL"
list "LIST"
local "LOCAL"
location "LOCATION"
master "MASTER"
microsecond "MICROSECOND"
minute "MINUTE"
......@@ -425,6 +427,7 @@ import (
repair "REPAIR"
repeatable "REPEATABLE"
respect "RESPECT"
replica "REPLICA"
replication "REPLICATION"
reverse "REVERSE"
role "ROLE"
......@@ -444,6 +447,7 @@ import (
session "SESSION"
share "SHARE"
shared "SHARED"
shutdown "SHUTDOWN"
signed "SIGNED"
simple "SIMPLE"
slave "SLAVE"
......@@ -512,6 +516,7 @@ import (
yearType "YEAR"
x509 "X509"
enforced "ENFORCED"
nowait "NOWAIT"
/* The following tokens belong to NotKeywordToken. Notice: make sure these tokens are contained in NotKeywordToken. */
addDate "ADDDATE"
......@@ -611,6 +616,7 @@ import (
split "SPLIT"
width "WIDTH"
regions "REGIONS"
region "REGION"
builtinAddDate
builtinBitAnd
......@@ -687,6 +693,7 @@ import (
SignedLiteral "Literal or NumLiteral with sign"
DefaultValueExpr "DefaultValueExpr(Now or Signed Literal)"
NowSymOptionFraction "NowSym with optional fraction part"
CharsetNameOrDefault "Character set name or default"
%type <statement>
AdminStmt "Check table statement or show ddl statement"
......@@ -749,6 +756,7 @@ import (
UpdateStmt "UPDATE statement"
UnionStmt "Union select state ment"
UseStmt "USE statement"
ShutdownStmt "SHUTDOWN statement"
%type <item>
AdminShowSlow "Admin Show Slow statement"
......@@ -798,6 +806,7 @@ import (
ConstraintKeywordOpt "Constraint Keyword or empty"
CreateTableOptionListOpt "create table option list opt"
CreateTableSelectOpt "Select/Union statement in CREATE TABLE ... SELECT"
CreateViewSelectOpt "Select/Union statement in CREATE VIEW ... AS SELECT"
DatabaseOption "CREATE Database specification"
DatabaseOptionList "CREATE Database specification list"
DatabaseOptionListOpt "CREATE Database specification list opt"
......@@ -861,6 +870,7 @@ import (
JoinTable "join table"
JoinType "join type"
KillOrKillTiDB "Kill or Kill TiDB"
LocationLabelList "location label name list"
LikeEscapeOpt "like escape option"
LikeTableWithOrWithoutParen "LIKE table_name or ( LIKE table_name )"
LimitClause "LIMIT clause"
......@@ -954,6 +964,7 @@ import (
ShowProfileType "Show profile type"
ShowProfileTypes "Show profile types"
SplitOption "Split Option"
SplitSyntaxOption "Split syntax Option"
Starting "Starting by"
StatementList "statement list"
StatsPersistentVal "stats_persistent value"
......@@ -1195,7 +1206,7 @@ import (
%right collate
%right encryption
%left splitOptionPriv
%left labels
%precedence '('
%precedence quick
%precedence escape
......@@ -1262,6 +1273,16 @@ AlterTablePartitionOpt:
parser.lastErrorAsWarn()
}
LocationLabelList:
{
$$ = []string{}
}
| "LOCATION" "LABELS" StringList
{
$$ = $3
}
AlterTableSpec:
TableOptionList %prec higherThanComma
{
......@@ -1270,6 +1291,17 @@ AlterTableSpec:
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
{
op := &ast.AlterTableSpec{
......@@ -1982,19 +2014,23 @@ RecoverTableStmt:
*
*******************************************************************/
SplitRegionStmt:
"SPLIT" "TABLE" TableName SplitOption
"SPLIT" SplitSyntaxOption "TABLE" TableName PartitionNameListOpt SplitOption
{
$$ = &ast.SplitRegionStmt{
Table: $3.(*ast.TableName),
SplitOpt: $4.(*ast.SplitOption),
SplitSyntaxOpt: $2.(*ast.SplitSyntaxOption),
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{
Table: $3.(*ast.TableName),
IndexName: model.NewCIStr($5),
SplitOpt: $6.(*ast.SplitOption),
SplitSyntaxOpt: $2.(*ast.SplitSyntaxOption),
Table: $4.(*ast.TableName),
PartitionNames: $5.([]model.CIStr),
IndexName: model.NewCIStr($7),
SplitOpt: $8.(*ast.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:
......@@ -3329,6 +3390,27 @@ CreateTableSelectOpt:
$$ = &ast.CreateTableStmt{Select: $1}
}
CreateViewSelectOpt:
SelectStmt
{
$$ = $1.(*ast.SelectStmt)
}
|
UnionStmt
{
$$ = $1.(*ast.UnionStmt)
}
|
'(' SelectStmt ')'
{
$$ = $2.(*ast.SelectStmt)
}
|
'(' UnionStmt ')'
{
$$ = $2.(*ast.UnionStmt)
}
LikeTableWithOrWithoutParen:
"LIKE" TableName
{
......@@ -3349,10 +3431,10 @@ LikeTableWithOrWithoutParen:
* as select Col1,Col2 from table WITH LOCAL CHECK OPTION
*******************************************************************/
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])
selStmt := $10.(*ast.SelectStmt)
selStmt := $10.(ast.StmtNode)
selStmt.SetText(strings.TrimSpace(parser.src[startOffset:]))
x := &ast.CreateViewStmt {
OrReplace: $2.(bool),
......@@ -4351,7 +4433,7 @@ UnReservedKeyword:
| "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"
| "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"
| "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"
......@@ -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"
| "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"
| "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:
"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"
| "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:
"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:
$$ = &ast.RollbackStmt{}
}
ShutdownStmt:
"SHUTDOWN"
{
$$ = &ast.ShutdownStmt{}
}
SelectStmtBasic:
"SELECT" SelectStmtOpts SelectStmtFieldList
{
......@@ -6969,6 +7058,10 @@ SelectLockOpt:
{
$$ = ast.SelectLockForUpdate
}
| "FOR" "UPDATE" "NOWAIT"
{
$$ = ast.SelectLockForUpdateNoWait
}
| "LOCK" "IN" "SHARE" "MODE"
{
$$ = ast.SelectLockInShareMode
......@@ -7337,12 +7430,24 @@ VariableAssignment:
ExtendValue: ast.NewValueExpr($4.(string)),
}
}
| CharsetKw CharsetName
| "NAMES" "DEFAULT"
{
$$ = &ast.VariableAssignment{
Name: ast.SetNames,
Value: ast.NewValueExpr($2.(string)),
}
v := &ast.DefaultExpr{}
$$ = &ast.VariableAssignment{Name: ast.SetNames, Value: v}
}
| CharsetKw CharsetNameOrDefault
{
$$ = &ast.VariableAssignment{Name: ast.SetNames, Value: $2}
}
CharsetNameOrDefault:
CharsetName
{
$$ = ast.NewValueExpr($1.(string))
}
| "DEFAULT"
{
$$ = &ast.DefaultExpr{}
}
CharsetName:
......@@ -7502,16 +7607,24 @@ AdminStmt:
{
$$ = &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,
JobNumber: $5.(int64),
}
if $6 != nil {
stmt.Where = $6.(ast.ExprNode)
}
$$ = stmt
}
| "ADMIN" "SHOW" TableName "NEXT_ROW_ID"
{
......@@ -7620,6 +7733,13 @@ AdminStmt:
Tables: $5.([]*ast.TableName),
}
}
| "ADMIN" "REPAIR" "TABLE" TableName CreateTableStmt
{
$$ = &ast.RepairTableStmt{
Table: $4.(*ast.TableName),
CreateStmt: $5.(*ast.CreateTableStmt),
}
}
AdminShowSlow:
"RECENT" NUM
......@@ -8326,6 +8446,7 @@ Statement:
| UseStmt
| UnlockTablesStmt
| LockTablesStmt
| ShutdownStmt
TraceableStmt:
SelectStmt
......@@ -9975,6 +10096,10 @@ PrivType:
{
$$ = mysql.EventPriv
}
| "SHUTDOWN"
{
$$ = mysql.ShutdownPriv
}
ObjectType:
{
......
......@@ -1227,6 +1227,7 @@ func (d *Datum) convertToMysqlYear(sc *stmtctx.StatementContext, target *FieldTy
s := d.GetString()
y, err = StrToInt(sc, s)
if err != nil {
ret.SetInt64(0)
return ret, errors.Trace(err)
}
if len(s) != 4 && len(s) > 0 && s[0:1] == "0" {
......@@ -1239,16 +1240,18 @@ func (d *Datum) convertToMysqlYear(sc *stmtctx.StatementContext, target *FieldTy
default:
ret, err = d.convertToInt(sc, NewFieldType(mysql.TypeLonglong))
if err != nil {
return invalidConv(d, target.Tp)
_, err = invalidConv(d, target.Tp)
ret.SetInt64(0)
return ret, err
}
y = ret.GetInt64()
}
y, err = AdjustYear(y, adjust)
if err != nil {
return invalidConv(d, target.Tp)
_, err = invalidConv(d, target.Tp)
}
ret.SetInt64(y)
return ret, nil
return ret, err
}
func (d *Datum) convertToMysqlBit(sc *stmtctx.StatementContext, target *FieldType) (Datum, error) {
......
......@@ -250,21 +250,6 @@ func (d *MyDecimal) GetDigitsFrac() int8 {
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.
func (d *MyDecimal) String() string {
tmp := *d
......@@ -1500,6 +1485,7 @@ func DecimalNeg(from *MyDecimal) *MyDecimal {
// Note: DO NOT use `from1` or `from2` as `to` since the metadata
// of `to` may be changed during evaluating.
func DecimalAdd(from1, from2, to *MyDecimal) error {
from1, from2, to = validateArgs(from1, from2, to)
to.resultFrac = myMaxInt8(from1.resultFrac, from2.resultFrac)
if from1.negative == from2.negative {
return doAdd(from1, from2, to)
......@@ -1510,6 +1496,7 @@ func DecimalAdd(from1, from2, to *MyDecimal) error {
// DecimalSub subs one decimal from another, sets the result to 'to'.
func DecimalSub(from1, from2, to *MyDecimal) error {
from1, from2, to = validateArgs(from1, from2, to)
to.resultFrac = myMaxInt8(from1.resultFrac, from2.resultFrac)
if from1.negative == from2.negative {
_, err := doSub(from1, from2, to)
......@@ -1518,6 +1505,28 @@ func DecimalSub(from1, from2, to *MyDecimal) error {
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) {
var (
wordsInt1 = digitsToWords(int(from1.digitsInt))
......@@ -1838,6 +1847,7 @@ DecimalMul multiplies two decimals.
digits, fast multiplication must be implemented.
*/
func DecimalMul(from1, from2, to *MyDecimal) error {
from1, from2, to = validateArgs(from1, from2, to)
var (
err error
wordsInt1 = digitsToWords(int(from1.digitsInt))
......@@ -1966,6 +1976,7 @@ func DecimalMul(from1, from2, to *MyDecimal) error {
// to - quotient
// fracIncr - increment of fraction
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)
return doDivMod(from1, from2, to, nil, fracIncr)
}
......@@ -1995,6 +2006,7 @@ DecimalMod does modulus of two decimals.
thus, there's no requirement for M or N to be integers
*/
func DecimalMod(from1, from2, to *MyDecimal) error {
from1, from2, to = validateArgs(from1, from2, to)
to.resultFrac = myMaxInt8(from1.resultFrac, from2.resultFrac)
return doDivMod(from1, from2, nil, to, 0)
}
......
......@@ -2199,6 +2199,11 @@ func strToDate(t *MysqlTime, date string, format string, ctx map[string]int) boo
return true
}
if len(date) == 0 {
ctx[token] = 0
return true
}
dateRemain, succ := matchDateWithToken(t, date, token, ctx)
if !succ {
return false
......@@ -2316,21 +2321,14 @@ func GetFormatType(format string) (isDuration, isDate bool) {
isDuration, isDate = false, false
break
}
var durationTokens bool
var dateTokens bool
if len(token) >= 2 && token[0] == '%' {
switch token[1] {
case 'h', 'H', 'i', 'I', 's', 'S', 'k', 'l':
durationTokens = true
case 'h', 'H', 'i', 'I', 's', 'S', 'k', 'l', 'f':
isDuration = true
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 {
break
}
......
......@@ -44,7 +44,9 @@ const (
// DefaultSlowThreshold is the default slow log threshold in millisecond.
DefaultSlowThreshold = 300
// 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.
......@@ -56,10 +58,9 @@ type FileLogConfig struct {
}
// NewFileLogConfig creates a FileLogConfig.
func NewFileLogConfig(rotate bool, maxSize uint) FileLogConfig {
func NewFileLogConfig(maxSize uint) FileLogConfig {
return FileLogConfig{FileLogConfig: zaplog.FileLogConfig{
LogRotate: rotate,
MaxSize: int(maxSize),
MaxSize: int(maxSize),
},
}
}
......@@ -292,9 +293,8 @@ func InitZapLogger(cfg *LogConfig) error {
if len(cfg.SlowQueryFile) != 0 {
sqfCfg := zaplog.FileLogConfig{
LogRotate: cfg.File.LogRotate,
MaxSize: cfg.File.MaxSize,
Filename: cfg.SlowQueryFile,
MaxSize: cfg.File.MaxSize,
Filename: cfg.SlowQueryFile,
}
sqCfg := &zaplog.Config{
Level: cfg.Level,
......
......@@ -129,118 +129,118 @@
"revisionTime": "2019-03-07T07:54:52Z"
},
{
"checksumSHA1": "QR1zSwFP8BdkTjNFC+/5gTS8C6c=",
"checksumSHA1": "2uDnUGEufCT0+kt4oKwe7G81+OQ=",
"path": "github.com/pingcap/parser",
"revision": "51a2e3b2e34b61a7519e7d3e17dac38f0e8684f7",
"revisionTime": "2019-10-08T03:21:57Z"
"revision": "b10cc800c4e47e8ac3809c8549c4123a5271dcca",
"revisionTime": "2019-10-22T01:55:17Z"
},
{
"checksumSHA1": "I4zlpjlOMFiWnRtAoSj50RSHsvk=",
"checksumSHA1": "C7qqPFYLpVVMKb2EnxetcWvjv1M=",
"path": "github.com/pingcap/parser/ast",
"revision": "51a2e3b2e34b61a7519e7d3e17dac38f0e8684f7",
"revisionTime": "2019-10-08T03:21:57Z"
"revision": "b10cc800c4e47e8ac3809c8549c4123a5271dcca",
"revisionTime": "2019-10-22T01:55:17Z"
},
{
"checksumSHA1": "xiv40YqnvHcbIhaEzJqjh5K7ehM=",
"path": "github.com/pingcap/parser/auth",
"revision": "51a2e3b2e34b61a7519e7d3e17dac38f0e8684f7",
"revisionTime": "2019-10-08T03:21:57Z"
"revision": "b10cc800c4e47e8ac3809c8549c4123a5271dcca",
"revisionTime": "2019-10-22T01:55:17Z"
},
{
"checksumSHA1": "EvDXpplklIXmKqLclzWzaN/uHKQ=",
"path": "github.com/pingcap/parser/charset",
"revision": "51a2e3b2e34b61a7519e7d3e17dac38f0e8684f7",
"revisionTime": "2019-10-08T03:21:57Z"
"revision": "b10cc800c4e47e8ac3809c8549c4123a5271dcca",
"revisionTime": "2019-10-22T01:55:17Z"
},
{
"checksumSHA1": "Aao6Mul/qqogOwPwM2arBKZkYZs=",
"path": "github.com/pingcap/parser/format",
"revision": "51a2e3b2e34b61a7519e7d3e17dac38f0e8684f7",
"revisionTime": "2019-10-08T03:21:57Z"
"revision": "b10cc800c4e47e8ac3809c8549c4123a5271dcca",
"revisionTime": "2019-10-22T01:55:17Z"
},
{
"checksumSHA1": "GAJ7IUg0t8DCKJbJQxJLkklEj2E=",
"checksumSHA1": "p8oGDBAfGZ6nLZxwwKvMLuWCBh8=",
"path": "github.com/pingcap/parser/model",
"revision": "51a2e3b2e34b61a7519e7d3e17dac38f0e8684f7",
"revisionTime": "2019-10-08T03:21:57Z"
"revision": "b10cc800c4e47e8ac3809c8549c4123a5271dcca",
"revisionTime": "2019-10-22T01:55:17Z"
},
{
"checksumSHA1": "pN8v8r1syhLlLXw9TOq6bFgJfnY=",
"checksumSHA1": "KSbc38GqBQdMUeDXRbC1m0cmkfI=",
"path": "github.com/pingcap/parser/mysql",
"revision": "51a2e3b2e34b61a7519e7d3e17dac38f0e8684f7",
"revisionTime": "2019-10-08T03:21:57Z"
"revision": "b10cc800c4e47e8ac3809c8549c4123a5271dcca",
"revisionTime": "2019-10-22T01:55:17Z"
},
{
"checksumSHA1": "olapD16WCMBU9vrA5PtlERGFfXw=",
"path": "github.com/pingcap/parser/opcode",
"revision": "51a2e3b2e34b61a7519e7d3e17dac38f0e8684f7",
"revisionTime": "2019-10-08T03:21:57Z"
"revision": "b10cc800c4e47e8ac3809c8549c4123a5271dcca",
"revisionTime": "2019-10-22T01:55:17Z"
},
{
"checksumSHA1": "L6rzy3sJU1RPf7AkJN+0zcwW/YY=",
"path": "github.com/pingcap/parser/terror",
"revision": "51a2e3b2e34b61a7519e7d3e17dac38f0e8684f7",
"revisionTime": "2019-10-08T03:21:57Z"
"revision": "b10cc800c4e47e8ac3809c8549c4123a5271dcca",
"revisionTime": "2019-10-22T01:55:17Z"
},
{
"checksumSHA1": "u1Lmm4Fa3su4ElZMN4w0hPzFZl4=",
"path": "github.com/pingcap/parser/types",
"revision": "51a2e3b2e34b61a7519e7d3e17dac38f0e8684f7",
"revisionTime": "2019-10-08T03:21:57Z"
"revision": "b10cc800c4e47e8ac3809c8549c4123a5271dcca",
"revisionTime": "2019-10-22T01:55:17Z"
},
{
"checksumSHA1": "guCKXZsHObqyjp6P2BwLSUpcG+Y=",
"path": "github.com/pingcap/tidb/sessionctx/stmtctx",
"revision": "7c776be85d4445edd894052cc7585c310be6fca6",
"revisionTime": "2019-10-08T05:59:24Z"
"revision": "58fc7d44f73b65cc4cf9121bd540d905c774b588",
"revisionTime": "2019-10-23T07:08:59Z"
},
{
"checksumSHA1": "DIDA04qsKrAzuwlq+uJrY3wTU2Y=",
"checksumSHA1": "oz6sCtUOhry0rhxsqKbWaJX8Suk=",
"path": "github.com/pingcap/tidb/types",
"revision": "7c776be85d4445edd894052cc7585c310be6fca6",
"revisionTime": "2019-10-08T05:59:24Z"
"revision": "58fc7d44f73b65cc4cf9121bd540d905c774b588",
"revisionTime": "2019-10-23T07:08:59Z"
},
{
"checksumSHA1": "OSOQVeP518zWu3RoYSDWoh7DIjg=",
"path": "github.com/pingcap/tidb/types/json",
"revision": "7c776be85d4445edd894052cc7585c310be6fca6",
"revisionTime": "2019-10-08T05:59:24Z"
"revision": "58fc7d44f73b65cc4cf9121bd540d905c774b588",
"revisionTime": "2019-10-23T07:08:59Z"
},
{
"checksumSHA1": "45zWX5Q6D6aTEWtc4p/lbD9WD4o=",
"path": "github.com/pingcap/tidb/types/parser_driver",
"revision": "7c776be85d4445edd894052cc7585c310be6fca6",
"revisionTime": "2019-10-08T05:59:24Z"
"revision": "58fc7d44f73b65cc4cf9121bd540d905c774b588",
"revisionTime": "2019-10-23T07:08:59Z"
},
{
"checksumSHA1": "oCrNchmOGNQTnrkjk5CxFZpu2rE=",
"path": "github.com/pingcap/tidb/util/execdetails",
"revision": "7c776be85d4445edd894052cc7585c310be6fca6",
"revisionTime": "2019-10-08T05:59:24Z"
"revision": "58fc7d44f73b65cc4cf9121bd540d905c774b588",
"revisionTime": "2019-10-23T07:08:59Z"
},
{
"checksumSHA1": "QGCTegCx13wJyB0isXsV7mNIljE=",
"path": "github.com/pingcap/tidb/util/hack",
"revision": "7c776be85d4445edd894052cc7585c310be6fca6",
"revisionTime": "2019-10-08T05:59:24Z"
"revision": "58fc7d44f73b65cc4cf9121bd540d905c774b588",
"revisionTime": "2019-10-23T07:08:59Z"
},
{
"checksumSHA1": "SZhLPQR66Rd4kWkva6W3sJmSNLY=",
"checksumSHA1": "NHsKdiYnPgrXvKeFN53WMH+SRwU=",
"path": "github.com/pingcap/tidb/util/logutil",
"revision": "7c776be85d4445edd894052cc7585c310be6fca6",
"revisionTime": "2019-10-08T05:59:24Z"
"revision": "58fc7d44f73b65cc4cf9121bd540d905c774b588",
"revisionTime": "2019-10-23T07:08:59Z"
},
{
"checksumSHA1": "OveQu0ABBJmMEwmmthqSRQC2Ef0=",
"path": "github.com/pingcap/tidb/util/math",
"revision": "7c776be85d4445edd894052cc7585c310be6fca6",
"revisionTime": "2019-10-08T05:59:24Z"
"revision": "58fc7d44f73b65cc4cf9121bd540d905c774b588",
"revisionTime": "2019-10-23T07:08:59Z"
},
{
"checksumSHA1": "EhvViFDlyohEB9dvepvISTP28Zg=",
"path": "github.com/pingcap/tidb/util/memory",
"revision": "7c776be85d4445edd894052cc7585c310be6fca6",
"revisionTime": "2019-10-08T05:59:24Z"
"revision": "58fc7d44f73b65cc4cf9121bd540d905c774b588",
"revisionTime": "2019-10-23T07:08:59Z"
},
{
"checksumSHA1": "QPIBwDNUFF5Whrnd41S3mkKa4gQ=",
......@@ -497,74 +497,74 @@
{
"checksumSHA1": "aKn1oKcY74N8TRLm3Ayt7Q4bbI4=",
"path": "vitess.io/vitess/go/bytes2",
"revision": "2c8664c8005b440c11fd070d30357c90f749f140",
"revisionTime": "2019-10-07T23:18:38Z"
"revision": "590a06f9277fd29d7c9f77d50c4b11f1ba48f41c",
"revisionTime": "2019-10-19T20:56:25Z"
},
{
"checksumSHA1": "bhE6CGQgZTIgLPp9lnvlKW/47xc=",
"path": "vitess.io/vitess/go/hack",
"revision": "2c8664c8005b440c11fd070d30357c90f749f140",
"revisionTime": "2019-10-07T23:18:38Z"
"revision": "590a06f9277fd29d7c9f77d50c4b11f1ba48f41c",
"revisionTime": "2019-10-19T20:56:25Z"
},
{
"checksumSHA1": "v2dgco7U/RQtQbdX9ULGEXsZw6k=",
"path": "vitess.io/vitess/go/sqltypes",
"revision": "2c8664c8005b440c11fd070d30357c90f749f140",
"revisionTime": "2019-10-07T23:18:38Z"
"revision": "590a06f9277fd29d7c9f77d50c4b11f1ba48f41c",
"revisionTime": "2019-10-19T20:56:25Z"
},
{
"checksumSHA1": "vAIRxI6MHsq3x1hLQwIyw5AvqtI=",
"checksumSHA1": "a39Nes10plscGYzwVlSRgXFAITk=",
"path": "vitess.io/vitess/go/vt/log",
"revision": "2c8664c8005b440c11fd070d30357c90f749f140",
"revisionTime": "2019-10-07T23:18:38Z"
"revision": "590a06f9277fd29d7c9f77d50c4b11f1ba48f41c",
"revisionTime": "2019-10-19T20:56:25Z"
},
{
"checksumSHA1": "pm6qqJ+px6ev0huIVSE73XKT/pM=",
"checksumSHA1": "PTiZ/ErlpNltBWLO7WK7FI1c79c=",
"path": "vitess.io/vitess/go/vt/proto/binlogdata",
"revision": "2c8664c8005b440c11fd070d30357c90f749f140",
"revisionTime": "2019-10-07T23:18:38Z"
"revision": "590a06f9277fd29d7c9f77d50c4b11f1ba48f41c",
"revisionTime": "2019-10-19T20:56:25Z"
},
{
"checksumSHA1": "U2N66XbwVN2UbS7mI2fQqODKTFU=",
"path": "vitess.io/vitess/go/vt/proto/query",
"revision": "2c8664c8005b440c11fd070d30357c90f749f140",
"revisionTime": "2019-10-07T23:18:38Z"
"revision": "590a06f9277fd29d7c9f77d50c4b11f1ba48f41c",
"revisionTime": "2019-10-19T20:56:25Z"
},
{
"checksumSHA1": "mioM1BFNP3voMMt6rvT6i9BMxTA=",
"path": "vitess.io/vitess/go/vt/proto/topodata",
"revision": "2c8664c8005b440c11fd070d30357c90f749f140",
"revisionTime": "2019-10-07T23:18:38Z"
"revision": "590a06f9277fd29d7c9f77d50c4b11f1ba48f41c",
"revisionTime": "2019-10-19T20:56:25Z"
},
{
"checksumSHA1": "vFv/sVYQzHQFzLdxfLA3vX5Nz0U=",
"path": "vitess.io/vitess/go/vt/proto/vtgate",
"revision": "2c8664c8005b440c11fd070d30357c90f749f140",
"revisionTime": "2019-10-07T23:18:38Z"
"revision": "590a06f9277fd29d7c9f77d50c4b11f1ba48f41c",
"revisionTime": "2019-10-19T20:56:25Z"
},
{
"checksumSHA1": "6Pzimtq+Jv8CI6kTqkAjMkPoZZI=",
"path": "vitess.io/vitess/go/vt/proto/vtrpc",
"revision": "2c8664c8005b440c11fd070d30357c90f749f140",
"revisionTime": "2019-10-07T23:18:38Z"
"revision": "590a06f9277fd29d7c9f77d50c4b11f1ba48f41c",
"revisionTime": "2019-10-19T20:56:25Z"
},
{
"checksumSHA1": "IpnM59xLwj3/Kv5sbEFXBUvcj0o=",
"path": "vitess.io/vitess/go/vt/proto/vttime",
"revision": "2c8664c8005b440c11fd070d30357c90f749f140",
"revisionTime": "2019-10-07T23:18:38Z"
"revision": "590a06f9277fd29d7c9f77d50c4b11f1ba48f41c",
"revisionTime": "2019-10-19T20:56:25Z"
},
{
"checksumSHA1": "W6ID/pp1kmcssaxW+PtAD3flg5E=",
"checksumSHA1": "kt8JHcyRpFLLC1IjaAMwY1ZnmFU=",
"path": "vitess.io/vitess/go/vt/sqlparser",
"revision": "2c8664c8005b440c11fd070d30357c90f749f140",
"revisionTime": "2019-10-07T23:18:38Z"
"revision": "590a06f9277fd29d7c9f77d50c4b11f1ba48f41c",
"revisionTime": "2019-10-19T20:56:25Z"
},
{
"checksumSHA1": "z9+F/lA1Xrl5S16LKssUH8VL6hs=",
"checksumSHA1": "FT4i3QIXo5VAM/jg8UK5uyigyQY=",
"path": "vitess.io/vitess/go/vt/vterrors",
"revision": "2c8664c8005b440c11fd070d30357c90f749f140",
"revisionTime": "2019-10-07T23:18:38Z"
"revision": "590a06f9277fd29d7c9f77d50c4b11f1ba48f41c",
"revisionTime": "2019-10-19T20:56:25Z"
}
],
"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.
// 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
......@@ -7,6 +23,7 @@ package log
import (
"flag"
"github.com/golang/glog"
)
......
......@@ -158,6 +158,23 @@ func IsDML(sql string) bool {
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
// only if it's a simple expression. Otherwise, it returns "".
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
import (
......@@ -15,7 +31,7 @@ func replacer(s string) string {
return s[2:]
}
result := strings.Replace(s, "%" ,".*", -1)
result := strings.Replace(s, "%", ".*", -1)
result = strings.Replace(result, "_", ".", -1)
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
import querypb "vitess.io/vitess/go/vt/proto/query"
......
......@@ -158,7 +158,7 @@ func skipToEnd(yylex interface{}) {
// DDL Tokens
%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> SHOW DESCRIBE EXPLAIN DATE ESCAPE REPAIR OPTIMIZE TRUNCATE
%token <bytes> MAXVALUE PARTITION REORGANIZE LESS THAN PROCEDURE TRIGGER
......@@ -1378,7 +1378,8 @@ alter_statement:
}
alter_object_type:
COLUMN
CHECK
| COLUMN
| CONSTRAINT
| FOREIGN
| FULLTEXT
......@@ -3324,6 +3325,7 @@ non_reserved_keyword:
| CHAR
| CHARACTER
| CHARSET
| CHECK
| COLLATION
| COLUMNS
| COMMENT_KEYWORD
......
......@@ -117,7 +117,7 @@ var keywords = map[string]int{
"char": CHAR,
"character": CHARACTER,
"charset": CHARSET,
"check": UNUSED,
"check": CHECK,
"collate": COLLATE,
"collation": COLLATION,
"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
/* 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
//
// 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.
先完成此消息的编辑!
想要评论请 注册