Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gosqlite
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gosqlite
Commits
ebcb34c3
Commit
ebcb34c3
authored
May 22, 2014
by
gwenn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Golint
parent
3178e848
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
54 additions
and
43 deletions
+54
-43
config.go
config.go
+1
-0
csv.go
csv.go
+3
-2
hook.c
hook.c
+1
-1
hook.go
hook.go
+3
-3
hook_test.go
hook_test.go
+3
-3
intarray.go
intarray.go
+9
-9
limit.go
limit.go
+1
-0
meta.go
meta.go
+1
-0
pool.go
pool.go
+2
-2
pragma.go
pragma.go
+7
-7
pragma_test.go
pragma_test.go
+10
-10
sqlite.go
sqlite.go
+3
-0
stmt.go
stmt.go
+1
-0
stmt_test.go
stmt_test.go
+2
-2
trace.go
trace.go
+3
-0
vtab.go
vtab.go
+2
-2
vtab_test.go
vtab_test.go
+2
-2
No files found.
config.go
View file @
ebcb34c3
...
@@ -24,6 +24,7 @@ import "unsafe"
...
@@ -24,6 +24,7 @@ import "unsafe"
// See ConfigThreadingMode
// See ConfigThreadingMode
type
ThreadingMode
int32
type
ThreadingMode
int32
// SQLite threading modes
const
(
const
(
SingleThread
ThreadingMode
=
C
.
SQLITE_CONFIG_SINGLETHREAD
SingleThread
ThreadingMode
=
C
.
SQLITE_CONFIG_SINGLETHREAD
MultiThread
ThreadingMode
=
C
.
SQLITE_CONFIG_MULTITHREAD
MultiThread
ThreadingMode
=
C
.
SQLITE_CONFIG_MULTITHREAD
...
...
csv.go
View file @
ebcb34c3
...
@@ -210,7 +210,7 @@ func (vc *csvTabCursor) Next() error {
...
@@ -210,7 +210,7 @@ func (vc *csvTabCursor) Next() error {
}
}
return
err
return
err
}
}
func
(
vc
*
csvTabCursor
)
E
of
()
bool
{
func
(
vc
*
csvTabCursor
)
E
OF
()
bool
{
return
vc
.
vTab
.
eof
return
vc
.
vTab
.
eof
}
}
func
(
vc
*
csvTabCursor
)
Column
(
c
*
Context
,
col
int
)
error
{
func
(
vc
*
csvTabCursor
)
Column
(
c
*
Context
,
col
int
)
error
{
...
@@ -254,7 +254,7 @@ func (db *Conn) ExportTableToCSV(dbName, table string, nullvalue string, headers
...
@@ -254,7 +254,7 @@ func (db *Conn) ExportTableToCSV(dbName, table string, nullvalue string, headers
return
s
.
ExportToCSV
(
nullvalue
,
headers
,
w
)
return
s
.
ExportToCSV
(
nullvalue
,
headers
,
w
)
}
}
// ExportT
ableT
oCSV export statement result to CSV.
// ExportToCSV export statement result to CSV.
// 'headers' flag turns output of headers on or off.
// 'headers' flag turns output of headers on or off.
// NULL values are output as specified by 'nullvalue' parameter.
// NULL values are output as specified by 'nullvalue' parameter.
func
(
s
*
Stmt
)
ExportToCSV
(
nullvalue
string
,
headers
bool
,
w
*
yacr
.
Writer
)
error
{
func
(
s
*
Stmt
)
ExportToCSV
(
nullvalue
string
,
headers
bool
,
w
*
yacr
.
Writer
)
error
{
...
@@ -283,6 +283,7 @@ func (s *Stmt) ExportToCSV(nullvalue string, headers bool, w *yacr.Writer) error
...
@@ -283,6 +283,7 @@ func (s *Stmt) ExportToCSV(nullvalue string, headers bool, w *yacr.Writer) error
return
w
.
Err
()
return
w
.
Err
()
}
}
// ImportConfig gathers import parameters.
type
ImportConfig
struct
{
type
ImportConfig
struct
{
Name
string
// the name of the input; used only for error reports
Name
string
// the name of the input; used only for error reports
Separator
byte
// CSV separator
Separator
byte
// CSV separator
...
...
hook.c
View file @
ebcb34c3
...
@@ -18,7 +18,7 @@ void* goSqlite3RollbackHook(sqlite3 *db, void *udp) {
...
@@ -18,7 +18,7 @@ void* goSqlite3RollbackHook(sqlite3 *db, void *udp) {
return
sqlite3_rollback_hook
(
db
,
goXRollbackHook
,
udp
);
return
sqlite3_rollback_hook
(
db
,
goXRollbackHook
,
udp
);
}
}
extern
void
goXUpdateHook
(
void
*
udp
,
int
action
,
char
const
*
dbName
,
char
const
*
tableName
,
sqlite3_int64
rowI
d
);
extern
void
goXUpdateHook
(
void
*
udp
,
int
action
,
char
const
*
dbName
,
char
const
*
tableName
,
sqlite3_int64
rowI
D
);
void
*
goSqlite3UpdateHook
(
sqlite3
*
db
,
void
*
udp
)
{
void
*
goSqlite3UpdateHook
(
sqlite3
*
db
,
void
*
udp
)
{
return
sqlite3_update_hook
(
db
,
goXUpdateHook
,
udp
);
return
sqlite3_update_hook
(
db
,
goXUpdateHook
,
udp
);
...
...
hook.go
View file @
ebcb34c3
...
@@ -74,7 +74,7 @@ func (c *Conn) RollbackHook(f RollbackHook, udp interface{}) {
...
@@ -74,7 +74,7 @@ func (c *Conn) RollbackHook(f RollbackHook, udp interface{}) {
}
}
// UpdateHook is the callback function signature.
// UpdateHook is the callback function signature.
type
UpdateHook
func
(
udp
interface
{},
a
Action
,
dbName
,
tableName
string
,
rowI
d
int64
)
type
UpdateHook
func
(
udp
interface
{},
a
Action
,
dbName
,
tableName
string
,
rowI
D
int64
)
type
sqliteUpdateHook
struct
{
type
sqliteUpdateHook
struct
{
f
UpdateHook
f
UpdateHook
...
@@ -82,9 +82,9 @@ type sqliteUpdateHook struct {
...
@@ -82,9 +82,9 @@ type sqliteUpdateHook struct {
}
}
//export goXUpdateHook
//export goXUpdateHook
func
goXUpdateHook
(
udp
unsafe
.
Pointer
,
action
int
,
dbName
,
tableName
*
C
.
char
,
rowI
d
C
.
sqlite3_int64
)
{
func
goXUpdateHook
(
udp
unsafe
.
Pointer
,
action
int
,
dbName
,
tableName
*
C
.
char
,
rowI
D
C
.
sqlite3_int64
)
{
arg
:=
(
*
sqliteUpdateHook
)(
udp
)
arg
:=
(
*
sqliteUpdateHook
)(
udp
)
arg
.
f
(
arg
.
udp
,
Action
(
action
),
C
.
GoString
(
dbName
),
C
.
GoString
(
tableName
),
int64
(
rowI
d
))
arg
.
f
(
arg
.
udp
,
Action
(
action
),
C
.
GoString
(
dbName
),
C
.
GoString
(
tableName
),
int64
(
rowI
D
))
}
}
// UpdateHook registers a callback to be invoked each time a row is updated,
// UpdateHook registers a callback to be invoked each time a row is updated,
...
...
hook_test.go
View file @
ebcb34c3
...
@@ -27,11 +27,11 @@ func rollbackHook(d interface{}) {
...
@@ -27,11 +27,11 @@ func rollbackHook(d interface{}) {
}
}
}
}
func
updateHook
(
d
interface
{},
a
Action
,
dbName
,
tableName
string
,
rowI
d
int64
)
{
func
updateHook
(
d
interface
{},
a
Action
,
dbName
,
tableName
string
,
rowI
D
int64
)
{
if
t
,
ok
:=
d
.
(
*
testing
.
T
);
ok
{
if
t
,
ok
:=
d
.
(
*
testing
.
T
);
ok
{
t
.
Logf
(
"UPD: %d, %s.%s.%d
\n
"
,
a
,
dbName
,
tableName
,
rowI
d
)
t
.
Logf
(
"UPD: %d, %s.%s.%d
\n
"
,
a
,
dbName
,
tableName
,
rowI
D
)
}
else
{
}
else
{
fmt
.
Printf
(
"%s: %d, %s.%s.%d
\n
"
,
d
,
a
,
dbName
,
tableName
,
rowI
d
)
fmt
.
Printf
(
"%s: %d, %s.%s.%d
\n
"
,
d
,
a
,
dbName
,
tableName
,
rowI
D
)
}
}
}
}
...
...
intarray.go
View file @
ebcb34c3
...
@@ -8,7 +8,7 @@ package sqlite
...
@@ -8,7 +8,7 @@ package sqlite
import
"fmt"
import
"fmt"
//
This
is the Go-language interface definition for the "intarray" or
//
IntArray
is the Go-language interface definition for the "intarray" or
// integer array virtual table for SQLite.
// integer array virtual table for SQLite.
//
//
// The intarray virtual table is designed to facilitate using an
// The intarray virtual table is designed to facilitate using an
...
@@ -89,17 +89,17 @@ func (m *intArray) Connect(c *Conn, args []string) (VTab, error) {
...
@@ -89,17 +89,17 @@ func (m *intArray) Connect(c *Conn, args []string) (VTab, error) {
func
(
m
*
intArray
)
DestroyModule
()
{
func
(
m
*
intArray
)
DestroyModule
()
{
}
}
func
(
v
*
intArray
)
BestIndex
()
error
{
func
(
m
*
intArray
)
BestIndex
()
error
{
return
nil
return
nil
}
}
func
(
v
*
intArray
)
Disconnect
()
error
{
func
(
m
*
intArray
)
Disconnect
()
error
{
return
nil
return
nil
}
}
func
(
v
*
intArray
)
Destroy
()
error
{
func
(
m
*
intArray
)
Destroy
()
error
{
return
nil
return
nil
}
}
func
(
v
*
intArray
)
Open
()
(
VTabCursor
,
error
)
{
func
(
m
*
intArray
)
Open
()
(
VTabCursor
,
error
)
{
return
&
intArrayVTabCursor
{
v
,
0
},
nil
return
&
intArrayVTabCursor
{
m
,
0
},
nil
}
}
type
intArrayVTabCursor
struct
{
type
intArrayVTabCursor
struct
{
...
@@ -118,7 +118,7 @@ func (vc *intArrayVTabCursor) Next() error {
...
@@ -118,7 +118,7 @@ func (vc *intArrayVTabCursor) Next() error {
vc
.
i
++
vc
.
i
++
return
nil
return
nil
}
}
func
(
vc
*
intArrayVTabCursor
)
E
of
()
bool
{
func
(
vc
*
intArrayVTabCursor
)
E
OF
()
bool
{
return
vc
.
i
>=
len
(
vc
.
vTab
.
content
)
return
vc
.
i
>=
len
(
vc
.
vTab
.
content
)
}
}
func
(
vc
*
intArrayVTabCursor
)
Column
(
c
*
Context
,
col
int
)
error
{
func
(
vc
*
intArrayVTabCursor
)
Column
(
c
*
Context
,
col
int
)
error
{
...
@@ -157,6 +157,6 @@ func (c *Conn) CreateIntArray(name string) (IntArray, error) {
...
@@ -157,6 +157,6 @@ func (c *Conn) CreateIntArray(name string) (IntArray, error) {
// The array of integers bound must be unchanged for the duration of
// The array of integers bound must be unchanged for the duration of
// any query against the corresponding virtual table. If the integer
// any query against the corresponding virtual table. If the integer
// array does change or is deallocated undefined behavior will result.
// array does change or is deallocated undefined behavior will result.
func
(
ia
*
intArray
)
Bind
(
elements
[]
int64
)
{
func
(
m
*
intArray
)
Bind
(
elements
[]
int64
)
{
ia
.
content
=
elements
m
.
content
=
elements
}
}
limit.go
View file @
ebcb34c3
...
@@ -15,6 +15,7 @@ import "C"
...
@@ -15,6 +15,7 @@ import "C"
// (See http://www.sqlite.org/c3ref/c_limit_attached.html)
// (See http://www.sqlite.org/c3ref/c_limit_attached.html)
type
Limit
int32
type
Limit
int32
// Run-time limit categories
const
(
const
(
LimitLength
Limit
=
C
.
SQLITE_LIMIT_LENGTH
// The maximum size of any string or BLOB or table row, in bytes.
LimitLength
Limit
=
C
.
SQLITE_LIMIT_LENGTH
// The maximum size of any string or BLOB or table row, in bytes.
LimitColumn
Limit
=
C
.
SQLITE_LIMIT_COLUMN
LimitColumn
Limit
=
C
.
SQLITE_LIMIT_COLUMN
...
...
meta.go
View file @
ebcb34c3
...
@@ -228,6 +228,7 @@ func (s *Stmt) ColumnDeclaredType(index int) string {
...
@@ -228,6 +228,7 @@ func (s *Stmt) ColumnDeclaredType(index int) string {
// Affinity enumerates SQLite column type affinity
// Affinity enumerates SQLite column type affinity
type
Affinity
string
type
Affinity
string
// SQLite column type affinities
const
(
const
(
Integral
=
Affinity
(
"INTEGER"
)
// Integer affinity
Integral
=
Affinity
(
"INTEGER"
)
// Integer affinity
Real
=
Affinity
(
"REAL"
)
Real
=
Affinity
(
"REAL"
)
...
...
pool.go
View file @
ebcb34c3
...
@@ -11,7 +11,7 @@ import (
...
@@ -11,7 +11,7 @@ import (
"time"
"time"
)
)
//
A
dapted from https://code.google.com/p/vitess/source/browse/go/pools/roundrobin.go
//
Pool a
dapted from https://code.google.com/p/vitess/source/browse/go/pools/roundrobin.go
type
Pool
struct
{
type
Pool
struct
{
mu
sync
.
Mutex
mu
sync
.
Mutex
available
*
sync
.
Cond
available
*
sync
.
Cond
...
@@ -144,7 +144,7 @@ func (p *Pool) IsClosed() bool {
...
@@ -144,7 +144,7 @@ func (p *Pool) IsClosed() bool {
return
p
.
factory
==
nil
return
p
.
factory
==
nil
}
}
// Set
c
apacity changes the capacity of the pool.
// Set
C
apacity changes the capacity of the pool.
// You can use it to expand or shrink.
// You can use it to expand or shrink.
func
(
p
*
Pool
)
SetCapacity
(
capacity
int
)
{
func
(
p
*
Pool
)
SetCapacity
(
capacity
int
)
{
p
.
mu
.
Lock
()
p
.
mu
.
Lock
()
...
...
pragma.go
View file @
ebcb34c3
...
@@ -138,9 +138,9 @@ func (c *Conn) SetSynchronous(dbName string, mode int) error {
...
@@ -138,9 +138,9 @@ func (c *Conn) SetSynchronous(dbName string, mode int) error {
// FkViolation is the description of one foreign key constraint violation.
// FkViolation is the description of one foreign key constraint violation.
type
FkViolation
struct
{
type
FkViolation
struct
{
Table
string
Table
string
RowI
d
int64
RowI
D
int64
Parent
string
Parent
string
FkI
d
int
FkI
D
int
}
}
// ForeignKeyCheck checks the database, or the table, for foreign key constraints that are violated
// ForeignKeyCheck checks the database, or the table, for foreign key constraints that are violated
...
@@ -172,7 +172,7 @@ func (c *Conn) ForeignKeyCheck(dbName, table string) ([]FkViolation, error) {
...
@@ -172,7 +172,7 @@ func (c *Conn) ForeignKeyCheck(dbName, table string) ([]FkViolation, error) {
var
violations
=
make
([]
FkViolation
,
0
,
20
)
var
violations
=
make
([]
FkViolation
,
0
,
20
)
err
=
s
.
execQuery
(
func
(
s
*
Stmt
)
(
err
error
)
{
err
=
s
.
execQuery
(
func
(
s
*
Stmt
)
(
err
error
)
{
v
:=
FkViolation
{}
v
:=
FkViolation
{}
if
err
=
s
.
Scan
(
&
v
.
Table
,
&
v
.
RowI
d
,
&
v
.
Parent
,
&
v
.
FkId
);
err
!=
nil
{
if
err
=
s
.
Scan
(
&
v
.
Table
,
&
v
.
RowI
D
,
&
v
.
Parent
,
&
v
.
FkID
);
err
!=
nil
{
return
return
}
}
violations
=
append
(
violations
,
v
)
violations
=
append
(
violations
,
v
)
...
@@ -203,10 +203,10 @@ func (c *Conn) SetQueryOnly(dbName string, mode bool) error {
...
@@ -203,10 +203,10 @@ func (c *Conn) SetQueryOnly(dbName string, mode bool) error {
return
c
.
FastExec
(
pragma
(
dbName
,
fmt
.
Sprintf
(
"query_only=%t"
,
mode
)))
return
c
.
FastExec
(
pragma
(
dbName
,
fmt
.
Sprintf
(
"query_only=%t"
,
mode
)))
}
}
// ApplicationI
d
queries the "Application ID" integer located into the database header.
// ApplicationI
D
queries the "Application ID" integer located into the database header.
// Database name is optional (default is 'main').
// Database name is optional (default is 'main').
// (See http://sqlite.org/pragma.html#pragma_application_id)
// (See http://sqlite.org/pragma.html#pragma_application_id)
func
(
c
*
Conn
)
ApplicationI
d
(
dbName
string
)
(
int
,
error
)
{
func
(
c
*
Conn
)
ApplicationI
D
(
dbName
string
)
(
int
,
error
)
{
var
id
int
var
id
int
err
:=
c
.
oneValue
(
pragma
(
dbName
,
"application_id"
),
&
id
)
err
:=
c
.
oneValue
(
pragma
(
dbName
,
"application_id"
),
&
id
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -215,10 +215,10 @@ func (c *Conn) ApplicationId(dbName string) (int, error) {
...
@@ -215,10 +215,10 @@ func (c *Conn) ApplicationId(dbName string) (int, error) {
return
id
,
nil
return
id
,
nil
}
}
// SetApplicationI
d
changes the "Application ID".
// SetApplicationI
D
changes the "Application ID".
// Database name is optional (default is 'main').
// Database name is optional (default is 'main').
// (See http://sqlite.org/pragma.html#pragma_application_id)
// (See http://sqlite.org/pragma.html#pragma_application_id)
func
(
c
*
Conn
)
SetApplicationI
d
(
dbName
string
,
id
int
)
error
{
func
(
c
*
Conn
)
SetApplicationI
D
(
dbName
string
,
id
int
)
error
{
return
c
.
FastExec
(
pragma
(
dbName
,
fmt
.
Sprintf
(
"application_id=%d"
,
id
)))
return
c
.
FastExec
(
pragma
(
dbName
,
fmt
.
Sprintf
(
"application_id=%d"
,
id
)))
}
}
...
...
pragma_test.go
View file @
ebcb34c3
...
@@ -128,7 +128,7 @@ func TestQueryOnly(t *testing.T) {
...
@@ -128,7 +128,7 @@ func TestQueryOnly(t *testing.T) {
assert
.
T
(
t
,
err
!=
nil
)
assert
.
T
(
t
,
err
!=
nil
)
}
}
func
TestApplicationI
d
(
t
*
testing
.
T
)
{
func
TestApplicationI
D
(
t
*
testing
.
T
)
{
if
VersionNumber
()
<
3007017
{
if
VersionNumber
()
<
3007017
{
return
return
}
}
...
@@ -136,18 +136,18 @@ func TestApplicationId(t *testing.T) {
...
@@ -136,18 +136,18 @@ func TestApplicationId(t *testing.T) {
db
:=
open
(
t
)
db
:=
open
(
t
)
defer
checkClose
(
db
,
t
)
defer
checkClose
(
db
,
t
)
appI
d
,
err
:=
db
.
ApplicationId
(
""
)
appI
D
,
err
:=
db
.
ApplicationID
(
""
)
checkNoError
(
t
,
err
,
"error getting application Id: %s"
)
checkNoError
(
t
,
err
,
"error getting application Id: %s"
)
assert
.
Equalf
(
t
,
0
,
appI
d
,
"got: %d; want: %d"
,
appId
,
0
)
assert
.
Equalf
(
t
,
0
,
appI
D
,
"got: %d; want: %d"
,
appID
,
0
)
err
=
db
.
SetApplicationI
d
(
""
,
123
)
err
=
db
.
SetApplicationI
D
(
""
,
123
)
checkNoError
(
t
,
err
,
"error setting application Id: %s"
)
checkNoError
(
t
,
err
,
"error setting application Id: %s"
)
appI
d
,
err
=
db
.
ApplicationId
(
""
)
appI
D
,
err
=
db
.
ApplicationID
(
""
)
checkNoError
(
t
,
err
,
"error getting application Id: %s"
)
checkNoError
(
t
,
err
,
"error getting application Id: %s"
)
assert
.
Equalf
(
t
,
123
,
appI
d
,
"got: %d; want: %d"
,
appId
,
123
)
assert
.
Equalf
(
t
,
123
,
appI
D
,
"got: %d; want: %d"
,
appID
,
123
)
_
,
err
=
db
.
ApplicationI
d
(
"bim"
)
_
,
err
=
db
.
ApplicationI
D
(
"bim"
)
assert
.
T
(
t
,
err
!=
nil
)
assert
.
T
(
t
,
err
!=
nil
)
}
}
...
@@ -176,11 +176,11 @@ func TestForeignKeyCheck(t *testing.T) {
...
@@ -176,11 +176,11 @@ func TestForeignKeyCheck(t *testing.T) {
checkNoError
(
t
,
err
,
"error while checking FK: %s"
)
checkNoError
(
t
,
err
,
"error while checking FK: %s"
)
assert
.
Equal
(
t
,
1
,
len
(
vs
),
"one FK violation expected"
)
assert
.
Equal
(
t
,
1
,
len
(
vs
),
"one FK violation expected"
)
v
:=
vs
[
0
]
v
:=
vs
[
0
]
assert
.
Equal
(
t
,
FkViolation
{
Table
:
"tree"
,
RowI
d
:
4
,
Parent
:
"tree"
,
FkId
:
0
},
v
)
assert
.
Equal
(
t
,
FkViolation
{
Table
:
"tree"
,
RowI
D
:
4
,
Parent
:
"tree"
,
FkID
:
0
},
v
)
fks
,
err
:=
db
.
ForeignKeys
(
""
,
"tree"
)
fks
,
err
:=
db
.
ForeignKeys
(
""
,
"tree"
)
checkNoError
(
t
,
err
,
"error while loading FK: %s"
)
checkNoError
(
t
,
err
,
"error while loading FK: %s"
)
fk
,
ok
:=
fks
[
v
.
FkI
d
]
fk
,
ok
:=
fks
[
v
.
FkI
D
]
assert
.
Tf
(
t
,
ok
,
"no FK with id: %d"
,
v
.
FkI
d
)
assert
.
Tf
(
t
,
ok
,
"no FK with id: %d"
,
v
.
FkI
D
)
assert
.
Equal
(
t
,
&
ForeignKey
{
Table
:
"tree"
,
From
:
[]
string
{
"parentId"
},
To
:
[]
string
{
"id"
}},
fk
)
assert
.
Equal
(
t
,
&
ForeignKey
{
Table
:
"tree"
,
From
:
[]
string
{
"parentId"
},
To
:
[]
string
{
"id"
}},
fk
)
mvs
,
err
:=
db
.
ForeignKeyCheck
(
"main"
,
"tree"
)
mvs
,
err
:=
db
.
ForeignKeyCheck
(
"main"
,
"tree"
)
...
...
sqlite.go
View file @
ebcb34c3
...
@@ -73,6 +73,7 @@ func (e Errno) Error() string {
...
@@ -73,6 +73,7 @@ func (e Errno) Error() string {
return
s
return
s
}
}
// SQLite result codes
const
(
const
(
ErrError
=
Errno
(
C
.
SQLITE_ERROR
)
/* SQL error or missing database */
ErrError
=
Errno
(
C
.
SQLITE_ERROR
)
/* SQL error or missing database */
ErrInternal
=
Errno
(
C
.
SQLITE_INTERNAL
)
/* Internal logic error in SQLite */
ErrInternal
=
Errno
(
C
.
SQLITE_INTERNAL
)
/* Internal logic error in SQLite */
...
@@ -180,6 +181,7 @@ func VersionNumber() int32 {
...
@@ -180,6 +181,7 @@ func VersionNumber() int32 {
// OpenFlag enumerates flags for file open operations
// OpenFlag enumerates flags for file open operations
type
OpenFlag
int32
type
OpenFlag
int32
// Flags for file open operations
const
(
const
(
OpenReadOnly
OpenFlag
=
C
.
SQLITE_OPEN_READONLY
OpenReadOnly
OpenFlag
=
C
.
SQLITE_OPEN_READONLY
OpenReadWrite
OpenFlag
=
C
.
SQLITE_OPEN_READWRITE
OpenReadWrite
OpenFlag
=
C
.
SQLITE_OPEN_READWRITE
...
@@ -386,6 +388,7 @@ func (c *Conn) GetAutocommit() bool {
...
@@ -386,6 +388,7 @@ func (c *Conn) GetAutocommit() bool {
// See Conn.BeginTransaction
// See Conn.BeginTransaction
type
TransactionType
uint8
type
TransactionType
uint8
// Transaction types
const
(
const
(
Deferred
TransactionType
=
0
Deferred
TransactionType
=
0
Immediate
TransactionType
=
1
Immediate
TransactionType
=
1
...
...
stmt.go
View file @
ebcb34c3
...
@@ -514,6 +514,7 @@ func (t Type) String() string {
...
@@ -514,6 +514,7 @@ func (t Type) String() string {
return
typeText
[
t
]
return
typeText
[
t
]
}
}
// SQLite fundamental datatypes
const
(
const
(
Integer
=
Type
(
C
.
SQLITE_INTEGER
)
Integer
=
Type
(
C
.
SQLITE_INTEGER
)
Float
=
Type
(
C
.
SQLITE_FLOAT
)
Float
=
Type
(
C
.
SQLITE_FLOAT
)
...
...
stmt_test.go
View file @
ebcb34c3
...
@@ -481,9 +481,9 @@ func TestInsertMisuse(t *testing.T) {
...
@@ -481,9 +481,9 @@ func TestInsertMisuse(t *testing.T) {
ois
,
err
:=
db
.
Prepare
(
"PRAGMA shrink_memory"
)
ois
,
err
:=
db
.
Prepare
(
"PRAGMA shrink_memory"
)
checkNoError
(
t
,
err
,
"prepare error: %s"
)
checkNoError
(
t
,
err
,
"prepare error: %s"
)
defer
checkFinalize
(
ois
,
t
)
defer
checkFinalize
(
ois
,
t
)
rowI
d
,
err
:=
ois
.
Insert
()
rowI
D
,
err
:=
ois
.
Insert
()
checkNoError
(
t
,
err
,
"insert error: %s"
)
checkNoError
(
t
,
err
,
"insert error: %s"
)
assert
.
Equal
(
t
,
int64
(
-
1
),
rowI
d
)
assert
.
Equal
(
t
,
int64
(
-
1
),
rowI
D
)
}
}
func
TestScanValues
(
t
*
testing
.
T
)
{
func
TestScanValues
(
t
*
testing
.
T
)
{
...
...
trace.go
View file @
ebcb34c3
...
@@ -91,6 +91,7 @@ func (c *Conn) Profile(f Profiler, udp interface{}) {
...
@@ -91,6 +91,7 @@ func (c *Conn) Profile(f Profiler, udp interface{}) {
// Auth enumerates Authorizer return codes
// Auth enumerates Authorizer return codes
type
Auth
int32
type
Auth
int32
// Authorizer return codes
const
(
const
(
AuthOk
Auth
=
C
.
SQLITE_OK
AuthOk
Auth
=
C
.
SQLITE_OK
AuthDeny
Auth
=
C
.
SQLITE_DENY
AuthDeny
Auth
=
C
.
SQLITE_DENY
...
@@ -100,6 +101,7 @@ const (
...
@@ -100,6 +101,7 @@ const (
// Action enumerates Authorizer action codes
// Action enumerates Authorizer action codes
type
Action
int32
type
Action
int32
// Authorizer action codes
const
(
const
(
CreateIndex
Action
=
C
.
SQLITE_CREATE_INDEX
CreateIndex
Action
=
C
.
SQLITE_CREATE_INDEX
CreateTable
Action
=
C
.
SQLITE_CREATE_TABLE
CreateTable
Action
=
C
.
SQLITE_CREATE_TABLE
...
@@ -299,6 +301,7 @@ func (c *Conn) ProgressHandler(f ProgressHandler, numOps int32, udp interface{})
...
@@ -299,6 +301,7 @@ func (c *Conn) ProgressHandler(f ProgressHandler, numOps int32, udp interface{})
// StmtStatus enumerates status parameters for prepared statements
// StmtStatus enumerates status parameters for prepared statements
type
StmtStatus
int32
type
StmtStatus
int32
// status counters for prepared statements
const
(
const
(
StmtStatusFullScanStep
StmtStatus
=
C
.
SQLITE_STMTSTATUS_FULLSCAN_STEP
StmtStatusFullScanStep
StmtStatus
=
C
.
SQLITE_STMTSTATUS_FULLSCAN_STEP
StmtStatusSort
StmtStatus
=
C
.
SQLITE_STMTSTATUS_SORT
StmtStatusSort
StmtStatus
=
C
.
SQLITE_STMTSTATUS_SORT
...
...
vtab.go
View file @
ebcb34c3
...
@@ -151,7 +151,7 @@ func goVNext(pCursor unsafe.Pointer) *C.char {
...
@@ -151,7 +151,7 @@ func goVNext(pCursor unsafe.Pointer) *C.char {
//export goVEof
//export goVEof
func
goVEof
(
pCursor
unsafe
.
Pointer
)
C
.
int
{
func
goVEof
(
pCursor
unsafe
.
Pointer
)
C
.
int
{
vtc
:=
(
*
sqliteVTabCursor
)(
pCursor
)
vtc
:=
(
*
sqliteVTabCursor
)(
pCursor
)
return
btocint
(
vtc
.
vTabCursor
.
E
of
())
return
btocint
(
vtc
.
vTabCursor
.
E
OF
())
}
}
//export goVColumn
//export goVColumn
...
@@ -218,7 +218,7 @@ type VTabCursor interface {
...
@@ -218,7 +218,7 @@ type VTabCursor interface {
Close
()
error
// See http://sqlite.org/vtab.html#xclose
Close
()
error
// See http://sqlite.org/vtab.html#xclose
Filter
(
/*idxNum int, idxStr string, int argc, sqlite3_value **argv*/
)
error
// See http://sqlite.org/vtab.html#xfilter
Filter
(
/*idxNum int, idxStr string, int argc, sqlite3_value **argv*/
)
error
// See http://sqlite.org/vtab.html#xfilter
Next
()
error
// See http://sqlite.org/vtab.html#xnext
Next
()
error
// See http://sqlite.org/vtab.html#xnext
E
of
()
bool
// See http://sqlite.org/vtab.html#xeof
E
OF
()
bool
// See http://sqlite.org/vtab.html#xeof
// col is zero-based so the first column is numbered 0
// col is zero-based so the first column is numbered 0
Column
(
c
*
Context
,
col
int
)
error
// See http://sqlite.org/vtab.html#xcolumn
Column
(
c
*
Context
,
col
int
)
error
// See http://sqlite.org/vtab.html#xcolumn
Rowid
()
(
int64
,
error
)
// See http://sqlite.org/vtab.html#xrowid
Rowid
()
(
int64
,
error
)
// See http://sqlite.org/vtab.html#xrowid
...
...
vtab_test.go
View file @
ebcb34c3
...
@@ -81,8 +81,8 @@ func (vc *testVTabCursor) Next() error {
...
@@ -81,8 +81,8 @@ func (vc *testVTabCursor) Next() error {
vc
.
index
++
vc
.
index
++
return
nil
return
nil
}
}
func
(
vc
*
testVTabCursor
)
E
of
()
bool
{
func
(
vc
*
testVTabCursor
)
E
OF
()
bool
{
//fmt.Printf("testVTabCursor.E
of
: %v\n", vc)
//fmt.Printf("testVTabCursor.E
OF
: %v\n", vc)
return
vc
.
index
>=
len
(
vc
.
vTab
.
intarray
)
return
vc
.
index
>=
len
(
vc
.
vTab
.
intarray
)
}
}
func
(
vc
*
testVTabCursor
)
Column
(
c
*
Context
,
col
int
)
error
{
func
(
vc
*
testVTabCursor
)
Column
(
c
*
Context
,
col
int
)
error
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment