Skip to content

Commit

Permalink
Add "START TRANSACTION WITH CAUSAL CONSISTENCY ONLY" (#1162)
Browse files Browse the repository at this point in the history
* add a start transaction without external consistency statement

Signed-off-by: ekexium <[email protected]>

* change the grammar to 'with causal consistency'

Signed-off-by: ekexium <[email protected]>

* rename WithoutExternalConsistency to CausalConsistency

Signed-off-by: ekexium <[email protected]>

* change syntax to 'start transaction with causal consistency only'

Signed-off-by: ekexium <[email protected]>

Co-authored-by: ti-srebot <[email protected]>
  • Loading branch information
ekexium and ti-srebot authored Feb 3, 2021
1 parent 559bdbd commit 32ef3e0
Show file tree
Hide file tree
Showing 5 changed files with 9,106 additions and 9,069 deletions.
9 changes: 6 additions & 3 deletions ast/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,10 @@ func (n *ExecuteStmt) Accept(v Visitor) (Node, bool) {
// See https://dev.mysql.com/doc/refman/5.7/en/commit.html
type BeginStmt struct {
stmtNode
Mode string
ReadOnly bool
Bound *TimestampBound
Mode string
ReadOnly bool
Bound *TimestampBound
CausalConsistencyOnly bool
}

// Restore implements Node interface.
Expand All @@ -414,6 +415,8 @@ func (n *BeginStmt) Restore(ctx *format.RestoreCtx) error {
return n.Bound.Timestamp.Restore(ctx)
}
}
} else if n.CausalConsistencyOnly {
ctx.WriteKeyWord("START TRANSACTION WITH CAUSAL CONSISTENCY ONLY")
} else {
ctx.WriteKeyWord("START TRANSACTION")
}
Expand Down
2 changes: 2 additions & 0 deletions misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ var tokenMap = map[string]int{
"CASCADED": cascaded,
"CASE": caseKwd,
"CAST": cast,
"CAUSAL": causal,
"CHAIN": chain,
"CHANGE": change,
"CHAR": charType,
Expand Down Expand Up @@ -233,6 +234,7 @@ var tokenMap = map[string]int{
"CONCURRENCY": concurrency,
"CONFIG": config,
"CONNECTION": connection,
"CONSISTENCY": consistency,
"CONSISTENT": consistent,
"CONSTRAINT": constraint,
"CONSTRAINTS": constraints,
Expand Down
Loading

0 comments on commit 32ef3e0

Please sign in to comment.