(self)
| 1137 | return self.protocol_version |
| 1138 | |
| 1139 | def _get_server_information(self): |
| 1140 | i = 0 |
| 1141 | packet = self._read_packet() |
| 1142 | data = packet.get_all_data() |
| 1143 | |
| 1144 | self.protocol_version = data[i] |
| 1145 | i += 1 |
| 1146 | |
| 1147 | server_end = data.find(b"\0", i) |
| 1148 | self.server_version = data[i:server_end].decode("latin1") |
| 1149 | i = server_end + 1 |
| 1150 | |
| 1151 | self.server_thread_id = struct.unpack("<I", data[i : i + 4]) |
| 1152 | i += 4 |
| 1153 | |
| 1154 | self.salt = data[i : i + 8] |
| 1155 | i += 9 # 8 + 1(filler) |
| 1156 | |
| 1157 | self.server_capabilities = struct.unpack("<H", data[i : i + 2])[0] |
| 1158 | i += 2 |
| 1159 | |
| 1160 | if len(data) >= i + 6: |
| 1161 | lang, stat, cap_h, salt_len = struct.unpack("<BHHB", data[i : i + 6]) |
| 1162 | i += 6 |
| 1163 | # TODO: deprecate server_language and server_charset. |
| 1164 | # mysqlclient-python doesn't provide it. |
| 1165 | self.server_language = lang |
| 1166 | try: |
| 1167 | self.server_charset = charset_by_id(lang).name |
| 1168 | except KeyError: |
| 1169 | # unknown collation |
| 1170 | self.server_charset = None |
| 1171 | |
| 1172 | self.server_status = stat |
| 1173 | if DEBUG: |
| 1174 | print("server_status: %x" % stat) |
| 1175 | |
| 1176 | self.server_capabilities |= cap_h << 16 |
| 1177 | if DEBUG: |
| 1178 | print("salt_len:", salt_len) |
| 1179 | salt_len = max(12, salt_len - 9) |
| 1180 | |
| 1181 | # reserved |
| 1182 | i += 10 |
| 1183 | |
| 1184 | if len(data) >= i + salt_len: |
| 1185 | # salt_len includes auth_plugin_data_part_1 and filler |
| 1186 | self.salt += data[i : i + salt_len] |
| 1187 | i += salt_len |
| 1188 | |
| 1189 | i += 1 |
| 1190 | # AUTH PLUGIN NAME may appear here. |
| 1191 | if self.server_capabilities & CLIENT.PLUGIN_AUTH and len(data) >= i: |
| 1192 | # Due to Bug#59453 the auth-plugin-name is missing the terminating |
| 1193 | # NUL-char in versions prior to 5.5.10 and 5.6.2. |
| 1194 | # ref: https://dev.mysql.com/doc/internals/en/connection-phase-packets.html#packet-Protocol::Handshake |
| 1195 | # didn't use version checks as mariadb is corrected and reports |
| 1196 | # earlier than those two. |
no test coverage detected