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.

const.go 3.3KB

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