const.go 3.3 KB

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