[sqlite] PRAGMA synchronous = NORMAL and Error = 21

2007-11-18 Thread learning Sqlite3




Hello,

I use the function:

apr_dbd_query(driver, sqlite3, , "PRAGMA  synchronous = NORMAL");

But I always get the error and error code is 21. In addtion, rows=(null).

Does it mean I should insert some rows into SQlite3 before I use 
apr_dbd_query()?

Thanks!

_
Explore the seven wonders of the world
http://search.msn.com/results.aspx?q=7+wonders+world=en-US=QBRE

Re: [sqlite] Memory Usage

2007-11-18 Thread Jim Dodgen
One other note, just about all real-time systems limit the dynamic 
allocation of memory because you lose the deterministic behavior, 
typically all memory is allocated when the task starts, memory is 
usually managed internally in standard sized chunks.


Also for long running tasks (months/years) you would suffer 
fragmentation and for limited memory systems a malloc/new  may fail 
weeks after the task starts and that would not be pretty. Also it is 
very hard or even impossible to completely test,  it is best to design 
the problem out.


Thus it is nice to have the ability to turnoff sqlite's ability to malloc

D. Richard Hipp wrote:


On Nov 18, 2007, at 8:12 AM, Russell Leighton wrote:



On Nov 17, 2007, at 4:56 PM, [EMAIL PROTECTED] wrote:



If you compile with -DSQLITE_MEMORY_SIZE= then SQLite
will *never* call malloc().  Instead, it uses a static
array that is  bytes in size for all of its memory
needs.  You can get by with as little as 100K or so of
memory, though the more memory you provide, the faster
it will run.  5MB is a good value.



Does using this setting (and eliminating malloc/free overhead) result
in a significant performance increase?


That depends on how good of a malloc you have on your system.
On Linux systems that typically use Doug Lea's malloc, there is
no measurable performance difference.  But I have had some
people running embedded systems tell me that using the
malloc-free SQLite results in a significant speed boost.  Your
mileage may vary.

D. Richard Hipp
[EMAIL PROTECTED]




- 


To unsubscribe, send email to [EMAIL PROTECTED]
- 








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



[sqlite] Re: Any way to obtain explicit read lock?

2007-11-18 Thread Igor Tandetnik

Igor Sereda <[EMAIL PROTECTED]> wrote:

Suppose we need to read two tables in an isolated way, so no db
change is visible to the connection between first and second readout.
As far as I see, there's no such SQL or API for that at the moment.  


Just do both SELECT's within a single transaction. See BEGIN, COMMIT

Igor Tandetnik

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



[sqlite] Re: building a custom DBD::SQLite

2007-11-18 Thread P Kishor
On Nov 18, 2007 2:59 PM, P Kishor <[EMAIL PROTECTED]> wrote:
> On Nov 17, 2007 2:22 PM, P Kishor <[EMAIL PROTECTED]> wrote:
> > I need to build a DBD::SQLite package using SQLite with fts
> > capabilities. Can someone on this list kindly give me painless, easy
> > to understand instructions to do so? I need to do this on a Mac OS X
> > 10.4 first, and then on my web host subsequently (running some flavor
> > of Linux, natch).
> >
>
>
> ok, let's try this again.
>
> I found instructions for building a loadable extension at
> 
>
> Note to Richard on the subject of improving the website -- please make
> such instructions easier to find by perhaps linking them somewhere
> prominently under "building or compiling" right off the download page
> for the source code.
>
> That said, I tried to build the fts2 extension and got the following --
>
> $ tar xvzf sqlite-3.4.2
> $ mkdir sqlite-3.4.2-build
> $ cd sqlite-3.4.2
> 
> 
> $ cd ..
> $ cd sqlite-3.4.2-build
> $ ../sqlite-3.4.2/configure LIBS=-ldl
> $ make
> $ export LD_LIBRARY_PATH="`pwd`:$LD_LIBRARY_PATH"
> $ gcc -I`pwd` -shared ../sqlite-3.4.2/ext/fts2/fts2.c -o fts2.so
> i686-apple-darwin8-gcc-4.0.1: unrecognized option '-shared'
> /usr/bin/ld: Undefined symbols:
> _main
> _sqlite3Fts2HashClear
> _sqlite3Fts2HashFind
> _sqlite3Fts2HashInit
> _sqlite3Fts2HashInsert
> _sqlite3Fts2InitHashTable
> _sqlite3Fts2PorterTokenizerModule
> _sqlite3Fts2SimpleTokenizerModule
> collect2: ld returned 1 exit status
>
>
> so, this is the first step that I have surmount. Once this is done, I
> would really like fts2 to not be shared but be permanently jammed into
> sqlite3 so I don't have to load it manually (unless, there is any
> significant advantage to building a shared library).

this is getting more and more a happy waste of time (hopefully I would
have learned something out of this). After much searching, I found Joe
Wilson's instructions at


Following those pretty much to the t, I almost got everything working.
Except, I got the following during make

