[mono.data.sqlite] Using sqlite_close_v2 when available
From Matthew Leibowitz (mattleibo)
This is the recommended function for garbage collected languages.
http://sqlite.org/c3ref/close.html
The sqlite3_close_v2() interface is intended for use with host
languages that are garbage collected, and where the order in which
destructors are called is arbitrary.
Falls back to old sqlite3_close if we are on an old system
Useful for ADO.NET where the connection os often closed, but the
commands are re-usable
Mostly visible on Windows operating systems
This snippet should fail with a System.IO.IOException using the
current build of Mono on Windows:
string filename = "test_" + Guid.NewGuid ().ToString ("N") + ".db";
SqliteConnection conn = new SqliteConnection ("Data Source=" + filename);
conn.Open ();
SqliteCommand cmd = conn.CreateCommand ();
cmd.CommandText = "PRAGMA legacy_file_format;";
cmd.ExecuteScalar ();
// close connection before the command
conn.Dispose ();
// then close the command
cmd.Dispose ();
// the locks should be released, and we should be able to delete the database
File.Delete (filename);