Ë
    Ûq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	 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 ddl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* ddl+m,Z, ddl-m.Z. ddl/m0Z0 ddl1m2Z2 ddl3m4Z4 e	rddl5m6Z6m7Z7 ddl8m9Z9  e*d«      Z:ejv                  jx                  Z<ejv                  jz                  Z=ej|                  j~                  Z?ej|                  j€                  Z@ej‚                  j„                  ZBej‚                  j†                  ZCej‚                  jˆ                  ZDejŠ                  jŒ                  ZFejŠ                  jŽ                  ZG e2j�                  «       ZI ej”                  d«      ZK G d„ de«      ZLdeL_M        eejœ                  gdf   ZOdePd <   eeLgdf   ZQdePd!<    G d"„ d#ee!   «      ZRy)$z
psycopg connection objects
é    )ÚannotationsN)ÚCallableÚGenericÚ
NamedTupleÚTYPE_CHECKING)ÚrefÚReferenceType)Úwarn)Úpartialé   )Úpq)Úerrors)Úpostgres)Ú
generators)ÚPQGenÚ	PQGenConnÚQuery)Ú
ComposableÚSQL)ÚXid)ÚRow)ÚAdaptersMap)ÚIsolationLevel)ÚLiteralStringÚSelfÚ	TypeAliasÚTypeVar)Úconnection_summary)ÚBasePipeline)ÚPrepareManager)Úcapabilities)ÚConnectionInfo)ÚPGconnÚPGresult)ÚBasePoolÚ	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__© ó    úY/var/www/html/kelly-backend/venv/lib/python3.12/site-packages/psycopg/_connection_base.pyr)   r)   ;   s   … ÙBàƒLØIàƒLØ3à	ƒHØEr5   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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&d:d„Z'd<d„Z(dJd„Z)dKd„Z*dKd „Z+e,	 	 	 	 	 	 dLd!„«       Z-dMd"„Z.dMd#„Z/e,	 	 	 	 	 	 dNd$„«       Z0edOd%„«       Z1e1j,                  dPd&„«       Z1edOd'„«       Z2e2j,                  dPd(„«       Z2e3	 dQd)d*œ	 	 	 	 	 dRd+„«       Z4e5f	 	 	 	 	 dSd,„Z6dTd-„Z7d:d.„Z8dUd/„Z9dVd0„Z:dUd1„Z;dUd2„Z<dWd3„Z=dXd4„Z>dUd5„Z?	 	 	 	 	 	 dYd6„Z@d:d7„ZAy8)ZÚ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                ór  — || _         d| _        d | _        g | _        g | _        d| _        d| _        t        «       | _        d | _	        t        | «      }t        t        j                  |«      |_        t        t        j                  |«      |_        |  d | _        |  d | _        d | _        d | _        d| _        y )NFr   r5   )ÚpgconnÚ_autocommitÚ	_adaptersÚ_notice_handlersÚ_notify_handlersÚ_num_transactionsÚ_closedr    Ú	_preparedÚ_tpcr   r   r:   Ú_notice_handlerÚnotice_handlerÚ_notify_handlerÚnotify_handlerÚ	_pipelineÚ_isolation_levelÚ
_read_onlyÚ_deferrableÚ_begin_statement)Úselfr<   Úwselfs      r6   Ú__init__zBaseConnection.__init__b   s¯   € ØˆŒØ ˆÔð .2ˆŒà57ˆÔØ57ˆÔð "#ˆÔàˆŒÜ)7Ó)9ˆŒØ-1ˆŒ	ä�D“	ˆÜ '¬×(FÑ(FÈÓ NˆÔÜ '¬×(FÑ(FÈÓ NˆÔñ 	à.2ˆŒñ 	à7;ˆÔØ'+ˆŒØ(,ˆÔØ #ˆÕr5   c                óz   — t        | d«      sy | j                  ry t        | d«      ry t        d| › d�t        «       y )Nr<   Ú_poolzconnection zV was deleted while still open. Please use 'with' or '.close()' to close the connection)ÚhasattrÚclosedr
   ÚResourceWarning©rN   s    r6   Ú__del__zBaseConnection.__del__…   sH   € ä�t˜XÔ&Øð �;Š;Øô �4˜Ô!ØäØ˜$˜ð  Gð Gäõ	
