Ë
    Ûqji$  ã                  ó  — U d Z ddlmZ ddlZddlmZ ddlmZmZ ddl	m
Z
 ddl	mZ dd	lmZmZ dd
lmZmZmZ ddlmZ ddlmZmZmZ ddlmZ er&ddlmZ ddlmZ ddl m!Z!m"Z" ddl#m$Z$ ddl%m&Z& ddl'm(Z( dZ)de*d<   e
jV                  jX                  Z,e
jV                  jZ                  Z-e
j\                  j^                  Z/e
j`                  jb                  Z1 ejd                  d«      Z3 G d„ d«      Z4 G d„ de4«      Z5 G d„ de4«      Z6y)z
commands pipeline management
é    )ÚannotationsN)ÚTracebackType)ÚAnyÚTYPE_CHECKINGé   )Úpq)Úerrors)ÚPipelineCommandÚPQGen)ÚDequeÚSelfÚ	TypeAlias)Úconnection_summary)Úpipeline_communicateÚ
fetch_manyÚsend)Úcapabilities)ÚPGresult)Ú
Connection)ÚKeyÚPrepare)Ú
BaseCursor)ÚBaseConnection)ÚAsyncConnectionzEtuple[BaseCursor[Any, Any], tuple[Key, Prepare, bytes] | None] | Noner   ÚPendingResultÚpsycopgc                  ó–   — e Zd ZU ded<   ded<   dd„Zdd„Zedd„«       Zedd„«       Z	dd	„Z
dd
„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zy)ÚBasePipelinezDeque[PipelineCommand]Úcommand_queuezDeque[PendingResult]Úresult_queuec                óš   — || _         |j                  | _        t        t           «       | _        t        t
           «       | _        d| _        y )Nr   )Ú_connÚpgconnr   r
   r   r   r    Úlevel)ÚselfÚconns     úR/var/www/html/kelly-backend/venv/lib/python3.12/site-packages/psycopg/_pipeline.pyÚ__init__zBasePipeline.__init__/   s;   € ØˆŒ
Ø—k‘kˆŒÜ"¤?Ñ3Ó5ˆÔÜ!¤-Ñ0Ó2ˆÔØˆ�
ó    c                óÊ   — | j                   j                  › d| j                   j                  › �}t        | j                  j
                  «      }d|› d|› dt        | «      d›d�S )NÚ.Ú<Ú z at 0xÚxÚ>)Ú	__class__Ú
__module__Ú__qualname__r   r"   r#   Úid)r%   ÚclsÚinfos      r'   Ú__repr__zBasePipeline.__repr__6   s]   € Ø—‘×*Ñ*Ð+¨1¨T¯^©^×-HÑ-HÐ,IÐJˆÜ! $§*¡*×"3Ñ"3Ó4ˆØ�3�%�q˜˜˜f¤R¨£X¨a L°Ð2Ð2r)   c                óT   — t        j                  | j                  j                  «      S ©N)r   ÚPipelineStatusr#   Úpipeline_status©r%   s    r'   ÚstatuszBasePipeline.status;   s   € ä× Ñ  §¡×!<Ñ!<Ó=Ð=r)   c                ó*   — t        j                  «       S )zCReturn `!True` if the psycopg libpq wrapper supports pipeline mode.)r   Úhas_pipeline)r4   s    r'   Úis_supportedzBasePipeline.is_supported?   s   € ô ×(Ñ(Ó*Ð*r)   c              #  ó<  K  — t        j                  d¬«       | j                  dk(  r| j                  j	                  «        nA| j
                  s| j                  j                  t        k(  r| j                  «       E d {  –—†  | xj                  dz  c_        y 7 Œ­w)NT)Úcheckr   r   )	r   r>   r$   r#   Úenter_pipeline_moder   Útransaction_statusÚACTIVEÚ	_sync_genr;   s    r'   Ú
_enter_genzBasePipeline._enter_genD   sm   è ø€ Ü×!Ñ!¨Õ-Ø�:‰:˜Š?Ø�K‰K×+Ñ+Õ-Ø×Ò 4§;¡;×#AÑ#AÄVÒ#Kð —~‘~Ó'×'Ð'Ø�
Š
�a‰Ž
ð (ús   ‚A=BÁ?BÂ Bc                óV  — | xj                   dz  c_         | j                   dk(  r:| j                  j                  t        k7  r	 | j                  j	                  «        y y y # t
        j                  $ r5}|rt        j                  d| |«       n|j                  d «      ‚Y d }~y d }~ww xY w)Nr   r   zerror ignored exiting %r: %s)
r$   r#   r<   ÚBADÚexit_pipeline_modeÚeÚOperationalErrorÚloggerÚwarningÚwith_traceback)r%   ÚexcÚexc2s      r'   Ú_exitzBasePipeline._exitR   sŒ   € Ø�
Š
�a‰�
Ø�:‰:˜Š?˜tŸ{™{×1Ñ1´SÒ8ð	4Ø—‘×.Ñ.Õ0ð  9ˆ?øô ×%Ñ%ò 4ñ Ü—N‘NÐ#AÀ4ÈÕNà×-Ñ-¨dÓ3Ð3ô Oûð4ús   ÁA  Á B(Á3+B#Â#B(c              #  ó˜   K  — | j                  «        | j                  «       E d {  –—†  | j                  d¬«      E d {  –—†  y 7 Œ7 Œ­w)NF©Úflush©Ú_enqueue_syncÚ_communicate_genÚ
_fetch_genr;   s    r'   rE   zBasePipeline._sync_gen`   sA   è ø€ Ø×ÑÔØ×(Ñ(Ó*×*Ð*Ø—?‘?¨�?Ó/×/Ñ/ð 	+øØ/ús!   ‚$A
¦A§A
Á AÁA
ÁA
c              #  óÚ   K  — 	 | j                  «        | j                  «       E d{  –—†  | j                  d¬«      E d{  –—†  y7 Œ7 Œ# | j                  d¬«      E d{  –—†7   w xY w­w)z_
        Exit current pipeline by sending a Sync and fetch back all remaining results.
        NTrS   rU   r;   s    r'   Ú	_exit_genzBasePipeline._exit_gene   sZ   è ø€ ð	3Ø×ÑÔ Ø×,Ñ,Ó.×.Ð.à—‘¨T�Ó2×2Ñ2ð /øà2ù�t—‘¨T�Ó2×2Ò2üsI   ‚A+„#A §A¨A ¬A+ÁA	ÁA+ÁA Á	A+ÁA(Á!A$Á"A(Á(A+c              #  ó  K  — t        | j                  | j                  «      E d{  –—† }d}|D ]/  }| j                  j	                  «       }	 | j                  ||«       Œ1 |�|‚y7 Œ?# t        j                  $ r}|€|}Y d}~ŒUd}~ww xY w­w)zqCommunicate with pipeline to send commands and possibly fetch
        results, which are then processed.
        N)r   r#   r   r    ÚpopleftÚ_process_resultsrJ   ÚError)r%   ÚfetchedÚ	exceptionÚresultsÚqueuedrO   s         r'   rW   zBasePipeline._communicate_geno   s’   è ø€ ô 2°$·+±+¸t×?QÑ?QÓR×RˆØˆ	ÛˆGØ×&Ñ&×.Ñ.Ó0ˆFð$Ø×%Ñ% f¨gÕ6ð ð Ð ØˆOð !ð Sùô —7‘7ò $ØÐ$Ø #�Iÿøð$üs9   ‚$B¦A&§%BÁA(ÁBÁ(B	Á;BÁ?BÂB	Â	Bc             #  óÀ  K  — | j                   sy|r7| j                  j                  «        t        | j                  «      E d{  –—†  d}| j                   rZt	        | j                  «      E d{  –—† }|sn:| j                   j                  «       }	 | j                  ||«       | j                   rŒZ|�|‚y7 Œq7 ŒH# t        j                  $ r}|€|}Y d}~Œ2d}~ww xY w­w)a^  Fetch available results from the connection and process them with
        pipeline queued items.

        If 'flush' is True, a PQsendFlushRequest() is issued in order to make
        sure results can be fetched. Otherwise, the caller may emit a
        PQpipelineSync() call to ensure the output buffer gets flushed before
        fetching.
        N)	r    r#   Úsend_flush_requestr   r   r\   r]   rJ   r^   )r%   rT   r`   ra   rb   rO   s         r'   rX   zBasePipeline._fetch_gen   sÒ   è ø€ ð × Ò ØáØ�K‰K×*Ñ*Ô,Ü˜DŸK™KÓ(×(Ð(àˆ	Ø×ÒÜ!+¨D¯K©KÓ!8×8ˆGÙð Ø×&Ñ&×.Ñ.Ó0ˆFð$Ø×%Ñ% f¨gÔ6ð ×Óð Ð ØˆOð !ð )øð 9ùô —7‘7ò $ØÐ$Ø #�Iÿøð$üsT   ‚ACÁB6Á*CÁ/B8Á0!CÂB: Â$CÂ1CÂ8CÂ:CÃCÃCÃCÃCc                óŒ  — |€k|\  }|j                   t        k(  r+t        j                  || j                  j
                  ¬«      ‚|j                   t        k(  rt        j                  d«      ‚y|\  }}|r.|\  }}}|j                  j                  j                  ||||«       |j                  |«       |j                  |«       y)ar  Process a results set fetched from the current pipeline.

        This matches 'results' with its respective element in the pipeline
        queue. For commands (None value in the pipeline queue), results are
        checked directly. For prepare statement creation requests, update the
        cache. Otherwise, results are attached to their respective cursor.
        N)Úencodingzpipeline aborted)r<   ÚFATAL_ERRORrJ   Úerror_from_resultr#   Ú	_encodingÚPIPELINE_ABORTEDÚPipelineAbortedr"   Ú	_preparedÚvalidateÚ_check_resultsÚ_set_results)	r%   rb   ra   ÚresultÚcursorÚprepinfoÚkeyÚprepÚnames	            r'   r]   zBasePipeline._process_resultsŸ   s±   € ð ˆ>Ø‰IˆVØ�}‰}¤Ò+Ü×)Ñ)¨&¸4¿;¹;×;PÑ;PÔQÐQØ—‘Ô"2Ò2Ü×'Ñ'Ð(:Ó;Ð;ð 3ð  &ÑˆF�HÙØ"*‘��T˜4à—‘×&Ñ&×/Ñ/°°T¸4ÀÔIØ×!Ñ! 'Ô*Ø×Ñ Õ(r)   c                ó˜   — | j                   j                  | j                  j                  «       | j                  j                  d«       y)z#Enqueue a PQpipelineSync() command.N)r   Úappendr#   Úpipeline_syncr    r;   s    r'   rV   zBasePipeline._enqueue_sync¶   s4   € à×Ñ×!Ñ! $§+¡+×";Ñ";Ô<Ø×Ñ× Ñ  Õ&r)   N)r&   zBaseConnection[Any]ÚreturnÚNone)ry   Ústr)ry   zpq.PipelineStatus)ry   Úbool)ry   úPQGen[None])rO   úBaseException | Nonery   rz   )rT   r|   ry   r}   )rb   r   ra   zlist[PGresult]ry   rz   ©ry   rz   )Ú__name__r1   r2   Ú__annotations__r(   r6   Úpropertyr<   Úclassmethodr?   rF   rQ   rE   rZ   rW   rX   r]   rV   © r)   r'   r   r   +   si   … Ø)Ó)Ø&Ó&óó3ð
 ò>ó ð>ð ò+ó ð+óó4ó0ó
