-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | pure haskell MySQL driver
--   
--   pure haskell MySQL driver
@package mysql-haskell
@version 0.8.3.0


-- | This module provide escape machinery for bytes and text types.
--   
--   reference:
--   <a>http://dev.mysql.com/doc/refman/5.7/en/string-literals.html</a>
--   
--   <ul>
--   <li>Escape Sequence Character Represented by Sequence</li>
--   <li>0 An ASCII NUL (X'00') character</li>
--   <li>' A single quote (“'”) character</li>
--   <li>" A double quote (“"”) character</li>
--   <li>b A backspace character</li>
--   <li>n A newline (linefeed) character</li>
--   <li>r A carriage return character</li>
--   <li>t A tab character</li>
--   <li>Z ASCII 26 (Control+Z); see note following the table</li>
--   <li>\ A backslash (“”) character</li>
--   <li>% A “%” character; see note following the table</li>
--   <li>_ A “_” character; see note following the table</li>
--   </ul>
--   
--   The <tt>%</tt> and <tt>_</tt> sequences are used to search for literal
--   instances of <tt>%</tt> and <tt>_</tt> in pattern-matching contexts
--   where they would otherwise be interpreted as wildcard characters, so
--   we won't auto escape <tt>%</tt> or <tt>_</tt> here.
module Database.MySQL.Protocol.Escape
escapeText :: Text -> Text
escapeBytes :: ByteString -> ByteString


-- | MySQL packet decoder&amp;encoder, and varities utility.
module Database.MySQL.Protocol.Packet

-- | MySQL packet type
data Packet
Packet :: !Int64 -> !Word8 -> !ByteString -> Packet
[pLen] :: Packet -> !Int64
[pSeqN] :: Packet -> !Word8
[pBody] :: Packet -> !ByteString
putPacket :: Packet -> Put
getPacket :: Get Packet
isERR :: Packet -> Bool
isOK :: Packet -> Bool
isEOF :: Packet -> Bool

-- | Decoding packet inside IO, throw <a>DecodePacketException</a> on fail
--   parsing, here we choose stability over correctness by omit incomplete
--   consumed case: if we successful parse a packet, then we don't care if
--   there're bytes left.
decodeFromPacket :: Binary a => Packet -> IO a
getFromPacket :: Get a -> Packet -> IO a
data DecodePacketException
DecodePacketFailed :: ByteString -> ByteOffset -> String -> DecodePacketException
encodeToPacket :: Binary a => Word8 -> a -> Packet
putToPacket :: Word8 -> Put -> Packet

-- | You may get interested in <a>OK</a> packet because it provides
--   information about successful operations.
data OK
OK :: !Int -> !Int -> !Word16 -> !Word16 -> OK

-- | affected row number
[okAffectedRows] :: OK -> !Int

-- | last insert's ID
[okLastInsertID] :: OK -> !Int
[okStatus] :: OK -> !Word16
[okWarningCnt] :: OK -> !Word16
getOK :: Get OK
putOK :: OK -> Put
data ERR
ERR :: !Word16 -> !ByteString -> !ByteString -> ERR
[errCode] :: ERR -> !Word16
[errState] :: ERR -> !ByteString
[errMsg] :: ERR -> !ByteString
getERR :: Get ERR
putERR :: ERR -> Put
data EOF
EOF :: !Word16 -> !Word16 -> EOF
[eofWarningCnt] :: EOF -> !Word16
[eofStatus] :: EOF -> !Word16
getEOF :: Get EOF
putEOF :: EOF -> Put
getByteStringNul :: Get ByteString
getRemainingByteString :: Get ByteString
putLenEncBytes :: ByteString -> Put
getLenEncBytes :: Get ByteString

-- | length encoded int
--   <a>https://dev.mysql.com/doc/internals/en/integer.html#packet-Protocol::LengthEncodedInteger</a>
getLenEncInt :: Get Int
putLenEncInt :: Int -> Put
putWord24le :: Word32 -> Put
getWord24le :: Get Word32
putWord48le :: Word64 -> Put
getWord48le :: Get Word64
getWord24be :: Get Word24
getInt24be :: Get Int24
getWord40be :: Get Word64
getWord48be :: Get Word64
getWord56be :: Get Word64
instance GHC.Classes.Eq Database.MySQL.Protocol.Packet.EOF
instance GHC.Show.Show Database.MySQL.Protocol.Packet.EOF
instance GHC.Classes.Eq Database.MySQL.Protocol.Packet.ERR
instance GHC.Show.Show Database.MySQL.Protocol.Packet.ERR
instance GHC.Classes.Eq Database.MySQL.Protocol.Packet.OK
instance GHC.Show.Show Database.MySQL.Protocol.Packet.OK
instance GHC.Show.Show Database.MySQL.Protocol.Packet.DecodePacketException
instance GHC.Classes.Eq Database.MySQL.Protocol.Packet.Packet
instance GHC.Show.Show Database.MySQL.Protocol.Packet.Packet
instance Data.Binary.Class.Binary Database.MySQL.Protocol.Packet.EOF
instance Data.Binary.Class.Binary Database.MySQL.Protocol.Packet.ERR
instance Data.Binary.Class.Binary Database.MySQL.Protocol.Packet.OK
instance GHC.Exception.Exception Database.MySQL.Protocol.Packet.DecodePacketException
instance Data.Binary.Class.Binary Database.MySQL.Protocol.Packet.Packet


-- | Column definition(aka. field type).
module Database.MySQL.Protocol.ColumnDef

-- | A description of a field (column) of a table.
data ColumnDef
ColumnDef :: !ByteString -> !ByteString -> !ByteString -> !ByteString -> !ByteString -> !Word16 -> !Word32 -> !FieldType -> !Word16 -> !Word8 -> ColumnDef

-- | Database for table.
[columnDB] :: ColumnDef -> !ByteString

-- | Table of column, if column was a field.
[columnTable] :: ColumnDef -> !ByteString

-- | Original table name, if table was an alias.
[columnOrigTable] :: ColumnDef -> !ByteString

-- | Name of column.
[columnName] :: ColumnDef -> !ByteString

-- | Original column name, if an alias.
[columnOrigName] :: ColumnDef -> !ByteString

-- | Character set number.
[columnCharSet] :: ColumnDef -> !Word16

-- | Width of column (create length).
[columnLength] :: ColumnDef -> !Word32
[columnType] :: ColumnDef -> !FieldType

-- | Div flags.
[columnFlags] :: ColumnDef -> !Word16

-- | Number of decimals in field.
[columnDecimals] :: ColumnDef -> !Word8
getField :: Get ColumnDef
putField :: ColumnDef -> Put

