Ë
    êëj‹]  ã                  óÀ  — U d Z ddlmZ ddlZddlZddlmZmZmZm	Z	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d
lmZmZmZ ddlmZmZ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dl%m&Z& ddl'm(Z(m)Z)m*Z*m+Z+m,Z, ddl-m.Z. ddl/m0Z0 ddl1m2Z2 ddl3m4Z4 ddl5m6Z6 erddl7m8Z8 ddl9m:Z:m;Z;  e,d«      Z<ejz                  j|                  Z>ejz                  j~                  Z?ej€                  j‚                  ZAej€                  j„                  ZBej†                  jˆ                  ZDej†                  jŠ                  ZEej†                  jŒ                  ZFejŽ                  j�                  ZHejŽ                  j’                  ZI e2j”                  «       ZK ej˜                  d«      ZM G d„ de
«      ZNdeN_O        eej                   gdf   ZQdeRd<   eeNgdf   ZSdeRd<    G d „ d!e	e"   «      ZTy)"z
psycopg connection objects
é    )ÚannotationsN)ÚTYPE_CHECKINGÚAnyÚCallableÚGenericÚ
NamedTuple)ÚReferenceTypeÚref)Úwarn)Úpartialé   )Úerrors)Ú
generatorsÚpostgresÚpq)ÚPQGenÚ	PQGenConnÚQuery)ÚSQLÚ
Composable)ÚXid)ÚRow)ÚAdaptersMap)ÚIsolationLevel)ÚDequeÚLiteralStringÚSelfÚ	TypeAliasÚTypeVar)Úconnection_summary)ÚPrepareManager)Úcapabilities)ÚBasePipeline)ÚConnectionInfo)ÚBasePool)ÚPGconnÚPGresultÚ	CursorRowÚpsycopgc                  ó4   — e Zd ZU dZded<   	 ded<   	 ded<   y)ÚNotifyz8An asynchronous notification received from the database.ÚstrÚchannelÚpayloadÚintÚpidN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__© ó    ú_/var/www/html/kelly/kelly-backend/venv/lib/python3.12/site-packages/psycopg/_connection_base.pyr+   r+   :   s   … ÙBàƒLØIàƒLØ3à	ƒHØEr7   r+   r   ÚNoticeHandlerÚNotifyHandlerc                  ó*  — e Zd ZdZej
                  Zej                  Zej                  Zej                  Zej                  Z	ej                  Z
ej                  Zej                  Zej                  Zej                  Zd9d„Zefd:d„Zd;d„Zed<d„«       Zed<d„«       Zed<d„«       Zej.                  d=d„«       Zd=d	„Zd>d
„Zed?d„«       Zej.                  d@d„«       Zd@d„ZdAd„ZedBd„«       Zej.                  dCd„«       ZdCd„ZdDd„ZedBd„«       Z e j.                  dCd„«       Z dCd„Z!dDd„Z"dEd„Z#edFd„«       Z$edGd„«       Z%edHd„«       Z&dId„Z'dJd„Z(d<d„Z)dKd„Z*dLd„Z+dLd „Z,e-	 	 	 	 	 	 dMd!„«       Z.dNd"„Z/dNd#„Z0e-	 	 	 	 	 	 dOd$„«       Z1edPd%„«       Z2e2j.                  dQd&„«       Z2edPd'„«       Z3e3j.                  dQd(„«       Z3e4	 dRd)d*œ	 	 	 	 	 dSd+„«       Z5e6f	 	 	 	 	 dTd,„Z7dUd-„Z8dJd.„Z9dVd/„Z:dWd0„Z;dVd1„Z<dVd2„Z=dXd3„Z>dYd4„Z?dVd5„Z@	 	 	 	 	 	 dZd6„ZAdJd7„ZBy8)[ÚBaseConnectionz±
    Base class for different types of connections.

    Share common functionalities such as access to the wrapped PGconn, but
    allow different interfaces (sync/async).
    c                ó�  — || _         d| _        d | _        g | _        g | _        d| _        d| _        t        «       | _        d | _	        t        «       | _        t        | «      }t        t        j                  |«      |_        t        t        j"                  |«      |_        |  d | _        |  d | _        d | _        d | _        d| _        y )NFr   r7   )ÚpgconnÚ_autocommitÚ	_adaptersÚ_notice_handlersÚ_notify_handlersÚ_num_transactionsÚ_closedr!   Ú	_preparedÚ_tpcr   Ú_notifies_backlogr
   r   r<   Ú_notice_handlerÚnotice_handlerÚ_notify_handlerÚnotify_handlerÚ	_pipelineÚ_isolation_levelÚ
