Skip to content

Commit 60691f5

Browse files
authored
*: clean up the deserted syntax of START TRANSACTION READ ONLY (pingcap#1230)
* Clean up the deserted syntax of START TRANSACTION READ ONLY Signed-off-by: JmPotato <[email protected]>
1 parent c37778a commit 60691f5

File tree

5 files changed

+5806
-5972
lines changed

5 files changed

+5806
-5972
lines changed

ast/dml.go

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3330,33 +3330,8 @@ func (m FulltextSearchModifier) WithQueryExpansion() bool {
33303330
return m&FulltextSearchModifierWithQueryExpansion == FulltextSearchModifierWithQueryExpansion
33313331
}
33323332

3333-
// TODO: remove the TimestampBoundMode.
3334-
type TimestampBoundMode int
3335-
3336-
const (
3337-
TimestampBoundStrong TimestampBoundMode = iota
3338-
TimestampBoundMaxStaleness
3339-
TimestampBoundExactStaleness
3340-
TimestampBoundReadTimestamp
3341-
TimestampBoundMinReadTimestamp
3342-
)
3343-
3344-
type TimestampReadModes int
3345-
3346-
const (
3347-
TimestampReadStrong TimestampReadModes = iota
3348-
TimestampReadBoundTimestamp
3349-
TimestampReadExactTimestamp
3350-
)
3351-
3352-
type TimestampBound struct {
3353-
Mode TimestampBoundMode
3354-
Timestamp ExprNode
3355-
}
3356-
33573333
type AsOfClause struct {
33583334
node
3359-
Mode TimestampReadModes
33603335
TsExpr ExprNode
33613336
}
33623337

ast/misc.go

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -388,9 +388,8 @@ func (n *ExecuteStmt) Accept(v Visitor) (Node, bool) {
388388
type BeginStmt struct {
389389
stmtNode
390390
Mode string
391-
ReadOnly bool
392-
Bound *TimestampBound
393391
CausalConsistencyOnly bool
392+
ReadOnly bool
394393
// AS OF is used to read the data at a specific point of time.
395394
// Should only be used when ReadOnly is true.
396395
AsOf *AsOfClause
@@ -401,24 +400,7 @@ func (n *BeginStmt) Restore(ctx *format.RestoreCtx) error {
401400
if n.Mode == "" {
402401
if n.ReadOnly {
403402
ctx.WriteKeyWord("START TRANSACTION READ ONLY")
404-
if n.Bound != nil {
405-
switch n.Bound.Mode {
406-
case TimestampBoundStrong:
407-
ctx.WriteKeyWord(" WITH TIMESTAMP BOUND STRONG")
408-
case TimestampBoundMaxStaleness:
409-
ctx.WriteKeyWord(" WITH TIMESTAMP BOUND MAX STALENESS ")
410-
return n.Bound.Timestamp.Restore(ctx)
411-
case TimestampBoundExactStaleness:
412-
ctx.WriteKeyWord(" WITH TIMESTAMP BOUND EXACT STALENESS ")
413-
return n.Bound.Timestamp.Restore(ctx)
414-
case TimestampBoundReadTimestamp:
415-
ctx.WriteKeyWord(" WITH TIMESTAMP BOUND READ TIMESTAMP ")
416-
return n.Bound.Timestamp.Restore(ctx)
417-
case TimestampBoundMinReadTimestamp:
418-
ctx.WriteKeyWord(" WITH TIMESTAMP BOUND MIN READ TIMESTAMP ")
419-
return n.Bound.Timestamp.Restore(ctx)
420-
}
421-
} else if n.AsOf != nil {
403+
if n.AsOf != nil {
422404
ctx.WriteKeyWord(" ")
423405
return n.AsOf.Restore(ctx)
424406
}
@@ -441,13 +423,6 @@ func (n *BeginStmt) Accept(v Visitor) (Node, bool) {
441423
return v.Leave(newNode)
442424
}
443425
n = newNode.(*BeginStmt)
444-
if n.Bound != nil && n.Bound.Timestamp != nil {
445-
newTimestamp, ok := n.Bound.Timestamp.Accept(v)
446-
if !ok {
447-
return n, false
448-
}
449-
n.Bound.Timestamp = newTimestamp.(ExprNode)
450-
}
451426
return v.Leave(n)
452427
}
453428

0 commit comments

Comments
 (0)