Skip to content

Commit

Permalink
the MySQL C API doesn't allow you to have more than one statement act…
Browse files Browse the repository at this point in the history
…ive on a connection at a time.
  • Loading branch information
waterson committed Feb 18, 2009
1 parent 2d18168 commit 4c82473
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Database/HDBC/MySQL/Connection.hsc
Expand Up @@ -495,7 +495,7 @@ fetchRow mysql__ stmt__ results =
case rv of
0 -> row
#{const MYSQL_DATA_TRUNCATED} -> row
#{const MYSQL_NO_DATA} -> return Nothing
#{const MYSQL_NO_DATA} -> finalizeForeignPtr stmt__ >> return Nothing
_ -> statementError stmt_
where row = mapM cellValue results >>= \cells -> return $ Just cells

Expand Down Expand Up @@ -597,7 +597,9 @@ typeIdOf n = ColTypes.SqlUnknownT ("unknown type "
doRun :: ForeignPtr MYSQL -> String -> [Types.SqlValue] -> IO Integer
doRun mysql__ query params = do
stmt <- newStatement mysql__ query
Types.execute stmt params
rv <- Types.execute stmt params
Types.finish stmt
return rv

-- Issue a query "old school", without using the prepared statement
-- API. We use this internally to send the transaction-related
Expand All @@ -624,6 +626,7 @@ doGetTables mysql__ = do
stmt <- newStatement mysql__ "SHOW TABLES"
Types.execute stmt []
rows <- unfoldRows stmt
Types.finish stmt
return $ map (fromSql . head) rows
where fromSql :: Types.SqlValue -> String
fromSql (Types.SqlString s) = s
Expand All @@ -638,6 +641,7 @@ doDescribeTable mysql__ table = do
stmt <- newStatement mysql__ ("DESCRIBE " ++ table)
Types.execute stmt []
rows <- unfoldRows stmt
Types.finish stmt
return $ map fromRow rows
where fromRow :: [Types.SqlValue] -> (String, ColTypes.SqlColDesc)
fromRow ((Types.SqlString colname)
Expand Down

0 comments on commit 4c82473

Please sign in to comment.