Re: [sqlite] question about proper use of prepare_v2()

2013-07-27 Thread Maxim Khitrov
On Sat, Jul 27, 2013 at 2:04 AM, Stephan Beal  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, , );
> 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


[sqlite] question about proper use of prepare_v2()

2013-07-27 Thread Stephan Beal
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, , );
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)???

:-?

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users