Re: [sqlite] Re: Changing Schema On The Fly

2007-06-01 Thread Joe Wilson
--- Mitchell Vincent <[EMAIL PROTECTED]> wrote:
> I guess this isn't possible after all?

Get the SQLite ODBC driver source code and alter it to do whatever 
you like when the type "timestamp" column comes up.

> On 5/31/07, Mitchell Vincent <[EMAIL PROTECTED]> wrote:
> > I have a set of databases that contain a date type called "timestamp".
> > I need to make those "integer" so they come through the ODBC driver
> > the right way. Is there any way to change all of that through queries
> > on-the-fly? I'd like to avoid re-creating all the databases if
> > possible..



  
___
You snooze, you lose. Get messages ASAP with AutoCheck
in the all-new Yahoo! Mail Beta.
http://advision.webevents.yahoo.com/mailbeta/newmail_html.html

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



[sqlite] Re: Changing Schema On The Fly

2007-06-01 Thread Mitchell Vincent

I guess this isn't possible after all?

On 5/31/07, Mitchell Vincent <[EMAIL PROTECTED]> wrote:

I have a set of databases that contain a date type called "timestamp".
I need to make those "integer" so they come through the ODBC driver
the right way. Is there any way to change all of that through queries
on-the-fly? I'd like to avoid re-creating all the databases if
possible..

Thanks!



--
- Mitchell Vincent
- K Software - Innovative Software Solutions
- Visit our website and check out our great software!
- http://www.ksoftware.net

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



RE: [sqlite] Age calculation on literal

2007-06-01 Thread RB Smissaert
Got the syntax right, but not the logic.
I believe this (VB) function will now get the right SQL to get the age in
months:

Function ISO8601Date2AgeInMonths(strField As String, _
 Optional strAlias As String) As String

  Dim strAS As String

  If Len(strAlias) > 0 Then
strAS = " AS "
  End If

  ISO8601Date2AgeInMonths = "case when date('now') >= " & _
"date(" & strField & ", '+' || (strftime('%Y',
'now') - " & _
"strftime('%Y', " & strField & ")) || ' years')
then " & _
"case when strftime('%d', 'now') <
strftime('%d', " & strField & ") then " & _
"((strftime('%Y', 'now') - strftime('%Y', " &
strField & ")) * 12 + " & _
"(strftime('%m', 'now') - strftime('%m', " &
strField & "))) - 1 " & _
"else " & _
"((strftime('%Y', 'now') - strftime('%Y', " &
strField & ")) * 12 + " & _
"(strftime('%m', 'now') - strftime('%m', " &
strField & "))) - 0 " & _
"end " & _
"else " & _
"case when " & _
"strftime('%d', 'now') < strftime('%d', " &
strField & ") " & _
"then " & _
"(strftime('%Y', 'now') - strftime('%Y', " &
strField & ") - 1) * 12 + " & _
"(strftime('%m', 'now') + (12 - strftime('%m', "
& strField & "))) - 1 " & _
"else " & _
"((strftime('%Y', 'now') - strftime('%Y', " &
strField & ") - 1) * 12 + " & _
"(strftime('%m', 'now') + (12 - strftime('%m', "
& strField & " - 0 " & _
"End " & _
"End" & strAS & strAlias

End Function


RBS


