packages feed

mysql-haskell 0.6.0.0 → 0.7.0.0

raw patch · 11 files changed

+26/−100 lines, 11 filesdep −HsOpenSSLdep −optparse-applicativedep ~tcp-streamsPVP ok

version bump matches the API change (PVP)

Dependencies removed: HsOpenSSL, optparse-applicative

Dependency ranges changed: tcp-streams

API changes (from Hackage documentation)

- Database.MySQL.OpenSSL: connect :: ConnectInfo -> (SSLContext, String) -> IO MySQLConn
- Database.MySQL.OpenSSL: connectDetail :: ConnectInfo -> (SSLContext, String) -> IO (Greeting, MySQLConn)
+ Database.MySQL.Connection: ConnectInfo :: HostName -> PortNumber -> ByteString -> ByteString -> ByteString -> ConnectInfo
+ Database.MySQL.Connection: ERRException :: ERR -> ERRException
+ Database.MySQL.Connection: MySQLConn :: {-# UNPACK #-} !(InputStream Packet) -> {-# UNPACK #-} !(OutputStream Packet) -> IO () -> {-# UNPACK #-} !(IORef Bool) -> MySQLConn
+ Database.MySQL.Connection: NetworkException :: NetworkException
+ Database.MySQL.Connection: UnconsumedResultSet :: UnconsumedResultSet
+ Database.MySQL.Connection: UnexpectedPacket :: Packet -> UnexpectedPacket
+ Database.MySQL.Connection: [ciDatabase] :: ConnectInfo -> ByteString
+ Database.MySQL.Connection: [ciHost] :: ConnectInfo -> HostName
+ Database.MySQL.Connection: [ciPassword] :: ConnectInfo -> ByteString
+ Database.MySQL.Connection: [ciPort] :: ConnectInfo -> PortNumber
+ Database.MySQL.Connection: [ciUser] :: ConnectInfo -> ByteString
+ Database.MySQL.Connection: [isConsumed] :: MySQLConn -> {-# UNPACK #-} !(IORef Bool)
+ Database.MySQL.Connection: [mysqlCloseSocket] :: MySQLConn -> IO ()
+ Database.MySQL.Connection: [mysqlRead] :: MySQLConn -> {-# UNPACK #-} !(InputStream Packet)
+ Database.MySQL.Connection: [mysqlWrite] :: MySQLConn -> {-# UNPACK #-} !(OutputStream Packet)
+ Database.MySQL.Connection: bUFSIZE :: Int
+ Database.MySQL.Connection: close :: MySQLConn -> IO ()
+ Database.MySQL.Connection: command :: MySQLConn -> Command -> IO OK
+ Database.MySQL.Connection: connect :: ConnectInfo -> IO MySQLConn
+ Database.MySQL.Connection: connectDetail :: ConnectInfo -> IO (Greeting, MySQLConn)
+ Database.MySQL.Connection: data ConnectInfo
+ Database.MySQL.Connection: data ERRException
+ Database.MySQL.Connection: data MySQLConn
+ Database.MySQL.Connection: data NetworkException
+ Database.MySQL.Connection: data UnconsumedResultSet
+ Database.MySQL.Connection: data UnexpectedPacket
+ Database.MySQL.Connection: decodeInputStream :: InputStream ByteString -> IO (InputStream Packet)
+ Database.MySQL.Connection: defaultConnectInfo :: ConnectInfo
+ Database.MySQL.Connection: guardUnconsumed :: MySQLConn -> IO ()
+ Database.MySQL.Connection: instance GHC.Exception.Exception Database.MySQL.Connection.ERRException
+ Database.MySQL.Connection: instance GHC.Exception.Exception Database.MySQL.Connection.NetworkException
+ Database.MySQL.Connection: instance GHC.Exception.Exception Database.MySQL.Connection.UnconsumedResultSet
+ Database.MySQL.Connection: instance GHC.Exception.Exception Database.MySQL.Connection.UnexpectedPacket
+ Database.MySQL.Connection: instance GHC.Show.Show Database.MySQL.Connection.ERRException
+ Database.MySQL.Connection: instance GHC.Show.Show Database.MySQL.Connection.NetworkException
+ Database.MySQL.Connection: instance GHC.Show.Show Database.MySQL.Connection.UnconsumedResultSet
+ Database.MySQL.Connection: instance GHC.Show.Show Database.MySQL.Connection.UnexpectedPacket
+ Database.MySQL.Connection: mkAuth :: ByteString -> ByteString -> ByteString -> Greeting -> Auth
+ Database.MySQL.Connection: ping :: MySQLConn -> IO OK
+ Database.MySQL.Connection: readPacket :: InputStream Packet -> IO Packet
+ Database.MySQL.Connection: waitCommandReply :: InputStream Packet -> IO OK
+ Database.MySQL.Connection: writeCommand :: Command -> OutputStream Packet -> IO ()
+ Database.MySQL.Connection: writeIORef' :: IORef a -> a -> IO ()

Files

ChangeLog.md view
@@ -1,5 +1,10 @@ # Revision history for mysql-haskell +## 0.7.0.0 -- 2016-11-09++* Split openssl support to [mysql-haskell-openssl](hackage.haskell.org/package/mysql-haskell-openssl).+* Expose `Database.MySQL.Connection` module due to this split, it shouldn't be used by user directly.+ ## 0.6.0.0 -- 2016-10-25  * Use binary-ieee754 for older binary compatibility.
Database/MySQL/BinLogProtocol/BinLogMeta.hs view
@@ -2,7 +2,7 @@  {-| Module      : Database.MySQL.BinLogProtocol.BinLogMeta-Description : binlog protocol column meta+Description : Binlog protocol column meta Copyright   : (c) Winterland, 2016 License     : BSD Maintainer  : drkoster@qq.com
Database/MySQL/BinLogProtocol/BinLogValue.hs view
@@ -1,6 +1,6 @@ {-| Module      : Database.MySQL.BinLogProtocol.BinLogValue-Description : binlog protocol+Description : Binlog protocol Copyright   : (c) Winterland, 2016 License     : BSD Maintainer  : drkoster@qq.com
Database/MySQL/Connection.hs view
@@ -39,6 +39,11 @@  -------------------------------------------------------------------------------- +-- | 'MySQLConn' wrap both 'InputStream' and 'OutputStream' for MySQL 'Packet'.+--+-- You shouldn't use one 'MySQLConn' in different thread, if you do that,+-- consider protecting it with a @MVar@.+-- data MySQLConn = MySQLConn {         mysqlRead        :: {-# UNPACK #-} !(InputStream  Packet)     ,   mysqlWrite       :: {-# UNPACK #-} !(OutputStream Packet)
− Database/MySQL/OpenSSL.hs
@@ -1,74 +0,0 @@-{-|-Module      : Database.MySQL.Connection-Description : Connection managment-Copyright   : (c) Winterland, 2016-License     : BSD-Maintainer  : drkoster@qq.com-Stability   : experimental-Portability : PORTABLE--This module provides secure MySQL connection using 'HsOpenSSL' package.---}--module Database.MySQL.OpenSSL-    ( connect-    , connectDetail-    , module Data.OpenSSLSetting-    ) where--import           Control.Exception              (bracketOnError, throwIO)-import           Control.Monad-import           Data.IORef                     (newIORef)-import           Database.MySQL.Connection      hiding (connect, connectDetail)-import           Database.MySQL.Protocol.Auth-import           Database.MySQL.Protocol.Packet-import qualified Network.Socket                 as N-import qualified OpenSSL                        as SSL-import qualified OpenSSL.X509                   as X509-import qualified OpenSSL.Session                as Session-import qualified System.IO.Streams              as Stream-import qualified System.IO.Streams.Binary       as Binary-import qualified System.IO.Streams.OpenSSL      as SSL-import qualified System.IO.Streams.TCP          as TCP-import           Data.OpenSSLSetting-------------------------------------------------------------------------------------- | Provide a 'Session.SSLContext' and a subject name to establish a TLS connection.----connect :: ConnectInfo -> (Session.SSLContext, String) -> IO MySQLConn-connect c cp = fmap snd (connectDetail c cp)--connectDetail :: ConnectInfo -> (Session.SSLContext, String) -> IO (Greeting, MySQLConn)-connectDetail (ConnectInfo host port db user pass) (ctx, subname) =-    bracketOnError (TCP.connectWithBufferSize host port bUFSIZE)-       (\(_, _, sock) -> N.close sock) $ \ (is, os, sock) -> do-            is' <- decodeInputStream is-            os' <- Binary.encodeOutputStream os-            p <- readPacket is'-            greet <- decodeFromPacket p-            if supportTLS (greetingCaps greet)-            then SSL.withOpenSSL $ do-                Stream.write (Just (encodeToPacket 1 sslRequest)) os'-                bracketOnError (Session.connection ctx sock) SSL.close $ \ ssl -> do-                    Session.connect ssl-                    trusted <- Session.getVerifyResult ssl-                    cert <- Session.getPeerCertificate ssl-                    subnames <- maybe (return []) (`X509.getSubjectName` False) cert-                    let cnname = lookup "CN" subnames-                        verified = maybe False (== subname) cnname-                    unless (trusted && verified) (throwIO $ Session.ProtocolError "fail to verify certificate")-                    (sslIs, sslOs) <- SSL.sslToStreams ssl-                    sslIs' <- decodeInputStream sslIs-                    sslOs' <- Binary.encodeOutputStream sslOs-                    let auth = mkAuth db user pass greet-                    Stream.write (Just (encodeToPacket 2 auth)) sslOs'-                    q <- readPacket sslIs'-                    if isOK q-                    then do-                        consumed <- newIORef True-                        let conn = MySQLConn sslIs' sslOs' (SSL.close ssl) consumed-                        return (greet, conn)-                    else Stream.write Nothing sslOs' >> decodeFromPacket q >>= throwIO . ERRException-            else error "Database.MySQL.OpenSSL: server doesn't support TLS connection"
Database/MySQL/Protocol/Auth.hs view
@@ -3,7 +3,7 @@  {-| Module      : Database.MySQL.Protocol.Auth-Description : MySQL field type+Description : MySQL Auth Packets Copyright   : (c) Winterland, 2016 License     : BSD Maintainer  : drkoster@qq.com
Database/MySQL/Protocol/Packet.hs view
@@ -2,7 +2,7 @@  {-| Module      : Database.MySQL.Protocol.Packet-Description : MySQL packet type+Description : MySQL packet type and various helpers. Copyright   : (c) Winterland, 2016 License     : BSD Maintainer  : drkoster@qq.com
Database/MySQL/TLS.hs view
@@ -1,6 +1,6 @@ {-| Module      : Database.MySQL.Connection-Description : Connection managment+Description : TLS support for mysql-haskell via @tls@ package. Copyright   : (c) Winterland, 2016 License     : BSD Maintainer  : drkoster@qq.com
README.md view
@@ -4,14 +4,16 @@ [![Hackage](https://img.shields.io/hackage/v/mysql-haskell.svg?style=flat)](http://hackage.haskell.org/package/mysql-haskell) [![Build Status](https://travis-ci.org/winterland1989/mysql-haskell.svg)](https://travis-ci.org/winterland1989/mysql-haskell) -`mysql-haskell` is a MySQL driver written entirely in haskell by @winterland1989 at infrastructure department of Didi group, it's going to be used in projects aiming at replacing old java based MySQL middlewares.+`mysql-haskell` is a MySQL driver written entirely in haskell. -This project is still in experimental stage and lack of produciton tests, use on your own risk, any form of contributions are welcomed!+<a href="http://www.genshuixue.com/"><img height=42 src='http://cdn.gsxservice.com/asset/img/logo-release2.png'></a>+<a href="http://chordify.net/"><img height=42 src='https://chordify.net/img/about/slide_250_1.jpg'></a>+<a href="http://www.didichuxing.com/"><img height=42 src='http://www.didichuxing.com/images/icon02.png'></a>  Is it fast? ---------- -In short, `select`(decode) is about 2 times slower than pure c/c++ but 5 times faster than `mysql-simple`, `insert` (encode) is about 1.5 times slower than pure c/c++, there're many factors involved(tls, prepared statment, batch using multiple statement):+In short, `select`(decode) is about 1.5 times slower than pure c/c++ but 5 times faster than `mysql-simple`, `insert` (encode) is about 1.5 times slower than pure c/c++, there're many factors involved(tls, prepared statment, batch using multiple statement):  <img src="https://github.com/winterland1989/mysql-haskell/blob/master/benchmark/result.png?raw=true" width="100%"> @@ -106,7 +108,7 @@ ```bash git clone https://github.com/winterland1989/mysql-haskell.git cd mysql-haskell-cabal install --only-dependencies+cabal install --enable-tests --only-dependencies cabal build ``` 
mysql-haskell.cabal view
@@ -1,5 +1,5 @@ name:                mysql-haskell-version:             0.6.0.0+version:             0.7.0.0 synopsis:            pure haskell MySQL driver description:         pure haskell MySQL driver license:             BSD3@@ -18,10 +18,6 @@   type:     git   location: git://github.com/winterland1989/mysql-haskell.git -flag openssl-  description:  Enable openssl support via @HsOpenSSL@-  default:      True- library     exposed-modules:    Database.MySQL.Base                     ,   Database.MySQL.TLS       @@ -35,17 +31,13 @@                     ,   Database.MySQL.BinLogProtocol.BinLogEvent                     ,   Database.MySQL.BinLogProtocol.BinLogValue                     ,   Database.MySQL.BinLogProtocol.BinLogMeta-    if flag(openssl)-        exposed-modules: Database.MySQL.OpenSSL---    other-modules:      Database.MySQL.Connection-                    ,   Database.MySQL.Query+                    ,   Database.MySQL.Connection+    other-modules:      Database.MySQL.Query     build-depends:      base          >= 4.7 && < 5                     ,   monad-loops   == 0.4.*                     ,   network       >= 2.3 && < 3.0                     ,   io-streams    >= 1.2 && < 2.0-                    ,   tcp-streams   >= 0.4 && < 0.6+                    ,   tcp-streams   >= 0.6 && < 0.7                     ,   wire-streams  >= 0.1                     ,   binary        == 0.8.*                     ,   binary-ieee754 == 0.1.*@@ -62,9 +54,6 @@                     ,   tls           >= 1.3.5 && < 1.4                     ,   vector        >= 0.8 -    if flag(openssl)-        build-depends:      HsOpenSSL      >=0.10.3 && <0.12-     default-language:    Haskell2010     default-extensions:     DeriveDataTypeable                         ,   DeriveGeneric@@ -86,7 +75,6 @@     build-depends:  mysql-haskell                   , base                   , bytestring-                  , optparse-applicative < 0.13                   , tasty == 0.11.*                   , tasty-hunit                   , text
test/Main.hs view
@@ -13,7 +13,7 @@ import           Database.MySQL.Base import           Database.MySQL.BinLog import           System.Environment-import qualified          System.IO.Streams as Stream+import qualified System.IO.Streams as Stream import           Test.Tasty import           Test.Tasty.HUnit import qualified TextRow