r5   c                ó¶   — | j                   j                  › d| j                   j                  › �}t        | j                  «      }d|› d|› dt        | «      d›d�S )NÚ.Ú<Ú z at 0xÚxÚ>)Ú	__class__r0   r1   r   r<   Úid)rN   ÚclsÚinfos      r6   Ú__repr__zBaseConnection.__repr__˜   sW   € Ø—‘×*Ñ*Ð+¨1¨T¯^©^×-HÑ-HÐ,IÐJˆÜ! $§+¡+Ó.ˆØ�3�%�q˜˜˜f¤R¨£X¨a L°Ð2Ð2r5   c                ó<   — | j                   j                  t        k(  S )z$`!True` if the connection is closed.)r<   ÚstatusÚBADrV   s    r6   rT   zBaseConnection.closed�   s   € ð �{‰{×!Ñ!¤SÑ(Ð(r5   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<   rd   re   rB   rV   s    r6   ÚbrokenzBaseConnection.broken¢   s%   € ð �{‰{×!Ñ!¤SÑ(Ò=°·±Ð-=Ð=r5   c                ó   — | j                   S )z'The autocommit state of the connection.)r=   rV   s    r6   Ú
autocommitzBaseConnection.autocommit¬   s   € ð ×ÑÐr5   c                ó&   — | j                  |«       y ©N)Ú_set_autocommit©rN   Úvalues     r6   ri   zBaseConnection.autocommit±   ó   € à×Ñ˜UÕ#r5   c                ó   — t         ‚rk   ©ÚNotImplementedErrorrm   s     r6   rl   zBaseConnection._set_autocommitµ   ó   € Ü!Ð!r5   c              #  ób   K  — | j                  d«      E d {  –—†  t        |«      | _        y 7 Œ­w)Nri   )Ú_check_intrans_genÚboolr=   rm   s     r6   Ú_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.
        )rJ   rV   s    r6   Úisolation_levelzBaseConnection.isolation_level¼   s   € ð
 ×$Ñ$Ð$r5   c                ó&   — | j                  |«       y rk   )Ú_set_isolation_levelrm   s     r6   ry   zBaseConnection.isolation_levelÃ   s   € à×!Ñ! %Õ(r5   c                ó   — t         ‚rk   rq   rm   s     r6   r{   z#BaseConnection._set_isolation_levelÇ   rs   r5   c              #  óx   K  — | j                  d«      E d {  –—†  |�t        |«      nd | _        d| _        y 7 Œ ­w)Nry   r5   )ru   r   rJ   rM   rm   s     r6   Ú_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.
        )rK   rV   s    r6   Ú	read_onlyzBaseConnection.read_onlyÏ   s   € ð
 �‰Ðr5   c                ó&   — | j                  |«       y rk   )Ú_set_read_onlyrm   s     r6   r�   zBaseConnection.read_onlyÖ   s   € à×Ñ˜EÕ"r5   c                ó   — t         ‚rk   rq   rm   s     r6   rƒ   zBaseConnection._set_read_onlyÚ   rs   r5   c              #  óx   K  — | j                  d«      E d {  –—†  |�t        |«      nd | _        d| _        y 7 Œ ­w)Nr�   r5   )ru   rv   rK   rM   rm   s     r6   Ú_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.
        )rL   rV   s    r6   Ú
deferrablezBaseConnection.deferrableâ   s   € ð
 ×ÑÐr5   c                ó&   — | j                  |«       y rk   )Ú_set_deferrablerm   s     r6   rˆ   zBaseConnection.deferrableé   ro   r5   c                ó   — t         ‚rk   rq   rm   s     r6   rŠ   zBaseConnection._set_deferrableí   rs   r5   c              #  óx   K  — | j                  d«      E d {  –—†  |�t        |«      nd | _        d| _        y 7 Œ ­w)Nrˆ   r5   )ru   rv   rL   rM   rm   s     r6   Ú_set_deferrable_genz"BaseConnection._set_deferrable_genð   s:   è ø€ Ø×*Ñ*¨<Ó8×8Ð8Ø*/Ð*;œ4 œ;ÀˆÔØ #ˆÕð 	9úr   c              #  ó¢  K  — | j                   j                  }|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ÚIDLErI   Ú	_sync_genrA   ÚeÚProgrammingErrorr   ÚTransactionStatusÚname)rN   Ú	attributerd   s      r6   ru   z!BaseConnection._check_intrans_genõ   sÄ   è ø€ à—‘×/Ñ/ˆØ”TŠ>˜dŸnšnØ—~‘~×/Ñ/Ó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<   rV   s    r6   ra   zBaseConnection.info  s   € ô ˜dŸk™kÓ*Ð*r5   c                ón   — | j                   st        t        j                  «      | _         | j                   S rk   )r>   r   r   ÚadaptersrV   s    r6   r™   zBaseConnection.adapters  s%   € à�~Š~Ü(¬×):Ñ):Ó;ˆDŒNà�~‰~Ðr5   c                ó   — | S rk   r4   rV   s    r6   Ú
connectionzBaseConnection.connection  s	   € ð ˆr5   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<   ÚsocketrV   s    r6   ÚfilenozBaseConnection.fileno  s   € ð �{‰{×!Ñ!Ð!r5   c                óz   — | j                  «       r+| j                  j                  «       }|j                  «        yy)z/Cancel the current operation on the connection.N)Ú_should_cancelr<   Ú
get_cancelÚcancel)rN   Úcs     r6   r¢   zBaseConnection.cancel"  s.   € à×ÑÔ Ø—‘×&Ñ&Ó(ˆAØ�H‰H�Jð !r5   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)rT   rD   r’   r“   rV   s    r6   r    zBaseConnection._should_cancel(  s:   € ð �;Š;ØØ�9Š9˜Ÿ™ 1šÜ×$Ñ$ØOóð ð r5   c             #  ó¢   K  — | j                   j                  «       }|j                  «        t        j                  ||¬«      E d {  –—†  y 7 Œ­w)N©Útimeout)r<   Úcancel_connÚstartr   r¢   )rN   r§   r¨   s      r6   Ú_cancel_genzBaseConnection._cancel_gen7  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)r?   Úappend©rN   Úcallbacks     r6   Úadd_notice_handlerz!BaseConnection.add_notice_handler<  ó   € ð 	×Ñ×$Ñ$ XÕ.r5   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)r?   Úremover­   s     r6   Úremove_notice_handlerz$BaseConnection.remove_notice_handlerE  r°   r5   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)r?   r’   Ú
Diagnosticr<   Ú	_encodingÚ	ExceptionÚloggerÚ	exception)rO   ÚresrN   ÚdiagÚcbÚexs         r6   rE   zBaseConnection._notice_handlerN  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)r@   r¬   r­   s     r6   Úadd_notify_handlerz!BaseConnection.add_notify_handler]  r°   r5   c                ó:   — | j                   j                  |«       y)z·
        Unregister a notification callable previously registered.

        :param callback: the callback to remove.
        :type callback: Callable[[~psycopg.Notify], None]
        N)r@   r²   r­   s     r6   Úremove_notify_handlerz$BaseConnection.remove_notify_handlerf  r°   r5   c                ó   —  | «       }|r|j                   sy |j                  j                  }t        |j                  j                  |«      |j                  j                  |«      |j                  «      }|j                   D ]
  } ||«       Œ y rk   )r@   r<   r¶   r)   ÚrelnameÚdecodeÚextraÚbe_pid)rO   ÚpgnrN   ÚencÚnr¼   s         r6   rG   zBaseConnection._notify_handlero  so   € ñ ‹wˆÙ˜×.Ò.Øà�k‰k×#Ñ#ˆÜ�3—;‘;×%Ñ% cÓ*¨C¯I©I×,<Ñ,<¸SÓ,AÀ3Ç:Á:ÓNˆØ×'Ô'ˆBÙˆq�Eñ (r5   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
        ©rC   Úprepare_thresholdrV   s    r6   rÌ   z BaseConnection.prepare_threshold|  s   € ð �~‰~×/Ñ/Ð/r5   c                ó&   — || j                   _        y rk   rË   rm   s     r6   rÌ   z BaseConnection.prepare_thresholdŠ  s   € à+0ˆ�‰Õ(r5   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)rC   Úprepared_maxÚsysÚmaxsize)rN   Úrvs     r6   rÏ   zBaseConnection.prepared_maxŽ  s)   € ð �^‰^×(Ñ(ˆØœ3Ÿ;™;Ò&ˆrÐ0¨DÐ0r5   c                óJ   — |€t         j                  }|| j                  _        y rk   )rÐ   rÑ   rC   rÏ   rm   s     r6   rÏ   zBaseConnection.prepared_max™  s   € àˆ=Ü—K‘KˆEØ&+ˆ�‰Õ#r5   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)r`   Úconninfor§   r<   Úconns        r6   Ú_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_bytesrI   r   Úsend_query_paramsÚcommand_queuer¬   Úresult_queueÚTEXTÚ
