[sqlite] System.Data.SQLite: Incompatible file locking behavior starting version 1.0.82.0

2013-04-25 Thread Levi Haskell (BLOOMBERG/ 731 LEXIN)
It seems that in version 1.0.81.0 and earlier the database file was released 
immediately after all SQLiteConnection objects were disposed even if some 
dependent SQLiteCommand and/or SQLiteDataReader objects were not yet disposed 
or closed. 
However starting version 1.0.82.0 the file remains locked. Consider this code:

var file = Path.GetTempFileName();
using (var connection = new SQLiteConnection(Data Source= + file))
{
  Console.WriteLine(connection.GetType().Assembly.FullName);
  connection.Open();

  var command = connection.CreateCommand();
  command.CommandText = CREATE TABLE t(a);
  command.ExecuteNonQuery();
}
// the following line succeeds in v1.0.81.0 and earlier but
// FAILS on v1.0.82.0 and later with file still in use error
File.Delete(file);

Was this change made by design?

Thanks,
- Levi

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] System.Data.SQLite: Incompatible file locking behavior starting version 1.0.82.0

2013-04-25 Thread Joe Mistachkin

As of release 1.0.82.0, the object disposal semantics were changed to keep
the underlying connection around until all associated System.Data.SQLite
objects have been properly disposed.

Levi Haskell wrote:
 
 var file = Path.GetTempFileName();
 using (var connection = new SQLiteConnection(Data Source= + file))
 {
   Console.WriteLine(connection.GetType().Assembly.FullName);
   connection.Open();
 
   var command = connection.CreateCommand();
   command.CommandText = CREATE TABLE t(a);
   command.ExecuteNonQuery();
 }
 // the following line succeeds in v1.0.81.0 and earlier but
 // FAILS on v1.0.82.0 and later with file still in use error
 File.Delete(file);
 

In the above example, adding command.Dispose(); just prior to the end of
the using block should allow the file to be deleted.


 Was this change made by design?


Yes.

--
Joe Mistachkin

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] System.Data.SQLite: Incompatible file locking behavior starting version 1.0.82.0

2013-04-25 Thread Levi Haskell (BLOOMBERG/ 731 LEXIN)
Thank you Joe,

What was the motivation for this change (it seems to be quite inconvenient in 
my case)?

- Levi

- Original Message -
From: sql...@mistachkin.com
To: sqlite-users@sqlite.org
Cc: Levi Haskell (BLOOMBERG/ 731 LEXIN)
At: Apr 25 2013 15:07:54


As of release 1.0.82.0, the object disposal semantics were changed to keep
the underlying connection around until all associated System.Data.SQLite
objects have been properly disposed.

Levi Haskell wrote:
 
 var file = Path.GetTempFileName();
 using (var connection = new SQLiteConnection(Data Source= + file))
 {
   Console.WriteLine(connection.GetType().Assembly.FullName);
   connection.Open();
 
   var command = connection.CreateCommand();
   command.CommandText = CREATE TABLE t(a);
   command.ExecuteNonQuery();
 }
 // the following line succeeds in v1.0.81.0 and earlier but
 // FAILS on v1.0.82.0 and later with file still in use error
 File.Delete(file);
 

In the above example, adding command.Dispose(); just prior to the end of
the using block should allow the file to be deleted.


 Was this change made by design?


Yes.

--
Joe Mistachkin


___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] System.Data.SQLite: Incompatible file locking behavior starting version 1.0.82.0

2013-04-25 Thread Joe Mistachkin

Levi Haskell wrote:

 What was the motivation for this change (it seems to be quite inconvenient
 in my case)?


The previous method used to deal with the non-deterministic finalization
order
imposed by the CLR did not work reliably in all circumstances, did not
follow
best-practices for the IDisposable interface, and relied heavily upon
internal
semantics of the native SQLite core library.

--
Joe Mistachkin

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] System.Data.SQLite: Incompatible file locking behavior starting version 1.0.82.0

2013-04-25 Thread Levi Haskell (BLOOMBERG/ 731 LEXIN)
Is this what the INTEROP_LEGACY_CLOSE compile-time option refers to?


  *Use the legacy connection closing algorithm when built with the 
INTEROP_LEGACY_CLOSE compile-time option.

Thanks,
- Levi

- Original Message -
From: sql...@mistachkin.com
To: sqlite-users@sqlite.org
Cc: Levi Haskell (BLOOMBERG/ 731 LEXIN)
At: Apr 25 2013 16:38:27


Levi Haskell wrote: gt; gt; What was the motivation for this change (it seems 
to be quite inconvenient gt; in my case)? gt;  The previous method used to 
deal with the non-deterministic finalization order imposed by the CLR did not 
work reliably in all circumstances, did not follow best-practices for the 
IDisposable interface, and relied heavily upon internal semantics of the native 
SQLite core library.  -- Joe Mistachkin  
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] System.Data.SQLite: Incompatible file locking behavior starting version 1.0.82.0

2013-04-25 Thread Joe Mistachkin

Levi Haskell wrote:

 Is this what the INTEROP_LEGACY_CLOSE compile-time option refers to?

 
Yes.

--
Joe Mistachkin

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users