Skip to content

Commit 866c329

Browse files
committed
fix breaking compatibility.
revert cf4bd56 close #394
1 parent bd7fdb6 commit 866c329

File tree

4 files changed

+15
-16
lines changed

4 files changed

+15
-16
lines changed

backup.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (b *SQLiteBackup) Step(p int) (bool, error) {
4848
if ret == C.SQLITE_DONE {
4949
return true, nil
5050
} else if ret != 0 && ret != C.SQLITE_LOCKED && ret != C.SQLITE_BUSY {
51-
return false, &Error{Code: ErrNo(ret)}
51+
return false, Error{Code: ErrNo(ret)}
5252
}
5353
return false, nil
5454
}
@@ -79,7 +79,7 @@ func (b *SQLiteBackup) Close() error {
7979
runtime.SetFinalizer(b, nil)
8080

8181
if ret != 0 {
82-
return &Error{Code: ErrNo(ret)}
82+
return Error{Code: ErrNo(ret)}
8383
}
8484
return nil
8585
}

error.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ var (
5858

5959
// Error return error message from errno.
6060
func (err ErrNo) Error() string {
61-
return (&Error{Code: err}).Error()
61+
return Error{Code: err}.Error()
6262
}
6363

6464
// Extend return extended errno.
@@ -68,11 +68,10 @@ func (err ErrNo) Extend(by int) ErrNoExtended {
6868

6969
// Error return error message that is extended code.
7070
func (err ErrNoExtended) Error() string {
71-
return (&Error{Code: ErrNo(C.int(err) & ErrNoMask), ExtendedCode: err}).Error()
71+
return Error{Code: ErrNo(C.int(err) & ErrNoMask), ExtendedCode: err}.Error()
7272
}
7373

74-
// Error return error message.
75-
func (err *Error) Error() string {
74+
func (err Error) Error() string {
7675
if err.err != "" {
7776
return err.err
7877
}

error_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func TestCorruptDbErrors(t *testing.T) {
4040
_, err = db.Exec("drop table foo")
4141
}
4242

43-
sqliteErr := err.(*Error)
43+
sqliteErr := err.(Error)
4444
if sqliteErr.Code != ErrNotADB {
4545
t.Error("wrong error code for corrupted DB")
4646
}
@@ -110,7 +110,7 @@ func TestExtendedErrorCodes_ForeignKey(t *testing.T) {
110110
if err == nil {
111111
t.Error("No error!")
112112
} else {
113-
sqliteErr := err.(*Error)
113+
sqliteErr := err.(Error)
114114
if sqliteErr.Code != ErrConstraint {
115115
t.Errorf("Wrong basic error code: %d != %d",
116116
sqliteErr.Code, ErrConstraint)
@@ -166,7 +166,7 @@ func TestExtendedErrorCodes_NotNull(t *testing.T) {
166166
if err == nil {
167167
t.Error("No error!")
168168
} else {
169-
sqliteErr := err.(*Error)
169+
sqliteErr := err.(Error)
170170
if sqliteErr.Code != ErrConstraint {
171171
t.Errorf("Wrong basic error code: %d != %d",
172172
sqliteErr.Code, ErrConstraint)
@@ -222,7 +222,7 @@ func TestExtendedErrorCodes_Unique(t *testing.T) {
222222
if err == nil {
223223
t.Error("No error!")
224224
} else {
225-
sqliteErr := err.(*Error)
225+
sqliteErr := err.(Error)
226226
if sqliteErr.Code != ErrConstraint {
227227
t.Errorf("Wrong basic error code: %d != %d",
228228
sqliteErr.Code, ErrConstraint)

sqlite3.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ func (ai *aggInfo) Done(ctx *C.sqlite3_context) {
298298
// Commit transaction.
299299
func (tx *SQLiteTx) Commit() error {
300300
_, err := tx.c.exec(context.Background(), "COMMIT", nil)
301-
if err != nil && err.(*Error).Code == C.SQLITE_BUSY {
301+
if err != nil && err.(Error).Code == C.SQLITE_BUSY {
302302
// sqlite3 will leave the transaction open in this scenario.
303303
// However, database/sql considers the transaction complete once we
304304
// return from Commit() - we must clean up to honour its semantics.
@@ -399,12 +399,12 @@ func (c *SQLiteConn) AutoCommit() bool {
399399
return int(C.sqlite3_get_autocommit(c.db)) != 0
400400
}
401401

402-
func (c *SQLiteConn) lastError() *Error {
402+
func (c *SQLiteConn) lastError() error {
403403
rv := C.sqlite3_errcode(c.db)
404404
if rv == C.SQLITE_OK {
405405
return nil
406406
}
407-
return &Error{
407+
return Error{
408408
Code: ErrNo(rv),
409409
ExtendedCode: ErrNoExtended(C.sqlite3_extended_errcode(c.db)),
410410
err: C.GoString(C.sqlite3_errmsg(c.db)),
@@ -519,7 +519,7 @@ func (c *SQLiteConn) begin(ctx context.Context) (driver.Tx, error) {
519519
return &SQLiteTx{c}, nil
520520
}
521521

522-
func errorString(err *Error) string {
522+
func errorString(err Error) string {
523523
return C.GoString(C.sqlite3_errstr(C.int(err.Code)))
524524
}
525525

@@ -601,15 +601,15 @@ func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) {
601601
C.SQLITE_OPEN_CREATE,
602602
nil)
603603
if rv != 0 {
604-
return nil, &Error{Code: ErrNo(rv)}
604+
return nil, Error{Code: ErrNo(rv)}
605605
}
606606
if db == nil {
607607
return nil, errors.New("sqlite succeeded without returning a database")
608608
}
609609

610610
rv = C.sqlite3_busy_timeout(db, C.int(busyTimeout))
611611
if rv != C.SQLITE_OK {
612-
return nil, &Error{Code: ErrNo(rv)}
612+
return nil, Error{Code: ErrNo(rv)}
613613
}
614614

615615
conn := &SQLiteConn{db: db, loc: loc, txlock: txlock}

0 commit comments

Comments
 (0)