3óó ó@)ô.'r)   r   c                  ó\   ‡ — e Zd ZU dZdZded<   d	ˆ fd„Zd
d„Zdd„Z	 	 	 	 	 	 	 	 dd„Zˆ xZ	S )ÚPipelinez(Handler for connection in pipeline mode.r   úConnection[Any]r"   c                ó$   •— t         ‰| �  |«       y r8   ©Úsuperr(   ©r%   r&   r0   s     €r'   r(   zPipeline.__init__Â   ó   ø€ Ü‰Ñ˜Õr)   c                ó  — 	 | j                   j                  5  | j                   j                  | j                  «       «       ddd«       y# 1 sw Y   yxY w# t        j
                  $ r}|j                  d«      ‚d}~ww xY w)zkSync the pipeline, send any pending command and receive and process
        all available results.
        N©r"   ÚlockÚwaitrE   rJ   Ú_NO_TRACEBACKrN   ©r%   Úexs     r'   ÚsynczPipeline.syncÅ   sW   € ð	*Ø—‘—“Ø—
‘
—‘ §¡Ó 0Ô1÷ !—‘ûä�‰ò 	*Ø×#Ñ# DÓ)Ð)ûð	*ús4   ‚A ˜*AÁA ÁAÁA ÁA ÁB Á*A;Á;B c                ó°   — | j                   j                  5  | j                   j                  | j                  «       «       d d d «       | S # 1 sw Y   | S xY wr8   ©r"   r�   r�   rF   r;   s    r'   Ú	__enter__zPipeline.__enter__Ï   s9   € Ø�Z‰Z�_‹_Ø�J‰J�O‰O˜DŸO™OÓ-Ô.÷ àˆ÷ àˆús   —*AÁAc                ó~  — 	 | j                   j                  5  | j                   j                  | j                  «       «       d d d «       | j                  |«       y # 1 sw Y   ŒxY w# t        $ r5}|rt
        j                  d| |«       n|j                  d «      ‚Y d }~ŒWd }~ww xY w# | j                  |«       w xY w©Nz error ignored terminating %r: %s©	r"   r�   r�   rZ   Ú	ExceptionrL   rM   rN   rQ   ©r%   Úexc_typeÚexc_valÚexc_tbrP   s        r'   Ú__exit__zPipeline.__exit__Ô   s�   € ð
	 Ø—‘—“Ø—
