Skip to content

Commit 916db29

Browse files
author
Erlend E. Aasland
committed
Move _pysqlite_connection_begin to cursor.c
1 parent 90bac9c commit 916db29

File tree

3 files changed

+36
-38
lines changed

3 files changed

+36
-38
lines changed

Modules/_sqlite/connection.c

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -372,42 +372,6 @@ int pysqlite_check_connection(pysqlite_Connection* con)
372372
}
373373
}
374374

375-
int
376-
_pysqlite_connection_begin(pysqlite_Connection *self)
377-
{
378-
int rc;
379-
sqlite3_stmt* statement;
380-
381-
Py_BEGIN_ALLOW_THREADS
382-
rc = sqlite3_prepare_v2(self->db, self->begin_statement, -1, &statement,
383-
NULL);
384-
Py_END_ALLOW_THREADS
385-
386-
if (rc != SQLITE_OK) {
387-
_pysqlite_seterror(self->db);
388-
goto error;
389-
}
390-
391-
rc = pysqlite_step(statement, self);
392-
if (rc != SQLITE_DONE) {
393-
_pysqlite_seterror(self->db);
394-
}
395-
396-
Py_BEGIN_ALLOW_THREADS
397-
rc = sqlite3_finalize(statement);
398-
Py_END_ALLOW_THREADS
399-
400-
if (rc != SQLITE_OK && !PyErr_Occurred()) {
401-
_pysqlite_seterror(self->db);
402-
}
403-
404-
error:
405-
if (PyErr_Occurred()) {
406-
return -1;
407-
}
408-
return 0;
409-
}
410-
411375
/*[clinic input]
412376
_sqlite3.Connection.commit as pysqlite_connection_commit
413377

Modules/_sqlite/connection.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@ typedef struct
108108

109109
extern PyTypeObject *pysqlite_ConnectionType;
110110

111-
int _pysqlite_connection_begin(pysqlite_Connection *self);
112-
113111
int pysqlite_connection_register_cursor(pysqlite_Connection* connection, PyObject* cursor);
114112
int pysqlite_check_thread(pysqlite_Connection* self);
115113
int pysqlite_check_connection(pysqlite_Connection* con);

Modules/_sqlite/cursor.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,42 @@ static int check_cursor(pysqlite_Cursor* cur)
395395
return pysqlite_check_thread(cur->connection) && pysqlite_check_connection(cur->connection);
396396
}
397397

398+
static int
399+
_pysqlite_connection_begin(pysqlite_Connection *self)
400+
{
401+
int rc;
402+
sqlite3_stmt* statement;
403+
404+
Py_BEGIN_ALLOW_THREADS
405+
rc = sqlite3_prepare_v2(self->db, self->begin_statement, -1, &statement,
406+
NULL);
407+
Py_END_ALLOW_THREADS
408+
409+
if (rc != SQLITE_OK) {
410+
_pysqlite_seterror(self->db);
411+
goto error;
412+
}
413+
414+
rc = pysqlite_step(statement, self);
415+
if (rc != SQLITE_DONE) {
416+
_pysqlite_seterror(self->db);
417+
}
418+
419+
Py_BEGIN_ALLOW_THREADS
420+
rc = sqlite3_finalize(statement);
421+
Py_END_ALLOW_THREADS
422+
423+
if (rc != SQLITE_OK && !PyErr_Occurred()) {
424+
_pysqlite_seterror(self->db);
425+
}
426+
427+
error:
428+
if (PyErr_Occurred()) {
429+
return -1;
430+
}
431+
return 0;
432+
}
433+
398434
static PyObject *
399435
_pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* operation, PyObject* second_argument)
400436
{

0 commit comments

Comments
 (0)