git.iko.soy/typeable/postgresql-simple
on master help sign in
Fix compatibility with older versions of postgresql-libpq
commitbe85ee90b35a35f5de099d820cd18c7239c4eea0 authorLeon P Smith <leon@melding-monads.com> dateMon 15 May 2017, 01:08 (9 years ago) parentf92ff66
3 files changed+12−2
src/Database/PostgreSQL/Simple/Copy.hs+4 src/Database/PostgreSQL/Simple/Internal.hs+2 src/Database/PostgreSQL/Simple/Internal/PQResultUtils.hs+6−2
src/Database/PostgreSQL/Simple/Copy.hs+4
@@ -85,8 +85,12 @@ doCopy funcName conn template q = do
8585 PQ.TuplesOk -> err
8686 PQ.CopyOut -> return ()
8787 PQ.CopyIn -> return ()
88+#if MIN_VERSION_postgresql_libpq(0,9,3)
8889 PQ.CopyBoth -> errMsg "COPY BOTH is not supported"
90+#endif
91+#if MIN_VERSION_postgresql_libpq(0,9,2)
8992 PQ.SingleTuple -> errMsg "single-row mode is not supported"
93+#endif
9094 PQ.BadResponse -> throwResultError funcName result status
9195 PQ.NonfatalError -> throwResultError funcName result status
9296 PQ.FatalError -> throwResultError funcName result status
src/Database/PostgreSQL/Simple/Internal.hs+2
@@ -351,6 +351,7 @@ exec conn sql =
351351 Just res -> do
352352 status <- PQ.resultStatus res
353353 case status of
354+ -- FIXME: handle PQ.CopyBoth and PQ.SingleTuple
354355 PQ.EmptyQuery -> getResult h mres'
355356 PQ.CommandOk -> getResult h mres'
356357 PQ.TuplesOk -> getResult h mres'
@@ -371,6 +372,7 @@ finishExecute :: Connection -> Query -> PQ.Result -> IO Int64
371372finishExecute _conn q result = do
372373 status <- PQ.resultStatus result
373374 case status of
375+ -- FIXME: handle PQ.CopyBoth and PQ.SingleTuple
374376 PQ.EmptyQuery -> throwIO $ QueryError "execute: Empty query" q
375377 PQ.CommandOk -> do
376378 ncols <- PQ.nfields result
src/Database/PostgreSQL/Simple/Internal/PQResultUtils.hs+6−2
@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
12
23------------------------------------------------------------------------------
34-- |
@@ -41,8 +42,12 @@ finishQueryWith parser conn q result = do
4142 PQ.CommandOk -> queryErr "query resulted in a command response"
4243 PQ.CopyOut -> queryErr "query: COPY TO is not supported"
4344 PQ.CopyIn -> queryErr "query: COPY FROM is not supported"
45+#if MIN_VERSION_postgresql_libpq(0,9,3)
4446 PQ.CopyBoth -> queryErr "query: COPY BOTH is not supported"
47+#endif
48+#if MIN_VERSION_postgresql_libpq(0,9,2)
4549 PQ.SingleTuple -> queryErr "query: single-row mode is not supported"
50+#endif
4651 PQ.BadResponse -> throwResultError "query" result status
4752 PQ.NonfatalError -> throwResultError "query" result status
4853 PQ.FatalError -> throwResultError "query" result status
@@ -67,8 +72,7 @@ getRowWith parser row ncols conn result = do
6772 Nothing
6873 ""
6974 (show (unCol col) ++ " slots in target type")
70− "mismatch between number of columns to \
71− \convert and number in target type")
75+ "mismatch between number of columns to convert and number in target type")
7276 Errors [] -> throwIO $ ConversionFailed "" Nothing "" "" "unknown error"
7377 Errors [x] -> throwIO x
7478 Errors xs -> throwIO $ ManyErrors xs