git.iko.soy/typeable/postgresql-simple
on master help sign in
Edit comments
commitde797487a12a3600e9be249ab4d4992464c74082 authorLeon P Smith <leon@melding-monads.com> dateThu 29 Dec 2011, 23:52 (15 years ago) parent725aa68
4 files changed+28−24
src/Database/PostgreSQL/Simple.hs+19−17 src/Database/PostgreSQL/Simple/QueryResults.hs+3−1 src/Database/PostgreSQL/Simple/Result.hs+5−5 src/Database/PostgreSQL/Simple/Types.hs+1−1
src/Database/PostgreSQL/Simple.hs+19−17
@@ -1,5 +1,6 @@
1−{-# LANGUAGE BangPatterns, DeriveDataTypeable, OverloadedStrings, DoAndIfThenElse, RecordWildCards, NamedFieldPuns #-}
2−
1+{-# LANGUAGE BangPatterns, DeriveDataTypeable, OverloadedStrings #-}
2+{-# LANGUAGE DoAndIfThenElse, RecordWildCards, NamedFieldPuns #-}
3+------------------------------------------------------------------------------
34-- |
45-- Module: Database.PostgreSQL.Simple
56-- Copyright: (c) 2011 MailRank, Inc.
@@ -9,8 +10,10 @@
910-- Stability: experimental
1011-- Portability: portable
1112--
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
1314-- use and high performance.
15+--
16+------------------------------------------------------------------------------
1417
1518module Database.PostgreSQL.Simple
1619 (
@@ -436,8 +439,8 @@ withResult fetchResult q act = bracket fetchResult Base.freeResult $ \r -> do
436439-- 'Base.commit' before this function returns.
437440--
438441-- If the action throws /any/ kind of exception (not just a
439−-- MySQL-related exception), the transaction will be rolled back using
440−-- 'Base.rollback', then the exception will be rethrown.
442+-- PostgreSQL-related exception), the transaction will be rolled back using
443+-- 'rollback', then the exception will be rethrown.
441444withTransaction :: Connection -> IO a -> IO a
442445withTransaction conn act = do
443446 _ <- begin conn
@@ -449,21 +452,21 @@ withTransaction conn act = do
449452-- rollback :: (MonadCatchIO m,MonadIO m) => Connection -> m ()
450453rollback :: Connection -> IO ()
451454rollback conn = do
452− _ <- execute_ conn "ABORT;"
455+ _ <- execute_ conn "ABORT"
453456 return ()
454457
455458-- | Commit a transaction.
456459-- commit :: (MonadCatchIO m,MonadIO m) => Connection -> m ()
457460commit :: Connection -> IO ()
458461commit conn = do
459− _ <- execute_ conn "COMMIT;"
462+ _ <- execute_ conn "COMMIT"
460463 return ()
461464
462465-- | Begin a transaction.
463466-- begin :: (MonadCatchIO m,MonadIO m) => Connection -> m ()
464467begin :: Connection -> IO ()
465468begin conn = do
466− _ <- execute_ conn "BEGIN;"
469+ _ <- execute_ conn "BEGIN"
467470 return ()
468471
469472fmtError :: String -> Query -> [Action] -> a
@@ -500,7 +503,7 @@ fmtError msg q xs = throw FormatError {
500503--
501504-- > {-# LANGUAGE OverloadedStrings #-}
502505-- >
503−-- > import Database.MySQL.Simple
506+-- > import Database.PostgreSQL.Simple
504507-- >
505508-- > hello = do
506509-- > conn <- connect defaultConnectInfo
@@ -707,16 +710,15 @@ fmtError msg q xs = throw FormatError {
707710-- permissive. Here are the rules.
708711--
709712-- * For numeric types, any Haskell type that can accurately represent
710−-- all values of the given MySQL type is considered \"compatible\".
711−-- For instance, you can always extract a MySQL @TINYINT@ column to
712−-- 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.
713+-- all values of the given PostgreSQL type is considered \"compatible\".
714+-- For instance, you can always extract a PostgreSQL 16-bit @SMALLINT@
715+-- column to a Haskell 'Int'. The Haskell 'Float' type can accurately
716+-- represent a @SMALLINT@, so it is considered compatble with those types.
715717--
716718-- * A numeric compatibility check is based only on the type of a
717−-- column, /not/ on its values. For instance, a MySQL @LONG_LONG@
718−-- column will be considered incompatible with a Haskell 'Int8',
719−-- even if it contains the value @1@.
719+-- column, /not/ on its values. For instance, a PostgreSQL 64-bit
720+-- @BIGINT@ column will be considered incompatible with a Haskell
721+-- 'Int16', even if it contains the value @1@.
720722--
721723-- * If a numeric incompatibility is found, 'query' will throw a
722724-- 'ResultError'.
src/Database/PostgreSQL/Simple/QueryResults.hs+3−1
@@ -1,7 +1,8 @@
11{-# LANGUAGE BangPatterns, OverloadedStrings #-}
22
3+------------------------------------------------------------------------------
34-- |
4−-- Module: Database.MySQL.Simpe.QueryResults
5+-- Module: Database.PostgreSQL.Simple.QueryResults
56-- Copyright: (c) 2011 MailRank, Inc.
67-- (c) 2011 Leon P Smith
78-- License: BSD3
@@ -14,6 +15,7 @@
1415--
1516-- Predefined instances are provided for tuples containing up to ten
1617-- elements.
18+------------------------------------------------------------------------------
1719
1820module Database.PostgreSQL.Simple.QueryResults
1921 (
src/Database/PostgreSQL/Simple/Result.hs+5−5
@@ -14,11 +14,11 @@
1414-- returned by a SQL query into a more useful Haskell representation.
1515--
1616-- A Haskell numeric type is considered to be compatible with all
17−-- MySQL numeric types that are less accurate than it. For instance,
18−-- the Haskell 'Double' type is compatible with the MySQL 'Long' type
19−-- because it can represent a 'Long' exactly. On the other hand, since
20−-- a 'Double' might lose precision if representing a 'LongLong', the
21−-- two are /not/ considered compatible.
17+-- PostgreSQL numeric types that are less accurate than it. For instance,
18+-- the Haskell 'Double' type is compatible with the PostgreSQL's 32-bit
19+-- @Int@ type because it can represent a @Int@ exactly. On the other hand,
20+-- since a 'Double' might lose precision if representing a 64-bit @BigInt@,
21+-- the two are /not/ considered compatible.
2222--
2323------------------------------------------------------------------------------
2424
src/Database/PostgreSQL/Simple/Types.hs+1−1
@@ -50,7 +50,7 @@ instance Eq Null where
5050--
5151-- > {-# LANGUAGE OverloadedStrings #-}
5252-- >
53−-- > import Database.MySQL.Simple
53+-- > import Database.PostgreSQL.Simple
5454-- >
5555-- > q :: Query
5656-- > q = "select ?"