mirror of
https://github.com/ncruces/go-sqlite3.git
synced 2026-01-11 21:49:13 +00:00
Fix #249.
This commit is contained in:
@@ -350,6 +350,8 @@ func (c *Conn) HardHeapLimit(n int64) int64 {
|
||||
}
|
||||
|
||||
// EnableChecksums enables checksums on a database.
|
||||
// If the database is in WAL mode,
|
||||
// you should shutdown and reopen all database connections before continuing.
|
||||
//
|
||||
// https://sqlite.org/cksumvfs.html
|
||||
func (c *Conn) EnableChecksums(schema string) error {
|
||||
|
||||
@@ -5,5 +5,5 @@ package sql3util
|
||||
//
|
||||
// https://sqlite.org/fileformat.html#pages
|
||||
func ValidPageSize(s int) bool {
|
||||
return 512 <= s && s <= 65536 && s&(s-1) == 0
|
||||
return s&(s-1) == 0 && 512 <= s && s <= 65536
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ func (c cksmFile) ReadAt(p []byte, off int64) (n int, err error) {
|
||||
|
||||
func (c cksmFile) WriteAt(p []byte, off int64) (n int, err error) {
|
||||
// SQLite is writing the first page of a database file.
|
||||
if c.isDB && off == 0 && len(p) >= 100 &&
|
||||
if (!c.isDB || off == 0) && sql3util.ValidPageSize(len(p)) &&
|
||||
bytes.HasPrefix(p, []byte("SQLite format 3\000")) {
|
||||
c.init((*[100]byte)(p))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user