@@ -166,17 +166,6 @@ class FromField a where
166 -- Returns a list of exceptions if the conversion fails. In the case of
166 -- Returns a list of exceptions if the conversion fails. In the case of
167 -- library instances, this will usually be a single 'ResultError', but
167 -- library instances, this will usually be a single 'ResultError', but
168 -- may be a 'UnicodeException'.
168 -- may be a 'UnicodeException'.
170− -- Note that retaining any reference to the 'Field' or 'ByteString'
171− -- arguments causes the entire @LibPQ.'PQ.Result'@ to be retained.
172− -- Thus, as a rule of thumb, implementations of 'fromField' should
173− -- not refer to these values after the result has been evaluated
174− -- to WHNF. But it can be profitable to break this rule when you
175− -- know it won't cause memory management problems.
177− -- The instances included with postgresql-simple follow this rule
178− -- of thumb (modulo bugs). For example, the instance for 'ByteString'
179− -- uses 'B.copy' to avoid such a reference.
181-- | Returns the data type name. This is the preferred way of identifying
170-- | Returns the data type name. This is the preferred way of identifying
182-- types that do not have a stable type oid, such as types provided by
171-- types that do not have a stable type oid, such as types provided by
@@ -320,7 +309,7 @@ unBinary (Binary x) = x
320instance FromField SB.ByteString where
309instance FromField SB.ByteString where
321 fromField f dat = if typeOid f == $(inlineTypoid TI.bytea)
310 fromField f dat = if typeOid f == $(inlineTypoid TI.bytea)
322 then unBinary <$> fromField f dat
311 then unBinary <$> fromField f dat
323− else doFromField f okText' (pure . B.copy) dat
312+ else doFromField f okText' pure dat
326instance FromField PQ.Oid where
315instance FromField PQ.Oid where
@@ -340,7 +329,7 @@ unescapeBytea f str = case unsafeDupablePerformIO (PQ.unescapeBytea str) of
340instance FromField (Binary SB.ByteString) where
329instance FromField (Binary SB.ByteString) where
341 fromField f dat = case format f of
330 fromField f dat = case format f of
342 PQ.Text -> doFromField f okBinary (unescapeBytea f) dat
331 PQ.Text -> doFromField f okBinary (unescapeBytea f) dat
343− PQ.Binary -> doFromField f okBinary (pure . Binary . B.copy) dat
332+ PQ.Binary -> doFromField f okBinary (pure . Binary) dat
345-- | bytea
334-- | bytea
346instance FromField (Binary LB.ByteString) where
335instance FromField (Binary LB.ByteString) where