diff --git a/CHANGELOG.md b/CHANGELOG.md
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+# hpqtypes-extras-1.16.3.1 (2023-04-13)
+* Add support for GHC 9.6.
+* Fix checkAndRememberMaterializationSupport's query.
+
 # hpqtypes-extras-1.16.3.0 (2023-01-25)
 * Add support for `WITH MATERIALIZED` with backward compatibility.
 * Add `sqlWhereEqualsAny`.
@@ -37,7 +41,7 @@
 # hpqtypes-extras-1.12.0.1 (2021-10-11)
 * Add support for log-base-0.11.0.0
 
-# hpqtypes-extras-1.12.0.0 (2021-10-??)
+# hpqtypes-extras-1.12.0.0 (2021-09-29)
 * Use plain exceptions instead of DBExtraException
 
 # hpqtypes-extras-1.11.0.0 (2021-03-29)
diff --git a/hpqtypes-extras.cabal b/hpqtypes-extras.cabal
--- a/hpqtypes-extras.cabal
+++ b/hpqtypes-extras.cabal
@@ -1,6 +1,6 @@
 cabal-version:       2.2
 name:                hpqtypes-extras
-version:             1.16.3.0
+version:             1.16.3.1
 synopsis:            Extra utilities for hpqtypes library
 description:         The following extras for hpqtypes library:
                      .
@@ -20,7 +20,7 @@
 copyright:           Scrive AB
 category:            Database
 build-type:          Simple
-tested-with:         GHC ==8.8.4 || ==8.10.7 || ==9.0.2 || ==9.2.4 || ==9.4.2
+tested-with:         GHC ==8.8.4 || ==8.10.7 || ==9.0.2 || ==9.2.7 || ==9.4.4 || ==9.6.1
 
 Source-repository head
   Type:     git
diff --git a/src/Database/PostgreSQL/PQTypes/Checks.hs b/src/Database/PostgreSQL/PQTypes/Checks.hs
--- a/src/Database/PostgreSQL/PQTypes/Checks.hs
+++ b/src/Database/PostgreSQL/PQTypes/Checks.hs
@@ -15,10 +15,11 @@
 
 import Control.Arrow ((&&&))
 import Control.Concurrent (threadDelay)
+import Control.Monad
 import Control.Monad.Catch
 import Control.Monad.Reader
 import Data.Int
-import Data.Function (on)
+import Data.Function
 import Data.List (partition)
 import Data.Maybe
 import Data.Monoid.Utils
diff --git a/src/Database/PostgreSQL/PQTypes/Deriving.hs b/src/Database/PostgreSQL/PQTypes/Deriving.hs
--- a/src/Database/PostgreSQL/PQTypes/Deriving.hs
+++ b/src/Database/PostgreSQL/PQTypes/Deriving.hs
@@ -15,6 +15,7 @@
 import Data.Text (Text)
 import Data.Typeable
 import Database.PostgreSQL.PQTypes
+import Foreign.Storable
 import qualified Data.Map.Strict as Map
 
 -- | Helper newtype to be used with @deriving via@ to derive @(PQFormat, ToSQL,
@@ -93,6 +94,7 @@
 
 instance
   ( EnumEncoding a
+  , Storable (PQBase (EnumBase a))
   , PQFormat (EnumBase a)
   , FromSQL (EnumBase a)
   , Show (EnumBase a)
diff --git a/src/Database/PostgreSQL/PQTypes/Model/Migration.hs b/src/Database/PostgreSQL/PQTypes/Model/Migration.hs
--- a/src/Database/PostgreSQL/PQTypes/Model/Migration.hs
+++ b/src/Database/PostgreSQL/PQTypes/Model/Migration.hs
@@ -64,13 +64,13 @@
   -- Name of the table that the cursor is associated with. It has to be the same as in the
   -- cursor SQL, see the second parameter.
   --
-  -- SQL that will be used for the cursor.
+  -- SQL providing a list of primary keys from the associated table that will be used for the cursor.
   --
-  -- Function that takes a list of primary keys provided by the cursor SQL and
-  -- runs an arbitrary computation within MonadDB. The function might be called
-  -- repeatedly depending on the number of primary keys. See the last argument.
+  -- Function that takes a batch of primary keys provided by the cursor SQL and runs an arbitrary computation
+  -- within MonadDB. The function might be called repeatedly depending on the batch size and total number of
+  -- selected primary keys. See the last argument.
   --
-  -- Number of primary keys fetched at once by the cursor SQL.
+  -- Batch size of primary keys to be fetched at once by the cursor SQL and be given to the modification function.
   -- To handle multi-column primary keys, the following needs to be done:
   --
   --   1. Get the list of tuples from PostgreSQL.
diff --git a/src/Database/PostgreSQL/PQTypes/SQL/Builder.hs b/src/Database/PostgreSQL/PQTypes/SQL/Builder.hs
--- a/src/Database/PostgreSQL/PQTypes/SQL/Builder.hs
+++ b/src/Database/PostgreSQL/PQTypes/SQL/Builder.hs
@@ -423,7 +423,7 @@
 checkAndRememberMaterializationSupport :: (MonadDB m, MonadIO m, MonadMask m) => m ()
 checkAndRememberMaterializationSupport = do
   res :: Either DBException Int64 <- try . withNewConnection $ do
-    runSQL01_ $ "WITH t(n) AS MATERIALIZED (SELECT 1) SELECT n FROM t LIMIT 1"
+    runSQL01_ $ "WITH t(n) AS MATERIALIZED (SELECT (1 :: bigint)) SELECT n FROM t LIMIT 1"
     fetchOne runIdentity
   liftIO $ writeIORef withMaterializedSupported (isRight res)
 
