Re: [sqlite] 1 reader 1 writer but sqlite3_step fails wit h “database is locked” error in both processes

2010-02-15 Thread a1rex
Closing the thread:
>Then why sqlite3_step() fails for the reader and for the 
writer?


The reader fails since
it cannot obtain SHARED lock required for reading.
It cannot obtain that
lock since the writer already managed to obtain PENDING or EXCLUSIVE lock.
 
The writer fails since
there is pending SHARED lock acquired by reader which did not finished reading.
The writer needs to obtain EXCLUSIVE lock and no other
locks of any kind are allowed to coexist with an EXCLUSIVE lock.


- Original Message 
From: Igor Tandetnik 
To: sqlite-users@sqlite.org
Sent: Sun, February 14, 2010 2:54:35 PM
Subject: Re: [sqlite] 1 reader 1 writer but sqlite3_step fails with “database 
is locked”  error in both processes

a1rex wrote:
>  I thought that I can have 1 writer and many readers 

You thought incorrectly. You can have one writer OR many readers.

Igor Tandetnik


  __
Make your browsing faster, safer, and easier with the new Internet Explorer® 8. 
Optimized for Yahoo! Get it Now for Free! at 
http://downloads.yahoo.com/ca/internetexplorer/
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] 1 reader 1 writer but sqlite3_step fails wit h “database is locked” error in both processes

2010-02-14 Thread a1rex
Thank you Igor! Now I understand your OR!



- Original Message 
From: Igor Tandetnik 
To: sqlite-users@sqlite.org
Sent: Sun, February 14, 2010 2:54:35 PM
Subject: Re: [sqlite] 1 reader 1 writer but sqlite3_step fails with “database 
is locked”  error in both processes

a1rex wrote:
>  I thought that I can have 1 writer and many readers 

You thought incorrectly. You can have one writer OR many readers.

Igor Tandetnik

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



  __
Looking for the perfect gift? Give the gift of Flickr! 

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


Re: [sqlite] 1 reader 1 writer but sqlite3_step fails wit h “database is locked” error in both processes

2010-02-14 Thread a1rex
Then why sqlite3_step() fails for the reader and for the writer?



- Original Message 
From: Igor Tandetnik 
To: sqlite-users@sqlite.org
Sent: Sun, February 14, 2010 2:54:35 PM
Subject: Re: [sqlite] 1 reader 1 writer but sqlite3_step fails with “database 
is locked”  error in both processes

a1rex wrote:
>  I thought that I can have 1 writer and many readers 

You thought incorrectly. You can have one writer OR many readers.

Igor Tandetnik

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



  __
Make your browsing faster, safer, and easier with the new Internet Explorer® 8. 
Optimized for Yahoo! Get it Now for Free! at 
http://downloads.yahoo.com/ca/internetexplorer/
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] 1 reader 1 writer but sqlite3_step fails wit h “database is locked” error in both processes

2010-02-14 Thread a1rex
Process A updates data base table in the tight loop. Nothing special:

loop
 sql = "UPDATE table SET blob=:blob WHERE id=?"; 
 rc = sqlite3_prepare_v2(…)
 rc = sqlite3_bind_int(…)
 sqlite3_bind_blob(…)
 rc = sqlite3_step(…) 
 rc = sqlite3_reset(…) 
rc = sqlite3_finalize(…);

Process B just reads from
the same table. 
 
Loop
{
sql = "SELECT * from table";
sqlite3_prepare_v2(…);
loop with 
rc = sqlite3_step(…);
 
rc = sqlite3_finalize(…);
}
 
The problem which I encounter is as follows:
 
== In process A ==
sqlite3_step() and sqlite3_reset(…) fail frequently with the error nr 5 = 
“database is locked”.

== In process B ==
sqlite3_step(…) and sqlite3_finalize(…) fail with the same error “database is 
locked”.
 
  I thought that I can have 1 writer and many readers 
 
Unfortunately it appears that even 1 reader can interfere with the writer. And 
the reader fails too.
The OS is Win XP Pro.
 
What don’t I understand here?  
 
Thank you,
Samuel 


  __
Ask a question on any topic and get answers from real people. Go to Yahoo! 
Answers and share what you know at http://ca.answers.yahoo.com
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users