[sqlite] C API reference manpages

2016-03-31 Thread Matthias-Christian Ott
On 31/03/16 14:39, Kristaps Dzonsons wrote:
>>> Is there any interest in integrating this tool to have manpages in the
>>> doc distribution without downstream bits?
>>
>> I think that would be cool.  Integrating your tool into the source
>> tree would mean that as the comment formats evolve, your tool would
>> evolve in lock-step.  If your tool is kept separate, then we might
>> change the documentation comment format without telling you, and break
>> things.
>>
>> One issue is the license.  SQLite is public domain, not BSD (or ISC).
>> Is it even possible for citizens of Latvia to release something to the
>> public domain?  In any event, some paperwork would have to flow
>> between us to make that happen.  Though, maybe that is not a huge
>> concern as we are not nearly as persnickety with licensing for the
>> documentation as we are with the code, and this tool would go in the
>> separate documentation repository
>> (https://www.sqlite.org/docsrc/timeline), not in the main code
>> repository.
>>
>> Would an even better solution be to enhance the capi3ref TCL script to
>> spit out mdoc files in parallel to the HTML documentation it currently
>> produces?
> 
> Richard,
> 
> As for public domain, I'm happy to put the sources under a similar
> license.  I can't speak for the voodoo of the public domain and the EU
> (or is it country-by-country?), however.

>From an English translation I found of the Latvian law includes moral
rights and is closer to the droit d'auteur than copyright. So it seems
difficult to place your work in the public domain.

I would advise you to contact the FSF, FSFE Legal or SFLC in this matter
if you want a general advice without legal fees. This entire topic as
been discussed in context of Wikimedia's projects, especially Wikipedia
and Wikimedia Commons, and CC0, so you might find information about
Latvia there.

- Matthias-Christian


[sqlite] Calling some predefined SQL function from another custom SQL function?

2016-03-31 Thread Keith Medcalf


> > Le 31 mars 2016 ? 13:32, Keith Medcalf  a ?crit :
> >
> > On the third hand, this could be a case of premature optimization and
> the optimal course of action is not to optimize the action before doing
> it, but as Nike says, "Just Do It".
> 
> I agree on the generic point, though here the desire to call another
> existing function from the implementation of a new one is merely a 'code
> reuse' point of view (not to re-invent/re-code things perfectly already
> implemented).  :)

You can call strftime just perfectly dandily and reuse that code, which exists 
in the platform runtime libraries.  Now if you had to re-implement strftime, I 
could see your point.  But you aren't.  You are just setting up some parameters 
and calling it.


