AlkantarClanX12

Your IP : 3.147.28.111


Current Path : /opt/cloudlinux/venv/lib64/python3.11/site-packages/pymysql/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/pymysql/__pycache__/protocol.cpython-311.pyc

�

�܋fW.����ddlmZddlmZmZddlmZddlZddlZdZ	dZ
dZdZd	Z
d
Zd�ZGd�d
��ZGd�de��ZGd�d��ZGd�d��ZGd�d��ZdS)�)�MBLENGTH)�
FIELD_TYPE�
SERVER_STATUS)�err�NF����c	����d��	tdt�����tdd��D]:}tj|��}td||jj|jfz���;td��n#t$rYnwxYw�fd�tdtt���d	��d
��D��}|D]i}td�
d�|D����d
d
t|��z
zzdzd�
�fd�|D����z���jtd��t��dS)Nc�D�d|cxkrdkrnnt|��SdS)N� ��.)�chr)�datas �G/opt/cloudlinux/venv/lib64/python3.11/site-packages/pymysql/protocol.py�	printablezdump_packet.<locals>.printables5��
�������������t�9�9���s�zpacket length:r�zcall[%d]: %s (line %d)zB------------------------------------------------------------------c�*��g|]}�||dz���S)��)�.0�irs  �r�
<listcomp>zdump_packet.<locals>.<listcomp>#s&���M�M�M�a��a�!�b�&�j�!�M�M�Mrr�r� c3�K�|]}|d�V��	dS)�02XNr)r�xs  r�	<genexpr>zdump_packet.<locals>.<genexpr>&s&����+�+�A��Z�Z�+�+�+�+�+�+rz   z  �c3�.�K�|]}�|��V��dS�Nr)rr!rs  �rr"zdump_packet.<locals>.<genexpr>)s+�����.�.�q�i�i��l�l�.�.�.�.�.�.r)�print�len�range�sys�	_getframe�f_code�co_name�f_lineno�
ValueError�min�join)rr�f�	dump_data�drs`    @r�dump_packetr4s��������

�
���D�	�	�*�*�*��q�!���	P�	P�A��
�a� � �A��*�a���1A�1�:�-N�N�O�O�O�O�
�h�������
�
�
���
����M�M�M�M�5��C��D�	�	�3�4G�4G��+L�+L�M�M�M�I�
�
�
��
��H�H�+�+��+�+�+�+�+��r�C��F�F�{�#�
$��
��g�g�.�.�.�.�A�.�.�.�.�.�
/�	
�	
�	
�	
�
�(�O�O�O�	�G�G�G�G�Gs�A7A?�?
B�Bc��eZdZdZdZd�Zd�Zd�Zd�Zd�Z	d d	�Z
d!d�Zd�Zd
�Z
d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZdS)"�MysqlPacketzrRepresentation of a MySQL response packet.

    Provides an interface for reading/parsing the packet results.
    ��	_position�_datac�"�d|_||_dS)Nrr7��selfr�encodings   r�__init__zMysqlPacket.__init__7s�������
�
�
rc��|jSr%�r9�r<s r�get_all_datazMysqlPacket.get_all_data;s
���z�rc
�Z�|j|j|j|z�}t|��|krkd|�dt|���d|j�dt|j����}tr#t	|��|���t
|���|xj|z
c_|S)zCRead the first 'size' bytes in packet and advance cursor past them.z-Result length not requested length:
Expected=z
.  Actual=z
.  Position: z.  Data Length: )r9r8r'�DEBUGr&�dump�AssertionError)r<�size�result�errors    r�readzMysqlPacket.read>s�����D�N�d�n�t�.C�D�E���v�;�;�$�����4�4��V�����d�n�n�n�c�$�*�o�o�o�G�
�
�
��e�����	�	���� ��'�'�'����$�����
rc�<�|j|jd�}d|_|S)z`Read all remaining data in the packet.

        (Subsequent read() will return errors.)
        N�r9r8�r<rHs  r�read_allzMysqlPacket.read_allNs$��
