Avoid sqlite3_clear_bindings()
Friday, August 03, 2012, Modified: Friday, August 03, 2012 Refs

Some SQLite examples you will find out on the web will use sqlite3_clear_bindings() as a matter of course at some point in among finishing with a prepared statement, resetting it, and binding new parameters to it. Don't bother with this clearing step. sqlite3_clear_bindings() is a convenience if some of a statement's parameters are left as null and only an unpredictable subset of them are set for each use. In that case, setting all to null in one call could be a win and at least save some code (see: http:[email protected]/msg38940.html).

The code for the function from SQLite 3.7.13 shows that it is taking a mutex and then attempting a memory free (via several levels of function calls) per parameter.

** Set all the parameters in the compiled SQL statement to NULL.
SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt *pStmt){
  int i;
  int rc = SQLITE_OK;
  Vdbe *p = (Vdbe*)pStmt;
  sqlite3_mutex *mutex = ((Vdbe*)pStmt)->db->mutex;
  for(i=0; inVar; i++){
    p->aVar[i].flags = MEM_Null;
  if( p->isPrepareV2 && p->expmask ){
    p->expired = 1;
  return rc;

Try Buffer, a smarter way to share links and pictures by spreading your tweets and posts out over time. Sign up from this link and we both get extra features.

Home :: Items