Close closes the database connection and removes the temporary file if it is not persistent.
()
| 413 | |
| 414 | // Close closes the database connection and removes the temporary file if it is not persistent. |
| 415 | func (t *TempDB) Close() error { |
| 416 | t.mu.Lock() |
| 417 | defer t.mu.Unlock() |
| 418 | |
| 419 | if t.db != nil { |
| 420 | if err := t.db.Close(); err != nil { |
| 421 | // Only remove file if it's not persistent |
| 422 | if t.config != nil && t.config.PersistentFile == "" { |
| 423 | os.Remove(t.path) |
| 424 | } |
| 425 | return err |
| 426 | } |
| 427 | } |
| 428 | |
| 429 | // Only remove file if it's not persistent |
| 430 | if t.config != nil && t.config.PersistentFile == "" { |
| 431 | return os.Remove(t.path) |
| 432 | } |
| 433 | return nil |
| 434 | } |
| 435 | |
| 436 | // verifyPragmaSettings reads back PRAGMA values to verify they were applied correctly |
| 437 | func verifyPragmaSettings(db *sql.DB, cfg *TempDBConfig) error { |