../sqlite-3.5.2/ext/fts1/fts1.c:7:2: error: #error fts1 has a design
flaw and has been deprecated.
make: *** [fts1.lo] Error 1

Fantastic. If it is has a design flaw and has been deprecated, then
why include it? Or, if it is included, where is the information that
it has been deprecated that one can read *before* doing make?

Anyway, I went back into Makefile.in and commented out all references
to fts1 and ran make again. This time I got

../sqlite-3.5.2/ext/fts2/fts2.c:7:2: error: #error fts2 has a design
flaw and has been deprecated.
make: *** [fts2.lo] Error 1

So, I went back into the ext library and discovered that there was
fts3. So, I went back into Makefile.in and commented out all
references to fts2, added similar looking lines for fts3 and ran make
again. This time it all worked. Great!

Well, not so great. Now when I run the new sqlite3, I get the following

dyld: lazy symbol binding failed: Symbol not found: _sqlite3Fts1Init
  Referenced from:
/Users/punkish/Projects/sqlite-3.5.2-build/.libs/libsqlite3.0.dylib
  Expected in: flat namespace

dyld: Symbol not found: _sqlite3Fts1Init
  Referenced from:
/Users/punkish/Projects/sqlite-3.5.2-build/.libs/libsqlite3.0.dylib
  Expected in: flat namespace

Trace/BPT trap

If I can get some clear instructions on how to do this successfully, I
promise to record them on the wiki for other poor souls who might try
this.

Many thanks in advance.

And, oh yes, still will need help with the following once the above is possible.


>
> Once I am successful with the above, I would like to build a
> DBD::SQLite with my new library.
>
> Many thanks for your guidance.
>
> --
> Puneet Kishor
>

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



[sqlite] Any way to obtain explicit read lock?

2007-11-18 Thread Igor Sereda

Suppose we need to read two tables in an isolated way, so no db change is 
visible to the connection between first and second readout. As far as I see, 
there's no such SQL or API for that at the moment. 

In other words:

1: // with the first step() the read lock is taken:
2: while(stmt1.step()) { read(stmt1); }   
3: // with the last step() the read lock has been released

4: // with the first step() the read lock is taken again, but...
5: // there might have been changes since line 3
6: while(stmt2.step()) { read(stmt2); }   

So if there's some constraints between tables read with these two statements, 
we can get an inconsistent readout.

One obvious workaround would be to keep a dummy table, like Oracle's "dual", 
and take one step() reading it to retrieve read lock, then release read lock by 
resetting this statement. Of course we can "begin immediate", but since no 
writing is going to be done, obtaining reserved lock will be a waste.

My question, is there maybe any direct way to obtain a read lock, which I 
missed from the docs? If not, can this be a minor feature request?

Thanks!
Igor


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



[sqlite] Re: building a custom DBD::SQLite

2007-11-18 Thread P Kishor
On Nov 17, 2007 2:22 PM, P Kishor <[EMAIL PROTECTED]> wrote:
> I need to build a DBD::SQLite package using SQLite with fts
> capabilities. Can someone on this list kindly give me painless, easy
> to understand instructions to do so? I need to do this on a Mac OS X
> 10.4 first, and then on my web host subsequently (running some flavor
> of Linux, natch).
>


ok, let's try this again.

I found instructions for building a loadable extension at


Note to Richard on the subject of improving the website -- please make
such instructions easier to find by perhaps linking them somewhere
prominently under "building or compiling" right off the download page
for the source code.

That said, I tried to build the fts2 extension and got the following --

$ tar xvzf sqlite-3.4.2
$ mkdir sqlite-3.4.2-build
$ cd sqlite-3.4.2


$ cd ..
$ cd sqlite-3.4.2-build
$ ../sqlite-3.4.2/configure LIBS=-ldl
$ make
$ export LD_LIBRARY_PATH="`pwd`:$LD_LIBRARY_PATH"
$ gcc -I`pwd` -shared ../sqlite-3.4.2/ext/fts2/fts2.c -o fts2.so
i686-apple-darwin8-gcc-4.0.1: unrecognized option '-shared'
/usr/bin/ld: Undefined symbols:
_main
_sqlite3Fts2HashClear
_sqlite3Fts2HashFind
_sqlite3Fts2HashInit
_sqlite3Fts2HashInsert
_sqlite3Fts2InitHashTable
_sqlite3Fts2PorterTokenizerModule
_sqlite3Fts2SimpleTokenizerModule
collect2: ld returned 1 exit status


so, this is the first step that I have surmount. Once this is done, I
would really like fts2 to not be shared but be permanently jammed into
sqlite3 so I don't have to load it manually (unless, there is any
significant advantage to building a shared library).

Once I am successful with the above, I would like to build a
DBD::SQLite with my new library.

Many thanks for your guidance.

--
Puneet Kishor

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



Re: [sqlite] Lemon problem

2007-11-18 Thread Téragone
Hello,

I finally find the bug. In fact that was many bugs.

