release memory on close, return close error

This commit is contained in:
kim 2024-04-18 11:41:07 +01:00
parent e92b36e765
commit 7ad9da2cfc
1 changed files with 4 additions and 4 deletions

View File

@ -272,10 +272,10 @@ func (c *SQLiteConn) QueryContext(ctx context.Context, query string, args []driv
func (c *SQLiteConn) Close() (err error) {
// see: https://www.sqlite.org/pragma.html#pragma_optimize
const onClose = "PRAGMA analysis_limit=1000; PRAGMA optimize;"
if r, ok := c.ConnIface.(sqlite3.DriverConn); ok {
_ = r.Raw().Exec(onClose)
_ = r.Raw().Close()
}
raw := c.ConnIface.(sqlite3.DriverConn).Raw()
_ = raw.Exec(onClose)
_ = raw.ReleaseMemory()
err = raw.Close()
return
}