postgresql-libpq 0.9.3.1 → 0.9.4.0
raw patch · 2 files changed
+48/−5 lines, 2 filesdep +Win32dep +unixdep ~basePVP ok
version bump matches the API change (PVP)
Dependencies added: Win32, unix
Dependency ranges changed: base
API changes (from Hackage documentation)
+ Database.PostgreSQL.LibPQ: libpqVersion :: IO Int
Files
- postgresql-libpq.cabal +12/−5
- src/Database/PostgreSQL/LibPQ.hsc +36/−0
postgresql-libpq.cabal view
@@ -1,5 +1,5 @@ Name: postgresql-libpq-Version: 0.9.3.1+Version: 0.9.4.0 Synopsis: low-level binding to libpq Description: This is a binding to libpq: the C application@@ -9,7 +9,7 @@ backend server and to receive the results of these queries. -Homepage: http://github.com/lpsmith/postgresql-libpq+Homepage: https://github.com/lpsmith/postgresql-libpq License: BSD3 License-file: LICENSE Author: Grant Monroe, Leon P Smith, Joey Adams@@ -36,6 +36,13 @@ Build-depends: base >= 4 && < 5 , bytestring + if !os(windows)+ Build-depends: unix++ if os(windows)+ Build-depends: Win32++ GHC-Options: -Wall if flag(use-pkg-config) Pkgconfig-depends: libpq@@ -49,9 +56,9 @@ source-repository head type: git- location: http://github.com/lpsmith/postgresql-libpq+ location: https://github.com/lpsmith/postgresql-libpq source-repository this type: git- location: http://github.com/lpsmith/postgresql-libpq- tag: v0.9.3.1+ location: https://github.com/lpsmith/postgresql-libpq+ tag: v0.9.4.0
src/Database/PostgreSQL/LibPQ.hsc view
@@ -78,6 +78,7 @@ , parameterStatus , protocolVersion , serverVersion+ , libpqVersion , errorMessage , socket , backendPID@@ -254,6 +255,14 @@ mask_ = Control.Exception.block #endif +import Control.Exception (try, IOException)++#ifndef mingw32_HOST_OS+import System.Posix.DynamicLinker+#else+import System.Win32.DLL+#endif+ -- $dbconn -- The following functions deal with making a connection to a -- PostgreSQL backend server. An application program can have several@@ -632,6 +641,28 @@ serverVersion connection = fmap fromIntegral $ withConn connection c_PQserverVersion +-- | Return the version of libpq that is being used.+--+-- The result of this function can be used to determine, at+-- run time, if specific functionality is available in the currently+-- loaded version of libpq. The function can be used, for example,+-- to determine which connection options are available for+-- PQconnectdb or if the hex bytea output added in PostgreSQL 9.0 is supported.+--+-- This function appeared in PostgreSQL version 9.1, so+-- it cannot be used to detect required functionality in earlier+-- versions, since linking to it will create a link dependency on version 9.1.+libpqVersion :: IO Int+libpqVersion = do+#ifndef mingw32_HOST_OS+ res <- try (dlsym Default "PQlibVersion") :: IO (Either IOException (FunPtr Int))+#else+ dl <- getModuleHandle $ Just "libpq"+ res <- try (castPtrToFunPtr `fmap` getProcAddress dl "PQlibVersion") :: IO (Either IOException (FunPtr Int))+#endif+ case res of+ Left _ -> error "libpqVersion is not supported for libpq < 9.1"+ Right funPtr -> return $ mkLibpqVersion funPtr -- | Returns the error message most recently generated by an operation -- on the connection.@@ -1916,7 +1947,9 @@ , notifyExtra :: {-# UNPACK #-} !B.ByteString -- ^ notification payload string } deriving Show +#if __GLASGOW_HASKELL__ < 800 #let alignment t = "%lu", (unsigned long)offsetof(struct {char x__; t (y__); }, y__)+#endif instance Storable Notify where sizeOf _ = #{size PGnotify} @@ -2391,6 +2424,9 @@ foreign import ccall unsafe "libpq-fe.h PQserverVersion" c_PQserverVersion :: Ptr PGconn -> IO CInt++foreign import ccall "dynamic"+ mkLibpqVersion :: FunPtr Int -> Int foreign import ccall unsafe "libpq-fe.h PQsocket" c_PQsocket :: Ptr PGconn -> IO CInt