��D�N�,�,�-������
rc��|j|z}|dks|t|j��krtd|�d|�����||_dS)z1Advance the cursor in data buffer 'length' bytes.rzInvalid advance amount (z) for cursor.  Position=N)r8r'r9�	Exception)r<�length�new_positions   r�advancezMysqlPacket.advanceWs\���~��.���!���|�c�$�*�o�o�=�=��)�!'�����7���
�&����rrc�t�|dks|t|j��krtd|z���||_dS)z9Set the position of the data buffer cursor to 'position'.rz)Invalid position to rewind cursor to: %s.N)r'r9rPr8)r<�positions  r�rewindzMysqlPacket.rewindas<���a�<�<�8�c�$�*�o�o�5�5��G�(�R�S�S�S�!����rrc�&�|j|||z�S)a>Get 'length' bytes starting at 'position'.

        Position is start of payload (first four packet header bytes are not
        included) starting at index '0'.

        No error checking is done.  If requesting outside end of buffer
        an empty string (or string shorter than 'length') may be returned!
        r@)r<rUrQs   r�	get_byteszMysqlPacket.get_bytesgs���z�(�h��&7�8�9�9rc�J�|j|j}|xjdz
c_|S�NrrLrMs  r�
read_uint8zMysqlPacket.read_uint8rs%����D�N�+�����!�����
rc�r�tjd|j|j��d}|xjdz
c_|S)Nz<Hr���struct�unpack_fromr9r8rMs  r�read_uint16zMysqlPacket.read_uint16w�4���#�D�$�*�d�n�E�E�a�H�����!�����
rc�x�tjd|j|j��\}}|xjdz
c_||dzzS)Nz<HB�rr^)r<�low�highs   r�read_uint24zMysqlPacket.read_uint24|s=���&�u�d�j�$�.�I�I�	��T����!�����d�b�j�!�!rc�r�tjd|j|j��d}|xjdz
c_|S)Nz<Ir�r^rMs  r�read_uint32zMysqlPacket.read_uint32�rbrc�r�tjd|j|j��d}|xjdz
c_|S)Nz<Qr�r^rMs  r�read_uint64zMysqlPacket.read_uint64�rbrc��|j�d|j��}|dkrdS|j|j|�}|dz|_|S)N�rr)r9�findr8)r<�end_posrHs   r�read_stringzMysqlPacket.read_string�sJ���*�/�/�%���8�8���Q�;�;��4���D�N�W�4�5�� �1�����
rc��|���}|tkrdS|tkr|S|tkr|���S|t
kr|���S|tkr|���SdS)z�Read a 'Length Coded Binary' number from the data buffer.

        Length coded numbers can be anywhere from 1 to 9 bytes depending
        on the value of the first byte.
        N)	r[�NULL_COLUMN�UNSIGNED_CHAR_COLUMN�UNSIGNED_SHORT_COLUMNra�UNSIGNED_INT24_COLUMNrg�UNSIGNED_INT64_COLUMNrm)r<�cs  r�read_length_encoded_integerz'MysqlPacket.read_length_encoded_integer�s���
�O�O���������4��#�#�#��H�
�'�
'�
'��#�#�%�%�%�
�'�
'�
'��#�#�%�%�%�
�'�
'�
'��#�#�%�%�%�(�
'rc�\�|���}|�dS|�|��S)aRead a 'Length Coded String' from the data buffer.

        A 'Length Coded String' consists first of a length coded
        (unsigned, positive) integer represented in 1-9 bytes followed by
        that many bytes of binary data.  (For example "cat" would be "3cat".)
        N)rzrJ)r<rQs  r�read_length_coded_stringz$MysqlPacket.read_length_coded_string�s1���1�1�3�3���>��4��y�y�� � � rc��tj|��}|�|j|j��}|xj|jz
