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