Viewing File: /opt/imunify360/venv/lib/python3.11/site-packages/pymysql/__pycache__/protocol.cpython-311.pyc



]j$.ddlmZddlmZmZddlmZddlZddlZdZ	dZ
dZdZd	Z
d
ZdZGdd
ZGddeZGddZGddZGddZdS))MBLENGTH)
FIELD_TYPE
SERVER_STATUS)errNFc	d	tdttddD]:}tj|}td||jj|jfz;tdn#t$rYnwxYwfdtdttd	d
D}|D]i}td
d|Dd
d
t|z
zzdzd
fd|DzjtdtdS)NcDd|cxkrdkrnnt|SdS)N .)chr)datas G/opt/imunify360/venv/lib64/python3.11/site-packages/pymysql/protocol.py	printablezdump_packet.<locals>.printables5
t99szpacket length:rzcall[%d]: %s (line %d)zB------------------------------------------------------------------c*g|]}||dzS)).0irs  r
<listcomp>zdump_packet.<locals>.<listcomp>#s&MMMaa!b&j!MMMrrr c3K|]}|dV	dS)02XNr)rxs  r	<genexpr>zdump_packet.<locals>.<genexpr>&s&++AZZ++++++rz   z  c3.K|]}|VdSNr)rr!rs  rr"zdump_packet.<locals>.<genexpr>)s+..qiill......r)printlenrangesys	_getframef_codeco_namef_lineno
ValueErrorminjoin)rrf	dump_datadrs`    @rdump_packetr4s


D		***q!	P	PA
a  A*a1A1:-NNOOOO
h



MMMM5CD		34G4G+L+LMMMI



HH+++++++rCFF{#
$
gg....A.....
/	
	
	
	

(OOO	GGGGGsA7A??
BBceZdZdZdZdZdZdZdZdZ	d d	Z
d!dZdZd
Z
dZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdS)"MysqlPacketzrRepresentation of a MySQL response packet.

    Provides an interface for reading/parsing the packet results.
    	_position_datac"d|_||_dS)Nrr7selfrencodings   r__init__zMysqlPacket.__init__7s


rc|jSr%r9r<s rget_all_datazMysqlPacket.get_all_data;s
zrc
Z|j|j|j|z}t||krkd|dt|d|jdt|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&dumpAssertionError)r<sizeresulterrors    rreadzMysqlPacket.read>sDNdnt.CDEv;;$x xx,/KKxxFJnxxfijnjtfufuxx

e		 '''$
rc<|j|jd}d|_|S)z`Read all remaining data in the packet.

        (Subsequent read() will return errors.)
        Nr9r8r<rHs  rread_allzMysqlPacket.read_allMs$
DN,,-
rc|j|z}|dks|t|jkrtd|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   radvancezMysqlPacket.advanceVs]~.!|c$*oo==Y6YY<YY
&rrct|dks|t|jkrtd|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  rrewindzMysqlPacket.rewind_s<a<<8c$*oo55G(RSSS!rrc&|j|||zS)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_bytesesz(h&7899rcJ|j|j}|xjdz
c_|SNrrLrMs  r
read_uint8zMysqlPacket.read_uint8ps%DN+!
rcrtjd|j|jd}|xjdz
c_|S)Nz<Hrstructunpack_fromr9r8rMs  rread_uint16zMysqlPacket.read_uint16u4#D$*dnEEaH!
rcxtjd|j|j\}}|xjdz
c_||dzzS)Nz<HBrr^)r<lowhighs   rread_uint24zMysqlPacket.read_uint24zs=&udj$.II	T!dbj!!rcrtjd|j|jd}|xjdz
c_|S)Nz<Irr^rMs  rread_uint32zMysqlPacket.read_uint32rbrcrtjd|j|jd}|xjdz
c_|S)Nz<Qrr^rMs  rread_uint64zMysqlPacket.read_uint64rbrc|jd|j}|dkrdS|j|j|}|dz|_|S)Nrr)r9findr8)r<end_posrHs   rread_stringzMysqlPacket.read_stringsJ*//%88Q;;4DNW45 1
rc|}|tkrdS|tkr|S|tkr|S|t
kr|S|tkr|SdS)zRead 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_COLUMNUNSIGNED_CHAR_COLUMNUNSIGNED_SHORT_COLUMNraUNSIGNED_INT24_COLUMNrgUNSIGNED_INT64_COLUMNrm)r<cs  rread_length_encoded_integerz'MysqlPacket.read_length_encoded_integers
OO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  rread_length_coded_stringz$MysqlPacket.read_length_coded_strings11133>4yy   rctj|}||j|j}|xj|jz
c_|Sr%)r_Structr`r9r8rG)r<fmtsrHs    rread_structzMysqlPacket.read_structs?M#tz4>::!& 
rcT|jddkot|jdkS)Nrrr9r'rAs ris_ok_packetzMysqlPacket.is_ok_packets%z!}!:c$*oo&::rcT|jddkot|jdkS)Nrr	rrAs r
is_eof_packetzMysqlPacket.is_eof_packets'z!}$<TZ1)<<rc$|jddkS)Nrrr@rAs ris_auth_switch_requestz"MysqlPacket.is_auth_switch_requestsz!}$$rc$|jddkS)Nrrr@rAs ris_extra_auth_datazMysqlPacket.is_extra_auth_datasz!}!!rc<|jd}d|cxkodkncS)Nrrr@)r<field_counts  ris_resultset_packetzMysqlPacket.is_resultset_packets/jmK&&&&3&&&&&rc$|jddkS)Nrrr@rAs ris_load_local_packetz MysqlPacket.is_load_local_packetz!}$$rc$|jddkS)Nrr@rAs ris_error_packetzMysqlPacket.is_error_packetrrcZ|r|dSdSr%)rraise_for_errorrAs rcheck_errorzMysqlPacket.check_errors8!!	#  """""	#	#rc||d|}trt	d|tj|jdS)Nrzerrno =)rVrSrarDr&rraise_mysql_exceptionr9)r<errnos  rrzMysqlPacket.raise_for_errors`


