-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
executor: implement set transaction read only as of transaction #24766
Changes from 1 commit
72498dd
21871cd
7f7643f
8e32482
9395162
900cf31
b0fe8e2
ce2df75
5c4ffda
6c938a7
3c465d0
29b8389
a72892a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -748,6 +748,13 @@ var defaultSysVars = []*SysVar{ | |
} | ||
return nil | ||
}}, | ||
{Scope: ScopeSession, Name: TiDBTxnReadTS, Value: "", SetSession: func(s *SessionVars, val string) error { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this sysvar exposed to users? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it is ok to exposed it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The problem is, users may also use this variable to set read ts. |
||
err := setTxnReadTS(s, val) | ||
if err != nil { | ||
return err | ||
} | ||
return nil | ||
Yisaer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}}, | ||
{Scope: ScopeGlobal | ScopeSession, Name: TiDBAllowMPPExecution, Value: On, Type: TypeEnum, PossibleValues: []string{"OFF", "ON", "ENFORCE"}, SetSession: func(s *SessionVars, val string) error { | ||
s.allowMPPExecution = val | ||
return nil | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -465,6 +465,23 @@ func setSnapshotTS(s *SessionVars, sVal string) error { | |
return err | ||
} | ||
|
||
func setTxnReadTS(s *SessionVars, sVal string) error { | ||
if sVal == "" { | ||
s.TxnReadTS = 0 | ||
return nil | ||
} | ||
t, err := types.ParseTime(s.StmtCtx, sVal, mysql.TypeTimestamp, types.MaxFsp) | ||
if err != nil { | ||
return err | ||
} | ||
t1, err := t.GoTime(s.TimeZone) | ||
if err != nil { | ||
return err | ||
} | ||
s.TxnReadTS = GoTimeToTS(t1) | ||
return err | ||
} | ||
|
||
// GoTimeToTS converts a Go time to uint64 timestamp. | ||
func GoTimeToTS(t time.Time) uint64 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this function is duplicated with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated. |
||
ts := (t.UnixNano() / int64(time.Millisecond)) << epochShiftBits | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should support expression? our bound read is a function call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is already supported, the testcase updated.