@@ -242,12 +242,12 @@ import qualified Data.ByteString as B
242242
243243import Control.Concurrent.MVar
244244
245- import Data.Typeable
246-
247245import Database.PostgreSQL.LibPQ.Compat
248246import Database.PostgreSQL.LibPQ.Enums
249247import Database.PostgreSQL.LibPQ.Internal
250248import Database.PostgreSQL.LibPQ.Marshal
249+ import Database.PostgreSQL.LibPQ.Notify
250+ import Database.PostgreSQL.LibPQ.Oid
251251
252252#if __GLASGOW_HASKELL__ >= 700
253253import Control.Exception (mask_ )
@@ -699,12 +699,6 @@ connectionUsedPassword connection =
699699newtype Result = Result (ForeignPtr PGresult ) deriving (Eq , Show )
700700data PGresult
701701
702-
703- newtype Oid = Oid CUInt deriving (Eq , Ord , Read , Show , Storable , Typeable )
704-
705- invalidOid :: Oid
706- invalidOid = Oid (# const InvalidOid )
707-
708702-- | Convert a list of parameters to the format expected by libpq FFI calls.
709703withParams :: [Maybe (Oid , B. ByteString , Format )]
710704 -> (CInt -> Ptr Oid -> Ptr CString -> Ptr CInt -> Ptr CInt -> IO a )
@@ -1739,35 +1733,7 @@ cancel (Cancel fp) =
17391733-- ordinary SQL commands. The arrival of NOTIFY messages can
17401734-- subsequently be detected by calling 'notifies'.
17411735
1742- data Notify = Notify {
1743- notifyRelname :: {-# UNPACK #-} ! B. ByteString -- ^ notification channel name
1744- , notifyBePid :: {-# UNPACK #-} ! CPid -- ^ process ID of notifying server process
1745- , notifyExtra :: {-# UNPACK #-} ! B. ByteString -- ^ notification payload string
1746- } deriving Show
17471736
1748- #if __GLASGOW_HASKELL__ < 800
1749- #let alignment t = "%lu", (unsigned long)offsetof(struct {char x__; t (y__); }, y__)
1750- #endif
1751- instance Storable Notify where
1752- sizeOf _ = # {size PGnotify }
1753-
1754- alignment _ = # {alignment PGnotify }
1755-
1756- peek ptr = do
1757- relname <- B. packCString =<< # {peek PGnotify , relname} ptr
1758- extra <- B. packCString =<< # {peek PGnotify , extra} ptr
1759- be_pid <- fmap f $ # {peek PGnotify , be_pid} ptr
1760- return $! Notify relname be_pid extra
1761- where
1762- f :: CInt -> CPid
1763- f = fromIntegral
1764-
1765- poke ptr (Notify a b c) =
1766- B. useAsCString a $ \ a' ->
1767- B. useAsCString c $ \ c' ->
1768- do # {poke PGnotify , relname} ptr a'
1769- # {poke PGnotify , be_pid} ptr (fromIntegral b :: CInt )
1770- # {poke PGnotify , extra} ptr c'
17711737
17721738
17731739-- | Returns the next notification from a list of unhandled
@@ -1915,8 +1881,6 @@ maybeBsFromForeignPtr fp f =
19151881
19161882type NoticeReceiver = NoticeBuffer -> Ptr PGresult -> IO ()
19171883
1918- data PGnotice
1919-
19201884-- | Upon connection initialization, any notices received from the server are
19211885-- normally written to the console. Notices are akin to warnings, and
19221886-- are distinct from notifications. This function suppresses notices.
@@ -1954,8 +1918,8 @@ getNotice (Conn _ nbRef) =
19541918 then return Nothing
19551919 else do
19561920 fp <- newForeignPtr finalizerFree (castPtr np)
1957- len <- # {peek PGnotice , len} np
1958- return $! Just $! mkPS fp ( # offset PGnotice , str) len
1921+ len <- pgNoticePeekLen np
1922+ return $! Just $! mkPS fp pgNoticeOffsetStr ( fromIntegral len)
19591923
19601924-- $largeobjects
19611925
0 commit comments