On Mon, May 17, 2010 at 02:15:09PM -0400, Sam Carleton scratched on the wall:
> Michael,
> 
> I really don't mean to be rude, but I know about the SQLITE_BUSY and that it
> must be handled and all that good stuff, am I handling it right now?  No;
> will I? Yes, but that isn't my issue, I understand I need to handle those
> conditions and I am confident that I know how to handle that condition.


> My question is real simple:  Can I open a DB in read-only and then attach a
> :memory: db to it and write to the :memory: db?  Or must the file DB be
> opened in read/write?

  No; Yes.  Whatever flags are passed to sqlite3_open_v2() appear to be
  passed to all ATTACHed databases as well, so if you open a database
  with SQLITE_OPEN_READONLY, the :memory: db is read-only as well.
  This limits their use.

  If you open a database read-write, but the file permissions do not
  allow that, it will still be opened read-only.  ATTACHed DBs will
  open read-write as well.  However, if the main db is in a read-only
  directory, SQLite can't make the proper journal files and returns
  errors.

> Oh, more to your question, let me ask you if this following assumption is
> correct:
> 
> *If you only need read-only access, open it in read-only, fore it plays
> nicer with other threads that are also doing read-only operations.*

  Not really.  Even if the DB is opened read-only, it still needs to
  manipulate locks on the file.  You might still get SQLITE_BUSY or any
  other lock-related errors/conditions.

   -j

-- 
Jay A. Kreibich < J A Y  @  K R E I B I.C H >

"Our opponent is an alien starship packed with atomic bombs.  We have
 a protractor."   "I'll go home and see if I can scrounge up a ruler
 and a piece of string."  --from Anathem by Neal Stephenson
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to