_read_onlyÚ_deferrableÚ_begin_statement)Úselfr>   Úwselfs      r8   Ú__init__zBaseConnection.__init__a   s»   € ØˆŒØ ˆÔð .2ˆŒà57ˆÔØ57ˆÔð "#ˆÔàˆŒÜ)7Ó)9ˆŒØ-1ˆŒ	ô 8=³wˆÔä�D“	ˆÜ '¬×(FÑ(FÈÓ NˆÔÜ '¬×(FÑ(FÈÓ NˆÔñ 	à.2ˆŒñ 	à7;ˆÔØ'+ˆŒØ(,ˆÔØ #ˆÕr7   c                ó˜   — t        | d«      sy | j                  ry t        | d«      ry  |t        j                  | «      › d�t        «       y )Nr>   Ú_poolz_ was deleted while still open. Please use 'with' or '.close()' to close the connection properly)ÚhasattrÚclosedÚobjectÚ__repr__ÚResourceWarning)rQ   Ú_BaseConnection__warns     r8   Ú__del__zBaseConnection.__del__ˆ   sP   € ä�t˜XÔ&Øð �;Š;Øô �4˜Ô!ØáÜ�‰˜tÓ$Ð%ð &Pð Päõ	
r7   c                ó¶   — | j                   j                  › d| j                   j                  › �}t        | j                  «      }d|› d|› dt        | «      d›d�S )NÚ.Ú<Ú z at 0xÚxÚ>)Ú	__class__r2   r3   r    r>   Úid)rQ   ÚclsÚinfos      r8   rY   zBaseConnection.__repr__›   sW   € Ø—‘×*Ñ*Ð+¨1¨T¯^©^×-HÑ-HÐ,IÐJˆÜ! $§+¡+Ó.ˆØ�3�%�q˜˜˜f¤R¨£X¨a L°Ð2Ð2r7   c                ó<   — | j                   j                  t        k(  S )z$`!True` if the connection is closed.)r>   ÚstatusÚBAD©rQ   s    r8   rW   zBaseConnection.closed    s   € ð �{‰{×!Ñ!¤SÑ(Ð(r7   c                óZ   — | j                   j                  t        k(  xr | j                   S )zÃ
        `!True` if the connection was interrupted.

        A broken connection is always `closed`, but wasn't closed in a clean
        way, such as using `close()` or a `!with` block.
        )r>   rh   ri   rD   rj   s    r8   ÚbrokenzBaseConnection.broken¥   s%   € ð �{‰{×!Ñ!¤SÑ(Ò=°·±Ð-=Ð=r7   c                ó   — | j                   S )z'The autocommit state of the connection.)r?   rj   s    r8   Ú
autocommitzBaseConnection.autocommit¯   s   € ð ×ÑÐr7   c                ó&   — | j                  |«       y ©N)Ú_set_autocommit©rQ   Úvalues     r8   rn   zBaseConnection.autocommit´   ó   € à×Ñ˜UÕ#r7   c                ó   — t         ‚rp   ©ÚNotImplementedErrorrr   s     r8   rq   zBaseConnection._set_autocommit¸   ó   € Ü!Ð!r7   c              #  ób   K  — | j                  d«      E d {  –—†  t        |«      | _        y 7 Œ­w)Nrn   )Ú_check_intrans_genÚboolr?   rr   s     r8   Ú_set_autocommit_genz"BaseConnection._set_autocommit_gen»   s+   è ø€ Ø×*Ñ*¨<Ó8×8Ð8Ü ›;ˆÕð 	9ús   ‚/—-˜/c                ó   — | j                   S )zX
        The isolation level of the new transactions started on the connection.
        )rM   rj   s    r8   Úisolation_levelzBaseConnection.isolation_level¿   s   € ð
 ×$Ñ$Ð$r7   c                ó&   — | j                  |«       y rp   )Ú_set_isolation_levelrr   s     r8   r~   zBaseConnection.isolation_levelÆ   s   € à×!Ñ! %Õ(r7   c                ó   — t         ‚rp   rv   rr   s     r8   r€   z#BaseConnection._set_isolation_levelÊ   rx   r7   c              #  óx   K  — | j                  d«      E d {  –—†  |�t        |«      nd | _        d| _        y 7 Œ ­w)Nr~   r7   )rz   r   rM   rP   rr   s     r8   Ú_set_isolation_level_genz'BaseConnection._set_isolation_level_genÍ   s=   è ø€ Ø×*Ñ*Ð+<Ó=×=Ð=Ø9>Ð9J¤¨uÔ 5ÐPTˆÔØ #ˆÕð 	>úó   ‚:—8˜!:c                ó   — | j                   S )zX
        The read-only state of the new transactions started on the connection.
        )rN   rj   s    r8   Ú	read_onlyzBaseConnection.read_onlyÒ   s   € ð
 �‰Ðr7   c                ó&   — | j                  |«       y rp   )Ú_set_read_onlyrr   s     r8   r†   zBaseConnection.read_onlyÙ   s   € à×Ñ˜EÕ"r7   c                ó   — t         ‚rp   rv   rr   s     r8   rˆ   zBaseConnection._set_read_onlyÝ   rx   r7   c              #  óx   K  — | j                  d«      E d {  –—†  |�t        |«      nd | _        d| _        y 7 Œ ­w)Nr†   r7   )rz   r{   rN   rP   rr   s     r8   Ú_set_read_only_genz!BaseConnection._set_read_only_genà   s9   è ø€ Ø×*Ñ*¨;Ó7×7Ð7Ø).Ð):œ$˜uœ+ÀˆŒØ #ˆÕð 	8úr„   c                ó   — | j                   S )zY
        The deferrable state of the new transactions started on the connection.
        )rO   rj   s    r8   Ú
