Re: [sqlite] Unexpected sqlite3_trace_v2 sqlite3_expanded_sql output.

2018-06-22 Thread Lodewijk Duymaer van Twist
Hi Clemens and Richard, 

I have not read the SQLITE_TRACE_STMT documentation well enough they where 
triggers containt in (X).. 

Thanks. 

Lodewijk 


Van: "Clemens Ladisch"  
Aan: "sqlite-users"  
Verzonden: Vrijdag 22 juni 2018 12:19:18 
Onderwerp: Re: [sqlite] Unexpected sqlite3_trace_v2 sqlite3_expanded_sql 
output. 

Lodewijk Duymaer van Twist wrote: 
> I'm tracing queries that my application makes using sqlite3_trace_v2 and 
> sqlite3_expanded_sql in the callback. The application uses sqlite 3.22.0. 
> 
> At some point the software will call sqlite3_exec with the following 
> statement: 
> BEGIN TRANSACTION; 
> DELETE FROM call_lists WHERE id = 11; 
> END TRANSACTION; 
> 
> The output of sqlite3_expanded_sql is: 
> BEGIN TRANSACTION; 
> DELETE FROM call_lists WHERE id = 11; 
> DELETE FROM call_lists WHERE id = 11; 
> DELETE FROM call_lists WHERE id = 11; 
> DELETE FROM call_lists WHERE id = 11; 
> END TRANSACTION; 
> 
> Is this normal explaiable behaviour or should I try to provide a repo? 

Are you tracing multiple SQLITE_TRACE_xxx events? 

And <https://www.sqlite.org/c3ref/c_trace.html> says: 
| An SQLITE_TRACE_STMT callback is invoked when a prepared statement first 
| begins running and possibly at other times during the execution of the 
| prepared statement, such as at the start of each trigger subprogram. 


Regards, 
Clemens 
___ 
sqlite-users mailing list 
sqlite-users@mailinglists.sqlite.org 
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users 
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Unexpected sqlite3_trace_v2 sqlite3_expanded_sql output.

2018-06-22 Thread Lodewijk Duymaer van Twist

Hi, 

I'm tracing queries that my application makes using sqlite3_trace_v2 and 
sqlite3_expanded_sql in the callback. The application uses sqlite 3.22.0. 

At some point the software will call sqlite3_exec with the following statement: 
BEGIN TRANSACTION; 
DELETE FROM call_lists WHERE id = 11; 
END TRANSACTION; 

The output of sqlite3_expanded_sql is: 
BEGIN TRANSACTION; 
DELETE FROM call_lists WHERE id = 11; 
DELETE FROM call_lists WHERE id = 11; 
DELETE FROM call_lists WHERE id = 11; 
DELETE FROM call_lists WHERE id = 11; 
END TRANSACTION; 

Is this normal explaiable behaviour or should I try to provide a repo? 

Kind regards, 

Lodewijk 



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


[sqlite] Question about using json_remove to remove items from an array

2018-01-15 Thread Lodewijk Duymaer van Twist
Hi All,

I have a question about removing items from a array.

I'm using creating json_object queries to push the results directly into 
protobuf messages. Long story short, I've used a view to workaround the 
arbitrary order of json_group_array using a some sequence nr to order by (Is 
this bad?), resulting in a json_object with a variable length item array in it. 
Now I would like to remove te sequence numbers from the array object.

Lets say I have this json object value:
CREATE TABLE "test_json" ( "json" TEXT );
INSERT INTO test_json (json) VALUES ('{ "name": "Some list", "items": 
[{"somevalue": 3,"sequence": 1,"someboolean": true}, {"somevalue": 
5,"sequence": 2,"someboolean": false}] }' );

How would I go about removing the sequence numbers from this object? 

Kind regards,

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


Re: [sqlite] Using .testcase and .check in continuous integration test

2017-10-17 Thread Lodewijk Duymaer van Twist
Hi Dominique, 

Thank you for investigating. You're fix works. Should I repost this as a bug 
with your fix, or will this be picked up as is right now? 

Kind regard, 

Lodewijk 


Van: "Dominique Devienne" <ddevie...@gmail.com> 
Aan: "sqlite-users" <sqlite-users@mailinglists.sqlite.org> 
Verzonden: Dinsdag 17 oktober 2017 13:38:13 
Onderwerp: Re: [sqlite] Using .testcase and .check in continuous integration 
test 

