o
    G)f?                     @  s6  d Z ddlmZ ddlZddlZddlmZ ddlmZm	Z	 ddl
mZmZmZmZmZmZmZmZmZ ddlmZ dd	lmZmZmZmZmZ dd
lmZmZmZm Z  ddl!m!Z! ddl"m#Z#m$Z$ ddl%m&Z& ddl'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z. erddl/m0Z0 dZ1dZ2dZ3dZ4dZ5dZ6dZ7dZ8G dd dZ9dS )z,Implements the MySQL Client/Server protocol.    )annotationsN)deque)DecimalDecimalException)	TYPE_CHECKINGAnyDequeDictListOptionalSequenceTupleUnion   )utils)PARAMETER_COUNT_AVAILABLE
ClientFlag	FieldFlag	FieldType	ServerCmd)DatabaseErrorInterfaceErrorProgrammingErrorget_exception)logger)MySQLAuthPluginget_auth_plugin)"MySQLCachingSHA2PasswordAuthPlugin)BinaryProtocolTypeDescriptionTypeEofPacketTypeHandShakeTypeOkPacketTypeStatsPacketType
StrOrBytes)MySQLSocket
            -   i   @c                   @  s  e Zd ZdZedddZeddd	Zedd
dZedddZedddZ	e			ddd#d$Z
eded%eddddddf
dd,d-Zeed%efdd.d/Zeddd3d4Zeddd8d9Zedd;d<Zedd>d?ZeddAdBZedddFdGZddIdJZedddNdOZ	5dddVdWZeddZd[Zedd]d^Ze	_dddadbZeddedfZeddhdiZ	CdddmdnZ	5	CdddqdrZeddtduZeddxdyZ edd{d|Z!edd~dZ"edddZ#			%		_		ddddZ$dS )MySQLProtocolzRImplements MySQL client/server protocol

    Create and parses MySQL packets.
    pktbytesreturnc                 C  s    | d t ks
td| dd S )a  Parse a MySQL auth more data packet.

        Args:
            pkt: Packet representing an `auth more data` response.

        Returns:
            auth_data: Authentication method data (see [1]).

        Raises:
            InterfaceError: If packet's status tag doesn't
                            match `protocol.EXCHANGE_FURTHER_STATUS`.

        References:
            [1]: https://dev.mysql.com/doc/dev/mysql-server/latest/                page_protocol_connection_phase_packets_protocol_auth_more_data.html
           z"Failed parsing AuthMoreData packet   N)EXCHANGE_FURTHER_STATUSr   )r,    r2   U/var/www/html/flask-app/venv/lib/python3.12/site-packages/mysql/connector/protocol.pyparse_auth_more_data[   s   z"MySQLProtocol.parse_auth_more_dataTuple[str, bytes]c                 C  sV   | d t kr
tdtj| dd dd\} }| r%| d dkr%| dd } | | fS )	a|  Parse a MySQL auth switch request packet.

        Args:
            pkt: Packet representing an `auth switch request` response.

        Returns:
            plugin_name: Name of the client authentication plugin to switch to.
            plugin_provided_data: Plugin provided data (see [1]).

        Raises:
            InterfaceError: If packet's status tag doesn't
                            match `protocol.AUTH_SWITCH_STATUS`.

        References:
            [1]: https://dev.mysql.com/doc/dev/mysql-server/                latest/page_protocol_connection_phase_packets_protocol_
                auth_switch_request.html
        r/   z'Failed parsing AuthSwitchRequest packetr0   N    endr   )AUTH_SWITCH_STATUSr   r   read_stringdecode)r,   plugin_namer2   r2   r3   parse_auth_switch_requestq   s   z'MySQLProtocol.parse_auth_switch_requestc                 C  sF   t | dd d\} }|tkrtdt j| dd\} }| | fS )a  Parse a MySQL auth next factor packet.

        Args:
            pkt: Packet representing an `auth next factor` response.

        Returns:
            plugin_name: Name of the client authentication plugin.
            plugin_provided_data: Initial authentication data for that
                                  client plugin (see [1]).

        Raises:
            InterfaceError: If packet's packet type doesn't
                            match `protocol.MFA_STATUS`.

        References:
            [1]: https://dev.mysql.com/doc/dev/mysql-server/latest/                page_protocol_connection_phase_packets_protocol_auth_                next_factor_request.html
        r/   Nr   z.Failed parsing AuthNextFactor packet (invalid)r6   r7   )r   read_int
