-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 02/18/2011 07:24 PM, Frank Chang wrote:
> As a result, I periodically get a sqlite return code of 1 from sqlite3_step 
> after inserting one of the 5.4 million rows. 

That just means there was an error.  You still need to sqlite3_reset to find
out what it was.  (eg it could be a constraint failure.)

> The database locking problem is causing me to skip insertions.

No, your code is.  Until you do a commit the data is not saved and there are
any number of reasons the transaction could be interrupted (eg running out
of memory).  You can use BEGIN EXCLUSIVE to acquire the write lock with the
begin statement rather than the lazy acquisition done by default.

> I would like to verify if my executable does indeed have multiple
connections to the sqlite database. Is there a sqlite API does can tell me
how many open connections my executable is responsible for?

Nope.  Each sqlite3_open is independent of the others and have no idea if
the same process, threads etc are also using the same file.  That is why
locking is used.  (shared cache mode is an exception.)

> Also, it is possible to determine the lines of code(i.e like a gdb
backtrace) in my application are responsible for each of the multiple
connection? Thank you.                                  

Put a breakpoint on sqlite3_open{,_v2}

If your one chunk of code should be the only one with a connection then use
BEGIN EXCLUSIVE and your transaction can't be interrupted by another
connection (same process or not).

If there should be multiple accessors then setting a busy timeout is
probably the most appropriate solution.

See also:

  http://www.sqlite.org/lockingv3.html

Roger
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk1fWWIACgkQmOOfHg372QR8QgCg0M4bJCTJTFZqyTQloqp2oZ+4
U6EAn3CSmscbyTlOHgKwJ8ajhZpdnyZg
=rVQa
-----END PGP SIGNATURE-----
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to