-- | <tt>newtype</tt> around <a>Word8</a> for represent
--   <tt>MySQL_TYPE</tt>, We don't use sum type here for speed reason.
newtype FieldType
FieldType :: Word8 -> FieldType
mySQLTypeDecimal :: FieldType
mySQLTypeTiny :: FieldType
mySQLTypeShort :: FieldType
mySQLTypeLong :: FieldType
mySQLTypeFloat :: FieldType
mySQLTypeDouble :: FieldType
mySQLTypeNull :: FieldType
mySQLTypeTimestamp :: FieldType
mySQLTypeLongLong :: FieldType
mySQLTypeInt24 :: FieldType
mySQLTypeDate :: FieldType
mySQLTypeTime :: FieldType
mySQLTypeDateTime :: FieldType
mySQLTypeYear :: FieldType
mySQLTypeNewDate :: FieldType
mySQLTypeVarChar :: FieldType
mySQLTypeBit :: FieldType
mySQLTypeTimestamp2 :: FieldType
mySQLTypeDateTime2 :: FieldType
mySQLTypeTime2 :: FieldType
mySQLTypeNewDecimal :: FieldType
mySQLTypeEnum :: FieldType
mySQLTypeSet :: FieldType
mySQLTypeTinyBlob :: FieldType
mySQLTypeMediumBlob :: FieldType
mySQLTypeLongBlob :: FieldType
mySQLTypeBlob :: FieldType
mySQLTypeVarString :: FieldType
mySQLTypeString :: FieldType
mySQLTypeGeometry :: FieldType
getFieldType :: Get FieldType
putFieldType :: FieldType -> Put
flagNotNull :: Word16 -> Bool
flagPrimaryKey :: Word16 -> Bool
flagUniqueKey :: Word16 -> Bool
flagMultipleKey :: Word16 -> Bool
flagBlob :: Word16 -> Bool
flagUnsigned :: Word16 -> Bool
flagZeroFill :: Word16 -> Bool
flagBinary :: Word16 -> Bool
flagEnum :: Word16 -> Bool
flagAutoIncrement :: Word16 -> Bool
flagTimeStamp :: Word16 -> Bool
flagSet :: Word16 -> Bool
flagNoDefaultValue :: Word16 -> Bool
flagPartKey :: Word16 -> Bool
flagNumeric :: Word16 -> Bool
instance GHC.Classes.Eq Database.MySQL.Protocol.ColumnDef.ColumnDef
instance GHC.Show.Show Database.MySQL.Protocol.ColumnDef.ColumnDef
instance GHC.Classes.Eq Database.MySQL.Protocol.ColumnDef.FieldType
instance GHC.Show.Show Database.MySQL.Protocol.ColumnDef.FieldType
instance Data.Binary.Class.Binary Database.MySQL.Protocol.ColumnDef.ColumnDef
instance Data.Binary.Class.Binary Database.MySQL.Protocol.ColumnDef.FieldType


-- | Core text and binary row decoder/encoder machinery.
module Database.MySQL.Protocol.MySQLValue

-- | Data type mapping between MySQL values and haskell values.
--   
--   There're some subtle differences between MySQL values and haskell
--   values:
--   
--   MySQL's <tt>DATETIME</tt> and <tt>TIMESTAMP</tt> are different on
--   timezone handling:
--   
--   <ul>
--   <li>DATETIME and DATE is just a represent of a calendar date, it has
--   no timezone information involved, you always get the same value as you
--   put no matter what timezone you're using with MySQL.</li>
--   <li>MySQL converts TIMESTAMP values from the current time zone to UTC
--   for storage, and back from UTC to the current time zone for retrieval.
--   If you put a TIMESTAMP with timezone A, then read it with timezone B,
--   you may get different result because of this conversion, so always be
--   careful about setting up the right timezone with MySQL, you can do it
--   with a simple <tt>SET time_zone = timezone;</tt> for more info on
--   timezone support, please read
--   <a>http://dev.mysql.com/doc/refman/5.7/en/time-zone-support.html</a></li>
--   </ul>
--   
--   So we use <a>LocalTime</a> to present both <tt>DATETIME</tt> and
--   <tt>TIMESTAMP</tt>, but the local here is different.
--   
--   MySQL's <tt>TIME</tt> type can present time of day, but also elapsed
--   time or a time interval between two events. <tt>TIME</tt> values may
--   range from <tt>-838:59:59</tt> to <tt>838:59:59</tt>, so
--   <a>MySQLTime</a> values consist of a sign and a <a>TimeOfDay</a> whose
--   hour part may exceeded 24. you can use <tt>timeOfDayToTime</tt> to get
--   the absolute time interval.
--   
--   Under MySQL &gt;= 5.7, <tt>DATETIME</tt>, <tt>TIMESTAMP</tt> and
--   <tt>TIME</tt> may contain fractional part, which matches haskell's
--   precision.
data MySQLValue

-- | DECIMAL, NEWDECIMAL
MySQLDecimal :: !Scientific -> MySQLValue

-- | Unsigned TINY
MySQLInt8U :: !Word8 -> MySQLValue

-- | TINY
MySQLInt8 :: !Int8 -> MySQLValue

-- | Unsigned SHORT
MySQLInt16U :: !Word16 -> MySQLValue

-- | SHORT
MySQLInt16 :: !Int16 -> MySQLValue

-- | Unsigned LONG, INT24
MySQLInt32U :: !Word32 -> MySQLValue

-- | LONG, INT24
MySQLInt32 :: !Int32 -> MySQLValue

-- | Unsigned LONGLONG
MySQLInt64U :: !Word64 -> MySQLValue

-- | LONGLONG
MySQLInt64 :: !Int64 -> MySQLValue

-- | IEEE 754 single precision format
MySQLFloat :: !Float -> MySQLValue

-- | IEEE 754 double precision format
MySQLDouble :: !Double -> MySQLValue

-- | YEAR
MySQLYear :: !Word16 -> MySQLValue

-- | DATETIME
MySQLDateTime :: !LocalTime -> MySQLValue

-- | TIMESTAMP
MySQLTimeStamp :: !LocalTime -> MySQLValue

-- | DATE
MySQLDate :: !Day -> MySQLValue

-- | sign(0 = non-negative, 1 = negative) hh mm ss microsecond The sign is
--   OPPOSITE to binlog one !!!
MySQLTime :: !Word8 -> !TimeOfDay -> MySQLValue

-- | todo: parsing to something meanful
MySQLGeometry :: !ByteString -> MySQLValue
MySQLBytes :: !ByteString -> MySQLValue
MySQLBit :: !Word64 -> MySQLValue
MySQLText :: !Text -> MySQLValue
MySQLNull :: MySQLValue

-- | Put <a>FieldType</a> and usigned bit(0x80/0x00) for
--   <a>MySQLValue</a>s.
putParamMySQLType :: MySQLValue -> Put

-- | Text protocol decoder
getTextField :: ColumnDef -> Get MySQLValue

-- | Text protocol encoder
putTextField :: MySQLValue -> Put

-- | Text row decoder
getTextRow :: [ColumnDef] -> Get [MySQLValue]
getTextRowVector :: Vector ColumnDef -> Get (Vector MySQLValue)

-- | Binary protocol decoder
getBinaryField :: ColumnDef -> Get MySQLValue

-- | Binary protocol encoder
putBinaryField :: MySQLValue -> Put

-- | Binary row decoder
--   
--   MySQL use a special null bitmap without offset = 2 here.
getBinaryRow :: [ColumnDef] -> Int -> Get [MySQLValue]
getBinaryRowVector :: Vector ColumnDef -> Int -> Get (Vector MySQLValue)

-- | Get a bit sequence as a Word64
--   
--   Since <a>Word64</a> has a <tt>Bits</tt> instance, it's easier to deal
--   with in haskell.
getBits :: Int -> Get Word64

