bpo-44079: Strip superfluous statement cache from sqlite3.Connection (GH-25998)

This commit is contained in:
Erlend Egeberg Aasland 2021-08-19 01:37:53 +02:00 committed by GitHub
parent b2f68b1900
commit 243b6c3b8f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 116 deletions

View file

@ -118,7 +118,6 @@ pysqlite_statement_create(pysqlite_Connection *connection, PyObject *sql)
self->st = stmt;
self->in_use = 0;
self->is_dml = is_dml;
self->in_weakreflist = NULL;
PyObject_GC_Track(self);
return self;
@ -361,23 +360,6 @@ pysqlite_statement_bind_parameters(pysqlite_state *state,
}
}
int pysqlite_statement_finalize(pysqlite_Statement* self)
{
int rc;
rc = SQLITE_OK;
if (self->st) {
Py_BEGIN_ALLOW_THREADS
rc = sqlite3_finalize(self->st);
Py_END_ALLOW_THREADS
self->st = NULL;
}
self->in_use = 0;
return rc;
}
int pysqlite_statement_reset(pysqlite_Statement* self)
{
int rc;
@ -407,9 +389,6 @@ stmt_dealloc(pysqlite_Statement *self)
{
PyTypeObject *tp = Py_TYPE(self);
PyObject_GC_UnTrack(self);
if (self->in_weakreflist != NULL) {
PyObject_ClearWeakRefs((PyObject*)self);
}
if (self->st) {
Py_BEGIN_ALLOW_THREADS
sqlite3_finalize(self->st);
@ -497,12 +476,7 @@ static int pysqlite_check_remaining_sql(const char* tail)
return 0;
}
static PyMemberDef stmt_members[] = {
{"__weaklistoffset__", T_PYSSIZET, offsetof(pysqlite_Statement, in_weakreflist), READONLY},
{NULL},
};
static PyType_Slot stmt_slots[] = {
{Py_tp_members, stmt_members},
{Py_tp_dealloc, stmt_dealloc},
{Py_tp_traverse, stmt_traverse},
{0, NULL},