Niall,

I'm using a dbname of 'file:memdb2?mode=memory&cache=shared' in order to allow 
several threads to connect
to the same in-memory DB (per docs at: http://www.sqlite.org/inmemorydb.html).

This works great! (And works around a dumb limitation od DBI/iThreads.)

The problem is that (despite the assertion in the above-linked docs to the 
affect: "The database is automatically deleted and memory is reclaimed when the 
last connection to the database closes."), this in-memory database actually 
persists. Ie. Beyond the life of the program that created it.

That is, I create a DB via a connect string as above, and insert (say) 1000 
records; query & print count(*) (prints 1000);  and then end the program. 

If then run the program a second time, the count output is 2000! And the 3rd 
time 3000...

Looking in the cwd, I see a file (called 'file'), but it has size 0? Looking 
further I discover that it has and Alternate stream named: 

       :memdb2?mode=memory&cache=shared:$DATA 

With a size of: 347136

IF I delete that "zero-length" file, then the next run of the program returns a 
count(8) of 1000 as expected.

So, the question is: Why is this file not being deleted?

As far as I can tell I am doing everything I can to enable it -- finish()ing my 
statement handles and disconnecting my connections -- but it still persists 
unless I unlink the file.

Is this a sqlite bug? Or a DBD::Sqlite bug? or a DBI bug; or some interaction 
between 1 or more of those and threading?

Thoughts?

Cheers, Buk.



> -----Original Message-----
> From: sqlite.browseruk.868d0fbe32.niall.oreilly#ucd...@ob.0sg.net
> Sent: Fri, 19 Jul 2013 13:36:31 +0100
> To: sqlite-users@sqlite.org
> Subject: Re: [sqlite] Using in-memory DBs of the form:
message
> 14 of 20) "file:memdb1?mode=memory&cache=shared" (via Perl, DBD::SQLite &
> DBI)
> 
> 
> On 19 Jul 2013, at 09:36, sqlite.20.browse...@xoxy.net wrote:
> 
>> Anyone here using SQLite via Perl & DBI & DBD::SQLite?
> 
>       Yes, but not with an in-memory database.
> 
>       Niall O'Reilly
> 
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

____________________________________________________________
FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!
Check it out at http://www.inbox.com/earth



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

Reply via email to