On Tue, Oct 17, 2017 at 12:30 PM, Lodewijk Duymaer van Twist < 
lodew...@adesys.nl> wrote: 

> That would be an other way, but what I'm looking for is using the Command 
> Line Shell ".testcase" and ".check" method. 
> 

OK. That's new information :) 


> Create an example test file: 
> echo ".testcase 100 
> SELECT (1,2,3)<(1,2,4), (1,2,3)<(1,NULL,4), (1,2,3)<(2,NULL,1); 
> .check 1||1 
> 
> .testcase 110 
> SELECT (1,2,3)<(1,2,4), (1,2,3)<(1,NULL,4), (1,2,3)<(2,NULL,1); 
> .check 1|5|1" > test-script.sql 
> 
> Execute the test: 
> sqlite3 < test-script.sql 
> 
> Bail will not work for that. 
> 

shell.c needs to change for that, by 1 character I believe, in 
do_meta_command. 
In case of a failure, set rc to 1 instead of 2. That way the shell no 
longer exits 
with 0, but 1, i.e. an error. 

I'm actually surprised the result of do_meta_command() is not subject to 
.bail, 
and always exits if non-zero. 

Either do those changes yourself in your locally compiled shell, 
or hope Richard agrees the behavior should change. --DD 

rc = do_meta_command(azCmd[i], ); 
if( rc ) return rc==2 ? 0 : rc; 

static int do_meta_command(char *zLine, ShellState *p){ 
... 
/* Cancel output redirection, if it is currently set (by .testcase) 
** Then read the content of the testcase-out.txt file and compare against 
** azArg[1]. If there are differences, report an error and exit. 
*/ 
if( c=='c' && n>=3 && strncmp(azArg[0], "check", n)==0 ){ 
char *zRes = 0; 
output_reset(p); 
if( nArg!=2 ){ 
raw_printf(stderr, "Usage: .check GLOB-PATTERN\n"); 
rc = 2; 
}else if( (zRes = readFile("testcase-out.txt", 0))==0 ){ 
raw_printf(stderr, "Error: cannot read 'testcase-out.txt'\n"); 
rc = 2; 
}else if( testcase_glob(azArg[1],zRes)==0 ){ 
utf8_printf(stderr, 
"testcase-%s FAILED\n Expected: [%s]\n Got: [%s]\n", 
p->zTestcase, azArg[1], zRes); 
rc = 2; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< change to 1 
}else{ 
utf8_printf(stdout, "testcase-%s ok\n", p->zTestcase); 
p->nCheck++; 
} 
sqlite3_free(zRes); 
}else 
... 

meta_command_exit: 
if( p->outCount ){ 
p->outCount--; 
if( p->outCount==0 ) output_reset(p); 
} 
return rc; 
} 
___ 
sqlite-users mailing list 
sqlite-users@mailinglists.sqlite.org 
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users 
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Using .testcase and .check in continuous integration test

2017-10-17 Thread Lodewijk Duymaer van Twist
Hi Dominique, 

That would be an other way, but what I'm looking for is using the Command Line 
Shell ".testcase" and ".check" method. 

Create an example test file: 
echo ".testcase 100 
SELECT (1,2,3)<(1,2,4), (1,2,3)<(1,NULL,4), (1,2,3)<(2,NULL,1); 
.check 1||1 

.testcase 110 
SELECT (1,2,3)<(1,2,4), (1,2,3)<(1,NULL,4), (1,2,3)<(2,NULL,1); 
.check 1|5|1" > test-script.sql 

Execute the test: 
sqlite3 < test-script.sql 

Bail will not work for that. 

Kind regards, 

Lodewijk 


Van: "Dominique Devienne" <ddevie...@gmail.com> 
Aan: "sqlite-users" <sqlite-users@mailinglists.sqlite.org> 
Verzonden: Maandag 16 oktober 2017 13:49:18 
Onderwerp: Re: [sqlite] Using .testcase and .check in continuous integration 
test 

On Mon, Oct 16, 2017 at 12:32 PM, Lodewijk Duymaer van Twist < 
lodew...@adesys.nl> wrote: 

