Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/Database/PostgreSQL/LibPQ.hs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ module Database.PostgreSQL.LibPQ
, setnonblocking
, isnonblocking
, setSingleRowMode
, setChunkedRowsMode
, FlushStatus(..)
, flush

Expand Down Expand Up @@ -1630,6 +1631,24 @@ setSingleRowMode :: Connection
setSingleRowMode connection = enumFromConn connection c_PQsetSingleRowMode


-- | Select chunked mode for the currently-executing query.
--
-- This function is similar to 'PQsetSingleRowMode', except that it specifies
-- retrieval of up to @chunkSize@ rows per 'Result', not necessarily just one
-- row. This function can only be called immediately after 'sendQuery' or one
-- of its sibling functions, before any other operation on the connection such
-- as 'consumeInput' or 'getResult'. If called at the correct time, the
-- function activates chunked mode for the current query and returns 1.
-- Otherwise the mode stays unchanged and the function returns 0. In any case,
-- the mode reverts to normal after completion of the current query.
setChunkedRowsMode :: Connection
-> Int
-> IO Bool
setChunkedRowsMode connection chunkSize =
enumFromConn connection $ \p ->
c_PQsetChunkedRowsMode p (fromIntegral chunkSize)


data FlushStatus = FlushOk
| FlushFailed
| FlushWriting
Expand Down
3 changes: 3 additions & 0 deletions src/Database/PostgreSQL/LibPQ/FFI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ foreign import capi "hs-libpq.h PQisnonblocking"
foreign import capi "hs-libpq.h PQsetSingleRowMode"
c_PQsetSingleRowMode :: Ptr PGconn -> IO CInt

foreign import capi "hs-libpq.h PQsetChunkedRowsMode"
c_PQsetChunkedRowsMode :: Ptr PGconn -> CInt -> IO CInt

foreign import capi "hs-libpq.h PQgetResult"
c_PQgetResult :: Ptr PGconn -> IO (Ptr PGresult)

Expand Down