postgresql-simple-0.7.0.1: Mid-Level PostgreSQL client library

Copyright | (c) 2013 Leon P Smith
License | BSD3
Maintainer | Leon P Smith <leon@melding-monads.com>
Stability | experimental
Safe Haskell | None
Language | Haskell2010

Database.PostgreSQL.Simple.TypeInfo

Description

This module provides convenient and efficient access to parts of the `pg_type` metatable. At the moment, this requires PostgreSQL 8.4 if you need to work with types that do not appear in `Static`.

The current scheme could be more efficient, especially for some use cases. In particular, connection pools that use many user-added types and connect to a set of servers with identical (or at least compatible) `pg_type` and associated tables could share a common typeinfo cache, thus saving memory and communication between the client and server.

Synopsis

- getTypeInfo :: Connection -> Oid -> IO TypeInfo
- data TypeInfo
  - = Basic {
    - typoid :: !Oid
    - typcategory :: !Char
    - typdelim :: !Char
    - typname :: !ByteString
    }
  - | Array {
    - typoid :: !Oid
    - typcategory :: !Char
    - typdelim :: !Char
    - typname :: !ByteString
    - typelem :: !TypeInfo
    }
  - | Range {
    - typoid :: !Oid
    - typcategory :: !Char
    - typdelim :: !Char
    - typname :: !ByteString
    - rngsubtype :: !TypeInfo
    }
  - | Composite {
    - typoid :: !Oid
    - typcategory :: !Char
    - typdelim :: !Char
    - typname :: !ByteString
    - typrelid :: !Oid
    - attributes :: !(Vector Attribute)
    }
- data Attribute = Attribute {
  - attname :: !ByteString
  - atttype :: !TypeInfo
  }

# Documentation

getTypeInfo :: Connection -> Oid -> IO TypeInfo Source #

Returns the metadata of the type with a particular oid. To find this data, `getTypeInfo` first consults postgresql-simple's built-in `staticTypeInfo` table, then checks the connection's typeinfo cache. Finally, the database's `pg_type` table will be queried only if necessary, and the result will be stored in the connections's cache.

data TypeInfo Source #

A structure representing some of the metadata regarding a PostgreSQL type, mostly taken from the `pg_type` table.

Constructors

Basic |

Fields

- typoid :: !Oid
- typcategory :: !Char
- typdelim :: !Char
- typname :: !ByteString

Array |

Fields

- typoid :: !Oid
- typcategory :: !Char
- typdelim :: !Char
- typname :: !ByteString
- typelem :: !TypeInfo

Range |

Fields

- typoid :: !Oid
- typcategory :: !Char
- typdelim :: !Char
- typname :: !ByteString
- rngsubtype :: !TypeInfo

Composite |

Fields

- typoid :: !Oid
- typcategory :: !Char
- typdelim :: !Char
- typname :: !ByteString
- typrelid :: !Oid
- attributes :: !(Vector Attribute)

#### Instances

Instances details

Show TypeInfo Source # |
Instance details Defined in Database.PostgreSQL.Simple.TypeInfo.Types Methods showsPrec :: Int -> TypeInfo -> ShowS Source # show :: TypeInfo -> String Source # showList :: [TypeInfo] -> ShowS Source #

data Attribute Source #

Constructors

Attribute |

Fields

- attname :: !ByteString
- atttype :: !TypeInfo

#### Instances

Instances details

Show Attribute Source # |
Instance details Defined in Database.PostgreSQL.Simple.TypeInfo.Types Methods showsPrec :: Int -> Attribute -> ShowS Source # show :: Attribute -> String Source # showList :: [Attribute] -> ShowS Source #