Re: [sqlite] Cannot retrieve SQLite Db Data Immediately After Application Startup

2014-09-02 Thread Simon Slavin

> On 3 Sep 2014, at 5:24am, Bob Moran  wrote:
> 
> Found more of what the issue is. I noticed that my SQL text was being 
> overwritten on the return from the call to prepare_v2.
> Stepping through the SQlite3 code I discovered that a malloc call for 500+ 
> bytes was returning a pointer 8 bytes below my SQL string.
> Don't have the foggiest notion as to why. My string is on the heap. If I wait 
> some time before making the call (my program is just waiting for input, then 
> the malloc call returns a pointer far removed from my passed in SQL text. 
> Must be some kind on Linux issue?

Are you using a SQLite library or including the amalgamation source code ?

If you're using the SQLite source are you using any SQLite compiler defs ?

Which compiler are you using ?

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


Re: [sqlite] Cannot retrieve SQLite Db Data Immediately After Application Startup

2014-09-02 Thread Bob Moran
Found more of what the issue is. I noticed that my SQL text was being 
overwritten on the return from the call to prepare_v2.
Stepping through the SQlite3 code I discovered that a malloc call for 500+ 
bytes was returning a pointer 8 bytes below my SQL string.
Don't have the foggiest notion as to why. My string is on the heap. If I wait 
some time before making the call (my program is just waiting for input, then 
the malloc call returns a pointer far removed from my passed in SQL text. Must 
be some kind on Linux issue?

Bob Moran

Continental Access / NAPCO Security Technologies
355 Bayview Ave.
Amityville, N.Y. 11701
631.842.9400 x327

rmo...@cicaccess.com


-Original Message-
From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] 
On Behalf Of Roger Binns
Sent: Tuesday, September 02, 2014 12:45 PM
To: General Discussion of SQLite Database
Subject: Re: [sqlite] Cannot retrieve SQLite Db Data Immediately After 
Application Startup

On 29/08/14 12:55, Bob Moran wrote:
> The return code (rc) is SQLITE_OK, but "stmnt" is NULL (0)
>
> if I start the application and wait for at least 1 minute, everything works.

You get NULL back from prepare with SQLITE_OK if the statement doesn't do 
anything.  Examples are empty strings or comments.  Chances are that is 
actually what is happening in your case.

Roger

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


Re: [sqlite] Selecting dates...

2014-09-02 Thread jose isaias cabrera

"Petite Abeille" wrote...


On Sep 2, 2014, at 9:48 PM, jose isaias cabrera  
wrote:



Thoughts?  Thanks.


SQLite doesn’t have date per se. You are free to store dates as either 
text or number, or anything you please. But it’s your responsibility to 
keep it straight.


thanks.

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


Re: [sqlite] Selecting dates...

2014-09-02 Thread jose isaias cabrera


"Richard Hipp" wrote...

On Tue, Sep 2, 2014 at 3:48 PM, jose isaias cabrera 
 select sum(val) from t where a BETWEEN '2010-01-01' AND
'2010-01-31';
10
sqlite> select sum(val) from t where a BETWEEN '2010-01-01' AND
'2010-02-01';
20
sqlite> select sum(val) from t where a BETWEEN '2010-01-01' AND
'2010-12-31';
40

Thoughts?  Thanks.

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





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



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


Re: [sqlite] Selecting dates...

2014-09-02 Thread Richard Hipp
On Tue, Sep 2, 2014 at 3:48 PM, jose isaias cabrera  wrote:

>
> Greetings!
>
> I know that SQLite dates are of the form -MM-DD and I like that. :-)
> I want to find out why these are working.
>

SQLite does not have a special "date" type.  SQLite stores dates as either
strings, or integers, or floating point numbers.  In your case it is
storing and comparing them as strings.


>
> create table t (a date, val integer);
>

If you instead said:

 create table t(a TEXT, val integer);

Would you then understand how it works?  If so, then my explanation is that
it works *exactly* the same why when you substitute "date" for "text" in
the table declaration.



> insert into t values ('2010-01-01', 10);
> insert into t values ('2010-1-1', 10);
> insert into t values ('2010-1-01', 10);
> insert into t values ('2010-02-01', 10);
> insert into t values ('2010-2-01', 10);
>
> select sum(val) from t where a BETWEEN '2010-01-01' AND '2010-01-31';
> select sum(val) from t where a BETWEEN '2010-01-01' AND '2010-02-01';
> select sum(val) from t where a BETWEEN '2010-01-01' AND '2010-12-31';
>
> sqlite> select sum(val) from t where a BETWEEN '2010-01-01' AND
> '2010-01-31';
> 10
> sqlite> select sum(val) from t where a BETWEEN '2010-01-01' AND
> '2010-02-01';
> 20
> sqlite> select sum(val) from t where a BETWEEN '2010-01-01' AND
> '2010-12-31';
> 40
>
> Thoughts?  Thanks.
>
> josé
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>



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


