Skip to content

Commit b66adaf

Browse files
Use 64-bit API if available
1 parent 9e44c0c commit b66adaf

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

Modules/_sqlite/cursor.c

+13-3
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,16 @@ stmt_mark_dirty(pysqlite_Statement *self)
776776
self->in_use = 1;
777777
}
778778

779+
static inline sqlite3_int64
780+
changes(sqlite3 *db)
781+
{
782+
#if SQLITE_VERSION_NUMBER >= 3037000
783+
return sqlite3_changes64(db);
784+
#else
785+
return (sqlite3_int64)sqlite3_changes(db);
786+
#endif
787+
}
788+
779789
PyObject *
780790
_pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* operation, PyObject* second_argument)
781791
{
@@ -945,12 +955,12 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* operation
945955
}
946956

947957
if (self->statement->is_dml && rc == SQLITE_DONE && multiple) {
948-
self->rowcount += (long)sqlite3_changes(self->connection->db);
958+
self->rowcount += changes(self->connection->db);
949959
}
950960

951961
if (rc == SQLITE_DONE && !multiple) {
952962
if (self->statement->is_dml) {
953-
self->rowcount = (long)sqlite3_changes(self->connection->db);
963+
self->rowcount = changes(self->connection->db);
954964
}
955965
stmt_reset(self->statement);
956966
Py_CLEAR(self->statement);
@@ -1127,7 +1137,7 @@ pysqlite_cursor_iternext(pysqlite_Cursor *self)
11271137
int rc = stmt_step(stmt);
11281138
if (rc == SQLITE_DONE) {
11291139
if (self->statement->is_dml) {
1130-
self->rowcount = (long)sqlite3_changes(self->connection->db);
1140+
self->rowcount = changes(self->connection->db);
11311141
}
11321142
(void)stmt_reset(self->statement);
11331143
}

Modules/_sqlite/cursor.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ typedef struct
3838
PyObject* row_cast_map;
3939
int arraysize;
4040
PyObject* lastrowid;
41-
long rowcount;
41+
sqlite3_int64 rowcount;
4242
PyObject* row_factory;
4343
pysqlite_Statement* statement;
4444
int closed;

0 commit comments

Comments
 (0)