Revert "accept lunny's suggestion"

This reverts commit 57fd669942.
This commit is contained in:
yong.an 2020-07-13 18:15:22 +08:00
parent 57fd669942
commit 3fb2294415
1 changed files with 11 additions and 2 deletions

View File

@ -100,8 +100,17 @@ func newSessionID() string {
} }
func newSession(engine *Engine) *Session { func newSession(engine *Engine) *Session {
var ctx context.Context
var sessionID string
if engine.logSessionID {
sessionID = newSessionID()
ctx = context.WithValue(engine.defaultContext, log.SessionIDKey, sessionID)
} else {
ctx = engine.defaultContext
}
session := &Session{ session := &Session{
ctx: engine.defaultContext, ctx: ctx,
engine: engine, engine: engine,
tx: nil, tx: nil,
statement: statements.NewStatement( statement: statements.NewStatement(
@ -130,7 +139,7 @@ func newSession(engine *Engine) *Session {
sessionType: engineSession, sessionType: engineSession,
} }
if engine.logSessionID { if engine.logSessionID {
session.ctx = context.WithValue(session.ctx, log.SessionIDKey, session) session.ctx = context.WithValue(session.ctx, sessionID, session)
} }
return session return session
} }