forked from mirror/go-sqlite3
Add fix for go-sqlite3 truncating 64-bit integers when compiled by 32-bit mingw-gcc on windows by converting 'long' variable types to 'long long' in sqlite3.go
This commit is contained in:
parent
b4142c444a
commit
6b4ee3cb4f
16
sqlite3.go
16
sqlite3.go
|
@ -48,21 +48,21 @@ _sqlite3_bind_blob(sqlite3_stmt *stmt, int n, void *p, int np) {
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_sqlite3_exec(sqlite3* db, const char* pcmd, long* rowid, long* changes)
|
_sqlite3_exec(sqlite3* db, const char* pcmd, long long* rowid, long long* changes)
|
||||||
{
|
{
|
||||||
int rv = sqlite3_exec(db, pcmd, 0, 0, 0);
|
int rv = sqlite3_exec(db, pcmd, 0, 0, 0);
|
||||||
*rowid = (long) sqlite3_last_insert_rowid(db);
|
*rowid = (long long) sqlite3_last_insert_rowid(db);
|
||||||
*changes = (long) sqlite3_changes(db);
|
*changes = (long long) sqlite3_changes(db);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_sqlite3_step(sqlite3_stmt* stmt, long* rowid, long* changes)
|
_sqlite3_step(sqlite3_stmt* stmt, long long* rowid, long long* changes)
|
||||||
{
|
{
|
||||||
int rv = sqlite3_step(stmt);
|
int rv = sqlite3_step(stmt);
|
||||||
sqlite3* db = sqlite3_db_handle(stmt);
|
sqlite3* db = sqlite3_db_handle(stmt);
|
||||||
*rowid = (long) sqlite3_last_insert_rowid(db);
|
*rowid = (long long) sqlite3_last_insert_rowid(db);
|
||||||
*changes = (long) sqlite3_changes(db);
|
*changes = (long long) sqlite3_changes(db);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,7 +243,7 @@ func (c *SQLiteConn) exec(cmd string) (driver.Result, error) {
|
||||||
pcmd := C.CString(cmd)
|
pcmd := C.CString(cmd)
|
||||||
defer C.free(unsafe.Pointer(pcmd))
|
defer C.free(unsafe.Pointer(pcmd))
|
||||||
|
|
||||||
var rowid, changes C.long
|
var rowid, changes C.longlong
|
||||||
rv := C._sqlite3_exec(c.db, pcmd, &rowid, &changes)
|
rv := C._sqlite3_exec(c.db, pcmd, &rowid, &changes)
|
||||||
if rv != C.SQLITE_OK {
|
if rv != C.SQLITE_OK {
|
||||||
return nil, c.lastError()
|
return nil, c.lastError()
|
||||||
|
@ -536,7 +536,7 @@ func (s *SQLiteStmt) Exec(args []driver.Value) (driver.Result, error) {
|
||||||
C.sqlite3_clear_bindings(s.s)
|
C.sqlite3_clear_bindings(s.s)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
var rowid, changes C.long
|
var rowid, changes C.longlong
|
||||||
rv := C._sqlite3_step(s.s, &rowid, &changes)
|
rv := C._sqlite3_step(s.s, &rowid, &changes)
|
||||||
if rv != C.SQLITE_ROW && rv != C.SQLITE_OK && rv != C.SQLITE_DONE {
|
if rv != C.SQLITE_ROW && rv != C.SQLITE_OK && rv != C.SQLITE_DONE {
|
||||||
err := s.c.lastError()
|
err := s.c.lastError()
|
||||||
|
|
Loading…
Reference in New Issue