------------------------------------------------------------------------------- |-- Module : Database.PostgreSQL.Simple.LargeObjects-- Copyright : (c) 2011-2012 Leon P Smith-- License : BSD3---- Maintainer : leon@melding-monads.com---- Support for PostgreSQL's Large Objects; see-- <http://www.postgresql.org/docs/9.1/static/largeobjects.html> for more-- information.---- Note that Large Object File Descriptors are only valid within a single-- database transaction, so if you are interested in using anything beyond-- 'loCreat', 'loImport', 'loExport', and 'loUnlink', you will need to run-- the entire sequence of functions in a transaction.-------------------------------------------------------------------------------moduleDatabase.PostgreSQL.Simple.LargeObjects(loCreat,loCreate,loImport,loImportWithOid,loExport,loOpen,loWrite,loRead,loSeek,loTell,loTruncate,loClose,loUnlink,Oid(..),LoFd,IOMode(..),SeekMode(..))whereimportControl.Applicative((<$>))importControl.Exception(throwIO)importqualifiedData.ByteStringasBimportDatabase.PostgreSQL.LibPQ(Oid(..),LoFd(..))importqualifiedDatabase.PostgreSQL.LibPQasPQimportDatabase.PostgreSQL.Simple.InternalimportSystem.IO(IOMode(..),SeekMode(..))liftPQ::B.ByteString->Connection->(PQ.Connection->IO(Maybea))->IOaliftPQstrconnm=withConnectionconn$\c->dores<-mccaseresofNothing->domsg<-maybestrid<$>PQ.errorMessagecthrowIO$fatalErrormsgJustx->returnxloCreat::Connection->IOOidloCreatconn=liftPQ"loCreat"conn(\c->PQ.loCreatc)loCreate::Connection->Oid->IOOidloCreateconnoid=liftPQ"loCreate"conn(\c->PQ.loCreatecoid)loImport::Connection->FilePath->IOOidloImportconnpath=liftPQ"loImport"conn(\c->PQ.loImportcpath)loImportWithOid::Connection->FilePath->Oid->IOOidloImportWithOidconnpathoid=liftPQ"loImportWithOid"conn(\c->PQ.loImportWithOidcpathoid)loExport::Connection->Oid->FilePath->IO()loExportconnoidpath=liftPQ"loExport"conn(\c->PQ.loExportcoidpath)loOpen::Connection->Oid->IOMode->IOLoFdloOpenconnoidmode=liftPQ"loOpen"conn(\c->PQ.loOpencoidmode)loWrite::Connection->LoFd->B.ByteString->IOIntloWriteconnfddat=liftPQ"loWrite"conn(\c->PQ.loWritecfddat)loRead::Connection->LoFd->Int->IOB.ByteStringloReadconnfdmaxlen=liftPQ"loRead"conn(\c->PQ.loReadcfdmaxlen)loSeek::Connection->LoFd->SeekMode->Int->IOIntloSeekconnfdseekmodeoffset=liftPQ"loSeek"conn(\c->PQ.loSeekcfdseekmodeoffset)loTell::Connection->LoFd->IOIntloTellconnfd=liftPQ"loTell"conn(\c->PQ.loTellcfd)loTruncate::Connection->LoFd->Int->IO()loTruncateconnfdlen=liftPQ"loTruncate"conn(\c->PQ.loTruncatecfdlen)loClose::Connection->LoFd->IO()loCloseconnfd=liftPQ"loClose"conn(\c->PQ.loClosecfd)loUnlink::Connection->Oid->IO()loUnlinkconnoid=liftPQ"loUnlink"conn(\c->PQ.loUnlinkcoid)