git.iko.soy/typeable/postgresql-simple
on master help sign in
Edit comments
de79748Leon P Smith
src/Database/PostgreSQL/Simple.hs+19−17
@@ -1,5 +1,6 @@
1−{-# LANGUAGE BangPatterns, DeriveDataTypeable, OverloadedStrings, DoAndIfThenElse, RecordWildCards, NamedFieldPuns #-}
1+{-# LANGUAGE BangPatterns, DeriveDataTypeable, OverloadedStrings #-}
2−
2+{-# LANGUAGE DoAndIfThenElse, RecordWildCards, NamedFieldPuns #-}
3+------------------------------------------------------------------------------
3-- |
4-- |
4-- Module: Database.PostgreSQL.Simple
5-- Module: Database.PostgreSQL.Simple
5-- Copyright: (c) 2011 MailRank, Inc.
6-- Copyright: (c) 2011 MailRank, Inc.
@@ -9,8 +10,10 @@
9-- Stability: experimental
10-- Stability: experimental
10-- Portability: portable
11-- Portability: portable
11--
12--
12−-- A mid-level client library for the MySQL database, aimed at ease of
13+-- A mid-level client library for the PostgreSQL database, aimed at ease of
13-- use and high performance.
14-- use and high performance.
15+--
16+------------------------------------------------------------------------------
14
17
15module Database.PostgreSQL.Simple
18module Database.PostgreSQL.Simple
16 (
19 (
@@ -436,8 +439,8 @@ withResult fetchResult q act = bracket fetchResult Base.freeResult $ \r -> do
436-- 'Base.commit' before this function returns.
439-- 'Base.commit' before this function returns.
437--
440--
438-- If the action throws /any/ kind of exception (not just a
441-- If the action throws /any/ kind of exception (not just a
439−-- MySQL-related exception), the transaction will be rolled back using
442+-- PostgreSQL-related exception), the transaction will be rolled back using
440−-- 'Base.rollback', then the exception will be rethrown.
443+-- 'rollback', then the exception will be rethrown.
441withTransaction :: Connection -> IO a -> IO a
444withTransaction :: Connection -> IO a -> IO a
442withTransaction conn act = do
445withTransaction conn act = do
443 _ <- begin conn
446 _ <- begin conn
@@ -449,21 +452,21 @@ withTransaction conn act = do
449-- rollback :: (MonadCatchIO m,MonadIO m) => Connection -> m ()
452-- rollback :: (MonadCatchIO m,MonadIO m) => Connection -> m ()
450rollback :: Connection -> IO ()
453rollback :: Connection -> IO ()
451rollback conn = do
454rollback conn = do
452− _ <- execute_ conn "ABORT;"
455+ _ <- execute_ conn "ABORT"
453 return ()
456 return ()
454
457
455-- | Commit a transaction.
458-- | Commit a transaction.
456-- commit :: (MonadCatchIO m,MonadIO m) => Connection -> m ()
459-- commit :: (MonadCatchIO m,MonadIO m) => Connection -> m ()
457commit :: Connection -> IO ()
460commit :: Connection -> IO ()
458commit conn = do
461commit conn = do
459− _ <- execute_ conn "COMMIT;"
462+ _ <- execute_ conn "COMMIT"
460 return ()
463 return ()
461
464
462-- | Begin a transaction.
465-- | Begin a transaction.
463-- begin :: (MonadCatchIO m,MonadIO m) => Connection -> m ()
466-- begin :: (MonadCatchIO m,MonadIO m) => Connection -> m ()
464begin :: Connection -> IO ()
467begin :: Connection -> IO ()
465begin conn = do
468begin conn = do
466− _ <- execute_ conn "BEGIN;"
469+ _ <- execute_ conn "BEGIN"
467 return ()
470 return ()
468
471
469fmtError :: String -> Query -> [Action] -> a
472fmtError :: String -> Query -> [Action] -> a
@@ -500,7 +503,7 @@ fmtError msg q xs = throw FormatError {
500--
503--
501-- > {-# LANGUAGE OverloadedStrings #-}
504-- > {-# LANGUAGE OverloadedStrings #-}
502-- >
505-- >
503−-- > import Database.MySQL.Simple
506+-- > import Database.PostgreSQL.Simple
504-- >
507-- >
505-- > hello = do
508-- > hello = do
506-- > conn <- connect defaultConnectInfo
509-- > conn <- connect defaultConnectInfo
@@ -707,16 +710,15 @@ fmtError msg q xs = throw FormatError {
707-- permissive. Here are the rules.
710-- permissive. Here are the rules.
708--
711--
709-- * For numeric types, any Haskell type that can accurately represent
712-- * For numeric types, any Haskell type that can accurately represent
710−-- all values of the given MySQL type is considered \"compatible\".
713+-- all values of the given PostgreSQL type is considered \"compatible\".
711−-- For instance, you can always extract a MySQL @TINYINT@ column to
714+-- For instance, you can always extract a PostgreSQL 16-bit @SMALLINT@
712−-- a Haskell 'Int'. The Haskell 'Float' type can accurately
715+-- column to a Haskell 'Int'. The Haskell 'Float' type can accurately
713−-- represent MySQL integer types of size up to @INT24@, so it is
714−-- considered compatble with those types.
716+-- represent a @SMALLINT@, so it is considered compatble with those types.
715--
717--
716-- * A numeric compatibility check is based only on the type of a
718-- * A numeric compatibility check is based only on the type of a
717−-- column, /not/ on its values. For instance, a MySQL @LONG_LONG@
719+-- column, /not/ on its values. For instance, a PostgreSQL 64-bit
718−-- column will be considered incompatible with a Haskell 'Int8',
720+-- @BIGINT@ column will be considered incompatible with a Haskell
719−-- even if it contains the value @1@.
721+-- 'Int16', even if it contains the value @1@.
720--
722--
721-- * If a numeric incompatibility is found, 'query' will throw a
723-- * If a numeric incompatibility is found, 'query' will throw a
722-- 'ResultError'.
724-- 'ResultError'.
src/Database/PostgreSQL/Simple/QueryResults.hs+3−1
@@ -1,7 +1,8 @@
1{-# LANGUAGE BangPatterns, OverloadedStrings #-}
1{-# LANGUAGE BangPatterns, OverloadedStrings #-}
2
2
3+------------------------------------------------------------------------------
3-- |
4-- |
4−-- Module: Database.MySQL.Simpe.QueryResults
5+-- Module: Database.PostgreSQL.Simple.QueryResults
5-- Copyright: (c) 2011 MailRank, Inc.
6-- Copyright: (c) 2011 MailRank, Inc.
6-- (c) 2011 Leon P Smith
7-- (c) 2011 Leon P Smith
7-- License: BSD3
8-- License: BSD3
@@ -14,6 +15,7 @@
14--
15--
15-- Predefined instances are provided for tuples containing up to ten
16-- Predefined instances are provided for tuples containing up to ten
16-- elements.
17-- elements.
18+------------------------------------------------------------------------------
17
19
18module Database.PostgreSQL.Simple.QueryResults
20module Database.PostgreSQL.Simple.QueryResults
19 (
21 (
src/Database/PostgreSQL/Simple/Result.hs+5−5
@@ -14,11 +14,11 @@
14-- returned by a SQL query into a more useful Haskell representation.
14-- returned by a SQL query into a more useful Haskell representation.
15--
15--
16-- A Haskell numeric type is considered to be compatible with all
16-- A Haskell numeric type is considered to be compatible with all
17−-- MySQL numeric types that are less accurate than it. For instance,
17+-- PostgreSQL numeric types that are less accurate than it. For instance,
18−-- the Haskell 'Double' type is compatible with the MySQL 'Long' type
18+-- the Haskell 'Double' type is compatible with the PostgreSQL's 32-bit
19−-- because it can represent a 'Long' exactly. On the other hand, since
19+-- @Int@ type because it can represent a @Int@ exactly. On the other hand,
20−-- a 'Double' might lose precision if representing a 'LongLong', the
20+-- since a 'Double' might lose precision if representing a 64-bit @BigInt@,
21−-- two are /not/ considered compatible.
21+-- the two are /not/ considered compatible.
22--
22--
23------------------------------------------------------------------------------
23------------------------------------------------------------------------------
24
24
src/Database/PostgreSQL/Simple/Types.hs+1−1
@@ -50,7 +50,7 @@ instance Eq Null where
50--
50--
51-- > {-# LANGUAGE OverloadedStrings #-}
51-- > {-# LANGUAGE OverloadedStrings #-}
52-- >
52-- >
53−-- > import Database.MySQL.Simple
53+-- > import Database.PostgreSQL.Simple
54-- >
54-- >
55-- > q :: Query
55-- > q :: Query
56-- > q = "select ?"
56-- > q = "select ?"