File: //proc/thread-self/root/var/opt/nydus/ops/mysql/connector/__pycache__/cursor.cpython-39.pyc
a
�,�h� � @ s� d Z ddlmZ ddlZddlZddlZddlZddlmZm Z ddl
mZ ddlm
Z
mZmZmZmZmZmZmZmZmZmZmZ ddlmZmZ dd lmZ dd
lmZm Z m!Z!m"Z"m#Z# ddl$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/ e
�rddl0m1Z1 d
Z2e�3de2� de2� d�ej4ej5B ej6B �Z7e�3dej4ej5B ej6B �Z8e�3de2� de2� d�ej4ej5B ej6B �Z9e�3dej4ej5B ej6B �Z:e�3d�Z;e�3dej<�Z=e�3d�Z>e�3d�Z?e�3d�Z@e�3d�ZAdZBdZCddd�d d!�ZDdd"d#�d$d%�ZEG d&d'� d'�ZFdd(dd)�d*d+�ZGG d,d-� d-e�ZHG d.d/� d/eH�ZIG d0d1� d1eI�ZJG d2d3� d3eI�ZKG d4d5� d5eJ�ZLG d6d7� d7eI�ZMG d8d9� d9eI�ZNG d:d;� d;eI�ZOG d<d=� d=eNeJ�ZPG d>d?� d?eOeJ�ZQG d@dA� dAeNeM�ZRG dBdC� dCeOeM�ZSG dDdE� dEeM�ZTdS )FzCursor classes.� )�annotationsN)�deque�
namedtuple)�Decimal)�
TYPE_CHECKING�Any�Deque�Dict� Generator�Iterator�List�NoReturn�Optional�Sequence�Tuple�Union� )�NAMED_TUPLE_CACHE�MySQLCursorAbstract)�
ServerFlag)�Error�InterfaceError�NotSupportedError�ProgrammingError�get_mysql_exception)�DescriptionType�
EofPacketType�MySQLConvertibleType�ParamsDictType�ParamsSequenceOrDictType�ParamsSequenceType�
ResultType�RowItemType�RowType�
StrOrBytes�WarningType)�MySQLConnectionz\/\*.*?\*\/�(z)|(["'`][^"'`]*?(z)[^"'`]*?["'`])z<\s*ON\s+DUPLICATE\s+KEY(?:[^"'`]*["'`][^"'`]*["'`])*[^"'`]*$z|\s)*INSERT(z[|\s)*(?:IGNORE\s+)?INTO\s+[`'\"]?.+[`'\"]?(?:\.[`'\"]?.+[`'\"]?){0,2}\s+VALUES\s*(\(.+\)).*z.*VALUES\s*(\(.+\)).*s (%s)sV
%
\((?P<mapping_key>[^)]+)\)
(?P<conversion_type>[diouxXeEfFgGcrs%])
s4 ;(?=(?:[^"'`]*(?:"[^"]*"|'[^']*'|`[^`]*`))*[^"'`]*$)s+ %s(?=(?:[^"'`]*["'`][^"'`]*["'`])*[^"'`]*$)z %\(.*?\)sz%\((.*?)\)szNo result set to fetch froml �� �bytes�bool)�stmt�returnc C sN t | �dko.| �d�o.t�t| d ��d dv }t | �dkoD| �d�}|pL|S )a� Checks if statement is an end-of-line comment.
Double-dash comment style requires the second dash to be
followed by at least one whitespace (Z) or control character (C) such
as a space, tab, newline, and so on.
Hash comment simply requires start from `#` and nothing else.
Args:
stmt: MySQL statement.
Returns:
Whether or not the statement is an end-of-line comment.
References:
[1]: https://dev.mysql.com/doc/refman/8.0/en/comments.html
� s --� r > �Z�C� #)�len�
startswith�unicodedata�category�chr)r* Zis_double_dash_commentZis_hash_comment� r6 �I/opt/nydus/tmp/pip-target-wkfpz8uv/lib64/python/mysql/connector/cursor.py�is_eol_commentx s ��r8 zDeque[bytes])�
multi_stmtr+ c C sj t t�| ��}dt|� }}|dkrT|d8 }|�� �� }|r|}t|�s|�|� qt|�rf|�|� |S )ac Parses a multi-statement query/operation.
Parsing consists of removing empty (which includes just whitespaces and/or control
characters) statements and EOL (end-of-line) comments.
However, there's a caveat, by rule, the last EOL comment found in the stream isn't
removed if and only if it's the last statement.
Why? EOL comments do not generate results, however, when the last statement is an
EOL comment the server returns an empty result. So, in other to match statements
and results correctly we need to keep the last EOL comment statement.
Args:
multi_stmt: Query representing multi-statement operations separated by semicolons.
Returns:
A list of statements that aren't empty and don't contain leading
ASCII whitespaces. Also, they aren't EOL comments except
perhaps for the last one.
� r r )r �RE_SQL_SPLIT_STMTS�splitr1 �popleft�lstripr8 �append)r9 �
executed_listr* Znum_stmsZ stmt_nextr6 r6 r7 �parse_multi_statement_query� s
rA c @ sB e Zd ZdZddd�dd�Zddd �d
d�Zedd
�dd��ZdS )�_ParamSubstitutorz4
Substitutes parameters into SQL statement.
zSequence[bytes]�None��paramsr+ c C s || _ d| _d S �Nr )rE �index)�selfrE r6 r6 r7 �__init__� s z_ParamSubstitutor.__init__�re.Matchr( ��matchobjr+ c C sF | j }| j d7 _ zt| j| �W S ty@ td�d �Y n0 d S )Nr z+Not enough parameters for the SQL statement)rG r( rE �
IndexErrorr )rH rL rG r6 r6 r7 �__call__� s ��z_ParamSubstitutor.__call__�int�r+ c C s t | j�| j S )z8Returns number of parameters remaining to be substituted)r1 rE rG �rH r6 r6 r7 � remaining� s z_ParamSubstitutor.remainingN)�__name__�
__module__�__qualname__�__doc__rI rN �propertyrR r6 r6 r6 r7 rB � s
rB zDict[bytes, bytes])�bytestr�
value_dictr+ c s$ ddd�� fdd�}t �|| �}|S )ah
>>> _bytestr_format_dict(b'%(a)s', {b'a': b'foobar'})
b'foobar
>>> _bytestr_format_dict(b'%%(a)s', {b'a': b'foobar'})
b'%%(a)s'
>>> _bytestr_format_dict(b'%%%(a)s', {b'a': b'foobar'})
b'%%foobar'
>>> _bytestr_format_dict(b'%(x)s %(y)s',
... {b'x': b'x=%(y)s', b'y': b'y=%(x)s'})
b'x=%(y)s y=%(x)s'
rJ r( rK c sV d}| � � }|d dkrd}|d dkr8|d }� | }|du rRtd|d � ���|S )zReplace pattern.NZconversion_type� %� sZmapping_keyzUnsupported conversion_type: )� groupdict�
ValueError)rL �value�groups�key�rY r6 r7 �replace� s �z%_bytestr_format_dict.<locals>.replace)�RE_PY_MAPPING_PARAM�sub)rX rY rb r* r6 ra r7 �_bytestr_format_dict� s
re c s" e Zd ZU dZdZded<