git.iko.soy/typeable/postgresql-simple
on master help sign in
Add getBackendPID
8210396Leon P Smith
src/Database/PostgreSQL/Simple/Notification.hs+12
@@ -32,6 +32,7 @@ module Database.PostgreSQL.Simple.Notification
32 ( Notification(..)
32 ( Notification(..)
33 , getNotification
33 , getNotification
34 , getNotificationNonBlocking
34 , getNotificationNonBlocking
35+ , getBackendPID
35 ) where
36 ) where
36
37
37import Control.Concurrent
38import Control.Concurrent
@@ -101,3 +102,14 @@ getNotificationNonBlocking conn =
101 case mmsg' of
102 case mmsg' of
102 Just msg -> return $! Just $! convertNotice msg
103 Just msg -> return $! Just $! convertNotice msg
103 Nothing -> return Nothing
104 Nothing -> return Nothing
105+
106+-- | Returns the process 'CPid' of the backend server process
107+-- handling this connection.
108+--
109+-- The backend PID is useful for debugging purposes and for comparison
110+-- to NOTIFY messages (which include the PID of the notifying backend
111+-- process). Note that the PID belongs to a process executing on the
112+-- database server host, not the local host!
113+
114+getBackendPID :: Connection -> IO CPid
115+getBackendPID conn = withConnection conn PQ.backendPID