git.iko.soy/typeable/postgresql-simple
on master help sign in
Merge pull request #121 from haskellari/libpq-0.10
cc3a39bOleg Grenrus
.github/workflows/haskell-ci.yml+2−32
@@ -73,36 +73,6 @@ jobs:
73 compilerVersion: 8.6.5
73 compilerVersion: 8.6.5
74 setup-method: hvr-ppa
74 setup-method: hvr-ppa
75 allow-failure: false
75 allow-failure: false
76− - compiler: ghc-8.4.4
77− compilerKind: ghc
78− compilerVersion: 8.4.4
79− setup-method: hvr-ppa
80− allow-failure: false
81− - compiler: ghc-8.2.2
82− compilerKind: ghc
83− compilerVersion: 8.2.2
84− setup-method: hvr-ppa
85− allow-failure: false
86− - compiler: ghc-8.0.2
87− compilerKind: ghc
88− compilerVersion: 8.0.2
89− setup-method: hvr-ppa
90− allow-failure: false
91− - compiler: ghc-7.10.3
92− compilerKind: ghc
93− compilerVersion: 7.10.3
94− setup-method: hvr-ppa
95− allow-failure: false
96− - compiler: ghc-7.8.4
97− compilerKind: ghc
98− compilerVersion: 7.8.4
99− setup-method: hvr-ppa
100− allow-failure: false
101− - compiler: ghc-7.6.3
102− compilerKind: ghc
103− compilerVersion: 7.6.3
104− setup-method: hvr-ppa
105− allow-failure: false
106 fail-fast: false
76 fail-fast: false
107 steps:
77 steps:
108 - name: apt
78 - name: apt
@@ -229,8 +199,8 @@ jobs:
229 touch cabal.project
199 touch cabal.project
230 touch cabal.project.local
200 touch cabal.project.local
231 echo "packages: ${PKGDIR_postgresql_simple}" >> cabal.project
201 echo "packages: ${PKGDIR_postgresql_simple}" >> cabal.project
232− if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo "package postgresql-simple" >> cabal.project ; fi
202+ echo "package postgresql-simple" >> cabal.project
233− if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo " ghc-options: -Werror=missing-methods" >> cabal.project ; fi
203+ echo " ghc-options: -Werror=missing-methods" >> cabal.project
234 cat >> cabal.project <<EOF
204 cat >> cabal.project <<EOF
235 allow-newer: cryptohash-md5-0.11.100.1:base
205 allow-newer: cryptohash-md5-0.11.100.1:base
236 EOF
206 EOF
.github/workflows/simple.yml+1−1
@@ -14,7 +14,7 @@ jobs:
14 strategy:
14 strategy:
15 matrix:
15 matrix:
16 os: [macos-latest, windows-latest]
16 os: [macos-latest, windows-latest]
17− ghc: ['8.10','9.0','9.2','9.4.2']
17+ ghc: ['8.10','9.0','9.2','9.4.5','9.6.2']
18 fail-fast: false
18 fail-fast: false
19 timeout-minutes:
19 timeout-minutes:
20 60
20 60
CHANGES.md+4−1
@@ -1,6 +1,9 @@
1−### Version 0.7 (2023-07-31)
1+### Version 0.7.0.0 (2023-07-31)
2
2
3 * Remove Eq Null instance. (Future `base` may break it, we remove it profilacticly).
3 * Remove Eq Null instance. (Future `base` may break it, we remove it profilacticly).
4+ * Use `postgresql-libpq >=0.10.0.0`. It includes critical fixes,
5+ by using `postgresql-simple >=0.7` you won't get older `postgresql-libpq`.
6+ * Drop support for GHC prior 8.6
4
7
5### Version 0.6.5.1 (2023-07-09)
8### Version 0.6.5.1 (2023-07-09)
6
9
postgresql-simple.cabal+8−33
@@ -1,6 +1,6 @@
1cabal-version: 1.12
1cabal-version: 1.12
2name: postgresql-simple
2name: postgresql-simple
3−version: 0.6.5.1
3+version: 0.7.0.0
4synopsis: Mid-Level PostgreSQL client library
4synopsis: Mid-Level PostgreSQL client library
5description:
5description:
6 Mid-Level PostgreSQL client library, forked from mysql-simple.
6 Mid-Level PostgreSQL client library, forked from mysql-simple.
@@ -23,13 +23,7 @@ extra-source-files:
23 test/results/unique-constraint-violation.expected
23 test/results/unique-constraint-violation.expected
24
24
25tested-with:
25tested-with:
26− GHC ==7.6.3
27− || ==7.8.4
28− || ==7.10.3
29− || ==8.0.2
30− || ==8.2.2
31− || ==8.4.4
32− || ==8.6.5
26+ GHC ==8.6.5
33 || ==8.8.4
27 || ==8.8.4
34 || ==8.10.7
28 || ==8.10.7
35 || ==9.0.2
29 || ==9.0.2
@@ -81,13 +75,13 @@ library
81
75
82 -- GHC bundled libs
76 -- GHC bundled libs
83 build-depends:
77 build-depends:
84− base >=4.6.0.0 && <4.19
78+ base >=4.12.0.0 && <4.19
85− , bytestring >=0.10.0.0 && <0.12
79+ , bytestring >=0.10.8.2 && <0.12
86− , containers >=0.5.0.0 && <0.7
80+ , containers >=0.6.0.1 && <0.7
87− , template-haskell >=2.8.0.0 && <2.21
81+ , template-haskell >=2.14.0.0 && <2.21
88 , text >=1.2.3.0 && <1.3 || >=2.0 && <2.1
82 , text >=1.2.3.0 && <1.3 || >=2.0 && <2.1
89 , time-compat >=1.9.5 && <1.12
83 , time-compat >=1.9.5 && <1.12
90− , transformers >=0.3.0.0 && <0.7
84+ , transformers >=0.5.6.2 && <0.7
91
85
92 -- Other dependencies
86 -- Other dependencies
93 build-depends:
87 build-depends:
@@ -97,19 +91,11 @@ library
97 , case-insensitive >=1.2.0.11 && <1.3
91 , case-insensitive >=1.2.0.11 && <1.3
98 , hashable >=1.2.7.0 && <1.5
92 , hashable >=1.2.7.0 && <1.5
99 , Only >=0.1 && <0.1.1
93 , Only >=0.1 && <0.1.1
100− , postgresql-libpq >=0.9.4.3 && <0.10
94+ , postgresql-libpq >=0.10.0.0 && <0.11
101 , scientific >=0.3.6.2 && <0.4
95 , scientific >=0.3.6.2 && <0.4
102 , uuid-types >=1.0.3 && <1.1
96 , uuid-types >=1.0.3 && <1.1
103 , vector >=0.12.0.1 && <0.14
97 , vector >=0.12.0.1 && <0.14
104
98
105− if !impl(ghc >=8.0)
106− build-depends:
107− fail >=4.9.0.0 && <4.10
108− , semigroups >=0.18.5 && <0.21
109−
110− if !impl(ghc >=7.6)
111− build-depends: ghc-prim
112−
113 default-extensions:
99 default-extensions:
114 BangPatterns
100 BangPatterns
115 DoAndIfThenElse
101 DoAndIfThenElse
@@ -123,15 +109,7 @@ source-repository head
123 type: git
109 type: git
124 location: http://github.com/haskellari/postgresql-simple
110 location: http://github.com/haskellari/postgresql-simple
125
111
126−source-repository this
127− type: git
128− location: http://github.com/haskellari/postgresql-simple
129− tag: v0.6.3
130−
131test-suite inspection
112test-suite inspection
132− if !impl(ghc >=8.0)
133− buildable: False
134−
135 default-language: Haskell2010
113 default-language: Haskell2010
136 type: exitcode-stdio-1.0
114 type: exitcode-stdio-1.0
137 hs-source-dirs: test
115 hs-source-dirs: test
@@ -184,9 +162,6 @@ test-suite test
184 , time-compat
162 , time-compat
185 , vector
163 , vector
186
164
187− if !impl(ghc >=7.6)
188− build-depends: ghc-prim
189−
190benchmark select
165benchmark select
191 default-language: Haskell2010
166 default-language: Haskell2010
192 type: exitcode-stdio-1.0
167 type: exitcode-stdio-1.0
src/Database/PostgreSQL/Simple/Compat.hs−53
@@ -12,36 +12,13 @@ module Database.PostgreSQL.Simple.Compat
12 ) where
12 ) where
13
13
14import qualified Control.Exception as E
14import qualified Control.Exception as E
15−import Data.Monoid
16import Data.ByteString (ByteString)
15import Data.ByteString (ByteString)
17−#if MIN_VERSION_bytestring(0,10,0)
18import Data.ByteString.Lazy (toStrict)
16import Data.ByteString.Lazy (toStrict)
19−#else
20−import qualified Data.ByteString as B
21−import Data.ByteString.Lazy (toChunks)
22−#endif
23import Data.ByteString.Builder (Builder, toLazyByteString)
17import Data.ByteString.Builder (Builder, toLazyByteString)
24−
25−#if MIN_VERSION_scientific(0,3,0)
26import Data.Text.Lazy.Builder.Scientific (scientificBuilder)
18import Data.Text.Lazy.Builder.Scientific (scientificBuilder)
27−#else
28−import Data.Scientific (scientificBuilder)
29−#endif
30−
31−#if __GLASGOW_HASKELL__ >= 702
32import System.IO.Unsafe (unsafeDupablePerformIO)
19import System.IO.Unsafe (unsafeDupablePerformIO)
33−#elif __GLASGOW_HASKELL__ >= 611
34−import GHC.IO (unsafeDupablePerformIO)
35−#else
36−import GHC.IOBase (unsafeDupablePerformIO)
37−#endif
38−
39import Data.Fixed (Pico)
20import Data.Fixed (Pico)
40−#if MIN_VERSION_base(4,7,0)
41import Data.Fixed (Fixed(MkFixed))
21import Data.Fixed (Fixed(MkFixed))
42−#else
43−import Unsafe.Coerce (unsafeCoerce)
44−#endif
45
22
46-- | Like 'E.mask', but backported to base before version 4.3.0.
23-- | Like 'E.mask', but backported to base before version 4.3.0.
47--
24--
@@ -51,44 +28,14 @@ import Unsafe.Coerce (unsafeCoerce)
51-- 'withTransactionMode' function calls the restore callback only once, so we
28-- 'withTransactionMode' function calls the restore callback only once, so we
52-- don't need that polymorphism.
29-- don't need that polymorphism.
53mask :: ((IO a -> IO a) -> IO b) -> IO b
30mask :: ((IO a -> IO a) -> IO b) -> IO b
54−#if MIN_VERSION_base(4,3,0)
55mask io = E.mask $ \restore -> io restore
31mask io = E.mask $ \restore -> io restore
56−#else
57−mask io = do
58− b <- E.blocked
59− E.block $ io $ \m -> if b then m else E.unblock m
60−#endif
61{-# INLINE mask #-}
32{-# INLINE mask #-}
62
33
63−#if !MIN_VERSION_base(4,5,0)
64−infixr 6 <>
65−
66−(<>) :: Monoid m => m -> m -> m
67−(<>) = mappend
68−{-# INLINE (<>) #-}
69−#endif
70−
71toByteString :: Builder -> ByteString
34toByteString :: Builder -> ByteString
72−#if MIN_VERSION_bytestring(0,10,0)
73toByteString x = toStrict (toLazyByteString x)
35toByteString x = toStrict (toLazyByteString x)
74−#else
75−toByteString x = B.concat (toChunks (toLazyByteString x))
76−#endif
77−
78−#if MIN_VERSION_base(4,7,0)
79
36
80toPico :: Integer -> Pico
37toPico :: Integer -> Pico
81toPico = MkFixed
38toPico = MkFixed
82
39
83fromPico :: Pico -> Integer
40fromPico :: Pico -> Integer
84fromPico (MkFixed i) = i
41fromPico (MkFixed i) = i
85−
86−#else
87−
88−toPico :: Integer -> Pico
89−toPico = unsafeCoerce
90−
91−fromPico :: Pico -> Integer
92−fromPico = unsafeCoerce
93−
94−#endif
src/Database/PostgreSQL/Simple/Copy.hs−4
@@ -86,12 +86,8 @@ doCopy funcName conn template q = do
86 PQ.TuplesOk -> err
86 PQ.TuplesOk -> err
87 PQ.CopyOut -> return ()
87 PQ.CopyOut -> return ()
88 PQ.CopyIn -> return ()
88 PQ.CopyIn -> return ()
89−#if MIN_VERSION_postgresql_libpq(0,9,3)
90 PQ.CopyBoth -> errMsg "COPY BOTH is not supported"
89 PQ.CopyBoth -> errMsg "COPY BOTH is not supported"
91−#endif
92−#if MIN_VERSION_postgresql_libpq(0,9,2)
93 PQ.SingleTuple -> errMsg "single-row mode is not supported"
90 PQ.SingleTuple -> errMsg "single-row mode is not supported"
94−#endif
95 PQ.BadResponse -> throwResultError funcName result status
91 PQ.BadResponse -> throwResultError funcName result status
96 PQ.NonfatalError -> throwResultError funcName result status
92 PQ.NonfatalError -> throwResultError funcName result status
97 PQ.FatalError -> throwResultError funcName result status
93 PQ.FatalError -> throwResultError funcName result status
src/Database/PostgreSQL/Simple/Errors.hs−1
@@ -25,7 +25,6 @@ module Database.PostgreSQL.Simple.Errors
25 )
25 )
26 where
26 where
27
27
28−import Control.Applicative
29import Control.Exception as E
28import Control.Exception as E
30
29
31import Data.Attoparsec.ByteString.Char8
30import Data.Attoparsec.ByteString.Char8
src/Database/PostgreSQL/Simple/HStore/Implementation.hs−6
@@ -22,9 +22,6 @@ import Data.ByteString.Builder (Builder, byteString, char8)
22import qualified Data.ByteString.Builder as BU
22import qualified Data.ByteString.Builder as BU
23import Data.ByteString.Internal (c2w, w2c)
23import Data.ByteString.Internal (c2w, w2c)
24import qualified Data.ByteString.Lazy as BL
24import qualified Data.ByteString.Lazy as BL
25−#if !MIN_VERSION_bytestring(0,10,0)
26−import qualified Data.ByteString.Lazy.Internal as BL (foldrChunks)
27−#endif
28import Data.Map(Map)
25import Data.Map(Map)
29import qualified Data.Map as Map
26import qualified Data.Map as Map
30import Data.Text(Text)
27import Data.Text(Text)
@@ -69,9 +66,6 @@ instance Semigroup HStoreBuilder where
69
66
70instance Monoid HStoreBuilder where
67instance Monoid HStoreBuilder where
71 mempty = Empty
68 mempty = Empty
72−#if !(MIN_VERSION_base(4,11,0))
73− mappend = (<>)
74−#endif
75
69
76class ToHStoreText a where
70class ToHStoreText a where
77 toHStoreText :: a -> HStoreText
71 toHStoreText :: a -> HStoreText
src/Database/PostgreSQL/Simple/Internal.hs−4
@@ -34,7 +34,6 @@ import Data.Int (Int64)
34import qualified Data.IntMap as IntMap
34import qualified Data.IntMap as IntMap
35import Data.IORef
35import Data.IORef
36import Data.Maybe(fromMaybe)
36import Data.Maybe(fromMaybe)
37−import Data.Monoid
38import Data.String
37import Data.String
39import qualified Data.Text as T
38import qualified Data.Text as T
40import qualified Data.Text.Encoding as TE
39import qualified Data.Text.Encoding as TE
@@ -490,9 +489,6 @@ instance Alternative Conversion where
490 Errors _ -> (oka <|>) <$> runConversion mb conn
489 Errors _ -> (oka <|>) <$> runConversion mb conn
491
490
492instance Monad Conversion where
491instance Monad Conversion where
493−#if !(MIN_VERSION_base(4,8,0))
494− return = pure
495−#endif
496 m >>= f = Conversion $ \conn -> do
492 m >>= f = Conversion $ \conn -> do
497 oka <- runConversion m conn
493 oka <- runConversion m conn
498 case oka of
494 case oka of
src/Database/PostgreSQL/Simple/Internal/PQResultUtils.hs−4
@@ -76,12 +76,8 @@ finishQueryWith' q result k = do
76 PQ.CommandOk -> queryErr "query resulted in a command response (did you mean to use `execute` or forget a RETURNING?)"
76 PQ.CommandOk -> queryErr "query resulted in a command response (did you mean to use `execute` or forget a RETURNING?)"
77 PQ.CopyOut -> queryErr "query: COPY TO is not supported"
77 PQ.CopyOut -> queryErr "query: COPY TO is not supported"
78 PQ.CopyIn -> queryErr "query: COPY FROM is not supported"
78 PQ.CopyIn -> queryErr "query: COPY FROM is not supported"
79−#if MIN_VERSION_postgresql_libpq(0,9,3)
80 PQ.CopyBoth -> queryErr "query: COPY BOTH is not supported"
79 PQ.CopyBoth -> queryErr "query: COPY BOTH is not supported"
81−#endif
82−#if MIN_VERSION_postgresql_libpq(0,9,2)
83 PQ.SingleTuple -> queryErr "query: single-row mode is not supported"
80 PQ.SingleTuple -> queryErr "query: single-row mode is not supported"
84−#endif
85 PQ.BadResponse -> throwResultError "query" result status
81 PQ.BadResponse -> throwResultError "query" result status
86 PQ.NonfatalError -> throwResultError "query" result status
82 PQ.NonfatalError -> throwResultError "query" result status
87 PQ.FatalError -> throwResultError "query" result status
83 PQ.FatalError -> throwResultError "query" result status
src/Database/PostgreSQL/Simple/Notification.hs−17
@@ -47,8 +47,6 @@ import GHC.IO.Exception ( ioe_location )
47
47
48#if defined(mingw32_HOST_OS)
48#if defined(mingw32_HOST_OS)
49import Control.Concurrent ( threadDelay )
49import Control.Concurrent ( threadDelay )
50−#elif !MIN_VERSION_base(4,7,0)
51−import Control.Concurrent ( threadWaitRead )
52#else
50#else
53import GHC.Conc ( atomically )
51import GHC.Conc ( atomically )
54import Control.Concurrent ( threadWaitReadSTM )
52import Control.Concurrent ( threadWaitReadSTM )
@@ -94,21 +92,6 @@ getNotification conn = join $ withConnection conn fetch
94 -- with async exceptions, whereas threadDelay can.
92 -- with async exceptions, whereas threadDelay can.
95 Just _fd -> do
93 Just _fd -> do
96 return (threadDelay 1000000 >> loop)
94 return (threadDelay 1000000 >> loop)
97−#elif !MIN_VERSION_base(4,7,0)
98− -- Technically there's a race condition that is usually benign.
99− -- If the connection is closed or reset after we drop the
100− -- lock, and then the fd index is reallocated to a new
101− -- descriptor before we call threadWaitRead, then
102− -- we could end up waiting on the wrong descriptor.
103− --
104− -- Now, if the descriptor becomes readable promptly, then
105− -- it's no big deal as we'll wake up and notice the change
106− -- on the next iteration of the loop. But if are very
107− -- unlucky, then we could end up waiting a long time.
108− Just fd -> do
109− return $ do
110− threadWaitRead fd `catch` (throwIO . setIOErrorLocation)
111− loop
112#else
95#else
113 -- This case fixes the race condition above. By registering
96 -- This case fixes the race condition above. By registering
114 -- our interest in the descriptor before we drop the lock,
97 -- our interest in the descriptor before we drop the lock,
src/Database/PostgreSQL/Simple/Ok.hs−4
@@ -72,10 +72,6 @@ instance MonadPlus Ok where
72 mplus = (<|>)
72 mplus = (<|>)
73
73
74instance Monad Ok where
74instance Monad Ok where
75−#if !(MIN_VERSION_base(4,8,0))
76− return = pure
77−#endif
78−
79 Errors es >>= _ = Errors es
75 Errors es >>= _ = Errors es
80 Ok a >>= f = f a
76 Ok a >>= f = f a
81
77
src/Database/PostgreSQL/Simple/ToField.hs−4
@@ -59,11 +59,7 @@ import qualified Data.Vector as V
59import qualified Database.PostgreSQL.LibPQ as PQ
59import qualified Database.PostgreSQL.LibPQ as PQ
60import Database.PostgreSQL.Simple.Time
60import Database.PostgreSQL.Simple.Time
61import Data.Scientific (Scientific)
61import Data.Scientific (Scientific)
62−#if MIN_VERSION_scientific(0,3,0)
63import Data.Text.Lazy.Builder.Scientific (scientificBuilder)
62import Data.Text.Lazy.Builder.Scientific (scientificBuilder)
64−#else
65−import Data.Scientific (scientificBuilder)
66−#endif
67import Foreign.C.Types (CUInt(..))
63import Foreign.C.Types (CUInt(..))
68
64
69-- | How to render an element when substituting it into a query.
65-- | How to render an element when substituting it into a query.
src/Database/PostgreSQL/Simple/Types.hs−3
@@ -93,9 +93,6 @@ instance Semigroup Query where
93
93
94instance Monoid Query where
94instance Monoid Query where
95 mempty = Query B.empty
95 mempty = Query B.empty
96−#if !(MIN_VERSION_base(4,11,0))
97− mappend = (<>)
98−#endif
99
96
100-- | Wrap a list of values for use in an @IN@ clause. Replaces a
97-- | Wrap a list of values for use in an @IN@ clause. Replaces a
101-- single \"@?@\" character with a parenthesized list of rendered
98-- single \"@?@\" character with a parenthesized list of rendered