You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

163 lines
3.0 KiB

  1. // Go MySQL Driver - A MySQL-Driver for Go's database/sql package
  2. //
  3. // Copyright 2012 The Go-MySQL-Driver Authors. All rights reserved.
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public
  6. // License, v. 2.0. If a copy of the MPL was not distributed with this file,
  7. // You can obtain one at http://mozilla.org/MPL/2.0/.
  8. package mysql
  9. const (
  10. minProtocolVersion byte = 10
  11. maxPacketSize = 1<<24 - 1
  12. timeFormat = "2006-01-02 15:04:05.999999"
  13. )
  14. // MySQL constants documentation:
  15. // http://dev.mysql.com/doc/internals/en/client-server-protocol.html
  16. const (
  17. iOK byte = 0x00
  18. iLocalInFile byte = 0xfb
  19. iEOF byte = 0xfe
  20. iERR byte = 0xff
  21. )
  22. // https://dev.mysql.com/doc/internals/en/capability-flags.html#packet-Protocol::CapabilityFlags
  23. type clientFlag uint32
  24. const (
  25. clientLongPassword clientFlag = 1 << iota
  26. clientFoundRows
  27. clientLongFlag
  28. clientConnectWithDB
  29. clientNoSchema
  30. clientCompress
  31. clientODBC
  32. clientLocalFiles
  33. clientIgnoreSpace
  34. clientProtocol41
  35. clientInteractive
  36. clientSSL
  37. clientIgnoreSIGPIPE
  38. clientTransactions
  39. clientReserved
  40. clientSecureConn
  41. clientMultiStatements
  42. clientMultiResults
  43. clientPSMultiResults
  44. clientPluginAuth
  45. clientConnectAttrs
  46. clientPluginAuthLenEncClientData
  47. clientCanHandleExpiredPasswords
  48. clientSessionTrack
  49. clientDeprecateEOF
  50. )
  51. const (
  52. comQuit byte = iota + 1
  53. comInitDB
  54. comQuery
  55. comFieldList
  56. comCreateDB
  57. comDropDB
  58. comRefresh
  59. comShutdown
  60. comStatistics
  61. comProcessInfo
  62. comConnect
  63. comProcessKill
  64. comDebug
  65. comPing
  66. comTime
  67. comDelayedInsert
  68. comChangeUser
  69. comBinlogDump
  70. comTableDump
  71. comConnectOut
  72. comRegisterSlave
  73. comStmtPrepare
  74. comStmtExecute
  75. comStmtSendLongData
  76. comStmtClose
  77. comStmtReset
  78. comSetOption
  79. comStmtFetch
  80. )
  81. // https://dev.mysql.com/doc/internals/en/com-query-response.html#packet-Protocol::ColumnType
  82. const (
  83. fieldTypeDecimal byte = iota
  84. fieldTypeTiny
  85. fieldTypeShort
  86. fieldTypeLong
  87. fieldTypeFloat
  88. fieldTypeDouble
  89. fieldTypeNULL
  90. fieldTypeTimestamp
  91. fieldTypeLongLong
  92. fieldTypeInt24
  93. fieldTypeDate
  94. fieldTypeTime
  95. fieldTypeDateTime
  96. fieldTypeYear
  97. fieldTypeNewDate
  98. fieldTypeVarChar
  99. fieldTypeBit
  100. )
  101. const (
  102. fieldTypeJSON byte = iota + 0xf5
  103. fieldTypeNewDecimal
  104. fieldTypeEnum
  105. fieldTypeSet
  106. fieldTypeTinyBLOB
  107. fieldTypeMediumBLOB
  108. fieldTypeLongBLOB
  109. fieldTypeBLOB
  110. fieldTypeVarString
  111. fieldTypeString
  112. fieldTypeGeometry
  113. )
  114. type fieldFlag uint16
  115. const (
  116. flagNotNULL fieldFlag = 1 << iota
  117. flagPriKey
  118. flagUniqueKey
  119. flagMultipleKey
  120. flagBLOB
  121. flagUnsigned
  122. flagZeroFill
  123. flagBinary
  124. flagEnum
  125. flagAutoIncrement
  126. flagTimestamp
  127. flagSet
  128. flagUnknown1
  129. flagUnknown2
  130. flagUnknown3
  131. flagUnknown4
  132. )
  133. // http://dev.mysql.com/doc/internals/en/status-flags.html
  134. type statusFlag uint16
  135. const (
  136. statusInTrans statusFlag = 1 << iota
  137. statusInAutocommit
  138. statusReserved // Not in documentation
  139. statusMoreResultsExists
  140. statusNoGoodIndexUsed
  141. statusNoIndexUsed
  142. statusCursorExists
  143. statusLastRowSent
  144. statusDbDropped
  145. statusNoBackslashEscapes
  146. statusMetadataChanged
  147. statusQueryWasSlow
  148. statusPsOutParams
  149. statusInTransReadonly
  150. statusSessionStateChanged
  151. )