Skip to content

Commit

Permalink
3.0 nowait grammar (pingcap#616)
Browse files Browse the repository at this point in the history
  • Loading branch information
cfzjywxk authored and coocood committed Nov 6, 2019
1 parent 555b970 commit c499e11
Show file tree
Hide file tree
Showing 9 changed files with 6,161 additions and 6,137 deletions.
5 changes: 4 additions & 1 deletion ast/dml.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ const (
SelectLockNone SelectLockType = iota
SelectLockForUpdate
SelectLockInShareMode
SelectLockForUpdateNoWait
)

// String implements fmt.Stringer.
Expand All @@ -434,6 +435,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"
}
Expand Down Expand Up @@ -881,7 +884,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())
}
Expand Down
2 changes: 1 addition & 1 deletion ast/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
1 change: 1 addition & 0 deletions misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,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
Expand Down
2 changes: 1 addition & 1 deletion model/model_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (*testModelSuite) TestModelBasic(c *C) {
c.Assert(tp.String(), Equals, "BTREE")
tp = IndexTypeHash
c.Assert(tp.String(), Equals, "HASH")
tp = 1E5
tp = 1e5
c.Assert(tp.String(), Equals, "")
has := index.HasPrefixIndex()
c.Assert(has, Equals, true)
Expand Down
1 change: 1 addition & 0 deletions mysql/errcode.go
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,7 @@ const (
ErrInvalidJSONPathArrayCell = 3165
ErrBadUser = 3162
ErrRoleNotGranted = 3530
ErrLockAcquireFailAndNoWaitSet = 3572
ErrWindowNoSuchWindow = 3579
ErrWindowCircularityInWindowGraph = 3580
ErrWindowNoChildPartitioning = 3581
Expand Down
1 change: 1 addition & 0 deletions mysql/errname.go
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,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",
Expand Down
Loading

0 comments on commit c499e11

Please sign in to comment.