You want your assert to be this:


assert(stmt != NULL);





Michael D. Black

Senior Scientist

Advanced Analytics Directorate

Advanced GEOINT Solutions Operating Unit

Northrop Grumman Information Systems

________________________________
From: [email protected] [[email protected]] on 
behalf of Rafael Ávila de Espíndola [[email protected]]
Sent: Monday, April 09, 2012 9:06 AM
To: [email protected]
Subject: EXT :[sqlite] case where sqlite3_prepare_v2 returns OK and sets stmt 
to NULL

Is it expected that the following program should run without asserting?

-----------------------
#include <sqlite3.h>
#include <stdlib.h>
#include <assert.h>

int main() {
   sqlite3 *db = NULL;
   int rc;
   rc = sqlite3_open("test.db", &db);
   assert(rc == SQLITE_OK);
   assert(db);
   sqlite3_stmt *stmt = NULL;
   rc = sqlite3_prepare_v2(db, "/* foobar", -1, &stmt, NULL);
   assert(rc == SQLITE_OK);
   assert(stmt == NULL);
   return 0;
}
-----------------------

I was expecting sqlite3_prepare_v2 to return an error code since the
comment is not terminated. Even if it was, the documentation is only
clear that a string with no SQL produces a NULL stmt, not what the
return code is in that situation.

Cheers,
Rafael
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to