-- | Use <a>ByteString</a> to present a bitmap.
--   
--   When used for represent bits values, the underlining <a>ByteString</a>
--   follows:
--   
--   <ul>
--   <li>byteString: head -&gt; tail</li>
--   <li>bit: high bit -&gt; low bit</li>
--   </ul>
--   
--   When used as a null-map/present-map, every bit inside a byte is mapped
--   to a column, the mapping order is following:
--   
--   <ul>
--   <li>byteString: head -&gt; tail</li>
--   <li>column: left -&gt; right</li>
--   </ul>
--   
--   We don't use <a>Int64</a> here because there maybe more than 64
--   columns.
newtype BitMap
BitMap :: ByteString -> BitMap
[fromBitMap] :: BitMap -> ByteString

-- | Test if a column is set(binlog protocol).
--   
--   The number counts from left to right.
isColumnSet :: BitMap -> Int -> Bool

-- | Test if a column is null(binary protocol).
--   
--   The number counts from left to right.
isColumnNull :: BitMap -> Int -> Bool

-- | Make a nullmap for params(binary protocol) without offset.
makeNullMap :: [MySQLValue] -> BitMap
instance GHC.Show.Show Database.MySQL.Protocol.MySQLValue.BitMap
instance GHC.Classes.Eq Database.MySQL.Protocol.MySQLValue.BitMap
instance GHC.Generics.Generic Database.MySQL.Protocol.MySQLValue.MySQLValue
instance GHC.Classes.Eq Database.MySQL.Protocol.MySQLValue.MySQLValue
instance GHC.Show.Show Database.MySQL.Protocol.MySQLValue.MySQLValue


-- | Common MySQL commands supports.
module Database.MySQL.Protocol.Command
type StmtID = Word32

-- | All support MySQL commands.
data Command

-- | 0x01
COM_QUIT :: Command

-- | 0x02
COM_INIT_DB :: !ByteString -> Command

-- | 0x03
COM_QUERY :: !ByteString -> Command

-- | 0x0E
COM_PING :: Command

-- | 0x12 binlog-pos, flags(0x01), server-id, binlog-filename
COM_BINLOG_DUMP :: !Word32 -> !Word16 -> !Word32 -> !ByteString -> Command

-- | 0x15 server-id, slaves hostname, slaves user, slaves password, slaves
--   port, replication rank(ignored), master-id(usually 0)
COM_REGISTER_SLAVE :: !Word32 -> !ByteString -> !ByteString -> !ByteString -> !Word16 -> !Word32 -> !Word32 -> Command

-- | 0x16 statement
COM_STMT_PREPARE :: !ByteString -> Command

-- | 0x17 stmtId, params
COM_STMT_EXECUTE :: !StmtID -> ![MySQLValue] -> !BitMap -> Command

-- | 0x19 stmtId
COM_STMT_CLOSE :: !StmtID -> Command

-- | 0x1A stmtId
COM_STMT_RESET :: !StmtID -> Command
COM_UNSUPPORTED :: Command
putCommand :: Command -> Put

-- | call <a>isOK</a> with this packet return true
data StmtPrepareOK
StmtPrepareOK :: !StmtID -> !Int -> !Int -> !Int -> StmtPrepareOK
[stmtId] :: StmtPrepareOK -> !StmtID
[stmtColumnCnt] :: StmtPrepareOK -> !Int
[stmtParamCnt] :: StmtPrepareOK -> !Int
[stmtWarnCnt] :: StmtPrepareOK -> !Int
getStmtPrepareOK :: Get StmtPrepareOK
instance GHC.Classes.Eq Database.MySQL.Protocol.Command.StmtPrepareOK
instance GHC.Show.Show Database.MySQL.Protocol.Command.StmtPrepareOK
instance GHC.Classes.Eq Database.MySQL.Protocol.Command.Command
instance GHC.Show.Show Database.MySQL.Protocol.Command.Command


-- | This module provide column meta decoder for binlog protocol.
--   
--   There're certain type won't appear in binlog event, and some types are
--   compressed into <a>mySQLTypeString</a> , please take python version as
--   a reference: <a>https://github.com/noplay/python-mysql-replication</a>
--   
--   You will not directly meet following <a>FieldType</a> namely:
--   
--   <ul>
--   <li>mySQLTypeDecimal</li>
--   <li>mySQLTypeNewdate</li>
--   <li>mySQLTypeEnum</li>
--   <li>mySQLTypeSet</li>
--   <li>mySQLTypeTinyBlob</li>
--   <li>mySQLTypeMediumBlOb</li>
--   <li>mySQLTypeLongBlob</li>
--   </ul>
module Database.MySQL.BinLogProtocol.BinLogMeta

-- | An intermedia date type for decoding row-based event's values.
data BinLogMeta
BINLOG_TYPE_TINY :: BinLogMeta
BINLOG_TYPE_SHORT :: BinLogMeta
BINLOG_TYPE_INT24 :: BinLogMeta
BINLOG_TYPE_LONG :: BinLogMeta
BINLOG_TYPE_LONGLONG :: BinLogMeta

-- | size
BINLOG_TYPE_FLOAT :: !Word8 -> BinLogMeta

-- | size
BINLOG_TYPE_DOUBLE :: !Word8 -> BinLogMeta

-- | bits, bytes
BINLOG_TYPE_BIT :: !Word16 -> !Word8 -> BinLogMeta
BINLOG_TYPE_TIMESTAMP :: BinLogMeta
BINLOG_TYPE_DATETIME :: BinLogMeta
BINLOG_TYPE_DATE :: BinLogMeta
BINLOG_TYPE_TIME :: BinLogMeta

-- | fsp
BINLOG_TYPE_TIMESTAMP2 :: !Word8 -> BinLogMeta

-- | fsp
BINLOG_TYPE_DATETIME2 :: !Word8 -> BinLogMeta

-- | fsp
BINLOG_TYPE_TIME2 :: !Word8 -> BinLogMeta
BINLOG_TYPE_YEAR :: BinLogMeta

-- | precision, scale
BINLOG_TYPE_NEWDECIMAL :: !Word8 -> !Word8 -> BinLogMeta

-- | 1 or 2(<a>Word8</a> or <a>Word16</a>), enum index size
BINLOG_TYPE_ENUM :: !Word8 -> BinLogMeta

-- | bitmap bits, bytes
BINLOG_TYPE_SET :: !Word16 -> !Word8 -> BinLogMeta

-- | length size
BINLOG_TYPE_BLOB :: !Word8 -> BinLogMeta

-- | meta length(if &lt; 256, then length is 8bit, if &gt; 256 then length
--   is 16bit)
BINLOG_TYPE_STRING :: !Word16 -> BinLogMeta

-- | length size
BINLOG_TYPE_GEOMETRY :: !Word8 -> BinLogMeta
getBinLogMeta :: FieldType -> Get BinLogMeta
instance GHC.Classes.Eq Database.MySQL.BinLogProtocol.BinLogMeta.BinLogMeta
instance GHC.Show.Show Database.MySQL.BinLogProtocol.BinLogMeta.BinLogMeta