send_queryr   Úexecuterd   Ú
COMMAND_OKÚ	TUPLES_OKÚFATAL_ERRORr’   Úerror_from_resultÚInterfaceErrorr   Ú
ExecStatusr•   rÄ   )rN   ÚcommandrÚ   ÚcmdÚresults        r6   Ú_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ä'×/Ñ/°·±Ó<×<¸bÑAˆØ�=‰=œJÒ&¨6¯=©=¼IÒ+EØ�}‰}¤Ò+Ü×)Ñ)¨&¸4¿;¹;×;PÑ;PÔQÐQä×&Ñ&Ø(¬¯©°v·}±}Ó)E×)JÑ)JÐ(KØ$ W§^¡^Ó%5Ð$8ð:óð ð ˆð =ú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ß   rI   r   r<   Úsend_close_preparedrä   r¬   rå   r   rè   rd   ré   rë   r’   rì   r¶   rí   r   rî   r•   )rN   r•   Ústmtrð   rñ   s        r6   Ú_deallocatezBaseConnection._deallocateà  sD  è ø€ ð ˆ<�Ø,0Ð,<�> DÒ(ÐBSˆDØ×)Ñ)¨$Ó/×/Ð/Øà×!Ñ!Ô#à�>Š>ÜØ—‘×/Ñ/Øóˆ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<   rd   ÚOKre   r’   ÚOperationalErrorrí   rV   s    r6   rß   z#BaseConnection._check_connection_ok  sh   € Ø�;‰;×Ñ¤Ò#Øà�;‰;×Ñ¤Ò$Ü×$Ñ$Ð%?Ó@Ð@Ü×ÑðØŸ+™+×,Ñ,Ð-ð/ó
ð 	
r5   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_commandrI   r‘   rV   s    r6   Ú_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ó    )
rM   ry   r   r¬   r•   Úreplacerá   r�   rˆ   Újoin)rN   ÚpartsÚvals      r6   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ˆÔØ×$Ñ$Ð$r5   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)
rA   r’   r“   rD   r<   r�   r�   rò   rI   r‘   rV   s    r6   Ú_commit_genzBaseConnection._commit_gen2  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)rA   r’   r“   rD   rI   r‘   r<   r�   r�   rò   rC   ÚclearÚmaintain_genrV   s    r6   Ú_rollback_genzBaseConnection._rollback_genF  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)rN   Ú	format_idÚgtridÚbquals       r6   ÚxidzBaseConnection.xida  s!   € ð 	�‰ÔÜ�~‰~˜i¨°Ó6Ð6r5   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=   rD   rò   rü   ©rN   r  s     r6   Ú_tpc_begin_genzBaseConnection._tpc_begin_genn  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 {})	rD   r’   r“   rò   r   Úformatr*   rI   r‘   r  s     r6   Ú_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 {})ÚlowerrD   r’   r“   rà   r   r  Úgetattrrò   r   r  r*   )rN   Úactionr  ÚfnameÚmeths        r6   Ú_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.Nr4   rV   s    r6   r  zBaseConnection._check_tpc°  s   € ð 	r5   N)r<   r#   )ÚreturnÚNone)r#  r*   )r#  rv   )rn   rv   r#  r$  )rn   rv   r#  úPQGen[None])r#  úIsolationLevel | None)rn   r&  r#  r$  )rn   r&  r#  r%  )r#  úbool | None)rn   r'  r#  r$  )rn   r'  r#  r%  )r–   r*   r#  r%  )r#  r"   )r#  r   )r#  zBaseConnection[Row])r#  r-   )r§   Úfloatr#  zPQGenConn[None])r®   r7   r#  r$  )rO   ú"ReferenceType[BaseConnection[Row]]rº   r$   r#  r$  )r®   r8   r#  r$  )rO   r)  rÇ   zpq.PGnotifyr#  r$  )r#  ú
int | None)rn   r*  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%  )Br/   r0   r1   r2   r’   ÚWarningÚErrorrí   ÚDatabaseErrorÚ	DataErrorrú   ÚIntegrityErrorÚInternalErrorr“   ÚNotSupportedErrorrP   rW   rb   ÚpropertyrT   rg   ri   Úsetterrl   rw   ry   r{   r~   r�   rƒ   r†   rˆ   rŠ   r�   ru   ra   r™   r›   rž   r¢   r    rª   r¯   r³   ÚstaticmethodrE   r¿   rÁ   rG   rÌ   rÏ   ÚclassmethodrØ   ræ   rò   r÷   rß   rý   rü   r  r
  r  r  r  r!  r  r4   r5   r6   r:   r:   N   sV  „ ñð �i‰i€GØ�G‰G€EØ×%Ñ%€NØ—O‘O€MØ—‘€IØ×)Ñ)ÐØ×%Ñ%€NØ—O‘O€MØ×)Ñ)ÐØ×+Ñ+Ðó!$óF
