RE: [sqlite] a few lemon questions
--- "Wilson, Ron" <[EMAIL PROTECTED]> wrote: > That being said, I've run into a huge roadblock. I'm using flex which > produces lex.yy.c which includes and . Which errno/unistd functions are actually used by the generated flex code? getc, ungetc? Maybe you can supply work-alike functions and those 2 header files. > another lexer? Follow drh's advice and write your own. You'll have fewer dependencies/problems and more control. Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping - To unsubscribe, send email to [EMAIL PROTECTED] -
RE: [sqlite] a few lemon questions
Ok. No problem I can take care of the memory issues. That being said, I've run into a huge roadblock. I'm using flex which produces lex.yy.c which includes and . Since I'm working in WinCE (eVC 4.2) neither of these includes exist. Sigh. I think I'm hosed. If I build my lexer with flex++, it still includes and . Has anyone had any luck with flex and wince? Can you recommend another lexer? RW Ron Wilson, Senior Engineer, MPR Associates, 518.831.7546 -Original Message- From: Joe Wilson [mailto:[EMAIL PROTECTED] Sent: Thursday, December 20, 2007 11:15 PM To: sqlite-users@sqlite.org Subject: RE: [sqlite] a few lemon questions --- "Wilson, Ron" <[EMAIL PROTECTED]> wrote: > 1. My non-terminal token destructors are not getting called. The > terminal destructors work fine, but none of my terminal tokens need > destruction. Two of my non-terminals definitely require destruction. I > have properly defined the %destructor and instrumented the destructor > code with std::cout << "in destructor" << std::endl;. They are simply > not being called. Ever. The destruction of well-formed parsed tree objects is your responsibility. See the comment below in the generated code as to the conditions when the destructor is called. If you use the symbol in the C code action of the rule, the destructor will not be invoked. (It wouldn't be a useful feature if the destructor was called unconditionally by each action!) Looking at lemon.c for the { C code }, I think it skips C/C++ code comments and quoted characters and strings when searching for rule symbols. Clever stuff. parse.y: 372 %type select {Select*} 373 %destructor select {sqlite3SelectDelete($$);} the generated parse.c file: /* The following function deletes the value associated with a ** symbol. The symbol can be either a terminal or nonterminal. ** "yymajor" is the symbol code, and "yypminor" is a pointer to ** the value. */ static void yy_destructor(YYCODETYPE yymajor, YYMINORTYPE *yypminor){ switch( yymajor ){ /* Here is inserted the actions which take place when a ** terminal or non-terminal is destroyed. This can happen ** when the symbol is popped from the stack during a ** reduce or during error processing or when a parser is ** being destroyed before it is finished parsing. ** ** Note: during a reduce, the only symbols destroyed are those ** which appear on the RHS of the rule, but which are not used ** inside the C code. */ case 155: case 189: case 206: #line 373 "parse.y" {sqlite3SelectDelete((yypminor->yy219));} Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping - To unsubscribe, send email to [EMAIL PROTECTED] - - To unsubscribe, send email to [EMAIL PROTECTED] -
RE: [sqlite] a few lemon questions
--- "Wilson, Ron" <[EMAIL PROTECTED]> wrote: > 1. My non-terminal token destructors are not getting called. The > terminal destructors work fine, but none of my terminal tokens need > destruction. Two of my non-terminals definitely require destruction. I > have properly defined the %destructor and instrumented the destructor > code with std::cout << "in destructor" << std::endl;. They are simply > not being called. Ever. The destruction of well-formed parsed tree objects is your responsibility. See the comment below in the generated code as to the conditions when the destructor is called. If you use the symbol in the C code action of the rule, the destructor will not be invoked. (It wouldn't be a useful feature if the destructor was called unconditionally by each action!) Looking at lemon.c for the { C code }, I think it skips C/C++ code comments and quoted characters and strings when searching for rule symbols. Clever stuff. parse.y: 372 %type select {Select*} 373 %destructor select {sqlite3SelectDelete($$);} the generated parse.c file: /* The following function deletes the value associated with a ** symbol. The symbol can be either a terminal or nonterminal. ** "yymajor" is the symbol code, and "yypminor" is a pointer to ** the value. */ static void yy_destructor(YYCODETYPE yymajor, YYMINORTYPE *yypminor){ switch( yymajor ){ /* Here is inserted the actions which take place when a ** terminal or non-terminal is destroyed. This can happen ** when the symbol is popped from the stack during a ** reduce or during error processing or when a parser is ** being destroyed before it is finished parsing. ** ** Note: during a reduce, the only symbols destroyed are those ** which appear on the RHS of the rule, but which are not used ** inside the C code. */ case 155: case 189: case 206: #line 373 "parse.y" {sqlite3SelectDelete((yypminor->yy219));} Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping - To unsubscribe, send email to [EMAIL PROTECTED] -
RE: [sqlite] a few lemon questions
Ok I've come a long way and have a functional parser using lemon and flex. However, there are a few unresolved items that I need help with. 1. My non-terminal token destructors are not getting called. The terminal destructors work fine, but none of my terminal tokens need destruction. Two of my non-terminals definitely require destruction. I have properly defined the %destructor and instrumented the destructor code with std::cout << "in destructor" << std::endl;. They are simply not being called. Ever. The only thing I can think of is that I'm not actually calling malloc on the terminal itself - the terminal is a struct that contains a pointer element which receives a malloc, e.g.: struct myTerminal { int* array; int count; } ... A.array = (int*) malloc(A.count * sizeof(int)); 2. Whenever there is a syntax error, the %syntax_error handler is called multiple times (once for each time it pops the stack). I know this is by design, but I need to send a NAK on a malformed message and I need a way to only send that NAK once. The lemon documentation vaguely mentions a "error" non-terminal. What would be a good strategy for managing syntax errors in a way that only notifies once for each malformed message? RW Ron Wilson, Senior Engineer, MPR Associates, 518.831.7546 - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Explain query plan
On Thu, 20 Dec 2007 11:27:37 -0800, Steven Fisher <[EMAIL PROTECTED]> wrote: >So I've been using EXPLAIN QUERY PLAN to try to optimize my queries, >and I realized I'm missing something important. > >It shares what tables are used and what indexes, but as I understand >it, it doesn't include whether I'm working entirely off indexes or >not. For instance, if I have a line: > >TABLE Groups WITH INDEX GroupTypeIndex > >...does that indicate if GroupTypeIndex fully satisfies the search? >How can I tell this? > >What'd be great is if explain query plan had another column that >indicated which columns it had to crawl through... EXPLAIN QUERY PLAN SELECT ... only shows which access strategy the optimizer has chosen. You will get much more detail with EXPLAIN SELECT ... It shows the VDBE code, which looks cryptic at first but will prove really informative. -- ( Kees Nuyt ) c[_] - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] suggestion for an optimized sql
It may be the case where the index will cause more harm than good in this instance depending upon the percentage matching. In other words if only 10% of the records match using the index great... But if say 90% match the index this would be Very Bad and A Full scan would be quicker. I full table scan is not always a bad thing. It just depends upon the percentage of rows you need returned. Clodo <[EMAIL PROTECTED]> wrote: Thanks to all great people that help me. I will create a specific field with an index on that. Bye! > You could create a field in the table Value01LessThanValue02 and use a > trigger to update this value whenever data is updated. Then you can search > on just this one field. However, it's a boolean result so depending on the > percentage of records that match this condition, the index may not be that > helpful in the end anyways. > > HTH, > > 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: Clodo [mailto:[EMAIL PROTECTED] > Sent: Thursday, December 20, 2007 5:36 AM > To: sqlite-users@sqlite.org > Subject: [sqlite] suggestion for an optimized sql > > Hi, i have a table like this with thousand of records: > > CREATE TABLE Table01 ( > id integer, > value01 text, > value02 text > ); > > I need to optimize the following sql: > > SELECT * FROM Table01 WHERE VALUE01 > > How i can use indexes to avoid a full-table scan? Thanks! > > > > - > To unsubscribe, send email to [EMAIL PROTECTED] > > - > > > - > To unsubscribe, send email to [EMAIL PROTECTED] > - > > > - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] shared cache mode locking
Ed, Dan opened a ticket. I agree the documentation isn't clear on the Exlusive locking state. Not really sure, if this is by design or a bug at this stage. I do think its a great feature of the Shared cache mode to allow table level locking. But I'm curious with this table level locking what would happen if two threads performed writes to two seperate tables concurrently using only a begin immediate. Thread a writes to tab1, Thread b writes to tab2, (Is this allowed ? or is a sqlite_locked kicked returned?) If it is allowed then would there be two journal files concurrently existing? And What happens during a crash with two journals ? This gets complicated very quickly. Ken Ed Pasma <[EMAIL PROTECTED]> wrote: Hello,` Empirically I found that it is exactly true. Must admit I'm confused but may it is in line with the Shared-Cache locking model. This does not mention the EXCLUSIVE locking state. The most 'secure' locking state it mentions is a write-transaction and this can coexist with read-transactions from others. Thus "begin exclusive" starts a write-transaction and the on-going read does not interfere. The error message seems to clarify the situation further: database table is locked. Thus the collision occurs at the table-level. And yes, taking different tables for read and write, it does not occur. Practically this may not help very much. But may be the following does in case you have a busy_timeout setting. When having Shared-Cache mode enabled, the timeout setting appears to be ignored by SQLite. This makes locking situations surface rather soon, also when there is no dead-lock. The situation may be handled by a programmatic retry? Regards, Ed Op 19-dec-2007, om 19:12 heeft Ken het volgende geschreven: > Some additional info: > > when the sqlite_lock is returned there is another thread that > appears to be reading the same table. Does the sqlite3 step return > sqlite_locked in this case? > > Thanks, > Ken > > > Ken wrote: > While using the new 3.5.4 sqlite3_enable_shared_cache I ran into a > strange lock situation. > > SQLITE_LOCK is returned from an insert statement, even though > the thread/connection performed a successful "begin exclusive" > transaction. > >begin exclusive > insert into table... ---> returns SQLITE_LOCKED > > Is it possible for both connections to begin exclusive transactions > whilst having the shared cache anabled? > > Thanks, > ken > > - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] shared cache mode locking
Hello,` Empirically I found that it is exactly true. Must admit I'm confused but may it is in line with the Shared-Cache locking model. This does not mention the EXCLUSIVE locking state. The most 'secure' locking state it mentions is a write-transaction and this can coexist with read-transactions from others. Thus "begin exclusive" starts a write-transaction and the on-going read does not interfere. The error message seems to clarify the situation further: database table is locked. Thus the collision occurs at the table-level. And yes, taking different tables for read and write, it does not occur. Practically this may not help very much. But may be the following does in case you have a busy_timeout setting. When having Shared-Cache mode enabled, the timeout setting appears to be ignored by SQLite. This makes locking situations surface rather soon, also when there is no dead-lock. The situation may be handled by a programmatic retry? Regards, Ed Op 19-dec-2007, om 19:12 heeft Ken het volgende geschreven: Some additional info: when the sqlite_lock is returned there is another thread that appears to be reading the same table. Does the sqlite3 step return sqlite_locked in this case? Thanks, Ken Ken <[EMAIL PROTECTED]> wrote: While using the new 3.5.4 sqlite3_enable_shared_cache I ran into a strange lock situation. SQLITE_LOCK is returned from an insert statement, even though the thread/connection performed a successful "begin exclusive" transaction. begin exclusive insert into table... ---> returns SQLITE_LOCKED Is it possible for both connections to begin exclusive transactions whilst having the shared cache anabled? Thanks, ken - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] suggestion for an optimized sql
Thanks to all great people that help me. I will create a specific field with an index on that. Bye! You could create a field in the table Value01LessThanValue02 and use a trigger to update this value whenever data is updated. Then you can search on just this one field. However, it's a boolean result so depending on the percentage of records that match this condition, the index may not be that helpful in the end anyways. HTH, 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: Clodo [mailto:[EMAIL PROTECTED] Sent: Thursday, December 20, 2007 5:36 AM To: sqlite-users@sqlite.org Subject: [sqlite] suggestion for an optimized sql Hi, i have a table like this with thousand of records: CREATE TABLE Table01 ( id integer, value01 text, value02 text ); I need to optimize the following sql: SELECT * FROM Table01 WHERE VALUE01 - To unsubscribe, send email to [EMAIL PROTECTED] -
[sqlite] Explain query plan
So I've been using EXPLAIN QUERY PLAN to try to optimize my queries, and I realized I'm missing something important. It shares what tables are used and what indexes, but as I understand it, it doesn't include whether I'm working entirely off indexes or not. For instance, if I have a line: TABLE Groups WITH INDEX GroupTypeIndex ...does that indicate if GroupTypeIndex fully satisfies the search? How can I tell this? What'd be great is if explain query plan had another column that indicated which columns it had to crawl through... - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] query does not work on sqlite c apis but works on the console
arbalest06 wrote: i already got it working.. I'm glad to hear that. however, is still have the free(): invalid pointer problem in my sqlite3_close..this is my code for my close api: if( GDBM_Db_p != NULL ) { printf( "FDBM_Close: GDBM_Db_p is not NULL\n" ); /* closes the database */ sqlite3_close( GDBM_Db_p ); } else { printf( "FDBM_Close: GDBM_Db_p is NULL\n" ); } the problem only occurs when sqlite3_prepare returns an error code other than SQLITE_OK..mostly, ..SQLITE_ERROR I suspect that your pointer is being changed somewhere along the line. Print the value of your pointer immediately after it is set by sqlite3_open(), and just before you call sqlite3_close(). These values should be the same, if not you will have to find out where it is being overwritten. HTH Dennis Cote - To unsubscribe, send email to [EMAIL PROTECTED] -
RE: [sqlite] suggestion for an optimized sql
Continuing with Sams thought process, Create another table that only contains record id's where value01=value02 Then just query table01_a The use of an index is probably not going to help and your better off most likely performing the full table scan especially if you are getting a significant chunk of the table and the records more than likely have an even distribution. "Samuel R. Neff" <[EMAIL PROTECTED]> wrote: You could create a field in the table Value01LessThanValue02 and use a trigger to update this value whenever data is updated. Then you can search on just this one field. However, it's a boolean result so depending on the percentage of records that match this condition, the index may not be that helpful in the end anyways. HTH, 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: Clodo [mailto:[EMAIL PROTECTED] Sent: Thursday, December 20, 2007 5:36 AM To: sqlite-users@sqlite.org Subject: [sqlite] suggestion for an optimized sql Hi, i have a table like this with thousand of records: CREATE TABLE Table01 ( id integer, value01 text, value02 text ); I need to optimize the following sql: SELECT * FROM Table01 WHERE VALUE01 How i can use indexes to avoid a full-table scan? Thanks! - To unsubscribe, send email to [EMAIL PROTECTED] - - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] query does not work on sqlite c apis but works on the console
i already got it working..the only problem was that my condition ( char * ) = "id=1"..i got it working when i made it to "id = 1"..spaces did that trouble to my code..however, is still have the free(): invalid pointer problem in my sqlite3_close..this is my code for my close api: if( GDBM_Db_p != NULL ) { printf( "FDBM_Close: GDBM_Db_p is not NULL\n" ); /* closes the database */ sqlite3_close( GDBM_Db_p ); } else { printf( "FDBM_Close: GDBM_Db_p is NULL\n" ); } the problem only occurs when sqlite3_prepare returns an error code other than SQLITE_OK..mostly, ..SQLITE_ERROR Dennis Cote wrote: > > arbalest06 wrote: >> im implementing a C program that uses the sqlite as my database..im using >> a >> global database pointer because im creating my apis for open and close >> database..my problem is that when i put a select query, the return value >> is >> 1..i copied my query to the console of sqlite3 and it worked perfectly >> fine..therefore, the database is accessible and present, and the query is >> correct..i cant think of anything that will cause this problem.. >> >> also, when i close the database, after this scenario, it gave me a >> free(): >> invalid pointer..and it was pointed to where sqlite3_close is.. >> >> > Your call to sqlite3_open() probably failed, possibly due to a bad file > name or path. Did you check the return code from sqlite3_open()? If the > open failed you should have a NULL value in your database pointer. This > will generate errors when you try to execute queries, and it may also > cause debug versions of free to complain. Just a thought. > > If you still have trouble, you will need to post your code to get better > help. > > HTH > Dennis Cote > > > - > To unsubscribe, send email to [EMAIL PROTECTED] > - > > > -- View this message in context: http://www.nabble.com/query-does-not-work-on-sqlite-c-apis-but-works-on-the-console-tp14436330p14439012.html Sent from the SQLite mailing list archive at Nabble.com. - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] query does not work on sqlite c apis but works on the console
arbalest06 wrote: im implementing a C program that uses the sqlite as my database..im using a global database pointer because im creating my apis for open and close database..my problem is that when i put a select query, the return value is 1..i copied my query to the console of sqlite3 and it worked perfectly fine..therefore, the database is accessible and present, and the query is correct..i cant think of anything that will cause this problem.. also, when i close the database, after this scenario, it gave me a free(): invalid pointer..and it was pointed to where sqlite3_close is.. Your call to sqlite3_open() probably failed, possibly due to a bad file name or path. Did you check the return code from sqlite3_open()? If the open failed you should have a NULL value in your database pointer. This will generate errors when you try to execute queries, and it may also cause debug versions of free to complain. Just a thought. If you still have trouble, you will need to post your code to get better help. HTH Dennis Cote - To unsubscribe, send email to [EMAIL PROTECTED] -
RE: [sqlite] suggestion for an optimized sql
You could create a field in the table Value01LessThanValue02 and use a trigger to update this value whenever data is updated. Then you can search on just this one field. However, it's a boolean result so depending on the percentage of records that match this condition, the index may not be that helpful in the end anyways. HTH, 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: Clodo [mailto:[EMAIL PROTECTED] Sent: Thursday, December 20, 2007 5:36 AM To: sqlite-users@sqlite.org Subject: [sqlite] suggestion for an optimized sql Hi, i have a table like this with thousand of records: CREATE TABLE Table01 ( id integer, value01 text, value02 text ); I need to optimize the following sql: SELECT * FROM Table01 WHERE VALUE01
[sqlite] query does not work on sqlite c apis but works on the console
good day! im implementing a C program that uses the sqlite as my database..im using a global database pointer because im creating my apis for open and close database..my problem is that when i put a select query, the return value is 1..i copied my query to the console of sqlite3 and it worked perfectly fine..therefore, the database is accessible and present, and the query is correct..i cant think of anything that will cause this problem.. also, when i close the database, after this scenario, it gave me a free(): invalid pointer..and it was pointed to where sqlite3_close is.. can anybody point out what's the problem?..thanx.. God bless! -- View this message in context: http://www.nabble.com/query-does-not-work-on-sqlite-c-apis-but-works-on-the-console-tp14436330p14436330.html Sent from the SQLite mailing list archive at Nabble.com. - To unsubscribe, send email to [EMAIL PROTECTED] -
[sqlite] Problems compiling 3.5.4 without TCL
Hello, I'm trying to compile SQLite 3.5.4 and I'm having the following problem: first, it does not detect anymore if TCL is present or not, so I added the --disable-tcl option to the configure, but even with this option I'm getting the following: $ configure CC=xlc_r CXX=xlC_r --prefix=/workspace/usr --enable-threadsafe --enable-cross-thread-connections --disable-tcl ... $ gmake ... tclsh ./tool/mksqlite3c.tcl gmake: tclsh: Command not found gmake: *** [sqlite3.c] Error 127 (Installing TCL is not an option) Thanks, Darío - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] suggestion for an optimized sql
On Thu, 20 Dec 2007 11:36:29 +0100, Clodo <[EMAIL PROTECTED]> wrote: >Hi, i have a table like this with thousand of records: > >CREATE TABLE Table01 ( > id integer, > value01 text, > value02 text >); > >I need to optimize the following sql: > >SELECT * FROM Table01 WHERE VALUE01 >How i can use indexes to avoid a full-table scan? Thanks! You could create an index on (value01) or on (value01,value02), but it probably wouldn't help at all. Being TEXT columns, the index could potentially be large. A full table scan might be replaced by a full index scan. I don't think it would be any faster. I would say: try it and compare the results. Use EXPLAIN SELECT * FROM Table01 WHERE value01
[sqlite] suggestion for an optimized sql
Hi, i have a table like this with thousand of records: CREATE TABLE Table01 ( id integer, value01 text, value02 text ); I need to optimize the following sql: SELECT * FROM Table01 WHERE VALUE01
Re: [sqlite] Encryption?
*) for crypting/compression you can have a look at http://www.greschenz.de (look/search for "sqlite" of course :-) i've written 2 (very small) sqlite-functions to support this... if my server is down again, please inform me :-) *) yes, i always use *.sdb (for SqliteDB, what else :-) Jason Tudor wrote: Is there any encryption functionality built into SQLite? Also, can I use extensions other than .db for SQLite database filtes? Thanks Tudor - To unsubscribe, send email to [EMAIL PROTECTED] -