Q  ""	$)U###!$*-----rc.t|jdSr%)r4r9rAs rrEzMysqlPacket.dumpsDJrN)r)r)__name__
__module____qualname____doc__	__slots__r>rBrJrNrSrVrXr[rargrjrmrrrzr|rrrrrrrrrrrErrrr6r6/s
'I


&&&""""	:	:	:	:

"""


&&&$
!
!
!;;;===%%%"""'''%%%%%%###...     rr6c0eZdZdZdZdZdZdZdZdS)FieldDescriptorPacketzA 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.
    cht|||||dSr%)r6r>_parse_field_descriptorr;s   rr>zFieldDescriptorPacket.__init__s4T4222$$X.....rc2||_||_|||_|||_|||_|||_|d\|_	|_
|_|_|_
dS)zParse the 'Field Descriptor' (Metadata) packet.

        This is compatible with MySQL 4.1+ (not compatible with MySQL 4.0).
        z	<xHIBHBxxN)r|catalogdbdecode
table_name	org_tablenameorg_namer	charsetnrrQ	type_codeflagsscale)r<r=s  rrz-FieldDescriptorPacket._parse_field_descriptors
4466//117799@@JJ6688??II1133::8DD	5577>>xHH

[))
	
NKNJJJJrc|j|jd|||j|jdzdkfS)zBProvides a 7-item tuple compatible with the Python PEP249 DB Spec.Nr]r)rrget_column_lengthrrrAs rdescriptionz!FieldDescriptorPacket.descriptionsL
IN""$$""$$JJNa
	
rc|jtjkr$tj|jd}|j|zS|jSrZ)rr
VAR_STRINGrgetrrQ)r<mblens  rrz'FieldDescriptorPacket.get_column_length
s:>Z222L33E;%''{rcrd|j|j|j|j|j|jS)Nz&{} {!r}.{!r}.{!r}, type={}, flags={:x})format	__class__rrrrrrAs r__str__zFieldDescriptorPacket.__str__s87>>NGOINJ


	
rN)	rrrrr>rrrrrrrrrsi///****










rrceZdZdZdZdZdS)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|jjzdz||_|jd|j|_|j|_	|
d\|_|_|j
|_|jtjz|_dS)NzCannot create z  object from invalid packet typerz<HH)rr.strrrpacketrSrz
affected_rows	insert_idr
server_status
warning_countrNmessagerSERVER_MORE_RESULTS_EXISTShas_nextr<from_packets  rr>zOKPacketWrapper.__init__%s''))	 dn-../45
"A![DDFF@@BB151A1A%1H1H.D.{++--*]-UU


rc,t|j|Sr%getattrrr<keys  r__getattr__zOKPacketWrapper.__getattr__6t{C(((rNrrrrr>rrrrrrs?VVV")))))rrceZdZdZdZdZdS)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|jd||_|jd\|_|_trtd|j|jtj
z|_dS)NCannot create '!' object from invalid packet typez<xhhzserver_status=)rr.rrrrrrDr&rrrrs  rr>zEOFPacketWrapper.__init__As((**	S$.SSS
"151H1H1P1P.D.	8"D$6777*]-UU


rc,t|j|Sr%rrs  rrzEOFPacketWrapper.__getattr__MrrNrrrrrr:s?
V
V
V)))))rrceZdZdZdZdZdS)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|jd||_|jdd|_trtd|jdSdS)Nrrrz	filename=)rr.rrrBfilenamerDr&rs  rr>zLoadLocalPacketWrapper.__init__Xs//11	S$.SSS
"00221226
	.+t}-----	.	.rc,t|j|Sr%rrs  rrz"LoadLocalPacketWrapper.__getattr__crrNrrrrrrQs<	.	.	.)))))rr)charsetr	constantsrrr#rr_r)rDrtrurvrwrxr4r6rrrrrrr<module>rsf00000000







	4o o o o o o o o d:
:
:
:
:
K:
:
:
z))))))))8)))))))).))))))))))r
Back to Directory File Manager