HDBC-mysql 0.6.6.4 → 0.7.0.0
raw patch · 6 files changed
+134/−127 lines, 6 filesdep ~basesetup-changedPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base
API changes (from Hackage documentation)
Files
- Database/HDBC/MySQL/Connection.hsc +1/−2
- Database/HDBC/MySQL/RTS.hsc +2/−0
- HDBC-mysql.cabal +39/−33
- README.markdown +0/−90
- README.md +90/−0
- Setup.lhs +2/−2
Database/HDBC/MySQL/Connection.hsc view
@@ -487,8 +487,7 @@ bindOfSqlValue $ Types.SqlUTCTime $ posixSecondsToUTCTime t -- A nasty helper function that cuts down on the boilerplate a bit.-bindOfSqlValue' :: (Integral a, Storable b) => a -> Ptr b -> CInt -> Signedness -> IO MYSQL_BIND-+bindOfSqlValue' :: Integral a => a -> Ptr b -> CInt -> Signedness -> IO MYSQL_BIND bindOfSqlValue' len buf_ btype signedness = do let buflen = fromIntegral len isNull_ <- new (0 :: CChar)
Database/HDBC/MySQL/RTS.hsc view
@@ -45,6 +45,8 @@ instance Storable SigSet where sizeOf _ = #{size sigset_t} alignment _ = alignment (undefined :: Ptr CInt)+ peek _ = undefined -- peek is unused+ poke _ = undefined -- poke is unused foreign import ccall unsafe "signal.h sigaddset" sigaddset :: Ptr SigSet -> CInt -> IO ()
HDBC-mysql.cabal view
@@ -1,39 +1,45 @@-Name: HDBC-mysql-Category: Database-Synopsis: MySQL driver for HDBC-Version: 0.6.6.4-Stability: Experimental-Maintainer: Ryan Mulligan <ryan@ryantm.com>-Author: Chris Waterson-Copyright: 2009-2010 Chris Waterson, 2011 MailRank-License: LGPL-License-file: COPYING-Homepage: https://github.com/ryantm/hdbc-mysql-Bug-Reports: https://github.com/ryantm/hdbc-mysql/issues-Build-Type: Custom-Tested-with: GHC-Cabal-Version: >= 1.8-Description:- This package provides a MySQL driver for HDBC, implemented via- bindings to the C @mysqlclient@ library.+name: HDBC-mysql+category: Database+synopsis: MySQL driver for HDBC+version: 0.7.0.0+stability: Experimental+maintainer: Ryan Mulligan <ryan@ryantm.com>+author: Chris Waterson+copyright: 2009-2010 Chris Waterson, 2011 MailRank+license: LGPL+license-file: COPYING+homepage: http://github.com/ryantm/hdbc-mysql+bug-reports: http://github.com/ryantm/hdbc-mysql/issues+build-type: Custom+tested-with: GHC+cabal-version: >= 1.24+description:+ This package provides a MySQL driver for HDBC, implemented via+ bindings to the C @mysqlclient@ library. extra-source-files:- ChangeLog- README.markdown+ ChangeLog+ README.md +custom-setup+ setup-depends:+ base >= 4.9 && < 5,+ Cabal >= 1.24+ library- Exposed-modules: Database.HDBC.MySQL- Other-modules:- Database.HDBC.MySQL.Connection- Database.HDBC.MySQL.RTS- Build-Depends:- HDBC >= 2.1.0,- base >= 2 && < 4.9,- bytestring,- time,- utf8-string- ghc-options: -Wall- Extra-Libraries: mysqlclient+ exposed-modules: Database.HDBC.MySQL+ other-modules:+ Database.HDBC.MySQL.Connection+ Database.HDBC.MySQL.RTS+ build-depends:+ HDBC >= 2.1.0,+ base >= 4.9 && < 5,+ bytestring,+ time,+ utf8-string+ ghc-options: -Wall+ extra-libraries: z ssl mysqlclient+ default-language: Haskell2010 source-repository head type: git- location: https://github.com/ryantm/hdbc-mysql+ location: http://github.com/ryantm/hdbc-mysql
− README.markdown
@@ -1,90 +0,0 @@-HDBC-mysql-==========--This is a "native" HDBC driver for MySQL that makes use of-libmysqlclient to communicate with a MySQL server. By way of-synopsis:-- import Control.Monad- import Database.HDBC- import Database.HDBC.MySQL- main = do conn <- connectMySQL defaultMySQLConnectInfo {- mysqlHost = "db1.example.com",- mysqlUser = "scott",- mysqlPassword = "tiger"- }-- rows <- quickQuery' conn "SELECT 1 + 1" []- forM_ rows $ \row -> putStrLn $ show row--At the moment, please consider this to be "alpha" software. As far as-I can tell, it works. There are some limitations that you should be-aware of.--Caveats-=======-- * This works with MySQL server and client libraries 5.0.75. I- haven't tried with 4.x nor 5.1. I suspect that using a server- version less than 4.1 won't work, due to lack of support for- prepared statements.-- * MySQL DATETIME and TIMESTAMP columns have no time zone information,- because they just don't. So, I'm just converting them blindly to- SqlEpochTime values, and assuming the times are UTC. This is all- fine if you're actually running your server in UTC, but it will- probably be confusing if you're not. It might be possible to- interpret the times using the current connection's default- time zone setting, instead. Is that better? Or worse?-- * Regardless, the types I convert to are now deprecated, and I need- to implement the new types (SqlLocalDate, etc.)-- * Out of the box, MySQL probably uses MyISAM tables to store its- data, and MyISAM tables don't support transactions. Yet, I'm- going to blindly respond "yes" if you ask whether the driver- itself supports transactions, and assume that you know enough to- use InnoDB tables in the database if you want to make use of- HDBC's transactional support. I *suppose* I might be able to- discover what the default table type is, and say "no" if it's not- a table type that supports transactions, but... meh.-- * I'm not sure that I can tell the difference between a MySQL TEXT- and a MySQL BLOB column. If you ask about the metadata of either,- I'll tell you it's a SqlBinaryT.-- * The statement and table metadata could stand to be improved a bit.- In particular, it would be nice if "describeTable foo" and- "describeResults" on "SELECT * FROM foo" returned the same thing.- (They're sorta close, I guess...)-- * Thread-safety could be an issue. In the driver code, there's- definitely a race condition between "prepare" and "disconnect",- for example. I haven't even *looked* at thread-safety issues for- the MySQL driver. I'm not sure if I should worry about it, or if- we assume that's going to be dealt with at a higher level.-- * We might crash if someone opens a connection, prepares a- statement, explicitly disconnects the connection, and then tries- to play with the statement.-- * It probably makes sense to marshall to the SqlByteString type when- retrieving BLOB data.--Testing-=======--There's a little test program that runs a query and spews out the-results. To compile it,-- ghc -idist/build -L/opt/local/lib/mysql5/mysql -lmysqlclient --make Test--I'm still trying to get the Makefile right so that it can build the-test sources: it's not there yet. Here's how I've been doing it, for-now:-- cd testsrc- ghc --make -package HUnit -package HDBC -Wall -i../dist/build -i.. -L/opt/local/lib/mysql5/mysql -lmysqlclient -o runtests runtests.hs--One issue is that I want the location of the MySQL library to come-from the configuration data, rather than be hard-coded.
+ README.md view
@@ -0,0 +1,90 @@+HDBC-mysql+==========++This is a "native" HDBC driver for MySQL that makes use of+libmysqlclient to communicate with a MySQL server. By way of+synopsis:++ import Control.Monad+ import Database.HDBC+ import Database.HDBC.MySQL+ main = do conn <- connectMySQL defaultMySQLConnectInfo {+ mysqlHost = "db1.example.com",+ mysqlUser = "scott",+ mysqlPassword = "tiger"+ }++ rows <- quickQuery' conn "SELECT 1 + 1" []+ forM_ rows $ \row -> putStrLn $ show row++At the moment, please consider this to be "alpha" software. As far as+I can tell, it works. There are some limitations that you should be+aware of.++Caveats+=======++ * This works with MySQL server and client libraries 5.0.75. I+ haven't tried with 4.x nor 5.1. I suspect that using a server+ version less than 4.1 won't work, due to lack of support for+ prepared statements.++ * MySQL DATETIME and TIMESTAMP columns have no time zone information,+ because they just don't. So, I'm just converting them blindly to+ SqlEpochTime values, and assuming the times are UTC. This is all+ fine if you're actually running your server in UTC, but it will+ probably be confusing if you're not. It might be possible to+ interpret the times using the current connection's default+ time zone setting, instead. Is that better? Or worse?++ * Regardless, the types I convert to are now deprecated, and I need+ to implement the new types (SqlLocalDate, etc.)++ * Out of the box, MySQL probably uses MyISAM tables to store its+ data, and MyISAM tables don't support transactions. Yet, I'm+ going to blindly respond "yes" if you ask whether the driver+ itself supports transactions, and assume that you know enough to+ use InnoDB tables in the database if you want to make use of+ HDBC's transactional support. I *suppose* I might be able to+ discover what the default table type is, and say "no" if it's not+ a table type that supports transactions, but... meh.++ * I'm not sure that I can tell the difference between a MySQL TEXT+ and a MySQL BLOB column. If you ask about the metadata of either,+ I'll tell you it's a SqlBinaryT.++ * The statement and table metadata could stand to be improved a bit.+ In particular, it would be nice if "describeTable foo" and+ "describeResults" on "SELECT * FROM foo" returned the same thing.+ (They're sorta close, I guess...)++ * Thread-safety could be an issue. In the driver code, there's+ definitely a race condition between "prepare" and "disconnect",+ for example. I haven't even *looked* at thread-safety issues for+ the MySQL driver. I'm not sure if I should worry about it, or if+ we assume that's going to be dealt with at a higher level.++ * We might crash if someone opens a connection, prepares a+ statement, explicitly disconnects the connection, and then tries+ to play with the statement.++ * It probably makes sense to marshall to the SqlByteString type when+ retrieving BLOB data.++Testing+=======++There's a little test program that runs a query and spews out the+results. To compile it,++ ghc -idist/build -L/opt/local/lib/mysql5/mysql -lmysqlclient --make Test++I'm still trying to get the Makefile right so that it can build the+test sources: it's not there yet. Here's how I've been doing it, for+now:++ cd testsrc+ ghc --make -package HUnit -package HDBC -Wall -i../dist/build -i.. -L/opt/local/lib/mysql5/mysql -lmysqlclient -o runtests runtests.hs++One issue is that I want the location of the MySQL library to come+from the configuration data, rather than be hard-coded.
Setup.lhs view
@@ -28,8 +28,8 @@ mysqlConfigProgram = (simpleProgram "mysql_config") { programFindLocation = \verbosity _ -> do- mysql_config <- findProgramLocation verbosity "mysql_config" - mysql_config5 <- findProgramLocation verbosity "mysql_config5"+ mysql_config <- findProgramOnSearchPath verbosity defaultProgramSearchPath "mysql_config"+ mysql_config5 <- findProgramOnSearchPath verbosity defaultProgramSearchPath "mysql_config5" return (mysql_config `mplus` mysql_config5) }