ó&3ð
 ò)ó ð)ð ò>ó ð>ð ò ó ð ð ×Ñò$ó ð$ó"ó'ð ò%ó ð%ð ×Ñò)ó ð)ó"ó$ð
 òó ðð ×Ñò#ó ð#ó"ó$ð
 ò ó ð ð ×Ñò$ó ð$ó"ó$ó
ð& ò+ó ð+ð òó ðð òó ðó"óóóCó
/ó/ð ðVØ1ðVØ8@ðVà	òVó ðVó/ó/ð ð
Ø1ð
Ø8Cð
à	ò
ó ð
ð ò0ó ð0ð ×Ñò1ó ð1ð ò1ó ð1ð ×Ñò,ó ð,ð àðØ58ñØðØ-2ðà	òó ðð :>ð,Øð,Ø-6ð,à	ó,ó\%óN	
ó
2ó%ó(2ó(2ó67óDó(2ðØ#ðØ*:ðà	óô>r5   r:   )Sr2   Ú
__future__r   rÐ   ÚloggingÚtypingr   r   r   r   Úweakrefr   r	   Úwarningsr
   Ú	functoolsr   r+  r   r   r’   r   r   Úabcr   r   r   Úsqlr   r   rD   r   Úrowsr   Úadaptr   Ú_enumsr   Ú_compatr   r   r   r   Úpq.miscr   rI   r   Ú
_preparingr    Ú_capabilitiesr!   Ú_connection_infor"   Úpq.abcr#   r$   Úpsycopg_pool.baser%   r&   ÚFormatræ   ÚBINARYÚ
ConnStatusrù   re   rî   ré   rê   rë   r”   r�   ÚINTRANSÚhas_send_close_preparedrô   Ú	getLoggerr¸   r)   r0   rµ   r7   r3   r8   r:   r4   r5   r6   Ú<module>rP     ss  ðòõ #ã 
Û ß ?Ó ?ß &Ý Ý å Ý Ý Ý ß (Ñ (ß  Ý Ý Ý Ý "ß <Ó <Ý 'Ý #Ý &Ý 'Ý ,áß(Ý*ñ �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ôe	�W˜S‘\õ e	r5   