git.iko.soy/typeable/postgresql-simple
on master help sign in
Improve documentation for FromField
commit2a8dd7ad3a9dddb53cd833796c1b2f3d5344dab6 authorLeon P Smith <leon@melding-monads.com> dateSun 18 Mar 2012, 17:20 (15 years ago) parent72853ee
1 file changed+10−3
src/Database/PostgreSQL/Simple/FromField.hs+10−3
src/Database/PostgreSQL/Simple/FromField.hs+10−3
@@ -90,9 +90,16 @@ class FromField a where
9090 fromField :: Field -> Maybe ByteString -> Ok a
9191 -- ^ Convert a SQL value to a Haskell value.
9292 --
93− -- Returns an exception if the conversion fails. In the case of
94− -- library instances, this will usually be a 'ResultError', but may
95− -- be a 'UnicodeException'.
93+ -- Returns a list of exceptions if the conversion fails. In the case of
94+ -- library instances, this will usually be a single 'ResultError', but
95+ -- may be a 'UnicodeException'.
96+ --
97+ -- Implementations of the 'fromField' method should not retain any
98+ -- references to the ByteString it is passed, as this will cause the
99+ -- entire @LibPQ.'PQ.Result'@ to be retained. For example, the
100+ -- instance for 'ByteString' uses 'B.copy' to avoid this issue. Note that
101+ -- using bytestring functions such as 'B.drop' and 'B.takeWhile' alone
102+ -- will also trigger this memory leak.
96103
97104instance (FromField a) => FromField (Maybe a) where
98105 fromField _ Nothing = pure Nothing