File: D:/Python311/Lib/site-packages/mysql/connector/__pycache__/protocol.cpython-311.pyc
�
�nc�~ � � � d Z ddlZddlZddlmZmZ ddlmZ ddlm Z ddl
mZmZm
Z
mZmZ ddlmZmZmZmZ d Z G d
� d� � ZdS )z,Implements the MySQL Client/Server protocol.� N)�Decimal�DecimalException� )�utils)�get_auth_plugin)�PARAMETER_COUNT_AVAILABLE�
ClientFlag� FieldFlag� FieldType� ServerCmd)�
DatabaseError�InterfaceError�ProgrammingError�
get_exception�
c � � e Zd ZdZed� � � Zed� � � Z d+d �Zed
� � � Zed,d�� � Z ed-d�� � Z
ed.d�� � Z d/d�Zed� � � Z
ed� � � Zed� � � Zed� � � Zed0d�� � Zd� Zed1d�� � Zd.d�Zed� � � Zed� � � Zed2d�� � Zed� � � Zed� � � Zd0d �Zd3d!�Zed"� � � Zed#� � � Zed$� � � Zed%� � � Zed&� � � Z d4d(�Z!ed)� � � Z"ed*� � � Z#dS )5�
MySQLProtocolzRImplements MySQL client/server protocol
Create and parses MySQL packets.
c �X � | t j z r|r|� d� � dz S dS )z.Prepare database string for handshake response�utf8� )r �CONNECT_WITH_DB�encode)�client_flags�databases �:D:\Python311\Lib\site-packages\mysql/connector/protocol.py�_connect_with_dbzMySQLProtocol._connect_with_db8 s7 � � �*�4�4� 5�� 5��?�?�6�*�*�W�4�4��w� c �D � |sdS t |� � |||||�� � }|� � � }n,# t t f$ r} t d| � �� � | �d} ~ ww xY w| t j z r(t
|� � }
t j d|
� � |z }n|dz }|S )z#Prepare the authentication responser )�username�passwordr �ssl_enabledzFailed authentication: N�<B) r �
auth_response� TypeErrorr r �SECURE_CONNECTION�len�struct�pack)r r r r �auth_plugin� auth_datar! �auth�plugin_auth_response�err�resplenr# s r �_auth_responsezMySQLProtocol._auth_response? s� � � � ��7�
K�/�?�;�/�/��!�!�!�'�� � �D� $(�#5�#5�#7�#7� � ���>�*� K� K� K� �!@�3�!@�!@�A�A�s�J����� K���� �*�6�6� ;��.�/�/�G�"�K��g�6�6�9M�M�M�M�0�7�:�M��s �18 �A!� A�A!N�- r � @Fc
�T � |d }| p|d } n-# t t f$ r}t d|� d�� � d�d}~ww xY w|sd} |� d� � }
n# t $ r |}
Y nw xY wd}t |
� � }t
j d |� |� d
�||||
� � }|| � ||||| ||� � z
}|| � ||� � z
}|t j z r|| � d� � dz z
}|t j z r|
�|| �
|
� � z
}|S )z"Make a MySQL Authentication packetr* r) �&Handshake misses authentication info (�)Nr r �xxxxxxxxxxxxxxxxxxxxxxz<IIH�sxr )r$ �KeyErrorr r �AttributeErrorr&