> > Le 31 mars 2016 ? 14:09, Hick Gunter  a ?crit :
> >
> > While it is technically possible to convincingly fake an SQLite context
> to call strftimeFunc() with, it also means that you are ignoring SQLite
> function overloading. And making yourself dependant on internal changes to
> SQLite structures that are opaque for a reason.
> 
> I never intended to hack the code, make strftimeFunc() non static to call
> it from elsewhere (out of sqlite code). My question was: is there a
> supported API function (a single one would be enough), to relay a call to
> the internal implementation of some function.
> 
> 
> Consider this theoretical case: in an application (not in a custom build
> of sqlite itself) I'd want to implement a function "date(...)",
> overloading/replacing the default date(). That is easy to do, and works
> fine. Now suppose I only have to check for some parameters not handled by
> the default date(), build a new set of parameters (standard looking after
> whatever conversion / preparation I had to do), call the original date()
> function (same context), get its result and forward it to my caller.
> 
> I can't.  I can't call the initial implementation (or even the previously
> stacked one - if there was a stacking which I'm not sure).  And I can't
> really built a SQL statement and execute it: if I'm using date() function
> in the SQL statement, chances are that statement will call *my* version
> which is current and not the initial implementation.
> 
> Note that I did simplify the problem I was trying to solve and reduced it
> to calls of date() taking a single parameter. Simply registering a new
> function date() taking a single parameter works fine. Calls with a single
> parameter call my implementation and calls with none or 2 or more
> parameters call the original default implementation. In this case, I have
> the solution. The real problem at hand was simpler than the generalization
> I posted about.
> 
> There is no bug, or problem to solve in SQLite here.  Just maybe a single
> C-API function to consider for addition at some point in the future.
> 
> Thanks you all,
> --
> Meilleures salutations, Met vriendelijke groeten, Best Regards,
> Olivier Mascia, integral.be/om
> 
> 
> Context, initial post:
> 
> > Le 30 mars 2016 ? 20:04, Olivier Mascia  a ?crit :
> >
> > Hello,
> >
> > Writing a scalar SQL function, is there a C-level way to call some other
> scalar SQL function?
> > For instance, writing some specialized date_xyz(), could it be possible
> to prepare some arguments and call strftime()?
> >
> > I see in the code that strftimeFunc() is the implementation for the
> predefined strftime(), and I see no huge difficulty calling it from my own
> function, but of course it is internal (static). Did I miss something in
> the API that would let me get a hand on it? Something like some
> 'sqlite3_call_function(...)' which would take the function name as text
> and let me hand it the context, count of arguments, array of them, and
> return me somehow a sqlite_value with the result?
> >
> > I think it is obvious I could build a SQL statement from within the
> function and execute it. But it sounds costly to involve the parser (yes,
> it's fast) for that, isn't it?
> >
> > --
> > Meilleures salutations, Met vriendelijke groeten, Best Regards,
> > Olivier Mascia, integral.be/om
> 
> 
> ___
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users





[sqlite] C API reference manpages

2016-03-31 Thread Kristaps Dzonsons
>> Is there any interest in integrating this tool to have manpages in the
>> doc distribution without downstream bits?
> 
> I think that would be cool.  Integrating your tool into the source
> tree would mean that as the comment formats evolve, your tool would
> evolve in lock-step.  If your tool is kept separate, then we might
> change the documentation comment format without telling you, and break
> things.
> 
> One issue is the license.  SQLite is public domain, not BSD (or ISC).
> Is it even possible for citizens of Latvia to release something to the
> public domain?  In any event, some paperwork would have to flow
> between us to make that happen.  Though, maybe that is not a huge
> concern as we are not nearly as persnickety with licensing for the
> documentation as we are with the code, and this tool would go in the
> separate documentation repository
> (https://www.sqlite.org/docsrc/timeline), not in the main code
> repository.
> 
> Would an even better solution be to enhance the capi3ref TCL script to
> spit out mdoc files in parallel to the HTML documentation it currently
> produces?

Richard,

As for public domain, I'm happy to put the sources under a similar
license.  I can't speak for the voodoo of the public domain and the EU
(or is it country-by-country?), however.

As for Tcl--I don't grok it myself or I'd have started modifying there.
 (I used capi3ref as a starting point.)  Be it C or Tcl, there's a lot
of string fiddling to get everything formatted for mdoc(7) (and to
collect refs), so it won't be pretty (or brief) in any language.

I'm happy maintaining the tool in or out of the tree--whatever's most
convenient.  I figured I'd just track changes to sqlite.h.in and update
the scanner if it was required.  (E.g. and in the most likely case: more
HTML tags.)  At the end of the day, I just want to use apropos and man
instead of the browser!

Best,

Kristaps

-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 842 bytes
Desc: OpenPGP digital signature
URL: 
<http://mailinglists.sqlite.org/cgi-bin/mailman/private/sqlite-users/attachments/20160331/79038d8e/attachment.pgp>


[sqlite] Calling some predefined SQL function from another custom SQL function?

2016-03-31 Thread Clemens Ladisch
Olivier Mascia wrote:
>> Le 31 mars 2016 ? 11:03, Clemens Ladisch  a ?crit :
>>> I think it is obvious I could build a SQL statement from within the
>>> function and execute it. But it sounds costly to involve the parser
>>> (yes, it's fast) for that, isn't it?
>>
>> You can prepare the statement beforehand.
>
> Not really. Preparing the statement involves the connection object
> which won't be known before function call.

The call to sqlite3_create_function() already involved the connection
object.


Regards,
Clemens


[sqlite] Calling some predefined SQL function from another custom SQL function?

2016-03-31 Thread Olivier Mascia
Hi,

> Le 31 mars 2016 ? 11:03, Clemens Ladisch  a ?crit :
> 
>> I think it is obvious I could build a SQL statement from within the
>> function and execute it. But it sounds costly to involve the parser
>> (yes, it's fast) for that, isn't it?
> 
> You can prepare the statement beforehand.

Not really. Preparing the statement involves the connection object which won't 
be known before function call. So preparation has to be done dynamically.  Did 
I really miss something here?


> Le 31 mars 2016 ? 13:32, Keith Medcalf  a ?crit :
> 
> On the third hand, this could be a case of premature optimization and the 
> optimal course of action is not to optimize the action before doing it, but 
> as Nike says, "Just Do It".

I agree on the generic point, though here the desire to call another existing 
function from the implementation of a new one is merely a 'code reuse' point of 
view (not to re-invent/re-code things perfectly already implemented).  :)


> Le 31 mars 2016 ? 14:09, Hick Gunter  a ?crit :
> 
> While it is technically possible to convincingly fake an SQLite context to 
> call strftimeFunc() with, it also means that you are ignoring SQLite function 
> overloading. And making yourself dependant on internal changes to SQLite 
> structures that are opaque for a reason.

I never intended to hack the code, make strftimeFunc() non static to call it 
from elsewhere (out of sqlite code). My question was: is there a supported API 
function (a single one would be enough), to relay a call to the internal 
implementation of some function.


Consider this theoretical case: in an application (not in a custom build of 
sqlite itself) I'd want to implement a function "date(...)", 
overloading/replacing the default date(). That is easy to do, and works fine. 
Now suppose I only have to check for some parameters not handled by the default 
date(), build a new set of parameters (standard looking after whatever 
conversion / preparation I had to do), call the original date() function (same 
context), get its result and forward it to my caller.

I can't.  I can't call the initial implementation (or even the previously 
stacked one - if there was a stacking which I'm not sure).  And I can't really 
built a SQL statement and execute it: if I'm using date() function in the SQL 
statement, chances are that statement will call *my* version which is current 
and not the initial implementation.

Note that I did simplify the problem I was trying to solve and reduced it to 
calls of date() taking a single parameter. Simply registering a new function 
date() taking a single parameter works fine. Calls with a single parameter call 
my implementation and calls with none or 2 or more parameters call the original 
default implementation. In this case, I have the solution. The real problem at 
hand was simpler than the generalization I posted about.

There is no bug, or problem to solve in SQLite here.  Just maybe a single C-API 
function to consider for addition at some point in the future.

Thanks you all,
-- 
Meilleures salutations, Met vriendelijke groeten, Best Regards,
Olivier Mascia, integral.be/om


Context, initial post:

> Le 30 mars 2016 ? 20:04, Olivier Mascia  a ?crit :
> 
> Hello,
> 
> Writing a scalar SQL function, is there a C-level way to call some other 
> scalar SQL function?
> For instance, writing some specialized date_xyz(), could it be possible to 
> prepare some arguments and call strftime()?
> 
> I see in the code that strftimeFunc() is the implementation for the 
> predefined strftime(), and I see no huge difficulty calling it from my own 
> function, but of course it is internal (static). Did I miss something in the 
> API that would let me get a hand on it? Something like some 
> 'sqlite3_call_function(...)' which would take the function name as text and 
> let me hand it the context, count of arguments, array of them, and return me 
> somehow a sqlite_value with the result?
> 
> I think it is obvious I could build a SQL statement from within the function 
> and execute it. But it sounds costly to involve the parser (yes, it's fast) 
> for that, isn't it?
> 
> -- 
> Meilleures salutations, Met vriendelijke groeten, Best Regards,
> Olivier Mascia, integral.be/om




[sqlite] C API reference manpages

2016-03-31 Thread Kristaps Dzonsons
Hello,

I couldn't find any way to convert the SQLite docs (via sqlite.h) to
UNIX manpages, so I wrote a tool that does so:

 https://github.com/kristapsdz/sqlite2mdoc

This generates one manpage per API reference with the proper SEE ALSO
(from collected references) and IMPLEMENTATION NOTES (the raw
declarations and preprocessor statements).  Its deficiencies are in
handling HTML tables (prints verbatim--not bad except for sqlite3_open,
where the table is quite wide), the mdoc(7) isn't picture-perfect, and
in handling some un-closed markup seen here and there.

It follows the logic of the Tcl code in capi3ref[2], but does so in C
w/o dependencies unless running Linux.

Is there any interest in integrating this tool to have manpages in the
doc distribution without downstream bits?

I've been using this for a while as part of the manpage corpus on my
OpenBSD, Mac OS X, and Linux machines.

Best,

Kristaps

[1] http://man.openbsd.org/OpenBSD-current/man7/mdoc.7
[2] https://www.sqlite.org/cgi/docsrc/finfo?name=pages/capi3ref.in


[sqlite] Calling some predefined SQL function from another custom SQL function?

2016-03-31 Thread Hick Gunter
While it is technically possible to convincingly fake an SQLite context to call 
strftimeFunc() with, it also means that you are ignoring SQLite function 
overloading. And making yourself dependant on internal changes to SQLite 
structures that are opaque for a reason.

-Urspr?ngliche Nachricht-
Von: sqlite-users-bounces at mailinglists.sqlite.org 
[mailto:sqlite-users-bounces at mailinglists.sqlite.org] Im Auftrag von Olivier 
Mascia
Gesendet: Mittwoch, 30. M?rz 2016 20:05
An: SQLite mailing list
Betreff: [sqlite] Calling some predefined SQL function from another custom SQL 
function?

Hello,

Writing a scalar SQL function, is there a C-level way to call some other scalar 
SQL function?
For instance, writing some specialized date_xyz(), could it be possible to 
prepare some arguments and call strftime()?

I see in the code that strftimeFunc() is the implementation for the predefined 
strftime(), and I see no huge difficulty calling it from my own function, but 
of course it is internal (static). Did I miss something in the API that would 
let me get a hand on it? Something like some 'sqlite3_call_function(...)' which 
would take the function name as text and let me hand it the context, count of 
arguments, array of them, and return me somehow a sqlite_value with the result?

I think it is obvious I could build a SQL statement from within the function 
and execute it. But it sounds costly to involve the parser (yes, it's fast) for 
that, isn't it?

--
Meilleures salutations, Met vriendelijke groeten, Best Regards, Olivier Mascia, 
integral.be/om


___
sqlite-users mailing list
sqlite-users at mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


___
 Gunter Hick
Software Engineer
Scientific Games International GmbH
FN 157284 a, HG Wien
Klitschgasse 2-4, A-1130 Vienna, Austria
Tel: +43 1 80100 0
E-Mail: hick at scigames.at

This communication (including any attachments) is intended for the use of the 
intended recipient(s) only and may contain information that is confidential, 
privileged or legally protected. Any unauthorized use or dissemination of this 
communication is strictly prohibited. If you have received this communication 
in error, please immediately notify the sender by return e-mail message and 
delete all copies of the original communication. Thank you for your cooperation.




[sqlite] Calling some predefined SQL function from another custom SQL function?

2016-03-31 Thread Clemens Ladisch
Olivier Mascia wrote:
> Writing a scalar SQL function, is there a C-level way to call some
> other scalar SQL function?

The only way is to build an SQL statement from within the function and
execute it.

> I think it is obvious I could build a SQL statement from within the
> function and execute it. But it sounds costly to involve the parser
> (yes, it's fast) for that, isn't it?

You can prepare the statement beforehand.


Regards,
Clemens


[sqlite] Understanding table and database locking mechanism inshared cache mode and normal mode

2016-03-31 Thread Domingo Alvarez Duarte
Hello !  

You can check the behavior of sqlite3 in a multi thread environment with this
program:  

https://gist.github.com/mingodad/79225c88f8dce0f174f5  

I did it to test how fast sqlite3 can be on a system (cpu/memory/threads) and
with it you can from the command line change the following parameters:  

data_size=256
num_threads=2
use_wal=1
use_synchronous=0
busy_retry=200
busy_retry_useconds=10
start_loop_useconds=0
mid_loop_useconds=0
use_memory_db=0  

And you'll get an output like this:  

Update rate: total=458547, last_total=423241, rate=35306, avg1=17653,
avg2=38212
Update busy rate: total=124, last_total=113, rate=11, avg1=5, avg2=10
Update failed rate: total=0, last_total=0, rate=0, avg1=0, avg2=0
Read busy rate: total=0, last_total=0, rate=0, avg1=0, avg2=0
Read failed rate: total=0, last_total=0, rate=0, avg1=0, avg2=0  

Where :  

Update rate = How many updates are done per second  

Update busy rate = How many times sqlite returned SQLITE_BUSY
(busy_retry_useconds)  

Update failed rate = How many times we've failed our timeout (busy_retry *
busy_retry_useconds)  

Read busy rate = Same as "Update busy rate" but for reads  

Read failed rate = Same as "Update failed rate" but for reads  

? - total = cumulative total from the beginning of the program execution  

? - last_total = the previous total  

? - rate = number of operations in the last second  

? - avg1 = average of operations by thread on the last second  

? - avg2 = average of operations by second since the begining of the program
execution  

?  

I hope it can help you and others to understand/tune sqlite for a specific
use case.  

Cheers !



[sqlite] C API reference manpages

2016-03-31 Thread Richard Hipp
On 3/31/16, Kristaps Dzonsons  wrote:
>
> Is there any interest in integrating this tool to have manpages in the
> doc distribution without downstream bits?
>

I think that would be cool.  Integrating your tool into the source
tree would mean that as the comment formats evolve, your tool would
evolve in lock-step.  If your tool is kept separate, then we might
change the documentation comment format without telling you, and break
things.

One issue is the license.  SQLite is public domain, not BSD (or ISC).
Is it even possible for citizens of Latvia to release something to the
public domain?  In any event, some paperwork would have to flow
between us to make that happen.  Though, maybe that is not a huge
concern as we are not nearly as persnickety with licensing for the
documentation as we are with the code, and this tool would go in the
separate documentation repository
(https://www.sqlite.org/docsrc/timeline), not in the main code
repository.

Would an even better solution be to enhance the capi3ref TCL script to
spit out mdoc files in parallel to the HTML documentation it currently
produces?

-- 
D. Richard Hipp
drh at sqlite.org


[sqlite] Note, using SQLAR compared to TGZ archive

2016-03-31 Thread Kevin
Thanks Richard,

I first saw a reference from the mailing list back in May 2014. I've
been reading the list since April 2010.

I'm not much of a C programmer, but I will let you know. 

I'm working on adding "comments" or tags to accompany the filenames. For
example, the file
"/mnt/KCYPictures/Pictures/Amys_tablet/Camera/20130727_204615.jpg" is a
picture of my daughter with he grandmother.

So, if I wanted to see files related to my daughter or her grandmother
or both together, a simple SQL query would help.

I was also interested in the concept of adding and removing files
incrementally, without having to read in an entire archive and the
rewriting the entire archive.

The application which precedes the archive function is where I take a
Linux LS listing and convert it into an SQLite database. I also add
"comments" and MD5SUMs of the files. 

I then compare the current LS SQLite database with a previous one. I
generate new MD5SUMs for new and modified files, and carry forward
comments and MD5SUMs for the unchanged files. The MD5SUMs tell me when a
file has a different name, different date or has moved folders.

I will then add the new and overwrite the modified files in the SQLAR
archive.



regs,

Kev




On 3/29/16, Kevin  wrote:
> Richard,
>
> Just a note of thanks for the SQLAR tool.

I'm glad you find it useful.  Really is it just a proof-of-concept.
If you are a C programmer and would like to try to enhance it, write
to me and I'll get you check-in privileges on the respository.

So where did you hear about SQLAR?

-- 
D. Richard Hipp
drh at sqlite.org



[sqlite] Calling some predefined SQL function from another custom SQL function?

2016-03-31 Thread Scott Hess
On Thu, Mar 31, 2016 at 6:39 AM, Olivier Mascia  wrote:

> > Le 31 mars 2016 ? 11:03, Clemens Ladisch  a ?crit :
> >> I think it is obvious I could build a SQL statement from within the
> >> function and execute it. But it sounds costly to involve the parser
> >> (yes, it's fast) for that, isn't it?
> >
> > You can prepare the statement beforehand.
>
> Not really. Preparing the statement involves the connection object which
> won't be known before function call. So preparation has to be done
> dynamically.  Did I really miss something here?


Put your function's persistent storage in the void*pApp passed to
sqlite3_create_function(), then get it back using sqlite3_user_data(ctx).
If the user_data is per-db, then you can have per-db state in there.

-scott


[sqlite] Calling some predefined SQL function from another custom SQL function?

2016-03-31 Thread Keith Medcalf

On the third hand, this could be a case of premature optimization and the 
optimal course of action is not to optimize the action before doing it, but as 
Nike says, "Just Do It".

> -Original Message-
> From: sqlite-users-bounces at mailinglists.sqlite.org [mailto:sqlite-users-
> bounces at mailinglists.sqlite.org] On Behalf Of Clemens Ladisch
> Sent: Thursday, 31 March, 2016 03:04
> To: SQLite mailing list
> Subject: Re: [sqlite] Calling some predefined SQL function from another
> custom SQL function?
> 
> Olivier Mascia wrote:
> > Writing a scalar SQL function, is there a C-level way to call some
> > other scalar SQL function?
> 
> The only way is to build an SQL statement from within the function and
> execute it.
> 
> > I think it is obvious I could build a SQL statement from within the
> > function and execute it. But it sounds costly to involve the parser
> > (yes, it's fast) for that, isn't it?
> 
> You can prepare the statement beforehand.
> 
> 
> Regards,
> Clemens
> ___
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users





[sqlite] Understanding table and database locking mechanism in shared cache mode and normal mode

2016-03-31 Thread Simon Slavin

On 31 Mar 2016, at 12:06am, Srikanth Bemineni  
wrote:
> 
> In this case a new connection is
> being given to a thread in shared cache mode to the database. If one of the
> thread gets a SQLITE_LOCKED status for statement execution, we use try
> again after some time assuming the other thread holding the lock would have
> either failed or committed the transaction.
> 
> Recently we moved to our connection type from shared cache to normal mode,
> to see if there is any significant improvement in performance as suggested
> by team member. Right now we have multiple database connections to same
> database. We started to see lot of SQLITE_LOCKED hangs.

In both modes (whether you're using 'shared cache' or not) use either

https://www.sqlite.org/c3ref/busy_timeout.html

or

https://www.sqlite.org/pragma.html#pragma_busy_timeout

to set a timeout of a minute (really.  a minute).  See if that sorts out your 
problem.  If you do this you do not need any retry mechanism in your own code: 
If SQLite returned _BUSY or _LOCKED then it has already done the retrying you 
told it to do.

> 1. Does a transaction lock ,will lock the table or the whole data base
> connection.?

All locks in SQLite are for the whole database.

> 2. What is the major difference in locking when compared to shared cache
> mode. ?

Sharing the cache is sharing the lock.  In other words two connections sharing 
a cache are not able to lock each other out.

For a detailed description (which you don't really need at this time) see



Simon.


[sqlite] Understanding table and database locking mechanism in shared cache mode and normal mode

2016-03-31 Thread Srikanth Bemineni
Hi

In shared cache mode the locking seems to be per table level basis. Which
seems to not block my operations on the other tables in the same database.
When there are multiple connections, any transaction is going to create a
data base level lock, which may result in  many write as well as read
starvation threads.

2.2 Table Level Locking

When two or more connections use a shared-cache, locks are used to
serialize concurrent access attempts on a per-table basis. Tables support
two types of locks, "read-locks" and "write-locks". Locks are granted to
connections - at any one time, each database connection has either a
read-lock, write-lock or no lock on each database table.

At any one time, a single table may have any number of active read-locks or
a single active write lock. To read data a table, a connection must first
obtain a read-lock. To write to a table, a connection must obtain a
write-lock on that table. If a required table lock cannot be obtained, the
query fails and SQLITE_LOCKED is returned to the caller.

Once a connection obtains a table lock, it is not released until the
current transaction (read or write) is concluded.


On Wed, Mar 30, 2016 at 11:19 PM, Srikanth Bemineni <
bemineni.srikanth at gmail.com> wrote:

> Hi,
>
> if( (lastStatus == SQLITE_OK) && mystatement)
> {
> m_lastStatus = sqlite3_step(mp_statement);
> while( lastStatus == SQLITE_LOCKED  || lastStatus == SQLITE_BUSY)
> {
>
>sleep(randomtime)
>lastStatus = sqlite3_step(mp_statement);
> }
> }
>
>
> My common execute for all the my thread is some what like this. In shared
> cache mode I used always end up with SQLITE_LOCKED as Roger Binns
> mentioned. Now I end up with an hanging SQLITE_BUSY. Is there some kind of
> a dead lock situation between threads that can cause this in normal mode.
>
> I did change all my transaction with BEGIN IMMEDIATE to get a lock for the
> each thread, so that my write and updates finish.
>
> Srikanth
>
>
> On Wed, Mar 30, 2016 at 8:02 PM, Roger Binns 
> wrote:
>
>> -BEGIN PGP SIGNED MESSAGE-
>> Hash: SHA1
>>
>> On 30/03/16 16:58, Simon Slavin wrote:
>> > In both modes (whether you're using 'shared cache' or not) use
>> > either
>> >
>> > https://www.sqlite.org/c3ref/busy_timeout.html
>>
>> The last time I dealt with shared cache mode, the busy timeout did not
>> apply.  You had to manually manage the timeout/retries yourself.  This
>> is by design:
>>
>> https://sqlite.org/src/tktview/ebde3f66fc64e21e61ef2854ed1a36dfff884a2f
>>
>> In the APSW doc I recommend against using shared cache mode, as it
>> doesn't have any benefits except for very small memory systems.
>>
>> Roger
>>
>> -BEGIN PGP SIGNATURE-
>> Version: GnuPG v2
>>
>> iEYEARECAAYFAlb8dyEACgkQmOOfHg372QQhhQCbBoKrBu40ZgroyJOPB8WVy4To
>> hcsAn0f8rx1h+foMBH0r4YVYo3pmc9Nc
>> =lNHi
>> -END PGP SIGNATURE-
>> ___
>> sqlite-users mailing list
>> sqlite-users at mailinglists.sqlite.org
>> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>>
>
>


[sqlite] Understanding table and database locking mechanism in shared cache mode and normal mode

2016-03-31 Thread Srikanth Bemineni
Hi,

if( (lastStatus == SQLITE_OK) && mystatement)
{
m_lastStatus = sqlite3_step(mp_statement);
while( lastStatus == SQLITE_LOCKED  || lastStatus == SQLITE_BUSY)
{

   sleep(randomtime)
   lastStatus = sqlite3_step(mp_statement);
}
}


My common execute for all the my thread is some what like this. In shared
cache mode I used always end up with SQLITE_LOCKED as Roger Binns
mentioned. Now I end up with an hanging SQLITE_BUSY. Is there some kind of
a dead lock situation between threads that can cause this in normal mode.

I did change all my transaction with BEGIN IMMEDIATE to get a lock for the
each thread, so that my write and updates finish.

Srikanth


On Wed, Mar 30, 2016 at 8:02 PM, Roger Binns  wrote:

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> On 30/03/16 16:58, Simon Slavin wrote:
> > In both modes (whether you're using 'shared cache' or not) use
> > either
> >
> > https://www.sqlite.org/c3ref/busy_timeout.html
>
> The last time I dealt with shared cache mode, the busy timeout did not
> apply.  You had to manually manage the timeout/retries yourself.  This
> is by design:
>
> https://sqlite.org/src/tktview/ebde3f66fc64e21e61ef2854ed1a36dfff884a2f
>
> In the APSW doc I recommend against using shared cache mode, as it
> doesn't have any benefits except for very small memory systems.
>
> Roger
>
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v2
>
> iEYEARECAAYFAlb8dyEACgkQmOOfHg372QQhhQCbBoKrBu40ZgroyJOPB8WVy4To
> hcsAn0f8rx1h+foMBH0r4YVYo3pmc9Nc
> =lNHi
> -END PGP SIGNATURE-
> ___
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>