tmp-postgres 1.28.0.0 → 1.28.1.0
raw patch · 5 files changed
+84/−12 lines, 5 filesdep ~basedep ~postgres-optionsdep ~processnew-component:exe:with-cache-loop
Dependency ranges changed: base, postgres-options, process
Files
- CHANGELOG.md +3/−0
- profiling/Main.hs +12/−0
- src/Database/Postgres/Temp/Internal/Config.hs +38/−4
- test/Main.hs +1/−3
- tmp-postgres.cabal +30/−5
CHANGELOG.md view
@@ -1,5 +1,8 @@ Changelog for tmp-postgres +1.28.1.0+ #208 Only hash important envs for initdb cache.+ 1.28.0.0 #200 Change behavior of Permanent. We now create the directory if it does not exist. Other changes
+ profiling/Main.hs view
@@ -0,0 +1,12 @@+import Database.Postgres.Temp+import Control.Exception++withLoop :: IO ()+withLoop = either throwIO pure =<< with (const $ pure ())++withCacheLoop :: IO ()+withCacheLoop = withDbCache $ \cache -> either throwIO pure =<<+ withConfig (defaultConfig <> cacheConfig cache) (const $ pure ())++main :: IO ()+main = withCacheLoop
src/Database/Postgres/Temp/Internal/Config.hs view
@@ -395,9 +395,9 @@ -- TODO come up with a better way to deal with this. Probably -- need to lock the directories recursively before deleting. handle ignoreDirIsMissing $- try (removePathForcibly mainDir) >>= \case- Left (_ :: IOError) -> try (removePathForcibly mainDir) >>= \case- Left (_ :: IOError) -> removePathForcibly mainDir+ try (removeDirectoryRecursive mainDir) >>= \case+ Left (_ :: IOError) -> try (removeDirectoryRecursive mainDir) >>= \case+ Left (_ :: IOError) -> removeDirectoryRecursive mainDir Right _ -> pure () Right _ -> pure () @@ -606,7 +606,8 @@ makeCommandLine :: String -> CompleteProcessConfig -> String makeCommandLine command CompleteProcessConfig {..} =- let envs = unwords $ map (\(x, y) -> x <> "=" <> y) completeProcessConfigEnvVars+ let envs = unwords $ map (\(x, y) -> x <> "=" <> y)+ $ filter ((`elem` envsToKeep) . fst) completeProcessConfigEnvVars args = unwords completeProcessConfigCmdLine in envs <> " " <> command <> args @@ -622,6 +623,39 @@ version = getInitDbVersion theHash = makeArgumentHash cmdLine in cacheFolder <> "/" <> version <> "/" <> theHash++envsToKeep :: [String]+envsToKeep =+ [ "PGHOST"+ , "PGHOSTADDR"+ , "PGPORT"+ , "PGDATABASE"+ , "PGUSER"+ , "PGPASSWORD"+ , "PGPASSFILE"+ , "PGSERVICE"+ , "PGSERVICEFILE"+ , "PGOPTIONS"+ , "PGAPPNAME"+ , "PGSSLMODE"+ , "PGREQUIRESSL"+ , "PGSSLCOMPRESSION"+ , "PGSSLCERT"+ , "PGSSLKEY"+ , "PGSSLROOTCERT"+ , "PGSSLCRL"+ , "PGREQUIREPEER"+ , "PGKRBSRVNAME"+ , "PGGSSLIB"+ , "PGCONNECT_TIMEOUT"+ , "PGCLIENTENCODING"+ , "PGTARGETSESSIONATTRS"+ , "PGDATESTYLE"+ , "PGTZ"+ , "PGGEQO"+ , "PGSYSCONFDIR"+ , "PGLOCALEDIR"+ ] splitDataDirectory :: CompleteProcessConfig -> (Maybe String, CompleteProcessConfig) splitDataDirectory old =
test/Main.hs view
@@ -472,10 +472,8 @@ withConfig nonEmptyFolderPlan mempty >>= \case Right () -> fail "Should not succeed"- Left ((InitDbFailed theOut theErr code)) -> do+ Left ((InitDbFailed _ _ code)) -> code `shouldBe` ExitFailure 1- length theOut `shouldSatisfy` (> 0)- length theErr `shouldSatisfy` (> 0) Left err -> fail $ "Wrong type of error " <> show err it "invalid initdb options cause an error" $ do
tmp-postgres.cabal view
@@ -1,5 +1,5 @@ name: tmp-postgres-version: 1.28.0.0+version: 1.28.1.0 synopsis: Start and stop a temporary postgres description: Start and stop a temporary postgres. See README.md homepage: https://github.com/jfischoff/tmp-postgres#readme@@ -99,7 +99,7 @@ main-is: Main.hs hs-source-dirs: benchmark default-language: Haskell2010- ghc-options: -O2 -Wall+ ghc-options: -O2 -Wall -threaded -rtsopts -with-rtsopts=-N build-depends: base , criterion , deepseq@@ -155,6 +155,31 @@ , TupleSections , ViewPatterns -source-repository head- type: git- location: https://github.com/jfischoff/tmp-postgres+executable with-cache-loop+ main-is: Main.hs+ hs-source-dirs: profiling+ default-language: Haskell2010+ ghc-options: -O2 -Wall -threaded -rtsopts -with-rtsopts=-N+ build-depends: base+ , async+ , directory+ , postgres-options+ , postgresql-simple+ , process+ , temporary+ , tmp-postgres+ default-extensions:+ ApplicativeDo+ , DeriveFunctor+ , DeriveGeneric+ , DerivingStrategies+ , DerivingVia+ , GeneralizedNewtypeDeriving+ , LambdaCase+ , OverloadedStrings+ , RankNTypes+ , RecordWildCards+ , ScopedTypeVariables+ , TemplateHaskell+ , TupleSections+ , ViewPatterns