deferrablezBaseConnection.deferrableå   s   € ð
 ×ÑÐr7   c                ó&   — | j                  |«       y rp   )Ú_set_deferrablerr   s     r8   r�   zBaseConnection.deferrableì   rt   r7   c                ó   — t         ‚rp   rv   rr   s     r8   r�   zBaseConnection._set_deferrableð   rx   r7   c              #  óx   K  — | j                  d«      E d {  –—†  |�t        |«      nd | _        d| _        y 7 Œ ­w)Nr�   r7   )rz   r{   rO   rP   rr   s     r8   Ú_set_deferrable_genz"BaseConnection._set_deferrable_genó   s:   è ø€ Ø×*Ñ*¨<Ó8×8Ð8Ø*/Ð*;œ4 œ;ÀˆÔØ #ˆÕð 	9úr„   c              #  ó¢  K  — | j                   j                  x}t        k(  rD| j                  r8| j                  j	                  «       E d {  –—†  | j                   j                  }|t        k7  r]| j
                  rt        j                  d|›d�«      ‚t        j                  d|›dt        j                  |«      j                  › �«      ‚y 7 Œ�­w)Nzcan't change z2 now: connection.transaction() context in progressz' now: connection in transaction status )r>   Útransaction_statusÚIDLErL   Ú	_sync_genrC   ÚeÚProgrammingErrorr   ÚTransactionStatusÚname)rQ   Ú	attributerh   s      r8   rz   z!BaseConnection._check_intrans_genø   sÅ   è ø€ à—k‘k×4Ñ4Ð4ˆF¼Ò=À$Ç.Â.Ø—~‘~×/Ñ/Ó1×1Ð1Ø—[‘[×3Ñ3ˆFØ”TŠ>Ø×%Ò%Ü×(Ñ(Ø# I =ð 1Cð Cóð ô
 ×(Ñ(Ø# I =ð 18ä×+Ñ+¨FÓ3×8Ñ8Ð9ð;óð ð ð 2ús   ‚A	CÁCÁBCc                ó,   — t        | j                  «      S )z>A `ConnectionInfo` attribute to inspect connection properties.)r$   r>   rj   s    r8   rf   zBaseConnection.info
  s   € ô ˜dŸk™kÓ*Ð*r7   c                ón   — | j                   st        t        j                  «      | _         | j                   S rp   )r@   r   r   Úadaptersrj   s    r8   rž   zBaseConnection.adapters  s%   € à�~Š~Ü(¬×):Ñ):Ó;ˆDŒNà�~‰~Ðr7   c                ó   — | S rp   r6   rj   s    r8   Ú
connectionzBaseConnection.connection  s	   € ð ˆr7   c                ó.   — | j                   j                  S )zæReturn the file descriptor of the connection.

        This function allows to use the connection as file-like object in
        functions waiting for readiness, such as the ones defined in the
        `selectors` module.
        )r>   Úsocketrj   s    r8   ÚfilenozBaseConnection.fileno  s   € ð �{‰{×!Ñ!Ð!r7   c                óz   — | j                  «       r+| j                  j                  «       }|j                  «        yy)z/Cancel the current operation on the connection.N)Ú_should_cancelr>   Ú
get_cancelÚcancel)rQ   Úcs     r8   r§   zBaseConnection.cancel$  s.   € à×ÑÔ Ø—‘×&Ñ&Ó(ˆAØ�H‰H�Jð !r7   c                ó~   — | j                   ry| j                  r$| j                  d   rt        j                  d«      ‚y)zhCheck whether the current command should actually be cancelled when
        invoking cancel*().
        Fr   z=cancel() cannot be used with a prepared two-phase transactionT)rW   rF   r—   r˜   rj   s    r8   r¥   zBaseConnection._should_cancel*  s:   € ð �;Š;ØØ�9Š9˜Ÿ™ 1šÜ×$Ñ$ØOóð ð r7   c             #  ó¢   K  — | j                   j                  «       }|j                  «        t        j                  ||¬«      E d {  –—†  y 7 Œ­w)N©Útimeout)r>   Úcancel_connÚstartr   r§   )rQ   r¬   r­   s      r8   Ú_cancel_genzBaseConnection._cancel_gen9  s:   è ø€ Ø—k‘k×-Ñ-Ó/ˆØ×ÑÔÜ×$Ñ$ [¸'ÔB×BÒBús   ‚AAÁAÁAc                ó:   — | j                   j                  |«       y)zá
        Register a callable to be invoked when a notice message is received.

        :param callback: the callback to call upon message received.
        :type callback: Callable[[~psycopg.errors.Diagnostic], None]
        N)rA   Úappend©rQ   Úcallbacks     r8   Úadd_notice_handlerz!BaseConnection.add_notice_handler>  ó   € ð 	×Ñ×$Ñ$ XÕ.r7   c                ó:   — | j                   j                  |«       y)zÄ
        Unregister a notice message callable previously registered.

        :param callback: the callback to remove.
        :type callback: Callable[[~psycopg.errors.Diagnostic], None]
        N)rA   Úremover²   s     r8   Úremove_notice_handlerz$BaseConnection.remove_notice_handlerG  rµ   r7   c                ó  —  | «       }|r|j                   sy t        j                  ||j                  j                  «      }|j                   D ]  }	  ||«       Œ y # t
        $ r!}t        j                  d||«       Y d }~Œ4d }~ww xY w)Nz)error processing notice callback '%s': %s)rA   r—   Ú
