git.iko.soy/typeable/postgresql-simple
on master help sign in
Quick fix for #119, copy_ goes into infinite loop
07fa663Leon P Smith
src/Database/PostgreSQL/Simple/Internal.hs+11−2
@@ -310,8 +310,17 @@ exec conn sql =
310 case mres' of
310 case mres' of
311 Nothing -> case mres of
311 Nothing -> case mres of
312 Nothing -> throwLibPQError h "PQgetResult returned no results"
312 Nothing -> throwLibPQError h "PQgetResult returned no results"
313− Just res -> return res
313+ Just res -> do
314+ status <- PQ.resultStatus res
315+ case status of
316+ PQ.EmptyQuery -> getResult h mres'
317+ PQ.CommandOk -> getResult h mres'
318+ PQ.TuplesOk -> getResult h mres'
319+ PQ.CopyOut -> return res
320+ PQ.CopyIn -> return res
321+ PQ.BadResponse -> getResult h mres'
322+ PQ.NonfatalError -> getResult h mres'
314− Just _ -> getResult h mres'
323+ PQ.FatalError -> getResult h mres'
315#endif
324#endif
316
325
317-- | A version of 'execute' that does not perform query substitution.
326-- | A version of 'execute' that does not perform query substitution.