> I would like use .testcase and .check in our GitLab Continuous Integration 
> test. 
> 
> GitLab pipelines will check process return code for success or fail. 
> 
> Consider a simple test: 
> lodewijk@DebianDev:~$ sqlite3 database.db3 < test.sql 
> testcase-100 ok 
> testcase-110 ok 
> lodewijk@DebianDev:~$ echo $? 
> 0 
> 
> Now if I would have a failure the return value of the sqlite3 process will 
> also be 0: 
> lodewijk@DebianDev:~$ sqlite3 octalarm.db3 < test/test-languages.sql 
> testcase-100 FAILED 
> Expected: [66] 
> Got: [67 
> ] 
> lodewijk@DebianDev:~$ echo $? 
> 0 
> 
> Is there a nice elegant way of making my CI stop on a failure? 
> 

C:\Users\ddevienne>sqlite3 -bail bad.db "create table foo(id)" && echo OK 
OK 

C:\Users\ddevienne>sqlite3 -bail bad.db "create table bar" && echo OK 
Error: near "bar": syntax error 

C:\Users\ddevienne> 
___ 
sqlite-users mailing list 
sqlite-users@mailinglists.sqlite.org 
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users 
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Using .testcase and .check in continuous integration test

2017-10-16 Thread Lodewijk Duymaer van Twist
I would like use .testcase and .check in our GitLab Continuous Integration 
test. 

GitLab pipelines will check process return code for success or fail. 

Consider a simple test: 
lodewijk@DebianDev:~$ sqlite3 database.db3 < test.sql 
testcase-100 ok 
testcase-110 ok 
lodewijk@DebianDev:~$ echo $? 
0 

Now if I would have a failure the return value of the sqlite3 process will also 
be 0: 
lodewijk@DebianDev:~$ sqlite3 octalarm.db3 < test/test-languages.sql 
testcase-100 FAILED 
Expected: [66] 
Got: [67 
] 
lodewijk@DebianDev:~$ echo $? 
0 

Is there a nice elegant way of making my CI stop on a failure? 

Kind regards, 

Lodewijk 

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


[sqlite] Well-Known Users of SQLite

2008-02-12 Thread Lodewijk Duymaer van Twist
Hi All,

I was just invited to use LiveStation (http://www.livestation.com/), the
LiveStation player installs sqlite3.dll. This might be why Microsoft
developers are seen in the sqlite mailing list.

http://www.livestation.com/news/18-livestation_showcased_at_microsoft_innova
tion_day

Kind regards,

Lodewijk

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


Re: [sqlite] SQLite version 3.5.6

2008-02-06 Thread Lodewijk Duymaer van Twist
Hello Richard,

I think http://www.sqlite.org/cvstrac/wiki?p=ToDo is due for an update.

Kind regards

Lodewijk


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED]
Sent: Wednesday, February 06, 2008 6:06 PM
To: sqlite-users@sqlite.org; [EMAIL PROTECTED];
[EMAIL PROTECTED]
Subject: [sqlite] SQLite version 3.5.6

SQLite version 3.5.6 is now available on the website.

http://www.sqlite.org/download.html

There is very little change from version 3.5.5.  The reason
for this release is that there was a regression in the virtual
table mechanism that prevented virtual tables from being used
in LEFT OUTER JOINs.  And there were some updates to the OS/2
driver.  Also, I bungled the release of version 3.5.5 such that
some users downloaded copies of 3.5.4 that were labeled 3.5.5.

We have still not encountered any bugs in new register-based
virtual machine.  You might recall that this was a huge change
moving from version 3.5.4 to 3.5.5 and there was some concern
that the change my destablize the core.  But such concern is
now past.  Version 3.5.6 is recommended for all users and is
consider stable and ready for production release.

As always, please report any problems to this mailing list,
or directly to me.

--
D. Richard Hipp <[EMAIL PROTECTED]>

___
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] mailing list slow?

2007-07-18 Thread Lodewijk Duymaer van Twist
I think that any e-mail should be delivered within a few seconds in this day
and age. Also real time mailing should improve discussions on the mailing
list.

Just an opinion.

Kind regards,

Lodewijk

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, July 18, 2007 7:39 PM
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] mailing list slow?

Joe Wilson <[EMAIL PROTECTED]> wrote:
> I noticed delays of an hour or so in posts hitting the mailing list
recently.
> Or is it just my mail server?
> 