Re: [sqlite] Selecting dates...

2014-09-02 Thread Petite Abeille

On Sep 2, 2014, at 9:48 PM, jose isaias cabrera  wrote:

> Thoughts?  Thanks.

SQLite doesn’t have date per se. You are free to store dates as either text or 
number, or anything you please. But it’s your responsibility to keep it 
straight.

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


[sqlite] Selecting dates...

2014-09-02 Thread jose isaias cabrera


Greetings!

I know that SQLite dates are of the form -MM-DD and I like that. :-)  I 
want to find out why these are working.


create table t (a date, val integer);
insert into t values ('2010-01-01', 10);
insert into t values ('2010-1-1', 10);
insert into t values ('2010-1-01', 10);
insert into t values ('2010-02-01', 10);
insert into t values ('2010-2-01', 10);

select sum(val) from t where a BETWEEN '2010-01-01' AND '2010-01-31';
select sum(val) from t where a BETWEEN '2010-01-01' AND '2010-02-01';
select sum(val) from t where a BETWEEN '2010-01-01' AND '2010-12-31';

sqlite> select sum(val) from t where a BETWEEN '2010-01-01' AND 
'2010-01-31';

10
sqlite> select sum(val) from t where a BETWEEN '2010-01-01' AND 
'2010-02-01';

20
sqlite> select sum(val) from t where a BETWEEN '2010-01-01' AND 
'2010-12-31';

40

Thoughts?  Thanks.

josé 


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


Re: [sqlite] Cannot retrieve SQLite Db Data Immediately After Application Startup

2014-09-02 Thread Roger Binns
On 29/08/14 12:55, Bob Moran wrote:
> The return code (rc) is SQLITE_OK, but "stmnt" is NULL (0)
> 
> if I start the application and wait for at least 1 minute, everything works.

You get NULL back from prepare with SQLITE_OK if the statement doesn't do
anything.  Examples are empty strings or comments.  Chances are that is
actually what is happening in your case.

Roger

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


Re: [sqlite] HELP sqlite3 used in vxworks has some problem

2014-09-02 Thread 王庆刚

Thank  Andy Ling. best wishes.
 
 
regards
 
Wang Qinggang.







At 2014-09-02 09:45:47, "Andy Ling"  wrote:
>> -Original Message-
>> From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-
>> boun...@sqlite.org] On Behalf Of ???
>> Sent: 02 September 2014 13:41
>> To: General Discussion of SQLite Database
>> Subject: Re: [sqlite] HELP sqlite3 used in vxworks has some problem
>> 
>> 
>> 
>> firstly :
>> Even if I used
>> #if OS_VXWORKS
>> || osAccess(zPath,0) != 0
>> #endif
>> 
>> 
>> or I used
>> #if OS_VXWORKS
>> }else if(errno == 0x380003 || errno == 13 )
>>   rc  = SQLITE_IOERR_DELETE_NOENT:
>> #endif
>> 
>> 
>> Without the SQLITE_ENABLE_LOCKING_STYLE compile option, I tried the
>> above two method, but  it still told me the error : disk I/o error.
>> 
>
>If you read what I wrote in the email you are answering, you will see that the 
>problem is that the host file system does not support fsync.
>
>So the short answer is that you cannot use SQLite with a database that is 
>stored on your host PC. You must use a file system that is part of the target 
>system.
>
>Regards
>
>Andy Ling
>
>___
>sqlite-users mailing list
>sqlite-users@sqlite.org
>http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] HELP sqlite3 used in vxworks has some problem

2014-09-02 Thread Andy Ling
> -Original Message-
> From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-
> boun...@sqlite.org] On Behalf Of ???
> Sent: 02 September 2014 13:41
> To: General Discussion of SQLite Database
> Subject: Re: [sqlite] HELP sqlite3 used in vxworks has some problem
> 
> 
> 
> firstly :
> Even if I used
> #if OS_VXWORKS
> || osAccess(zPath,0) != 0
> #endif
> 
> 
> or I used
> #if OS_VXWORKS
> }else if(errno == 0x380003 || errno == 13 )
>   rc  = SQLITE_IOERR_DELETE_NOENT:
> #endif
> 
> 
> Without the SQLITE_ENABLE_LOCKING_STYLE compile option, I tried the
> above two method, but  it still told me the error : disk I/o error.
> 

If you read what I wrote in the email you are answering, you will see that the 
problem is that the host file system does not support fsync.

So the short answer is that you cannot use SQLite with a database that is 
stored on your host PC. You must use a file system that is part of the target 
system.

Regards

Andy Ling

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


Re: [sqlite] Integrity check

2014-09-02 Thread Simon Slavin

On 2 Sep 2014, at 9:50am, Jan Slodicka  wrote:

> Simon Slavin-3 wrote
>> If possible, you should try to do your synchronisation when your app is
>> frontmost only.  However, I understand that this may not be appropriate
>> for your app.
> 
> Exactly, under normal circumstances the synchronization of our app is the
> topmost priority, hence we have to continue.

