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
09aabd90
Commit
09aabd90
authored
Aug 21, 2012
by
gwenn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Converted constants to CamelCase.
parent
a1cb9353
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
76 additions
and
76 deletions
+76
-76
busy_test.go
busy_test.go
+5
-5
date.go
date.go
+7
-7
date_test.go
date_test.go
+1
-1
sqlite.go
sqlite.go
+15
-15
sqlite_test.go
sqlite_test.go
+4
-4
trace.go
trace.go
+42
-42
trace_test.go
trace_test.go
+2
-2
No files found.
busy_test.go
View file @
09aabd90
...
...
@@ -36,9 +36,9 @@ func TestInterrupt(t *testing.T) {
func
openTwoConnSameDb
(
t
*
testing
.
T
)
(
*
os
.
File
,
*
Conn
,
*
Conn
)
{
f
,
err
:=
ioutil
.
TempFile
(
""
,
"gosqlite-test"
)
checkNoError
(
t
,
f
.
Close
(),
"couldn't close temp file: %s"
)
db1
,
err
:=
Open
(
f
.
Name
(),
O
PEN_READWRITE
,
OPEN_CREATE
,
OPEN_FULLMUTEX
)
db1
,
err
:=
Open
(
f
.
Name
(),
O
penReadWrite
,
OpenCreate
,
OpenFullMutex
)
checkNoError
(
t
,
err
,
"couldn't open database file: %s"
)
db2
,
err
:=
Open
(
f
.
Name
(),
O
PEN_READWRITE
,
OPEN_CREATE
,
OPEN_FULLMUTEX
)
db2
,
err
:=
Open
(
f
.
Name
(),
O
penReadWrite
,
OpenCreate
,
OpenFullMutex
)
checkNoError
(
t
,
err
,
"couldn't open database file: %s"
)
return
f
,
db1
,
db2
}
...
...
@@ -48,7 +48,7 @@ func TestDefaultBusy(t *testing.T) {
defer
os
.
Remove
(
f
.
Name
())
defer
db1
.
Close
()
defer
db2
.
Close
()
checkNoError
(
t
,
db1
.
BeginTransaction
(
E
XCLUSIVE
),
"couldn't begin transaction: %s"
)
checkNoError
(
t
,
db1
.
BeginTransaction
(
E
xclusive
),
"couldn't begin transaction: %s"
)
defer
db1
.
Rollback
()
_
,
err
:=
db2
.
SchemaVersion
(
""
)
...
...
@@ -65,7 +65,7 @@ func TestBusyTimeout(t *testing.T) {
defer
os
.
Remove
(
f
.
Name
())
defer
db1
.
Close
()
defer
db2
.
Close
()
checkNoError
(
t
,
db1
.
BeginTransaction
(
E
XCLUSIVE
),
"couldn't begin transaction: %s"
)
checkNoError
(
t
,
db1
.
BeginTransaction
(
E
xclusive
),
"couldn't begin transaction: %s"
)
//join := make(chan bool)
checkNoError
(
t
,
db2
.
BusyTimeout
(
500
),
"couldn't set busy timeout: %s"
)
...
...
@@ -96,7 +96,7 @@ func TestBusyHandler(t *testing.T) {
return
true
},
&
called
)
checkNoError
(
t
,
db1
.
BeginTransaction
(
E
XCLUSIVE
),
"couldn't begin transaction: %s"
)
checkNoError
(
t
,
db1
.
BeginTransaction
(
E
xclusive
),
"couldn't begin transaction: %s"
)
go
func
()
{
time
.
Sleep
(
time
.
Millisecond
)
...
...
date.go
View file @
09aabd90
...
...
@@ -9,21 +9,21 @@ import (
)
const
(
JULIAN_DAY
=
2440587.5
// 1970-01-01 00:00:00 is JD 2440587.5
DAY_IN_SECONDS
=
60
*
60
*
24
julianDay
=
2440587.5
// 1970-01-01 00:00:00 is JD 2440587.5
dayInSeconds
=
60
*
60
*
24
)
// JulianDayToUTC transforms a julian day number into an UTC Time.
func
JulianDayToUTC
(
jd
float64
)
time
.
Time
{
jd
-=
JULIAN_DAY
jd
*=
DAY_IN_SECONDS
jd
-=
julianDay
jd
*=
dayInSeconds
return
time
.
Unix
(
int64
(
jd
),
0
)
.
UTC
()
}
// JulianDayToLocalTime transforms a julian day number into a local Time.
func
JulianDayToLocalTime
(
jd
float64
)
time
.
Time
{
jd
-=
JULIAN_DAY
jd
*=
DAY_IN_SECONDS
jd
-=
julianDay
jd
*=
dayInSeconds
return
time
.
Unix
(
int64
(
jd
),
0
)
}
...
...
@@ -33,5 +33,5 @@ func JulianDay(t time.Time) float64 {
if
ns
>=
0
{
ns
+=
0.5
}
return
ns
/
DAY_IN_SECONDS
+
JULIAN_DAY
return
ns
/
dayInSeconds
+
julianDay
}
date_test.go
View file @
09aabd90
...
...
@@ -11,7 +11,7 @@ import (
)
func
TestJulianDay
(
t
*
testing
.
T
)
{
utc
:=
JulianDayToUTC
(
JULIAN_DAY
)
utc
:=
JulianDayToUTC
(
2440587.5
)
if
utc
.
Unix
()
!=
0
{
t
.
Errorf
(
"Error, expecting %d got %d"
,
0
,
utc
.
Unix
())
}
...
...
sqlite.go
View file @
09aabd90
...
...
@@ -181,14 +181,14 @@ func Version() string {
type
OpenFlag
int
const
(
O
PEN_READONLY
OpenFlag
=
C
.
SQLITE_OPEN_READONLY
O
PEN_READWRITE
OpenFlag
=
C
.
SQLITE_OPEN_READWRITE
O
PEN_CREATE
OpenFlag
=
C
.
SQLITE_OPEN_CREATE
O
PEN_URI
OpenFlag
=
C
.
SQLITE_OPEN_URI
O
PEN_NOMUTEX
OpenFlag
=
C
.
SQLITE_OPEN_NOMUTEX
O
PEN_FULLMUTEX
OpenFlag
=
C
.
SQLITE_OPEN_FULLMUTEX
O
PEN_SHAREDCACHE
OpenFlag
=
C
.
SQLITE_OPEN_SHAREDCACHE
O
PEN_PRIVATECACHE
OpenFlag
=
C
.
SQLITE_OPEN_PRIVATECACHE
O
penReadOnly
OpenFlag
=
C
.
SQLITE_OPEN_READONLY
O
penReadWrite
OpenFlag
=
C
.
SQLITE_OPEN_READWRITE
O
penCreate
OpenFlag
=
C
.
SQLITE_OPEN_CREATE
O
penUri
OpenFlag
=
C
.
SQLITE_OPEN_URI
O
penNoMutex
OpenFlag
=
C
.
SQLITE_OPEN_NOMUTEX
O
penFullMutex
OpenFlag
=
C
.
SQLITE_OPEN_FULLMUTEX
O
penSharedCache
OpenFlag
=
C
.
SQLITE_OPEN_SHAREDCACHE
O
penPrivateCache
OpenFlag
=
C
.
SQLITE_OPEN_PRIVATECACHE
)
// Open a new database connection.
...
...
@@ -406,22 +406,22 @@ func (c *Conn) GetAutocommit() bool {
type
TransactionType
int
const
(
D
EFERRED
TransactionType
=
0
I
MMEDIATE
TransactionType
=
1
E
XCLUSIVE
TransactionType
=
2
D
eferred
TransactionType
=
0
I
mmediate
TransactionType
=
1
E
xclusive
TransactionType
=
2
)
// Begin transaction in deferred mode
func
(
c
*
Conn
)
Begin
()
error
{
return
c
.
BeginTransaction
(
D
EFERRED
)
return
c
.
BeginTransaction
(
D
eferred
)
}
func
(
c
*
Conn
)
BeginTransaction
(
t
TransactionType
)
error
{
if
t
==
D
EFERRED
{
if
t
==
D
eferred
{
return
c
.
exec
(
"BEGIN"
)
}
else
if
t
==
I
MMEDIATE
{
}
else
if
t
==
I
mmediate
{
return
c
.
exec
(
"BEGIN IMMEDIATE"
)
}
else
if
t
==
E
XCLUSIVE
{
}
else
if
t
==
E
xclusive
{
return
c
.
exec
(
"BEGIN EXCLUSIVE"
)
}
panic
(
fmt
.
Sprintf
(
"Unsupported transaction type: '%#v'"
,
t
))
...
...
sqlite_test.go
View file @
09aabd90
...
...
@@ -18,7 +18,7 @@ func checkNoError(t *testing.T, err error, format string) {
}
func
open
(
t
*
testing
.
T
)
*
Conn
{
db
,
err
:=
Open
(
":memory:"
,
O
PEN_READWRITE
,
OPEN_CREATE
,
OPEN_FULLMUTEX
)
db
,
err
:=
Open
(
":memory:"
,
O
penReadWrite
,
OpenCreate
,
OpenFullMutex
)
checkNoError
(
t
,
err
,
"couldn't open database file: %s"
)
if
db
==
nil
{
t
.
Fatal
(
"opened database is nil"
)
...
...
@@ -211,9 +211,9 @@ func TestInsertWithStatement(t *testing.T) {
assertEquals
(
t
,
"expected %d but got %d"
,
int64
(
1
),
inum
)
assertEquals
(
t
,
"expected %q but got %q"
,
"hello"
,
sstr
)
}
assert
(
t
,
"expected full scan"
,
999
==
rs
.
Status
(
S
TMTSTATUS_FULLSCAN_STEP
,
false
))
assert
(
t
,
"expected one sort"
,
1
==
rs
.
Status
(
S
TMTSTATUS_SORT
,
false
))
assert
(
t
,
"expected no auto index"
,
0
==
rs
.
Status
(
S
TMTSTATUS_AUTOINDEX
,
false
))
assert
(
t
,
"expected full scan"
,
999
==
rs
.
Status
(
S
tmtStatusFullScanStep
,
false
))
assert
(
t
,
"expected one sort"
,
1
==
rs
.
Status
(
S
tmtStatusSort
,
false
))
assert
(
t
,
"expected no auto index"
,
0
==
rs
.
Status
(
S
tmtStatusAutoIndex
,
false
))
}
func
TestScanColumn
(
t
*
testing
.
T
)
{
...
...
trace.go
View file @
09aabd90
...
...
@@ -85,48 +85,48 @@ func (c *Conn) Profile(f Profiler, udp interface{}) {
type
Auth
int
const
(
A
UTH_OK
Auth
=
C
.
SQLITE_OK
A
UTH_DENY
Auth
=
C
.
SQLITE_DENY
A
UTH_IGNORE
Auth
=
C
.
SQLITE_IGNORE
A
uthOk
Auth
=
C
.
SQLITE_OK
A
uthDeny
Auth
=
C
.
SQLITE_DENY
A
uthIgnore
Auth
=
C
.
SQLITE_IGNORE
)
// Authorizer action codes
type
Action
int
const
(
C
REATE_INDEX
Action
=
C
.
SQLITE_CREATE_INDEX
C
REATE_TABLE
Action
=
C
.
SQLITE_CREATE_TABLE
C
REATE_TEMP_INDEX
Action
=
C
.
SQLITE_CREATE_TEMP_INDEX
C
REATE_TEMP_TABLE
Action
=
C
.
SQLITE_CREATE_TEMP_TABLE
C
REATE_TEMP_TRIGGER
Action
=
C
.
SQLITE_CREATE_TEMP_TRIGGER
C
REATE_TEMP_VIEW
Action
=
C
.
SQLITE_CREATE_TEMP_VIEW
C
REATE_TRIGGER
Action
=
C
.
SQLITE_CREATE_TRIGGER
C
REATE_VIEW
Action
=
C
.
SQLITE_CREATE_VIEW
D
ELETE
Action
=
C
.
SQLITE_DELETE
D
ROP_INDEX
Action
=
C
.
SQLITE_DROP_INDEX
D
ROP_TABLE
Action
=
C
.
SQLITE_DROP_TABLE
D
ROP_TEMP_INDEX
Action
=
C
.
SQLITE_DROP_TEMP_INDEX
D
ROP_TEMP_TABLE
Action
=
C
.
SQLITE_DROP_TEMP_TABLE
D
ROP_TEMP_TRIGGER
Action
=
C
.
SQLITE_DROP_TEMP_TRIGGER
D
ROP_TEMP_VIEW
Action
=
C
.
SQLITE_DROP_TEMP_VIEW
D
ROP_TRIGGER
Action
=
C
.
SQLITE_DROP_TRIGGER
D
ROP_VIEW
Action
=
C
.
SQLITE_DROP_VIEW
I
NSERT
Action
=
C
.
SQLITE_INSERT
P
RAGMA
Action
=
C
.
SQLITE_PRAGMA
R
EAD
Action
=
C
.
SQLITE_READ
S
ELECT
Action
=
C
.
SQLITE_SELECT
T
RANSACTION
Action
=
C
.
SQLITE_TRANSACTION
U
PDATE
Action
=
C
.
SQLITE_UPDATE
A
TTACH
Action
=
C
.
SQLITE_ATTACH
D
ETACH
Action
=
C
.
SQLITE_DETACH
A
LTER_TABLE
Action
=
C
.
SQLITE_ALTER_TABLE
R
EINDEX
Action
=
C
.
SQLITE_REINDEX
A
NALYZE
Action
=
C
.
SQLITE_ANALYZE
C
REATE_VTABLE
Action
=
C
.
SQLITE_CREATE_VTABLE
D
ROP_VTABLE
Action
=
C
.
SQLITE_DROP_VTABLE
F
UNCTION
Action
=
C
.
SQLITE_FUNCTION
S
AVEPOINT
Action
=
C
.
SQLITE_SAVEPOINT
C
OPY
Action
=
C
.
SQLITE_COPY
C
reateIndex
Action
=
C
.
SQLITE_CREATE_INDEX
C
reateTable
Action
=
C
.
SQLITE_CREATE_TABLE
C
reateTempIndex
Action
=
C
.
SQLITE_CREATE_TEMP_INDEX
C
reateTempTable
Action
=
C
.
SQLITE_CREATE_TEMP_TABLE
C
reateTempTrigger
Action
=
C
.
SQLITE_CREATE_TEMP_TRIGGER
C
reateTempView
Action
=
C
.
SQLITE_CREATE_TEMP_VIEW
C
reateTrigger
Action
=
C
.
SQLITE_CREATE_TRIGGER
C
reateView
Action
=
C
.
SQLITE_CREATE_VIEW
D
elete
Action
=
C
.
SQLITE_DELETE
D
ropIndex
Action
=
C
.
SQLITE_DROP_INDEX
D
ropTable
Action
=
C
.
SQLITE_DROP_TABLE
D
ropTempIndex
Action
=
C
.
SQLITE_DROP_TEMP_INDEX
D
ropTempTable
Action
=
C
.
SQLITE_DROP_TEMP_TABLE
D
ropTempTrigger
Action
=
C
.
SQLITE_DROP_TEMP_TRIGGER
D
ropTempView
Action
=
C
.
SQLITE_DROP_TEMP_VIEW
D
ropTrigger
Action
=
C
.
SQLITE_DROP_TRIGGER
D
ropView
Action
=
C
.
SQLITE_DROP_VIEW
I
nsert
Action
=
C
.
SQLITE_INSERT
P
ragma
Action
=
C
.
SQLITE_PRAGMA
R
ead
Action
=
C
.
SQLITE_READ
S
elect
Action
=
C
.
SQLITE_SELECT
T
ransaction
Action
=
C
.
SQLITE_TRANSACTION
U
pdate
Action
=
C
.
SQLITE_UPDATE
A
ttach
Action
=
C
.
SQLITE_ATTACH
D
etach
Action
=
C
.
SQLITE_DETACH
A
lterTable
Action
=
C
.
SQLITE_ALTER_TABLE
R
eindex
Action
=
C
.
SQLITE_REINDEX
A
nalyze
Action
=
C
.
SQLITE_ANALYZE
C
reateVTable
Action
=
C
.
SQLITE_CREATE_VTABLE
D
ropVTable
Action
=
C
.
SQLITE_DROP_VTABLE
F
unction
Action
=
C
.
SQLITE_FUNCTION
S
avepoint
Action
=
C
.
SQLITE_SAVEPOINT
C
opy
Action
=
C
.
SQLITE_COPY
)
// See Conn.SetAuthorizer
...
...
@@ -218,9 +218,9 @@ func (c *Conn) ProgressHandler(f ProgressHandler, numOps int, udp interface{}) {
type
StmtStatus
int
const
(
S
TMTSTATUS_FULLSCAN_STEP
StmtStatus
=
C
.
SQLITE_STMTSTATUS_FULLSCAN_STEP
S
TMTSTATUS_SORT
StmtStatus
=
C
.
SQLITE_STMTSTATUS_SORT
S
TMTSTATUS_AUTOINDEX
StmtStatus
=
C
.
SQLITE_STMTSTATUS_AUTOINDEX
S
tmtStatusFullScanStep
StmtStatus
=
C
.
SQLITE_STMTSTATUS_FULLSCAN_STEP
S
tmtStatusSort
StmtStatus
=
C
.
SQLITE_STMTSTATUS_SORT
S
tmtStatusAutoIndex
StmtStatus
=
C
.
SQLITE_STMTSTATUS_AUTOINDEX
)
// Return the value of a status counter for a prepared statement
...
...
@@ -307,9 +307,9 @@ func ConfigLog(f Logger, udp interface{}) error {
type
ThreadingMode
int
const
(
S
INGLETHREAD
ThreadingMode
=
C
.
SQLITE_CONFIG_SINGLETHREAD
M
ULTITHREAD
ThreadingMode
=
C
.
SQLITE_CONFIG_MULTITHREAD
S
ERIALIZED
ThreadingMode
=
C
.
SQLITE_CONFIG_SERIALIZED
S
ingleThread
ThreadingMode
=
C
.
SQLITE_CONFIG_SINGLETHREAD
M
ultiThread
ThreadingMode
=
C
.
SQLITE_CONFIG_MULTITHREAD
S
erialized
ThreadingMode
=
C
.
SQLITE_CONFIG_SERIALIZED
)
// Alters threading mode
...
...
trace_test.go
View file @
09aabd90
...
...
@@ -11,7 +11,7 @@ import (
)
func
init
()
{
err
:=
ConfigThreadingMode
(
S
ERIALIZED
)
err
:=
ConfigThreadingMode
(
S
erialized
)
if
err
!=
nil
{
panic
(
fmt
.
Sprintf
(
"cannot change threading mode: '%s'"
,
err
))
}
...
...
@@ -35,7 +35,7 @@ func authorizer(d interface{}, action Action, arg1, arg2, dbName, triggerName st
}
else
{
fmt
.
Printf
(
"%s: %d, %s, %s, %s, %s
\n
"
,
d
,
action
,
arg1
,
arg2
,
dbName
,
triggerName
)
}
return
A
UTH_OK
return
A
uthOk
}
func
profile
(
d
interface
{},
sql
string
,
nanoseconds
uint64
)
{
...
...
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