only set stmt cacheKey when cache is enabled

This commit is contained in:
Yasuhiro Matsumoto
2026-04-14 14:14:47 +09:00
parent 2badb4cfef
commit 59e8e756b9

View File

@@ -1943,7 +1943,7 @@ func (c *SQLiteConn) takeCachedStmt(query string) *SQLiteStmt {
} }
func (c *SQLiteConn) putCachedStmt(s *SQLiteStmt) bool { func (c *SQLiteConn) putCachedStmt(s *SQLiteStmt) bool {
if c == nil || s == nil || s.s == nil || s.cacheKey == "" || !c.stmtCacheEnabled { if c == nil || s == nil || s.s == nil || s.cacheKey == "" {
return false return false
} }
@@ -2021,7 +2021,7 @@ func (c *SQLiteConn) prepareWithCache(ctx context.Context, query string) (driver
return nil, err return nil, err
} }
ss := stmt.(*SQLiteStmt) ss := stmt.(*SQLiteStmt)
if ss.t == "" { if ss.t == "" && c.stmtCacheEnabled {
ss.cacheKey = query ss.cacheKey = query
} }
return ss, nil return ss, nil