Portability | non-portable |
---|---|
Stability | experimental |
Maintainer | oleg@pobox.com, alistair@abayley.org |
Simple wrappers for PostgreSQL functions (FFI) plus middle-level wrappers (in the second part of this file)
- data DBHandleStruct = PGconn
- type DBHandle = Ptr DBHandleStruct
- data StmtStruct = PGresult
- type ResultSetHandle = Ptr StmtStruct
- type Oid = CUInt
- type Format = CInt
- type Void = ()
- type ParamLen = CInt
- data PGException = PGException Int String
- catchPG :: IO a -> (PGException -> IO a) -> IO a
- throwPG :: Integral a => a -> String -> any
- rethrowPG :: PGException -> any
- cStr :: CStringLen -> CString
- cStrLen :: CStringLen -> CInt
- fPQconnectdb :: CString -> IO DBHandle
- fPQfinish :: DBHandle -> IO ()
- fPQreset :: DBHandle -> IO ()
- fPQdb :: DBHandle -> CString
- type ConnStatusType = CInt
- fPQstatus :: DBHandle -> IO ConnStatusType
- fPQerrorMessage :: DBHandle -> IO CString
- fPQsetClientEncoding :: DBHandle -> CString -> IO CString
- type NoticeReceiver = Ptr () -> ResultSetHandle -> IO ()
- type NoticeProcessor = Ptr () -> CString -> IO ()
- mkNoticeReceiver :: NoticeReceiver -> IO (FunPtr NoticeReceiver)
- mkNoticeProcessor :: NoticeProcessor -> IO (FunPtr NoticeProcessor)
- fPQsetNoticeReceiver :: DBHandle -> FunPtr NoticeReceiver -> Ptr () -> IO (FunPtr NoticeReceiver)
- fPQsetNoticeProcessor :: DBHandle -> FunPtr NoticeProcessor -> Ptr () -> IO (FunPtr NoticeProcessor)
- fPQexecParams :: DBHandle -> CString -> CInt -> Ptr Oid -> Ptr Void -> Ptr ParamLen -> Ptr Format -> CInt -> IO ResultSetHandle
- fPQprepare :: DBHandle -> CString -> CString -> CInt -> Ptr Oid -> IO ResultSetHandle
- fPQexecPrepared :: DBHandle -> CString -> CInt -> Ptr Void -> Ptr ParamLen -> Ptr Format -> CInt -> IO ResultSetHandle
- fPQresultStatus :: ResultSetHandle -> IO ExecStatusType
- type ExecStatusType = CInt
- fPQresultErrorMessage :: ResultSetHandle -> IO CString
- fPQclear :: ResultSetHandle -> IO ()
- fPQntuples :: ResultSetHandle -> IO CInt
- fPQnfields :: ResultSetHandle -> IO CInt
- fPQfname :: ResultSetHandle -> CInt -> IO CString
- fPQfformat :: ResultSetHandle -> CInt -> IO CInt
- fPQftype :: ResultSetHandle -> CInt -> IO Oid
- fPQgetvalue :: ResultSetHandle -> CInt -> CInt -> IO (Ptr Word8)
- fPQgetisnull :: ResultSetHandle -> CInt -> CInt -> IO CInt
- fPQgetlength :: ResultSetHandle -> CInt -> CInt -> IO CInt
- fPQcmdStatus :: ResultSetHandle -> IO CString
- fPQcmdTuples :: ResultSetHandle -> IO CString
- fPQoidValue :: ResultSetHandle -> IO Oid
- fPQputCopyData :: DBHandle -> Ptr Word8 -> CInt -> IO CInt
- fPQputCopyEnd :: DBHandle -> CString -> IO CInt
- fPQgetResult :: DBHandle -> IO ResultSetHandle
- type PGVerbosity = CInt
- fPQsetErrorVerbosity :: DBHandle -> PGVerbosity -> IO PGVerbosity
- type LOAccessType = CInt
- type WhenceType = CInt
- flo_creat :: DBHandle -> LOAccessType -> IO Oid
- flo_import :: DBHandle -> CString -> IO Oid
- flo_export :: DBHandle -> Oid -> CString -> IO CInt
- flo_open :: DBHandle -> Oid -> LOAccessType -> IO CInt
- flo_write :: DBHandle -> CInt -> Ptr Word8 -> CUInt -> IO CInt
- flo_read :: DBHandle -> CInt -> Ptr Word8 -> CUInt -> IO CInt
- flo_lseek :: DBHandle -> CInt -> CInt -> WhenceType -> IO CInt
- flo_tell :: DBHandle -> CInt -> IO CInt
- flo_close :: DBHandle -> CInt -> IO CInt
- flo_unlink :: DBHandle -> Oid -> IO CInt
- getError :: DBHandle -> IO String
- openDb :: String -> IO DBHandle
- closeDb :: DBHandle -> IO ()
- class PGType a where
- data PGBindVal = PGBindVal {
- bindValOid :: Oid
- bindValFormat :: Format
- bindValSize :: CInt
- bindValPtr :: IO (Ptr Word8)
- toCChar :: Char -> CChar
- fromCChar :: CChar -> Char
- toCInt :: Int -> CInt
- check'stmt :: DBHandle -> ExecStatusType -> ResultSetHandle -> IO ResultSetHandle
- stmtPrepare :: DBHandle -> String -> String -> [Oid] -> IO String
- nqExec :: DBHandle -> String -> IO (String, String, Oid)
- execCommand :: DBHandle -> String -> [PGBindVal] -> IO (String, String, Oid)
- execPreparedCommand :: DBHandle -> String -> [PGBindVal] -> IO (String, String, Oid)
- stmtExecImm :: DBHandle -> String -> [PGBindVal] -> IO (ResultSetHandle, Int)
- stmtExecImm0 :: DBHandle -> String -> IO (ResultSetHandle, Int)
- stmtExec0 :: DBHandle -> String -> IO (ResultSetHandle, Int)
- stmtExec0t :: DBHandle -> String -> IO (ResultSetHandle, Int)
- stmtExec :: DBHandle -> String -> [PGBindVal] -> IO (ResultSetHandle, Int)
- execPrepared :: DBHandle -> String -> [PGBindVal] -> CInt -> IO (ResultSetHandle, Int)
- prepare'n'exec :: DBHandle -> String -> String -> [PGBindVal] -> IO (ResultSetHandle, Int)
- stmtFinalise :: ResultSetHandle -> IO ()
- colValPtr :: ResultSetHandle -> Int -> Int -> IO (Ptr Word8)
- colVal :: PGType a => ResultSetHandle -> Int -> Int -> IO a
- colValString :: ResultSetHandle -> Int -> Int -> IO String
- colValInt :: ResultSetHandle -> Int -> Int -> IO Int
- colValInt64 :: ResultSetHandle -> Int -> Int -> IO Int64
- colValDouble :: ResultSetHandle -> Int -> Int -> IO Double
- colValFloat :: ResultSetHandle -> Int -> Int -> IO Float
- colValUTCTime :: ResultSetHandle -> Int -> Int -> IO UTCTime
- colValCalTime :: ResultSetHandle -> Int -> Int -> IO CalendarTime
- colValNull :: ResultSetHandle -> Int -> Int -> IO Bool
- sbph :: String -> Int -> Bool -> String -> String
- nqCopyIn_buflen :: Int
- nqCopyIn :: DBHandle -> String -> Handle -> IO ()
Documentation
type DBHandle = Ptr DBHandleStructSource
data StmtStruct Source
type ResultSetHandle = Ptr StmtStructSource
rethrowPG :: PGException -> anySource
cStr :: CStringLen -> CStringSource
cStrLen :: CStringLen -> CIntSource
fPQconnectdb :: CString -> IO DBHandleSource
type ConnStatusType = CIntSource
type NoticeReceiver = Ptr () -> ResultSetHandle -> IO ()Source
fPQsetNoticeReceiver :: DBHandle -> FunPtr NoticeReceiver -> Ptr () -> IO (FunPtr NoticeReceiver)Source
fPQsetNoticeProcessor :: DBHandle -> FunPtr NoticeProcessor -> Ptr () -> IO (FunPtr NoticeProcessor)Source
fPQexecParams :: DBHandle -> CString -> CInt -> Ptr Oid -> Ptr Void -> Ptr ParamLen -> Ptr Format -> CInt -> IO ResultSetHandleSource
fPQprepare :: DBHandle -> CString -> CString -> CInt -> Ptr Oid -> IO ResultSetHandleSource
fPQexecPrepared :: DBHandle -> CString -> CInt -> Ptr Void -> Ptr ParamLen -> Ptr Format -> CInt -> IO ResultSetHandleSource
type ExecStatusType = CIntSource
fPQclear :: ResultSetHandle -> IO ()Source
fPQfformat :: ResultSetHandle -> CInt -> IO CIntSource
fPQgetvalue :: ResultSetHandle -> CInt -> CInt -> IO (Ptr Word8)Source
fPQgetisnull :: ResultSetHandle -> CInt -> CInt -> IO CIntSource
fPQgetlength :: ResultSetHandle -> CInt -> CInt -> IO CIntSource
type PGVerbosity = CIntSource
type LOAccessType = CIntSource
type WhenceType = CIntSource
PGBindVal | |
|
execPreparedCommand :: DBHandle -> String -> [PGBindVal] -> IO (String, String, Oid)Source
This is for commands, as opposed to queries.
The query equivalent of execPreparedCommand
is stmtExec
.
stmtExecImm :: DBHandle -> String -> [PGBindVal] -> IO (ResultSetHandle, Int)Source
stmtExecImm0 :: DBHandle -> String -> IO (ResultSetHandle, Int)Source
stmtExec0t :: DBHandle -> String -> IO (ResultSetHandle, Int)Source
execPrepared :: DBHandle -> String -> [PGBindVal] -> CInt -> IO (ResultSetHandle, Int)Source
prepare'n'exec :: DBHandle -> String -> String -> [PGBindVal] -> IO (ResultSetHandle, Int)Source
colValPtr :: ResultSetHandle -> Int -> Int -> IO (Ptr Word8)Source
Column numbers are zero-indexed, so subtract one from given index (we present a one-indexed interface). So are the row numbers.
colValString :: ResultSetHandle -> Int -> Int -> IO StringSource
colValInt64 :: ResultSetHandle -> Int -> Int -> IO Int64Source
colValDouble :: ResultSetHandle -> Int -> Int -> IO DoubleSource
colValFloat :: ResultSetHandle -> Int -> Int -> IO FloatSource
colValUTCTime :: ResultSetHandle -> Int -> Int -> IO UTCTimeSource
colValCalTime :: ResultSetHandle -> Int -> Int -> IO CalendarTimeSource
colValNull :: ResultSetHandle -> Int -> Int -> IO BoolSource