const.go 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. const (
  84. fieldTypeDecimal byte = iota
  85. fieldTypeTiny
  86. fieldTypeShort
  87. fieldTypeLong
  88. fieldTypeFloat
  89. fieldTypeDouble
  90. fieldTypeNULL
  91. fieldTypeTimestamp
  92. fieldTypeLongLong
  93. fieldTypeInt24
  94. fieldTypeDate
  95. fieldTypeTime
  96. fieldTypeDateTime
  97. fieldTypeYear
  98. fieldTypeNewDate
  99. fieldTypeVarChar
  100. fieldTypeBit
  101. )
  102. const (
  103. fieldTypeJSON byte = iota + 0xf5
  104. fieldTypeNewDecimal
  105. fieldTypeEnum
  106. fieldTypeSet
  107. fieldTypeTinyBLOB
  108. fieldTypeMediumBLOB
  109. fieldTypeLongBLOB
  110. fieldTypeBLOB
  111. fieldTypeVarString
  112. fieldTypeString
  113. fieldTypeGeometry
  114. )
  115. type fieldFlag uint16
  116. const (
  117. flagNotNULL fieldFlag = 1 << iota
  118. flagPriKey
  119. flagUniqueKey
  120. flagMultipleKey
  121. flagBLOB
  122. flagUnsigned
  123. flagZeroFill
  124. flagBinary
  125. flagEnum
  126. flagAutoIncrement
  127. flagTimestamp
  128. flagSet
  129. flagUnknown1
  130. flagUnknown2
  131. flagUnknown3
  132. flagUnknown4
  133. )
  134. // http://dev.mysql.com/doc/internals/en/status-flags.html
  135. type statusFlag uint16
  136. const (
  137. statusInTrans statusFlag = 1 << iota
  138. statusInAutocommit
  139. statusReserved // Not in documentation
  140. statusMoreResultsExists
  141. statusNoGoodIndexUsed
  142. statusNoIndexUsed
  143. statusCursorExists
  144. statusLastRowSent
  145. statusDbDropped
  146. statusNoBackslashEscapes
  147. statusMetadataChanged
  148. statusQueryWasSlow
  149. statusPsOutParams
  150. statusInTransReadonly
  151. statusSessionStateChanged
  152. )