Re: [sqlite] Custom Collation comparing only firt character?

2011-08-27 Thread Jean-Christophe Deschamps

>Cool - can you please post a link to the sources?

Sure, here you are:
http://dl.dropbox.com/u/26433628/unifuzz.zip

The .c source contains all details (and all the bugs).


--
j...@antichoc.net  

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


[sqlite] Attaching an in-memory database

2011-08-27 Thread Abhinav Upadhyay
Hi,

I am trying to attach an in-memory database and then create a table in
it. Here is the code that I am using:

/* I have already opened a connection to a database before the following */
sqlite3_exec(db, "ATTACH DATABASE :memory AS metadb", NULL, NULL, &errmsg);
if (errmsg != NULL) {
warnx("%s", errmsg);
free(errmsg);
exit(EXIT_FAILURE);
}

/* I need to keep all the operations in a single transaction for
better performance */
sqlite3_exec(db, "BEGIN", NULL, NULL, &errmsg);
if (errmsg != NULL) {
warnx("%s", errmsg);
free(errmsg);
exit(EXIT_FAILURE);
}

...
/* somewhere down the line I try to create a table in the in-memory
attached database */
sqlstr = "CREATE TABLE IF NOT EXISTS metadb.file_cache("
" md5_hash, file PRIMARY KEY)";


sqlite3_exec(db, sqlstr, NULL, NULL, &errmsg);
if (errmsg != NULL) {
warnx("%s", errmsg);
free(errmsg);
exit(EXIT_FAILURE);
}
...

But on running the program I am getting an error exactly at the point
where I am trying to execute the create table statement above:

# ./makemandb
Building temporary file cache
makemandb: near ".": syntax error

What might be wrong here ? From the documentation it seems that I
should be explicitly specifying the database name if I have attached
one or more databases.

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


Re: [sqlite] Attaching an in-memory database

2011-08-27 Thread Simon Slavin

On 27 Aug 2011, at 4:50pm, Abhinav Upadhyay wrote:

> sqlite3_exec(db, "ATTACH DATABASE :memory AS metadb", NULL, NULL, &errmsg);

Need a colon after 'memory':

ATTACH DATABASE ':memory:' AS metadb;

I don't think you need the quotes I put in, I'm not sure.

When in doubt, use the SQLite shell tool to execute the commands you're trying 
to do in your app.  This will tell you whether the fault is in your SQL coding 
or your C coding.  It has saved me many hours of looking at the wrong problem.

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


Re: [sqlite] Attaching an in-memory database

2011-08-27 Thread Abhinav Upadhyay
On Sat, Aug 27, 2011 at 9:52 PM, Simon Slavin  wrote:
>
> On 27 Aug 2011, at 4:50pm, Abhinav Upadhyay wrote:
>
>> sqlite3_exec(db, "ATTACH DATABASE :memory AS metadb", NULL, NULL, &errmsg);
>
> Need a colon after 'memory':
>
> ATTACH DATABASE ':memory:' AS metadb;
>
> I don't think you need the quotes I put in, I'm not sure.
>
> When in doubt, use the SQLite shell tool to execute the commands you're 
> trying to do in your app.  This will tell you whether the fault is in your 
> SQL coding or your C coding.  It has saved me many hours of looking at the 
> wrong problem.

Ah, that was silly of me :( . I could not see the 2nd colon in the
documentation page until now :P. Looks like it is working.

Thanks

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


[sqlite] [PATCH 1/2] Fix memory corruption in test routine

2011-08-27 Thread Thomas Jarosch
Credit goes to "cppcheck".

The author or authors of this code dedicate any and all copyright interest
in this code to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and successors.
We intend this dedication to be an overt act of relinquishment in perpetuity
of all present and future rights to this code under copyright law.

Signed-off-by: Thomas Jarosch 
---
 src/test1.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/test1.c b/src/test1.c
index 7fdf54b..2045c81 100644
--- a/src/test1.c
+++ b/src/test1.c
@@ -4395,7 +4395,8 @@ static u8 *sqlite3_stack_baseline = 0;
 static void prepStack(void){
   int i;
   u32 bigBuf[65536];
-  for(i=0; ihttp://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] [PATCH 2/2] Fix file descriptor leak on error

2011-08-27 Thread Thomas Jarosch
Credit goes to "cppcheck".

The author or authors of this code dedicate any and all copyright interest
in this code to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and successors.
We intend this dedication to be an overt act of relinquishment in perpetuity
of all present and future rights to this code under copyright law.

Signed-off-by: Thomas Jarosch 
---
 tool/lemon.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/tool/lemon.c b/tool/lemon.c
index bd2938b..1f8082c 100644
--- a/tool/lemon.c
+++ b/tool/lemon.c
@@ -2521,12 +2521,14 @@ void Parse(struct lemon *gp)
   if( filebuf==0 ){
 ErrorMsg(ps.filename,0,"Can't allocate %d of memory to hold this file.",
   filesize+1);
+fclose(fp);
 gp->errorcnt++;
 return;
   }
   if( fread(filebuf,1,filesize,fp)!=filesize ){
 ErrorMsg(ps.filename,0,"Can't read in all %d bytes of this file.",
   filesize);
+fclose(fp);
 free(filebuf);
 gp->errorcnt++;
 return;
-- 
1.7.4.4

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