-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresult.go
34 lines (29 loc) · 832 Bytes
/
result.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package mysqlx
import (
"errors"
"math"
)
type result struct {
hasLastInsertID bool
lastInsertID uint64 // protocol defines as uint64, database/sql as int64
hasRowsAffected bool
rowsAffected uint64 // protocol defines as uint64, database/sql as int64
hasRowsMatched bool
rowsMatched uint64
hasRowsFound bool
rowsFound uint64
}
// ErrInt64Overflow is the error return when an int64
var ErrInt64Overflow = errors.New("Value exceeded math.MaxInt64")
func (r *result) LastInsertId() (int64, error) {
if r.lastInsertID > math.MaxInt64 {
return int64(r.lastInsertID), ErrInt64Overflow
}
return int64(r.lastInsertID), nil
}
func (r *result) RowsAffected() (int64, error) {
if r.rowsAffected > math.MaxInt64 {
return int64(r.rowsAffected), ErrInt64Overflow
}
return int64(r.rowsAffected), nil
}