Skip to content

Commit 0cd0f48

Browse files
committed
Rename WAL, fixes.
1 parent c69ee0f commit 0cd0f48

File tree

5 files changed

+24
-11
lines changed

5 files changed

+24
-11
lines changed

config.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,10 @@ func traceCallback(ctx context.Context, mod api.Module, evt TraceEvent, pDB, pAr
250250
return rc
251251
}
252252

253-
// WalCheckpoint checkpoints a WAL database.
253+
// WALCheckpoint checkpoints a WAL database.
254254
//
255255
// https://sqlite.org/c3ref/wal_checkpoint_v2.html
256-
func (c *Conn) WalCheckpoint(schema string, mode CheckpointMode) (nLog, nCkpt int, err error) {
256+
func (c *Conn) WALCheckpoint(schema string, mode CheckpointMode) (nLog, nCkpt int, err error) {
257257
defer c.arena.mark()()
258258
nLogPtr := c.arena.new(ptrlen)
259259
nCkptPtr := c.arena.new(ptrlen)
@@ -266,19 +266,19 @@ func (c *Conn) WalCheckpoint(schema string, mode CheckpointMode) (nLog, nCkpt in
266266
return nLog, nCkpt, c.error(r)
267267
}
268268

269-
// WalAutoCheckpoint configures WAL auto-checkpoints.
269+
// WALAutoCheckpoint configures WAL auto-checkpoints.
270270
//
271271
// https://sqlite.org/c3ref/wal_autocheckpoint.html
272-
func (c *Conn) WalAutoCheckpoint(pages int) error {
272+
func (c *Conn) WALAutoCheckpoint(pages int) error {
273273
r := c.call("sqlite3_wal_autocheckpoint", uint64(c.handle), uint64(pages))
274274
return c.error(r)
275275
}
276276

277-
// WalHook registers a callback function to be invoked
277+
// WALHook registers a callback function to be invoked
278278
// each time data is committed to a database in WAL mode.
279279
//
280280
// https://sqlite.org/c3ref/wal_hook.html
281-
func (c *Conn) WalHook(cb func(db *Conn, schema string, pages int) error) {
281+
func (c *Conn) WALHook(cb func(db *Conn, schema string, pages int) error) {
282282
var enable uint64
283283
if cb != nil {
284284
enable = 1

tests/wal_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func TestWAL_readonly(t *testing.T) {
104104
}
105105
}
106106

107-
func TestConn_WalCheckpoint(t *testing.T) {
107+
func TestConn_WALCheckpoint(t *testing.T) {
108108
if !vfs.SupportsFileLocking {
109109
t.Skip("skipping without locks")
110110
}
@@ -118,13 +118,13 @@ func TestConn_WalCheckpoint(t *testing.T) {
118118
}
119119
defer db.Close()
120120

121-
err = db.WalAutoCheckpoint(1000)
121+
err = db.WALAutoCheckpoint(1000)
122122
if err != nil {
123123
t.Fatal(err)
124124
}
125125

126-
db.WalHook(func(db *sqlite3.Conn, schema string, pages int) error {
127-
log, ckpt, err := db.WalCheckpoint(schema, sqlite3.CHECKPOINT_FULL)
126+
db.WALHook(func(db *sqlite3.Conn, schema string, pages int) error {
127+
log, ckpt, err := db.WALCheckpoint(schema, sqlite3.CHECKPOINT_FULL)
128128
t.Log(log, ckpt, err)
129129
return err
130130
})

util/sql3util/arg.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ func NamedArg(arg string) (key, val string) {
1313
}
1414

1515
// Unquote unquotes a string.
16+
//
17+
// https://sqlite.org/lang_keywords.html
1618
func Unquote(val string) string {
1719
if len(val) < 2 {
1820
return val
@@ -40,6 +42,9 @@ func Unquote(val string) string {
4042
return strings.ReplaceAll(rst, old, new)
4143
}
4244

45+
// ParseBool parses a boolean.
46+
//
47+
// https://sqlite.org/pragma.html#syntax
4348
func ParseBool(s string) (b, ok bool) {
4449
if len(s) == 0 {
4550
return false, false

util/sql3util/sql3util.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
11
// Package sql3util implements SQLite utilities.
22
package sql3util
3+
4+
// ValidPageSize returns true if s is a valid page size.
5+
//
6+
// https://sqlite.org/fileformat.html#pages
7+
func ValidPageSize(s int) bool {
8+
return 512 <= s && s <= 65536 && s&(s-1) == 0
9+
}

vfs/vfs.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"crypto/rand"
66
"io"
77
"reflect"
8+
"strings"
89
"time"
910

1011
"github.com/tetratelabs/wazero"
@@ -343,7 +344,7 @@ func vfsFileControl(ctx context.Context, mod api.Module, pFile uint32, op _Fcntl
343344
value = util.ReadString(mod, ptr, _MAX_SQL_LENGTH)
344345
}
345346

346-
out, err := file.Pragma(name, value)
347+
out, err := file.Pragma(strings.ToLower(name), value)
347348

348349
ret := vfsErrorCode(err, _ERROR)
349350
if ret == _ERROR {

0 commit comments

Comments
 (0)