diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 505114c..497bf43 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -51,26 +51,21 @@ jobs: # interruption safety, MVars and STM, so we test the single threaded # runtime, too. # We also vary things like PGHOST to test both TCP and Unix Domain Sockets. - concurrently -g --timings --names pg18,pg17,pg16,pg15,pg14,single-threaded-rts,ghc984,ghc967 \ - 'timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg18-tests.txt nix-build --no-out-link -A testsPg18' \ + concurrently -g --timings --names pg18-ghc9122,pg17,pg16-ghc984-tcp,pg15-single-threaded-rts,pg14-ghc967 \ + 'nix-build --no-out-link --argstr ghc ghc9122 -A hpgsql-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg18-ghc9122-tests.txt nix-build --no-out-link --argstr ghc ghc9122 -A testsPg18' \ 'timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg17-tests.txt nix-build --no-out-link -A testsPg17' \ - 'timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg16-tests.txt nix-build --no-out-link -A testsPg16' \ - 'timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg15-tests.txt nix-build --no-out-link -A testsPg15' \ - 'timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg14-tests.txt nix-build --no-out-link -A testsPg14' \ - 'nix-build --no-out-link --argstr threading "-threaded" -A hpgsql-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg18-single-threaded-rts-tests.txt nix-build --no-out-link --argstr threading "-threaded" -A testsPg18' \ - 'nix-build --no-out-link --argstr ghc ghc984 --argstr PGHOST localhost -A hpgsql-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg18-ghc984-tests.txt nix-build --no-out-link --argstr ghc ghc984 -A testsPg18' \ - 'nix-build --no-out-link --argstr ghc ghc967 -A hpgsql-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg18-ghc967-tests.txt nix-build --no-out-link --argstr ghc ghc967 -A testsPg18' + 'nix-build --no-out-link --argstr ghc ghc984 --argstr PGHOST localhost -A hpgsql-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg16-ghc984-tests.txt nix-build --no-out-link --argstr ghc ghc984 -A testsPg16' \ + 'nix-build --no-out-link --argstr threading "-threaded" -A hpgsql-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg15-single-threaded-rts-tests.txt nix-build --no-out-link --argstr threading "-threaded" -A testsPg15' \ + 'nix-build --no-out-link --argstr ghc ghc967 -A hpgsql-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg14-ghc967-tests.txt nix-build --no-out-link --argstr ghc ghc967 -A testsPg14' - name: Run hpgsql-simple-compat tests run: | - concurrently -g --timings --names pg18,pg17,pg16,pg15,pg14,ghc984,ghc967 \ - 'timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg18-simple-compat-tests.txt nix-build --no-out-link -A hpgsqlSimpleCompatTestsPg18' \ + concurrently -g --timings --names pg18-ghc9122,pg17,pg16-ghc984,pg15,pg14-ghc967 \ + 'nix-build --no-out-link --argstr ghc ghc984 -A hpgsql-simple-compat-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg18-ghc9122-simple-compat-tests.txt nix-build --no-out-link --argstr ghc ghc9122 -A hpgsqlSimpleCompatTestsPg18' \ 'timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg17-simple-compat-tests.txt nix-build --no-out-link -A hpgsqlSimpleCompatTestsPg17' \ - 'timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg16-simple-compat-tests.txt nix-build --no-out-link -A hpgsqlSimpleCompatTestsPg16' \ + 'nix-build --no-out-link --argstr ghc ghc984 -A hpgsql-simple-compat-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg16-ghc984-simple-compat-tests.txt nix-build --no-out-link --argstr ghc ghc984 -A hpgsqlSimpleCompatTestsPg16' \ 'timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg15-simple-compat-tests.txt nix-build --no-out-link -A hpgsqlSimpleCompatTestsPg15' \ - 'timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg14-simple-compat-tests.txt nix-build --no-out-link -A hpgsqlSimpleCompatTestsPg14' \ - 'nix-build --no-out-link --argstr ghc ghc984 -A hpgsql-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg18-ghc984-simple-compat-tests.txt nix-build --no-out-link --argstr ghc ghc984 -A hpgsqlSimpleCompatTestsPg18' \ - 'nix-build --no-out-link --argstr ghc ghc967 -A hpgsql-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg18-ghc967-simple-compat-tests.txt nix-build --no-out-link --argstr ghc ghc967 -A hpgsqlSimpleCompatTestsPg18' + 'nix-build --no-out-link --argstr ghc ghc967 -A hpgsql-simple-compat-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg14-ghc967-simple-compat-tests.txt nix-build --no-out-link --argstr ghc ghc967 -A hpgsqlSimpleCompatTestsPg14' build-aarch64-darwin: runs-on: macos-14 @@ -103,21 +98,11 @@ jobs: run: | # We don't run these concurrently because Nix does not have a sandbox in Macs, so it's # not worth the risk. - timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg18-tests.txt nix-build --no-out-link -A testsPg18 + nix-build --no-out-link --argstr ghc ghc9122 -A hpgsql-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg18-ghc9122-tests.txt nix-build --no-out-link --argstr ghc ghc9122 -A testsPg18 timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg17-tests.txt nix-build --no-out-link -A testsPg17 - timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg16-tests.txt nix-build --no-out-link -A testsPg16 - timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg15-tests.txt nix-build --no-out-link -A testsPg15 - timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg14-tests.txt nix-build --no-out-link -A testsPg14 - - - name: Run tests with different combinations - run: | - # GHC's single and multi-threaded runtimes are different with respect - # to many things, and our library relies on a lot of ThreadId tracking, - # interruption safety, MVars and STM, so we test the single threaded - # runtime, too. - # We also vary things like PGHOST to test both TCP and Unix Domain Sockets. - nix-build --no-out-link --argstr threading "-threaded" -A hpgsql-tests - timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg18-single-threaded-rts-tests.txt nix-build --no-out-link --argstr threading "-threaded" --argstr PGHOST localhost -A testsPg18 + nix-build --no-out-link --argstr ghc ghc984 --argstr PGHOST localhost -A hpgsql-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg16-ghc984-tests.txt nix-build --no-out-link --argstr ghc ghc984 -A testsPg16 + nix-build --no-out-link --argstr threading "-threaded" -A hpgsql-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg15-single-threaded-rts-tests.txt nix-build --no-out-link --argstr threading "-threaded" -A testsPg15 + nix-build --no-out-link --argstr ghc ghc967 -A hpgsql-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg14-ghc967-tests.txt nix-build --no-out-link --argstr ghc ghc967 -A testsPg14 - name: Run hpgsql-simple-compat tests run: | diff --git a/INTERRUPTION-SAFETY.md b/INTERRUPTION-SAFETY.md index 381f4cb..f1f8c10 100644 --- a/INTERRUPTION-SAFETY.md +++ b/INTERRUPTION-SAFETY.md @@ -21,8 +21,8 @@ withTransaction $ With Hpgsql you shouldn't run into such issues, or at least we promise that: - Hpgsql is interruption-safe, so a query can be interrupted by asynchronous exceptions and you should still be able to run new queries on the same connection without any other side-effects. Naturally, it is up to you to determine which queries ran or not to completion, since they might have side-effects*. - Hpgsql will throw either `PostgresError` or `IrrecoverableHpgsqlError`, and: - - If you receive a `IrrecoverableHpgsqlError`, Hpgsql makes no promises about which statements ran to completion and what connection state is, and you should `closeForcefully` the connection without running any other queries. These errors should only be thrown for "obvious" developer mistakes from which usually there would be no way to proceed, anyway. + - If you receive a `IrrecoverableHpgsqlError`, Hpgsql makes no promises about which statements ran to completion and what the connection state is. You should `closeForcefully` the connection without running any other queries. These errors should only be thrown for "obvious" developer mistakes from which usually there would be no way to proceed, anyway. - If you receive a `PostgresError` exception, postgres and Hpgsql's states are synced and you can issue new queries afterwards. - - It is possible Hpgsql throws a different kind of exception. File a bug report if that happens, and if you know it came from Hpgsql, treat it like a `IrrecoverableHpgsqlError`. + - You can file a bug report if Hpgsql throws a different kind of exception, and we'll treat it like a bug. * There are edge cases with different behaviour, but hpgsql will document them or throw an `IrrecoverableHpgsqlError` with informative instructions. diff --git a/README.md b/README.md index 8b0c9ff..1fde719 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ f val = do ## Current status -Hpgsql is in active development, is new and has not been used in Production yet. It currently lacks (at least) many of the authentication methods that libpq provides; for now only cleartext and MD5 password auth are supported, and only unencrypted connections. +Hpgsql is in active development, is new and has not been used in Production yet. It currently lacks many of the authentication methods that libpq provides; for now only cleartext, MD5 and SCRAM-SHA-256 password auth are supported, and only unencrypted connections. That being said, one of my other projects, codd, [has a tests-passing branch using hpgsql-simple-compat](https://github.com/mzabani/codd/pull/227) (the nearly API compatible fork of postgresql-simple described in the next section) with very few modifications. diff --git a/Runfile b/Runfile index 05b3e0d..bcb45a5 100644 --- a/Runfile +++ b/Runfile @@ -31,17 +31,19 @@ ci-tests: hlint . - concurrently -g --timings --names pg18,pg17,pg16,pg15,pg14 \ - 'nix-build --no-out-link -A testsPg18' \ - 'nix-build --no-out-link -A testsPg17' \ - 'nix-build --no-out-link -A testsPg16' \ - 'nix-build --no-out-link -A testsPg15' \ - 'nix-build --no-out-link -A testsPg14' - - # concurrently -g --timings --names single-threaded,ghc984,ghc967 \ - # 'nix-build --no-out-link --argstr threading "-threaded" -A testsPg18' \ - # 'nix-build --no-out-link --argstr ghc ghc984 -A testsPg18' \ - # 'nix-build --no-out-link --argstr ghc ghc967 -A testsPg18' + concurrently -g --timings --names pg18-ghc9122,pg17,pg16-ghc984-tcp,pg15-single-threaded-rts,pg14-ghc967 \ + 'nix-build --no-out-link --argstr ghc ghc9122 -A hpgsql-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg18-ghc9122-tests.txt nix-build --no-out-link --argstr ghc ghc9122 -A testsPg18' \ + 'timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg17-tests.txt nix-build --no-out-link -A testsPg17' \ + 'nix-build --no-out-link --argstr ghc ghc984 --argstr PGHOST localhost -A hpgsql-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg16-ghc984-tests.txt nix-build --no-out-link --argstr ghc ghc984 -A testsPg16' \ + 'nix-build --no-out-link --argstr threading "-threaded" -A hpgsql-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg15-single-threaded-rts-tests.txt nix-build --no-out-link --argstr threading "-threaded" -A testsPg15' \ + 'nix-build --no-out-link --argstr ghc ghc967 -A hpgsql-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg14-ghc967-tests.txt nix-build --no-out-link --argstr ghc ghc967 -A testsPg14' + + concurrently -g --timings --names pg18-ghc9122,pg17,pg16-ghc984,pg15,pg14-ghc967 \ + 'nix-build --no-out-link --argstr ghc ghc984 -A hpgsql-simple-compat-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg18-ghc9122-simple-compat-tests.txt nix-build --no-out-link --argstr ghc ghc9122 -A hpgsqlSimpleCompatTestsPg18' \ + 'timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg17-simple-compat-tests.txt nix-build --no-out-link -A hpgsqlSimpleCompatTestsPg17' \ + 'nix-build --no-out-link --argstr ghc ghc984 -A hpgsql-simple-compat-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg16-ghc984-simple-compat-tests.txt nix-build --no-out-link --argstr ghc ghc984 -A hpgsqlSimpleCompatTestsPg16' \ + 'timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg15-simple-compat-tests.txt nix-build --no-out-link -A hpgsqlSimpleCompatTestsPg15' \ + 'nix-build --no-out-link --argstr ghc ghc967 -A hpgsql-simple-compat-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg14-ghc967-simple-compat-tests.txt nix-build --no-out-link --argstr ghc ghc967 -A hpgsqlSimpleCompatTestsPg14' ## diff --git a/hpgsql-simple-compat/hpgsql-simple-compat.cabal b/hpgsql-simple-compat/hpgsql-simple-compat.cabal index c490b38..9c37e26 100644 --- a/hpgsql-simple-compat/hpgsql-simple-compat.cabal +++ b/hpgsql-simple-compat/hpgsql-simple-compat.cabal @@ -24,6 +24,11 @@ category: Database homepage: https://github.com/mzabani/hpgsql#readme bug-reports: https://github.com/mzabani/hpgsql/issues build-type: Simple +tested-with: + GHC ==9.6.7 + || ==9.8.4 + || ==9.10.3 + || ==9.12.2 source-repository head type: git @@ -84,21 +89,18 @@ library -- GHC bundled libs build-depends: - base >= 4.18 && < 4.21 + base >= 4.18 && < 4.22 , bytestring >= 0.11 && < 0.13 , case-insensitive >= 1.2 && < 1.3 , containers >= 0.6 && < 0.8 - , template-haskell >= 2.20 && < 2.23 + , template-haskell >= 2.20 && < 2.24 , text >= 2.0 && < 2.2 , aeson >= 2.2 && < 2.3 , attoparsec >= 0.14 && < 0.15 - , haskell-src-meta >= 0.8 && < 0.9 , hpgsql >= 0.2 && < 0.3 , hashable >= 1.5 && < 1.6 , mtl >= 2.3 && < 2.4 - , streaming >= 0.2 && < 0.3 , time-compat >= 1.9 && < 1.10 - , transformers >= 0.6 && < 0.7 , Only >= 0.1 && < 0.2 , scientific >= 0.3 && < 0.4 , uuid-types >= 1.0 && < 1.1 diff --git a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Copy.hs b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Copy.hs index 1511e80..ac4681a 100644 --- a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Copy.hs +++ b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Copy.hs @@ -42,7 +42,6 @@ import qualified Data.ByteString.Char8 as B import Data.Int (Int64) import qualified Data.Text as Text import Data.Text.Encoding (decodeUtf8) -import Data.Typeable (Typeable) import Database.PostgreSQL.Simple.HpgsqlUtils (toHpgsqlQuery) import Database.PostgreSQL.Simple.Internal import Database.PostgreSQL.Simple.ToRow (ToRow) @@ -80,7 +79,7 @@ data CopyOutResult | -- | No more rows, and a count of the -- number of rows returned. CopyOutDone {-# UNPACK #-} !Int64 - deriving (Eq, Typeable, Show) + deriving (Eq, Show) -- | Feed some data to a @COPY FROM STDIN@ query. Note that -- the data does not need to represent a single row, or even an diff --git a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Errors.hs b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Errors.hs index 603b1be..3531955 100644 --- a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Errors.hs +++ b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Errors.hs @@ -25,11 +25,8 @@ module Database.PostgreSQL.Simple.Errors where import Control.Exception as E - import Data.Attoparsec.ByteString.Char8 import Data.ByteString (ByteString) -import Data.Typeable - import Database.PostgreSQL.Simple.Internal -- Examples of parsed error messages @@ -55,7 +52,7 @@ data ConstraintViolation CheckViolation ByteString ByteString | -- | Name of the exclusion violation constraint ExclusionViolation ByteString - deriving (Show, Eq, Ord, Typeable) + deriving (Show, Eq, Ord) -- Default instance should be enough instance Exception ConstraintViolation where diff --git a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/FromField.hs b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/FromField.hs index 145c2ff..3a2b83b 100644 --- a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/FromField.hs +++ b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/FromField.hs @@ -157,7 +157,7 @@ data ResultError errHaskellType :: String, errMessage :: String } - deriving (Eq, Show, Typeable) + deriving (Eq, Show) instance Exception ResultError where toException = postgresqlExceptionToException @@ -176,8 +176,8 @@ class FromField a where fromField = let dec = Hpgsql.fieldDecoder in \f -> - if (Hpgsql.allowedPgTypes dec) f - then \mbs -> Conversion $ \_encCtx -> case (Hpgsql.fieldValueDecoder dec) f mbs of + if Hpgsql.allowedPgTypes dec f + then \mbs -> Conversion $ \_encCtx -> case Hpgsql.fieldValueDecoder dec f mbs of Right v -> Ok v Left err -> Errors [toException $ userError err] else \_ -> Conversion $ \_encCtx -> Errors [toException $ userError "Invalid type OID for FromField instance"] diff --git a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/HStore/Implementation.hs b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/HStore/Implementation.hs index 10ee778..422c0c2 100644 --- a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/HStore/Implementation.hs +++ b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/HStore/Implementation.hs @@ -27,7 +27,6 @@ import qualified Data.Text as TS import qualified Data.Text.Encoding as TS import Data.Text.Encoding.Error (UnicodeException) import qualified Data.Text.Lazy as TL -import Data.Typeable class ToHStore a where toHStore :: a -> HStoreBuilder @@ -36,7 +35,6 @@ class ToHStore a where data HStoreBuilder = Empty | Comma !Builder - deriving (Typeable) instance ToHStore HStoreBuilder where toHStore = id @@ -68,7 +66,6 @@ class ToHStoreText a where -- | Represents escape text, ready to be the key or value to a hstore value newtype HStoreText = HStoreText Builder - deriving stock (Typeable) deriving newtype (Semigroup, Monoid) instance ToHStoreText HStoreText where @@ -112,13 +109,13 @@ hstore (toHStoreText -> (HStoreText key)) (toHStoreText -> (HStoreText val)) = `mappend` char8 '"' ) -newtype HStoreList = HStoreList {fromHStoreList :: [(Text, Text)]} deriving (Typeable, Show) +newtype HStoreList = HStoreList {fromHStoreList :: [(Text, Text)]} deriving (Show) -- | hstore instance ToHStore HStoreList where toHStore (HStoreList xs) = mconcat (map (uncurry hstore) xs) -newtype HStoreMap = HStoreMap {fromHStoreMap :: Map Text Text} deriving (Eq, Ord, Typeable, Show) +newtype HStoreMap = HStoreMap {fromHStoreMap :: Map Text Text} deriving (Eq, Ord, Show) instance ToHStore HStoreMap where toHStore (HStoreMap xs) = Map.foldrWithKey f mempty xs diff --git a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Internal.hs b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Internal.hs index 782b019..fb159bc 100644 --- a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Internal.hs +++ b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Internal.hs @@ -49,14 +49,12 @@ data Connection = Connection connectionTempNameCounter :: {-# UNPACK #-} !(IORef Int64), hpgConn :: HPgConnection } - deriving (Typeable) instance Eq Connection where x == y = hpgConn x == hpgConn y -- | Superclass for postgresql exceptions data SomePostgreSqlException = forall e. (Exception e) => SomePostgreSqlException e - deriving (Typeable) postgresqlExceptionToException :: (Exception e) => e -> SomeException postgresqlExceptionToException = toException . SomePostgreSqlException @@ -83,7 +81,7 @@ data SqlError = SqlError -- to help debugging the source of errors. sqlStatement :: ByteString } - deriving (Eq, Show, Typeable) + deriving (Eq, Show) fatalError :: ByteString -> SqlError fatalError msg = SqlError "" FatalError msg "" "" "" @@ -98,7 +96,7 @@ data QueryError = QueryError { qeMessage :: String, qeQuery :: Query } - deriving (Eq, Show, Typeable) + deriving (Eq, Show) instance Exception QueryError where toException = postgresqlExceptionToException @@ -112,7 +110,7 @@ data FormatError = FormatError fmtQuery :: Query, fmtParams :: [ByteString] } - deriving (Eq, Show, Typeable) + deriving (Eq, Show) instance Exception FormatError where toException = postgresqlExceptionToException @@ -125,7 +123,7 @@ data ConnectInfo = ConnectInfo connectPassword :: String, connectDatabase :: String } - deriving (Generic, Eq, Read, Show, Typeable) + deriving (Generic, Eq, Read, Show) -- | Default information for setting up a connection. -- @@ -240,7 +238,7 @@ withConnection Connection {..} m = m $ PQ.Connection hpgConn -- for detailed information regarding libpq and SSL. connectPostgreSQL :: ByteString -> IO Connection connectPostgreSQL connstr = do - connectionObjects <- newMVar (IntMap.empty) + connectionObjects <- newMVar IntMap.empty connectionTempNameCounter <- newIORef 0 case Hpgsql.Connection.parseLibpqConnectionString (TE.decodeUtf8 connstr) of Left err -> error err diff --git a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Ok.hs b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Ok.hs index 6112635..a7fc005 100644 --- a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Ok.hs +++ b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Ok.hs @@ -31,7 +31,6 @@ module Database.PostgreSQL.Simple.Ok where import Control.Applicative import Control.Exception import Control.Monad (MonadPlus (..)) -import Data.Typeable import qualified Control.Monad.Fail as Fail @@ -39,7 +38,7 @@ import qualified Control.Monad.Fail as Fail -- a difference list (or a tree?) data Ok a = Errors [SomeException] | Ok !a - deriving (Show, Typeable, Functor) + deriving (Show, Functor) -- | Two 'Errors' cases are considered equal, regardless of what the -- list of exceptions looks like. @@ -79,6 +78,6 @@ instance Fail.MonadFail Ok where -- | a way to reify a list of exceptions into a single exception newtype ManyErrors = ManyErrors [SomeException] - deriving (Show, Typeable) + deriving (Show) instance Exception ManyErrors diff --git a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Range.hs b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Range.hs index b192619..3400082 100644 --- a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Range.hs +++ b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Range.hs @@ -19,19 +19,17 @@ module Database.PostgreSQL.Simple.Range ) where -import Data.Typeable (Typeable) - -- | Represents boundary of a range data RangeBound a = NegInfinity | Inclusive !a | Exclusive !a | PosInfinity - deriving (Show, Typeable, Eq, Functor) + deriving (Show, Eq, Functor) -- | Generic range type data PGRange a = PGRange !(RangeBound a) !(RangeBound a) - deriving (Show, Typeable, Functor) + deriving (Show, Functor) empty :: PGRange a empty = PGRange PosInfinity NegInfinity diff --git a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/ToField.hs b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/ToField.hs index 35824b9..f591fb3 100644 --- a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/ToField.hs +++ b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/ToField.hs @@ -33,7 +33,6 @@ import qualified Data.Text.Lazy as LT import Data.Time.Calendar.Compat (Day) import Data.Time.Compat (CalendarDiffTime, NominalDiffTime, UTCTime, ZonedTime) import Data.Time.LocalTime.Compat (LocalTime, TimeOfDay) -import Data.Typeable (Typeable) import Data.UUID.Types (UUID) import Data.Vector (Vector) import Hpgsql.Builder (BinaryField (..)) @@ -54,7 +53,6 @@ data Action Many [Action] | -- | Just a static SQL fragment to render Plain LB.ByteString - deriving (Typeable) instance Show Action where show (QueryArgument _) = "QueryArgument" diff --git a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Types.hs b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Types.hs index b21816c..703ed06 100644 --- a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Types.hs +++ b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Types.hs @@ -42,7 +42,6 @@ import Data.Text (Text) import qualified Data.Text as T import Data.Text.Encoding (encodeUtf8) import Data.Tuple.Only (Only (..)) -import Data.Typeable (Typeable) import Database.PostgreSQL.LibPQ (Oid (..)) import Database.PostgreSQL.Simple.Compat (toByteString) import Database.PostgreSQL.Simple.ToField (Action (..), ToField (..)) @@ -53,11 +52,11 @@ import Hpgsql.Types (PGArray (..), (:.) (..)) -- | A placeholder for the SQL @NULL@ value. data Null = Null - deriving (Read, Show, Typeable) + deriving (Read, Show) -- | A placeholder for the PostgreSQL @DEFAULT@ value. data Default = Default - deriving (Read, Show, Typeable) + deriving (Read, Show) -- | A query string. This type is intended to make it difficult to -- construct a SQL query by concatenating string fragments, as that is @@ -81,7 +80,7 @@ data Default = Default newtype Query = Query { fromQuery :: ByteString } - deriving (Eq, Ord, Typeable) + deriving (Eq, Ord) instance Show Query where show = show . fromQuery @@ -145,7 +144,7 @@ instance Monoid Query where -- be null or you want null treated sensibly as a component of @IN@ or -- @NOT IN@. newtype In a = In a - deriving (Eq, Ord, Read, Show, Typeable, Functor) + deriving (Eq, Ord, Read, Show, Functor) instance (ToField a) => ToField (In [a]) where toField (In []) = Plain "(NULL)" @@ -153,7 +152,7 @@ instance (ToField a) => ToField (In [a]) where -- | Wrap binary data for use as a @bytea@ value. newtype Binary a = Binary {fromBinary :: a} - deriving (Eq, Ord, Read, Show, Typeable, Functor) + deriving (Eq, Ord, Read, Show, Functor) instance ToField (Binary ByteString) @@ -165,7 +164,7 @@ instance ToPgField (Binary ByteString) where -- | Wrap text for use as sql identifier, i.e. a table or column name. newtype Identifier = Identifier {fromIdentifier :: Text} - deriving stock (Eq, Ord, Read, Show, Typeable) + deriving stock (Eq, Ord, Read, Show) deriving newtype (IsString) instance ToField Identifier where @@ -177,7 +176,7 @@ instance Hashable Identifier where -- | Wrap text for use as (maybe) qualified identifier, i.e. a table -- with schema, or column with table. data QualifiedIdentifier = QualifiedIdentifier (Maybe Text) Text - deriving (Eq, Ord, Read, Show, Typeable) + deriving (Eq, Ord, Read, Show) instance ToField QualifiedIdentifier where toField (QualifiedIdentifier m n) = case m of @@ -201,7 +200,7 @@ instance IsString QualifiedIdentifier where else QualifiedIdentifier (Just x) (T.tail y) newtype Savepoint = Savepoint Query - deriving (Eq, Ord, Show, Read, Typeable) + deriving (Eq, Ord, Show, Read) -- | Represents a @VALUES@ table literal, usable as an alternative to -- 'Database.PostgreSQL.Simple.executeMany' and @@ -257,7 +256,7 @@ newtype Savepoint = Savepoint Query -- See for -- more information. data Values a = Values [QualifiedIdentifier] [a] - deriving (Eq, Ord, Show, Read, Typeable) + deriving (Eq, Ord, Show, Read) interleaveFoldr :: (a -> [b] -> [b]) -> b -> [b] -> [a] -> [b] interleaveFoldr f b bs' as = foldr (\a bs -> b : f a bs) bs' as diff --git a/hpgsql/hpgsql.cabal b/hpgsql/hpgsql.cabal index 8f162d2..9d0343f 100644 --- a/hpgsql/hpgsql.cabal +++ b/hpgsql/hpgsql.cabal @@ -17,6 +17,7 @@ tested-with: GHC ==9.6.7 || ==9.8.4 || ==9.10.3 + || ==9.12.2 source-repository head type: git @@ -95,7 +96,7 @@ library Only >= 0.1 && < 0.2, aeson >= 2.2 && < 2.3, attoparsec >= 0.14 && < 0.15, - base >= 4.18 && < 4.21, + base >= 4.18 && < 4.22, bytestring >= 0.11 && < 0.13, case-insensitive >= 1.2 && < 1.3, cereal >= 0.5 && < 0.6, @@ -110,9 +111,9 @@ library scientific >= 0.3 && < 0.4, stm >= 2.5 && < 2.6, streaming >= 0.2 && < 0.3, - template-haskell >= 2.20 && < 2.23, + template-haskell >= 2.20 && < 2.24, text >= 2.0 && < 2.2, - time >= 1.12 && < 1.13, + time >= 1.12 && < 1.15, transformers >= 0.6 && < 0.7, uuid-types >= 1.0 && < 1.1, vector >= 0.13 && < 0.14 diff --git a/hpgsql/src/Hpgsql/Encoding.hs b/hpgsql/src/Hpgsql/Encoding.hs index 7c6dbed..3636db3 100644 --- a/hpgsql/src/Hpgsql/Encoding.hs +++ b/hpgsql/src/Hpgsql/Encoding.hs @@ -397,7 +397,7 @@ instance ToPgField Scientific where calculateDigits :: Int16 -> Int16 -> Integer -> BS.ByteString -> (Int16, Int16, BS.ByteString) calculateDigits !ndigitsSoFar !weightSoFar 0 !encodedDigits = (ndigitsSoFar, weightSoFar, encodedDigits) calculateDigits !ndigitsSoFar !weightSoFar !val !encodedDigits = - let (quotient, fromIntegral -> rest :: Int16) = val `divMod` 10000 + let (quotient, fromIntegral -> (rest :: Int16)) = val `divMod` 10000 in calculateDigits (ndigitsSoFar + 1) (weightSoFar + 1) diff --git a/hpgsql/src/Hpgsql/Types.hs b/hpgsql/src/Hpgsql/Types.hs index e38f53b..21fb011 100644 --- a/hpgsql/src/Hpgsql/Types.hs +++ b/hpgsql/src/Hpgsql/Types.hs @@ -17,7 +17,7 @@ import qualified Data.ByteString as BS import qualified Data.ByteString.Builder as Builder import qualified Data.ByteString.Lazy as LBS import Data.Tuple.Only (Only (..)) -import Data.Typeable (Proxy (..), Typeable) +import Data.Typeable (Proxy (..)) import Hpgsql.Builder (BinaryField (..)) import Hpgsql.Encoding (FieldDecoder (..), FieldEncoder (..), FieldInfo (..), FromPgField (..), FromPgRow (..), RowEncoder (..), ToPgField (..), ToPgRow (..), arrayField, toPgVectorField) import Hpgsql.TypeInfo (EncodingContext (..), TypeInfo (..), jsonOid, jsonbOid, lookupTypeByOid) @@ -101,7 +101,8 @@ instance FromPgField PgJson where -- into your type (from either json or jsonb), and to encode -- to jsonb. newtype Aeson a = Aeson {getAeson :: a} - deriving (Eq, Show, Read, Typeable, Functor) + deriving stock (Functor, Read, Show) + deriving newtype (Eq) instance (FromJSON a) => FromPgField (Aeson a) where fieldDecoder =