-- | Auth related packet.
module Database.MySQL.Protocol.Auth
data Greeting
Greeting :: !Word8 -> !ByteString -> !Word32 -> !ByteString -> !Word32 -> !Word8 -> !Word16 -> !ByteString -> !ByteString -> Greeting
[greetingProtocol] :: Greeting -> !Word8
[greetingVersion] :: Greeting -> !ByteString
[greetingConnId] :: Greeting -> !Word32
[greetingSalt1] :: Greeting -> !ByteString
[greetingCaps] :: Greeting -> !Word32
[greetingCharset] :: Greeting -> !Word8
[greetingStatus] :: Greeting -> !Word16
[greetingSalt2] :: Greeting -> !ByteString
[greetingAuthPlugin] :: Greeting -> !ByteString
putGreeting :: Greeting -> Put
getGreeting :: Get Greeting
data Auth
Auth :: !Word32 -> !Word32 -> !Word8 -> !ByteString -> !ByteString -> !ByteString -> Auth
[authCaps] :: Auth -> !Word32
[authMaxPacket] :: Auth -> !Word32
[authCharset] :: Auth -> !Word8
[authName] :: Auth -> !ByteString
[authPassword] :: Auth -> !ByteString
[authSchema] :: Auth -> !ByteString
getAuth :: Get Auth
putAuth :: Auth -> Put
data SSLRequest
SSLRequest :: !Word32 -> !Word32 -> !Word8 -> SSLRequest
[sslReqCaps] :: SSLRequest -> !Word32
[sslReqMaxPacket] :: SSLRequest -> !Word32
[sslReqCharset] :: SSLRequest -> !Word8
getSSLRequest :: Get SSLRequest
putSSLRequest :: SSLRequest -> Put
clientCap :: Word32
clientMaxPacketSize :: Word32
supportTLS :: Word32 -> Bool
sslRequest :: Word8 -> SSLRequest
instance GHC.Classes.Eq Database.MySQL.Protocol.Auth.SSLRequest
instance GHC.Show.Show Database.MySQL.Protocol.Auth.SSLRequest
instance GHC.Classes.Eq Database.MySQL.Protocol.Auth.Auth
instance GHC.Show.Show Database.MySQL.Protocol.Auth.Auth
instance GHC.Classes.Eq Database.MySQL.Protocol.Auth.Greeting
instance GHC.Show.Show Database.MySQL.Protocol.Auth.Greeting
instance Data.Binary.Class.Binary Database.MySQL.Protocol.Auth.SSLRequest
instance Data.Binary.Class.Binary Database.MySQL.Protocol.Auth.Auth
instance Data.Binary.Class.Binary Database.MySQL.Protocol.Auth.Greeting


-- | This is an internal module, the <a>MySQLConn</a> type should not
--   directly acessed to user.
module Database.MySQL.Connection

