unset interrupt BEFORE closing connection

This commit is contained in:
kim 2024-04-18 12:05:06 +01:00
parent 3dcd314ed8
commit 2a9d1cb4f4
1 changed files with 4 additions and 1 deletions

View File

@ -278,12 +278,15 @@ func (c *SQLiteConn) Close() (err error) {
// Set a timeout context to limit execution time.
ctx, cncl := context.WithTimeout(ctx, 5*time.Second)
old := raw.SetInterrupt(ctx)
defer func() { cncl(); raw.SetInterrupt(old) }()
// see: https://www.sqlite.org/pragma.html#pragma_optimize
const onClose = "PRAGMA analysis_limit=1000; PRAGMA optimize;"
_ = raw.Exec(onClose)
// Unset timeout context.
_ = raw.SetInterrupt(old)
cncl()
// Finally, release + close.
_ = raw.ReleaseMemory()
err = raw.Close()