const.go 3.1 KB

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