‘
—‘ §¡Ó 0Ô1÷ !ð �J‰J�wÕ÷ !�ûäò 	0áÜ—‘ÐAÀ4ÈÕNà×)Ñ)¨$Ó/Ð/ô Oûð	0ûð �J‰J�wÕús@   ‚A( ˜*AÁA( ÁA%Á!A( Á(	B&Á1+B!ÂB) Â!B&Â&B) Â)B<)r&   r‡   ry   rz   r   ©ry   r   ©r�   ztype[BaseException] | Nonerž   r~   rŸ   zTracebackType | Nonery   rz   )
r€   r1   r2   Ú__doc__r�   r(   r”   r—   r    Ú__classcell__©r0   s   @r'   r†   r†   ¼   sK   ø… Ù2à€JØÓõó*óð
 à,ð ð &ð ð %ð	 ð
 
÷ r)   r†   c                  ó\   ‡ — e Zd ZU dZdZded<   d	ˆ fd„Zd
d„Zdd„Z	 	 	 	 	 	 	 	 dd„Zˆ xZ	S )ÚAsyncPipelinez.Handler for async connection in pipeline mode.r   úAsyncConnection[Any]r"   c                ó$   •— t         ‰| �  |«       y r8   r‰   r‹   s     €r'   r(   zAsyncPipeline.__init__í   rŒ   r)   c              ƒ  ó\  K  — 	 | j                   j                  4 ƒd {  –—†  | j                   j                  | j                  «       «      ƒ d {  –—†  d d d «      ƒd {  –—†  y 7 ŒF7 Œ7 Œ	# 1 ƒd {  –—†7  sw Y   y xY w# t        j
                  $ r}|j                  d «      ‚d }~ww xY w­wr8   rŽ   r’   s     r'   r”   zAsyncPipeline.syncð   ss   è ø€ ð	*Ø—z‘z——“Ø—j‘j—o‘o d§n¡nÓ&6Ó7×7Ð7÷ '—‘øØ7øð 'ø——‘ûä�‰ò 	*Ø×#Ñ# DÓ)Ð)ûð	*üs‹   ‚B,„B  žA%ŸB  ¢-A+ÁA'ÁA+ÁB  ÁA)Á B  Á$B,Á%B  Á'A+Á)B  Á+A=Á1A4Á2A=Á9B  Á<B,Á=B  Â B)ÂB$Â$B)Â)B,c              ƒ  ó  K  — | j                   j                  4 ƒd {  –—†  | j                   j                  | j                  «       «      ƒ d {  –—†  d d d «      ƒd {  –—†  | S 7 ŒG7 Œ7 Œ
