github.com/insionng/yougam@v0.0.0-20170714101924-2bc18d833463/libraries/pingcap/tidb/mysql/const.go (about) 1 // Copyright 2015 PingCAP, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // See the License for the specific language governing permissions and 12 // limitations under the License. 13 14 package mysql 15 16 // Version informations. 17 const ( 18 MinProtocolVersion byte = 10 19 MaxPayloadLen int = 1<<24 - 1 20 ServerVersion string = "5.5.31-TiDB-1.0" 21 ) 22 23 // Header informations. 24 const ( 25 OKHeader byte = 0x00 26 ErrHeader byte = 0xff 27 EOFHeader byte = 0xfe 28 LocalInFileHeader byte = 0xfb 29 ) 30 31 // Server informations. 32 const ( 33 ServerStatusInTrans uint16 = 0x0001 34 ServerStatusAutocommit uint16 = 0x0002 35 ServerMoreResultsExists uint16 = 0x0008 36 ServerStatusNoGoodIndexUsed uint16 = 0x0010 37 ServerStatusNoIndexUsed uint16 = 0x0020 38 ServerStatusCursorExists uint16 = 0x0040 39 ServerStatusLastRowSend uint16 = 0x0080 40 ServerStatusDBDropped uint16 = 0x0100 41 ServerStatusNoBackslashEscaped uint16 = 0x0200 42 ServerStatusMetadataChanged uint16 = 0x0400 43 ServerStatusWasSlow uint16 = 0x0800 44 ServerPSOutParams uint16 = 0x1000 45 ) 46 47 // Command informations. 48 const ( 49 ComSleep byte = iota 50 ComQuit 51 ComInitDB 52 ComQuery 53 ComFieldList 54 ComCreateDB 55 ComDropDB 56 ComRefresh 57 ComShutdown 58 ComStatistics 59 ComProcessInfo 60 ComConnect 61 ComProcessKill 62 ComDebug 63 ComPing 64 ComTime 65 ComDelayedInsert 66 ComChangeUser 67 ComBinlogDump 68 ComTableDump 69 ComConnectOut 70 ComRegisterSlave 71 ComStmtPrepare 72 ComStmtExecute 73 ComStmtSendLongData 74 ComStmtClose 75 ComStmtReset 76 ComSetOption 77 ComStmtFetch 78 ComDaemon 79 ComBinlogDumpGtid 80 ComResetConnection 81 ) 82 83 // Client informations. 84 const ( 85 ClientLongPassword uint32 = 1 << iota 86 ClientFoundRows 87 ClientLongFlag 88 ClientConnectWithDB 89 ClientNoSchema 90 ClientCompress 91 ClientODBC 92 ClientLocalFiles 93 ClientIgnoreSpace 94 ClientProtocol41 95 ClientInteractive 96 ClientSSL 97 ClientIgnoreSigpipe 98 ClientTransactions 99 ClientReserved 100 ClientSecureConnection 101 ClientMultiStatements 102 ClientMultiResults 103 ClientPSMultiResults 104 ClientPluginAuth 105 ClientConnectAtts 106 ClientPluginAuthLenencClientData 107 ) 108 109 // Cache type informations. 110 const ( 111 TypeNoCache byte = 0xff 112 ) 113 114 // Auth name informations. 115 const ( 116 AuthName = "mysql_native_password" 117 ) 118 119 // MySQL database and tables. 120 const ( 121 // SystemDB is the name of system database. 122 SystemDB = "mysql" 123 // UserTable is the table in system db contains user info. 124 UserTable = "User" 125 // DBTable is the table in system db contains db scope privilege info. 126 DBTable = "DB" 127 // TablePrivTable is the table in system db contains table scope privilege info. 128 TablePrivTable = "Tables_priv" 129 // ColumnPrivTable is the table in system db contains column scope privilege info. 130 ColumnPrivTable = "Columns_priv" 131 // GlobalVariablesTable is the table contains global system variables. 132 GlobalVariablesTable = "GLOBAL_VARIABLES" 133 // GlobalStatusTable is the table contains global status variables. 134 GlobalStatusTable = "GLOBAL_STATUS" 135 // TiDBTable is the table contains tidb info. 136 TiDBTable = "tidb" 137 ) 138 139 // PrivilegeType privilege 140 type PrivilegeType uint32 141 142 const ( 143 _ PrivilegeType = 1 << iota 144 // CreatePriv is the privilege to create schema/table. 145 CreatePriv 146 // SelectPriv is the privilege to read from table. 147 SelectPriv 148 // InsertPriv is the privilege to insert data into table. 149 InsertPriv 150 // UpdatePriv is the privilege to update data in table. 151 UpdatePriv 152 // DeletePriv is the privilege to delete data from table. 153 DeletePriv 154 // ShowDBPriv is the privilege to run show databases statement. 155 ShowDBPriv 156 // CreateUserPriv is the privilege to create user. 157 CreateUserPriv 158 // DropPriv is the privilege to drop schema/table. 159 DropPriv 160 // GrantPriv is the privilege to grant privilege to user. 161 GrantPriv 162 // AlterPriv is the privilege to run alter statement. 163 AlterPriv 164 // ExecutePriv is the privilege to run execute statement. 165 ExecutePriv 166 // IndexPriv is the privilege to create/drop index. 167 IndexPriv 168 // AllPriv is the privilege for all actions. 169 AllPriv 170 ) 171 172 // Priv2UserCol is the privilege to mysql.user table column name. 173 var Priv2UserCol = map[PrivilegeType]string{ 174 CreatePriv: "Create_priv", 175 SelectPriv: "Select_priv", 176 InsertPriv: "Insert_priv", 177 UpdatePriv: "Update_priv", 178 DeletePriv: "Delete_priv", 179 ShowDBPriv: "Show_db_priv", 180 CreateUserPriv: "Create_user_priv", 181 DropPriv: "Drop_priv", 182 GrantPriv: "Grant_priv", 183 AlterPriv: "Alter_priv", 184 ExecutePriv: "Execute_priv", 185 IndexPriv: "Index_priv", 186 } 187 188 // Col2PrivType is the privilege tables column name to privilege type. 189 var Col2PrivType = map[string]PrivilegeType{ 190 "Create_priv": CreatePriv, 191 "Select_priv": SelectPriv, 192 "Insert_priv": InsertPriv, 193 "Update_priv": UpdatePriv, 194 "Delete_priv": DeletePriv, 195 "Show_db_priv": ShowDBPriv, 196 "Create_user_priv": CreateUserPriv, 197 "Drop_priv": DropPriv, 198 "Grant_priv": GrantPriv, 199 "Alter_priv": AlterPriv, 200 "Execute_priv": ExecutePriv, 201 "Index_priv": IndexPriv, 202 } 203 204 // AllGlobalPrivs is all the privileges in global scope. 205 var AllGlobalPrivs = []PrivilegeType{SelectPriv, InsertPriv, UpdatePriv, DeletePriv, CreatePriv, DropPriv, GrantPriv, AlterPriv, ShowDBPriv, ExecutePriv, IndexPriv, CreateUserPriv} 206 207 // Priv2Str is the map for privilege to string. 208 var Priv2Str = map[PrivilegeType]string{ 209 CreatePriv: "Create", 210 SelectPriv: "Select", 211 InsertPriv: "Insert", 212 UpdatePriv: "Update", 213 DeletePriv: "Delete", 214 ShowDBPriv: "Show Databases", 215 CreateUserPriv: "Create User", 216 DropPriv: "Drop", 217 GrantPriv: "Grant Option", 218 AlterPriv: "Alter", 219 ExecutePriv: "Execute", 220 IndexPriv: "Index", 221 } 222 223 // Priv2SetStr is the map for privilege to string. 224 var Priv2SetStr = map[PrivilegeType]string{ 225 CreatePriv: "Create", 226 SelectPriv: "Select", 227 InsertPriv: "Insert", 228 UpdatePriv: "Update", 229 DeletePriv: "Delete", 230 DropPriv: "Drop", 231 GrantPriv: "Grant", 232 AlterPriv: "Alter", 233 ExecutePriv: "Execute", 234 IndexPriv: "Index", 235 } 236 237 // SetStr2Priv is the map for privilege set string to privilege type. 238 var SetStr2Priv = map[string]PrivilegeType{ 239 "Create": CreatePriv, 240 "Select": SelectPriv, 241 "Insert": InsertPriv, 242 "Update": UpdatePriv, 243 "Delete": DeletePriv, 244 "Drop": DropPriv, 245 "Grant": GrantPriv, 246 "Alter": AlterPriv, 247 "Execute": ExecutePriv, 248 "Index": IndexPriv, 249 } 250 251 // AllDBPrivs is all the privileges in database scope. 252 var AllDBPrivs = []PrivilegeType{SelectPriv, InsertPriv, UpdatePriv, DeletePriv, CreatePriv, DropPriv, GrantPriv, AlterPriv, ExecutePriv, IndexPriv} 253 254 // AllTablePrivs is all the privileges in table scope. 255 var AllTablePrivs = []PrivilegeType{SelectPriv, InsertPriv, UpdatePriv, DeletePriv, CreatePriv, DropPriv, GrantPriv, AlterPriv, IndexPriv} 256 257 // AllColumnPrivs is all the privileges in column scope. 258 var AllColumnPrivs = []PrivilegeType{SelectPriv, InsertPriv, UpdatePriv} 259 260 // AllPrivilegeLiteral is the string literal for All Privilege. 261 const AllPrivilegeLiteral = "ALL PRIVILEGES"