Re: [sqlite] Two problems in latest version of lempar.c
Hi Richard thanks for the quick response! On 04.10.2016 14:21, Richard Hipp wrote: > On 10/4/16, Benjamin Franksenwrote: >> I am using the lemon parser generator in a project >> (http://www-csr.bessy.de/control/SoftDist/sequencer/). I updated the >> lemon parser template tools/lempar.c to the latest available version and >> found two problems, reported by gcc: >> >> ./snl.c: In function ‘yy_destructor’: >> ./snl.c:116:36: warning: unused variable ‘presult’ [-Wunused-variable] >> #define snlParserARG_FETCH Node **presult = yypParser->presult > > This can be resolved by using the "presult" variable in one of your > destructors. I have no destructors. The parser I am generating is part of a compiler that never frees any resources (until it exits). Anyway, ParseARG_STORE is used once in lempar.c to actually store the extra argument and four times to suppress unused variable warnings (according to the source comments), so I guess a fifth time won't do much harm ;-) >> ./snl.c: In function ‘snlParser’: >> ./snl.c:2446:33: warning: comparison of distinct pointer types lacks a >> cast [enabled by default] >> while( yypParser->yytos >= >yystack > > I think the latest trunk check-in may fix this. > https://www.sqlite.org/src/info/3a9d802fda105856 > > But that fix is untested, as the error handling logic where this code > is found is #ifdef-ed out in SQLite. Please give the latest a try and > let me know if that fails to fix the problem. The fix works fine, thanks. I don't know why I didn't see it when I looked at the repo today (I did intend to grab the latest version from the trunk), probably made a mistake navigating the web interface. Cheers Ben -- "Make it so they have to reboot after every typo." ― Scott Adams signature.asc Description: OpenPGP digital signature ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Two problems in latest version of lempar.c
On 10/4/16, Benjamin Franksenwrote: > Hello > > I am using the lemon parser generator in a project > (http://www-csr.bessy.de/control/SoftDist/sequencer/). I updated the > lemon parser template tools/lempar.c to the latest available version and > found two problems, reported by gcc: > > ./snl.c: In function ‘yy_destructor’: > ./snl.c:116:36: warning: unused variable ‘presult’ [-Wunused-variable] > #define snlParserARG_FETCH Node **presult = yypParser->presult This can be resolved by using the "presult" variable in one of your destructors. > ./snl.c: In function ‘snlParser’: > ./snl.c:2446:33: warning: comparison of distinct pointer types lacks a > cast [enabled by default] > while( yypParser->yytos >= >yystack I think the latest trunk check-in may fix this. https://www.sqlite.org/src/info/3a9d802fda105856 But that fix is untested, as the error handling logic where this code is found is #ifdef-ed out in SQLite. Please give the latest a try and let me know if that fails to fix the problem. -- D. Richard Hipp d...@sqlite.org ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
[sqlite] Two problems in latest version of lempar.c
Hello I am using the lemon parser generator in a project (http://www-csr.bessy.de/control/SoftDist/sequencer/). I updated the lemon parser template tools/lempar.c to the latest available version and found two problems, reported by gcc: ./snl.c: In function ‘yy_destructor’: ./snl.c:116:36: warning: unused variable ‘presult’ [-Wunused-variable] #define snlParserARG_FETCH Node **presult = yypParser->presult ^ ./snl.c:1031:3: note: in expansion of macro ‘snlParserARG_FETCH’ snlParserARG_FETCH; ^ ./snl.c: In function ‘snlParser’: ./snl.c:2446:33: warning: comparison of distinct pointer types lacks a cast [enabled by default] while( yypParser->yytos >= >yystack The first is a harmless warning which can be suppressed by using the snlParserARG_STORE macro in yy_destructor right after snlParserARG_FETCH, as is done similarly in a number of other functions in lempar.c. The second one is *NOT* harmless. The '&' before yypParser->yystack is indeed wrong and could in corner cases lead to a crash or worse a security vulnerability. Cheers Ben PS: I am not subscribed, so please add my address to any replies. -- "Make it so they have to reboot after every typo." ― Scott Adams signature.asc Description: OpenPGP digital signature ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Two problems
On Mon, 2006-01-23 at 09:48 -0500, Paul Tomblin wrote: > Quoting Dan Kennedy ([EMAIL PROTECTED]): > > > - The second problem appears to be a problem with self-locking. I'm > > > inserting a "mapping" into a table. I have a query active to find ids > > > that require mapping, and then I try to find the current lowest > > > unused "mapping" value, and insert it. > > > > Right. You can't modify a table that is currently being scanned by > > a SELECT query. One way around this is to make a copy of the table > > in a TEMP table for the duration of the operation. > > But actually I'm not currently selecting from it. I prepare two > statements, one for query and one for insert. The query should only > return 0 or 1 rows. I do the query, then if it returns 0 rows, I do the > insert. I repeat this multiple times, using the same prepared statements > each time. Like I said, this never caused a problem when I did it in > MySQL or PostgreSQL. > > I realize that SQLite has to be simplied compared to full features RDBMS, > but it appears that either the SQLite library, or possibly the perl > wrapper, is somehow mistaking a prepared statement which has finished > executing the current query for one whose query is still open. > > I suppose the only way I'm going to know for sure is to try writing the > same sequence of events in C, and it's been so long I'm not sure my C > skills are up to it. > I ran into this just yesterday. I have a SELECT query that uses a sub-query to find a value in another table in order to find out if a particular row has been INSERTED yet. I suspect what's happening is that SQLite thinks that the SELECT query may fetch more than one row and so is not considered finished. Interestingly, the column against which I'm performing the sub-SELECT equality query is defined with UNIQUE, so I assumed SQLite would DWIM. The only solution I found was to use LIMIT 1 in both the inner and outer SELECTs, or to invoke finish() against the statement handles. Looking at http://www.sqlite.org/optoverview.html I see that LIMIT is preventing the optimizer flattening the subquery, so finish() is probably a better solution. -- David P.C. Wollmann AIM & Yahoo!: converter42 | MSN Messenger: [EMAIL PROTECTED] PGP Fingerprint: 53C8 BF29 9AF0 EEE8 85DB 8D1C 14B1 023E 9079 CAD8 Get free PKCS client and server certificates at http://www.cacert.org/
Re: [sqlite] Two problems
- Original Message - From: "Paul Tomblin" <[EMAIL PROTECTED]> Quoting Dan Kennedy ([EMAIL PROTECTED]): > - The second problem appears to be a problem with self-locking. I'm > inserting a "mapping" into a table. I have a query active to find > ids > that require mapping, and then I try to find the current lowest > unused "mapping" value, and insert it. Right. You can't modify a table that is currently being scanned by a SELECT query. One way around this is to make a copy of the table in a TEMP table for the duration of the operation. But actually I'm not currently selecting from it. I prepare two statements, one for query and one for insert. The query should only return 0 or 1 rows. I do the query, then if it returns 0 rows, I do the insert. I repeat this multiple times, using the same prepared statements each time. Like I said, this never caused a problem when I did it in MySQL or PostgreSQL. I realize that SQLite has to be simplied compared to full features RDBMS, but it appears that either the SQLite library, or possibly the perl wrapper, is somehow mistaking a prepared statement which has finished executing the current query for one whose query is still open. I suppose the only way I'm going to know for sure is to try writing the same sequence of events in C, and it's been so long I'm not sure my C skills are up to it. All you need to do is make sure you've reset() your row-selecting reader before you execute the insert and then it'll work. Robert
Re: [sqlite] Two problems
Paul Tomblin <[EMAIL PROTECTED]> wrote: > Quoting Dan Kennedy ([EMAIL PROTECTED]): > > > - The second problem appears to be a problem with self-locking. I'm > > > inserting a "mapping" into a table. I have a query active to find ids > > > that require mapping, and then I try to find the current lowest > > > unused "mapping" value, and insert it. > > > > Right. You can't modify a table that is currently being scanned by > > a SELECT query. One way around this is to make a copy of the table > > in a TEMP table for the duration of the operation. > > But actually I'm not currently selecting from it. I prepare two > statements, one for query and one for insert. The query should only > return 0 or 1 rows. I do the query, then if it returns 0 rows, I do the > insert. I repeat this multiple times, using the same prepared statements > each time. Call sqlite3_reset() on the query before doing the insert. -- D. Richard Hipp <[EMAIL PROTECTED]>
Re: [sqlite] Two problems
Quoting Dan Kennedy ([EMAIL PROTECTED]): > > - The second problem appears to be a problem with self-locking. I'm > > inserting a "mapping" into a table. I have a query active to find ids > > that require mapping, and then I try to find the current lowest > > unused "mapping" value, and insert it. > > Right. You can't modify a table that is currently being scanned by > a SELECT query. One way around this is to make a copy of the table > in a TEMP table for the duration of the operation. But actually I'm not currently selecting from it. I prepare two statements, one for query and one for insert. The query should only return 0 or 1 rows. I do the query, then if it returns 0 rows, I do the insert. I repeat this multiple times, using the same prepared statements each time. Like I said, this never caused a problem when I did it in MySQL or PostgreSQL. I realize that SQLite has to be simplied compared to full features RDBMS, but it appears that either the SQLite library, or possibly the perl wrapper, is somehow mistaking a prepared statement which has finished executing the current query for one whose query is still open. I suppose the only way I'm going to know for sure is to try writing the same sequence of events in C, and it's been so long I'm not sure my C skills are up to it. -- Paul Tomblin <[EMAIL PROTECTED]> http://xcski.com/blogs/pt/ If you're not part of the solution, you're part of the precipitate.
Re: [sqlite] Two problems
> - insert the value "0E9" (and other variables that would look like numbers > if they were in numeric fields) into a varchar(10) field, and it gets > converted to the numeric equivalent. I think it might the perl wrapper doing the conversion. SQLite shouldn't do this. SQLite version 3.3.0 sqlite> create table a(b varchar(10)); sqlite> insert into a values('0E9'); sqlite> select * from a; 0E9 sqlite> select typeof(b) from a; text sqlite> insert into a values(0E9); sqlite> select typeof(b) from a; text text sqlite> select b from a; 0E9 0E9 > - The second problem appears to be a problem with self-locking. I'm > inserting a "mapping" into a table. I have a query active to find ids > that require mapping, and then I try to find the current lowest > unused "mapping" value, and insert it. Right. You can't modify a table that is currently being scanned by a SELECT query. One way around this is to make a copy of the table in a TEMP table for the duration of the operation. __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
[sqlite] Two problems
I'm just testing out my http://navaid.com/ applications with SQLite. In the past, my scripts have worked with MySQL and PostgreSQL with minimal changes, but I'm getting two problems with SQLite in perl DBD::SQLite: - insert the value "0E9" (and other variables that would look like numbers if they were in numeric fields) into a varchar(10) field, and it gets converted to the numeric equivalent. The identical syntax worked fine with MySQL and PostgresSQL. The schema looks like: sqlite> .schema waypoint CREATE TABLE waypoint ( id varchar(10) default NULL, datasource_key varchar(20) default NULL, type varchar(30) default NULL, name varchar(100) default NULL, address varchar(120) default NULL, state char(3) default NULL, country char(2) default NULL, latitude double default NULL, longitude double default NULL, declination double default NULL, datasource smallint(6) default NULL, elevation double default NULL, main_frequency varchar(9) default NULL, ispublic tinyint(1) default NULL, chart_map smallint(6) default NULL, tpa smallint(6) default NULL ); CREATE INDEX waypoint_datasource on waypoint(datasource); CREATE INDEX waypoint_id on waypoint(id); CREATE INDEX waypoint_type on waypoint(type); sqlite> and is inserted with $wptInsertStmt = $conn->prepare(qq{ INSERT INTO waypoint (id, datasource_key, type, name, address, state, country, latitude, longitude, declination, elevation, main_frequency, datasource, ispublic, chart_map) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)}); $wptInsertStmt->execute($id, $datasource_key, $type, $name, $address, $state, $country, $latitude, $longitude, $declination, $elevation, $main_frequency, $datasource, $isPublic, $chart_map) or die $wptInsertStmt->errstr; print "Inserted $type: $id\n"; - The second problem appears to be a problem with self-locking. I'm inserting a "mapping" into a table. I have a query active to find ids that require mapping, and then I try to find the current lowest unused "mapping" value, and insert it. But when I do, the open query seems to have locked the database against itself, and I get an error: DBD::SQLite::st execute failed: database table is locked(1) at dbdimp.c line 401 at /config_backup/navaid.com//perl/DBLoad_lite.pm line 547. The code in question: my $selectStmt = $conn->prepare( "SELECT distinct(a.id) " . "FROM waypoint a " . "LEFT JOIN id_mapping b " . "ON a.id = b.id " . "WHERE b.id is null"); my $insertStmt = $conn->prepare( "INSERT " . "INTO id_mapping(id, pdb_id) " . "VALUES (?,?)"); $selectStmt->execute() or die $selectStmt->errstr; while (my @row = $selectStmt->fetchrow_array) { my ($id) = @row; print "new ID: $id\n"; $maxNumber = nextId($maxNumber); print "inserting $id, $maxNumber\n"; $insertStmt->execute($id, $maxNumber++); #<-- this is line 547 } nextID does the following: while (1) { $isTaken->execute($maxNumber); if (@row = $isTaken->fetchrow_array) { print "$maxNumber is already taken\n"; $maxNumber++; } else { last; } } return $maxNumber; Any ideas? -- Paul Tomblin <[EMAIL PROTECTED]> http://xcski.com/blogs/pt/ If the automobile had followed the same development as the computer a Rolls Royce would today cost $100, get a million miles per gallon and explode once a year killing everybody inside. - Robert Cringley (InfoWorld)