-- | <a>MySQLConn</a> wrap both <a>InputStream</a> and
--   <tt>OutputStream</tt> for MySQL <a>Packet</a>.
--   
--   You shouldn't use one <a>MySQLConn</a> in different thread, if you do
--   that, consider protecting it with a <tt>MVar</tt>.
data MySQLConn
MySQLConn :: {-# UNPACK #-} !(InputStream Packet) -> (Packet -> IO ()) -> IO () -> {-# UNPACK #-} !(IORef Bool) -> MySQLConn
[mysqlRead] :: MySQLConn -> {-# UNPACK #-} !(InputStream Packet)
[mysqlWrite] :: MySQLConn -> (Packet -> IO ())
[mysqlCloseSocket] :: MySQLConn -> IO ()
[isConsumed] :: MySQLConn -> {-# UNPACK #-} !(IORef Bool)

-- | Everything you need to establish a MySQL connection.
--   
--   To setup a TLS connection, use module <a>Database.MySQL.TLS</a> or
--   <a>Database.MySQL.OpenSSL</a>.
data ConnectInfo
ConnectInfo :: HostName -> PortNumber -> ByteString -> ByteString -> ByteString -> Word8 -> ConnectInfo
[ciHost] :: ConnectInfo -> HostName
[ciPort] :: ConnectInfo -> PortNumber
[ciDatabase] :: ConnectInfo -> ByteString
[ciUser] :: ConnectInfo -> ByteString
[ciPassword] :: ConnectInfo -> ByteString
[ciCharset] :: ConnectInfo -> Word8

-- | A simple <a>ConnectInfo</a> targeting localhost with
--   <tt>user=root</tt> and empty password.
--   
--   Default charset is set to <tt>utf8_general_ci</tt> to support
--   older(&lt; 5.5.3) MySQL versions, but be aware this is a partial utf8
--   encoding, you may want to use <a>defaultConnectInfoMB4</a> instead to
--   support full utf8 charset(emoji, etc.). You can query your server's
--   support with <tt>SELECT id, collation_name FROM
--   information_schema.collations ORDER BY id;</tt>
defaultConnectInfo :: ConnectInfo

-- | <a>defaultConnectInfo</a> with charset set to
--   <tt>utf8mb4_unicode_ci</tt>
--   
--   This is recommanded on any MySQL server version &gt;= 5.5.3.
defaultConnectInfoMB4 :: ConnectInfo
utf8_general_ci :: Word8
utf8mb4_unicode_ci :: Word8

-- | Socket buffer size.
--   
--   maybe exposed to <a>ConnectInfo</a> laster?
bUFSIZE :: Int

-- | Establish a MySQL connection.
connect :: ConnectInfo -> IO MySQLConn

-- | Establish a MySQL connection with <a>Greeting</a> back, so you can
--   find server's version .etc.
connectDetail :: ConnectInfo -> IO (Greeting, MySQLConn)
mkAuth :: ByteString -> ByteString -> ByteString -> Word8 -> Greeting -> Auth

-- | A specialized <a>decodeInputStream</a> here for speed
decodeInputStream :: InputStream ByteString -> IO (InputStream Packet)

-- | Close a MySQL connection.
close :: MySQLConn -> IO ()

-- | Send a <a>COM_PING</a>.
ping :: MySQLConn -> IO OK

-- | Send a <a>Command</a> which don't return a resultSet.
command :: MySQLConn -> Command -> IO OK
waitCommandReply :: InputStream Packet -> IO OK
readPacket :: InputStream Packet -> IO Packet
writeCommand :: Command -> (Packet -> IO ()) -> IO ()
guardUnconsumed :: MySQLConn -> IO ()
writeIORef' :: IORef a -> a -> IO ()
data NetworkException
NetworkException :: NetworkException
data UnconsumedResultSet
UnconsumedResultSet :: UnconsumedResultSet
data ERRException
ERRException :: ERR -> ERRException
data UnexpectedPacket
UnexpectedPacket :: Packet -> UnexpectedPacket
instance GHC.Show.Show Database.MySQL.Connection.UnexpectedPacket
instance GHC.Show.Show Database.MySQL.Connection.ERRException
instance GHC.Show.Show Database.MySQL.Connection.UnconsumedResultSet
instance GHC.Show.Show Database.MySQL.Connection.NetworkException
instance GHC.Show.Show Database.MySQL.Connection.ConnectInfo
instance GHC.Exception.Exception Database.MySQL.Connection.UnexpectedPacket
instance GHC.Exception.Exception Database.MySQL.Connection.ERRException
instance GHC.Exception.Exception Database.MySQL.Connection.UnconsumedResultSet
instance GHC.Exception.Exception Database.MySQL.Connection.NetworkException


-- | Binlog protocol
module Database.MySQL.BinLogProtocol.BinLogValue

-- | Data type for representing binlog values.
--   
--   This data type DOES NOT try to parse binlog values into detailed
--   haskell values, because you may not want to waste performance in
--   situations like database middleware.
--   
--   Due to the lack of signedness infomation in binlog meta, we cannot
--   distinguish, for example, between unsigned tiny 255 and tiny -1, so we
--   use int to present <tt>TINY,SHORT,INT,LONG</tt>. If you have unsigned
--   columns, use <a>fromIntegral</a> to convert it to word to get real
--   unsigned value back, for example, <tt>fromIntegral (-1 :: Int) == 255
--   :: Word</tt>
--   
--   For above reason, we use <a>Int24</a> to present MySQL's
--   <tt>INT24</tt> type, you can get back the unsigned value using
--   <tt>word24</tt> package's <tt>Word24</tt> type.
--   
--   Timestamp types(<a>BinLogTimeStamp</a> and <a>BinLogTimeStamp2</a>)
--   are values converted into UTC already, see <tt>MySQLVaule</tt> 's
--   note.
--   
--   There's also no infomation about charset, so we use <a>ByteString</a>
--   to present both text and blob types, if you want to get text
--   representation back, you have to query column charset infomation, and
--   use icu or iconv to decode. IT MAY NOT BE UTF-8.
--   
--   The <tt>SET</tt> and <tt>ENUM</tt> values are presented by their
--   index's value and bitmap respectively, if you need get the string
--   value back, you have to perform a 'DESC tablename' to get the set or
--   enum table.
data BinLogValue
BinLogTiny :: !Int8 -> BinLogValue
BinLogShort :: !Int16 -> BinLogValue
BinLogInt24 :: !Int24 -> BinLogValue
BinLogLong :: !Int32 -> BinLogValue
BinLogLongLong :: !Int64 -> BinLogValue
BinLogFloat :: !Float -> BinLogValue
BinLogDouble :: !Double -> BinLogValue

-- | a 64bit bitmap.
BinLogBit :: !Word64 -> BinLogValue

-- | a utc timestamp, note 0 doesn't mean <tt>1970-01-01 00:00:00</tt>,
--   because mysql choose 0 to present '0000-00-00 00:00:00'
BinLogTimeStamp :: !Word32 -> BinLogValue

-- | like <a>BinLogTimeStamp</a> with an addtional microseconds field.
BinLogTimeStamp2 :: !Word32 -> !Word32 -> BinLogValue

-- | YYYY MM DD hh mm ss
BinLogDateTime :: !Word16 -> !Word8 -> !Word8 -> !Word8 -> !Word8 -> !Word8 -> BinLogValue

-- | YYYY MM DD hh mm ss microsecond
BinLogDateTime2 :: !Word16 -> !Word8 -> !Word8 -> !Word8 -> !Word8 -> !Word8 -> !Word32 -> BinLogValue

-- | YYYY MM DD
BinLogDate :: !Word16 -> !Word8 -> !Word8 -> BinLogValue

-- | sign(1= non-negative, 0= negative) hh mm ss
BinLogTime :: !Word8 -> !Word16 -> !Word8 -> !Word8 -> BinLogValue

-- | sign(1= non-negative, 0= negative) hh mm ss microsecond
BinLogTime2 :: !Word8 -> !Word16 -> !Word8 -> !Word8 -> !Word32 -> BinLogValue

-- | year value, 0 stand for '0000'
BinLogYear :: !Word16 -> BinLogValue

-- | sign(1= non-negative, 0= negative) integeral part, fractional part
BinLogNewDecimal :: !Scientific -> BinLogValue

-- | enum indexing value
BinLogEnum :: !Word16 -> BinLogValue

-- | set indexing 64bit bitmap.
BinLogSet :: !Word64 -> BinLogValue

-- | all string and blob values.
BinLogBytes :: !ByteString -> BinLogValue
BinLogGeometry :: !ByteString -> BinLogValue
BinLogNull :: BinLogValue

-- | BinLog protocol decoder
getBinLogField :: BinLogMeta -> Get BinLogValue
getMicroSecond :: Word8 -> Get Int32
getBits' :: Word8 -> Get Word64

-- | BinLog row decoder
getBinLogRow :: [BinLogMeta] -> BitMap -> Get [BinLogValue]
instance GHC.Generics.Generic Database.MySQL.BinLogProtocol.BinLogValue.BinLogValue
instance GHC.Classes.Eq Database.MySQL.BinLogProtocol.BinLogValue.BinLogValue
instance GHC.Show.Show Database.MySQL.BinLogProtocol.BinLogValue.BinLogValue


-- | Binlog event type
module Database.MySQL.BinLogProtocol.BinLogEvent

-- | binlog tyoe
data BinLogEventType
BINLOG_UNKNOWN_EVENT :: BinLogEventType
BINLOG_START_EVENT_V3 :: BinLogEventType
BINLOG_QUERY_EVENT :: BinLogEventType
BINLOG_STOP_EVENT :: BinLogEventType
BINLOG_ROTATE_EVENT :: BinLogEventType
BINLOG_INTVAR_EVENT :: BinLogEventType
BINLOG_LOAD_EVENT :: BinLogEventType
BINLOG_SLAVE_EVENT :: BinLogEventType
BINLOG_CREATE_FILE_EVENT :: BinLogEventType
BINLOG_APPEND_BLOCK_EVENT :: BinLogEventType
BINLOG_EXEC_LOAD_EVENT :: BinLogEventType
BINLOG_DELETE_FILE_EVENT :: BinLogEventType
BINLOG_NEW_LOAD_EVENT :: BinLogEventType
BINLOG_RAND_EVENT :: BinLogEventType
BINLOG_USER_VAR_EVENT :: BinLogEventType
BINLOG_FORMAT_DESCRIPTION_EVENT :: BinLogEventType
BINLOG_XID_EVENT :: BinLogEventType
BINLOG_BEGIN_LOAD_QUERY_EVENT :: BinLogEventType
BINLOG_EXECUTE_LOAD_QUERY_EVENT :: BinLogEventType
BINLOG_TABLE_MAP_EVENT :: BinLogEventType
BINLOG_WRITE_ROWS_EVENTv0 :: BinLogEventType
BINLOG_UPDATE_ROWS_EVENTv0 :: BinLogEventType
BINLOG_DELETE_ROWS_EVENTv0 :: BinLogEventType
BINLOG_WRITE_ROWS_EVENTv1 :: BinLogEventType
BINLOG_UPDATE_ROWS_EVENTv1 :: BinLogEventType
BINLOG_DELETE_ROWS_EVENTv1 :: BinLogEventType
BINLOG_INCIDENT_EVENT :: BinLogEventType
BINLOG_HEARTBEAT_EVENT :: BinLogEventType
BINLOG_IGNORABLE_EVENT :: BinLogEventType
BINLOG_ROWS_QUERY_EVENT :: BinLogEventType
BINLOG_WRITE_ROWS_EVENTv2 :: BinLogEventType
BINLOG_UPDATE_ROWS_EVENTv2 :: BinLogEventType
BINLOG_DELETE_ROWS_EVENTv2 :: BinLogEventType
BINLOG_GTID_EVENT :: BinLogEventType
BINLOG_ANONYMOUS_GTID_EVENT :: BinLogEventType
BINLOG_PREVIOUS_GTIDS_EVENT :: BinLogEventType
data BinLogPacket
BinLogPacket :: !Word32 -> !BinLogEventType -> !Word32 -> !Word32 -> !Word64 -> !Word16 -> !ByteString -> !Bool -> BinLogPacket
[blTimestamp] :: BinLogPacket -> !Word32
[blEventType] :: BinLogPacket -> !BinLogEventType
[blServerId] :: BinLogPacket -> !Word32
[blEventSize] :: BinLogPacket -> !Word32

-- | for future GTID compatibility
[blLogPos] :: BinLogPacket -> !Word64
[blFlags] :: BinLogPacket -> !Word16
[blBody] :: BinLogPacket -> !ByteString
[blSemiAck] :: BinLogPacket -> !Bool
putSemiAckResp :: Word32 -> ByteString -> Put
getBinLogPacket :: Bool -> Bool -> Get BinLogPacket
getFromBinLogPacket :: Get a -> BinLogPacket -> IO a
getFromBinLogPacket' :: (BinLogEventType -> Get a) -> BinLogPacket -> IO a
data FormatDescription
FormatDescription :: !Word16 -> !ByteString -> !Word32 -> !ByteString -> FormatDescription
[fdVersion] :: FormatDescription -> !Word16
[fdMySQLVersion] :: FormatDescription -> !ByteString
[fdCreateTime] :: FormatDescription -> !Word32

-- | a array indexed by Binlog Event Type - 1 to extract the length of the
--   event specific header.
[fdEventHeaderLenVector] :: FormatDescription -> !ByteString
getFormatDescription :: Get FormatDescription
eventHeaderLen :: FormatDescription -> BinLogEventType -> Word8
data RotateEvent
RotateEvent :: !Word64 -> !ByteString -> RotateEvent
[rPos] :: RotateEvent -> !Word64
[rFileName] :: RotateEvent -> !ByteString
getRotateEvent :: Get RotateEvent

-- | This's query parser for statement based binlog's query event, it's
--   actually not used in row based binlog.
data QueryEvent
QueryEvent :: !Word32 -> !Word32 -> !Word16 -> !ByteString -> !ByteString -> !Query -> QueryEvent
[qSlaveProxyId] :: QueryEvent -> !Word32
[qExecTime] :: QueryEvent -> !Word32
[qErrCode] :: QueryEvent -> !Word16
[qStatusVars] :: QueryEvent -> !ByteString
[qSchemaName] :: QueryEvent -> !ByteString
[qQuery] :: QueryEvent -> !Query
getQueryEvent :: Get QueryEvent

-- | This's the query event in row based binlog.
data QueryEvent'
QueryEvent' :: !Query -> QueryEvent'
[qQuery'] :: QueryEvent' -> !Query
getQueryEvent' :: Get QueryEvent'
data TableMapEvent
TableMapEvent :: !Word64 -> !Word16 -> !ByteString -> !ByteString -> !Int -> ![FieldType] -> ![BinLogMeta] -> !ByteString -> TableMapEvent
[tmTableId] :: TableMapEvent -> !Word64
[tmFlags] :: TableMapEvent -> !Word16
[tmSchemaName] :: TableMapEvent -> !ByteString
[tmTableName] :: TableMapEvent -> !ByteString
[tmColumnCnt] :: TableMapEvent -> !Int
[tmColumnType] :: TableMapEvent -> ![FieldType]
[tmColumnMeta] :: TableMapEvent -> ![BinLogMeta]
[tmNullMap] :: TableMapEvent -> !ByteString
getTableMapEvent :: FormatDescription -> Get TableMapEvent
data DeleteRowsEvent
DeleteRowsEvent :: !Word64 -> !Word16 -> !Int -> !BitMap -> ![[BinLogValue]] -> DeleteRowsEvent
[deleteTableId] :: DeleteRowsEvent -> !Word64
[deleteFlags] :: DeleteRowsEvent -> !Word16
[deleteColumnCnt] :: DeleteRowsEvent -> !Int
[deletePresentMap] :: DeleteRowsEvent -> !BitMap
[deleteRowData] :: DeleteRowsEvent -> ![[BinLogValue]]
getDeleteRowEvent :: FormatDescription -> TableMapEvent -> BinLogEventType -> Get DeleteRowsEvent
data WriteRowsEvent
WriteRowsEvent :: !Word64 -> !Word16 -> !Int -> !BitMap -> ![[BinLogValue]] -> WriteRowsEvent
[writeTableId] :: WriteRowsEvent -> !Word64
[writeFlags] :: WriteRowsEvent -> !Word16
[writeColumnCnt] :: WriteRowsEvent -> !Int
[writePresentMap] :: WriteRowsEvent -> !BitMap
[writeRowData] :: WriteRowsEvent -> ![[BinLogValue]]
getWriteRowEvent :: FormatDescription -> TableMapEvent -> BinLogEventType -> Get WriteRowsEvent
data UpdateRowsEvent
UpdateRowsEvent :: !Word64 -> !Word16 -> !Int -> !(BitMap, BitMap) -> ![([BinLogValue], [BinLogValue])] -> UpdateRowsEvent
[updateTableId] :: UpdateRowsEvent -> !Word64
[updateFlags] :: UpdateRowsEvent -> !Word16
[updateColumnCnt] :: UpdateRowsEvent -> !Int
[updatePresentMap] :: UpdateRowsEvent -> !(BitMap, BitMap)
[updateRowData] :: UpdateRowsEvent -> ![([BinLogValue], [BinLogValue])]
getUpdateRowEvent :: FormatDescription -> TableMapEvent -> BinLogEventType -> Get UpdateRowsEvent
getPresentMap :: Int -> Int -> Get BitMap
instance GHC.Generics.Generic Database.MySQL.BinLogProtocol.BinLogEvent.UpdateRowsEvent
instance GHC.Classes.Eq Database.MySQL.BinLogProtocol.BinLogEvent.UpdateRowsEvent
instance GHC.Show.Show Database.MySQL.BinLogProtocol.BinLogEvent.UpdateRowsEvent
instance GHC.Generics.Generic Database.MySQL.BinLogProtocol.BinLogEvent.WriteRowsEvent
instance GHC.Classes.Eq Database.MySQL.BinLogProtocol.BinLogEvent.WriteRowsEvent
instance GHC.Show.Show Database.MySQL.BinLogProtocol.BinLogEvent.WriteRowsEvent
instance GHC.Generics.Generic Database.MySQL.BinLogProtocol.BinLogEvent.DeleteRowsEvent
instance GHC.Classes.Eq Database.MySQL.BinLogProtocol.BinLogEvent.DeleteRowsEvent
instance GHC.Show.Show Database.MySQL.BinLogProtocol.BinLogEvent.DeleteRowsEvent
instance GHC.Generics.Generic Database.MySQL.BinLogProtocol.BinLogEvent.TableMapEvent
instance GHC.Classes.Eq Database.MySQL.BinLogProtocol.BinLogEvent.TableMapEvent
instance GHC.Show.Show Database.MySQL.BinLogProtocol.BinLogEvent.TableMapEvent
instance GHC.Classes.Eq Database.MySQL.BinLogProtocol.BinLogEvent.QueryEvent'
instance GHC.Show.Show Database.MySQL.BinLogProtocol.BinLogEvent.QueryEvent'
instance GHC.Generics.Generic Database.MySQL.BinLogProtocol.BinLogEvent.QueryEvent
instance GHC.Classes.Eq Database.MySQL.BinLogProtocol.BinLogEvent.QueryEvent
instance GHC.Show.Show Database.MySQL.BinLogProtocol.BinLogEvent.QueryEvent
instance GHC.Classes.Eq Database.MySQL.BinLogProtocol.BinLogEvent.RotateEvent
instance GHC.Show.Show Database.MySQL.BinLogProtocol.BinLogEvent.RotateEvent
instance GHC.Generics.Generic Database.MySQL.BinLogProtocol.BinLogEvent.FormatDescription
instance GHC.Classes.Eq Database.MySQL.BinLogProtocol.BinLogEvent.FormatDescription
instance GHC.Show.Show Database.MySQL.BinLogProtocol.BinLogEvent.FormatDescription
instance GHC.Classes.Eq Database.MySQL.BinLogProtocol.BinLogEvent.BinLogPacket
instance GHC.Show.Show Database.MySQL.BinLogProtocol.BinLogEvent.BinLogPacket
instance GHC.Enum.Enum Database.MySQL.BinLogProtocol.BinLogEvent.BinLogEventType
instance GHC.Classes.Eq Database.MySQL.BinLogProtocol.BinLogEvent.BinLogEventType
instance GHC.Show.Show Database.MySQL.BinLogProtocol.BinLogEvent.BinLogEventType


-- | This module provide common MySQL operations,
--   
--   NOTEs on <tt>Exception</tt>s: This package use <tt>Exception</tt> to
--   deal with unexpected situations, but you shouldn't try to catch them
--   if you don't have a recovery plan, for example: there's no meaning to
--   catch a <a>ERRException</a> during authentication unless you want to
--   try different passwords. By using this library you will meet:
--   
--   <ul>
--   <li><a>NetworkException</a>: underline network is broken.</li>
--   <li><a>UnconsumedResultSet</a>: you should consume previous resultset
--   before sending new command.</li>
--   <li><a>ERRException</a>: you receive a <a>ERR</a> packet when you
--   shouldn't.</li>
--   <li><a>UnexpectedPacket</a>: you receive a unexpected packet when you
--   shouldn't.</li>
--   <li><a>DecodePacketException</a>: there's a packet we can't
--   decode.</li>
--   <li><a>WrongParamsCount</a>: you're giving wrong number of params to
--   <a>renderParams</a>.</li>
--   </ul>
--   
--   Both <a>UnexpectedPacket</a> and <a>DecodePacketException</a> may
--   indicate a bug of this library rather your code, so please report!
module Database.MySQL.Base

-- | <a>MySQLConn</a> wrap both <a>InputStream</a> and
--   <tt>OutputStream</tt> for MySQL <a>Packet</a>.
--   
--   You shouldn't use one <a>MySQLConn</a> in different thread, if you do
--   that, consider protecting it with a <tt>MVar</tt>.
data MySQLConn

-- | Everything you need to establish a MySQL connection.
--   
--   To setup a TLS connection, use module <a>Database.MySQL.TLS</a> or
--   <a>Database.MySQL.OpenSSL</a>.
data ConnectInfo
ConnectInfo :: HostName -> PortNumber -> ByteString -> ByteString -> ByteString -> Word8 -> ConnectInfo
[ciHost] :: ConnectInfo -> HostName
[ciPort] :: ConnectInfo -> PortNumber
[ciDatabase] :: ConnectInfo -> ByteString
[ciUser] :: ConnectInfo -> ByteString
[ciPassword] :: ConnectInfo -> ByteString
[ciCharset] :: ConnectInfo -> Word8

-- | A simple <a>ConnectInfo</a> targeting localhost with
--   <tt>user=root</tt> and empty password.
--   
--   Default charset is set to <tt>utf8_general_ci</tt> to support
--   older(&lt; 5.5.3) MySQL versions, but be aware this is a partial utf8
--   encoding, you may want to use <a>defaultConnectInfoMB4</a> instead to
--   support full utf8 charset(emoji, etc.). You can query your server's
--   support with <tt>SELECT id, collation_name FROM
--   information_schema.collations ORDER BY id;</tt>
defaultConnectInfo :: ConnectInfo

-- | <a>defaultConnectInfo</a> with charset set to
--   <tt>utf8mb4_unicode_ci</tt>
--   
--   This is recommanded on any MySQL server version &gt;= 5.5.3.
defaultConnectInfoMB4 :: ConnectInfo

-- | Establish a MySQL connection.
connect :: ConnectInfo -> IO MySQLConn

-- | Establish a MySQL connection with <a>Greeting</a> back, so you can
--   find server's version .etc.
connectDetail :: ConnectInfo -> IO (Greeting, MySQLConn)

-- | Close a MySQL connection.
close :: MySQLConn -> IO ()

-- | Send a <a>COM_PING</a>.
ping :: MySQLConn -> IO OK

-- | Execute a MySQL query with parameters which don't return a result-set.
--   
--   The query may contain placeholders <tt>?</tt>, for filling up
--   parameters, the parameters will be escaped before get filled into the
--   query, please DO NOT enable <tt>NO_BACKSLASH_ESCAPES</tt>, and you
--   should consider using prepared statement if this's not an one shot
--   query.
execute :: QueryParam p => MySQLConn -> Query -> [p] -> IO OK

-- | Execute a multi-row query which don't return result-set.
--   
--   Leverage MySQL's multi-statement support to do batch
--   insert/update/delete, you may want to use <a>withTransaction</a> to
--   make sure it's atomic, and use <tt>sum . map okAffectedRows</tt> to
--   get all affected rows count.
executeMany :: QueryParam p => MySQLConn -> Query -> [[p]] -> IO [OK]

-- | Execute a MySQL query which don't return a result-set.
execute_ :: MySQLConn -> Query -> IO OK

-- | Execute a MySQL query which return a result-set.
query_ :: MySQLConn -> Query -> IO ([ColumnDef], InputStream [MySQLValue])

-- | <a>Vector</a> version of <a>query_</a>.
queryVector_ :: MySQLConn -> Query -> IO (Vector ColumnDef, InputStream (Vector MySQLValue))

-- | Execute a MySQL query which return a result-set with parameters.
--   
--   Note that you must fully consumed the result-set before start a new
--   query on the same <a>MySQLConn</a>, or an <a>UnconsumedResultSet</a>
--   will be thrown. if you want to skip the result-set, use
--   <a>skipToEof</a>.
query :: QueryParam p => MySQLConn -> Query -> [p] -> IO ([ColumnDef], InputStream [MySQLValue])

-- | <a>Vector</a> version of <a>query</a>.
queryVector :: QueryParam p => MySQLConn -> Query -> [p] -> IO (Vector ColumnDef, InputStream (Vector MySQLValue))

-- | Ask MySQL to prepare a query statement.
prepareStmt :: MySQLConn -> Query -> IO StmtID

-- | Ask MySQL to prepare a query statement.
--   
--   All details from <tt>COM_STMT_PREPARE</tt> Response are returned: the
--   <a>StmtPrepareOK</a> packet, params's <a>ColumnDef</a>, result's
--   <a>ColumnDef</a>.
prepareStmtDetail :: MySQLConn -> Query -> IO (StmtPrepareOK, [ColumnDef], [ColumnDef])

-- | Execute prepared query statement with parameters, expecting no
--   resultset.
executeStmt :: MySQLConn -> StmtID -> [MySQLValue] -> IO OK

-- | Execute prepared query statement with parameters, expecting resultset.
--   
--   Rules about <a>UnconsumedResultSet</a> applied here too.
queryStmt :: MySQLConn -> StmtID -> [MySQLValue] -> IO ([ColumnDef], InputStream [MySQLValue])

-- | <a>Vector</a> version of <a>queryStmt</a>
queryStmtVector :: MySQLConn -> StmtID -> [MySQLValue] -> IO (Vector ColumnDef, InputStream (Vector MySQLValue))

-- | Ask MySQL to closed a query statement.
closeStmt :: MySQLConn -> StmtID -> IO ()

-- | Ask MySQL to reset a query statement, all previous resultset will be
--   cleared.
resetStmt :: MySQLConn -> StmtID -> IO ()

-- | Run querys inside a transaction, querys will be rolled back if
--   exception arise.
withTransaction :: MySQLConn -> IO a -> IO a

-- | A type that may be used as a single parameter to a SQL query. Inspired
--   from <tt>mysql-simple</tt>.
class QueryParam a

-- | Prepare a value for substitution into a query string.
render :: QueryParam a => a -> Put

-- | A type to wrap a query parameter in to allow for single and
--   multi-valued parameters.
--   
--   The behavior of <a>Param</a> can be illustrated by following example:
--   
--   <pre>
--   render $ One (MySQLText "hello") = hello
--   render $ Many [MySQLText "hello", MySQLText "world"] = hello, world
--   render $ Many [] = null
--   </pre>
--   
--   So you can now write a query like this: <tt> SELECT * FROM test WHERE
--   _id IN (?, 888) </tt> and use <a>Many</a> <a>Param</a> to fill the
--   hole. There's no equivalent for prepared statement sadly.
data Param
One :: MySQLValue -> Param
Many :: [MySQLValue] -> Param

-- | Query string type borrowed from <tt>mysql-simple</tt>.
--   
--   This type is intended to make it difficult to construct a SQL query by
--   concatenating string fragments, as that is an extremely common way to
--   accidentally introduce SQL injection vulnerabilities into an
--   application.
--   
--   This type is an instance of <a>IsString</a>, so the easiest way to
--   construct a query is to enable the <tt>OverloadedStrings</tt> language
--   extension and then simply write the query in double quotes.
--   
--   The underlying type is a <a>ByteString</a>, and literal Haskell
--   strings that contain Unicode characters will be correctly transformed
--   to UTF-8.
newtype Query
Query :: ByteString -> Query
[fromQuery] :: Query -> ByteString
renderParams :: QueryParam p => Query -> [p] -> Query

-- | Send a <a>Command</a> which don't return a resultSet.
command :: MySQLConn -> Command -> IO OK

-- | Drives an <a>InputStream</a> to end-of-stream, discarding all of the
--   yielded values.
skipToEof :: () => InputStream a -> IO ()
data NetworkException
NetworkException :: NetworkException
data UnconsumedResultSet
UnconsumedResultSet :: UnconsumedResultSet
data ERRException
ERRException :: ERR -> ERRException
data UnexpectedPacket
UnexpectedPacket :: Packet -> UnexpectedPacket
data DecodePacketException
DecodePacketFailed :: ByteString -> ByteOffset -> String -> DecodePacketException
data WrongParamsCount
WrongParamsCount :: WrongParamsCount


-- | This module provide tools for binlog listening and row based binlog
--   decoding.
module Database.MySQL.BinLog
type SlaveID = Word32

-- | binlog filename and position to start listening.
data BinLogTracker
BinLogTracker :: {-# UNPACK #-} !ByteString -> {-# UNPACK #-} !Word32 -> BinLogTracker
[btFileName] :: BinLogTracker -> {-# UNPACK #-} !ByteString
[btNextPos] :: BinLogTracker -> {-# UNPACK #-} !Word32

-- | Register a pesudo slave to master, although MySQL document suggests
--   you should call this before calling <a>dumpBinLog</a>, but it seems
--   it's not really necessary.
registerPesudoSlave :: MySQLConn -> SlaveID -> IO OK

-- | Setup binlog listening on given connection, during listening the
--   connection CAN NOT be used to do query, or an
--   <a>UnconsumedResultSet</a> will be thrown.
dumpBinLog :: MySQLConn -> SlaveID -> BinLogTracker -> Bool -> IO (FormatDescription, IORef ByteString, InputStream BinLogPacket)

-- | Row based binlog event type.
--   
--   It's recommended to enable row query event before <a>dumpBinLog</a>,
--   so that you can get <a>RowQueryEvent</a> in row based binlog(it's
--   important for detect a table change for example), more information
--   please refer <a>sysvar_binlog_rows_query_log_events</a>
--   
--   A <a>BinLogTracker</a> is included so that you can roll up your own HA
--   solutions, for example, writing the tracker to zookeeper when you done
--   with an event.
--   
--   The first <a>Word32</a> field is a timestamp present when this event
--   is logged.
data RowBinLogEvent
RowQueryEvent :: {-# UNPACK #-} !Word32 -> !BinLogTracker -> !QueryEvent' -> RowBinLogEvent
RowDeleteEvent :: {-# UNPACK #-} !Word32 -> !BinLogTracker -> !TableMapEvent -> !DeleteRowsEvent -> RowBinLogEvent
RowWriteEvent :: {-# UNPACK #-} !Word32 -> !BinLogTracker -> !TableMapEvent -> !WriteRowsEvent -> RowBinLogEvent
RowUpdateEvent :: {-# UNPACK #-} !Word32 -> !BinLogTracker -> !TableMapEvent -> !UpdateRowsEvent -> RowBinLogEvent

-- | decode row based event from <a>BinLogPacket</a> stream.
decodeRowBinLogEvent :: (FormatDescription, IORef ByteString, InputStream BinLogPacket) -> IO (InputStream RowBinLogEvent)

-- | Get latest master's binlog filename and position.
getLastBinLogTracker :: MySQLConn -> IO (Maybe BinLogTracker)

-- | Return True if binlog_checksum = CRC32. Only for MySQL &gt; 5.6
isCheckSumEnabled :: MySQLConn -> IO Bool

-- | Return True if rpl_semi_sync_master_enabled = ON. Only for MySQL &gt;
--   5.5
isSemiSyncEnabled :: MySQLConn -> IO Bool
instance GHC.Generics.Generic Database.MySQL.BinLog.RowBinLogEvent
instance GHC.Classes.Eq Database.MySQL.BinLog.RowBinLogEvent
instance GHC.Show.Show Database.MySQL.BinLog.RowBinLogEvent
instance GHC.Generics.Generic Database.MySQL.BinLog.BinLogTracker
instance GHC.Classes.Eq Database.MySQL.BinLog.BinLogTracker
instance GHC.Show.Show Database.MySQL.BinLog.BinLogTracker


-- | This module provides secure MySQL connection using <tt>tls</tt>
--   package, please make sure your certificate is v3 extension enabled.
module Database.MySQL.TLS

-- | Provide a <a>ClientParams</a> and a subject name to establish a TLS
--   connection.
connect :: ConnectInfo -> (ClientParams, String) -> IO MySQLConn
connectDetail :: ConnectInfo -> (ClientParams, String) -> IO (Greeting, MySQLConn)
