git.iko.soy/typeable/postgresql-simple
on master help sign in
Fill in some documentation
commitf685f92bd97c8ae36c08428bde234f3e46a83d26 authorLeon P Smith <leon@melding-monads.com> dateTue 26 Mar 2013, 17:23 (14 years ago) parent2c59c11
3 files changed+26−4
CHANGES+4−4 src/Database/PostgreSQL/Simple/TypeInfo.hs+19 src/Database/PostgreSQL/Simple/TypeInfo/Types.hs+3
CHANGES+4−4
@@ -3,7 +3,7 @@ Version 0.3.0.1 (2013-03-26)
33 silently failed to render in Haddock.
44
55Version 0.3.0.0 (2013-03-25)
6− * Added support for PostgreSQL's Array Types. Thanks to Jason Dusek
6+ * Added support for PostgreSQL's Array Types. Thanks to Jason Dusek
77 for his work on this feature.
88
99 * Added a brand new TypeInfo system that gives FromField instances
@@ -15,7 +15,7 @@ Version 0.3.0.0 (2013-03-25)
1515 * Changed the type of the `fromField` and `fromRow` methods to allow
1616 a restricted set of IO actions, and stopped pre-calculating the type
1717 name of every column. As a result, the type of the `typename`
18− operator changed from `Field -> ByteString` to
18+ operator changed from `Field -> ByteString` to
1919 `Field -> Conversion ByteString`, where Conversion is the new monad
2020 that conversion computations run inside.
2121
@@ -33,7 +33,7 @@ Version 0.3.0.0 (2013-03-25)
3333
3434 * Changed withTransactionModeRetry to accept a predicate of which
3535 SqlErrors to retry, due to the fact that serialization errors can
36− sometimes manifest themselves as constraint violations. Thanks
36+ sometimes manifest themselves as constraint violations. Thanks
3737 to Oliver Charles for pointing this out and implementing the change.
3838
3939 * Added simple tests of the fold operator, thanks to Joey Adams.
@@ -45,7 +45,7 @@ Version 0.3.0.0 (2013-03-25)
4545
4646
4747Version 0.2.4.1 (2012-08-29)
48− * Fixed the documentation of `In`. Thanks to rekado and dstcruz for
48+ * Fixed the documentation of `In`. Thanks to rekado and dstcruz for
4949 pointing this out.
5050
5151Version 0.2.4.0 (2012-08-23)
src/Database/PostgreSQL/Simple/TypeInfo.hs+19
@@ -8,6 +8,18 @@
88-- Maintainer: Leon P Smith <leon@melding-monads.com>
99-- Stability: experimental
1010--
11+-- This module provides convenient and efficient access to parts of the
12+-- @pg_type@ metatable. At the moment, this requires PostgreSQL 8.4 if
13+-- you need to work with types that do not appear in
14+-- 'Database.PostgreSQL.Simple.TypeInfo.Static'.
15+--
16+-- The current scheme could be more efficient, especially for some use
17+-- cases. In particular, connection pools that use many user-added
18+-- types and connect to a set of servers with identical (or at least
19+-- compatible) @pg_type@ and associated tables could share a common
20+-- typeinfo cache, thus saving memory and communication between the
21+-- client and server.
22+--
1123------------------------------------------------------------------------------
1224
1325module Database.PostgreSQL.Simple.TypeInfo
@@ -27,6 +39,13 @@ import Database.PostgreSQL.Simple.Types
2739import Database.PostgreSQL.Simple.TypeInfo.Types
2840import Database.PostgreSQL.Simple.TypeInfo.Static
2941
42+-- | Returns the metadata of the type with a particular oid. To find
43+-- this data, 'getTypeInfo' first consults postgresql-simple's
44+-- built-in 'staticTypeInfo' table, then checks the connection's
45+-- typeinfo cache. Finally, the database's 'pg_type' table will
46+-- be queried only if necessary, and the result will be stored
47+-- in the connections's cache.
48+
3049getTypeInfo :: Connection -> PQ.Oid -> IO TypeInfo
3150getTypeInfo conn@Connection{..} oid =
3251 case staticTypeInfo oid of
src/Database/PostgreSQL/Simple/TypeInfo/Types.hs+3
@@ -13,6 +13,9 @@ module Database.PostgreSQL.Simple.TypeInfo.Types where
1313import Data.ByteString(ByteString)
1414import Database.PostgreSQL.LibPQ(Oid)
1515
16+-- | A structure representing some of the metadata regarding a PostgreSQL
17+-- type, mostly taken from the @pg_type@ table.
18+
1619data TypeInfo
1720
1821 = Basic { typoid :: {-# UNPACK #-} !Oid