- Grammar rule order.
- Input string not reseted properly.

Thank you.

David
On Nov 18, 2007 10:30 AM, Joe Wilson <[EMAIL PROTECTED]> wrote:

> It's most likely your bug. Just add some debug prints in your grammar
> and tokenizer to see what's going on.
> See also: ParseTrace() in http://www.hwaci.com/sw/lemon/lemon.html
>
> --- Téragone <[EMAIL PROTECTED]> wrote:
> > I have a problem with a rule of a small calculator which accept
> variables :
> >
> > assignment(A) ::= VARIABLE(C) EQUAL expr(B).
> >
> > I can set variable with simple value or expression like :
> > a=2
> > b=2+3
> >
> > but when I try :
> > c=a+b
> >
> > The result is put in variable b instead of c.
> >
> > Is it my bug or a Lemon bug ?
>
>
>
>
>  
> 
> Be a better pen pal.
> Text or chat with friends inside Yahoo! Mail. See how.
> http://overview.mail.yahoo.com/
>
>
> -
> To unsubscribe, send email to [EMAIL PROTECTED]
>
> -
>
>


Re: [sqlite] Memory Usage

2007-11-18 Thread D. Richard Hipp


On Nov 18, 2007, at 8:12 AM, Russell Leighton wrote:



On Nov 17, 2007, at 4:56 PM, [EMAIL PROTECTED] wrote:



If you compile with -DSQLITE_MEMORY_SIZE= then SQLite
will *never* call malloc().  Instead, it uses a static
array that is  bytes in size for all of its memory
needs.  You can get by with as little as 100K or so of
memory, though the more memory you provide, the faster
it will run.  5MB is a good value.



Does using this setting (and eliminating malloc/free overhead) result
in a significant performance increase?


That depends on how good of a malloc you have on your system.
On Linux systems that typically use Doug Lea's malloc, there is
no measurable performance difference.  But I have had some
people running embedded systems tell me that using the
malloc-free SQLite results in a significant speed boost.  Your
mileage may vary.

D. Richard Hipp
[EMAIL PROTECTED]




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



Re: [sqlite] Lemon problem

2007-11-18 Thread Joe Wilson
It's most likely your bug. Just add some debug prints in your grammar 
and tokenizer to see what's going on.
See also: ParseTrace() in http://www.hwaci.com/sw/lemon/lemon.html

--- Téragone <[EMAIL PROTECTED]> wrote:
> I have a problem with a rule of a small calculator which accept variables :
> 
> assignment(A) ::= VARIABLE(C) EQUAL expr(B).
> 
> I can set variable with simple value or expression like :
> a=2
> b=2+3
> 
> but when I try :
> c=a+b
> 
> The result is put in variable b instead of c.
> 
> Is it my bug or a Lemon bug ?



  

Be a better pen pal. 
Text or chat with friends inside Yahoo! Mail. See how.  
http://overview.mail.yahoo.com/

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



[sqlite] Lemon problem

2007-11-18 Thread Téragone
Hello,

I have a problem with a rule of a small calculator which accept variables :

assignment(A) ::= VARIABLE(C) EQUAL expr(B).

I can set variable with simple value or expression like :
a=2
b=2+3

but when I try :
c=a+b

The result is put in variable b instead of c.

Is it my bug or a Lemon bug ?

Thank you,
David


Re: [sqlite] Memory Usage

2007-11-18 Thread Russell Leighton


On Nov 17, 2007, at 4:56 PM, [EMAIL PROTECTED] wrote:



If you compile with -DSQLITE_MEMORY_SIZE= then SQLite
will *never* call malloc().  Instead, it uses a static
array that is  bytes in size for all of its memory
needs.  You can get by with as little as 100K or so of
memory, though the more memory you provide, the faster
it will run.  5MB is a good value.



Does using this setting (and eliminating malloc/free overhead) result
in a significant performance increase?


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



[sqlite] fts table insert performance

2007-11-18 Thread Wang Yun
Hi

I insert rfc txt files into a full text search table, 4119 txt files are
188MB totally. After insert, database file is 443MB.
Logic is below, it's not the real code.


BEGIN_TRANSACTION

CREATE TABLE Notes ( rowid INTEGER PRIMARY KEY, docid, CreateTime,
LastModifyTime )
CREATE VIRTUAL TABLE NotesFTS using fts2( Title, Content )

for( 4119 txt file )
{
open and read file content into a string

INSERT INTO NotesFTS ( Title, Content ) VALUES ( ..., ... )
INSERT INTO Notes ( docid, CreateTime, LastModifyTime ) VALUES (
last_insert_id, DATETIME('NOW'), DATETIME('NOW') )
}

COMMIT


This cost 154 seconds, I use fts2 and my PC is Intel 2.33GHz, 2 CPUs.
If I don't use fts, just insert into normal table, will cost 11 seconds.

I don't know when sqlite will update the full text index, after each insert?
How can I improve the performance?

Thanks,
Wang Yun




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