# 1 ƒd {  –—†7  sw Y   | S xY w­wr8   r–   r;   s    r'   Ú
__aenter__zAsyncPipeline.__aenter__÷   sW   è ø€ Ø—:‘:—?—?“?Ø—*‘*—/‘/ $§/¡/Ó"3Ó4×4Ð4÷ #—?àˆð #øØ4øð #ø—?—?�?àˆüsV   ‚B�A%žB¡-A+ÁA'ÁA+ÁBÁA)ÁBÁ'A+Á)BÁ+A>Á1A4Á2A>Á9Bc              ƒ  óÔ  K  — 	 | j                   j                  4 ƒd {  –—†  | j                   j                  | j                  «       «      ƒ d {  –—†  d d d «      ƒd {  –—†  | j                  |«       y 7 ŒW7 Œ(7 Œ# 1 ƒd {  –—†7  sw Y   Œ*xY w# t        $ r5}|rt
        j                  d| |«       n|j                  d «      ‚Y d }~Œfd }~ww xY w# | j                  |«       w xY w­wr™   rš   rœ   s        r'   Ú	__aexit__zAsyncPipeline.__aexit__ü   s©   è ø€ ð
	 Ø—z‘z——“Ø—j‘j—o‘o d§n¡nÓ&6Ó7×7Ð7÷ '—ð �J‰J�wÕð 'øØ7øð 'ø——‘ûäò 	0áÜ—‘ÐAÀ4ÈÕNà×)Ñ)¨$Ó/Ð/ô Oûð	0ûð �J‰J�wÕüs‘   ‚C(„B žA6ŸB ¢-A<ÁA8ÁA<ÁB ÁA:Á B Á$C(Á6B Á8A<Á:B Á<BÂBÂBÂ
