On Dec 12, 2008, at 11:16 AM, Marco Bambini wrote:

> I have two databases, db1 and db2.
> At some point I attach db2 to db1 as 'destdb' then I do:
>
> sqlite3_exec(db1, "BEGIN", ...);
> sqlite3_exec(db1, "INSERT INTO destdb.table1 SELECT * FROM
> main.table1", ...);
> sqlite3_exec(db1, "INSERT INTO destdb.table2 SELECT * FROM
> main.table2", ...);
> sqlite3_exec(db1, "COMMIT", ...);
>
> so, I am actually reading from db1 and writing to db2, but since the
> two db are attached and the transaction is started in db1, I wonder if
> locking on db1 is marked as RESERVED or EXCLUSIVE at some point. (I
> just would like to know if db1 seems a db with write operations from
> sqlite's point of view)... and should the transaction be started on
> db2 or it doesn't matter when the two dbs are attached?
>

Recompile with -DSQLITE_DEBUG=1.  Then call "PRAGMA lock_status" prior  
to the COMMIT (or any other place when you want to know what the  
status of the locks is) and it will tell you.

Or, from C, call sqlite3_file_control() with the  
SQLITE_FCNTL_LOCKSTATE option for each attached database and you will  
get back the lock status for that database.  See the implementation of  
the "lock_status" pragma for an example.

D. Richard Hipp
d...@hwaci.com



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

Reply via email to