module Pqi.Conformance.Reference
( adapter,
)
where
import qualified Database.PostgreSQL.LibPQ as LibPQ
import qualified Pqi
import Pqi.Conformance.Prelude
adapter :: Pqi.Adapter
adapter :: Adapter
adapter =
Pqi.Adapter
{ name :: Text
Pqi.name = Text
"postgresql-libpq (reference)",
connectdb :: ByteString -> IO Connection
Pqi.connectdb = \ByteString
conninfo -> Connection -> Connection
mkConnection (Connection -> Connection) -> IO Connection -> IO Connection
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> IO Connection
LibPQ.connectdb ByteString
conninfo,
connectStart :: ByteString -> IO Connection
Pqi.connectStart = \ByteString
conninfo -> Connection -> Connection
mkConnection (Connection -> Connection) -> IO Connection -> IO Connection
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> IO Connection
LibPQ.connectStart ByteString
conninfo,
newNullConnection :: IO Connection
Pqi.newNullConnection = Connection -> Connection
mkConnection (Connection -> Connection) -> IO Connection -> IO Connection
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> IO Connection
LibPQ.newNullConnection,
unescapeBytea :: ByteString -> IO (Maybe ByteString)
Pqi.unescapeBytea = \ByteString
input -> ByteString -> IO (Maybe ByteString)
LibPQ.unescapeBytea ByteString
input
}
mkConnection :: LibPQ.Connection -> Pqi.Connection
mkConnection :: Connection -> Connection
mkConnection Connection
c =
Pqi.Connection
{ connectPoll :: IO PollingStatus
Pqi.connectPoll = PollingStatus -> PollingStatus
fromPollingStatus (PollingStatus -> PollingStatus)
-> IO PollingStatus -> IO PollingStatus
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Connection -> IO PollingStatus
LibPQ.connectPoll Connection
c,
isNullConnection :: Bool
Pqi.isNullConnection = Connection -> Bool
LibPQ.isNullConnection Connection
c,
finish :: IO ()
Pqi.finish = Connection -> IO ()
LibPQ.finish Connection
c,
reset :: IO ()
Pqi.reset = Connection -> IO ()
LibPQ.reset Connection
c,
resetStart :: IO Bool
Pqi.resetStart = Connection -> IO Bool
LibPQ.resetStart Connection
c,
resetPoll :: IO PollingStatus
Pqi.resetPoll = PollingStatus -> PollingStatus
fromPollingStatus (PollingStatus -> PollingStatus)
-> IO PollingStatus -> IO PollingStatus
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Connection -> IO PollingStatus
LibPQ.resetPoll Connection
c,
db :: IO (Maybe ByteString)
Pqi.db = Connection -> IO (Maybe ByteString)
LibPQ.db Connection
c,
user :: IO (Maybe ByteString)
Pqi.user = Connection -> IO (Maybe ByteString)
LibPQ.user Connection
c,
pass :: IO (Maybe ByteString)
Pqi.pass = Connection -> IO (Maybe ByteString)
LibPQ.pass Connection
c,
host :: IO (Maybe ByteString)
Pqi.host = Connection -> IO (Maybe ByteString)
LibPQ.host Connection
c,
port :: IO (Maybe ByteString)
Pqi.port = Connection -> IO (Maybe ByteString)
LibPQ.port Connection
c,
options :: IO (Maybe ByteString)
Pqi.options = Connection -> IO (Maybe ByteString)
LibPQ.options Connection
c,
status :: IO ConnStatus
Pqi.status = ConnStatus -> ConnStatus
fromConnStatus (ConnStatus -> ConnStatus) -> IO ConnStatus -> IO ConnStatus
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Connection -> IO ConnStatus
LibPQ.status Connection
c,
transactionStatus :: IO TransactionStatus
Pqi.transactionStatus = TransactionStatus -> TransactionStatus
fromTransactionStatus (TransactionStatus -> TransactionStatus)
-> IO TransactionStatus -> IO TransactionStatus
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Connection -> IO TransactionStatus
LibPQ.transactionStatus Connection
c,
parameterStatus :: ByteString -> IO (Maybe ByteString)
Pqi.parameterStatus = \ByteString
name -> Connection -> ByteString -> IO (Maybe ByteString)
LibPQ.parameterStatus Connection
c ByteString
name,
protocolVersion :: IO Int
Pqi.protocolVersion = Connection -> IO Int
LibPQ.protocolVersion Connection
c,
serverVersion :: IO Int
Pqi.serverVersion = Connection -> IO Int
LibPQ.serverVersion Connection
c,
errorMessage :: IO (Maybe ByteString)
Pqi.errorMessage = Connection -> IO (Maybe ByteString)
LibPQ.errorMessage Connection
c,
socket :: IO (Maybe Fd)
Pqi.socket = Connection -> IO (Maybe Fd)
LibPQ.socket Connection
c,
backendPID :: IO Int32
Pqi.backendPID = CPid -> Int32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (CPid -> Int32) -> IO CPid -> IO Int32
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Connection -> IO CPid
LibPQ.backendPID Connection
c,
connectionNeedsPassword :: IO Bool
Pqi.connectionNeedsPassword = Connection -> IO Bool
LibPQ.connectionNeedsPassword Connection
c,
connectionUsedPassword :: IO Bool
Pqi.connectionUsedPassword = Connection -> IO Bool
LibPQ.connectionUsedPassword Connection
c,
exec :: ByteString -> IO (Maybe Result)
Pqi.exec = \ByteString
sql -> (Result -> Result) -> Maybe Result -> Maybe Result
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Result -> Result
mkResult (Maybe Result -> Maybe Result)
-> IO (Maybe Result) -> IO (Maybe Result)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Connection -> ByteString -> IO (Maybe Result)
LibPQ.exec Connection
c ByteString
sql,
execParams :: ByteString
-> [Maybe (Word32, ByteString, Format)]
-> Format
-> IO (Maybe Result)
Pqi.execParams = \ByteString
sql [Maybe (Word32, ByteString, Format)]
params Format
resultFormat ->
(Result -> Result) -> Maybe Result -> Maybe Result
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Result -> Result
mkResult (Maybe Result -> Maybe Result)
-> IO (Maybe Result) -> IO (Maybe Result)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Connection
-> ByteString
-> [Maybe (Oid, ByteString, Format)]
-> Format
-> IO (Maybe Result)
LibPQ.execParams Connection
c ByteString
sql ((Maybe (Word32, ByteString, Format)
-> Maybe (Oid, ByteString, Format))
-> [Maybe (Word32, ByteString, Format)]
-> [Maybe (Oid, ByteString, Format)]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (((Word32, ByteString, Format) -> (Oid, ByteString, Format))
-> Maybe (Word32, ByteString, Format)
-> Maybe (Oid, ByteString, Format)
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Word32, ByteString, Format) -> (Oid, ByteString, Format)
toParam) [Maybe (Word32, ByteString, Format)]
params) (Format -> Format
toFormat Format
resultFormat),
prepare :: ByteString -> ByteString -> Maybe [Word32] -> IO (Maybe Result)
Pqi.prepare = \ByteString
name ByteString
sql Maybe [Word32]
paramTypes ->
(Result -> Result) -> Maybe Result -> Maybe Result
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Result -> Result
mkResult (Maybe Result -> Maybe Result)
-> IO (Maybe Result) -> IO (Maybe Result)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Connection
-> ByteString -> ByteString -> Maybe [Oid] -> IO (Maybe Result)
LibPQ.prepare Connection
c ByteString
name ByteString
sql (([Word32] -> [Oid]) -> Maybe [Word32] -> Maybe [Oid]
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Word32 -> Oid) -> [Word32] -> [Oid]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Word32 -> Oid
toOid) Maybe [Word32]
paramTypes),
execPrepared :: ByteString
-> [Maybe (ByteString, Format)] -> Format -> IO (Maybe Result)
Pqi.execPrepared = \ByteString
name [Maybe (ByteString, Format)]
params Format
resultFormat ->
(Result -> Result) -> Maybe Result -> Maybe Result
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Result -> Result
mkResult (Maybe Result -> Maybe Result)
-> IO (Maybe Result) -> IO (Maybe Result)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Connection
-> ByteString
-> [Maybe (ByteString, Format)]
-> Format
-> IO (Maybe Result)
LibPQ.execPrepared Connection
c ByteString
name ((Maybe (ByteString, Format) -> Maybe (ByteString, Format))
-> [Maybe (ByteString, Format)] -> [Maybe (ByteString, Format)]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (((ByteString, Format) -> (ByteString, Format))
-> Maybe (ByteString, Format) -> Maybe (ByteString, Format)
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (ByteString, Format) -> (ByteString, Format)
toBoundParam) [Maybe (ByteString, Format)]
params) (Format -> Format
toFormat Format
resultFormat),
describePrepared :: ByteString -> IO (Maybe Result)
Pqi.describePrepared = \ByteString
name -> (Result -> Result) -> Maybe Result -> Maybe Result
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Result -> Result
mkResult (Maybe Result -> Maybe Result)
-> IO (Maybe Result) -> IO (Maybe Result)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Connection -> ByteString -> IO (Maybe Result)
LibPQ.describePrepared Connection
c ByteString
name,
describePortal :: ByteString -> IO (Maybe Result)
Pqi.describePortal = \ByteString
name -> (Result -> Result) -> Maybe Result -> Maybe Result
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Result -> Result
mkResult (Maybe Result -> Maybe Result)
-> IO (Maybe Result) -> IO (Maybe Result)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Connection -> ByteString -> IO (Maybe Result)
LibPQ.describePortal Connection
c ByteString
name,
escapeStringConn :: ByteString -> IO (Maybe ByteString)
Pqi.escapeStringConn = \ByteString
s -> Connection -> ByteString -> IO (Maybe ByteString)
LibPQ.escapeStringConn Connection
c ByteString
s,
escapeByteaConn :: ByteString -> IO (Maybe ByteString)
Pqi.escapeByteaConn = \ByteString
s -> Connection -> ByteString -> IO (Maybe ByteString)
LibPQ.escapeByteaConn Connection
c ByteString
s,
escapeIdentifier :: ByteString -> IO (Maybe ByteString)
Pqi.escapeIdentifier = \ByteString
s -> Connection -> ByteString -> IO (Maybe ByteString)
LibPQ.escapeIdentifier Connection
c ByteString
s,
sendQuery :: ByteString -> IO Bool
Pqi.sendQuery = \ByteString
sql -> Connection -> ByteString -> IO Bool
LibPQ.sendQuery Connection
c ByteString
sql,
sendQueryParams :: ByteString
-> [Maybe (Word32, ByteString, Format)] -> Format -> IO Bool
Pqi.sendQueryParams = \ByteString
sql [Maybe (Word32, ByteString, Format)]
params Format
resultFormat ->
Connection
-> ByteString
-> [Maybe (Oid, ByteString, Format)]
-> Format
-> IO Bool
LibPQ.sendQueryParams Connection
c ByteString
sql ((Maybe (Word32, ByteString, Format)
-> Maybe (Oid, ByteString, Format))
-> [Maybe (Word32, ByteString, Format)]
-> [Maybe (Oid, ByteString, Format)]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (((Word32, ByteString, Format) -> (Oid, ByteString, Format))
-> Maybe (Word32, ByteString, Format)
-> Maybe (Oid, ByteString, Format)
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Word32, ByteString, Format) -> (Oid, ByteString, Format)
toParam) [Maybe (Word32, ByteString, Format)]
params) (Format -> Format
toFormat Format
resultFormat),
sendPrepare :: ByteString -> ByteString -> Maybe [Word32] -> IO Bool
Pqi.sendPrepare = \ByteString
name ByteString
sql Maybe [Word32]
paramTypes ->
Connection -> ByteString -> ByteString -> Maybe [Oid] -> IO Bool
LibPQ.sendPrepare Connection
c ByteString
name ByteString
sql (([Word32] -> [Oid]) -> Maybe [Word32] -> Maybe [Oid]
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Word32 -> Oid) -> [Word32] -> [Oid]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Word32 -> Oid
toOid) Maybe [Word32]
paramTypes),
sendQueryPrepared :: ByteString -> [Maybe (ByteString, Format)] -> Format -> IO Bool
Pqi.sendQueryPrepared = \ByteString
name [Maybe (ByteString, Format)]
params Format
resultFormat ->
Connection
-> ByteString -> [Maybe (ByteString, Format)] -> Format -> IO Bool
LibPQ.sendQueryPrepared Connection
c ByteString
name ((Maybe (ByteString, Format) -> Maybe (ByteString, Format))
-> [Maybe (ByteString, Format)] -> [Maybe (ByteString, Format)]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (((ByteString, Format) -> (ByteString, Format))
-> Maybe (ByteString, Format) -> Maybe (ByteString, Format)
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (ByteString, Format) -> (ByteString, Format)
toBoundParam) [Maybe (ByteString, Format)]
params) (Format -> Format
toFormat Format
resultFormat),
sendDescribePrepared :: ByteString -> IO Bool
Pqi.sendDescribePrepared = \ByteString
name -> Connection -> ByteString -> IO Bool
LibPQ.sendDescribePrepared Connection
c ByteString
name,
sendDescribePortal :: ByteString -> IO Bool
Pqi.sendDescribePortal = \ByteString
name -> Connection -> ByteString -> IO Bool
LibPQ.sendDescribePortal Connection
c ByteString
name,
getResult :: IO (Maybe Result)
Pqi.getResult = (Result -> Result) -> Maybe Result -> Maybe Result
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Result -> Result
mkResult (Maybe Result -> Maybe Result)
-> IO (Maybe Result) -> IO (Maybe Result)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Connection -> IO (Maybe Result)
LibPQ.getResult Connection
c,
consumeInput :: IO Bool
Pqi.consumeInput = Connection -> IO Bool
LibPQ.consumeInput Connection
c,
isBusy :: IO Bool
Pqi.isBusy = Connection -> IO Bool
LibPQ.isBusy Connection
c,
setnonblocking :: Bool -> IO Bool
Pqi.setnonblocking = \Bool
nonBlocking -> Connection -> Bool -> IO Bool
LibPQ.setnonblocking Connection
c Bool
nonBlocking,
isnonblocking :: IO Bool
Pqi.isnonblocking = Connection -> IO Bool
LibPQ.isnonblocking Connection
c,
setSingleRowMode :: IO Bool
Pqi.setSingleRowMode = Connection -> IO Bool
LibPQ.setSingleRowMode Connection
c,
flush :: IO FlushStatus
Pqi.flush = FlushStatus -> FlushStatus
fromFlushStatus (FlushStatus -> FlushStatus) -> IO FlushStatus -> IO FlushStatus
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Connection -> IO FlushStatus
LibPQ.flush Connection
c,
pipelineStatus :: IO PipelineStatus
Pqi.pipelineStatus = PipelineStatus -> PipelineStatus
fromPipelineStatus (PipelineStatus -> PipelineStatus)
-> IO PipelineStatus -> IO PipelineStatus
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Connection -> IO PipelineStatus
LibPQ.pipelineStatus Connection
c,
enterPipelineMode :: IO Bool
Pqi.enterPipelineMode = Connection -> IO Bool
LibPQ.enterPipelineMode Connection
c,
exitPipelineMode :: IO Bool
Pqi.exitPipelineMode = Connection -> IO Bool
LibPQ.exitPipelineMode Connection
c,
pipelineSync :: IO Bool
Pqi.pipelineSync = Connection -> IO Bool
LibPQ.pipelineSync Connection
c,
sendFlushRequest :: IO Bool
Pqi.sendFlushRequest = Connection -> IO Bool
LibPQ.sendFlushRequest Connection
c,
getCancel :: IO (Maybe Cancel)
Pqi.getCancel = (Cancel -> Cancel) -> Maybe Cancel -> Maybe Cancel
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Cancel -> Cancel
mkCancel (Maybe Cancel -> Maybe Cancel)
-> IO (Maybe Cancel) -> IO (Maybe Cancel)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Connection -> IO (Maybe Cancel)
LibPQ.getCancel Connection
c,
notifies :: IO (Maybe Notify)
Pqi.notifies = (Notify -> Notify) -> Maybe Notify -> Maybe Notify
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Notify -> Notify
fromNotify (Maybe Notify -> Maybe Notify)
-> IO (Maybe Notify) -> IO (Maybe Notify)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Connection -> IO (Maybe Notify)
LibPQ.notifies Connection
c,
disableNoticeReporting :: IO ()
Pqi.disableNoticeReporting = Connection -> IO ()
LibPQ.disableNoticeReporting Connection
c,
enableNoticeReporting :: IO ()
Pqi.enableNoticeReporting = Connection -> IO ()
LibPQ.enableNoticeReporting Connection
c,
getNotice :: IO (Maybe ByteString)
Pqi.getNotice = Connection -> IO (Maybe ByteString)
LibPQ.getNotice Connection
c,
putCopyData :: ByteString -> IO CopyInResult
Pqi.putCopyData = \ByteString
value -> CopyInResult -> CopyInResult
fromCopyInResult (CopyInResult -> CopyInResult)
-> IO CopyInResult -> IO CopyInResult
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Connection -> ByteString -> IO CopyInResult
LibPQ.putCopyData Connection
c ByteString
value,
putCopyEnd :: Maybe ByteString -> IO CopyInResult
Pqi.putCopyEnd = \Maybe ByteString
reason -> CopyInResult -> CopyInResult
fromCopyInResult (CopyInResult -> CopyInResult)
-> IO CopyInResult -> IO CopyInResult
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Connection -> Maybe ByteString -> IO CopyInResult
LibPQ.putCopyEnd Connection
c Maybe ByteString
reason,
getCopyData :: Bool -> IO CopyOutResult
Pqi.getCopyData = \Bool
nonBlocking -> CopyOutResult -> CopyOutResult
fromCopyOutResult (CopyOutResult -> CopyOutResult)
-> IO CopyOutResult -> IO CopyOutResult
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Connection -> Bool -> IO CopyOutResult
LibPQ.getCopyData Connection
c Bool
nonBlocking,
loCreat :: IO (Maybe Word32)
Pqi.loCreat = (Oid -> Word32) -> Maybe Oid -> Maybe Word32
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Oid -> Word32
fromOid (Maybe Oid -> Maybe Word32) -> IO (Maybe Oid) -> IO (Maybe Word32)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Connection -> IO (Maybe Oid)
LibPQ.loCreat Connection
c,
loCreate :: Word32 -> IO (Maybe Word32)
Pqi.loCreate = \Word32
oid -> (Oid -> Word32) -> Maybe Oid -> Maybe Word32
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Oid -> Word32
fromOid (Maybe Oid -> Maybe Word32) -> IO (Maybe Oid) -> IO (Maybe Word32)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Connection -> Oid -> IO (Maybe Oid)
LibPQ.loCreate Connection
c (Word32 -> Oid
toOid Word32
oid),
loImport :: String -> IO (Maybe Word32)
Pqi.loImport = \String
path -> (Oid -> Word32) -> Maybe Oid -> Maybe Word32
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Oid -> Word32
fromOid (Maybe Oid -> Maybe Word32) -> IO (Maybe Oid) -> IO (Maybe Word32)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Connection -> String -> IO (Maybe Oid)
LibPQ.loImport Connection
c String
path,
loImportWithOid :: String -> Word32 -> IO (Maybe Word32)
Pqi.loImportWithOid = \String
path Word32
oid -> (Oid -> Word32) -> Maybe Oid -> Maybe Word32
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Oid -> Word32
fromOid (Maybe Oid -> Maybe Word32) -> IO (Maybe Oid) -> IO (Maybe Word32)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Connection -> String -> Oid -> IO (Maybe Oid)
LibPQ.loImportWithOid Connection
c String
path (Word32 -> Oid
toOid Word32
oid),
loExport :: Word32 -> String -> IO (Maybe ())
Pqi.loExport = \Word32
oid String
path -> Connection -> Oid -> String -> IO (Maybe ())
LibPQ.loExport Connection
c (Word32 -> Oid
toOid Word32
oid) String
path,
loOpen :: Word32 -> IOMode -> IO (Maybe Int32)
Pqi.loOpen = \Word32
oid IOMode
mode -> (LoFd -> Int32) -> Maybe LoFd -> Maybe Int32
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap LoFd -> Int32
fromLibPQLoFd (Maybe LoFd -> Maybe Int32) -> IO (Maybe LoFd) -> IO (Maybe Int32)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Connection -> Oid -> IOMode -> IO (Maybe LoFd)
LibPQ.loOpen Connection
c (Word32 -> Oid
toOid Word32
oid) IOMode
mode,
loWrite :: Int32 -> ByteString -> IO (Maybe Int)
Pqi.loWrite = \Int32
fd ByteString
value -> Connection -> LoFd -> ByteString -> IO (Maybe Int)
LibPQ.loWrite Connection
c (Int32 -> LoFd
toLibPQLoFd Int32
fd) ByteString
value,
loRead :: Int32 -> Int -> IO (Maybe ByteString)
Pqi.loRead = \Int32
fd Int
len -> Connection -> LoFd -> Int -> IO (Maybe ByteString)
LibPQ.loRead Connection
c (Int32 -> LoFd
toLibPQLoFd Int32
fd) Int
len,
loSeek :: Int32 -> SeekMode -> Int -> IO (Maybe Int)
Pqi.loSeek = \Int32
fd SeekMode
mode Int
offset -> Connection -> LoFd -> SeekMode -> Int -> IO (Maybe Int)
LibPQ.loSeek Connection
c (Int32 -> LoFd
toLibPQLoFd Int32
fd) SeekMode
mode Int
offset,
loTell :: Int32 -> IO (Maybe Int)
Pqi.loTell = \Int32
fd -> Connection -> LoFd -> IO (Maybe Int)
LibPQ.loTell Connection
c (Int32 -> LoFd
toLibPQLoFd Int32
fd),
loTruncate :: Int32 -> Int -> IO (Maybe ())
Pqi.loTruncate = \Int32
fd Int
len -> Connection -> LoFd -> Int -> IO (Maybe ())
LibPQ.loTruncate Connection
c (Int32 -> LoFd
toLibPQLoFd Int32
fd) Int
len,
loClose :: Int32 -> IO (Maybe ())
Pqi.loClose = \Int32
fd -> Connection -> LoFd -> IO (Maybe ())
LibPQ.loClose Connection
c (Int32 -> LoFd
toLibPQLoFd Int32
fd),
loUnlink :: Word32 -> IO (Maybe ())
Pqi.loUnlink = \Word32
oid -> Connection -> Oid -> IO (Maybe ())
LibPQ.loUnlink Connection
c (Word32 -> Oid
toOid Word32
oid),
clientEncoding :: IO ByteString
Pqi.clientEncoding = Connection -> IO ByteString
LibPQ.clientEncoding Connection
c,
setClientEncoding :: ByteString -> IO Bool
Pqi.setClientEncoding = \ByteString
encoding -> Connection -> ByteString -> IO Bool
LibPQ.setClientEncoding Connection
c ByteString
encoding,
setErrorVerbosity :: Verbosity -> IO Verbosity
Pqi.setErrorVerbosity = \Verbosity
verbosity ->
Verbosity -> Verbosity
fromVerbosity (Verbosity -> Verbosity) -> IO Verbosity -> IO Verbosity
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Connection -> Verbosity -> IO Verbosity
LibPQ.setErrorVerbosity Connection
c (Verbosity -> Verbosity
toVerbosity Verbosity
verbosity)
}
mkResult :: LibPQ.Result -> Pqi.Result
mkResult :: Result -> Result
mkResult Result
r =
Pqi.Result
{ resultStatus :: IO ExecStatus
Pqi.resultStatus = ExecStatus -> ExecStatus
fromExecStatus (ExecStatus -> ExecStatus) -> IO ExecStatus -> IO ExecStatus
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Result -> IO ExecStatus
LibPQ.resultStatus Result
r,
resultErrorMessage :: IO (Maybe ByteString)
Pqi.resultErrorMessage = Result -> IO (Maybe ByteString)
LibPQ.resultErrorMessage Result
r,
resultErrorField :: FieldCode -> IO (Maybe ByteString)
Pqi.resultErrorField = \FieldCode
field -> Result -> FieldCode -> IO (Maybe ByteString)
LibPQ.resultErrorField Result
r (FieldCode -> FieldCode
toFieldCode FieldCode
field),
unsafeFreeResult :: IO ()
Pqi.unsafeFreeResult = Result -> IO ()
LibPQ.unsafeFreeResult Result
r,
ntuples :: IO Int32
Pqi.ntuples = Row -> Int32
fromRow (Row -> Int32) -> IO Row -> IO Int32
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Result -> IO Row
LibPQ.ntuples Result
r,
nfields :: IO Int32
Pqi.nfields = Column -> Int32
fromColumn (Column -> Int32) -> IO Column -> IO Int32
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Result -> IO Column
LibPQ.nfields Result
r,
fname :: Int32 -> IO (Maybe ByteString)
Pqi.fname = \Int32
column -> Result -> Column -> IO (Maybe ByteString)
LibPQ.fname Result
r (Int32 -> Column
toColumn Int32
column),
fnumber :: ByteString -> IO (Maybe Int32)
Pqi.fnumber = \ByteString
name -> (Column -> Int32) -> Maybe Column -> Maybe Int32
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Column -> Int32
fromColumn (Maybe Column -> Maybe Int32)
-> IO (Maybe Column) -> IO (Maybe Int32)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Result -> ByteString -> IO (Maybe Column)
LibPQ.fnumber Result
r ByteString
name,
ftable :: Int32 -> IO Word32
Pqi.ftable = \Int32
column -> Oid -> Word32
fromOid (Oid -> Word32) -> IO Oid -> IO Word32
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Result -> Column -> IO Oid
LibPQ.ftable Result
r (Int32 -> Column
toColumn Int32
column),
ftablecol :: Int32 -> IO Int32
Pqi.ftablecol = \Int32
column -> Column -> Int32
fromColumn (Column -> Int32) -> IO Column -> IO Int32
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Result -> Column -> IO Column
LibPQ.ftablecol Result
r (Int32 -> Column
toColumn Int32
column),
fformat :: Int32 -> IO Format
Pqi.fformat = \Int32
column -> Format -> Format
fromFormat (Format -> Format) -> IO Format -> IO Format
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Result -> Column -> IO Format
LibPQ.fformat Result
r (Int32 -> Column
toColumn Int32
column),
ftype :: Int32 -> IO Word32
Pqi.ftype = \Int32
column -> Oid -> Word32
fromOid (Oid -> Word32) -> IO Oid -> IO Word32
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Result -> Column -> IO Oid
LibPQ.ftype Result
r (Int32 -> Column
toColumn Int32
column),
fmod :: Int32 -> IO Int
Pqi.fmod = \Int32
column -> Result -> Column -> IO Int
LibPQ.fmod Result
r (Int32 -> Column
toColumn Int32
column),
fsize :: Int32 -> IO Int
Pqi.fsize = \Int32
column -> Result -> Column -> IO Int
LibPQ.fsize Result
r (Int32 -> Column
toColumn Int32
column),
getvalue :: Int32 -> Int32 -> IO (Maybe ByteString)
Pqi.getvalue = \Int32
row Int32
column -> Result -> Row -> Column -> IO (Maybe ByteString)
LibPQ.getvalue' Result
r (Int32 -> Row
toRow Int32
row) (Int32 -> Column
toColumn Int32
column),
getvalue' :: Int32 -> Int32 -> IO (Maybe ByteString)
Pqi.getvalue' = \Int32
row Int32
column -> Result -> Row -> Column -> IO (Maybe ByteString)
LibPQ.getvalue' Result
r (Int32 -> Row
toRow Int32
row) (Int32 -> Column
toColumn Int32
column),
getisnull :: Int32 -> Int32 -> IO Bool
Pqi.getisnull = \Int32
row Int32
column -> Result -> Row -> Column -> IO Bool
LibPQ.getisnull Result
r (Int32 -> Row
toRow Int32
row) (Int32 -> Column
toColumn Int32
column),
getlength :: Int32 -> Int32 -> IO Int
Pqi.getlength = \Int32
row Int32
column -> Result -> Row -> Column -> IO Int
LibPQ.getlength Result
r (Int32 -> Row
toRow Int32
row) (Int32 -> Column
toColumn Int32
column),
nparams :: IO Int32
Pqi.nparams = Int -> Int32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Int32) -> IO Int -> IO Int32
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Result -> IO Int
LibPQ.nparams Result
r,
paramtype :: Int32 -> IO Word32
Pqi.paramtype = \Int32
index -> Oid -> Word32
fromOid (Oid -> Word32) -> IO Oid -> IO Word32
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Result -> Int -> IO Oid
LibPQ.paramtype Result
r (Int32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int32
index),
cmdStatus :: IO (Maybe ByteString)
Pqi.cmdStatus = Result -> IO (Maybe ByteString)
LibPQ.cmdStatus Result
r,
cmdTuples :: IO (Maybe ByteString)
Pqi.cmdTuples = Result -> IO (Maybe ByteString)
LibPQ.cmdTuples Result
r
}
mkCancel :: LibPQ.Cancel -> Pqi.Cancel
mkCancel :: Cancel -> Cancel
mkCancel Cancel
handle =
Pqi.Cancel
{ cancel :: IO (Either ByteString ())
Pqi.cancel = Cancel -> IO (Either ByteString ())
LibPQ.cancel Cancel
handle
}
toParam :: (Word32, ByteString, Pqi.Format) -> (LibPQ.Oid, ByteString, LibPQ.Format)
toParam :: (Word32, ByteString, Format) -> (Oid, ByteString, Format)
toParam (Word32
oid, ByteString
value, Format
format) = (Word32 -> Oid
toOid Word32
oid, ByteString
value, Format -> Format
toFormat Format
format)
toBoundParam :: (ByteString, Pqi.Format) -> (ByteString, LibPQ.Format)
toBoundParam :: (ByteString, Format) -> (ByteString, Format)
toBoundParam (ByteString
value, Format
format) = (ByteString
value, Format -> Format
toFormat Format
format)
toOid :: Word32 -> LibPQ.Oid
toOid :: Word32 -> Oid
toOid = CUInt -> Oid
LibPQ.Oid (CUInt -> Oid) -> (Word32 -> CUInt) -> Word32 -> Oid
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word32 -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral
fromOid :: LibPQ.Oid -> Word32
fromOid :: Oid -> Word32
fromOid (LibPQ.Oid CUInt
value) = CUInt -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral CUInt
value
toRow :: Int32 -> LibPQ.Row
toRow :: Int32 -> Row
toRow = Int32 -> Row
forall a. Integral a => a -> Row
LibPQ.toRow
fromRow :: LibPQ.Row -> Int32
fromRow :: Row -> Int32
fromRow = Int -> Int32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Int32) -> (Row -> Int) -> Row -> Int32
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Row -> Int
forall a. Enum a => a -> Int
fromEnum
toColumn :: Int32 -> LibPQ.Column
toColumn :: Int32 -> Column
toColumn = Int32 -> Column
forall a. Integral a => a -> Column
LibPQ.toColumn
fromColumn :: LibPQ.Column -> Int32
fromColumn :: Column -> Int32
fromColumn = Int -> Int32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Int32) -> (Column -> Int) -> Column -> Int32
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Column -> Int
forall a. Enum a => a -> Int
fromEnum
toLibPQLoFd :: Int32 -> LibPQ.LoFd
toLibPQLoFd :: Int32 -> LoFd
toLibPQLoFd = CInt -> LoFd
LibPQ.LoFd (CInt -> LoFd) -> (Int32 -> CInt) -> Int32 -> LoFd
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int32 -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral
fromLibPQLoFd :: LibPQ.LoFd -> Int32
fromLibPQLoFd :: LoFd -> Int32
fromLibPQLoFd (LibPQ.LoFd CInt
fd) = CInt -> Int32
forall a b. (Integral a, Num b) => a -> b
fromIntegral CInt
fd
fromNotify :: LibPQ.Notify -> Pqi.Notify
fromNotify :: Notify -> Notify
fromNotify Notify
notification =
Pqi.Notify
{ relname :: ByteString
Pqi.relname = Notify -> ByteString
LibPQ.notifyRelname Notify
notification,
bePid :: Int32
Pqi.bePid = CPid -> Int32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Notify -> CPid
LibPQ.notifyBePid Notify
notification),
extra :: ByteString
Pqi.extra = Notify -> ByteString
LibPQ.notifyExtra Notify
notification
}
toFormat :: Pqi.Format -> LibPQ.Format
toFormat :: Format -> Format
toFormat = \case
Format
Pqi.Text -> Format
LibPQ.Text
Format
Pqi.Binary -> Format
LibPQ.Binary
fromFormat :: LibPQ.Format -> Pqi.Format
fromFormat :: Format -> Format
fromFormat = \case
Format
LibPQ.Text -> Format
Pqi.Text
Format
LibPQ.Binary -> Format
Pqi.Binary
fromExecStatus :: LibPQ.ExecStatus -> Pqi.ExecStatus
fromExecStatus :: ExecStatus -> ExecStatus
fromExecStatus = \case
ExecStatus
LibPQ.EmptyQuery -> ExecStatus
Pqi.EmptyQuery
ExecStatus
LibPQ.CommandOk -> ExecStatus
Pqi.CommandOk
ExecStatus
LibPQ.TuplesOk -> ExecStatus
Pqi.TuplesOk
ExecStatus
LibPQ.CopyOut -> ExecStatus
Pqi.CopyOut
ExecStatus
LibPQ.CopyIn -> ExecStatus
Pqi.CopyIn
ExecStatus
LibPQ.CopyBoth -> ExecStatus
Pqi.CopyBoth
ExecStatus
LibPQ.BadResponse -> ExecStatus
Pqi.BadResponse
ExecStatus
LibPQ.NonfatalError -> ExecStatus
Pqi.NonfatalError
ExecStatus
LibPQ.FatalError -> ExecStatus
Pqi.FatalError
ExecStatus
LibPQ.SingleTuple -> ExecStatus
Pqi.SingleTuple
ExecStatus
LibPQ.PipelineSync -> ExecStatus
Pqi.PipelineSync
ExecStatus
LibPQ.PipelineAbort -> ExecStatus
Pqi.PipelineAbort
fromConnStatus :: LibPQ.ConnStatus -> Pqi.ConnStatus
fromConnStatus :: ConnStatus -> ConnStatus
fromConnStatus = \case
ConnStatus
LibPQ.ConnectionOk -> ConnStatus
Pqi.ConnectionOk
ConnStatus
LibPQ.ConnectionBad -> ConnStatus
Pqi.ConnectionBad
ConnStatus
LibPQ.ConnectionStarted -> ConnStatus
Pqi.ConnectionStarted
ConnStatus
LibPQ.ConnectionMade -> ConnStatus
Pqi.ConnectionMade
ConnStatus
LibPQ.ConnectionAwaitingResponse -> ConnStatus
Pqi.ConnectionAwaitingResponse
ConnStatus
LibPQ.ConnectionAuthOk -> ConnStatus
Pqi.ConnectionAuthOk
ConnStatus
LibPQ.ConnectionSetEnv -> ConnStatus
Pqi.ConnectionSetEnv
ConnStatus
LibPQ.ConnectionSSLStartup -> ConnStatus
Pqi.ConnectionSSLStartup
fromTransactionStatus :: LibPQ.TransactionStatus -> Pqi.TransactionStatus
fromTransactionStatus :: TransactionStatus -> TransactionStatus
fromTransactionStatus = \case
TransactionStatus
LibPQ.TransIdle -> TransactionStatus
Pqi.TransIdle
TransactionStatus
LibPQ.TransActive -> TransactionStatus
Pqi.TransActive
TransactionStatus
LibPQ.TransInTrans -> TransactionStatus
Pqi.TransInTrans
TransactionStatus
LibPQ.TransInError -> TransactionStatus
Pqi.TransInError
TransactionStatus
LibPQ.TransUnknown -> TransactionStatus
Pqi.TransUnknown
fromPollingStatus :: LibPQ.PollingStatus -> Pqi.PollingStatus
fromPollingStatus :: PollingStatus -> PollingStatus
fromPollingStatus = \case
PollingStatus
LibPQ.PollingFailed -> PollingStatus
Pqi.PollingFailed
PollingStatus
LibPQ.PollingReading -> PollingStatus
Pqi.PollingReading
PollingStatus
LibPQ.PollingWriting -> PollingStatus
Pqi.PollingWriting
PollingStatus
LibPQ.PollingOk -> PollingStatus
Pqi.PollingOk
fromPipelineStatus :: LibPQ.PipelineStatus -> Pqi.PipelineStatus
fromPipelineStatus :: PipelineStatus -> PipelineStatus
fromPipelineStatus = \case
PipelineStatus
LibPQ.PipelineOn -> PipelineStatus
Pqi.PipelineOn
PipelineStatus
LibPQ.PipelineOff -> PipelineStatus
Pqi.PipelineOff
PipelineStatus
LibPQ.PipelineAborted -> PipelineStatus
Pqi.PipelineAborted
fromFlushStatus :: LibPQ.FlushStatus -> Pqi.FlushStatus
fromFlushStatus :: FlushStatus -> FlushStatus
fromFlushStatus = \case
FlushStatus
LibPQ.FlushOk -> FlushStatus
Pqi.FlushOk
FlushStatus
LibPQ.FlushFailed -> FlushStatus
Pqi.FlushFailed
FlushStatus
LibPQ.FlushWriting -> FlushStatus
Pqi.FlushWriting
fromCopyInResult :: LibPQ.CopyInResult -> Pqi.CopyInResult
fromCopyInResult :: CopyInResult -> CopyInResult
fromCopyInResult = \case
CopyInResult
LibPQ.CopyInOk -> CopyInResult
Pqi.CopyInOk
CopyInResult
LibPQ.CopyInError -> CopyInResult
Pqi.CopyInError
CopyInResult
LibPQ.CopyInWouldBlock -> CopyInResult
Pqi.CopyInWouldBlock
fromCopyOutResult :: LibPQ.CopyOutResult -> Pqi.CopyOutResult
fromCopyOutResult :: CopyOutResult -> CopyOutResult
fromCopyOutResult = \case
LibPQ.CopyOutRow ByteString
value -> ByteString -> CopyOutResult
Pqi.CopyOutRow ByteString
value
CopyOutResult
LibPQ.CopyOutWouldBlock -> CopyOutResult
Pqi.CopyOutWouldBlock
CopyOutResult
LibPQ.CopyOutDone -> CopyOutResult
Pqi.CopyOutDone
CopyOutResult
LibPQ.CopyOutError -> CopyOutResult
Pqi.CopyOutError
toVerbosity :: Pqi.Verbosity -> LibPQ.Verbosity
toVerbosity :: Verbosity -> Verbosity
toVerbosity = \case
Verbosity
Pqi.ErrorsTerse -> Verbosity
LibPQ.ErrorsTerse
Verbosity
Pqi.ErrorsDefault -> Verbosity
LibPQ.ErrorsDefault
Verbosity
Pqi.ErrorsVerbose -> Verbosity
LibPQ.ErrorsVerbose
fromVerbosity :: LibPQ.Verbosity -> Pqi.Verbosity
fromVerbosity :: Verbosity -> Verbosity
fromVerbosity = \case
Verbosity
LibPQ.ErrorsTerse -> Verbosity
Pqi.ErrorsTerse
Verbosity
LibPQ.ErrorsDefault -> Verbosity
Pqi.ErrorsDefault
Verbosity
LibPQ.ErrorsVerbose -> Verbosity
Pqi.ErrorsVerbose
toFieldCode :: Pqi.FieldCode -> LibPQ.FieldCode
toFieldCode :: FieldCode -> FieldCode
toFieldCode = \case
FieldCode
Pqi.DiagSeverity -> FieldCode
LibPQ.DiagSeverity
FieldCode
Pqi.DiagSqlstate -> FieldCode
LibPQ.DiagSqlstate
FieldCode
Pqi.DiagMessagePrimary -> FieldCode
LibPQ.DiagMessagePrimary
FieldCode
Pqi.DiagMessageDetail -> FieldCode
LibPQ.DiagMessageDetail
FieldCode
Pqi.DiagMessageHint -> FieldCode
LibPQ.DiagMessageHint
FieldCode
Pqi.DiagStatementPosition -> FieldCode
LibPQ.DiagStatementPosition
FieldCode
Pqi.DiagInternalPosition -> FieldCode
LibPQ.DiagInternalPosition
FieldCode
Pqi.DiagInternalQuery -> FieldCode
LibPQ.DiagInternalQuery
FieldCode
Pqi.DiagContext -> FieldCode
LibPQ.DiagContext
FieldCode
Pqi.DiagSourceFile -> FieldCode
LibPQ.DiagSourceFile
FieldCode
Pqi.DiagSourceLine -> FieldCode
LibPQ.DiagSourceLine
FieldCode
Pqi.DiagSourceFunction -> FieldCode
LibPQ.DiagSourceFunction