Skip to content

Commit 24e6b03

Browse files
committed
add InitSessionVariable in session manager
1 parent c740588 commit 24e6b03

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

server/context.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,15 @@ func (s *SessionManager) getOrCreateSession(ctx context.Context, conn *mysql.Con
235235
return sess, nil
236236
}
237237

238+
// InitSessionVariable sets a value to a parameter of a session at start.
239+
func (s *SessionManager) InitSessionVariable(ctx context.Context, conn *mysql.Conn, name, value string) error {
240+
sess, err := s.getOrCreateSession(ctx, conn)
241+
if err != nil {
242+
return err
243+
}
244+
return sess.InitSessionVariable(s.ctxFactory(ctx, sql.WithSession(sess)), name, value)
245+
}
246+
238247
// NewContextWithQuery creates a new context for the session at the given conn.
239248
func (s *SessionManager) NewContextWithQuery(ctx context.Context, conn *mysql.Conn, query string) (*sql.Context, error) {
240249
sess, err := s.getOrCreateSession(ctx, conn)

0 commit comments

Comments
 (0)