Diagnosticr>   Ú	_encodingÚ	ExceptionÚloggerÚ	exception)rR   ÚresrQ   ÚdiagÚcbÚexs         r8   rH   zBaseConnection._notice_handlerP  s{   € ñ ‹wˆÙ˜×.Ò.Øä�|‰|˜C §¡×!6Ñ!6Ó7ˆØ×'Ô'ˆBðVÙ�4•ñ (øô ò VÜ× Ñ Ð!LÈbÐRT×UÑUûðVús   ÁAÁ	BÁ%BÂBc                ó:   — | j                   j                  |«       y)zÝ
        Register a callable to be invoked whenever a notification is received.

        :param callback: the callback to call upon notification received.
        :type callback: Callable[[~psycopg.Notify], None]
        N)rB   r±   r²   s     r8   Úadd_notify_handlerz!BaseConnection.add_notify_handler_  rµ   r7   c                ó:   — | j                   j                  |«       y)z·
        Unregister a notification callable previously registered.

        :param callback: the callback to remove.
        :type callback: Callable[[~psycopg.Notify], None]
        N)rB   r·   r²   s     r8   Úremove_notify_handlerz$BaseConnection.remove_notify_handlerh  rµ   r7   c                ób  —  | «       x}sy |j                   j                  }t        |j                  j	                  |«      |j
                  j	                  |«      |j                  «      }|j                  r|j                  D ]
  } ||«       Œ y |j                  x}�|j                  |«       y y rp   )
r>   r»   r+   ÚrelnameÚdecodeÚextraÚbe_pidrB   rG   r±   )rR   ÚpgnrQ   ÚencÚnrÁ   Úds          r8   rJ   zBaseConnection._notify_handlerq  s”   € ñ ›���Øà�k‰k×#Ñ#ˆÜ�3—;‘;×%Ñ% cÓ*¨C¯I©I×,<Ñ,<¸SÓ,AÀ3Ç:Á:ÓNˆà× Ò Ø×+Ô+�Ù�1•ñ ,ð ×+Ñ+Ð+�Ð8Ø—‘˜•ð 9r7   c                ó.   — | j                   j                  S )a&  
        Number of times a query is executed before it is prepared.

        - If it is set to 0, every query is prepared the first time it is
          executed.
        - If it is set to `!None`, prepared statements are disabled on the
          connection.

        Default value: 5
        ©rE   Úprepare_thresholdrj   s    r8   rÒ   z BaseConnection.prepare_thresholdƒ  s   € ð �~‰~×/Ñ/Ð/r7   c                ó&   — || j                   _        y rp   rÑ   rr   s     r8   rÒ   z BaseConnection.prepare_threshold‘  s   € à+0ˆ�‰Õ(r7   c                ó\   — | j                   j                  }|t        j                  k7  r|S dS )z©
        Maximum number of prepared statements on the connection.

        `!None` means no max number of prepared statements. The default value
        is 100.
        N)rE   Úprepared_maxÚsysÚmaxsize)rQ   Úrvs     r8   rÕ   zBaseConnection.prepared_max•  s)   € ð �^‰^×(Ñ(ˆØœ3Ÿ;™;Ò&ˆrÐ0¨DÐ0r7   c                óJ   — |€t         j                  }|| j                  _        y rp   )rÖ   r×   rE   rÕ   rr   s     r8   rÕ   zBaseConnection.prepared_max   s   € àˆ=Ü—K‘KˆEØ&+ˆ�‰Õ#r7   g        r«   c             #  ó`   K  — t        j                  ||¬«      E d{  –—† } | |«      }|S 7 Œ­w)z?Generator to connect to the database and create a new instance.r«   N)r   Úconnect)re   Úconninfor¬   r>   Úconns        r8   Ú_connect_genzBaseConnection._connect_gen°  s1   è ø€ ô
 '×.Ñ.¨xÀÔI×IˆÙ�6‹{ˆØˆð Jús   ‚.�,ž.c              #  ó  K  — | j                  «        t        |t        «      r&|j                  | j                  j
                  «      }n!t        |t        «      r|j                  | «      }| j                  rnt        | j                  j                  |d|¬«      }| j                  j                  j                  |«       | j                  j                  j                  d«       y|t        k(  r| j                  j                  |«       n| j                  j                  |d|¬«       t!        j"                  | j                  «      E d{  –—† d   }|j$                  t&        k7  r¡|j$                  t(        k7  rŽ|j$                  t*        k(  r+t-        j.                  || j                  j
                  ¬«      ‚t-        j0                  dt3        j4                  |j$                  «      j6                  › d|j9                  «       ›�«      ‚|S 7 Œ½­w)zñ
        Generator to send a command and receive the result to the backend.

        Only used to implement internal commands such as "commit", with eventual
        arguments bound client-side. The cursor can do more complex stuff.
        N)Úresult_formatéÿÿÿÿ©Úencodingúunexpected result z from command )Ú_check_connection_okÚ