-Original Message-
From: RB Smissaert [mailto:[EMAIL PROTECTED] 
Sent: 01 June 2007 21:46
To: sqlite-users@sqlite.org
Subject: RE: [sqlite] Age calculation on literal

Got this now, after correcting the brackets:

SELECT
case when
date('2006-10-14', '+' || (strftime('%Y', 'now') - strftime('%Y', '2006-
10-14')) || ' years') <= date('now') then
case when
strftime('%d', 'now') > strftime('%d', '2006-10-14')
then
((strftime('%Y', 'now') - strftime('%Y', '2006-10-14')) * 12 +
(strftime('%m', 'now') - strftime('%m', '2006-10-14'))) - 1 
else 
(strftime('%Y', 'now') - strftime('%Y', '2006-10-14')) * 12 +
(strftime('%m', 'now') - strftime('%m', '2006-10-14'))
end 
else 
case when
strftime('%d', 'now') > strftime('%d', '2006-10-14')
then
(strftime('%Y', 'now') - strftime('%Y', '2006-10-14') - 1) * 12 +
(strftime('%m', 'now') +
(12 - strftime('%m', '2006-10-14'))) - 1 
else 
(strftime('%Y', 'now') - strftime('%Y', '2006-10-14') - 1) * 12 +
(strftime('%m', 'now') + (12 - strftime('%m', '2006-10-14')))
end
end


RBS


-Original Message-
From: Dennis Cote [mailto:[EMAIL PROTECTED] 
Sent: 01 June 2007 19:53
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] Age calculation on literal

On 6/1/07, RB Smissaert <[EMAIL PROTECTED]> wrote:
>
> Got this nearly worked out now, but somehow I can't get the nested case
> when
> syntax right:
>
> SELECT
> case
> when
> date('2006-10-14', '+' || (strftime('%Y', 'now') - strftime('%Y',
> '2006-10-14')) || ' years') <= date('now')
> then
> case when
> strftime('%d', 'now') > strftime('%d', '2006-10-14')
> then
> ((strftime('%Y', 'now') - strftime('%Y', '2006-10-14')) * 12 +
> (strftime('%m', 'now') - strftime('%m', '2006-10-14')) - 1
> else
> (strftime('%Y', 'now') - strftime('%Y', '2006-10-14'))) * 12 +



You have an extra closing bracket in the line above.


(strftime('%m', 'now') - strftime('%m', '2006-10-14'))
> end
> else
> case when
> strftime('%d', 'now') > strftime('%d', '2006-10-14')
> then
> ((strftime('%Y', 'now') - strftime('%Y', '2006-10-14') -1)   * 12 +
> (strftime('%m', 'now') +
> (12 - strftime('%m', '2006-10-14' -1
> else
> (strftime('%Y', 'now') - strftime('%Y', '2006-10-14') -1)  * 12 +
> (strftime('%m', 'now') +
> (12 - strftime('%m', '2006-10-14')))
> end
> end
>
> It will give me an error (from my VB wrapper) syntax error near else.
> Any idea what is wrong here?


Try this instead, I find the extra indentation makes it easier to see what
you are doing.

SELECT
case when
date('2006-10-14', '+' || (strftime('%Y', 'now') - strftime('%Y',
'2006-10-14')) || ' years') <= date('now')
then
case when
strftime('%d', 'now') > strftime('%d', '2006-10-14')
then
((strftime('%Y', 'now') - strftime('%Y', '2006-10-14')) * 12 +
(strftime('%m', 'now') - strftime('%m', '2006-10-14')) - 1
else
(strftime('%Y', 'now') - strftime('%Y', '2006-10-14')) * 12 +

RE: [sqlite] Age calculation on literal

2007-06-01 Thread RB Smissaert
Got this now, after correcting the brackets:

SELECT
case when
date('2006-10-14', '+' || (strftime('%Y', 'now') - strftime('%Y', '2006-
10-14')) || ' years') <= date('now') then
case when
strftime('%d', 'now') > strftime('%d', '2006-10-14')
then
((strftime('%Y', 'now') - strftime('%Y', '2006-10-14')) * 12 +
(strftime('%m', 'now') - strftime('%m', '2006-10-14'))) - 1 
else 
(strftime('%Y', 'now') - strftime('%Y', '2006-10-14')) * 12 +
(strftime('%m', 'now') - strftime('%m', '2006-10-14'))
end 
else 
case when
strftime('%d', 'now') > strftime('%d', '2006-10-14')
then
(strftime('%Y', 'now') - strftime('%Y', '2006-10-14') - 1) * 12 +
(strftime('%m', 'now') +
(12 - strftime('%m', '2006-10-14'))) - 1 
else 
(strftime('%Y', 'now') - strftime('%Y', '2006-10-14') - 1) * 12 +
(strftime('%m', 'now') + (12 - strftime('%m', '2006-10-14')))
end
end


RBS


-Original Message-
From: Dennis Cote [mailto:[EMAIL PROTECTED] 
Sent: 01 June 2007 19:53
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] Age calculation on literal

On 6/1/07, RB Smissaert <[EMAIL PROTECTED]> wrote:
>
> Got this nearly worked out now, but somehow I can't get the nested case
> when
> syntax right:
>
> SELECT
> case
> when
> date('2006-10-14', '+' || (strftime('%Y', 'now') - strftime('%Y',
> '2006-10-14')) || ' years') <= date('now')
> then
> case when
> strftime('%d', 'now') > strftime('%d', '2006-10-14')
> then
> ((strftime('%Y', 'now') - strftime('%Y', '2006-10-14')) * 12 +
> (strftime('%m', 'now') - strftime('%m', '2006-10-14')) - 1
> else
> (strftime('%Y', 'now') - strftime('%Y', '2006-10-14'))) * 12 +



You have an extra closing bracket in the line above.


(strftime('%m', 'now') - strftime('%m', '2006-10-14'))
> end
> else
> case when
> strftime('%d', 'now') > strftime('%d', '2006-10-14')
> then
> ((strftime('%Y', 'now') - strftime('%Y', '2006-10-14') -1)   * 12 +
> (strftime('%m', 'now') +
> (12 - strftime('%m', '2006-10-14' -1
> else
> (strftime('%Y', 'now') - strftime('%Y', '2006-10-14') -1)  * 12 +
> (strftime('%m', 'now') +
> (12 - strftime('%m', '2006-10-14')))
> end
> end
>
> It will give me an error (from my VB wrapper) syntax error near else.
> Any idea what is wrong here?


Try this instead, I find the extra indentation makes it easier to see what
you are doing.

SELECT
case when
date('2006-10-14', '+' || (strftime('%Y', 'now') - strftime('%Y',
'2006-10-14')) || ' years') <= date('now')
then
case when
strftime('%d', 'now') > strftime('%d', '2006-10-14')
then
((strftime('%Y', 'now') - strftime('%Y', '2006-10-14')) * 12 +
(strftime('%m', 'now') - strftime('%m', '2006-10-14')) - 1
else
(strftime('%Y', 'now') - strftime('%Y', '2006-10-14')) * 12 +
(strftime('%m', 'now') - strftime('%m', '2006-10-14'))
end
else
case when
strftime('%d', 'now') > strftime('%d', '2006-10-14')
then
(strftime('%Y', 'now') - strftime('%Y', '2006-10-14') - 1) * 12 +
(strftime('%m', 'now') +
(12 - strftime('%m', '2006-10-14' -1
else
(strftime('%Y', 'now') - strftime('%Y', '2006-10-14') - 1) * 12 +
(strftime('%m', 'now') + (12 - strftime('%m', '2006-10-14')))
end
end

HTH
Dennis Cote



-
To unsubscribe, send email to [EMAIL PROTECTED]
-



RE: [sqlite] Age calculation on literal

2007-06-01 Thread RB Smissaert
Yes, that looks better and thanks for that.
Still get the same error though.
I will keep fiddling with it.

RBS


-Original Message-
From: Dennis Cote [mailto:[EMAIL PROTECTED] 
Sent: 01 June 2007 19:53
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] Age calculation on literal

On 6/1/07, RB Smissaert <[EMAIL PROTECTED]> wrote:
>
> Got this nearly worked out now, but somehow I can't get the nested case
> when
> syntax right:
>
> SELECT
> case
> when
> date('2006-10-14', '+' || (strftime('%Y', 'now') - strftime('%Y',
> '2006-10-14')) || ' years') <= date('now')
> then
> case when
> strftime('%d', 'now') > strftime('%d', '2006-10-14')
> then
> ((strftime('%Y', 'now') - strftime('%Y', '2006-10-14')) * 12 +
> (strftime('%m', 'now') - strftime('%m', '2006-10-14')) - 1
> else
> (strftime('%Y', 'now') - strftime('%Y', '2006-10-14'))) * 12 +



You have an extra closing bracket in the line above.


(strftime('%m', 'now') - strftime('%m', '2006-10-14'))
> end
> else
> case when
> strftime('%d', 'now') > strftime('%d', '2006-10-14')
> then
> ((strftime('%Y', 'now') - strftime('%Y', '2006-10-14') -1)   * 12 +
> (strftime('%m', 'now') +
> (12 - strftime('%m', '2006-10-14' -1
> else
> (strftime('%Y', 'now') - strftime('%Y', '2006-10-14') -1)  * 12 +
> (strftime('%m', 'now') +
> (12 - strftime('%m', '2006-10-14')))
> end
> end
>
> It will give me an error (from my VB wrapper) syntax error near else.
> Any idea what is wrong here?


Try this instead, I find the extra indentation makes it easier to see what
you are doing.

SELECT
case when
date('2006-10-14', '+' || (strftime('%Y', 'now') - strftime('%Y',
'2006-10-14')) || ' years') <= date('now')
then
case when
strftime('%d', 'now') > strftime('%d', '2006-10-14')
then
((strftime('%Y', 'now') - strftime('%Y', '2006-10-14')) * 12 +
(strftime('%m', 'now') - strftime('%m', '2006-10-14')) - 1
else
(strftime('%Y', 'now') - strftime('%Y', '2006-10-14')) * 12 +
(strftime('%m', 'now') - strftime('%m', '2006-10-14'))
end
else
case when
strftime('%d', 'now') > strftime('%d', '2006-10-14')
then
(strftime('%Y', 'now') - strftime('%Y', '2006-10-14') - 1) * 12 +
(strftime('%m', 'now') +
(12 - strftime('%m', '2006-10-14' -1
else
(strftime('%Y', 'now') - strftime('%Y', '2006-10-14') - 1) * 12 +
(strftime('%m', 'now') + (12 - strftime('%m', '2006-10-14')))
end
end

HTH
Dennis Cote



-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Concurrency

2007-06-01 Thread Eduardo Morras
At 20:58 01/06/2007, you wrote:
>On 6/1/07, Eduardo Morras <[EMAIL PROTECTED]> wrote:
>
>>If i remember well, sqlite uses two databases for metadata/schema
>
>Databases or tables? Could you be thinking of the sqlite_master table?

 You're right 1 db and 2 tables. Yes i'm thinking on sqlite_master table.

Thanks



   Usuario de FreeBSD+Xfce, OpenOffice y muchos mas OSS.
Microsoft declara que el OSS viola 235 patentes. Por favor, DENUNCIAME. 


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Does Attach improve Concurrency ?

2007-06-01 Thread Eduardo Morras
At 19:32 01/06/2007, you wrote:

>When you have a connection with multiple attached databases and the
>connection acquires an exclusive lock, does it always lock all attached
>databases or does it keep track of which databases require the lock?  Does
>using separate databases and attaching them improve concurrency (by
>providing finer-grained locking)?

It locks all attached databases. No, it does not improve concurrency but i can 
improve speed if database files are on more than one phisical disk. The sqlite 
bottleneck is i/o access on most cases.



   Usuario de FreeBSD+Xfce, OpenOffice y muchos mas OSS.
Microsoft declara que el OSS viola 235 patentes. Por favor, DENUNCIAME. 


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Concurrency

2007-06-01 Thread Will Leshner

On 6/1/07, Eduardo Morras <[EMAIL PROTECTED]> wrote:


If i remember well, sqlite uses two databases for metadata/schema


Databases or tables? Could you be thinking of the sqlite_master table?

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Age calculation on literal

2007-06-01 Thread Dennis Cote

On 6/1/07, RB Smissaert <[EMAIL PROTECTED]> wrote:


Got this nearly worked out now, but somehow I can't get the nested case
when
syntax right:

SELECT
case
when
date('2006-10-14', '+' || (strftime('%Y', 'now') - strftime('%Y',
'2006-10-14')) || ' years') <= date('now')
then
case when
strftime('%d', 'now') > strftime('%d', '2006-10-14')
then
((strftime('%Y', 'now') - strftime('%Y', '2006-10-14')) * 12 +
(strftime('%m', 'now') - strftime('%m', '2006-10-14')) - 1
else
(strftime('%Y', 'now') - strftime('%Y', '2006-10-14'))) * 12 +




You have an extra closing bracket in the line above.


(strftime('%m', 'now') - strftime('%m', '2006-10-14'))

end
else
case when
strftime('%d', 'now') > strftime('%d', '2006-10-14')
then
((strftime('%Y', 'now') - strftime('%Y', '2006-10-14') -1)   * 12 +
(strftime('%m', 'now') +
(12 - strftime('%m', '2006-10-14' -1
else
(strftime('%Y', 'now') - strftime('%Y', '2006-10-14') -1)  * 12 +
(strftime('%m', 'now') +
(12 - strftime('%m', '2006-10-14')))
end
end

It will give me an error (from my VB wrapper) syntax error near else.
Any idea what is wrong here?



Try this instead, I find the extra indentation makes it easier to see what
you are doing.

SELECT
case when
   date('2006-10-14', '+' || (strftime('%Y', 'now') - strftime('%Y',
   '2006-10-14')) || ' years') <= date('now')
then
   case when
   strftime('%d', 'now') > strftime('%d', '2006-10-14')
   then
   ((strftime('%Y', 'now') - strftime('%Y', '2006-10-14')) * 12 +
   (strftime('%m', 'now') - strftime('%m', '2006-10-14')) - 1
   else
   (strftime('%Y', 'now') - strftime('%Y', '2006-10-14')) * 12 +
   (strftime('%m', 'now') - strftime('%m', '2006-10-14'))
   end
else
   case when
   strftime('%d', 'now') > strftime('%d', '2006-10-14')
   then
   (strftime('%Y', 'now') - strftime('%Y', '2006-10-14') - 1) * 12 +
   (strftime('%m', 'now') +
   (12 - strftime('%m', '2006-10-14' -1
   else
   (strftime('%Y', 'now') - strftime('%Y', '2006-10-14') - 1) * 12 +
   (strftime('%m', 'now') + (12 - strftime('%m', '2006-10-14')))
   end
end

HTH
Dennis Cote


Re: [sqlite] Concurrency

2007-06-01 Thread Eduardo Morras
At 19:24 01/06/2007, you wrote:
>Why you said less than 29?

SQLite has a soft limit of 10 databases and a hard limit of 32, you can change 
it at compile time. If i remember well, sqlite uses two databases for 
metadata/schema, so you get a max of 30 databases, you need another one as 
master db, so you get 29 free databases. 


---
Nunca mezclo pastillas con alcohol, ... las disuelvo. 


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



[sqlite] Does Attach improve Concurrency ?

2007-06-01 Thread Samuel R. Neff

When you have a connection with multiple attached databases and the
connection acquires an exclusive lock, does it always lock all attached
databases or does it keep track of which databases require the lock?  Does
using separate databases and attaching them improve concurrency (by
providing finer-grained locking)?

Thanks,

Sam




-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Concurrency

2007-06-01 Thread Marco Bambini

Why you said less than 29?

---
Marco Bambini
http://www.sqlabs.net
http://www.sqlabs.net/blog/
http://www.sqlabs.net/realsqlserver/



On Jun 1, 2007, at 6:56 PM, Eduardo Morras wrote:


At 11:17 01/06/2007, you wrote:

Hi,

I am having a scenario where I have one reader/writer and many  
writer threads.
All writers are pretty basic (single INSERT INTO; some sort of a  
logging info

what a thread has done).

I believe I will receive many BUSY return codes and I don't like  
these
spinlock-like retries. The problem I am having with this design is  
that I would
like to complete the thread ASAP, so that I don't have many  
threads idling and

consuming resources of my embedded system.

I was thinking to either:

a. Use mutex/semaphore before writting to the database or

b. Have a (thread safe) list of INSERT INTO strings that every  
writer thread

populates and the main reader/writer thread later executes.

Is this a good approach? Does anyone have a better design? I don't  
want to use
other database, because I think Sqlite is great for an embedded  
system that I

am using.


How many threads have you?. If threads number is low (less than 29)  
you can use a database for each thread. Each one will have it's own  
file and no write lock problems. From time to time a simple sql  
query can get all data from those databases, write to the main one  
and delete the databases.


HTH


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Concurrency

2007-06-01 Thread Eduardo Morras
At 11:17 01/06/2007, you wrote:
>Hi,
>
>I am having a scenario where I have one reader/writer and many writer threads.
>All writers are pretty basic (single INSERT INTO; some sort of a logging info
>what a thread has done).
>
>I believe I will receive many BUSY return codes and I don't like these
>spinlock-like retries. The problem I am having with this design is that I would
>like to complete the thread ASAP, so that I don't have many threads idling and
>consuming resources of my embedded system.
>
>I was thinking to either:
>
>a. Use mutex/semaphore before writting to the database or
>
>b. Have a (thread safe) list of INSERT INTO strings that every writer thread
>populates and the main reader/writer thread later executes.
>
>Is this a good approach? Does anyone have a better design? I don't want to use
>other database, because I think Sqlite is great for an embedded system that I
>am using.

How many threads have you?. If threads number is low (less than 29) you can use 
a database for each thread. Each one will have it's own file and no write lock 
problems. From time to time a simple sql query can get all data from those 
databases, write to the main one and delete the databases.

HTH



   Usuario de FreeBSD+Xfce, OpenOffice y muchos mas OSS.
Microsoft declara que el OSS viola 235 patentes. Por favor, DENUNCIAME. 


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Re: CAST

2007-06-01 Thread BardzoTajneKonto

> Sqlite lets us advance our storage 
> capabilities into a more flexible world.

Sure, but it's not allways a good thing. Usually one column stores related 
data.
Related data mostly have the same type. Entering a value of different type is 
an error
which is silently ignored. Allowing different types gives us more 
flexibility, but is also
more error-prone. Ofcourse there are other databases that can be chosen 
instead of
SQLite if type safety is required, but compile time option wouldn't hurt 
SQLite in any way.


---
CTR  brzmi tajemniczo ? 
Sprawd¼ co mo¿esz zyskaæ na >>> http://link.interia.pl/f1a9d


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Concurrency

2007-06-01 Thread Doug Currie
On Friday, June 01, 2007 Ian Frosst wrote: 

> For Windows, this is not the case with Automatic Reset events.  The system
> guarantees that only one thread waiting on the event is woken up (it keeps a
> queue): the others happily keep sleeping until the next setting of the
> event.

That may work for you, but has the possible drawback of starving a
thread... Windows doesn't guarantee that the woken thread is the one
at the head of the "queue." See, e.g.,
http://blogs.msdn.com/oldnewthing/archive/2006/03/13/550402.aspx
So, I never use PulseEvent or Automatic Reset events.

Of course, if you expect there to be intervals when there are no
waiting threads, and you can afford to wait for that interval for a
synchronization point, and you don't care the order in which the
inserts are performed, the Automatic Reset event might work.

e

> On 6/1/07, Doug Currie <[EMAIL PROTECTED]> wrote:
>>
>> On Friday, June 01, 2007 Ian Frosst wrote:
>>
>> > On the topic of a more efficient busy handler, one approach I considered
>> > was to implement an event which was signalled when a database unlock
>> > occurred.
>> > That way, the busy handler could just wait on the event (which is an
>> > efficient wait state), and be guaranteed of a wake up when the lock is
>> > released (the event would be signalled at this time.)  However, I wasn't
>> > at the time familiar enough with SQLite's innards to implement such a
>> > beast.
>> > Can anyone see any pitfalls to such an approach?
>>
>> The problems occur when multiple threads are waiting on the event;
>> they all wake up and compete for the resource again. For better
>> solutions, see: http://world.std.com/~jmhart/batons.htm

-- 
Doug Currie
Londonderry, NH, USA


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Concurrency

2007-06-01 Thread Ken


[EMAIL PROTECTED] wrote: Hi,

I am having a scenario where I have one reader/writer and many writer threads.
All writers are pretty basic (single INSERT INTO; some sort of a logging info
what a thread has done).

I believe I will receive many BUSY return codes and I don't like these
spinlock-like retries. The problem I am having with this design is that I would
like to complete the thread ASAP, so that I don't have many threads idling and
consuming resources of my embedded system.

I was thinking to either:

a. Use mutex/semaphore before writting to the database or

b. Have a (thread safe) list of INSERT INTO strings that every writer thread
populates and the main reader/writer thread later executes.

Is this a good approach? Does anyone have a better design? I don't want to use
other database, because I think Sqlite is great for an embedded system that I
am using.
___
Najhitrej¹i brezplaèni klicni dostop :: Varno in zanesljivo po internetu
Obi¹èite http://www.dialup386.com/

-
To unsubscribe, send email to [EMAIL PROTECTED]
-


 When you have multiple writes using sqlite you will need to perform a 
syncrhonization of some form.
 
 I would recommend using option "b" that you indicated. Create a thread that 
connects to the DB and handles all of you i/o to sqlite. That way you will 
never get a db locked or busy retry... 
 Take a look at src/test_server.c for an example implementation. For 
your case you really don't need to implement the "shared cache". Just create a 
simple db open internally to the thread. Have each client send its insert data 
into the "servers" incoming work queue.
 
 This will work as long as the "clients" don't need to wait or guarantee 
durability before proceeding. 
 
 


RE: [sqlite] Concurrency

2007-06-01 Thread Samuel R. Neff

Nice analogy, but in the case the cat really does have 9 lives (or many
more) 'cause with SQLITE_BUSY you can just retry and while retrying is a
performance penalty in my experience SQLITE_BUSY is a very rare occurrence.

All I'm saying is don't fix a perceived problem until you've tested to be
sure your perception is correct.

Sam


---
We're Hiring! Seeking a passionate developer to join our team building Flex
based products. Position is in the Washington D.C. metro area. If interested
contact [EMAIL PROTECTED]
 
-Original Message-
From: John Stanton [mailto:[EMAIL PROTECTED] 
Sent: Friday, June 01, 2007 9:40 AM
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] Concurrency

You make a very good point.  Someone called it the "cat running over the 
road" situation.  A cat runs across a busy road without looking by going 
as fast as possible and rarely does one get run over.  On the other hand 
roads are lined with dead armadillos.

If you synchronization logic is sound and you avoid polling or waits the 
faster your database runs the more concurrent transactions per second 
you will achieve.


-
To unsubscribe, send email to [EMAIL PROTECTED]

-


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Concurrency

2007-06-01 Thread Ian Frosst

For Windows, this is not the case with Automatic Reset events.  The system
guarantees that only one thread waiting on the event is woken up (it keeps a
queue): the others happily keep sleeping until the next setting of the
event.

On 6/1/07, Doug Currie <[EMAIL PROTECTED]> wrote:


On Friday, June 01, 2007 Ian Frosst wrote:

> On the topic of a more efficient busy handler, one approach I considered
was
> to implement an event which was signalled when a database unlock
occurred.
> That way, the busy handler could just wait on the event (which is an
> efficient wait state), and be guaranteed of a wake up when the lock is
> released (the event would be signalled at this time.)  However, I wasn't
at
> the time familiar enough with SQLite's innards to implement such a
beast.
> Can anyone see any pitfalls to such an approach?

The problems occur when multiple threads are waiting on the event;
they all wake up and compete for the resource again. For better
solutions, see: http://world.std.com/~jmhart/batons.htm

e

--
Doug Currie
Londonderry, NH, USA



-
To unsubscribe, send email to [EMAIL PROTECTED]

-




Re: [sqlite] Concurrency

2007-06-01 Thread Doug Currie
On Friday, June 01, 2007 Ian Frosst wrote: 

> On the topic of a more efficient busy handler, one approach I considered was
> to implement an event which was signalled when a database unlock occurred.
> That way, the busy handler could just wait on the event (which is an
> efficient wait state), and be guaranteed of a wake up when the lock is
> released (the event would be signalled at this time.)  However, I wasn't at
> the time familiar enough with SQLite's innards to implement such a beast.
> Can anyone see any pitfalls to such an approach?

The problems occur when multiple threads are waiting on the event;
they all wake up and compete for the resource again. For better
solutions, see: http://world.std.com/~jmhart/batons.htm

e

-- 
Doug Currie
Londonderry, NH, USA


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



[sqlite] Sqlite 3 Crash on OSX

2007-06-01 Thread Mark Gilbert

Folks.

My app just crashed in the field randomly after some time running fine.

Thread 12 Crashed:
0   libsqlite3.0.dylib  0x9406e587 sqlite3pager_get + 390
1   libsqlite3.0.dylib  0x94054275 sqlite3BtreeCopyFile + 381
2   libsqlite3.0.dylib  0x940542dd sqlite3BtreeCopyFile + 485
3   libsqlite3.0.dylib  0x940545b6 sqlite3BtreeLast + 134
4   libsqlite3.0.dylib  0x940830c1 sqlite3VdbeExec + 16021
5   libsqlite3.0.dylib  0x94084c73 sqlite3_step + 270
6   libsqlite3.0.dylib  0x9408b343 sqlite3_exec + 260
7   libsqlite3.0.dylib  0x9407a53d sqlite3_get_table + 189

Anyone have anything specific to suggest ?

Cheers

Mark.
--
[EMAIL PROTECTED]
Tel: +44 208 340 5677
fax: +44 870 055 7790
http://www.gallery.co.uk

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



RE: [sqlite] Age calculation on literal

2007-06-01 Thread RB Smissaert
Got this nearly worked out now, but somehow I can't get the nested case when
syntax right:

SELECT 
case 
when 
date('2006-10-14', '+' || (strftime('%Y', 'now') - strftime('%Y',
'2006-10-14')) || ' years') <= date('now') 
then 
case when 
strftime('%d', 'now') > strftime('%d', '2006-10-14') 
then 
((strftime('%Y', 'now') - strftime('%Y', '2006-10-14')) * 12 +
(strftime('%m', 'now') - strftime('%m', '2006-10-14')) - 1 
else 
(strftime('%Y', 'now') - strftime('%Y', '2006-10-14'))) * 12 +
(strftime('%m', 'now') - strftime('%m', '2006-10-14'))
end 
else 
case when 
strftime('%d', 'now') > strftime('%d', '2006-10-14') 
then 
((strftime('%Y', 'now') - strftime('%Y', '2006-10-14') -1)   * 12 +
(strftime('%m', 'now') + 
(12 - strftime('%m', '2006-10-14' -1 
else 
(strftime('%Y', 'now') - strftime('%Y', '2006-10-14') -1)  * 12 +
(strftime('%m', 'now') + 
(12 - strftime('%m', '2006-10-14')))
end 
end

It will give me an error (from my VB wrapper) syntax error near else.
Any idea what is wrong here?


RBS

-Original Message-
From: Dennis Cote [mailto:[EMAIL PROTECTED] 
Sent: 31 May 2007 22:17
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] Age calculation on literal

RB Smissaert wrote:
> Thanks to Dennis Cote I got a nice way to get the age from the date in the
> form '-nmm-dd'. It works fine when I run it on a field, but when I run
> it on a literal date it gives me 100 too much:
>
> select
> case when 
> date('2002-01-01', '+' || (strftime('%Y', 'now') - 
> strftime('%Y', '2002-01-01')) || ' years') <= date('now') 
> then 
> strftime('%Y', 'now') - strftime('%Y', '2002-01-01') 
> else
> strftime('%Y', 'now') - strftime('%Y', '2002-01-01') - 1 
> end
>
> Why is this?
>
>   
This works for me in the sqlite shell as shown below:

C:\Documents and Settings\DennisC>sqlite3
SQLite version 3.3.15
Enter ".help" for instructions
sqlite>
sqlite> select
   ...> case when
   ...> date('2002-01-01', '+' || (strftime('%Y', 'now') -
   ...> strftime('%Y', '2002-01-01')) || ' years') <= date('now')
   ...> then
   ...> strftime('%Y', 'now') - strftime('%Y', '2002-01-01')
   ...> else
   ...> strftime('%Y', 'now') - strftime('%Y', '2002-01-01') - 1
   ...> end
   ...> ;
5

How are you running this query?

Dennis Cote


-
To unsubscribe, send email to [EMAIL PROTECTED]

-



-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Concurrency

2007-06-01 Thread John Stanton
With other applications you can use semaphores for synchronization and 
achieve minimal latency and a low overhead.


If you have networked files you are dependent upon the file locking and 
on the effectiveness of the cross network file locking.  This does not 
necessarily work as expected and in particular notorious cases does not 
work at all.


If you want maximal performance across a nwetwork you need to implement 
a server to manage the database on one machine.


Israel Figueroa wrote:

What if the database is locked by another application, or by another box?

The driver should poll untill it get an "idle database" and then thow an
event... and then, we're polling again.

I'm coding some similar to the original post... I'm not that good with
threads yet, but I did foresee that even with my tiny inserts maybe some
moment I could get a Sqlite_busy. Is that bad just keep inserting until i
get a Sqlite_ok ? Assuming that is not a multiuser enviroment, just one app
accesing the database.

2007/6/1, Ian Frosst <[EMAIL PROTECTED]>:



On the topic of a more efficient busy handler, one approach I considered
was
to implement an event which was signalled when a database unlock 
occurred.

That way, the busy handler could just wait on the event (which is an
efficient wait state), and be guaranteed of a wake up when the lock is
released (the event would be signalled at this time.)  However, I wasn't
at
the time familiar enough with SQLite's innards to implement such a beast.
Can anyone see any pitfalls to such an approach?

Ian

On 6/1/07, John Stanton <[EMAIL PROTECTED]> wrote:
>
> Tom Briggs wrote:
> >
> >
> >>I don't want to use
> >>other database, because I think Sqlite is great for an
> >>embedded system that I
> >>am using.
> >
> >
> >I think that your own questions about concurrency prove this
> > incorrect.  If you need high concurrency and you don't like retries,
> > SQLite is not the database for you.
> >
> >-T
> >
>
> If you require ACID type data integrity and have a single disk there is
> no such thing as a "high concurrency database".  They all share a 
single

> disk resource in some way.  With Sqlite it is up to the designer to
> build in concurrency and that cna be done by single streaming.  Better
> performance is achieved by using a single database connection so that
> cache hits are maximized.
>
> If your design is such that you never get a busy then you have an
> effective allocation of your disk resource.  Using mutexes between
> threads and semaphores between processes gives you that capability.
>
> To my mind the only time you should use the busy logic is when you are
> working across a network with shared files.
>
>
>
>
- 


> To unsubscribe, send email to [EMAIL PROTECTED]
>
>
- 


>
>








-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Concurrency

2007-06-01 Thread Israel Figueroa

What if the database is locked by another application, or by another box?

The driver should poll untill it get an "idle database" and then thow an
event... and then, we're polling again.

I'm coding some similar to the original post... I'm not that good with
threads yet, but I did foresee that even with my tiny inserts maybe some
moment I could get a Sqlite_busy. Is that bad just keep inserting until i
get a Sqlite_ok ? Assuming that is not a multiuser enviroment, just one app
accesing the database.

2007/6/1, Ian Frosst <[EMAIL PROTECTED]>:


On the topic of a more efficient busy handler, one approach I considered
was
to implement an event which was signalled when a database unlock occurred.
That way, the busy handler could just wait on the event (which is an
efficient wait state), and be guaranteed of a wake up when the lock is
released (the event would be signalled at this time.)  However, I wasn't
at
the time familiar enough with SQLite's innards to implement such a beast.
Can anyone see any pitfalls to such an approach?

Ian

On 6/1/07, John Stanton <[EMAIL PROTECTED]> wrote:
>
> Tom Briggs wrote:
> >
> >
> >>I don't want to use
> >>other database, because I think Sqlite is great for an
> >>embedded system that I
> >>am using.
> >
> >
> >I think that your own questions about concurrency prove this
> > incorrect.  If you need high concurrency and you don't like retries,
> > SQLite is not the database for you.
> >
> >-T
> >
>
> If you require ACID type data integrity and have a single disk there is
> no such thing as a "high concurrency database".  They all share a single
> disk resource in some way.  With Sqlite it is up to the designer to
> build in concurrency and that cna be done by single streaming.  Better
> performance is achieved by using a single database connection so that
> cache hits are maximized.
>
> If your design is such that you never get a busy then you have an
> effective allocation of your disk resource.  Using mutexes between
> threads and semaphores between processes gives you that capability.
>
> To my mind the only time you should use the busy logic is when you are
> working across a network with shared files.
>
>
>
>
-
> To unsubscribe, send email to [EMAIL PROTECTED]
>
>
-
>
>





--
Thanks God


RE: [sqlite] Concurrency

2007-06-01 Thread KKH
// wrapper for sqlite3_prepare_v2 which retries
creating statements if the db returns SQLITE_BUSY or
SQLITE_LOCKED
int sql_prepare(sqlite3 *db, const char *sql,
sqlite3_stmt **ppStmt, int wait) {
#ifdef SQL_DEBUG
printf(sql);
printf("\n");
fflush(stdout);
#endif
int rc;
char looper[4] = {'|','/','-','\\'};
int looperc = 0;
int waited = 0;
while (1) {
rc = sqlite3_prepare_v2(db,sql,-1,ppStmt,NULL);
if (rc == SQLITE_LOCKED || rc == SQLITE_BUSY) {
if (wait != 0) {
fprintf(stdout,"Database is locked or busy.
Waiting %is ... %1c\r", ++waited,
looper[looperc]);
fflush(stdout);
wait--;
looperc = ++looperc % sizeof(looper);
sleep(1);
} else {
fprintf(stderr,"Database was locked or busy 
while
creating statement. I've given up.\n");
return rc;
}
} else {
if (waited != 0) printf("\n\n");
return rc;
}
}
}
--- [EMAIL PROTECTED] schrieb:

> Hi,
> 
> I am having a scenario where I have one
> reader/writer and many writer threads.
> All writers are pretty basic (single INSERT INTO;
> some sort of a logging info
> what a thread has done).
> 
> I believe I will receive many BUSY return codes and
> I don't like these
> spinlock-like retries. The problem I am having with
> this design is that I would
> like to complete the thread ASAP, so that I don't
> have many threads idling and
> consuming resources of my embedded system.
> 
> I was thinking to either:
> 
> a. Use mutex/semaphore before writting to the
> database or
> 
> b. Have a (thread safe) list of INSERT INTO strings
> that every writer thread
> populates and the main reader/writer thread later
> executes.
> 
> Is this a good approach? Does anyone have a better
> design? I don't want to use
> other database, because I think Sqlite is great for
> an embedded system that I
> am using.
>
___
> Najhitrej¹i brezplaèni klicni dostop :: Varno in
> zanesljivo po internetu
> Obi¹èite http://www.dialup386.com/
> 
>
-
> To unsubscribe, send email to
> [EMAIL PROTECTED]
>
-
> 
> 




___ 
Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Concurrency

2007-06-01 Thread John Stanton

Samuel R. Neff wrote:

If option (b), using a single thread for writing and a multi-threaded write
queue works in your situation, then that would probably provide best
concurrency and performance.  The only downside to this is the delayed
writes mean you don't as easily get feedback to the original writer if a
write fails (bad data for example).  You could build delayed
feedback/callback into the system, just depends on your application
architecture.

Also, I would strongly suggest doing some actual testing and confirming
there is a bottleneck without any custom code to increase concurrency before
programming workarounds for an expected problem.  What we've found is that
SQLite is so much faster than other databases (MSSQL in particular) that
concurrency is greatly improved simply because each write is faster and thus
the time the db is locked is less even though the whole db is locked.

HTH,

Sam

---
We're Hiring! Seeking a passionate developer to join our team building
products. Position is in the Washington D.C. metro area. If interested
contact [EMAIL PROTECTED]
 
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Friday, June 01, 2007 5:18 AM

To: sqlite-users@sqlite.org
Subject: [sqlite] Concurrency

Hi,

I am having a scenario where I have one reader/writer and many writer
threads.
All writers are pretty basic (single INSERT INTO; some sort of a logging
info
what a thread has done).

I believe I will receive many BUSY return codes and I don't like these
spinlock-like retries. The problem I am having with this design is that I
would
like to complete the thread ASAP, so that I don't have many threads idling
and
consuming resources of my embedded system.

I was thinking to either:

a. Use mutex/semaphore before writting to the database or

b. Have a (thread safe) list of INSERT INTO strings that every writer thread
populates and the main reader/writer thread later executes.

Is this a good approach? Does anyone have a better design? I don't want to
use
other database, because I think Sqlite is great for an embedded system that
I
am using.



You make a very good point.  Someone called it the "cat running over the 
road" situation.  A cat runs across a busy road without looking by going 
as fast as possible and rarely does one get run over.  On the other hand 
roads are lined with dead armadillos.


If you synchronization logic is sound and you avoid polling or waits the 
faster your database runs the more concurrent transactions per second 
you will achieve.


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Concurrency

2007-06-01 Thread Ian Frosst

On the topic of a more efficient busy handler, one approach I considered was
to implement an event which was signalled when a database unlock occurred.
That way, the busy handler could just wait on the event (which is an
efficient wait state), and be guaranteed of a wake up when the lock is
released (the event would be signalled at this time.)  However, I wasn't at
the time familiar enough with SQLite's innards to implement such a beast.
Can anyone see any pitfalls to such an approach?

Ian

On 6/1/07, John Stanton <[EMAIL PROTECTED]> wrote:


Tom Briggs wrote:
>
>
>>I don't want to use
>>other database, because I think Sqlite is great for an
>>embedded system that I
>>am using.
>
>
>I think that your own questions about concurrency prove this
> incorrect.  If you need high concurrency and you don't like retries,
> SQLite is not the database for you.
>
>-T
>

If you require ACID type data integrity and have a single disk there is
no such thing as a "high concurrency database".  They all share a single
disk resource in some way.  With Sqlite it is up to the designer to
build in concurrency and that cna be done by single streaming.  Better
performance is achieved by using a single database connection so that
cache hits are maximized.

If your design is such that you never get a busy then you have an
effective allocation of your disk resource.  Using mutexes between
threads and semaphores between processes gives you that capability.

To my mind the only time you should use the busy logic is when you are
working across a network with shared files.



-
To unsubscribe, send email to [EMAIL PROTECTED]

-




RE: [sqlite] Concurrency

2007-06-01 Thread Tom Briggs
 
> If you require ACID type data integrity and have a single 
> disk there is 
> no such thing as a "high concurrency database".  They all 

   Then don't blame me if he's asking the wrong questions. :)

   -T

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



RE: [sqlite] Concurrency

2007-06-01 Thread Tom Briggs

   I have no suggestions (I'm not an embedded systems guy), but your initial 
comment implied that there were other options.  If there aren't then your 
original statement is invalid and there's nothing to discuss. :)

   -T 

> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
> Sent: Friday, June 01, 2007 8:27 AM
> To: sqlite-users@sqlite.org
> Subject: RE: [sqlite] Concurrency
> 
> Tom,
> 
> > > I don't want to use
> > > other database, because I think Sqlite is great for an
> > > embedded system that I
> > > am using.
> >
> >I think that your own questions about concurrency prove this
> > incorrect.  If you need high concurrency and you don't like retries,
> > SQLite is not the database for you.
> 
> Then what database would you suggest instead Sqlite for use 
> in embedded (low
> memory, cpu: 200 Mhz) system?
> __
> _
> Najhitrejši brezplačni klicni dostop :: Varno in zanesljivo 
> po internetu
> Obiščite http://www.dialup386.com/
> 
> --
> ---
> To unsubscribe, send email to [EMAIL PROTECTED]
> --
> ---
> 
> 

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



RE: [sqlite] Concurrency

2007-06-01 Thread Samuel R. Neff

If option (b), using a single thread for writing and a multi-threaded write
queue works in your situation, then that would probably provide best
concurrency and performance.  The only downside to this is the delayed
writes mean you don't as easily get feedback to the original writer if a
write fails (bad data for example).  You could build delayed
feedback/callback into the system, just depends on your application
architecture.

Also, I would strongly suggest doing some actual testing and confirming
there is a bottleneck without any custom code to increase concurrency before
programming workarounds for an expected problem.  What we've found is that
SQLite is so much faster than other databases (MSSQL in particular) that
concurrency is greatly improved simply because each write is faster and thus
the time the db is locked is less even though the whole db is locked.

HTH,

Sam

---
We're Hiring! Seeking a passionate developer to join our team building
products. Position is in the Washington D.C. metro area. If interested
contact [EMAIL PROTECTED]
 
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Friday, June 01, 2007 5:18 AM
To: sqlite-users@sqlite.org
Subject: [sqlite] Concurrency

Hi,

I am having a scenario where I have one reader/writer and many writer
threads.
All writers are pretty basic (single INSERT INTO; some sort of a logging
info
what a thread has done).

I believe I will receive many BUSY return codes and I don't like these
spinlock-like retries. The problem I am having with this design is that I
would
like to complete the thread ASAP, so that I don't have many threads idling
and
consuming resources of my embedded system.

I was thinking to either:

a. Use mutex/semaphore before writting to the database or

b. Have a (thread safe) list of INSERT INTO strings that every writer thread
populates and the main reader/writer thread later executes.

Is this a good approach? Does anyone have a better design? I don't want to
use
other database, because I think Sqlite is great for an embedded system that
I
am using.


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: Re: [sqlite] sqlite3_open() fails on WinCE due to utf8ToUnicode / unicodeToU

2007-06-01 Thread Nuno Lucas

On 6/1/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

Yes, I can rebuild the image, but i didn't find any UTF-8 code
page. But it really looks like this code page is not installed,
because I tried GetCPInfo(CP_ACP, ) and it failed with
ERROR_INVALID_PARAMETER. Can you tell me where I can enable UTF-8
support. (hope this is not to offtopic).


Sorry but never used the WinCE builder tool.
Maybe someone here knows better.

Regards,
~Nuno Lucas


Regards,
Daniel


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Concurrency

2007-06-01 Thread John Stanton

Tom Briggs wrote:
 


I don't want to use
other database, because I think Sqlite is great for an 
embedded system that I

am using.



   I think that your own questions about concurrency prove this
incorrect.  If you need high concurrency and you don't like retries,
SQLite is not the database for you.

   -T



If you require ACID type data integrity and have a single disk there is 
no such thing as a "high concurrency database".  They all share a single 
disk resource in some way.  With Sqlite it is up to the designer to 
build in concurrency and that cna be done by single streaming.  Better 
performance is achieved by using a single database connection so that 
cache hits are maximized.


If your design is such that you never get a busy then you have an 
effective allocation of your disk resource.  Using mutexes between 
threads and semaphores between processes gives you that capability.


To my mind the only time you should use the busy logic is when you are 
working across a network with shared files.



-
To unsubscribe, send email to [EMAIL PROTECTED]
-



AW: Re: [sqlite] sqlite3_open() fails on WinCE due to utf8ToUnicode / unicodeToU

2007-06-01 Thread [EMAIL PROTECTED]
Hello

Yes, I can rebuild the image, but i didn't find any UTF-8 code 
page. But it really looks like this code page is not installed, 
because I tried GetCPInfo(CP_ACP, ) and it failed with 
ERROR_INVALID_PARAMETER. Can you tell me where I can enable UTF-8 
support. (hope this is not to offtopic).

Regards,
Daniel




-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Concurrency

2007-06-01 Thread John Stanton
We find that synchronizing access to database writes using a mutex works 
well.  You could think of implementing read and write locks using the 
thread primitives and achieve a better result.


If you do poll to resolve busy checks a spinlock is certainly a bad 
idea.  When we use that approach we will yield the thread after each busy.


[EMAIL PROTECTED] wrote:

Hi,

I am having a scenario where I have one reader/writer and many writer threads.
All writers are pretty basic (single INSERT INTO; some sort of a logging info
what a thread has done).

I believe I will receive many BUSY return codes and I don't like these
spinlock-like retries. The problem I am having with this design is that I would
like to complete the thread ASAP, so that I don't have many threads idling and
consuming resources of my embedded system.

I was thinking to either:

a. Use mutex/semaphore before writting to the database or

b. Have a (thread safe) list of INSERT INTO strings that every writer thread
populates and the main reader/writer thread later executes.

Is this a good approach? Does anyone have a better design? I don't want to use
other database, because I think Sqlite is great for an embedded system that I
am using.
___
Najhitrejši brezplačni klicni dostop :: Varno in zanesljivo po internetu
Obiščite http://www.dialup386.com/

-
To unsubscribe, send email to [EMAIL PROTECTED]
-




-
To unsubscribe, send email to [EMAIL PROTECTED]
-



RE: [sqlite] Concurrency

2007-06-01 Thread b00mer
Tom,

> > I don't want to use
> > other database, because I think Sqlite is great for an
> > embedded system that I
> > am using.
>
>I think that your own questions about concurrency prove this
> incorrect.  If you need high concurrency and you don't like retries,
> SQLite is not the database for you.

Then what database would you suggest instead Sqlite for use in embedded (low
memory, cpu: 200 Mhz) system?
___
Najhitrejši brezplačni klicni dostop :: Varno in zanesljivo po internetu
Obiščite http://www.dialup386.com/

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



RE: [sqlite] Concurrency

2007-06-01 Thread Tom Briggs
 
> I don't want to use
> other database, because I think Sqlite is great for an 
> embedded system that I
> am using.

   I think that your own questions about concurrency prove this
incorrect.  If you need high concurrency and you don't like retries,
SQLite is not the database for you.

   -T

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] sqlite3_open() fails on WinCE due to utf8ToUnicode / unicodeToUtf8

2007-06-01 Thread Nuno Lucas

On 6/1/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

Hello

It looks like there's a problem on WinCE operating system with the
utf8ToUnicode() / unicodeToUtf8() conversion functions. No database
can be opened by sqlite3_open() because thehes functions fail.

Please have a look what happens there (location: os_win.c :)

[...]

If I use the CP_ACP flag, everthing works ok:
nChar = MultiByteToWideChar(CP_ACP, 0, zFilename, -1, NULL, 0);

Same failure probably in unicodeToUtf8() because it uses
"WideCharToMultiByte(CP_UTF8, 0, zWideFilename, -1, 0, 0, 0, 0);"

My question:
Is this a bug or is something wrong with my WinCE-Image?


It probably means your WinCE OS image doesn't have UTF-8 support
built-in, so you either have to make your own character set
conversions or rebuild the OS image with that support (if you can
change the image, that is).

Regards,
~Nuno Lucas


Version information
SQLite 3.3.17 (also tried 3.3.13 and failed)
WinCE 5.0


Regards
Daniel


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



[sqlite] Concurrency

2007-06-01 Thread b00mer
Hi,

I am having a scenario where I have one reader/writer and many writer threads.
All writers are pretty basic (single INSERT INTO; some sort of a logging info
what a thread has done).

I believe I will receive many BUSY return codes and I don't like these
spinlock-like retries. The problem I am having with this design is that I would
like to complete the thread ASAP, so that I don't have many threads idling and
consuming resources of my embedded system.

I was thinking to either:

a. Use mutex/semaphore before writting to the database or

b. Have a (thread safe) list of INSERT INTO strings that every writer thread
populates and the main reader/writer thread later executes.

Is this a good approach? Does anyone have a better design? I don't want to use
other database, because I think Sqlite is great for an embedded system that I
am using.
___
Najhitrejši brezplačni klicni dostop :: Varno in zanesljivo po internetu
Obiščite http://www.dialup386.com/

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



[sqlite] sqlite3_open() fails on WinCE due to utf8ToUnicode / unicodeToUtf8

2007-06-01 Thread [EMAIL PROTECTED]
Hello

It looks like there's a problem on WinCE operating system with the 
utf8ToUnicode() / unicodeToUtf8() conversion functions. No database 
can be opened by sqlite3_open() because thehes functions fail.

Please have a look what happens there (location: os_win.c :)
/*
** Convert a UTF-8 string to microsoft unicode (UTF-16?). 
**
** Space to hold the returned string is obtained from 
sqliteMalloc.
*/
static WCHAR *utf8ToUnicode(const char *zFilename){// ->->-> 
zFilename is "mydatabase.db"
  int nChar;
  WCHAR *zWideFilename;

  nChar = MultiByteToWideChar(CP_UTF8, 0, zFilename, -1, NULL, 0);  
// ->->-> returns 0 here
  zWideFilename = sqliteMalloc( nChar*sizeof(zWideFilename[0]) );   
// ->->-> returns null pointer
  if( zWideFilename==0 ){
return 0;   
  // ->->-> leaves function here
  }
  nChar = MultiByteToWideChar(CP_UTF8, 0, zFilename, -1, 
zWideFilename, nChar);
  if( nChar==0 ){
sqliteFree(zWideFilename);
zWideFilename = 0;
  }
  return zWideFilename;
}

If I use the CP_ACP flag, everthing works ok:
nChar = MultiByteToWideChar(CP_ACP, 0, zFilename, -1, NULL, 0);

Same failure probably in unicodeToUtf8() because it uses 
"WideCharToMultiByte(CP_UTF8, 0, zWideFilename, -1, 0, 0, 0, 0);"

My question:
Is this a bug or is something wrong with my WinCE-Image?

Version information
SQLite 3.3.17 (also tried 3.3.13 and failed)
WinCE 5.0


Regards
Daniel




-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] file structure issue

2007-06-01 Thread weiyang wang

Nuno and Vivien thanks for your replies. i will try that.

wang


On 5/23/07, Nuno Lucas <[EMAIL PROTECTED]> wrote:


On 5/23/07, weiyang wang <[EMAIL PROTECTED]> wrote:
> does anyone know how can i get the source codes with the early file
> structure? (65 seperate files)? thanks in advance.

Download the complete source code [1] and run "./configure" on it (you
need a POSIX build system, like linux, cygwin or MSYS).

After that is done, you should have all preprocessed files generated,
so you can just copy them to where you want.


Regards,
~Nuno Lucas

[1] http://www.sqlite.org/sqlite-3.3.17.tar.gz

>
> wang
>


-
To unsubscribe, send email to [EMAIL PROTECTED]

-