Re: [sqlite] Bug on "!" unary prefix operator?
--- Ken <[EMAIL PROTECTED]> wrote: > SQLite documentation indicates that "!" is a unary prefix operator. Is this > a bug? Yeah, the docs seem to indicate that SQLite supports '!'. http://sqlite.org/lang_expr.html: Supported unary prefix operators are these: -+!~NOT If you care to have this operator, see attached patch. This unary '!' operator works like the NOT operator except it has the same precedence level as the unary bitwise not operator '~'. sqlite> select !!23; 1 sqlite> select !0 + !0; 2 sqlite> select not 0 + not 0; 0 Be a better pen pal. Text or chat with friends inside Yahoo! Mail. See how. http://overview.mail.yahoo.com/Index: src/parse.y === RCS file: /sqlite/sqlite/src/parse.y,v retrieving revision 1.236 diff -u -3 -p -r1.236 parse.y --- src/parse.y 17 Nov 2007 22:23:28 - 1.236 +++ src/parse.y 18 Nov 2007 05:33:03 - @@ -205,7 +205,7 @@ id(A) ::= ID(X). {A = X;} %left STAR SLASH REM. %left CONCAT. %left COLLATE. -%right UMINUS UPLUS BITNOT. +%right UMINUS UPLUS BITNOT UNOT. // And "ids" is an identifer-or-string. // @@ -746,6 +746,10 @@ expr(A) ::= BITNOT(B) expr(X). { A = sqlite3PExpr(pParse, @B, X, 0, 0); sqlite3ExprSpan(A,&B,&X->span); } +expr(A) ::= UNOT(B) expr(X). { + A = sqlite3PExpr(pParse, TK_NOT, X, 0, 0); + sqlite3ExprSpan(A,&B,&X->span); +} expr(A) ::= MINUS(B) expr(X). [UMINUS] { A = sqlite3PExpr(pParse, TK_UMINUS, X, 0, 0); sqlite3ExprSpan(A,&B,&X->span); Index: src/tokenize.c === RCS file: /sqlite/sqlite/src/tokenize.c,v retrieving revision 1.136 diff -u -3 -p -r1.136 tokenize.c --- src/tokenize.c 27 Aug 2007 23:26:59 - 1.136 +++ src/tokenize.c 18 Nov 2007 05:33:03 - @@ -203,12 +203,12 @@ static int getToken(const unsigned char } } case '!': { - if( z[1]!='=' ){ -*tokenType = TK_ILLEGAL; -return 2; - }else{ + if( z[1]=='=' ){ *tokenType = TK_NE; return 2; + }else{ +*tokenType = TK_UNOT; +return 1; } } case '|': { Index: test/main.test === RCS file: /sqlite/sqlite/test/main.test,v retrieving revision 1.27 diff -u -3 -p -r1.27 main.test --- test/main.test 3 Sep 2007 15:42:48 - 1.27 +++ test/main.test 18 Nov 2007 05:33:03 - @@ -267,7 +267,7 @@ do_test main-3.1 { sqlite3 db testdb set v [catch {execsql {SELECT * from T1 where x!!5}} msg] lappend v $msg -} {1 {unrecognized token: "!!"}} +} {1 {near "!": syntax error}} do_test main-3.2 { catch {db close} foreach f [glob -nocomplain testdb/*] {file delete -force $f} - To unsubscribe, send email to [EMAIL PROTECTED] -
[sqlite] SQL operator precedence
> I believe SQLite uses the same operator precedence as the SQL standard > requires. If I am wrong about that, please correct me and I will > change it. As I interpret the SQL92 standard (which I believe SQLite tries to follow), I think all comparison operators should have the same level of precedence: ::= | | | | | Nothing in the wording of the standard that I can find suggests that NE and EQ have a different precedence level from the other 4 comparison ops: %left IS MATCH LIKE_KW BETWEEN IN ISNULL NOTNULL NE EQ. %left GT LE LT GE. The following binary bitwise operators are outside of the SQL92 standard: <<, >> & | but many SQL implementations tend to adopt the C precedence rules in this case. Principle of least astonishment, I imagine. Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Memory Usage
Dr. Hipp, thanks, I'm sure I can use one or more of your solutions below to solve my problem... Scott SQLite does maintain a cache of the database file. It will hold up to 2000 pages by default. You can change the cache size by using the "PRAGMA cache_size=N" pragma. You can set N as small as 10. The cache does not grow beyond its limit. If you compile with -DSQLITE_ENABLE_MEMORY_MANAGMENT=1 the you can use the sqlite3_soft_heap_limit() interface to limit the total amount of memory SQLite will use. You can also use sqlite3_release_memory() to get SQLite to give up memory out of its cache. 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. In the next release, we might provide a new C interface or a pragma or both that will flush the cache. -- D. Richard Hipp <[EMAIL PROTECTED]> - To unsubscribe, send email to [EMAIL PROTECTED] - -- View this message in context: http://www.nabble.com/Memory-Usage-tf4822840.html#a13815730 Sent from the SQLite mailing list archive at Nabble.com. - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Trying to build a static library
On Nov 17, 2007 12:07 PM, A.J.Millan <[EMAIL PROTECTED]> wrote: > > sources/where.c: In function `int whereClauseInsert(WhereClause*, Expr*, > int)': > sources/where.c:231: error: invalid conversion from `void*' to `WhereTerm*' > My first guess is you are trying to compile it as C++. Otherwise I see no reason for that to fail. -- Cory Nelson - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Trying to build a static library
I use gcc for compiling Sqlite for both Windows and Linux and others. On Windoze I use Dev-Cpp as and IDE over the top of Mingw. You might look at the compiler options and ensure that you are just specifying plain vanilla ANSI C. A.J.Millan wrote: John: Thanks for your feedback, but the question is: are you compiling gcc in Linux or in Windows-32 with minGW? The problem is that I'm using the GNU gcc compiler under Windows (minGW), trying to build a static library as a C (not C++) project, and get a lot of compiler error. All related to type conversion. As an example here is the first: sources/where.c: In function `int whereClauseInsert(WhereClause*, Expr*, int)': sources/where.c:231: error: invalid conversion from `void*' to `WhereTerm*' Perhaps I'm missing some compiler option, but by the moment the system work pretty well compiling projects in both C and C++ using that platform. Some idea? I use static libraries and gcc. Just use --enable-static and you should get the link library created. A.J.Millan wrote: Hi all: Instead the supplied DLL, I would like to statically link the SQLite library in a new project, and I wonder if someone has build a SQLite static library xxx.a using minGW in Windows and the sources/headers contanied in the sqlite-source-3_5_2.zip Any tips on that are welcome. - To unsubscribe, send email to [EMAIL PROTECTED] - - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] sqlite and lemon operator precedence problem/question
On Nov 17, 2007, at 5:30 PM, Joe Wilson wrote: sqlite> select ~1 - ~5; -8 sqlite> select (~1) - (~5); 4 That would be a bug in lemon... I guess adopting the same operator precedence as MySQL or MS SQL Server is out of the question? I believe SQLite uses the same operator precedence as the SQL standard requires. If I am wrong about that, please correct me and I will change it. On the other hand, changing the operator precedence to agree with MySQL or MSSQL is not something we are interested in doing if they are using a non-standard precedence. D. Richard Hipp [EMAIL PROTECTED] - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] sqlite and lemon operator precedence problem/question
--- "D. Richard Hipp" <[EMAIL PROTECTED]> wrote: > I was wrong. Turns out the bug was in the SQLite grammar > file parse.y. It was assigning the same precedence to the > ones-complement ~ operator and the NOT operator. But > ~ should have higher precedence, it seems. Fixed by > check-in [4548]. Just to confirm, if you mix multiple operators in the same Lemon rule must you take manual precautions that they do not have different precedences? It would be pretty cool if that expansion could happen automatically since the action specified in the grammar is the same: original rule: expr(A) ::= NOT|BITNOT(B) expr(X). { A = sqlite3PExpr(pParse, @B, X, 0, 0); sqlite3ExprSpan(A,&B,&X->span); } your grammar correction: expr(A) ::= NOT(B) expr(X). { A = sqlite3PExpr(pParse, @B, X, 0, 0); sqlite3ExprSpan(A,&B,&X->span); } expr(A) ::= BITNOT(B) expr(X). { A = sqlite3PExpr(pParse, @B, X, 0, 0); sqlite3ExprSpan(A,&B,&X->span); } ...or perhaps have Lemon issue a warning of an operator precedence problem? Get easy, one-click access to your favorites. Make Yahoo! your homepage. http://www.yahoo.com/r/hs - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] sqlite and lemon operator precedence problem/question
> > sqlite> select ~1 - ~5; > > -8 > > sqlite> select (~1) - (~5); > > 4 > > > > That would be a bug in lemon... I guess adopting the same operator precedence as MySQL or MS SQL Server is out of the question? http://dev.mysql.com/doc/refman/5.0/en/operator-precedence.html BINARY, COLLATE ! - (unary minus), ~ (unary bit inversion) ^ *, /, DIV, %, MOD -, + <<, >> & | =, <=>, >=, >, <=, <, <>, !=, IS, LIKE, REGEXP, IN BETWEEN, CASE, WHEN, THEN, ELSE NOT &&, AND XOR ||, OR := http://msdn2.microsoft.com/en-us/library/ms190276.aspx Be a better sports nut! Let your teams follow you with Yahoo Mobile. Try it now. http://mobile.yahoo.com/sports;_ylt=At9_qDKvtAbMuh1G1SQtBI7ntAcJ - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] sqlite and lemon operator precedence problem/question
On Nov 17, 2007, at 5:12 PM, D. Richard Hipp wrote: On Nov 17, 2007, at 4:58 PM, Joe Wilson wrote: I'm having difficulty with Lemon's operator precedence. That would be a bug in lemon... I was wrong. Turns out the bug was in the SQLite grammar file parse.y. It was assigning the same precedence to the ones-complement ~ operator and the NOT operator. But ~ should have higher precedence, it seems. Fixed by check-in [4548]. D. Richard Hipp [EMAIL PROTECTED] - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] sqlite and lemon operator precedence problem/question
On Nov 17, 2007, at 4:58 PM, Joe Wilson wrote: I'm having difficulty with Lemon's operator precedence. Given SQLite's operator precedence table where it's presumably interpreted with lowest precedence tokens at the top to the highest precedence tokens at the bottom: %left OR. %left AND. %right NOT. %left IS MATCH LIKE_KW BETWEEN IN ISNULL NOTNULL NE EQ. %left GT LE LT GE. %right ESCAPE. %left BITAND BITOR LSHIFT RSHIFT. %left PLUS MINUS. %left STAR SLASH REM. %left CONCAT. %left COLLATE. %right UMINUS UPLUS BITNOT. Why doesn't the BITNOT operator '~' have the highest precedence? SQLite version 3.5.2 Enter ".help" for instructions sqlite> select ~1 - ~5; -8 sqlite> select (~1) - (~5); 4 That would be a bug in lemon... D. Richard Hipp [EMAIL PROTECTED] - To unsubscribe, send email to [EMAIL PROTECTED] -
[sqlite] sqlite and lemon operator precedence problem/question
I'm having difficulty with Lemon's operator precedence. Given SQLite's operator precedence table where it's presumably interpreted with lowest precedence tokens at the top to the highest precedence tokens at the bottom: %left OR. %left AND. %right NOT. %left IS MATCH LIKE_KW BETWEEN IN ISNULL NOTNULL NE EQ. %left GT LE LT GE. %right ESCAPE. %left BITAND BITOR LSHIFT RSHIFT. %left PLUS MINUS. %left STAR SLASH REM. %left CONCAT. %left COLLATE. %right UMINUS UPLUS BITNOT. Why doesn't the BITNOT operator '~' have the highest precedence? SQLite version 3.5.2 Enter ".help" for instructions sqlite> select ~1 - ~5; -8 sqlite> select (~1) - (~5); 4 Is precedence not determined by the order of the %left/%right lines in parse.y? If not, how might one assign BITNOT the highest precedence? MySQL, by comparison: mysql> select ~1 - ~5; +-+ | ~1 - ~5 | +-+ | 4 | +-+ mysql> select (~1) - (~5); +-+ | (~1) - (~5) | +-+ | 4 | +-+ MySQL operator precedence: http://dev.mysql.com/doc/refman/5.0/en/operator-precedence.html MS SQL Server precedence: http://msdn2.microsoft.com/en-us/library/ms190276.aspx Be a better sports nut! Let your teams follow you with Yahoo Mobile. Try it now. http://mobile.yahoo.com/sports;_ylt=At9_qDKvtAbMuh1G1SQtBI7ntAcJ - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Memory Usage
Raymond Hurst <[EMAIL PROTECTED]> wrote: > Hi Scott, > > Ooops..meant to say the following. > > My initial evaluation of this database was that it allocates memory for > each operation on the database. It returns the memory only when the > database is CLOSED. So the behavior you see is normal. > Ray Hurst > No. SQLite does maintain a cache of the database file. It will hold up to 2000 pages by default. You can change the cache size by using the "PRAGMA cache_size=N" pragma. You can set N as small as 10. The cache does not grow beyond its limit. If you compile with -DSQLITE_ENABLE_MEMORY_MANAGMENT=1 the you can use the sqlite3_soft_heap_limit() interface to limit the total amount of memory SQLite will use. You can also use sqlite3_release_memory() to get SQLite to give up memory out of its cache. 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. In the next release, we might provide a new C interface or a pragma or both that will flush the cache. -- D. Richard Hipp <[EMAIL PROTECTED]> - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Memory Usage
There must be a way to flush what ever is being cached. Help It's hard to believe I'm the only guy that wants to keep the database open and just do inserts, to save CPU time. Scott rhurst2 wrote: > > Hi Scott, > > Ooops..meant to say the following. > > My initial evaluation of this database was that it allocates memory for > each operation on the database. It returns the memory only when the > database is CLOSED. So the behavior you see is normal. > Ray Hurst > > ScottDerrick wrote: >> I am using sqlite3 in a DAQ device. Data can be viewed on the unit using >> a >> Rails enabled web server. >> >> The data is being stored to the database every 1 to 5 seconds. I wanted >> to >> leave the the database open for as long as teh application is running and >> then use a IMMEDIATE, PREPARE-INSERT(x), FINALIZE, COMMIT sequence. The >> application may run as long as 30 days at a time. >> >> To save disk access and CPU time I was not going to open and close the >> database for every insertion iteration. However I have noticed that my >> application seems use more and more memory as time goes bye. If I open >> and >> close the database for the insertion cycle the memory usage is stable. >> >> It seems like a bug to me but I assume the database is keeping some kind >> of >> rollback or restore data in memory. Any way I can tel the database not >> to >> do save this data in memory if I don't close the database, so my memory >> usage is stable? >> >> thanks, >> >> Scott > > - > To unsubscribe, send email to [EMAIL PROTECTED] > - > > > -- View this message in context: http://www.nabble.com/Memory-Usage-tf4822840.html#a13813367 Sent from the SQLite mailing list archive at Nabble.com. - To unsubscribe, send email to [EMAIL PROTECTED] -
[sqlite] building a custom DBD::SQLite
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). Many thanks, -- Puneet Kishor - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Memory Usage
Hi Scott, Ooops..meant to say the following. My initial evaluation of this database was that it allocates memory for each operation on the database. It returns the memory only when the database is CLOSED. So the behavior you see is normal. Ray Hurst ScottDerrick wrote: I am using sqlite3 in a DAQ device. Data can be viewed on the unit using a Rails enabled web server. The data is being stored to the database every 1 to 5 seconds. I wanted to leave the the database open for as long as teh application is running and then use a IMMEDIATE, PREPARE-INSERT(x), FINALIZE, COMMIT sequence. The application may run as long as 30 days at a time. To save disk access and CPU time I was not going to open and close the database for every insertion iteration. However I have noticed that my application seems use more and more memory as time goes bye. If I open and close the database for the insertion cycle the memory usage is stable. It seems like a bug to me but I assume the database is keeping some kind of rollback or restore data in memory. Any way I can tel the database not to do save this data in memory if I don't close the database, so my memory usage is stable? thanks, Scott - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Memory Usage
Hi Scott, My initial evaluation of this database was that it allocates memory for each operation on the database. It returns the memory only when the database is committed. So the behavior you see is normal. Ray Hurst ScottDerrick wrote: I am using sqlite3 in a DAQ device. Data can be viewed on the unit using a Rails enabled web server. The data is being stored to the database every 1 to 5 seconds. I wanted to leave the the database open for as long as teh application is running and then use a IMMEDIATE, PREPARE-INSERT(x), FINALIZE, COMMIT sequence. The application may run as long as 30 days at a time. To save disk access and CPU time I was not going to open and close the database for every insertion iteration. However I have noticed that my application seems use more and more memory as time goes bye. If I open and close the database for the insertion cycle the memory usage is stable. It seems like a bug to me but I assume the database is keeping some kind of rollback or restore data in memory. Any way I can tel the database not to do save this data in memory if I don't close the database, so my memory usage is stable? thanks, Scott - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Trying to build a static library
John: Thanks for your feedback, but the question is: are you compiling gcc in Linux or in Windows-32 with minGW? The problem is that I'm using the GNU gcc compiler under Windows (minGW), trying to build a static library as a C (not C++) project, and get a lot of compiler error. All related to type conversion. As an example here is the first: sources/where.c: In function `int whereClauseInsert(WhereClause*, Expr*, int)': sources/where.c:231: error: invalid conversion from `void*' to `WhereTerm*' Perhaps I'm missing some compiler option, but by the moment the system work pretty well compiling projects in both C and C++ using that platform. Some idea? I use static libraries and gcc. Just use --enable-static and you should get the link library created. A.J.Millan wrote: Hi all: Instead the supplied DLL, I would like to statically link the SQLite library in a new project, and I wonder if someone has build a SQLite static library xxx.a using minGW in Windows and the sources/headers contanied in the sqlite-source-3_5_2.zip Any tips on that are welcome. - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Need help reading 3.3.2 database files with 3.5.2...
> I was able to open and run "PRAGMA integrity_check" on the > database file you sent me (off-list) on both Linux and > MacOSX x86 using SQLite version 3.4.1 and 3.5.2. No errors. > > I have no idea what is causing your problem. Ok, since it was confirmed here that there SHOULDN'T be a problem, I went back, rebuilt things again, and now everything seems to work. I have no idea what the problem was, and investigated it before posting, but *shrug* seems to be fine now. I don't think there was an incompatible version hanging around, but something was causing the issue for me. At any rate, thanks for the help. Problem seems to be solved. - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Need help reading 3.3.2 database files with 3.5.2...
"Michael Dupuis" <[EMAIL PROTECTED]> wrote: > > SQLite version 3.5.2 can read and write database files created > > by every prior version of SQLite. No exceptions. > > > > Which is what I would expect. But still, I get the error that the > latest build can't read my older format. Is there anything that CAN > cause this error? My version 3.3.2 was built on Mac OS X, the latest > is as well. There were no changes in source, both were built straight > out of the source tarball... I don't recall doing anything "special" > to the 3.3.2 build that would break any compatibility either way. It > is puzzling. > I was able to open and run "PRAGMA integrity_check" on the database file you sent me (off-list) on both Linux and MacOSX x86 using SQLite version 3.4.1 and 3.5.2. No errors. I have no idea what is causing your problem. -- D. Richard Hipp <[EMAIL PROTECTED]> - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Need help reading 3.3.2 database files with 3.5.2...
> SQLite version 3.5.2 can read and write database files created > by every prior version of SQLite. No exceptions. > Which is what I would expect. But still, I get the error that the latest build can't read my older format. Is there anything that CAN cause this error? My version 3.3.2 was built on Mac OS X, the latest is as well. There were no changes in source, both were built straight out of the source tarball... I don't recall doing anything "special" to the 3.3.2 build that would break any compatibility either way. It is puzzling. - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Need help reading 3.3.2 database files with 3.5.2...
"Michael Dupuis" <[EMAIL PROTECTED]> wrote: > On 11/16/07, Trevor Talbot <[EMAIL PROTECTED]> wrote: > > It should just work. Are you sure the problem is about the version > > instead of something else? What error are you getting? > > > > Yeah, that's what I expected, but I'm getting an "unsupported file > format" error when I try and access any table. If I switch back to the > 3.3.2 version, it works again. > Please send me a copy of your database file. -- D. Richard Hipp <[EMAIL PROTECTED]> - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Need help reading 3.3.2 database files with 3.5.2...
"Michael Dupuis" <[EMAIL PROTECTED]> wrote: > Greetings, > > I have an application that uses SQLite 3.3.2 right now, and I'm > looking to move to 3.5.2. The problem I have right now is that 3.5.2 > can't open the 3.3.2 formatted database files. I know that the file > format changed, and then changed back, but I thought there was still a > way to get 3.5.2 to open the 3.3.2 "new" formatted database files. I > tried executing both of the PRAGMA legacy_file_format=ON and PRAGMA > legacy_file_format=OFF commands, but neither worked, is there any > other way that I can get the latest version of SQLite to read my older > formatted database files? > SQLite version 3.5.2 can read and write database files created by every prior version of SQLite. No exceptions. The previous statement is actually more general: SQLite version 3.x.y can read and write any database created by any prior version of SQLite. The second statement is an invariant. If ever we change SQLite in such a way that it cannot read or write prior database versions, then it will become SQLite version 4.0.0. There are no plans to ever do this. Things *mostly* work in the other direction: SQLite version 3.0.0 can read and write databases created by any subsequent version of SQLite. There are some exceptions to this rule. If a database uses features that were added later (such as decending indices, virtual tables, autovacuum, etc) then clearly an earlier version of SQLite will not be able to work with that database. Unlike other database, the SQLite file format does not change gratuitously. -- D. Richard Hipp <[EMAIL PROTECTED]> - To unsubscribe, send email to [EMAIL PROTECTED] -