On Sat, Jul 27, 2013 at 2:04 AM, Stephan Beal <sgb...@googlemail.com> wrote:
> Hi, all,
>
> i'm porting some code from one sqlite3-using project (Fossil SCM) to
> another sqlite3-using project (a prototype for Fossil v2) and i came across
> this code snippet:
>
>   while( rc==SQLITE_OK && z[0] ){
>     pStmt = 0; // <==== type=(sqlite3_stmt*)
>     rc = sqlite3_prepare_v2(g.db, z, -1, &pStmt, &zEnd);
>     if( rc!=SQLITE_OK ) break;
>     if( pStmt ){
>    ...
>     }
>     z = zEnd;
>   }
>
> My question is: is the if(pStmt) block there a case of too much error
> handling, or can it really happen that prepare() returns OK but also leaves
> pStmt as NULL (e.g. for an empty SQL statement)???

pStmt will be NULL if zSql contains only a comment or whitespace. There
is a comment about this in sqlite3_exec (legacy.c).
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to