Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parser: add nowait keyword, add for update no wait grammar, and related error… #582

Merged
merged 4 commits into from
Oct 18, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion ast/dml.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ const (
SelectLockNone SelectLockType = iota
SelectLockForUpdate
SelectLockInShareMode
SelectLockForUpdateNoWait
)

// String implements fmt.Stringer.
Expand All @@ -432,6 +433,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 @@ -666,6 +666,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 @@ -903,6 +903,7 @@ const (
ErrBadUser = 3162
ErrInvalidEncryptionOption = 3184
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 @@ -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",
Expand Down
Loading