No.  It is not correct.  Have you read the documentation?

https://sqlite.org/rescode.html#locked

Multiple threads cannot perform operations at the same time on the same 
connection.  This is verboten.  Forbidden.  Does not work.  Will cause 
explosions and death of children.  Do not do it.  Ever.  Period.  End of Line.

"The SQLITE_LOCKED result code differs from SQLITE_BUSY in that SQLITE_LOCKED 
indicates a conflict on the same database connection (or on a connection with a 
shared cache) whereas SQLITE_BUSY indicates a conflict with a different 
database connection"

So if you do something like this:

open database using connection1
on connection1 SELECT * FROM DATA
while got some rows:
  on connection1 DROP TABLE DATA

the DROP TABLE DATA will get a SQLITE_LOCKED because it cannot delete the table 
DATA because it is being read ON THE SAME CONNECTION.

conversely if you do something like this:

open database using connection1
open database using connection2
on connection1 SELECT * FROM DATA
while got some rows:
  on connection2 DROP TABLE DATA

the DROP TABLE DATA will get a SQLITE_BUSY because it cannot delete the table 
DATA because it is being read ON A DIFFERENT CONNECTION.

"threads" have nothing to do with anything whatsoever except that if you make 
any sqlite3_x call simultaneously using THE SAME CONNECTION (or something 
derived from the same connection, like a cursor) then the universe will explode 
and children will die!  Do not do that.  Ever.

NB:  different "connections" to the same "shared cache" are really the "same 
connection" ... for the purposes of the SQLITE_LOCKED / SQLITE_BUSY and 
different connections for the purposes of the universe exploding and children 
dying.

---
The fact that there's a Highway to Hell but only a Stairway to Heaven says a 
lot about anticipated traffic volume.


>-----Original Message-----
>From: sqlite-users [mailto:sqlite-users-
>boun...@mailinglists.sqlite.org] On Behalf Of Prajeesh Prakash
>Sent: Wednesday, 28 November, 2018 08:36
>To: SQLite mailing list
>Subject: [sqlite] SQLITE_LOCKED and SQLITE_BUSY
>
>Hi members,
>
>The SQLITE_LOCKED error will happen on same database connection when
>two thread trying to do read/write operation at same time.
>SQLITE_BUSY will get when one thread on one connection is doing
>read/write operation and another thread on another connection trying
>to read/write the DB. Is it correct?
>
>
>Thank you
>_______________________________________________
>sqlite-users mailing list
>sqlite-users@mailinglists.sqlite.org
>http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users



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

Reply via email to