Skip to content

Commit

Permalink
Documented putCopyData and putCopyEnd
Browse files Browse the repository at this point in the history
  • Loading branch information
joeyadams committed Mar 8, 2012
1 parent a7cae29 commit 5ab97d9
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Database/PostgreSQL/LibPQ.hsc
Expand Up @@ -1522,6 +1522,12 @@ unescapeBytea bs =
-- rows in bulk, @COPY FROM@ is /much/ faster than individual @INSERT@
-- statements.
--
-- For more information, see:
--
-- * <http://www.postgresql.org/docs/current/static/sql-copy.html>
--
-- * <http://www.postgresql.org/docs/current/static/libpq-copy.html>
--
-- The following example illustrates the procedure for using @COPY FROM@ with
-- libpq:
--
Expand Down Expand Up @@ -1559,6 +1565,7 @@ toCopyResult n | n < 0 = CopyError
| otherwise = CopyOk


-- | Send raw @COPY@ data to the server during the @COPY_IN@ state.
putCopyData :: Connection -> B.ByteString -> IO CopyResult
putCopyData conn bs =
B.unsafeUseAsCStringLen bs $ putCopyCString conn
Expand All @@ -1570,6 +1577,15 @@ putCopyCString conn (str, len) =
withConn conn $ \ptr -> c_PQputCopyData ptr str (fromIntegral len)


-- | Send end-of-data indication to the server during the @COPY_IN@ state.
--
-- * @putCopyEnd conn Nothing@ ends the @COPY_IN@ operation successfully.
--
-- * @putCopyEnd conn (Just errormsg)@ forces the @COPY@ to fail, with
-- @errormsg@ used as the error message.
--
-- After 'putCopyEnd' returns 'CopyOk', call 'getResult' to obtain the final
-- result status of the @COPY@ command. Then return to normal operation.
putCopyEnd :: Connection -> Maybe B.ByteString -> IO CopyResult
putCopyEnd conn Nothing =
fmap toCopyResult $
Expand Down

0 comments on commit 5ab97d9

Please sign in to comment.