isinstancer,   Úencoder>   r»   r   Úas_bytesrL   r   Úsend_query_paramsÚcommand_queuer±   Úresult_queueÚTEXTÚ
send_queryr   Úexecuterh   Ú
COMMAND_OKÚ	TUPLES_OKÚFATAL_ERRORr—   Úerror_from_resultÚInterfaceErrorr   Ú
ExecStatusrš   rÉ   )rQ   Úcommandrà   ÚcmdÚresults        r8   Ú_exec_commandzBaseConnection._exec_command¹  sŒ  è ø€ ð 	×!Ñ!Ô#ä�gœsÔ#Ø—n‘n T§[¡[×%:Ñ%:Ó;‰GÜ˜¤Ô,Ø×&Ñ& tÓ,ˆGà�>Š>ÜØ—‘×-Ñ-ØØØ+ô	ˆCð �N‰N×(Ñ(×/Ñ/°Ô4Ø�N‰N×'Ñ'×.Ñ.¨tÔ4Øð
 œDÒ Ø�K‰K×"Ñ" 7Õ+à�K‰K×)Ñ)¨'°4À}Ð)ÔUä'1×'9Ñ'9¸$¿+¹+Ó'F×FÈÑKˆØ�=‰=œJÒ&¨6¯=©=¼IÒ+EØ�}‰}¤Ò+Ü×)Ñ)¨&¸4¿;¹;×;PÑ;PÔQÐQä×&Ñ&Ø(¬¯©°v·}±}Ó)E×)JÑ)JÐ(KØ$ W§^¡^Ó%5Ð$8ð:óð ð ˆð Gús   ‚EH	Å	HÅ
B>H	c              #  ó&  K  — |�t         s#|�d|z   nd}| j                  |«      E d{  –—†  y| j                  «        | j                  rkt	        | j
                  j                  |«      }| j                  j                  j                  |«       | j                  j                  j                  d«       y| j
                  j                  |«       t        j                  | j
                  «      E d{  –—† d   }|j                  t        k7  r~|j                  t        k(  r+t        j                   || j
                  j"                  ¬«      ‚t        j$                  dt'        j(                  |j                  «      j*                  › d�«      ‚y7 �Œd7 Œœ­w)ae  
        Deallocate one, or all, prepared statement in the session.

        ``name == None`` stands for DEALLOCATE ALL.

        If possible, use protocol-level commands; otherwise use SQL statements.

        Note that PgBouncer doesn't support DEALLOCATE name, but it supports
        protocol-level Close from 1.21 and DEALLOCATE ALL from 1.22.
        Ns   DEALLOCATE s   DEALLOCATE ALLrá   râ   rä   z0 from sending closing prepared statement message)Ú_HAS_SEND_CLOSErø   rå   rL   r   r>   Úsend_close_preparedrê   r±   rë   r   rî   rh   rï   rñ   r—   rò   r»   ró   r   rô   rš   )rQ   rš   Ústmtrö   r÷   s        r8   Ú_deallocatezBaseConnection._deallocateç  s>  è ø€ ð ˆ<�Ø,0Ð,<�> DÒ(ÐBSˆDØ×)Ñ)¨$Ó/×/Ð/Øà×!Ñ!Ô#à�>Š>Ü˜$Ÿ+™+×9Ñ9¸4Ó@ˆCØ�N‰N×(Ñ(×/Ñ/°Ô4Ø�N‰N×'Ñ'×.Ñ.¨tÔ4Øà�‰×'Ñ'¨Ô-ä'×/Ñ/°·±Ó<×<¸bÑAˆØ�=‰=œJÒ&Ø�}‰}¤Ò+Ü×)Ñ)¨&¸4¿;¹;×;PÑ;PÔQÐQä×&Ñ&Ø(¬¯©°v·}±}Ó)E×)JÑ)JÐ(KØFðGóð ð	 'ð 0ùð =ús#   ‚&F¨F©C	FÃ2FÃ3BFÆFc                óú   — | j                   j                  t        k(  ry | j                   j                  t        k(  rt	        j
                  d«      ‚t	        j                  d| j                   j                  › �«      ‚)Nzthe connection is closedz7cannot execute operations: the connection is in status )r>   rh   ÚOKri   r—   ÚOperationalErrorró   rj   s    r8   rå   z#BaseConnection._check_connection_ok  sh   € Ø�;‰;×Ñ¤Ò#Øà�;‰;×Ñ¤Ò$Ü×$Ñ$Ð%?Ó@Ð@Ü×ÑðØŸ+™+×,Ñ,Ð-ð/ó
