packages feed

tmp-postgres 1.34.0.1 → 1.34.1.0

raw patch · 5 files changed

+42/−3 lines, 5 filesdep ~ansi-wl-pprint

Dependency ranges changed: ansi-wl-pprint

Files

CHANGELOG.md view
@@ -1,4 +1,6 @@ Changelog for tmp-postgres+- 1.34.1.0+  - #229 Add a `auto_explain` config  - 1.34.0.1   - #244 Fix cacheDbConfig doc
src/Database/Postgres/Temp.hs view
@@ -56,6 +56,7 @@   , defaultConfig   , defaultConfig_9_3_10   , verboseConfig+  , autoExplainConfig   -- *** Custom Config builder helpers   , optionsToDefaultConfig   -- ** Main resource handle
src/Database/Postgres/Temp/Internal.hs view
@@ -262,6 +262,43 @@   , postgresConfig = standardProcessConfig   } +{-|+Useful options for configuring and loading @auto_explain@.++@since 1.34.1.0+-}+autoExplainPostgresConfig :: Int -> [(String, String)]+autoExplainPostgresConfig milliseconds = verbosePostgresConfig <>+  [ ("log_min_duration_statement", show milliseconds <> "ms")+  , ("shared_preload_libraries", "'auto_explain'")+  , ("session_preload_libraries", "'auto_explain'")+  , ("auto_explain.log_analyze", "1")+  , ("auto_explain.log_buffers", "1")+  , ("auto_explain.log_timing", "1")+  , ("auto_explain.log_triggers", "1")+  , ("auto_explain.log_verbose", "1")+  , ("auto_explain.log_min_duration", show milliseconds <> "ms")+  , ("auto_explain.log_nested_statements", "1")+  , ("auto_explain.sample_rate", "1")+  , ("auto_explain.log_verbose", "on")+  , ("log_connections", "off")+  , ("log_disconnections", "off")+  ]++{-|+A config which loads and configures @auto_explain@. Useful for+understanding slow queries plans.++@since 1.34.1.0+-}+autoExplainConfig+  :: Int+  -- ^ Minimum number of milliseconds to log. Use 0 to log all queries.+  -> Config+autoExplainConfig milliseconds = defaultConfig <> mempty+  { postgresConfigFile = autoExplainPostgresConfig milliseconds+  , postgresConfig = standardProcessConfig+  }  {-| 
test/Main.hs view
@@ -381,7 +381,7 @@    it "withDbCache seems to work" $     withDbCache $ \cacheInfo ->-      either throwIO pure <=< withConfig (cacheConfig cacheInfo <> verboseConfig) $ \db -> do+      either throwIO pure <=< withConfig (cacheConfig cacheInfo <> autoExplainConfig 0) $ \db -> do         assertConnection db         withConn db $ \conn -> countDbs conn `shouldReturn` 3 @@ -628,7 +628,6 @@     let action db = withConn db $ \conn -> do           _ <- PG.execute_ conn "BEGIN; CREATE TABLE foo ( id int );"           void $ PG.execute_ conn "INSERT INTO foo (id) VALUES (1); END;"-          putStrLn "hey"     withTempDirectory "/tmp" "tmp-postgres-cache-action" $ \cachePath -> do       let theFinalCachePath = cachePath <> "/cached"       cacheAction theFinalCachePath action (defaultConfig { dataDirectory = Permanent theFinalCachePath } ) >>= \case
tmp-postgres.cabal view
@@ -1,5 +1,5 @@ name:                tmp-postgres-version:             1.34.0.1+version:             1.34.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