/* ** Terminate the current execution of a virtual machine then ** reset the virtual machine back to its starting state so that it ** can be reused. Any error message resulting from the prior execution ** is written into *pzErrMsg. A success code from the prior execution ** is returned. */ int sqlite_reset( sqlite_vm *pVm, /* The virtual machine to be destroyed */ char **pzErrMsg /* OUT: Write error messages here */ ){ int rc = sqliteVdbeReset((Vdbe*)pVm, pzErrMsg); sqliteVdbeMakeReady((Vdbe*)pVm, -1, 0); sqliteStrRealloc(pzErrMsg); return rc; }
/* ** Clean up and delete a VDBE after execution. Return an integer which is ** the result code. Write any error message text into *pzErrMsg. */ int sqliteVdbeFinalize(Vdbe *p, char **pzErrMsg){ int rc; sqlite *db; if( p->magic!=VDBE_MAGIC_RUN && p->magic!=VDBE_MAGIC_HALT ){ sqliteSetString(pzErrMsg, sqlite_error_string(SQLITE_MISUSE), (char*)0); return SQLITE_MISUSE; } db = p->db; rc = sqliteVdbeReset(p, pzErrMsg); sqliteVdbeDelete(p); if( db->want_to_close && db->pVdbe==0 ){ sqlite_close(db); } if( rc==SQLITE_SCHEMA ){ sqliteResetInternalSchema(db, 0); } return rc; }