ð 	
r7   c              #  ó  K  — | j                   ry| j                  j                  t        k7  ry| j	                  | j                  «       «      E d{  –—†  | j                  r#| j                  j                  «       E d{  –—†  yy7 Œ47 Œ­w)z.Generator to start a transaction if necessary.N)r?   r>   r”   r•   rø   Ú_get_tx_start_commandrL   r–   rj   s    r8   Ú_start_queryzBaseConnection._start_query  sp   è ø€ à×ÒØà�;‰;×)Ñ)¬TÒ1Øà×%Ñ% d×&@Ñ&@Ó&BÓC×CÐCØ�>Š>Ø—~‘~×/Ñ/Ó1×1Ñ1ð ð 	Døà1ús$   ‚AB	ÁBÁ-B	Á>BÁ?B	ÂB	c                óþ  — | j                   r| j                   S dg}| j                  �_t        | j                  «      }|j                  d«       |j                  |j                  j                  dd«      j                  «       «       | j                  �|j                  | j                  rdnd«       | j                  �|j                  | j                  rdnd«       d	j                  |«      | _         | j                   S )
Ns   BEGINs   ISOLATION LEVELÚ_r`   s	   READ ONLYs
   READ WRITEs
   DEFERRABLEs   NOT DEFERRABLEó    )
rP   r~   r   r±   rš   Úreplacerç   r†   r�   Újoin)rQ   ÚpartsÚvals      r8   r  z$BaseConnection._get_tx_start_command"  sÇ   € Ø× Ò Ø×(Ñ(Ð(à�
ˆà×ÑÐ+Ü  ×!5Ñ!5Ó6ˆCØ�L‰LÐ+Ô,Ø�L‰L˜Ÿ™×)Ñ)¨#¨sÓ3×:Ñ:Ó<Ô=à�>‰>Ð%Ø�L‰L¨¯ª™¸]ÔKà�?‰?Ð&Ø�L‰L¨$¯/ª/™Ð?PÔQà $§	¡	¨%Ó 0ˆÔØ×$Ñ$Ð$r7   c              #  ód  K  — | j                   rt        j                  d«      ‚| j                  rt        j                  d«      ‚| j                  j
                  t        k(  ry| j                  d«      E d{  –—†  | j                  r#| j                  j                  «       E d{  –—†  yy7 Œ47 Œ­w)z-Generator implementing `Connection.commit()`.zˆExplicit commit() forbidden within a Transaction context. (Transaction will be automatically committed on successful exit from context.)z6commit() cannot be used during a two-phase transactionNs   COMMIT)
rC   r—   r˜   rF   r>   r”   r•   rø   rL   r–   rj   s    r8   Ú_commit_genzBaseConnection._commit_gen6  sž   è ø€ à×!Ò!Ü×$Ñ$ð4óð ð
 �9Š9Ü×$Ñ$ØHóð ð �;‰;×)Ñ)¬TÒ1Øà×%Ñ% iÓ0×0Ð0à�>Š>Ø—~‘~×/Ñ/Ó1×1Ñ1ð ð 	1øð 2ús$   ‚A5B0Á7B,Á8-B0Â%B.Â&B0Â.B0c              #  óB  K  — | j                   rt        j                  d«      ‚| j                  rt        j                  d«      ‚| j                  r"| j                  j                  «       E d{  –—†  | j                  j                  t        k(  ry| j                  d«      E d{  –—†  | j                  j                  «        | j                  j                  | «      E d{  –—†  | j                  r#| j                  j                  «       E d{  –—†  yy7 Œ¨7 Œs7 Œ87 Œ­w)z/Generator implementing `Connection.rollback()`.zŒExplicit rollback() forbidden within a Transaction context. (Either raise Rollback() or allow an exception to propagate out of the context.)z8rollback() cannot be used during a two-phase transactionNs   ROLLBACK)rC   r—   r˜   rF   rL   r–   r>   r”   r•   rø   rE   ÚclearÚmaintain_genrj   s    r8   Ú_rollback_genzBaseConnection._rollback_genJ  sî   è ø€ à×!Ò!Ü×$Ñ$ðAóð ð
 �9Š9Ü×$Ñ$ØJóð ð
 �>Š>Ø—~‘~×/Ñ/Ó1×1Ð1à�;‰;×)Ñ)¬TÒ1Øà×%Ñ% kÓ2×2Ð2Ø�‰×ÑÔØ—>‘>×.Ñ.¨tÓ4×4Ð4à�>Š>Ø—~‘~×/Ñ/Ó1×1Ñ1ð ð 2øð
 	3øà4øð 2úsH   ‚A,DÁ.DÁ/6DÂ%DÂ&<DÃ"DÃ#-DÄDÄDÄDÄDÄDc                óP   — | j                  «        t        j                  |||«      S )aL  
        Returns a `Xid` to pass to the `!tpc_*()` methods of this connection.

        The argument types and constraints are explained in
        :ref:`two-phase-commit`.

        The values passed to the method will be available on the returned
        object as the members `~Xid.format_id`, `~Xid.gtrid`, `~Xid.bqual`.
        )Ú
_check_tpcr   Ú
from_parts)rQ   Ú	format_idÚgtridÚbquals       r8   ÚxidzBaseConnection.xide  s!   € ð 	�‰ÔÜ�~‰~˜i¨°Ó6Ð6r7   c              #  óè  K  — | j                  «        t        |t        «      st        j                  |«      }| j                  j
                  t        k7  rIt        j                  dt        j                  | j                  j
                  «      j                  › �«      ‚| j                  rt        j                  d«      ‚|df| _        | j                  | j                  «       «      E d {  –—†  y 7 Œ­w)Nz8can't start two-phase transaction: connection in status z3can't use two-phase transactions in autocommit modeF)r  ræ   r   Úfrom_stringr>   r”   r•   r—   r˜   r   r™   rš   r?   rF   rø   r  ©rQ   r  s     r8   Ú_tpc_begin_genzBaseConnection._tpc_begin_genr  sÄ   è ø€ Ø�‰Ôä˜#œsÔ#Ü—/‘/ #Ó&ˆCà�;‰;×)Ñ)¬TÒ1Ü×$Ñ$ðÜ×(Ñ(¨¯©×)GÑ)GÓH×MÑMÐNðPóð ð
 ×ÒÜ×$Ñ$ØEóð ð ˜%�LˆŒ	Ø×%Ñ% d×&@Ñ&@Ó&BÓC×CÒCús   ‚C(C2Ã*C0Ã+C2c              #  ó   K  — | j                   st        j                  d«      ‚| j                   d   rt        j                  d«      ‚| j                   d   }|df| _         | j                  t	        d«      j                  t        |«      «      «      E d {  –—†  | j                  r#| j                  j                  «       E d {  –—†  y y 7 Œ47 Œ­w)Nz='tpc_prepare()' must be called inside a two-phase transactionr   zF'tpc_prepare()' cannot be used during a prepared two-phase transactionr   TzPREPARE TRANSACTION {})	rF   r—   r˜   rø   r   Úformatr,   rL   r–   r  s     r8   Ú_tpc_prepare_genzBaseConnection._tpc_prepare_gen†  sµ   è ø€ Ø�yŠyÜ×$Ñ$ØOóð ð �9‰9�QŠ<Ü×$Ñ$ØXóð ð �i‰i˜‰lˆØ˜$�KˆŒ	Ø×%Ñ%¤cÐ*BÓ&C×&JÑ&JÌ3ÈsË8Ó&TÓU×UÐUØ�>Š>Ø—~‘~×/Ñ/Ó1×1Ñ1ð ð 	Vøà1ús$   ‚BCÂC
Â-CÃCÃCÃCc              #  óp  K  — d|j                  «       › d�}|€4| j                  st        j                  |› d�«      ‚| j                  d   }nI| j                  rt        j                  |› d�«      ‚t	        |t
        «      st        j                  |«      }| j                  rD| j                  d   s5t        | d|j                  «       › d�«      }d | _         |«       E d {  –—†  y | j                  t        d	«      j                  t        |«      t        |«      «      «      E d {  –—†  d | _        y 7 ŒQ7 Œ­w)
NÚtpc_z()z? without xid must must be called inside a two-phase transactionr   z= with xid must must be called outside a two-phase transactionr   r  Ú_genz{} PREPARED {})ÚlowerrF   r—   r˜   ræ   r   r  Úgetattrrø   r   r  r,   )rQ   Úactionr  ÚfnameÚmeths        r8   Ú_tpc_finish_genzBaseConnection._tpc_finish_gen•  s&  è ø€ ð �v—|‘|“~Ð& bÐ)ˆØˆ;Ø—9’9Ü×(Ñ(Ø�gð =ð =óð ð —)‘)˜A‘,‰Cà�yŠyÜ×(Ñ(Ø�gð 7ð 7óð ô ˜c¤3Ô'Ü—o‘o cÓ*�à�9Š9˜TŸY™Y qš\ä˜4 1 V§\¡\£^Ð$4°DÐ!9Ó:ˆDØˆDŒIÙ“v×Ñà×)Ñ)ÜÐ$Ó%×,Ñ,¬S°«[¼#¸c»(ÓCó÷ ð ð ˆD�Ið øðús%   ‚CD6Ã D2Ã!AD6Ä%D4Ä&D6Ä4D6c                 ó   — y)z0Raise NotSupportedError if TPC is not supported.Nr6   rj   s    r8   r  zBaseConnection._check_tpc´  s   € ð 	r7   N)r>   r&   )r[   r   ÚreturnÚNone)r)  r,   )r)  r{   )rs   r{   r)  r*  )rs   r{   r)  úPQGen[None])r)  úIsolationLevel | None)rs   r,  r)  r*  )rs   r,  r)  r+  )r)  úbool | None)rs   r-  r)  r*  )rs   r-  r)  r+  )r›   r,   r)  r+  )r)  r$   )r)  r   )r)  zBaseConnection[Row])r)  r/   )r)  r*  )r¬   Úfloatr)  zPQGenConn[None])r³   r9   r)  r*  )rR   ú"ReferenceType[BaseConnection[Row]]r¿   r'   r)  r*  )r³   r:   r)  r*  )rR   r/  rÌ   zpq.PGnotifyr)  r*  )r)  ú
int | None)rs   r0  r)  r*  )Ú )rÜ   r,   r¬   r.  r)  zPQGenConn[Self])rõ   r   rà   z	pq.Formatr)  zPQGen[PGresult | None])rš   zbytes | Noner)  r+  )r)  r+  )r)  Úbytes)r  r/   r  r,   r  r,   r)  r   )r  z	Xid | strr)  r+  )r$  r   r  zXid | str | Noner)  r+  )Cr1   r2   r3   r4   r—   ÚWarningÚErrorró   ÚDatabaseErrorÚ	DataErrorr   ÚIntegrityErrorÚInternalErrorr˜   ÚNotSupportedErrorrS   r   r\   rY   ÚpropertyrW   rl   rn   Úsetterrq   r|   r~   r€   rƒ   r†   rˆ   r‹   r�   r�   r’   rz   rf   rž   r    r£   r§   r¥   r¯   r´   r¸   ÚstaticmethodrH   rÄ   rÆ   rJ   rÒ   rÕ   ÚclassmethodrÞ   rì   rø   rý   rå   r  r  r  r  r  r  r  r'  r  r6   r7   r8   r<   r<   M   s[  „ ñð �i‰i€GØ�G‰G€EØ×%Ñ%€NØ—O‘O€MØ—‘€IØ×)Ñ)ÐØ×%Ñ%€NØ—O‘O€MØ×)Ñ)ÐØ×+Ñ+Ðó%$ðN %)ô 
ó&3ð
 ò)ó ð)ð ò>ó ð>ð ò ó ð ð ×Ñò$ó ð$ó"ó'ð ò%ó ð%ð ×Ñò)ó ð)ó"ó$ð
 òó ðð ×Ñò#ó ð#ó"ó$ð
 ò ó ð ð ×Ñò$ó ð$ó"ó$ó
ð$ ò+ó ð+ð òó ðð òó ðó"óóóCó
/ó/ð ðVØ1ðVØ8@ðVà	òVó ðVó/ó/ð ðØ1ðØ8Cðà	òó ðð" ò0ó ð0ð ×Ñò1ó ð1ð ò1ó ð1ð ×Ñò,ó ð,ð àðØ58ñØðØ-2ðà	òó ðð :>ð,Øð,Ø-6ð,à	ó,ó\"óH	
ó
2ó%ó(2ó(2ó67óDó(2ðØ#ðØ*:ðà	óô>r7   r<   )Ur4   Ú
__future__r   rÖ   ÚloggingÚtypingr   r   r   r   r   Úweakrefr	   r
   Úwarningsr   Ú	functoolsr   r1  r   r—   r   r   r   Úabcr   r   r   Úsqlr   r   rF   r   Úrowsr   Úadaptr   Ú_enumsr   Ú_compatr   r   r   r   r   Úpq.miscr    Ú
_preparingr!   Ú_capabilitiesr"   Ú_pipeline_baser#   Ú_connection_infor$   Úpsycopg_pool.baser%   Úpq.abcr&   r'   r(   ÚFormatrì   ÚBINARYÚ
ConnStatusrÿ   ri   rô   rï   rð   rñ   r™   r•   ÚINTRANSÚhas_send_close_preparedrú   Ú	getLoggerr½   r+   r2   rº   r9   r5   r:   r<   r6   r7   r8   Ú<module>rW     sp  ðòõ #ã 
Û ß DÕ Dß &Ý Ý å ß &Ñ &ß (Ñ (ß  Ý Ý Ý Ý "ß CÕ CÝ 'Ý &Ý 'Ý (Ý ,áÝ*ç(ñ �KÓ €	à	‡y�y‡~�~€Ø	�‰×	Ñ	€à‡]�]×Ñ€Ø‡m�m×Ñ€à�]‰]×%Ñ%€
Ø�M‰M×#Ñ#€	Ø�m‰m×'Ñ'€à	×Ñ× Ñ €Ø
×
Ñ
×
&Ñ
&€à6�,×6Ñ6Ó8€à	ˆ×	Ñ	˜9Ó	%€ô
FˆZô 
Fð €Ô à# Q§\¡\ N°DÐ$8Ñ9€ˆyÓ 9Ø# V H¨d NÑ3€ˆyÓ 3ôj	�W˜S‘\õ j	r7   