const.go 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. package replication
  2. const (
  3. //we only support MySQL 5.0.0+ binlog format, maybe???
  4. MinBinlogVersion = 4
  5. )
  6. var (
  7. //binlog header [ fe `bin` ]
  8. BinLogFileHeader []byte = []byte{0xfe, 0x62, 0x69, 0x6e}
  9. SemiSyncIndicator byte = 0xef
  10. )
  11. const (
  12. LOG_EVENT_BINLOG_IN_USE_F uint16 = 0x0001
  13. LOG_EVENT_FORCED_ROTATE_F uint16 = 0x0002
  14. LOG_EVENT_THREAD_SPECIFIC_F uint16 = 0x0004
  15. LOG_EVENT_SUPPRESS_USE_F uint16 = 0x0008
  16. LOG_EVENT_UPDATE_TABLE_MAP_VERSION_F uint16 = 0x0010
  17. LOG_EVENT_ARTIFICIAL_F uint16 = 0x0020
  18. LOG_EVENT_RELAY_LOG_F uint16 = 0x0040
  19. LOG_EVENT_IGNORABLE_F uint16 = 0x0080
  20. LOG_EVENT_NO_FILTER_F uint16 = 0x0100
  21. LOG_EVENT_MTS_ISOLATE_F uint16 = 0x0200
  22. )
  23. const (
  24. BINLOG_DUMP_NEVER_STOP uint16 = 0x00
  25. BINLOG_DUMP_NON_BLOCK uint16 = 0x01
  26. BINLOG_THROUGH_POSITION uint16 = 0x02
  27. BINLOG_THROUGH_GTID uint16 = 0x04
  28. )
  29. const (
  30. BINLOG_ROW_IMAGE_FULL = "FULL"
  31. BINLOG_ROW_IAMGE_MINIMAL = "MINIMAL"
  32. BINLOG_ROW_IMAGE_NOBLOB = "NOBLOB"
  33. )
  34. type EventType byte
  35. const (
  36. UNKNOWN_EVENT EventType = iota
  37. START_EVENT_V3
  38. QUERY_EVENT
  39. STOP_EVENT
  40. ROTATE_EVENT
  41. INTVAR_EVENT
  42. LOAD_EVENT
  43. SLAVE_EVENT
  44. CREATE_FILE_EVENT
  45. APPEND_BLOCK_EVENT
  46. EXEC_LOAD_EVENT
  47. DELETE_FILE_EVENT
  48. NEW_LOAD_EVENT
  49. RAND_EVENT
  50. USER_VAR_EVENT
  51. FORMAT_DESCRIPTION_EVENT
  52. XID_EVENT
  53. BEGIN_LOAD_QUERY_EVENT
  54. EXECUTE_LOAD_QUERY_EVENT
  55. TABLE_MAP_EVENT
  56. WRITE_ROWS_EVENTv0
  57. UPDATE_ROWS_EVENTv0
  58. DELETE_ROWS_EVENTv0
  59. WRITE_ROWS_EVENTv1
  60. UPDATE_ROWS_EVENTv1
  61. DELETE_ROWS_EVENTv1
  62. INCIDENT_EVENT
  63. HEARTBEAT_EVENT
  64. IGNORABLE_EVENT
  65. ROWS_QUERY_EVENT
  66. WRITE_ROWS_EVENTv2
  67. UPDATE_ROWS_EVENTv2
  68. DELETE_ROWS_EVENTv2
  69. GTID_EVENT
  70. ANONYMOUS_GTID_EVENT
  71. PREVIOUS_GTIDS_EVENT
  72. )
  73. const (
  74. // MariaDB event starts from 160
  75. MARIADB_ANNOTATE_ROWS_EVENT EventType = 160 + iota
  76. MARIADB_BINLOG_CHECKPOINT_EVENT
  77. MARIADB_GTID_EVENT
  78. MARIADB_GTID_LIST_EVENT
  79. )
  80. func (e EventType) String() string {
  81. switch e {
  82. case UNKNOWN_EVENT:
  83. return "UnknownEvent"
  84. case START_EVENT_V3:
  85. return "StartEventV3"
  86. case QUERY_EVENT:
  87. return "QueryEvent"
  88. case STOP_EVENT:
  89. return "StopEvent"
  90. case ROTATE_EVENT:
  91. return "RotateEvent"
  92. case INTVAR_EVENT:
  93. return "IntVarEvent"
  94. case LOAD_EVENT:
  95. return "LoadEvent"
  96. case SLAVE_EVENT:
  97. return "SlaveEvent"
  98. case CREATE_FILE_EVENT:
  99. return "CreateFileEvent"
  100. case APPEND_BLOCK_EVENT:
  101. return "AppendBlockEvent"
  102. case EXEC_LOAD_EVENT:
  103. return "ExecLoadEvent"
  104. case DELETE_FILE_EVENT:
  105. return "DeleteFileEvent"
  106. case NEW_LOAD_EVENT:
  107. return "NewLoadEvent"
  108. case RAND_EVENT:
  109. return "RandEvent"
  110. case USER_VAR_EVENT:
  111. return "UserVarEvent"
  112. case FORMAT_DESCRIPTION_EVENT:
  113. return "FormatDescriptionEvent"
  114. case XID_EVENT:
  115. return "XIDEvent"
  116. case BEGIN_LOAD_QUERY_EVENT:
  117. return "BeginLoadQueryEvent"
  118. case EXECUTE_LOAD_QUERY_EVENT:
  119. return "ExectueLoadQueryEvent"
  120. case TABLE_MAP_EVENT:
  121. return "TableMapEvent"
  122. case WRITE_ROWS_EVENTv0:
  123. return "WriteRowsEventV0"
  124. case UPDATE_ROWS_EVENTv0:
  125. return "UpdateRowsEventV0"
  126. case DELETE_ROWS_EVENTv0:
  127. return "DeleteRowsEventV0"
  128. case WRITE_ROWS_EVENTv1:
  129. return "WriteRowsEventV1"
  130. case UPDATE_ROWS_EVENTv1:
  131. return "UpdateRowsEventV1"
  132. case DELETE_ROWS_EVENTv1:
  133. return "DeleteRowsEventV1"
  134. case INCIDENT_EVENT:
  135. return "IncidentEvent"
  136. case HEARTBEAT_EVENT:
  137. return "HeartbeatEvent"
  138. case IGNORABLE_EVENT:
  139. return "IgnorableEvent"
  140. case ROWS_QUERY_EVENT:
  141. return "RowsQueryEvent"
  142. case WRITE_ROWS_EVENTv2:
  143. return "WriteRowsEventV2"
  144. case UPDATE_ROWS_EVENTv2:
  145. return "UpdateRowsEventV2"
  146. case DELETE_ROWS_EVENTv2:
  147. return "DeleteRowsEventV2"
  148. case GTID_EVENT:
  149. return "GTIDEvent"
  150. case ANONYMOUS_GTID_EVENT:
  151. return "AnonymousGTIDEvent"
  152. case PREVIOUS_GTIDS_EVENT:
  153. return "PreviousGTIDsEvent"
  154. case MARIADB_ANNOTATE_ROWS_EVENT:
  155. return "MariadbAnnotateRowsEvent"
  156. case MARIADB_BINLOG_CHECKPOINT_EVENT:
  157. return "MariadbBinLogCheckPointEvent"
  158. case MARIADB_GTID_EVENT:
  159. return "MariadbGTIDEvent"
  160. case MARIADB_GTID_LIST_EVENT:
  161. return "MariadbGTIDListEvent"
  162. default:
  163. return "UnknownEvent"
  164. }
  165. }
  166. const (
  167. BINLOG_CHECKSUM_ALG_OFF byte = 0 // Events are without checksum though its generator
  168. // is checksum-capable New Master (NM).
  169. BINLOG_CHECKSUM_ALG_CRC32 byte = 1 // CRC32 of zlib algorithm.
  170. // BINLOG_CHECKSUM_ALG_ENUM_END, // the cut line: valid alg range is [1, 0x7f].
  171. BINLOG_CHECKSUM_ALG_UNDEF byte = 255 // special value to tag undetermined yet checksum
  172. // or events from checksum-unaware servers
  173. )