The server (www.sqlite.org) seems to be doing OK.
Load average is 0.13.  Nothing unusual in the logs.

There are currently 1281 people on the mailing list.  The
mailing list manager (ezmlm) will send messages to at most
20 people at at time.  If each send requires 20 seconds,
that means about 1200 seconds to relay a message, or about
20 minutes.

Might be your mail server.  Spam loads continue to increase.
My spam/email ratio is approaching 30:1.  In other words, I
get about 30 spams for each legitimate email now.

--
D. Richard Hipp <[EMAIL PROTECTED]>



-
To unsubscribe, send email to [EMAIL PROTECTED]

-


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



RE: [sqlite] mailing list slow?

2007-07-18 Thread Lodewijk Duymaer van Twist
Same here

-Original Message-
From: Joe Wilson [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, July 18, 2007 6:01 PM
To: sqlite-users@sqlite.org
Subject: [sqlite] mailing list slow?

I noticed delays of an hour or so in posts hitting the mailing list
recently.
Or is it just my mail server?


 


Be a PS3 game guru.
Get your game face on with the latest PS3 news and previews at Yahoo! Games.
http://videogames.yahoo.com/platform?platform=120121


-
To unsubscribe, send email to [EMAIL PROTECTED]

-


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



RE: [sqlite] Sharing an in-memory database between applications

2007-07-17 Thread Lodewijk Duymaer van Twist
Hi Rob,

This maybe a dumb idea but have you tried a software RAM disk? Or maybe even
a physical RAM disk. 

http://www.tomshardware.com/2005/09/07/can_gigabyte/index.html

Kind Regards,

Lodewijk


-Original Message-
From: Rob Richardson [mailto:[EMAIL PROTECTED] 
Sent: Friday, July 13, 2007 5:35 PM
To: sqlite-users@sqlite.org
Subject: [sqlite] Sharing an in-memory database between applications

Greetings!

We are using an SQLite database to store process data that will
eventually be displayed on a graph.  The database design is simple,
including only six tables, but the table containing the data points for
the graph could contain a few million records.  By using the simplest
possible query and asking for the bare minimum of data I need at any one
point, I've managed to get the time to display the graph down from a few
minutes to about 15 seconds for a sample database with 1.3 million
records.  

But I'm wondering if I can use an in-memory database to improve this
dramatically.  The data is collected by a Windows service that collects
data and adds it to the database once a minute.  If the service would
also store the data into an in-memory database, and the graphing
application could somehow read the same database, I ought to be able to
get unbelievable speed.  Is this feasible?  If so, how would I set it
up?

Another possibility might be to read the entire database from disk into
an in-memory database when the graphing application starts up, if
there's a way to do that that is much faster than a set of INSERT INTO
newtable SELECT * FROM oldtable (or whatever -- you get the idea)
statements.

Thank you very much.

Rob Richardson
RAD-CON INC.


-
To unsubscribe, send email to [EMAIL PROTECTED]

-


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



RE: [sqlite] Re: R: Re: [sqlite] How to compile sqlite3 C sample code

2006-08-28 Thread Lodewijk Duymaer van Twist
Hi,

How about downloading the sample code from www.apress.com

http://www.apress.com/book/supplementDownload.html?bID=10130=3537

Nice book, try getting it.

Kind regards,

Lodewijk

-Original Message-
From: Tikky [mailto:[EMAIL PROTECTED] 
Sent: Monday, August 28, 2006 2:18 AM
To: sqlite-users@sqlite.org
Subject: [sqlite] Re: R: Re: [sqlite] How to compile sqlite3 C sample code


Hi,
I am also one of SQLilte User. I am struggling to compile c code for sqlite.
If you don't mind , please send me c code to compile.
 i am waiting for ur reply.
thanks

[EMAIL PROTECTED] wrote:
> 
> Thanks for your fast response.
> Now I can compile and test program works 
> fine, but.
> When I run: test test.db "select * from tbl1"
> sqlite3_exec function give me follow error: Unsupported file format.
> 
> If I run this query using sqlite3 interactive program all works fine.
> test.db contatins only tlb1 whith 2 coloumns and 2 records.
> 
> Any 
> Suggestions ?
> 
> 
> Messaggio originale
> Da: [EMAIL PROTECTED]
> Data: 
> 26-gen-2006 5.57 PM
> A: 
> Ogg: Re: [sqlite] How 
> to compile sqlite3 C sample code
> 
> On Jan 26, 2006, at 11:03 AM, 
> [EMAIL PROTECTED] wrote:
> 
>> I'm a novice and after compiled and correctly 
> installed SQLite 3.x,
>> i've tried to compile sample C++ program found 
> in Quickstart page.
>> I've
>> got Linker errors, like follows:
>>
>> 
> /home/etrax/tmp/cckIV5JC.o: In
>> function `main':
>> t.c:(.text+0xd6): 
> undefined reference to
>> `sqlite3_open'
>> t.c:(.text+0xee): undefined 
> reference to
>> `sqlite3_errmsg'
>> t.c:(.text+0x115): undefined 
> reference to
>> `sqlite3_close'
>> t.c:(.text+0x142): undefined reference 
> to
>> `sqlite3_exec'
>> t.c:(.text+0x175): undefined reference to
>> 
> `sqlite3_close'
>> collect2: ld returned 1 exit status
>>
>> Any 
> suggestions ?
>> I've compiled sqlite3 without errors and using sqlite3 
> I've created  
>> and
>> I can use a testDB.
>>
>> Regards
> 
> You need to 
> tell the linker that you're using the SQLite library, and  
> possibly 
> where to find that library.
> 
> To tell the linker you're using SQLite, 
> just add to your LDFLAGS '- 
> lsqlite3'. If the linker still can't seem 
> to find the sqlite3  
> library, you may also need to add '-
> L/usr/local/lib' (assuming you  
> installed SQLite into /usr/local, 
> which is the default destination).
> 
> A complete makefile might be as 
> simple as the following line:
> LDFLAGS = -L/usr/local/lib -lsqlite3
> 
> Then, just 'make t' should compile and link your test program 
> correctly.
> HTH,
> -MIke Ashmore
> 
> 
> 
> 
> 

-- 
View this message in context:
http://www.nabble.com/R%3A-Re%3A--sqlite--How-to-compile-sqlite3-C-sample-co
de-tf1009320.html#a6016846
Sent from the SQLite forum at Nabble.com.



-
To unsubscribe, send email to [EMAIL PROTECTED]

-


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



RE: [sqlite] Database locked. Any idea ?

2006-06-20 Thread Lodewijk Duymaer van Twist
Hi,

I don't know if I can help you with your problem, but I'm interested in what
you are trying to do, are u using uCos on a Z-World based system?

Kind regards,

Lodewijk Duymaer van Twist



RE: [sqlite] WAKEUP !!! SOMEBODY IS DESTROYING THE WIKI PAGES

2006-03-30 Thread Lodewijk Duymaer van Twist
Someone was filling them with porn links, but they have been restored now.

Kind regards,

Lodewijk

-Original Message-
From: Bert Verhees [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 30, 2006 1:15 PM
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] WAKEUP !!! SOMEBODY IS DESTROYING THE WIKI PAGES

Lodewijk Duymaer van Twist wrote:

> 
>
>
>  
>
Looks strange, many changes now, today, in short time. But I cannot 
judge what is changed, some one should take a look at it.

Bert

21:12   *   Wiki page SqliteCompetitors 
<http://www.sqlite.org/cvstrac/wiki?p=SqliteCompetitors> edited by 
anonymous
21:11   *   Wiki page SqlitePorts 
<http://www.sqlite.org/cvstrac/wiki?p=SqlitePorts> edited by anonymous
21:11   *   Wiki page SqliteReporting 
<http://www.sqlite.org/cvstrac/wiki?p=SqliteReporting> edited by anonymous
21:10   *   Wiki page SqliteNetwork 
<http://www.sqlite.org/cvstrac/wiki?p=SqliteNetwork> edited by anonymous
21:06   *   Wiki page DateAndTimeFunctions 
<http://www.sqlite.org/cvstrac/wiki?p=DateAndTimeFunctions> edited by 
anonymous
21:06   *   Wiki page ReadLine 
<http://www.sqlite.org/cvstrac/wiki?p=ReadLine> edited by anonymous
20:58   *   Wiki page SqliteTclPackageWrapper 
<http://www.sqlite.org/cvstrac/wiki?p=SqliteTclPackageWrapper> edited by 
anonymous
20:57   *   Wiki page MultiThreading 
<http://www.sqlite.org/cvstrac/wiki?p=MultiThreading> edited by anonymous
20:56   *   Wiki page SqliteUsers 
<http://www.sqlite.org/cvstrac/wiki?p=SqliteUsers> edited by anonymous
20:55   *   Wiki page SqliteCompetitors 
<http://www.sqlite.org/cvstrac/wiki?p=SqliteCompetitors> edited by 
anonymous
20:54   *   Wiki page SqlitePorts 
<http://www.sqlite.org/cvstrac/wiki?p=SqlitePorts> edited by anonymous
20:52   *   Wiki page SqliteReporting 
<http://www.sqlite.org/cvstrac/wiki?p=SqliteReporting> edited by anonymous
20:48   *   Wiki page SqliteNetwork 
<http://www.sqlite.org/cvstrac/wiki?p=SqliteNetwork> edited by anonymous
20:46   *   Wiki page DateAndTimeFunctions 
<http://www.sqlite.org/cvstrac/wiki?p=DateAndTimeFunctions> edited by 
anonymous





[sqlite] WAKEUP !!! SOMEBODY IS DESTROYING THE WIKI PAGES

2006-03-30 Thread Lodewijk Duymaer van Twist
 



RE: [sqlite] How to create a queue using Sqlite

2006-02-07 Thread Lodewijk Duymaer van Twist
Thanks this helps a lot! I'll get on it right away. 

Kind regards,

Lodewijk

-Original Message-
From: Christian Smith [mailto:[EMAIL PROTECTED] 
Sent: Monday, February 06, 2006 9:34 AM
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] How to create a queue using Sqlite

On Thu, 2 Feb 2006, Lodewijk Duymaer van Twist wrote:

>Hi,
>
>
>
>I would like to create some sort of queue using sqlite. I'm thinking about
>transmitting commands to hardware devices/managers using a queue table.
>
>Is it possible to trigger a function created with sqlite3_create_function
in
>one application by another application. Kind of like a plug-in application.


No. The function is associated with the database connection, and is
invoked by the sqlite VM of the compiled statement.


>
>
>
>Is this possible without polling the content of this queue table.


Question is, what's specifically wrong with polling?

Use an auto-increment integer primary key, then the queueing application
queues jobs by inserting them into the table (using NULL for the primary
key.)

The second application sits in a loop, reading the entries as they are
created using the primary auto-increment key to keep track of what has
already been processed. Pseudo code:

App 1:
void submit_job( args )
{
exec("insert into spool values ();");
}

App 2:
boolean process_jobs()
{
static int last_job = 0;
int prev_last_job = last_job;

// Get jobs to be processed into separate table
exec("begin");
exec("insert into temp_spool select * from spool where
id>$last_job");
exec("delete from spool where id>$last_job");
exec("commit;");

// Process jobs from separate table, then delete.
exec("begin");
foreach("select * from temp_spool;") {
last_job = id;
process job;
}
exec("delete from temp_spool;");
exec("commit;");

return ( last_job != prev_last_job );
}


In App2, process_jobs will return true if any jobs were processed, and
false otherwise. You'd test this return value and re-call process_jobs if
true as more jobs may have come in as you processed the last jobs:
App2:
while(1) {
if (!process_jobs) {
sleep(1);
}
}

This ensures you don't poll excessively when there ae no jobs coming, and
don't sleep unnecassarily when jobs are coming in steadily. You'd want the
temp_spool table in a seperate database, so as not to tie up the main
database while processing jobs.

Christian

-- 
/"\
\ /ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL
 X   - AGAINST MS ATTACHMENTS
/ \



[sqlite] How to create a queue using Sqlite

2006-02-02 Thread Lodewijk Duymaer van Twist
Hi,

 

I would like to create some sort of queue using sqlite. I'm thinking about
transmitting commands to hardware devices/managers using a queue table. 

Is it possible to trigger a function created with sqlite3_create_function in
one application by another application. Kind of like a plug-in application. 

 

Is this possible without polling the content of this queue table.

 

Kind regards,

 

Lodewijk Duymaer van Twist