diff --git a/sqlite3.go b/sqlite3.go index 3c609eb..5e9a5c2 100644 --- a/sqlite3.go +++ b/sqlite3.go @@ -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 @@ -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) @@ -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 {