You may have done this already but I suspect that you need to read the section 
called 'Implementing Long-Running Background Tasks' from



carefully if you expect to do File IO and network traffic in the background.  
What you describe seems to be closest to 'Background fetch'.

iOS expects your application to call 
'beginBackgroundTaskWithName:expirationHandler:' when appropriate and to 
provide the expiration handler.  This allows you to have a task such as 
synchronisation executed irrelevant to whether the app is frontmost or not.  
You can then use 'backgroundTimeRemaining' to find out whether iOS is going to 
force-quit your app.  That way your background activities won't be terminated 
without warning.

Unfortunately I have no experience of implementing something like this but this 
page



looks interesting.

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


Re: [sqlite] HELP sqlite3 used in vxworks has some problem

2014-09-02 Thread 王庆刚


firstly :
Even if I used 
#if OS_VXWORKS
|| osAccess(zPath,0) != 0
#endif


or I used 
#if OS_VXWORKS
}else if(errno == 0x380003 || errno == 13 )
  rc  = SQLITE_IOERR_DELETE_NOENT:
#endif 


Without the SQLITE_ENABLE_LOCKING_STYLE compile option, I tried the above two 
method, but  it still told me the error : disk I/o error.


secondly,
I found another problem. When I download the *.out file, it tells me Unresolved 
Symbols List: sem_post, ftruncate, sem_trywait,sem_open.
when building with spec:PPC604gnu, have the above problem, build spec:SIMNTdiab 
do not. 









At 2014-09-01 11:40:53, "Andy Ling"  wrote:
>
>
>> -Original Message-
>> From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-
>> boun...@sqlite.org] On Behalf Of Richard Hipp
>> Sent: 01 September 2014 15:30
>> To: General Discussion of SQLite Database
>> Subject: Re: [sqlite] HELP sqlite3 used in vxworks has some problem
>> > > Please try the patch at
>> > >
>> http://www.sqlite.org/src/info/b0f6b91f36b503d8ba8d5257bb194f8c1afb483
>> > > 3 and
>> > > see if that fixes the problem.
>> > >
>> >
>> > I think that fixes unixDelete. Running on the vxWorks dosFs disk
>> > everything works as before.
>> >
>> > If I use the host filing system, then I think the delete of the
>> > non-existent file works, but it then fails in unixSync followed by a fail
>> > in unixDelete
>> >
>> > os_unix.c:27830: (35) full_fsync(/tgtsvr/testdb.sql-journal) -  (1034)
>> >
>> 
>> 
>> Error code 35 is ENOTSUP - fsync is apparently not supported on your
>> filesystem.
>> 
>
>OK. So it sounds like the answer to Wang Qinggang at the moment is that the 
>host filing system is not supported.
>
>I'm slightly surprised fsync isn't supported, but a quick test here proves 
>that it isn't. I will try and raise it with WindRiver and see what they say. 
>It may be a general problem with any network filing system under vxWorks.
>
>I'm happy that dosFs works. That's all I need for the time being.
>
>Regards
>
>Andy Ling
>
>
>___
>sqlite-users mailing list
>sqlite-users@sqlite.org
>http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Integrity check

2014-09-02 Thread Jan Slodicka
Thanks, Simon.


Simon Slavin-3 wrote
> If possible, you should try to do your synchronisation when your app is
> frontmost only.  However, I understand that this may not be appropriate
> for your app.

Exactly, under normal circumstances the synchronization of our app is the
topmost priority, hence we have to continue.




--
View this message in context: 
http://sqlite.1065341.n5.nabble.com/Integrity-check-tp77519p77644.html
Sent from the SQLite mailing list archive at Nabble.com.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] New wrapper library: QUINCE

2014-09-02 Thread Michael Shepanski

Hello,

I've just found the page 
http://www.sqlite.org/cvstrac/wiki?p=SqliteWrappers , which says "If you 
know of a driver or wrapper for SQLite that is not listed below, please 
feel free to add it to the list."


I would like to add an entry for quince, but I need to log in. Log in to 
what? How do I register? Or do I need to ask an authorized person to do it?


Thanks,
--- Michael


On 19/08/2014 8:18 AM, Michael Shepanski wrote:

Hi Sqliters,

I've released an open-source library called quince (QUeries In C++ 
Expressions) that lets you access sqlite3 easily from C++.  I know, I 
know: you've got plenty of those already, but this one is different I 
promise...


It's an EDSL (Embedded Domain-Specific Language), which lets you build 
sophisticated SQL features in C++ syntax with C++ data types, and it's 
also an ORM, which figures out how to represent your C++ 
structs/classes/tuples as multiple columns. It's a plain old library, 
so no special compiler and no code generation step. And fwiw it works 
with PostgreSQL too (and maybe other DBMSes in the future -- it's a 
matter of adding backend libraries).


It's all explained at http://quince-lib.com .

Cheers,
--- Michael Shepanski

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


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