git.iko.soy/typeable/postgresql-simple
on master help sign in
Copy every field, all the time.
8635f88Leon P Smith
src/Database/PostgreSQL/Simple/FromField.hs+2−13
@@ -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'.
169− --
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.
176− --
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.
180
169
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
324
313
325-- | oid
314-- | oid
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
344
333
345-- | bytea
334-- | bytea
346instance FromField (Binary LB.ByteString) where
335instance FromField (Binary LB.ByteString) where
src/Database/PostgreSQL/Simple/FromRow.hs+1−1
@@ -70,7 +70,7 @@ class FromRow a where
70 fromRow :: RowParser a
70 fromRow :: RowParser a
71
71
72getvalue :: PQ.Result -> PQ.Row -> PQ.Column -> Maybe ByteString
72getvalue :: PQ.Result -> PQ.Row -> PQ.Column -> Maybe ByteString
73−getvalue result row col = unsafeDupablePerformIO (PQ.getvalue result row col)
73+getvalue result row col = unsafeDupablePerformIO (PQ.getvalue' result row col)
74
74
75nfields :: PQ.Result -> PQ.Column
75nfields :: PQ.Result -> PQ.Column
76nfields result = unsafeDupablePerformIO (PQ.nfields result)
76nfields result = unsafeDupablePerformIO (PQ.nfields result)