Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions sqlite3.go
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,7 @@ func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) {

// PRAGMA's
encryptKey := ""
cipher_page_size := 0
cipher_compatibility := -1
autoVacuum := -1
busyTimeout := 5000
Expand Down Expand Up @@ -1056,6 +1057,15 @@ func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) {
encryptKey = val
}

// _cipher_page_size
if val := params.Get("_cipher_page_size"); val != "" {
size, err := strconv.ParseInt(val, 10, 64)
if err != nil {
return nil, fmt.Errorf("Invalid _cipher_page_size: %v: %v", val, err)
}
cipher_page_size = int(size)
}

// _cipher_compatibility
if val := params.Get("_cipher_compatibility"); val != "" {
iv, err := strconv.ParseInt(val, 10, 64)
Expand Down Expand Up @@ -1429,6 +1439,16 @@ func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) {
}
}

// Cipher Page Size
// The cipher_page_size pragma should be called immediately after if provided
if cipher_page_size > 0 {
err := exec(fmt.Sprintf("PRAGMA cipher_page_size = %d;", cipher_page_size))
if err != nil {
C.sqlite3_close_v2(db)
return nil, err
}
}

// Cipher Compatibility
// The cipher_compatibility pragma should be called immediately after if provided
if cipher_compatibility > -1 {
Expand Down