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

Stabilityexperimental
MaintainerLeon P Smith <leon@melding-monads.com>
Safe HaskellNone

Database.PostgreSQL.Simple.Internal

Description

Internal bits. This interface is less stable and can change at any time. In particular this means that while the rest of the postgresql-simple package endeavors to follow the package versioning policy, this module does not. Also, at the moment there are things in here that aren't particularly internal and are exported elsewhere; these will eventually disappear from this module.

Synopsis

Documentation

data Field Source

A Field represents metadata about a particular field

You don't particularly want to retain these structures for a long period of time, as they will retain the entire query result, not just the field metadata

Constructors

Field 

Fields

result :: !Result
 
column :: !Column
 
typeOid :: !Oid

This returns the type oid associated with the column. Analogous to libpq's PQftype.

data Connection Source

Constructors

Connection 

Fields

connectionHandle :: !(MVar Connection)
 
connectionObjects :: !(MVar TypeInfoCache)
 
connectionTempNameCounter :: !(IORef Int64)
 

data SqlError Source

Constructors

SqlError 

Fields

sqlState :: ByteString
 
sqlExecStatus :: ExecStatus
 
sqlErrorMsg :: ByteString
 
sqlErrorDetail :: ByteString
 
sqlErrorHint :: ByteString
 

Instances

Show SqlError 
Typeable SqlError 
Exception SqlError 

fatalError :: ByteString -> SqlErrorSource

data QueryError Source

Exception thrown if query is used to perform an INSERT-like operation, or execute is used to perform a SELECT-like operation.

Constructors

QueryError 

Fields

qeMessage :: String
 
qeQuery :: Query
 

Instances

Eq QueryError 
Show QueryError 
Typeable QueryError 
Exception QueryError 

data ConnectInfo Source

Constructors

ConnectInfo 

Fields

connectHost :: String
 
connectPort :: Word16
 
connectUser :: String
 
connectPassword :: String
 
connectDatabase :: String
 

Instances

Eq ConnectInfo 
Read ConnectInfo 
Show ConnectInfo 
Typeable ConnectInfo 

defaultConnectInfo :: ConnectInfoSource

Default information for setting up a connection.

Defaults are as follows:

  • Server on localhost
  • Port on 5432
  • User postgres
  • No password
  • Database postgres

Use as in the following example:

 connect defaultConnectInfo { connectHost = "db.example.com" }

connect :: ConnectInfo -> IO ConnectionSource

Connect with the given username to the given database. Will throw an exception if it cannot connect.

connectPostgreSQL :: ByteString -> IO ConnectionSource

Attempt to make a connection based on a libpq connection string. See http://www.postgresql.org/docs/9.1/static/libpq-connect.html for more information.

postgreSQLConnectionString :: ConnectInfo -> ByteStringSource

Turns a ConnectInfo data structure into a libpq connection string.

oid2int :: Oid -> IntSource

exec :: Connection -> ByteString -> IO ResultSource

execute_ :: Connection -> Query -> IO Int64Source

A version of execute that does not perform query substitution.

throwResultError :: ByteString -> Result -> ExecStatus -> IO aSource

withConnection :: Connection -> (Connection -> IO a) -> IO aSource

Atomically perform an action with the database handle, if there is one.

data Row Source

Constructors

Row 

Fields

row :: !Row
 
rowresult :: !Result
 

newtype RowParser a Source

Constructors

RP 

Instances

Monad RowParser 
Functor RowParser 
Applicative RowParser 
Alternative RowParser 

newtype Conversion a Source

Constructors

Conversion 

Fields

runConversion :: Connection -> IO (Ok a)
 

Instances

Monad Conversion 
Functor Conversion 
MonadPlus Conversion 
Applicative Conversion 
Alternative Conversion 

conversionError :: Exception err => err -> Conversion aSource

fdError :: ByteString -> IOErrorSource