MFA_STATUSr   r;   r<   )r,   statusr=   r2   r2   r3   parse_auth_next_factor   s
   z$MySQLProtocol.parse_auth_next_factor
conn_attrsDict[str, str]c              	     s    D ]} | du rd |< qt  fdd D t   t   }td|g} D ]*}|tdt| ||  |tdt |  | |   q/d|S )az  Encode the connection attributes.

        Args:
            conn_attrs: Connection attributes.

        Returns:
            serialized_conn_attrs: Serialized connection attributes as per [1].

        References:
            [1]: https://dev.mysql.com/doc/dev/mysql-server/latest/                page_protocol_connection_phase_packets_protocol_handshake_response.html
        N c                 3  s$    | ]}t |t  |  V  qd S N)len).0xrC   r2   r3   	<genexpr>   s   " z0MySQLProtocol.make_conn_attrs.<locals>.<genexpr><B    )	sumrG   keysvaluesstructpackappendencodejoin)rC   	attr_nameconn_attrs_lenconn_attrs_packetr2   rJ   r3   make_conn_attrs   s"   


zMySQLProtocol.make_conn_attrsclient_flagsintdatabaseOptional[str]c                 C  s   | t j@ r|r| d S dS )a  Prepare database string for handshake response.

        Args:
            client_flags: Integer representing client capabilities flags.
            database: Initial database name for the connection.

        Returns:
            serialized_database: Serialized database name as per [1].

        References:
            [1]: https://dev.mysql.com/doc/dev/mysql-server/latest/                page_protocol_connection_phase_packets_protocol_handshake_response.html
        r6   )r   CONNECT_WITH_DBrT   )rZ   r\   r2   r2   r3   connect_with_db   s   zMySQLProtocol.connect_with_dbNF	auth_datausernamestrpasswordauth_pluginauth_plugin_classssl_enabledboolplugin_configOptional[Dict[str, Any]]Tuple[bytes, MySQLAuthPlugin]c              
   C  s   |sdt |||dfS |du ri }zt|||||d}|j| fi |}	W n ttfy< }
 ztd|
 |
