Skip to content

Commit be85ee9

Browse files
committed
Fix compatibility with older versions of postgresql-libpq
1 parent f92ff66 commit be85ee9

3 files changed

Lines changed: 12 additions & 2 deletions

File tree

src/Database/PostgreSQL/Simple/Copy.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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
371372
finishExecute _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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

0 commit comments

Comments
 (0)