c_|Sr%)r_�Structr`r9r8rG)r<�fmt�srHs    r�read_structzMysqlPacket.read_struct�s?���M�#�������t�z�4�>�:�:�����!�&� ����
rc�T�|jddkot|j��dkS)Nrr�r9r'rAs r�is_ok_packetzMysqlPacket.is_ok_packet�s%���z�!�}��!�:�c�$�*�o�o��&:�:rc�T�|jddkot|j��dkS)Nrr�	r�rAs r�
is_eof_packetzMysqlPacket.is_eof_packet�s'���z�!�}��$�<��T�Z���1�)<�<rc�$�|jddkS)Nrrr@rAs r�is_auth_switch_requestz"MysqlPacket.is_auth_switch_request�s���z�!�}��$�$rc�$�|jddkS)Nrrr@rAs r�is_extra_auth_datazMysqlPacket.is_extra_auth_data�s���z�!�}��!�!rc�<�|jd}d|cxkodkncS)Nrr�r@)r<�field_counts  r�is_resultset_packetzMysqlPacket.is_resultset_packet�s/���j��m���K�&�&�&�&�3�&�&�&�&�&rc�$�|jddkS)Nrrr@rAs r�is_load_local_packetz MysqlPacket.is_load_local_packet�����z�!�}��$�$rc�$�|jddkS)Nr�r@rAs r�is_error_packetzMysqlPacket.is_error_packet�r�rc�Z�|���r|���dSdSr%)r��raise_for_errorrAs r�check_errorzMysqlPacket.check_error�s8�����!�!�	#�� � �"�"�"�"�"�	#�	#rc���|���|�d��|���}trt	d|��tj|j��dS)Nrzerrno =)rVrSrarDr&r�raise_mysql_exceptionr9)r<�errnos  rr�zMysqlPacket.raise_for_error�s`�����
�
�
����Q����� � �"�"���	$��)�U�#�#�#��!�$�*�-�-�-�-�-rc�.�t|j��dSr%)r4r9rAs rrEzMysqlPacket.dump�s���D�J�����rN)r)r)�__name__�
__module__�__qualname__�__doc__�	__slots__r>rBrJrNrSrVrXr[rargrjrmrrrzr|r�r�r�r�r�r�r�r�r�r�rErrrr6r6/s���������
'�I���������� ���&�&�&�"�"�"�"�	:�	:�	:�	:����
���
"�"�"�
���
���
���&�&�&�$
!�
!�
!����;�;�;�=�=�=�%�%�%�"�"�"�'�'�'�%�%�%�%�%�%�#�#�#�.�.�.� � � � � rr6c�0�eZdZdZd�Zd�Zd�Zd�Zd�ZdS)�FieldDescriptorPacketz�A MysqlPacket that represents a specific column's metadata in the result.

    Parsing is automatically done and the results are exported via public
    attributes on the class such as: db, table_name, name, length, type_code.
    c�h�t�|||��|�|��dSr%)r6r>�_parse_field_descriptorr;s   rr>zFieldDescriptorPacket.__init__�s4�����T�4��2�2�2��$�$�X�.�.�.�.�.rc�2�|���|_|���|_|����|��|_|����|��|_|����|��|_|����|��|_|�d��\|_	|_
|_|_|_
dS)z�Parse the 'Field Descriptor' (Metadata) packet.

        This is compatible with MySQL 4.1+ (not compatible with MySQL 4.0).
        z	<xHIBHBxxN)r|�catalog�db�decode�
table_name�	org_table�name�org_namer��	charsetnrrQ�	type_code�flags�scale)r<r=s  rr�z-FieldDescriptorPacket._parse_field_descriptor�s���
�4�4�6�6����/�/�1�1����7�7�9�9�@�@��J�J����6�6�8�8�?�?��I�I����1�1�3�3�:�:�8�D�D��	��5�5�7�7�>�>�x�H�H��
�
���[�)�)�
	
��N��K��N��J��J�J�Jrc��|j|jd|���|���|j|jdzdkfS)zBProvides a 7-item tuple compatible with the Python PEP249 DB Spec.Nr]r)r�r��get_column_lengthr�r�rAs r�descriptionz!FieldDescriptorPacket.descriptionsL��
�I��N���"�"�$�$��"�"�$�$��J��J��N�a��
�	
rc��|jtjkr$tj|jd��}|j|zS|jSrZ)r�r�
VAR_STRINGr�getr�rQ)r<�mblens  rr�z'FieldDescriptorPacket.get_column_lengths:���>�Z�2�2�2��L����3�3�E��;�%�'�'��{�rc�r�d�|j|j|j|j|j|j��S)Nz&{} {!r}.{!r}.{!r}, type={}, flags={:x})�format�	__class__r�r�r�r�r�rAs r�__str__zFieldDescriptorPacket.__str__s8��7�>�>��N��G��O��I��N��J�

�
�	
rN)	r�r�r�r�r>r�r�r�r�rrrr�r��si��������/�/�/�*�*�*�*

�

�

����
�
�
�
�
rr�c��eZdZdZd�Zd�ZdS)�OKPacketWrapperz�
    OK Packet Wrapper. It uses an existing packet object, and wraps
    around it, exposing useful variables while still providing access
    to the original packet objects variables and methods.
    c���|���s,tdt|jj��zdz���||_|j�d��|j���|_|j���|_	|�
d��\|_|_|j�
��|_|jtjz|_dS)NzCannot create z  object from invalid packet typerz<HH)r�r.�strr�r��packetrSrz�
affected_rows�	insert_idr��
server_status�
warning_countrN�messager�SERVER_MORE_RESULTS_EXISTS�has_next�r<�from_packets  rr>zOKPacketWrapper.__init__'s����'�'�)�)�	�� ��d�n�-�.�.�/�4�5���
�"�������A����!�[�D�D�F�F�����@�@�B�B���15�1A�1A�%�1H�1H�.���D�.��{�+�+�-�-����*�]�-U�U��
�
�
rc�,�t|j|��Sr%��getattrr��r<�keys  r�__getattr__zOKPacketWrapper.__getattr__8����t�{�C�(�(�(rN�r�r�r�r�r>r�rrrr�r� s?��������V�V�V�")�)�)�)�)rr�c��eZdZdZd�Zd�ZdS)�EOFPacketWrapperz�
    EOF Packet Wrapper. It uses an existing packet object, and wraps
    around it, exposing useful variables while still providing access
    to the original packet objects variables and methods.
    c�$�|���std|j�d����||_|j�d��\|_|_trtd|j��|jtj
z|_dS)N�Cannot create '�!' object from invalid packet typez<xhhzserver_status=)r�r.r�r�r�r�r�rDr&rr�r�r�s  rr>zEOFPacketWrapper.__init__Cs����(�(�*�*�	��S�$�.�S�S�S���
�"���15��1H�1H��1P�1P�.���D�.��	8��"�D�$6�7�7�7��*�]�-U�U��
�
�
rc�,�t|j|��Sr%r�r�s  rr�zEOFPacketWrapper.__getattr__Or�rNr�rrrr�r�<s?��������
V�
V�
V�)�)�)�)�)rr�c��eZdZdZd�Zd�ZdS)�LoadLocalPacketWrapperz�
    Load Local Packet Wrapper. It uses an existing packet object, and wraps
    around it, exposing useful variables while still providing access
    to the original packet objects variables and methods.
    c���|���std|j�d����||_|j���dd�|_trtd|j��dSdS)Nr�r�rz	filename=)r�r.r�r�rB�filenamerDr&r�s  rr>zLoadLocalPacketWrapper.__init__Zs����/�/�1�1�	��S�$�.�S�S�S���
�"�����0�0�2�2�1�2�2�6��
��	.��+�t�}�-�-�-�-�-�	.�	.rc�,�t|j|��Sr%r�r�s  rr�z"LoadLocalPacketWrapper.__getattr__er�rNr�rrrr�r�Ss<��������	.�	.�	.�)�)�)�)�)rr�)�charsetr�	constantsrrr#rr_r)rDrtrurvrwrxr4r6r�r�r�r�rrr�<module>r�sf��������0�0�0�0�0�0�0�0�������
�
�
�
�
�
�
�
�	���������������4q �q �q �q �q �q �q �q �h:
�:
�:
�:
�:
�K�:
�:
�:
�z)�)�)�)�)�)�)�)�8)�)�)�)�)�)�)�)�.)�)�)�)�)�)�)�)�)�)r