d}
~
ww |	du rItd|j |tj@ rWt	t
|	|	 n|	d }	|	|fS )a  Prepare the first authentication response.

        Args:
            auth_data: Authorization data from initial handshake.
            username: Account's username.
            password: Account's password.
            client_flags: Integer representing client capabilities flags.
            auth_plugin: Authorization plugin name.
            auth_plugin_class: Authorization plugin class (has higher precedence
                               than the authorization plugin name).
            ssl_enabled: Whether SSL is enabled or not.
            plugin_config: Custom configuration to be passed to the auth plugin
                           when invoked. The parameters defined here will override
                           the ones defined in the auth plugin itself.

        Returns:
            auth_response: Authorization plugin response.
            auth_strategy: Authorization plugin instance created based
                           on the provided `auth_plugin` and `auth_plugin_class`
                           parameters.

        Raises:
            InterfaceError: If authentication fails or when got a NULL auth response.
        r6   )rf   NzFailed authentication: z8Got NULL auth response while authenticating with plugin )r   r   auth_response	TypeErrorr   namer   SECURE_CONNECTIONr   	int1storerG   )r`   ra   rc   rZ   rd   re   rf   rh   auth_strategyrk   errr2   r2   r3   auth_plugin_first_response   s4   #z(MySQLProtocol.auth_plugin_first_responser   	handshaker!   charsetmax_allowed_packetOptional[Dict[str, str]]is_change_user_requestc              
   C  s  |  }g }|
rtd td | du rtdd| ddu r'tddz|p-| d }W n ttfyF } z	td| d	dd}~ww td
| |
ra|t	dt
| dtj| nd}|t	d| t
| d|||| tj| d |||||||d\}}|| |t|| |
r|t	d| |tj@ r||  d  |tj@ r|	dur|t|	 d||fS )a  Make a MySQL Authentication packet.

        Args:
            handshake: Initial handshake.
            username: Account's username.
            password: Account's password.
            database: Initial database name for the connection
            charset: Client charset (see [2]), only the lower 8-bits.
            client_flags: Integer representing client capabilities flags.
            max_allowed_packet: Maximum packet size.
            auth_plugin: Authorization plugin name.
            auth_plugin_class: Authorization plugin class (has higher precedence
                               than the authorization plugin name).
            conn_attrs: Connection attributes.
            is_change_user_request: Whether is a `change user request` operation or not.
            ssl_enabled: Whether SSL is enabled or not.
            plugin_config: Custom configuration to be passed to the auth plugin
                           when invoked. The parameters defined here will override
                           the one defined in the auth plugin itself.

        Returns:
            handshake_response: Handshake response as per [1].
            auth_strategy: Authorization plugin instance created based
                           on the provided `auth_plugin` and `auth_plugin_class`.

        Raises:
            ProgrammingError: Handshake misses authentication info.

        References:
            [1]: https://dev.mysql.com/doc/dev/mysql-server/latest/                page_protocol_connection_phase_packets_protocol_handshake_response.html

            [2]: https://dev.mysql.com/doc/dev/mysql-server/latest/                page_protocol_basic_character_set.html#a_protocol_character_set
        zGot a `change user` requestzStarting authorization phaseNzGot a NULL handshaker`   z$Handshake misses authentication inford   z-Handshake misses authentication plugin info ()z#The provided initial strategy is %srL   sxxxxxxxxxxxxxxxxxxxxxxxz<IIH)r`   ra   rc   rZ   rd   re   rf   rh   <Hr6   rM   )rT   r   debugr   getrl   KeyErrorrS   rQ   rR   rG   r   CHANGE_USERr+   rr   r_   r   PLUGIN_AUTHCONNECT_ARGSrY   rU   )rs   ra   rc   r\   rt   rZ   ru   rd   re   rC   rw   rf   rh   
b_usernameresponse_payloadrq   fillerrk   rp   r2   r2   r3   	make_auth  sr   3








zMySQLProtocol.make_authc                 C  s$   d t|t|t| dgS )a  Make a SSL authentication packet (see [1]).

        Args:
            charset: Client charset (see [2]), only the lower 8-bits.
            client_flags: Integer representing client capabilities flags.
            max_allowed_packet: Maximum packet size.

        Returns:
            ssl_request_pkt: SSL connection request packet.

        References:
            [1]: https://dev.mysql.com/doc/dev/mysql-server/latest/                page_protocol_connection_phase_packets_protocol_ssl_request.html

            [2]: https://dev.mysql.com/doc/dev/mysql-server/latest/                page_protocol_basic_character_set.html#a_protocol_character_set
        rM   s                         rU   r   	int4store	int2store)rt   rZ   ru   r2   r2   r3   make_auth_ssl  s   zMySQLProtocol.make_auth_sslcommandargumentOptional[bytes]c                 C  s   t | }|du r|S || S )z(Make a MySQL packet containing a commandN)r   ro   )r   r   datar2   r2   r3   make_command  s   
zMySQLProtocol.make_commandr   statement_idrowsc                 C  s   t | t | S )z0Make a MySQL packet with Fetch Statement command)r   r   )r   r   r2   r2   r3   make_stmt_fetch  s   zMySQLProtocol.make_stmt_fetchpacketc           	   	   C  s  i }t d| dd d |d< |d tkr"td|d  dt tj| dd dd	\} |d
< t d| dd \|d< }}|d< |d< }}|d
  |d
