From 59e8e756b9cb3815dea75463f8276e289cd93d89 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Tue, 14 Apr 2026 14:14:47 +0900 Subject: [PATCH] only set stmt cacheKey when cache is enabled --- sqlite3.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sqlite3.go b/sqlite3.go index fa21a81..62199ab 100644 --- a/sqlite3.go +++ b/sqlite3.go @@ -1943,7 +1943,7 @@ func (c *SQLiteConn) takeCachedStmt(query string) *SQLiteStmt { } 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 } @@ -2021,7 +2021,7 @@ func (c *SQLiteConn) prepareWithCache(ctx context.Context, query string) (driver return nil, err } ss := stmt.(*SQLiteStmt) - if ss.t == "" { + if ss.t == "" && c.stmtCacheEnabled { ss.cacheKey = query } return ss, nil