HDBC-mysql 0.6.5.1 → 0.6.6.0
raw patch · 3 files changed
+30/−5 lines, 3 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
+ Database.HDBC.MySQL: mysqlGroup :: MySQLConnectInfo -> Maybe String
- Database.HDBC.MySQL: MySQLConnectInfo :: String -> String -> String -> String -> Int -> String -> MySQLConnectInfo
+ Database.HDBC.MySQL: MySQLConnectInfo :: String -> String -> String -> String -> Int -> String -> Maybe String -> MySQLConnectInfo
Files
- Database/HDBC/MySQL.hs +1/−1
- Database/HDBC/MySQL/Connection.hsc +28/−3
- HDBC-mysql.cabal +1/−1
Database/HDBC/MySQL.hs view
@@ -26,7 +26,7 @@ 'mysqlPassword' = \"tiger\" } 'quickQuery'' conn \"SELECT 1 + 1\" []- forM_ rows $ \row -> putStrLn $ show row+ forM_ rows $ \\row -> putStrLn $ show row @ There are some important caveats to note about this driver.
Database/HDBC/MySQL/Connection.hsc view
@@ -44,6 +44,8 @@ , mysqlPort :: Int -- | The absolute path of the server's Unix socket; e.g., @\"\/var\/lib\/mysql.sock\"@ , mysqlUnixSocket :: String+ -- | The group name in my.cnf from which it reads options; e.g., @\"test\"@+ , mysqlGroup :: Maybe String } {- | Typical connection information, meant to be overridden partially,@@ -57,7 +59,7 @@ -} defaultMySQLConnectInfo :: MySQLConnectInfo-defaultMySQLConnectInfo = MySQLConnectInfo "127.0.0.1" "root" "" "test" 3306 ""+defaultMySQLConnectInfo = MySQLConnectInfo "127.0.0.1" "root" "" "test" 3306 "" Nothing data Connection = Connection { disconnect :: IO ()@@ -104,6 +106,11 @@ connectMySQL info = do mysql_ <- mysql_init nullPtr when (mysql_ == nullPtr) (error "mysql_init failed")+ case mysqlGroup info of+ Just group -> withCString group $ \group_ -> do+ _ <- mysql_options mysql_ #{const MYSQL_READ_DEFAULT_GROUP} (castPtr group_)+ return ()+ Nothing -> return () withCString (mysqlHost info) $ \host_ -> withCString (mysqlUser info) $ \user_ -> withCString (mysqlPassword info) $ \passwd_ ->@@ -560,10 +567,19 @@ rv <- mysql_stmt_fetch stmt_ case rv of 0 -> row- #{const MYSQL_DATA_TRUNCATED} -> row+ #{const MYSQL_DATA_TRUNCATED} -> liftM Just $ mapM (uncurry $ fill stmt_) $ zip [0..] results #{const MYSQL_NO_DATA} -> finalizeForeignPtr stmt__ >> return Nothing _ -> statementError stmt_- where row = mapM cellValue results >>= \cells -> return $ Just cells+ where row = liftM Just $ mapM cellValue results+ fill stmt_ column bind = do+ err <- peek $ bindError bind+ if err == 1 then do len <- peek $ bindLength bind+ bracket (mallocBytes $ fromIntegral len) free $ \buffer_ ->+ do let tempBind = bind { bindBuffer = buffer_, bindBufferLength = len }+ rv <- with tempBind $ \bind_ -> mysql_stmt_fetch_column stmt_ bind_ column 0+ when (rv /= 0) (statementError stmt_)+ cellValue tempBind+ else cellValue bind -- Produces a single SqlValue cell value given the binding, handling -- nulls appropriately.@@ -800,6 +816,12 @@ :: Ptr MYSQL -> IO (Ptr MYSQL) +foreign import ccall unsafe mysql_options+ :: Ptr MYSQL+ -> CInt+ -> Ptr ()+ -> IO CInt+ foreign import ccall unsafe mysql_real_connect :: Ptr MYSQL -- the context -> CString -- hostname@@ -845,6 +867,9 @@ foreign import ccall unsafe mysql_stmt_fetch :: Ptr MYSQL_STMT -> IO CInt++foreign import ccall unsafe mysql_stmt_fetch_column+ :: Ptr MYSQL_STMT -> Ptr MYSQL_BIND -> CUInt -> CULong -> IO CInt foreign import ccall unsafe mysql_stmt_close :: Ptr MYSQL_STMT -> IO ()
HDBC-mysql.cabal view
@@ -1,7 +1,7 @@ Name: HDBC-mysql Category: Database Synopsis: MySQL driver for HDBC-Version: 0.6.5.1+Version: 0.6.6.0 Stability: Experimental Maintainer: Bryan O'Sullivan <bos@serpentine.com> Author: Chris Waterson