initCapabilities initializes the capabilities based on server support and configuration
(serverCapabilities capabilityFlag, serverExtCapabilities extendedCapabilityFlag, cfg *Config)
| 278 | |
| 279 | // initCapabilities initializes the capabilities based on server support and configuration |
| 280 | func (mc *mysqlConn) initCapabilities(serverCapabilities capabilityFlag, serverExtCapabilities extendedCapabilityFlag, cfg *Config) { |
| 281 | clientCapabilities := |
| 282 | clientMySQL | |
| 283 | clientLongFlag | |
| 284 | clientProtocol41 | |
| 285 | clientSecureConn | |
| 286 | clientTransactions | |
| 287 | clientPluginAuthLenEncClientData | |
| 288 | clientLocalFiles | |
| 289 | clientPluginAuth | |
| 290 | clientMultiResults | |
| 291 | clientConnectAttrs | |
| 292 | clientDeprecateEOF |
| 293 | |
| 294 | if cfg.ClientFoundRows { |
| 295 | clientCapabilities |= clientFoundRows |
| 296 | } |
| 297 | if cfg.compress { |
| 298 | clientCapabilities |= clientCompress |
| 299 | } |
| 300 | // To enable TLS / SSL |
| 301 | if mc.cfg.TLS != nil { |
| 302 | clientCapabilities |= clientSSL |
| 303 | } |
| 304 | |
| 305 | if mc.cfg.MultiStatements { |
| 306 | clientCapabilities |= clientMultiStatements |
| 307 | } |
| 308 | if n := len(cfg.DBName); n > 0 { |
| 309 | clientCapabilities |= clientConnectWithDB |
| 310 | } |
| 311 | |
| 312 | // only keep client capabilities that server have |
| 313 | mc.capabilities = clientCapabilities & serverCapabilities |
| 314 | |
| 315 | // set MariaDB extended clientCacheMetadata capability if server support it |
| 316 | mc.extCapabilities = clientCacheMetadata & serverExtCapabilities |
| 317 | } |
| 318 | |
| 319 | // Client Authentication Packet |
| 320 | // https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_connection_phase_packets_protocol_handshake_response.html |