The strcmp might be misleading you, depending on the implementation if a parameter is actually NULL it can return 0. But the easiest thing would be to print the queries right before you call the exec function and see what it shows. Also how did you allocate the query value that is passed in?
Sandy -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 28, 2004 12:43 PM To: sqlite-users@sqlite.org Subject: Re: [sqlite] Running out of memory Hi All, To give some more information void myfunction(char* query) { printf(" Query is: %s \n",query); char* newquery = "insert into sdb (id,resclass,type,manufacturer,method,ownership,precision,minrange,maxrange, capacity) values (43,'HARDWARE','MONITOR','GE','NA','XYZ',0,0,4,2)" int cmpval = strcmp(query,newquery); if (cmpval == 0) printf("strings match \n"); else printf("Strings dont match\n") printf("------------------------------------------\n"); rc = sqlite3_exec(db,query, NULL, 0, &zErrMsg); if( rc!=SQLITE_OK ) { fprintf(stderr, "SQL error while registering: %s\n",zErrMsg); } } Now if I use sqlite3_exec(db,newquery, NULL, 0, &zErrMsg) it works fine. But if I use sqlite3_exec(db,query, NULL, 0, &zErrMsg); it gives me the unrecognized token "" error. Eventhough my strcmp function tells me that the two strings match, but sql_exec does not think so. I am bit confused as to why the same hard-coded string works but not the other one. Any help on this would be great. Regards, --Sameer. On Tue, 28 Dec 2004, D. Richard Hipp wrote: > Roger Binns wrote: > > [M]ost software does not play well with running out of memory... > > > > FWIW: If a malloc() ever fails with SQLite, it will return > SQLITE_NOMEM. It also sets a flag and will forever after > continue to return SQLITE_NOMEM even if you free up a bunch > of memory so that malloc() would start working again. There > is no way to reset this condition. Once a malloc() fails, > the party is over and you might as well shut down the process. > > If malloc() fails, SQLite might also leak memory. (Ironic, > isn't it?) > > The only guarantees that SQLite makes after a malloc failure > is that it will not abort() or panic() or segfault. Basically, > it just gives you a chance to shutdown gracefully. This might > not sound like much, but as Roger points out, it is a lot > more than most other software packages offer. > >