HDBC-mysql 0.2 → 0.3
raw patch · 2 files changed
+11/−15 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- Database/HDBC/MySQL/Connection.hsc +10/−14
- HDBC-mysql.cabal +1/−1
Database/HDBC/MySQL/Connection.hsc view
@@ -120,11 +120,7 @@ -- So we'll turn it off here and start our first transaction. mysql_autocommit mysql_ 0 - -- XXX force a leak here. I have yet to fathom why the- -- references below to mysql__ don't keep the foreignPtr- -- alive.- --mysql__ <- newForeignPtr mysql_close mysql_- mysql__ <- newForeignPtr_ mysql_+ mysql__ <- newForeignPtr mysql_close mysql_ doStartTransaction mysql__ return $ Connection@@ -249,11 +245,7 @@ -- If an error occurs below, we'll lose the reference to the foreign -- pointer and run the finalizer.-- -- XXX force a leak here. I have yet to fathom why the references- -- below to stmt__ don't keep the foreignPtr alive.- --stmt__ <- newForeignPtr mysql_stmt_close stmt_- stmt__ <- newForeignPtr_ stmt_+ stmt__ <- newForeignPtr mysql_stmt_close stmt_ withCStringLen query $ \(query_, len) -> do rv <- mysql_stmt_prepare stmt_ query_ (fromIntegral len)@@ -497,13 +489,13 @@ -- values into a list of SqlValue types. fetchRow :: ForeignPtr MYSQL -> ForeignPtr MYSQL_STMT -> [MYSQL_BIND] -> IO (Maybe [Types.SqlValue]) fetchRow mysql__ stmt__ results =- withForeignPtr mysql__ $ \_ ->- withForeignPtr stmt__ $ \stmt_ -> do+ withForeignPtr mysql__ $ \_ ->+ withForeignPtr stmt__ $ \stmt_ -> do rv <- mysql_stmt_fetch stmt_ 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 @@ -605,7 +597,9 @@ 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@@ -632,6 +626,7 @@ 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@@ -646,6 +641,7 @@ 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)
HDBC-mysql.cabal view
@@ -1,7 +1,7 @@ Name: HDBC-mysql Category: Database Synopsis: MySQL driver for HDBC-Version: 0.2+Version: 0.3 Description: This package provides a MySQL driver for HDBC. Stability: Experimental Maintainer: Chris Waterson <waterson@maubi.net>