Skip to content

Commit 9efa963

Browse files
committed
[vtable] Rename Context to SQLiteContext
To not conflict with core "context" package naming.
1 parent 618e784 commit 9efa963

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

_example/vtable/vtable.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package main
33
import (
44
"encoding/json"
55
"fmt"
6-
"github.com/mattn/go-sqlite3"
6+
"github.com/DataDog/go-sqlite3"
77
"io/ioutil"
88
"net/http"
99
)
@@ -73,7 +73,7 @@ type ghRepoCursor struct {
7373
repos []GithubRepo
7474
}
7575

76-
func (vc *ghRepoCursor) Column(c *sqlite3.Context, col int) error {
76+
func (vc *ghRepoCursor) Column(c *sqlite3.SQLiteContext, col int) error {
7777
switch col {
7878
case 0:
7979
c.ResultInt(vc.repos[vc.index].ID)

context.go renamed to sqlite_context.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ import (
3535
const i64 = unsafe.Sizeof(int(0)) > 4
3636

3737
type ZeroBlobLength int32
38-
type Context C.sqlite3_context
38+
type SQLiteContext C.sqlite3_context
3939

4040
// ResultBool sets the result of an SQL function.
41-
func (c *Context) ResultBool(b bool) {
41+
func (c *SQLiteContext) ResultBool(b bool) {
4242
if b {
4343
c.ResultInt(1)
4444
} else {
@@ -48,7 +48,7 @@ func (c *Context) ResultBool(b bool) {
4848

4949
// ResultBlob sets the result of an SQL function.
5050
// See: sqlite3_result_blob, http://sqlite.org/c3ref/result_blob.html
51-
func (c *Context) ResultBlob(b []byte) {
51+
func (c *SQLiteContext) ResultBlob(b []byte) {
5252
if i64 && len(b) > math.MaxInt32 {
5353
C.sqlite3_result_error_toobig((*C.sqlite3_context)(c))
5454
return
@@ -62,13 +62,13 @@ func (c *Context) ResultBlob(b []byte) {
6262

6363
// ResultDouble sets the result of an SQL function.
6464
// See: sqlite3_result_double, http://sqlite.org/c3ref/result_blob.html
65-
func (c *Context) ResultDouble(d float64) {
65+
func (c *SQLiteContext) ResultDouble(d float64) {
6666
C.sqlite3_result_double((*C.sqlite3_context)(c), C.double(d))
6767
}
6868

6969
// ResultInt sets the result of an SQL function.
7070
// See: sqlite3_result_int, http://sqlite.org/c3ref/result_blob.html
71-
func (c *Context) ResultInt(i int) {
71+
func (c *SQLiteContext) ResultInt(i int) {
7272
if i64 && (i > math.MaxInt32 || i < math.MinInt32) {
7373
C.sqlite3_result_int64((*C.sqlite3_context)(c), C.sqlite3_int64(i))
7474
} else {
@@ -78,26 +78,26 @@ func (c *Context) ResultInt(i int) {
7878

7979
// ResultInt64 sets the result of an SQL function.
8080
// See: sqlite3_result_int64, http://sqlite.org/c3ref/result_blob.html
81-
func (c *Context) ResultInt64(i int64) {
81+
func (c *SQLiteContext) ResultInt64(i int64) {
8282
C.sqlite3_result_int64((*C.sqlite3_context)(c), C.sqlite3_int64(i))
8383
}
8484

8585
// ResultNull sets the result of an SQL function.
8686
// See: sqlite3_result_null, http://sqlite.org/c3ref/result_blob.html
87-
func (c *Context) ResultNull() {
87+
func (c *SQLiteContext) ResultNull() {
8888
C.sqlite3_result_null((*C.sqlite3_context)(c))
8989
}
9090

9191
// ResultText sets the result of an SQL function.
9292
// See: sqlite3_result_text, http://sqlite.org/c3ref/result_blob.html
93-
func (c *Context) ResultText(s string) {
93+
func (c *SQLiteContext) ResultText(s string) {
9494
h := (*reflect.StringHeader)(unsafe.Pointer(&s))
9595
cs, l := (*C.char)(unsafe.Pointer(h.Data)), C.int(h.Len)
9696
C.my_result_text((*C.sqlite3_context)(c), cs, l)
9797
}
9898

9999
// ResultZeroblob sets the result of an SQL function.
100100
// See: sqlite3_result_zeroblob, http://sqlite.org/c3ref/result_blob.html
101-
func (c *Context) ResultZeroblob(n ZeroBlobLength) {
101+
func (c *SQLiteContext) ResultZeroblob(n ZeroBlobLength) {
102102
C.sqlite3_result_zeroblob((*C.sqlite3_context)(c), C.int(n))
103103
}

vtable.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ func goVEof(pCursor unsafe.Pointer) C.int {
294294
//export goVColumn
295295
func goVColumn(pCursor, cp unsafe.Pointer, col int) *C.char {
296296
vtc := lookupHandle(uintptr(pCursor)).(*sqliteVTabCursor)
297-
c := (*Context)(cp)
297+
c := (*SQLiteContext)(cp)
298298
err := vtc.vTabCursor.Column(c, col)
299299
if err != nil {
300300
return mPrintf("%s", err.Error())
@@ -349,7 +349,7 @@ type VTabCursor interface {
349349
// http://sqlite.org/vtab.html#xeof
350350
EOF() bool
351351
// http://sqlite.org/vtab.html#xcolumn
352-
Column(c *Context, col int) error
352+
Column(c *SQLiteContext, col int) error
353353
// http://sqlite.org/vtab.html#xrowid
354354
Rowid() (int64, error)
355355
}

vtable_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func (vc *testVTabCursor) EOF() bool {
9494
return vc.index >= len(vc.vTab.intarray)
9595
}
9696

97-
func (vc *testVTabCursor) Column(c *Context, col int) error {
97+
func (vc *testVTabCursor) Column(c *SQLiteContext, col int) error {
9898
if col != 0 {
9999
return fmt.Errorf("column index out of bounds: %d", col)
100100
}

0 commit comments

Comments
 (0)