/* action in (ACTION_RESET, ACTION_FINALIZE) */ void pysqlite_do_all_statements(pysqlite_Connection* self, int action) { int i; PyObject* weakref; PyObject* statement; pysqlite_Cursor* cursor; for (i = 0; i < PyList_Size(self->statements); i++) { weakref = PyList_GetItem(self->statements, i); statement = PyWeakref_GetObject(weakref); if (statement != Py_None) { if (action == ACTION_RESET) { (void)pysqlite_statement_reset((pysqlite_Statement*)statement); } else { (void)pysqlite_statement_finalize((pysqlite_Statement*)statement); } } } for (i = 0; i < PyList_Size(self->cursors); i++) { weakref = PyList_GetItem(self->cursors, i); cursor = (pysqlite_Cursor*)PyWeakref_GetObject(weakref); if ((PyObject*)cursor != Py_None) { cursor->reset = 1; } } }
/* Empty the entire statement cache of this connection */ void pysqlite_flush_statement_cache(pysqlite_Connection* self) { pysqlite_Node* node; pysqlite_Statement* statement; node = self->statement_cache->first; while (node) { statement = (pysqlite_Statement*)(node->data); (void)pysqlite_statement_finalize(statement); node = node->next; } Py_DECREF(self->statement_cache); self->statement_cache = (pysqlite_Cache*)PyObject_CallFunction((PyObject*)&pysqlite_CacheType, "O", self); Py_DECREF(self); self->statement_cache->decref_factory = 0; }