| Copyright | (c) Winterland, 2016 |
|---|---|
| License | BSD |
| Maintainer | drkoster@qq.com |
| Stability | experimental |
| Portability | PORTABLE |
| Safe Haskell | None |
| Language | Haskell2010 |
Database.MySQL.BinLogProtocol.BinLogValue
Description
Binlog protocol
- data BinLogValue
- = BinLogTiny !Int8
- | BinLogShort !Int16
- | BinLogInt24 !Int24
- | BinLogLong !Int32
- | BinLogLongLong !Int64
- | BinLogFloat !Float
- | BinLogDouble !Double
- | BinLogBit !Word64
- | BinLogTimeStamp !Word32
- | BinLogTimeStamp2 !Word32 !Word32
- | BinLogDateTime !Word16 !Word8 !Word8 !Word8 !Word8 !Word8
- | BinLogDateTime2 !Word16 !Word8 !Word8 !Word8 !Word8 !Word8 !Word32
- | BinLogDate !Word16 !Word8 !Word8
- | BinLogTime !Word8 !Word16 !Word8 !Word8
- | BinLogTime2 !Word8 !Word16 !Word8 !Word8 !Word32
- | BinLogYear !Word16
- | BinLogNewDecimal !Scientific
- | BinLogEnum !Word16
- | BinLogSet !Word64
- | BinLogBytes !ByteString
- | BinLogGeometry !ByteString
- | BinLogNull
- getBinLogField :: BinLogMeta -> Get BinLogValue
- getMicroSecond :: Word8 -> Get Int32
- getBits' :: Word8 -> Get Word64
- getBinLogRow :: [BinLogMeta] -> BitMap -> Get [BinLogValue]
Documentation
data BinLogValue Source #
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 TINY,SHORT,INT,LONG. If you have unsigned columns, use fromIntegral to convert it to word to get real unsigned value back, for example, fromIntegral (-1 :: Int) == 255 :: Word
For above reason, we use Int24 to present MySQL's INT24 type, you can get back the unsigned value using word24 package's Word24 type.
Timestamp types(BinLogTimeStamp and BinLogTimeStamp2) are values converted into UTC already, see MySQLVaule 's note.
There's also no infomation about charset, so we use ByteString 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 SET and ENUM 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.
Constructors
| BinLogTiny !Int8 | |
| BinLogShort !Int16 | |
| BinLogInt24 !Int24 | |
| BinLogLong !Int32 | |
| BinLogLongLong !Int64 | |
| BinLogFloat !Float | |
| BinLogDouble !Double | |
| BinLogBit !Word64 | a 64bit bitmap. |
| BinLogTimeStamp !Word32 | a utc timestamp, note 0 doesn't mean |
| BinLogTimeStamp2 !Word32 !Word32 | like |
| BinLogDateTime !Word16 !Word8 !Word8 !Word8 !Word8 !Word8 | YYYY MM DD hh mm ss |
| BinLogDateTime2 !Word16 !Word8 !Word8 !Word8 !Word8 !Word8 !Word32 | YYYY MM DD hh mm ss microsecond |
| BinLogDate !Word16 !Word8 !Word8 | YYYY MM DD |
| BinLogTime !Word8 !Word16 !Word8 !Word8 | sign(1= non-negative, 0= negative) hh mm ss |
| BinLogTime2 !Word8 !Word16 !Word8 !Word8 !Word32 | sign(1= non-negative, 0= negative) hh mm ss microsecond |
| BinLogYear !Word16 | year value, 0 stand for '0000' |
| BinLogNewDecimal !Scientific | sign(1= non-negative, 0= negative) integeral part, fractional part |
| BinLogEnum !Word16 | enum indexing value |
| BinLogSet !Word64 | set indexing 64bit bitmap. |
| BinLogBytes !ByteString | all string and blob values. |
| BinLogGeometry !ByteString | |
| BinLogNull |
Instances
getBinLogField :: BinLogMeta -> Get BinLogValue Source #
BinLog protocol decoder
getBinLogRow :: [BinLogMeta] -> BitMap -> Get [BinLogValue] Source #
BinLog row decoder