< | dd } t|| }d}|tj	@ r|rmt
d|d nd}| d| }| |d } |d dkr|dd }|tj@ rd| vr|d
 drd| } |d< ntj| dd	\} |d< |d d|d< nd|d< || |d< ||d< |S )zParse a MySQL Handshake-packet.<xxxxBr   r0   protocolz$Protocol mismatch; server version = z, client version = Nr6   r7   server_version_originalz<I8sx2sBH2sBxxxxxxxxxx   server_threadidrt   server_statusrM         r9   z5.5.8rd   utf-8mysql_native_passwordr`   capabilities)rQ   unpackPROTOCOL_VERSIONr   r   r;   r<   intreadr   rn   minr   
startswith)	r   res
auth_data1capabilities1capabilities2auth_data_lengthr   
auth_data2sizer2   r2   r3   parse_handshake  sR   

zMySQLProtocol.parse_handshaker"   c              
   C  s   | d dks
t di }zTtd| dd d |d< t| dd \} |d< t| \} |d	< td
| dd \|d< |d< | dd } | r^t| \} |d< |d d|d< W |S W |S  tyq } zt d|d}~ww )zParse a MySQL OK-packetr/   r   z#Failed parsing OK packet (invalid).r   r0   field_countNaffected_rows	insert_idz<HHstatus_flagwarning_countinfo_msgr   zFailed parsing OK packet.)r   rQ   r   r   read_lc_intread_lc_stringr<   
ValueError)r   	ok_packetrq   r2   r2   r3   parse_ok  s,   
zMySQLProtocol.parse_okOptional[int]c              
   C  sF   zt | dd d }|W S  tjtfy" } ztd|d}~ww )z=Parse a MySQL packet with the number of columns in result setr/   Nr   zFailed parsing column count)r   r   rQ   errorr   r   )r   countrq   r2   r2   r3   parse_column_count  s   
z MySQLProtocol.parse_column_countr   encodingr   c              	   C  s   t | dd \} }t | \} }t | \} }t | \} }t | \} }t | \} }ztd| \}}}}}W n tjyH   tddw |||dddd| tj@ ||f	S )zParse a MySQL column-packet.r/   Nz	<xHIBHBxxz!Failed parsing column information)	r   r   rQ   r   r   r   r<   r   NOT_NULL)r   r   _rm   rt   column_typeflagsr2   r2   r3   parse_column  s6   


zMySQLProtocol.parse_columnr    c              
   C  s   |d dkr|  |S d}i }ztd|}W n tjy) } zt||d}~ww |d dkr6t|dks:t||d	 |d
< |d |d< |S )zParse a MySQL EOF-packetr/   r   zFailed parsing EOF packet.z<xxxBBHHNr   r'   	   r(   r      r   )r   rQ   r   r   r   rG   )selfr   err_msgr   unpackedrq   r2   r2   r3   	parse_eof9  s   

zMySQLProtocol.parse_eofTwith_headerr#   c           	      C  s  d}i }dg}d}|r| dd  d}n|  d}|D ]c}zdd | dd	D \}}W n ty> } zt||d}~ww |d
}zt|||< W q ttfy   zt|d
||< W n ty| } zt| d| dt| d|d}~ww Y qw |S )zParse the statistics packetz)Failed getting COM_STATISTICS informationrM   r/   Ns     c                 S  s   g | ]}|  qS r2   )strip)rH   vr2   r2   r3   
<listcomp>[      z2MySQLProtocol.parse_statistics.<locals>.<listcomp>   :r(   r   z (:rx   )	splitr   r   r<   r[   r~   r   r   repr)	r   r   errmsgr   pairslblpairvalrq   r2   r2   r3   parse_statisticsM  s6   


 zMySQLProtocol.parse_statisticssockr%   versionTuple[int, ...]r   ATuple[List[Tuple[Optional[bytes], ...]], Optional[EofPacketType]]c                 C  s&  |}g }d}d}d}	 |s||kr	 ||fS |  }	|	drS|	dd g}
|  }	|	drA|
|	dd  |  }	|	ds/|
|	dd  td|
}n!|	d dkrg|	d dk rg| |	}d}nd}tt|	dd }|du r|dur|| n|du r|du rt|	|d	7 }q)
zRead MySQL text result

        Reads all or given number of rows from the socket.

        Returns a tuple with 2 elements: a list with all rows and
        the EOF packet.
        Nr   Ts   r/   rM   r'      r   )	recvr   rS   r   read_lc_string_listrU   r   r-   r   )r   r   r   r   r   r   eofrowdatair   datasr2   r2   r3   read_text_resultj  s<   



zMySQLProtocol.read_text_resultfieldTuple[bytes, int]c                 C  s   |d t jkrd}d}n&|d t jkrd}d}n|d t jt jfv r'd}d}n|d t jkr2d}d}|d	 tj@ r=| }| |d
 t	
|| d| d fS )z%Parse an integer from a binary packetr   <b<hr(   <ir/   <qr   r   Nr   )r   TINYSHORTINT24LONGLONGLONGr   UNSIGNEDupperrQ   r   )r   r   format_lengthr2   r2   r3   _parse_binary_integer  s   $z#MySQLProtocol._parse_binary_integerTuple[bytes, float]c                 C  sD   |d t jkrd}d}nd}d}| |d t|| d| d fS )z)Parse a float/double from a binary packetr   r   <dr/   z<fNr   )r   DOUBLErQ   r   )r   r   r   r   r2   r2   r3   _parse_binary_float  s   $z!MySQLProtocol._parse_binary_floatutf8Tuple[bytes, Decimal]c                 C  s    t | \} }| t||fS )z(Parse a New Decimal from a binary packet)r   r   r   r<   )r   rt   valuer2   r2   r3   _parse_binary_new_decimal  s   z'MySQLProtocol._parse_binary_new_decimal
field_type?Tuple[bytes, Optional[Union[datetime.date, datetime.datetime]]]c              	   C  s   | d }d}|dkr8t d| dd d }| d }| d }|tjtjfv r/tj|||d}nAtj|||d}n8|dkrpd}|d	krPt d
| d|d  d }tjt d| dd d | d | d | d | d | d |d}| |d d |fS )z&Parse a timestamp from a binary packetr   Nr/   r{   r   r   )yearmonthdayr      <Ir   r0      )r   r   r   hourminutesecondmicrosecond)rQ   r   r   DATETIME	TIMESTAMPdatetimedate)r   r   r   r   r   r   r   mcsr2   r2   r3   _parse_binary_timestamp  s.   
z%MySQLProtocol._parse_binary_timestamp Tuple[bytes, datetime.timedelta]c                 C  s   | d }|s| dd t  fS | d|d  }d}|dkr*td|dd d }td|dd d }|d dkr@|d9 }t j||d ||d	 |d d
}| |d d |fS )z'Parse a time value from a binary packetr   r   Nr   r   r0   r9   r   r   )dayssecondsmicrosecondsminuteshours)r  	timedeltarQ   r   )r   r   r   r	  r  tmpr2   r2   r3   _parse_binary_time  s$   z MySQLProtocol._parse_binary_timefieldsList[DescriptionType]Tuple[BinaryProtocolType, ...]c           
   	   C  s  t |d d d }dd |d| D }||d }g }d}t|D ]\}}	|t|d d  d|d d > @ r?|d q#|	d tjtjtjtjtj	fv r]| 
||	\}}|| q#|	d tjtjfv ru| ||	\}}|| q#|	d tjtjfv r| ||\}}|| q#|	d tjtjtjfv r| ||	d \}}|| q#|	d tjkr| |\}}|| q#|	d tjks|	d d	krt|\}}|| q#t|\}}z
||| W q# ty   || Y q#w t|S )
z(Parse values from a binary result packetr   r(   r   c                 S  s   g | ]}t |qS r2   )r[   )rH   r   r2   r2   r3   r     r   z6MySQLProtocol._parse_binary_values.<locals>.<listcomp>r   Nr   ?   )rG   	enumerater[   rS   r   r   r   r   r   r   r   r   FLOATr   DECIMAL
NEWDECIMALr   r  DATEr  r
  TIMEr  r   BINARYr   r   r<   UnicodeDecodeErrortuple)
r   r  r   rt   null_bitmap_lengthnull_bitmaprP   r   posr   r2   r2   r3   _parse_binary_values  sX   $
z"MySQLProtocol._parse_binary_valuescolumnsDTuple[List[Tuple[BinaryProtocolType, ...]], Optional[EofPacketType]]c           
      C  s   g }d}d}d}	 |dur	 ||fS ||kr	 ||fS t | }	|	d dkr/| |	}d}n|	d dkrBd}| ||	dd |}|du rP|durP|| n|du r\|du r\t|	|d7 }q	)zwRead MySQL binary protocol result

        Reads all or given number of binary resultset rows from the socket.
        Nr   Tr/   r'   r0   r   )r-   r   r   r$  rS   r   )
r   r   r%  r   rt   r   r   rP   r   r   r2   r2   r3   read_binary_result-  s0   
z MySQLProtocol.read_binary_resultDict[str, int]c              
   C  s   | d dks
t di }z5t| dd d\} |d< t| d\} |d< t| d\} |d	< | d
d } t| d\} |d< W |S  tyR } zt d|d}~ww )z(Parse a MySQL Binary Protocol OK packet.r/   r   zFailed parsing Binary OK packetr0   Nr   r(   num_columns
num_paramsr   r   )r   r   r?   r   )r   ok_pktrq   r2   r2   r3   parse_binary_prepare_okO  s   
z%MySQLProtocol.parse_binary_prepare_okr   Tuple[bytes, int, int]c                 C  s   d}d}| dk r,| dkrd}t j}n?| dkrd}t j}n5| dkr&d}t j}n+d	}t j}n%d
}| dkr8d}t j}n| dkrBd}t j}n| dkrLd}t j}nt j}d}t|| ||fS )z0Prepare an integer for the MySQL binary protocolNr   ir   i r   i   r   r      r)   rL   i  r{   l    r   z<Q)r   r   r   r   r   rQ   rR   )r   r   r   r   r2   r2   r3   prepare_binary_integera  s6   z$MySQLProtocol.prepare_binary_integer'Union[datetime.date, datetime.datetime]c                 C  s   t | tjr
tj}nt | tjrtj}ntdt| j	t
| jt
| jg}t | tjrQ|t
| jt
| jt
| jg | jdkrQ|t| j d|}t
t|| |fS )a  Prepare a timestamp object for the MySQL binary protocol

        This method prepares a timestamp of type datetime.datetime or
        datetime.date for sending over the MySQL binary protocol.
        A tuple is returned with the prepared value and field type
        as elements.

        Raises ValueError when the argument value is of invalid type.

        Returns a tuple.
        z2Argument must a datetime.datetime or datetime.dater   rM   )
isinstancer  r   r  r  r  r   r   r   r   ro   r   r   extendr  r  r  r  rS   r   rU   rG   )r   r   chunkspackedr2   r2   r3   prepare_binary_timestamp  s(   







z&MySQLProtocol.prepare_binary_timestamp(Union[datetime.timedelta, datetime.time]c           
      C  s  t | tjtjfstdtj}d}d}tg }t | tjrP| jdk r%d}t	| j
d\}}t	|d\}}|tt| jt|t|t|g | j}n|tdt| jt| jt| jg | j}|ru|t| |t| d|}	tt|	|	 |fS )a  Prepare a time object for the MySQL binary protocol

        This method prepares a time object of type datetime.timedelta or
        datetime.time for sending over the MySQL binary protocol.
        A tuple is returned with the prepared value and field type
        as elements.

        Raises ValueError when the argument value is of invalid type.

        Returns a tuple.
        z3Argument must a datetime.timedelta or datetime.timer   Nr   i  <   rM   )r1  r  r  timer   r   r  r   r  divmodr  r2  r   r   absro   r  r  r  r  r  rS   
appendleftrU   rG   )
r   r   negativer	  r3  r  	remainderminssecsr4  r2   r2   r3   prepare_binary_time  s@   




z!MySQLProtocol.prepare_binary_time	statementparamr   c                 C  s   d t| t||gS )zMPrepare long data for prepared statements

        Returns a string.
        rM   r   )rA  rB  r   r2   r2   r3   prepare_stmt_send_long_data  s   z)MySQLProtocol.prepare_stmt_send_long_datar2   Sequence[BinaryProtocolType]
parametersr   r   long_data_used Optional[Dict[int, Tuple[bool]]]query_attrs.Optional[List[Tuple[str, BinaryProtocolType]]]converter_str_fallbackc	              	   C  s  d}	dgt |d d  }
g }g }d}t |}g }|s|n|t }|dkr'd}|du r-i }|rJt|}|D ]	\}}|| q5dgt |d d  }
|sO|r|t |krYtd	t|D ]-\}}d}|du r|
|d   d|d > O  < |ttj	t|  q]||v r|| d rtj
}ntj}nt|tr| |\}}}|| nt|tr||}|tt ||  tj}nt|tr|tt ||  tj}nt|tr|tt t||t||  tj}net|tr|td
| tj}nRt|tjtjfr"| |\}}|| n;t|tjtjfr9| |\}}|| n$|rSt||}|tt ||  tj}n
td|j j! d|t|t|  |r|d |kr|||  d |}|tt ||  q]t"|t|t"|	g}|dur|t | }n|}|r|dur|t| |#dd |
D  |td d}|D ]'}|| |dur|d |kr||||   n|d |d7 }q|D ]}|| qd$|S )z6Make a MySQL packet with the Statement Execute commandr   r   r   r   rM   utf8mb4r   NzTFailed executing prepared statement: data values does not match number of parametersr   z&MySQL binary protocol can not handle 'z	' objectsc                 S  s   g | ]}t d |qS )B)rQ   rR   )rH   bitr2   r2   r3   r   _  s    z3MySQLProtocol.make_stmt_execute.<locals>.<listcomp>r6   )%rG   r   listrS   r   r  r   ro   r   NULLBLOBSTRINGr1  r[   r/  rb   rT   lc_intr-   r   r  floatrQ   rR   r   r  r  r5  r  r8  r@  r   	__class____name__r   r2  rU   )r   r   r   rE  r   rF  rt   rH  rJ  iteration_countr"  rP   typesr4  data_lenquery_attr_namesr   attr_valr#  r   _flagsr   rm   r   parameter_countr   a_typea_valuer2   r2   r3   make_stmt_execute  s   











zMySQLProtocol.make_stmt_execute)r,   r-   r.   r-   )r,   r-   r.   r5   )rC   rD   r.   r-   )rZ   r[   r\   r]   r.   r-   )NFN)r`   r-   ra   rb   rc   rb   rZ   r[   rd   rb   re   r]   rf   rg   rh   ri   r.   rj   )rs   r!   ra   rb   rc   rb   r\   r]   rt   r[   rZ   r[   ru   r[   rd   r]   re   r]   rC   rv   rw   rg   rf   rg   rh   ri   r.   rj   )rt   r[   rZ   r[   ru   r[   r.   r-   rF   )r   r[   r   r   r.   r-   )r   )r   r[   r   r[   r.   r-   )r   r-   r.   r!   )r   r-   r.   r"   )r   r-   r.   r   )r   )r   r-   r   rb   r.   r   )r   r-   r.   r    )T)r   r-   r   rg   r.   r#   )r   r%   r   r   r   r[   r.   r   )r   r-   r   r   r.   r   )r   r-   r   r   r.   r   )r   )r   r-   rt   rb   r.   r   )r   r-   r   r[   r.   r   )r   r-   r.   r  )r  r  r   r-   rt   rb   r.   r  )r   r   )
r   r%   r%  r  r   r[   rt   rb   r.   r&  )r   r-   r.   r(  )r   r[   r.   r-  )r   r0  r.   r   )r   r6  r.   r   )rA  r[   rB  r[   r   r-   r.   r-   )r2   r2   r   Nr   NF)r   r[   r   rD  rE  r   r   r[   rF  rG  rt   rb   rH  rI  rJ  rg   r.   r-   )%rU  
__module____qualname____doc__staticmethodr4   r>   rB   rY   r_   rr   DEFAULT_CHARSET_IDDEFAULT_MAX_ALLOWED_PACKETr   r   r   r   r   r   r   r   r   r   r   r   r   r   r
  r  r$  r'  r,  r/  r5  r@  rC  r_  r2   r2   r2   r3   r+   U   s    Az 3
 ):"!*7
r+   ):rb  
__future__r   r  rQ   collectionsr   decimalr   r   typingr   r   r   r	   r
   r   r   r   r   rE   r   	constantsr   r   r   r   r   errorsr   r   r   r   r   pluginsr   r   plugins.caching_sha2_passwordr   rW  r   r   r    r!   r"   r#   r$   networkr%   r   r:   r1   	OK_STATUSr@   
ERR_STATUSrd  re  r+   r2   r2   r2   r3   <module>   s2   ,$
