Commit 09aabd90 authored by gwenn's avatar gwenn

Converted constants to CamelCase.

parent a1cb9353
......@@ -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(), OPEN_READWRITE, OPEN_CREATE, OPEN_FULLMUTEX)
db1, err := Open(f.Name(), OpenReadWrite, OpenCreate, OpenFullMutex)
checkNoError(t, err, "couldn't open database file: %s")
db2, err := Open(f.Name(), OPEN_READWRITE, OPEN_CREATE, OPEN_FULLMUTEX)
db2, err := Open(f.Name(), OpenReadWrite, 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(EXCLUSIVE), "couldn't begin transaction: %s")
checkNoError(t, db1.BeginTransaction(Exclusive), "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(EXCLUSIVE), "couldn't begin transaction: %s")
checkNoError(t, db1.BeginTransaction(Exclusive), "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(EXCLUSIVE), "couldn't begin transaction: %s")
checkNoError(t, db1.BeginTransaction(Exclusive), "couldn't begin transaction: %s")
go func() {
time.Sleep(time.Millisecond)
......
......@@ -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
}
......@@ -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())
}
......
......@@ -181,14 +181,14 @@ func Version() string {
type OpenFlag int
const (
OPEN_READONLY OpenFlag = C.SQLITE_OPEN_READONLY
OPEN_READWRITE OpenFlag = C.SQLITE_OPEN_READWRITE
OPEN_CREATE OpenFlag = C.SQLITE_OPEN_CREATE
OPEN_URI OpenFlag = C.SQLITE_OPEN_URI
OPEN_NOMUTEX OpenFlag = C.SQLITE_OPEN_NOMUTEX
OPEN_FULLMUTEX OpenFlag = C.SQLITE_OPEN_FULLMUTEX
OPEN_SHAREDCACHE OpenFlag = C.SQLITE_OPEN_SHAREDCACHE
OPEN_PRIVATECACHE OpenFlag = C.SQLITE_OPEN_PRIVATECACHE
OpenReadOnly OpenFlag = C.SQLITE_OPEN_READONLY
OpenReadWrite OpenFlag = C.SQLITE_OPEN_READWRITE
OpenCreate OpenFlag = C.SQLITE_OPEN_CREATE
OpenUri OpenFlag = C.SQLITE_OPEN_URI
OpenNoMutex OpenFlag = C.SQLITE_OPEN_NOMUTEX
OpenFullMutex OpenFlag = C.SQLITE_OPEN_FULLMUTEX
OpenSharedCache OpenFlag = C.SQLITE_OPEN_SHAREDCACHE
OpenPrivateCache OpenFlag = C.SQLITE_OPEN_PRIVATECACHE
)
// Open a new database connection.
......@@ -406,22 +406,22 @@ func (c *Conn) GetAutocommit() bool {
type TransactionType int
const (
DEFERRED TransactionType = 0
IMMEDIATE TransactionType = 1
EXCLUSIVE TransactionType = 2
Deferred TransactionType = 0
Immediate TransactionType = 1
Exclusive TransactionType = 2
)
// Begin transaction in deferred mode
func (c *Conn) Begin() error {
return c.BeginTransaction(DEFERRED)
return c.BeginTransaction(Deferred)
}
func (c *Conn) BeginTransaction(t TransactionType) error {
if t == DEFERRED {
if t == Deferred {
return c.exec("BEGIN")
} else if t == IMMEDIATE {
} else if t == Immediate {
return c.exec("BEGIN IMMEDIATE")
} else if t == EXCLUSIVE {
} else if t == Exclusive {
return c.exec("BEGIN EXCLUSIVE")
}
panic(fmt.Sprintf("Unsupported transaction type: '%#v'", t))
......
......@@ -18,7 +18,7 @@ func checkNoError(t *testing.T, err error, format string) {
}
func open(t *testing.T) *Conn {
db, err := Open(":memory:", OPEN_READWRITE, OPEN_CREATE, OPEN_FULLMUTEX)
db, err := Open(":memory:", OpenReadWrite, 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(STMTSTATUS_FULLSCAN_STEP, false))
assert(t, "expected one sort", 1 == rs.Status(STMTSTATUS_SORT, false))
assert(t, "expected no auto index", 0 == rs.Status(STMTSTATUS_AUTOINDEX, false))
assert(t, "expected full scan", 999 == rs.Status(StmtStatusFullScanStep, false))
assert(t, "expected one sort", 1 == rs.Status(StmtStatusSort, false))
assert(t, "expected no auto index", 0 == rs.Status(StmtStatusAutoIndex, false))
}
func TestScanColumn(t *testing.T) {
......
......@@ -85,48 +85,48 @@ func (c *Conn) Profile(f Profiler, udp interface{}) {
type Auth int
const (
AUTH_OK Auth = C.SQLITE_OK
AUTH_DENY Auth = C.SQLITE_DENY
AUTH_IGNORE Auth = C.SQLITE_IGNORE
AuthOk Auth = C.SQLITE_OK
AuthDeny Auth = C.SQLITE_DENY
AuthIgnore Auth = C.SQLITE_IGNORE
)
// Authorizer action codes
type Action int
const (
CREATE_INDEX Action = C.SQLITE_CREATE_INDEX
CREATE_TABLE Action = C.SQLITE_CREATE_TABLE
CREATE_TEMP_INDEX Action = C.SQLITE_CREATE_TEMP_INDEX
CREATE_TEMP_TABLE Action = C.SQLITE_CREATE_TEMP_TABLE
CREATE_TEMP_TRIGGER Action = C.SQLITE_CREATE_TEMP_TRIGGER
CREATE_TEMP_VIEW Action = C.SQLITE_CREATE_TEMP_VIEW
CREATE_TRIGGER Action = C.SQLITE_CREATE_TRIGGER
CREATE_VIEW Action = C.SQLITE_CREATE_VIEW
DELETE Action = C.SQLITE_DELETE
DROP_INDEX Action = C.SQLITE_DROP_INDEX
DROP_TABLE Action = C.SQLITE_DROP_TABLE
DROP_TEMP_INDEX Action = C.SQLITE_DROP_TEMP_INDEX
DROP_TEMP_TABLE Action = C.SQLITE_DROP_TEMP_TABLE
DROP_TEMP_TRIGGER Action = C.SQLITE_DROP_TEMP_TRIGGER
DROP_TEMP_VIEW Action = C.SQLITE_DROP_TEMP_VIEW
DROP_TRIGGER Action = C.SQLITE_DROP_TRIGGER
DROP_VIEW Action = C.SQLITE_DROP_VIEW
INSERT Action = C.SQLITE_INSERT
PRAGMA Action = C.SQLITE_PRAGMA
READ Action = C.SQLITE_READ
SELECT Action = C.SQLITE_SELECT
TRANSACTION Action = C.SQLITE_TRANSACTION
UPDATE Action = C.SQLITE_UPDATE
ATTACH Action = C.SQLITE_ATTACH
DETACH Action = C.SQLITE_DETACH
ALTER_TABLE Action = C.SQLITE_ALTER_TABLE
REINDEX Action = C.SQLITE_REINDEX
ANALYZE Action = C.SQLITE_ANALYZE
CREATE_VTABLE Action = C.SQLITE_CREATE_VTABLE
DROP_VTABLE Action = C.SQLITE_DROP_VTABLE
FUNCTION Action = C.SQLITE_FUNCTION
SAVEPOINT Action = C.SQLITE_SAVEPOINT
COPY Action = C.SQLITE_COPY
CreateIndex Action = C.SQLITE_CREATE_INDEX
CreateTable Action = C.SQLITE_CREATE_TABLE
CreateTempIndex Action = C.SQLITE_CREATE_TEMP_INDEX
CreateTempTable Action = C.SQLITE_CREATE_TEMP_TABLE
CreateTempTrigger Action = C.SQLITE_CREATE_TEMP_TRIGGER
CreateTempView Action = C.SQLITE_CREATE_TEMP_VIEW
CreateTrigger Action = C.SQLITE_CREATE_TRIGGER
CreateView Action = C.SQLITE_CREATE_VIEW
Delete Action = C.SQLITE_DELETE
DropIndex Action = C.SQLITE_DROP_INDEX
DropTable Action = C.SQLITE_DROP_TABLE
DropTempIndex Action = C.SQLITE_DROP_TEMP_INDEX
DropTempTable Action = C.SQLITE_DROP_TEMP_TABLE
DropTempTrigger Action = C.SQLITE_DROP_TEMP_TRIGGER
DropTempView Action = C.SQLITE_DROP_TEMP_VIEW
DropTrigger Action = C.SQLITE_DROP_TRIGGER
DropView Action = C.SQLITE_DROP_VIEW
Insert Action = C.SQLITE_INSERT
Pragma Action = C.SQLITE_PRAGMA
Read Action = C.SQLITE_READ
Select Action = C.SQLITE_SELECT
Transaction Action = C.SQLITE_TRANSACTION
Update Action = C.SQLITE_UPDATE
Attach Action = C.SQLITE_ATTACH
Detach Action = C.SQLITE_DETACH
AlterTable Action = C.SQLITE_ALTER_TABLE
Reindex Action = C.SQLITE_REINDEX
Analyze Action = C.SQLITE_ANALYZE
CreateVTable Action = C.SQLITE_CREATE_VTABLE
DropVTable Action = C.SQLITE_DROP_VTABLE
Function Action = C.SQLITE_FUNCTION
Savepoint Action = C.SQLITE_SAVEPOINT
Copy 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 (
STMTSTATUS_FULLSCAN_STEP StmtStatus = C.SQLITE_STMTSTATUS_FULLSCAN_STEP
STMTSTATUS_SORT StmtStatus = C.SQLITE_STMTSTATUS_SORT
STMTSTATUS_AUTOINDEX StmtStatus = C.SQLITE_STMTSTATUS_AUTOINDEX
StmtStatusFullScanStep StmtStatus = C.SQLITE_STMTSTATUS_FULLSCAN_STEP
StmtStatusSort StmtStatus = C.SQLITE_STMTSTATUS_SORT
StmtStatusAutoIndex 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 (
SINGLETHREAD ThreadingMode = C.SQLITE_CONFIG_SINGLETHREAD
MULTITHREAD ThreadingMode = C.SQLITE_CONFIG_MULTITHREAD
SERIALIZED ThreadingMode = C.SQLITE_CONFIG_SERIALIZED
SingleThread ThreadingMode = C.SQLITE_CONFIG_SINGLETHREAD
MultiThread ThreadingMode = C.SQLITE_CONFIG_MULTITHREAD
Serialized ThreadingMode = C.SQLITE_CONFIG_SERIALIZED
)
// Alters threading mode
......
......@@ -11,7 +11,7 @@ import (
)
func init() {
err := ConfigThreadingMode(SERIALIZED)
err := ConfigThreadingMode(Serialized)
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 AUTH_OK
return AuthOk
}
func profile(d interface{}, sql string, nanoseconds uint64) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment