Skip to content

Commit

Permalink
Fix discarded value warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
zenzike committed Mar 3, 2012
1 parent 8c3dba3 commit 31ebedf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
18 changes: 9 additions & 9 deletions Database/HDBC/PostgreSQL/Parser.hs
Expand Up @@ -13,43 +13,43 @@ escapeseq = (try $ string "''") <|>
(try $ string "\\'")

literal :: GenParser Char st [Char]
literal = do char '\''
literal = do _ <- char '\''
s <- many (escapeseq <|> (noneOf "'" >>= (\x -> return [x])))
char '\''
_ <- char '\''
return $ "'" ++ (concat s) ++ "'"

qidentifier :: GenParser Char st [Char]
qidentifier = do char '"'
qidentifier = do _ <- char '"'
s <- many (noneOf "\"")
char '"'
_ <- char '"'
return $ "\"" ++ s ++ "\""

comment :: GenParser Char st [Char]
comment = ccomment <|> linecomment

ccomment :: GenParser Char st [Char]
ccomment = do string "/*"
ccomment = do _ <- string "/*"
c <- manyTill ((try ccomment) <|>
(anyChar >>= (\x -> return [x])))
(try (string "*/"))
return $ "/*" ++ concat c ++ "*/"

linecomment :: GenParser Char st [Char]
linecomment = do string "--"
linecomment = do _ <- string "--"
c <- many (noneOf "\n")
char '\n'
_ <- char '\n'
return $ "--" ++ c ++ "\n"

-- FIXME: handle pgsql dollar-quoted constants

qmark :: (Num st, Show st) => GenParser Char st [Char]
qmark = do char '?'
qmark = do _ <- char '?'
n <- getState
updateState (+1)
return $ "$" ++ show n

escapedQmark :: GenParser Char st [Char]
escapedQmark = do try (char '\\' >> char '?')
escapedQmark = do _ <- try (char '\\' >> char '?')
return "?"

statement :: (Num st, Show st) => GenParser Char st [Char]
Expand Down
14 changes: 7 additions & 7 deletions Database/HDBC/PostgreSQL/Statement.hsc
Expand Up @@ -100,7 +100,7 @@ fexecuteRaw sstate =
do l "in fexecute"
public_ffinish sstate -- Sets nextrowmv to -1
resptr <- pqexec cconn cquery
handleResultStatus cconn resptr sstate =<< pqresultStatus resptr
_ <- handleResultStatus cconn resptr sstate =<< pqresultStatus resptr
return ()

handleResultStatus :: (Num a, Read a) => Ptr CConn -> WrappedCStmt -> SState -> ResultStatus -> IO a
Expand All @@ -109,28 +109,28 @@ handleResultStatus cconn resptr sstate status =
#{const PGRES_EMPTY_QUERY} ->
do l $ "PGRES_EMPTY_QUERY: " ++ squery sstate
pqclear_raw resptr
swapMVar (coldefmv sstate) []
_ <- swapMVar (coldefmv sstate) []
return 0
#{const PGRES_COMMAND_OK} ->
do l $ "PGRES_COMMAND_OK: " ++ squery sstate
rowscs <- pqcmdTuples resptr
rows <- peekCString rowscs
pqclear_raw resptr
swapMVar (coldefmv sstate) []
_ <- swapMVar (coldefmv sstate) []
return $ case rows of
"" -> 0
x -> read x
#{const PGRES_TUPLES_OK} ->
do l $ "PGRES_TUPLES_OK: " ++ squery sstate
fgetcoldef resptr >>= swapMVar (coldefmv sstate)
_ <- fgetcoldef resptr >>= swapMVar (coldefmv sstate)
numrows <- pqntuples resptr
if numrows < 1 then (pqclear_raw resptr >> return 0) else
do
wrappedptr <- withRawConn (dbo sstate)
(\rawconn -> wrapstmt resptr rawconn)
fresptr <- newForeignPtr pqclearptr wrappedptr
swapMVar (nextrowmv sstate) 0
swapMVar (stomv sstate) (Just fresptr)
_ <- swapMVar (nextrowmv sstate) 0
_ <- swapMVar (stomv sstate) (Just fresptr)
return 0
_ | resptr == nullPtr -> do
l $ "PGRES ERROR: " ++ squery sstate
Expand Down Expand Up @@ -218,7 +218,7 @@ fexecutemany sstate arglist =
public_ffinish :: SState -> IO ()
public_ffinish sstate =
do l "public_ffinish"
swapMVar (nextrowmv sstate) (-1)
_ <- swapMVar (nextrowmv sstate) (-1)
modifyMVar_ (stomv sstate) worker
where worker Nothing = return Nothing
worker (Just sth) = ffinish sth >> return Nothing
Expand Down

0 comments on commit 31ebedf

Please sign in to comment.