From abf681aaa98030f1805df84af9ed03b306843509 Mon Sep 17 00:00:00 2001 From: safiir <809320935@qq.com> Date: Sun, 26 Mar 2023 18:10:51 +0800 Subject: [PATCH] ADD: PRAGMA cipher_compatibility --- sqlite3.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/sqlite3.go b/sqlite3.go index 363a44a..90ee021 100644 --- a/sqlite3.go +++ b/sqlite3.go @@ -1016,6 +1016,7 @@ func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) { // PRAGMA's encryptKey := "" + cipher_compatibility := -1 autoVacuum := -1 busyTimeout := 5000 caseSensitiveLike := -1 @@ -1042,6 +1043,15 @@ func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) { encryptKey = val } + // _cipher_compatibility + if val := params.Get("_cipher_compatibility"); val != "" { + iv, err := strconv.ParseInt(val, 10, 64) + if err != nil { + return nil, fmt.Errorf("Invalid _cipher_compatibility: %v: %v", val, err) + } + cipher_compatibility = int(iv) + } + // Authentication if _, ok := params["_auth"]; ok { authCreate = true @@ -1406,6 +1416,15 @@ func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) { } } + // Cipher Compatibility + // The cipher_compatibility pragma should be called immediately after if provided + if cipher_compatibility > -1 { + if err := exec(fmt.Sprintf("PRAGMA cipher_compatibility = %d;", cipher_compatibility)); err != nil { + C.sqlite3_close_v2(db) + return nil, err + } + } + // USER AUTHENTICATION // // User Authentication is always performed even when