-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update bundled sqlite to 3.5.0 #47
Conversation
I appreciate it! There's actually a one-line change that we have to make every time we upgrade. :( It has to do with the stat64 structure on OS X... I can get to it sometime this weekend, or if you are motivated and want to learn the details, you can educate yourself by examining a pull request for a previous sqlite version upgrade. :) |
i couldn't test it on OS X anyway, so probably better for you to do it :) On Sat, Jun 28, 2014 at 7:05 AM, Irene Knapp notifications@github.com
A UNIX signature isn't a return address, it's the ASCII equivalent of a |
Fair enough! :) |
i think
is the needed change? Anyway, it's working locally. |
(i would update the PR but emacs stripped the whitespace from the c files so it looks like a massive commit) |
Ah, excellent, thank you! I very much appreciate your doing this work. I tagged this issue with a new tag, "useful", so that we can find your research easily next time around, haha. I'll fix the whitespace at my end and get this merged in, sometime tonight. :) |
Thanks Irene :) looking to remove one of my seemingly infinite list of cabal sandbox add-source invocations... |
Hi Irene - is there something blocking releasing this to hackage? |
I'll apply the OS X change separately. |
For the record, I think the author of this PR meant sqlite 3.8.5, not 3.5. |
@mwotton @IreneKnapp This is working for me on Mac OS X without applying the stat fix. I'll try to dig out from the issues database why it's required. If you know, please let me know. EDIT: it's documented in commit 6890f68. I'll try if it still repros. |
Yeah - I tagged that issue as "useful" for this reason! |
Since it was a patch around an upstream issue, probably they finally fixed it. :) |
is working fine. But I don't know if this is pertinent to some particular GHC and/or Mac OS X version. I'm thinking I'll release without it and make a point release with this patch if someone complains. EDIT: I think I'll just apply the path. |
This is now in direct-sqlite-2.3.14 on Hackage. |
This reverts commit ffc6e42. See IreneKnapp#47 for more information. (cherry picked from commit 8576d6f)
There are two SQLite encryption options: - [SQLite SEE](http://www.hwaci.com/sw/sqlite/see.html) - [SQLCipher](https://www.zetetic.net/sqlcipher/) SEE can be bought from the original authors, while SQLCipher is an open source option. This change adds the SQLCipher amalgamation (`./configure && make sqlite3.c`) from SQLCipher v3.4.2 release source code. The `stat_local` patch (IreneKnapp#47) has *NOT* be applied, as this works fine without on macOS Sierra. The SQLCipher engine can be compiled against commoncrypto (apple), OpenSSL or LibTomCrypt. If any of the respective `-f`lags are enable, the SQLCipher SQLite3 version is build. With SQLCipher the `PRAGMA key` and `PRAGMA rekey` pragmas can be used: ``` PRAGMA key = 'passphrase'; -- start with the existing database passphrase PRAGMA rekey = 'new-passphrase'; -- rekey will reencrypt with the new passphrase ``` and need to be issued as first command when working with encrypted databases. Together with the `sqlite-simple` package we can then build something simple like the following encrypted databases access ``` {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} module Main where import qualified Database.SQLite.Simple as DB import qualified Database.SQLite.Simple.FromRow as DB import Data.Monoid ((<>)) import qualified Data.Text as T import Data.String (fromString) import Control.Exception main :: IO () main = DB.withConnection "test.db" $ \conn -> do version <- getUserVersion' conn $ do putStrLn "Please provide the passphrase" getLine case version of 0 -> do putStrLn "Please provide initial passphrase" passphrase <- getLine setKey conn passphrase initDb conn return () _ -> putStrLn "TODO: Do something with the database..." return () setKey :: DB.Connection -> String -> IO () setKey conn passphrase = DB.execute_ conn . fromString $ "PRAGMA key = '" <> passphrase <> "'" getUserVersion :: DB.Connection -> IO Int getUserVersion conn = head <$> DB.query_ conn "PRAGMA user_version" >>= \case DB.Only n -> return n -- | Tries to get the userVersion, and uses the handle to -- request the password, until it succeeds. getUserVersion' :: DB.Connection -> IO String -> IO Int getUserVersion' conn getPassphrase = handleJust exFilter exHandle (getUserVersion conn) where exFilter :: DB.SQLError -> Maybe () exFilter (DB.SQLError DB.ErrorNotADatabase _ _) = Just () exFilter _ = Nothing exHandle :: () -> IO Int exHandle _ = do passphrase <- getPassphrase setKey conn passphrase getUserVersion' conn getPassphrase -- | Initialize or migrate the database initDb :: DB.Connection -> IO Int initDb conn = getUserVersion conn >>= \case 0 -> DB.execute_ conn "PRAGMA user_version = 1" >> return 1 n -> return n ```
i noticed there was a new sqlite, so figured the bundling could be updated. No sweat if you've already got a process for doing this :)