#if !SQLITE_STANDARD\r
int n = UnsafeNativeMethods.sqlite3_close_interop(db);\r
#else\r
- ResetConnection(db);\r
- int n = UnsafeNativeMethods.sqlite3_close(db);\r
+ ResetConnection(db);\r
+ int n;\r
+ try {\r
+ n = UnsafeNativeMethods.sqlite3_close_v2(db);\r
+ } catch (EntryPointNotFoundException) {\r
+ n = UnsafeNativeMethods.sqlite3_close(db);\r
+ }\r
#endif\r
if (n > 0) throw new SqliteException(n, SQLiteLastError(db));\r
}\r
[DllImport(SQLITE_DLL)]\r
#endif\r
internal static extern int sqlite3_close(IntPtr db);\r
+ \r
+#if !PLATFORM_COMPACTFRAMEWORK\r
+ [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]\r
+#else\r
+ [DllImport(SQLITE_DLL)]\r
+#endif\r
+ internal static extern int sqlite3_close_v2(IntPtr db);\r
\r
#if !PLATFORM_COMPACTFRAMEWORK\r
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]\r
readonly static string _connectionString = "URI=file://" + _uri + ", version=3";
SqliteConnection _conn = new SqliteConnection ();
+ [Test]
+ public void ReleaseDatabaseFileHandles ()
+ {
+ _conn.ConnectionString = _connectionString;
+ _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 (_uri);
+ }
+
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void ConnectionStringTest_Null ()