B Â	CÂ+C
ÃC Ã
CÃC ÃC%Ã%C()r&   r¨   ry   rz   r   r¡   r¢   )
r€   r1   r2   r£   r�   r(   r”   r¬   r®   r¤   r¥   s   @r'   r§   r§   ç   sK   ø… Ù8à€JØÓõó*óð
 à,ð ð &ð ð %ð	 ð
 
÷ r)   r§   )7r£   Ú
__future__r   ÚloggingÚtypesr   Útypingr   r   Ú r   r	   rJ   Úabcr
   r   Ú_compatr   r   r   Úpq.miscr   Ú
generatorsr   r   r   Ú_capabilitiesr   Úpq.abcr   Ú
connectionr   Ú
_preparingr   r   Ú_cursor_baser   Ú_connection_baser   Úconnection_asyncr   r   r�   Ú
ExecStatusrg   rj   Ú
ConnStatusrH   ÚTransactionStatusrD   Ú	getLoggerrL   r   r†   r§   r„   r)   r'   Ú<module>rÃ      sÓ   ðòõ #ã Ý ß %å Ý ß 'ß +Ñ +Ý 'ß >Ñ >Ý 'áÝ Ý&ß(Ý(Ý0Ý1ð Lð ˆyó ð �m‰m×'Ñ'€Ø—=‘=×1Ñ1Ð Ø‡m�m×Ñ€à	×	Ñ	×	$Ñ	$€à	ˆ×	Ñ	˜9Ó	%€÷N'ñ N'ôb( ˆ|ô ( ôV% �Lõ % r)   