if( db->xTrace ){
if( db->xTrace && !db->init.busy ){
int sqlite_compile(  sqlite *db,                 /* The database on which the SQL executes */  const char *zSql,           /* The SQL to be executed */  const char **pzTail,        /* OUT: Next statement after the first */  sqlite_vm **ppVm,           /* OUT: The virtual machine */  char **pzErrMsg             /* OUT: Write error messages here */){  Parse sParse;  if( pzErrMsg ) *pzErrMsg = 0;  if( sqliteSafetyOn(db) ) goto exec_misuse;  if( !db->init.busy ){    if( (db->flags & SQLITE_Initialized)==0 ){      int rc, cnt = 1;      while( (rc = sqliteInit(db, pzErrMsg))==SQLITE_BUSY         && db->xBusyCallback         && db->xBusyCallback(db->pBusyArg, "", cnt++)!=0 ){}      if( rc!=SQLITE_OK ){        sqliteStrRealloc(pzErrMsg);        sqliteSafetyOff(db);        return rc;      }      if( pzErrMsg ){        sqliteFree(*pzErrMsg);        *pzErrMsg = 0;      }    }    if( db->file_format<3 ){      sqliteSafetyOff(db);      sqliteSetString(pzErrMsg, "obsolete database file format", (char*)0);      return SQLITE_ERROR;    }  }  assert( (db->flags & SQLITE_Initialized)!=0 || db->init.busy );  if( db->pVdbe==0 ){ db->nChange = 0; }  memset(&sParse, 0, sizeof(sParse));  sParse.db = db;  sqliteRunParser(&sParse, zSql, pzErrMsg);  if( db->xTrace ){    /* Trace only the statment that was compiled.    ** Make a copy of that part of the SQL string since zSQL is const    ** and we must pass a zero terminated string to the trace function    ** The copy is unnecessary if the tail pointer is pointing at the    ** beginnig or end of the SQL string.    */    if( sParse.zTail && sParse.zTail!=zSql && *sParse.zTail ){      char *tmpSql = sqliteStrNDup(zSql, sParse.zTail - zSql);      if( tmpSql ){        db->xTrace(db->pTraceArg, tmpSql);        free(tmpSql);      }else{        /* If a memory error occurred during the copy,        ** trace entire SQL string and fall through to the        ** sqlite_malloc_failed test to report the error.        */        db->xTrace(db->pTraceArg, zSql);       }    }else{      db->xTrace(db->pTraceArg, zSql);     }  }  if( sqlite_malloc_failed ){    sqliteSetString(pzErrMsg, "out of memory", (char*)0);    sParse.rc = SQLITE_NOMEM;    sqliteRollbackAll(db);    sqliteResetInternalSchema(db, 0);    db->flags &= ~SQLITE_InTrans;  }  if( sParse.rc==SQLITE_DONE ) sParse.rc = SQLITE_OK;  if( sParse.rc!=SQLITE_OK && pzErrMsg && *pzErrMsg==0 ){    sqliteSetString(pzErrMsg, sqlite_error_string(sParse.rc), (char*)0);  }  sqliteStrRealloc(pzErrMsg);  if( sParse.rc==SQLITE_SCHEMA ){    sqliteResetInternalSchema(db, 0);  }  assert( ppVm );  *ppVm = (sqlite_vm*)sParse.pVdbe;  if( pzTail ) *pzTail = sParse.zTail;  if( sqliteSafetyOff(db) ) goto exec_misuse;  return sParse.rc;exec_misuse:  if( pzErrMsg ){    *pzErrMsg = 0;    sqliteSetString(pzErrMsg, sqlite_error_string(SQLITE_MISUSE), (char*)0);    sqliteStrRealloc(pzErrMsg);  }  return SQLITE_MISUSE;}