Skip to content

Commit

Permalink
This is an automated cherry-pick of pingcap#44486
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <[email protected]>
  • Loading branch information
zimulala authored and ti-chi-bot committed Jun 8, 2023
1 parent 03c7688 commit 58e1778
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,9 @@ func (s *session) TxnInfo() *txninfo.TxnInfo {
}

processInfo := s.ShowProcess()
if processInfo == nil {
return nil
}
txnInfo.ConnectionID = processInfo.ID
txnInfo.Username = processInfo.User
txnInfo.CurrentDB = processInfo.DB
Expand Down Expand Up @@ -2840,6 +2843,29 @@ func (s *session) ShowProcess() *util.ProcessInfo {
return pi
}

<<<<<<< HEAD
=======
// GetStartTSFromSession returns the startTS in the session `se`
func GetStartTSFromSession(se interface{}) (startTS, processInfoID uint64) {
tmp, ok := se.(*session)
if !ok {
logutil.BgLogger().Error("GetStartTSFromSession failed, can't transform to session struct")
return 0, 0
}
txnInfo := tmp.TxnInfo()
if txnInfo != nil {
startTS = txnInfo.StartTS
processInfoID = txnInfo.ConnectionID
}

logutil.BgLogger().Debug(
"GetStartTSFromSession getting startTS of internal session",
zap.Uint64("startTS", startTS), zap.Time("start time", oracle.GetTimeFromTS(startTS)))

return startTS, processInfoID
}

>>>>>>> 3c50d5130ba (session, ddl: fix the nil point in `TxnInfo` (#44486))
// logStmt logs some crucial SQL including: CREATE USER/GRANT PRIVILEGE/CHANGE PASSWORD/DDL etc and normal SQL
// if variable.ProcessGeneralLog is set.
func logStmt(execStmt *executor.ExecStmt, s *session) {
Expand Down

0 comments on commit 58e1778

Please sign in to comment.