§
    YŠtjB^  ã                  ó0  — 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 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. d
dl/m0Z0 d
dl1m2Z2 d
dl3m4Z4 d
dl5m6Z6 d
dl7m8Z8 erddl9m:Z: d
dl;m<Z<m=Z=  e.d¦  «        Z>ej?        j@        Z@ej?        jA        ZAejB        jC        ZCejB        jD        ZDejE        jF        ZFejE        jG        ZGejE        jH        ZHejI        jJ        ZJejI        jK        ZK e4jL        ¦   «         ZM ejN        d¦  «        ZO G d„ de	¦  «        ZPdeP_Q        eejR        gdf         ZSdeTd <   eePgdf         ZUdeTd!<    G d"„ d#ee&         ¦  «        ZVdS )$z
psycopg connection objects
é    )ÚannotationsN)ÚTYPE_CHECKINGÚAnyÚGenericÚ
NamedTupleÚ	TypeAlias)ÚReferenceTypeÚref)Úwarn)Úpartial)Údeque)ÚCallableé   )Úerrors)Ú
generatorsÚpostgresÚpq)ÚPQGenÚ	PQGenConnÚQueryNoTemplate)ÚSQLÚ
Composable)ÚXid)ÚRow)ÚAdaptersMap)ÚIsolationLevel)ÚLiteralStringÚSelfÚTypeVar)Úconnection_summary)ÚPrepareManager)Úcapabilities)ÚBasePipeline)ÚConnectionInfo)ÚBasePool)ÚPGconnÚPGresultÚ	CursorRowÚpsycopgc                  ó6   — e Zd ZU dZded<   	 ded<   	 ded<   dS )ÚNotifyz8An asynchronous notification received from the database.ÚstrÚchannelÚpayloadÚintÚpidN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__© ó    úV/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/psycopg/_connection_base.pyr+   r+   <   s9   € € € € € € ØBÐBà€L€L�LØIà€L€L�LØ3à€H€H�HØEÐ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dkd„Zefdld	„Zdmd„Zednd„¦   «         Zednd„¦   «         Zednd„¦   «         Zej        dod„¦   «         Zdod„Zdpd„Zedqd„¦   «         Zej        drd„¦   «         Zdrd„Zdsd„Zedtd„¦   «         Zej        dud„¦   «         Zdud„Zdvd„Zedtd„¦   «         Z e j        dud „¦   «         Z dud!„Z!dvd"„Z"dwd$„Z#edxd&„¦   «         Z$edyd(„¦   «         Z%edzd*„¦   «         Z&d{d,„Z'd|d-„Z(dnd.„Z)d}d2„Z*d~d5„Z+d~d6„Z,e-dd;„¦   «         Z.d€d=„Z/d€d>„Z0e-d�dA„¦   «         Z1ed‚dC„¦   «         Z2e2j        dƒdD„¦   «         Z2ed‚dE„¦   «         Z3e3j        dƒdF„¦   «         Z3e4	 d„dHdIœd…dL„¦   «         Z5e6fd†dR„Z7d‡dU„Z8d|dV„Z9dˆdW„Z:d‰dY„Z;dˆdZ„Z<dˆd[„Z=dŠd`„Z>d‹dc„Z?dˆdd„Z@dŒdh„ZAd|di„ZBdjS )�ÚBaseConnectionz±
    Base class for different types of connections.

    Share common functionalities such as access to the wrapped PGconn, but
    allow different interfaces (sync/async).
    Úpgconnr&   c                ó®  — || _         d| _        d | _        g | _        g | _        d| _        d| _        t          ¦   «         | _        d | _	        t          ¦   «         | _        t          | ¦  «        }t          t          j        |¦  «        |_        t          t          j        |¦  «        |_        |  d | _        |  |  d | _        d | _        d | _        d| _        d S )NFr   r7   )r=   Ú_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__c   sÔ   € ØˆŒØ ˆÔð .2ˆŒà57ˆÔØ57ˆÔð "#ˆÔàˆŒÝ)7Ñ)9Ô)9ˆŒØ-1ˆŒ	õ 8=±w´wˆÔå�D‘	”	ˆÝ '­Ô(FÈÑ NÔ NˆÔÝ '­Ô(FÈÑ NÔ NˆÔð 	Ð#à.2ˆŒð 	ÐàÐà7;ˆÔØ'+ˆŒØ(,ˆÔØ #ˆÔÐÐr7   Ú_BaseConnection__warnr   ÚreturnÚNonec                ó¸   — t          | d¦  «        sd S | j        rd S t          | d¦  «        rd S  |t                               | ¦  «        › d�t          ¦  «         d S )Nr=   Ú_poolz_ was deleted while still open. Please use 'with' or '.close()' to close the connection properly)ÚhasattrÚclosedÚobjectÚ__repr__ÚResourceWarning)rQ   rT   s     r8   Ú__del__zBaseConnection.__del__Œ   s…   € å�t˜XÑ&Ô&ð 	ØˆFð Œ;ð 	ØˆFõ �4˜Ñ!Ô!ð 	ØˆFàˆÝ�Š˜tÑ$Ô$ð Pð Pð Påñ	
ô 	
ð 	
ð 	
ð 	
r7   r,   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   r\   zBaseConnection.__repr__Ÿ   sX   € Ø”Ô*ÐJÐJ¨T¬^Ô-HÐJÐJˆÝ! $¤+Ñ.Ô.ˆØ2�3Ð2Ð2˜Ð2Ð2¥R¨¡X¤XÐ2Ð2Ð2Ð2Ð2r7   Úboolc                ó,   — | j         j        t          k    S )z$`!True` if the connection is closed.)r=   ÚstatusÚBAD©rQ   s    r8   rZ   zBaseConnection.closed¤   s   € ð Œ{Ô!¥SÒ(Ð(r7   c                ó<   — | j         j        t          k    o| 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=   rk   rl   rD   rm   s    r8   ÚbrokenzBaseConnection.broken©   s   € ð Œ{Ô!¥SÒ(Ð=°´Ð-=Ð=r7   c                ó   — | j         S )z'The autocommit state of the connection.)r?   rm   s    r8   Ú
autocommitzBaseConnection.autocommit³   s   € ð ÔÐr7   Úvaluec                ó0   — |                       |¦  «         d S ©N)Ú_set_autocommit©rQ   rr   s     r8   rq   zBaseConnection.autocommit¸   ó   € à×Ò˜UÑ#Ô#Ð#Ð#Ð#r7   c                ó   — t           ‚rt   ©ÚNotImplementedErrorrv   s     r8   ru   zBaseConnection._set_autocommit¼   ó   € Ý!Ð!r7   úPQGen[None]c              #  óh   K  — |                       d¦  «        E d {V —† t          |¦  «        | _        d S )Nrq   )Ú_check_intrans_genri   r?   rv   s     r8   Ú_set_autocommit_genz"BaseConnection._set_autocommit_gen¿   s@   è è € Ø×*Ò*¨<Ñ8Ô8Ð8Ð8Ð8Ð8Ð8Ð8Ð8Ý ™;œ;ˆÔÐÐr7   úIsolationLevel | Nonec                ó   — | j         S )zX
        The isolation level of the new transactions started on the connection.
        )rM   rm   s    r8   Úisolation_levelzBaseConnection.isolation_levelÃ   s   € ð
 Ô$Ð$r7   c                ó0   — |                       |¦  «         d S rt   )Ú_set_isolation_levelrv   s     r8   r‚   zBaseConnection.isolation_levelÊ   s   € à×!Ò! %Ñ(Ô(Ð(Ð(Ð(r7   c                ó   — t           ‚rt   ry   rv   s     r8   r„   z#BaseConnection._set_isolation_levelÎ   r{   r7   c              #  ó~   K  — |                       d¦  «        E d {V —† |�t          |¦  «        nd | _        d| _        d S )Nr‚   r7   )r~   r   rM   rP   rv   s     r8   Ú_set_isolation_level_genz'BaseConnection._set_isolation_level_genÑ   sV   è è € Ø×*Ò*Ð+<Ñ=Ô=Ð=Ð=Ð=Ð=Ð=Ð=Ð=Ø9>Ð9J¥¨uÑ 5Ô 5Ð 5ÐPTˆÔØ #ˆÔÐÐr7   úbool | Nonec                ó   — | j         S )zX
        The read-only state of the new transactions started on the connection.
        )rN   rm   s    r8   Ú	read_onlyzBaseConnection.read_onlyÖ   s   € ð
 ŒÐr7   c                ó0   — |                       |¦  «         d S rt   )Ú_set_read_onlyrv   s     r8   rŠ   zBaseConnection.read_onlyÝ   s   € à×Ò˜EÑ"Ô"Ð"Ð"Ð"r7   c                ó   — t           ‚rt   ry   rv   s     r8   rŒ   zBaseConnection._set_read_onlyá   r{   r7   c              #  ó~   K  — |                       d¦  «        E d {V —† |�t          |¦  «        nd | _        d| _        d S )NrŠ   r7   )r~   ri   rN   rP   rv   s     r8   Ú_set_read_only_genz!BaseConnection._set_read_only_genä   sP   è è € Ø×*Ò*¨;Ñ7Ô7Ð7Ð7Ð7Ð7Ð7Ð7Ð7Ø).Ð):�$˜u™+œ+˜+ÀˆŒØ #ˆÔÐÐr7   c                ó   — | j         S )zY
        The deferrable state of the new transactions started on the connection.
        )rO   rm   s    r8   Ú
deferrablezBaseConnection.deferrableé   s   € ð
 ÔÐr7   c                ó0   — |                       |¦  «         d S rt   )Ú_set_deferrablerv   s     r8   r‘   zBaseConnection.deferrableð   rw   r7   c                ó   — t           ‚rt   ry   rv   s     r8   r“   zBaseConnection._set_deferrableô   r{   r7   c              #  ó~   K  — |                       d¦  «        E d {V —† |�t          |¦  «        nd | _        d| _        d S )Nr‘   r7   )r~   ri   rO   rP   rv   s     r8   Ú_set_deferrable_genz"BaseConnection._set_deferrable_gen÷   sQ   è è € Ø×*Ò*¨<Ñ8Ô8Ð8Ð8Ð8Ð8Ð8Ð8Ð8Ø*/Ð*;�4 ™;œ;˜;ÀˆÔØ #ˆÔÐÐr7   Ú	attributec              #  óR  K  — | j         j        x}t          k    r2| j        r+| j                             ¦   «         E d {V —† | j         j        }|t          k    rP| j        rt          j        d|›d�¦  «        ‚t          j        d|›dt          j	        |¦  «        j
        › �¦  «        ‚d S )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   r—   rk   s      r8   r~   z!BaseConnection._check_intrans_genü   sß   è è € à”kÔ4Ð4ˆF½Ò=Ð=À$Ä.Ð=Ø”~×/Ò/Ñ1Ô1Ð1Ð1Ð1Ð1Ð1Ð1Ð1Ø”[Ô3ˆFØ•TŠ>ˆ>ØÔ%ð 
ÝÔ(ðC Ið Cð Cð Cñô ð õ
 Ô(ð; Ið ;ð ;åÔ+¨FÑ3Ô3Ô8ð;ð ;ñô ð ð ˆ>r7   r$   c                ó*   — t          | j        ¦  «        S )z>A `ConnectionInfo` attribute to inspect connection properties.)r$   r=   rm   s    r8   rh   zBaseConnection.info  s   € õ ˜dœkÑ*Ô*Ð*r7   r   c                óZ   — | j         st          t          j        ¦  «        | _         | j         S rt   )r@   r   r   Úadaptersrm   s    r8   r¢   zBaseConnection.adapters  s&   € àŒ~ð 	<Ý(­Ô):Ñ;Ô;ˆDŒNàŒ~Ðr7   úBaseConnection[Row]c                ó   — | S rt   r6   rm   s    r8   Ú
connectionzBaseConnection.connection  s	   € ð ˆr7   r/   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=   Úsocketrm   s    r8   ÚfilenozBaseConnection.fileno  s   € ð Œ{Ô!Ð!r7   c                óŒ   — |                       ¦   «         r/| j                             ¦   «         }|                     ¦   «          dS dS )z/Cancel the current operation on the connection.N)Ú_should_cancelr=   Ú
get_cancelÚcancel)rQ   Úcs     r8   r¬   zBaseConnection.cancel(  sD   € à×ÒÑ Ô ð 	Ø”×&Ò&Ñ(Ô(ˆAØ�HŠH‰JŒJˆJˆJˆJð	ð 	r7   c                óh   — | j         rdS | j        r!| j        d         rt          j        d¦  «        ‚dS )zhCheck whether the current command should actually be cancelled when
        invoking cancel*().
        Fr   z=cancel() cannot be used with a prepared two-phase transactionT)rZ   rF   rœ   r�   rm   s    r8   rª   zBaseConnection._should_cancel.  sI   € ð Œ;ð 	Ø�5ØŒ9ð 	˜œ 1œð 	ÝÔ$ØOñô ð ð ˆtr7   ÚtimeoutÚfloatúPQGenConn[None]c             #  óœ   K  — | j                              ¦   «         }|                     ¦   «          t          j        ||¬¦  «        E d {V —† d S )N©r¯   )r=   Úcancel_connÚstartr   r¬   )rQ   r¯   r´   s      r8   Ú_cancel_genzBaseConnection._cancel_gen=  sY   è è € Ø”k×-Ò-Ñ/Ô/ˆØ×ÒÑÔÐÝÔ$ [¸'ÐBÑBÔBÐBÐBÐBÐBÐBÐBÐBÐBÐBr7   Úcallbackr9   c                ó:   — | j                              |¦  «         dS )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   r·   s     r8   Úadd_notice_handlerz!BaseConnection.add_notice_handlerB  ó!   € ð 	Ô×$Ò$ XÑ.Ô.Ð.Ð.Ð.r7   c                ó:   — | j                              |¦  «         dS )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_handlerK  r¼   r7   rR   ú"ReferenceType[BaseConnection[Row]]Úresr'   c                ó   —  | ¦   «         }|r|j         sd S t          j        ||j        j        ¦  «        }|j         D ]A}	  ||¦  «         Œ# t
          $ r&}t                               d||¦  «         Y d }~Œ:d }~ww xY wd S )Nz)error processing notice callback '%s': %s)rA   rœ   Ú
Diagnosticr=   Ú	_encodingÚ	ExceptionÚloggerÚ	exception)rR   rÁ   rQ   ÚdiagÚcbÚexs         r8   rH   zBaseConnection._notice_handlerT  s½   € ð ˆu‰wŒwˆØð 	˜Ô.ð 	ØˆFåŒ|˜C ¤Ô!6Ñ7Ô7ˆØÔ'ð 	Vð 	VˆBðVØ��4‘”��øÝð Vð Vð VÝ× Ò Ð!LÈbÐRTÑUÔUÐUÐUÐUÐUÐUÐUøøøøðVøøøð	Vð 	Vs   ¿AÁ
A;ÁA6Á6A;r:   c                ó:   — | j                              |¦  «         dS )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_handlerc  r¼   r7   c                ó:   — | j                              |¦  «         dS )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_handlerl  r¼   r7   Úpgnúpq.PGnotifyc                óB  —  | ¦   «         x}sd S |j         j        }t          |j                             |¦  «        |j                             |¦  «        |j        ¦  «        }|j        r|j        D ]} ||¦  «         Œd S |j        x}�| 	                    |¦  «         d S d S rt   )
r=   rÄ   r+   ÚrelnameÚdecodeÚextraÚbe_pidrB   rG   r¹   )rR   rÏ   rQ   ÚencÚnrÉ   Úds          r8   rJ   zBaseConnection._notify_handleru  s¹   € ð ˜™œ��ð 	ØˆFàŒkÔ#ˆÝ�3”;×%Ò% cÑ*Ô*¨C¬I×,<Ò,<¸SÑ,AÔ,AÀ3Ä:ÑNÔNˆàÔ ð 	ØÔ+ð ð �Ø��1‘”��ðð ð Ô+Ð+�Ð8Ø—’˜‘”���ð 9Ð8r7   ú
int | Nonec                ó   — | 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_thresholdrm   s    r8   rÜ   z BaseConnection.prepare_threshold‡  s   € ð Œ~Ô/Ð/r7   c                ó   — || j         _        d S rt   rÛ   rv   s     r8   rÜ   z BaseConnection.prepare_threshold•  s   € à+0ˆŒÔ(Ð(Ð(r7   c                óB   — | j         j        }|t          j        k    r|n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ˆr¨DÐ0r7   c                ó:   — |€t           j        }|| j        _        d S rt   )rà   rá   rE   rß   rv   s     r8   rß   zBaseConnection.prepared_max¤  s   € àˆ=Ý”KˆEØ&+ˆŒÔ#Ð#Ð#r7   Ú g        r³   ÚconninfoúPQGenConn[Self]c             #  óX   K  — t          j        ||¬¦  «        E d{V —†} | |¦  «        }|S )z?Generator to connect to the database and create a new instance.r³   N)r   Úconnect)rg   rå   r¯   r=   Úconns        r8   Ú_connect_genzBaseConnection._connect_gen´  sA   è è € õ
 'Ô.¨xÀÐIÑIÔIÐIÐIÐIÐIÐIÐIˆØˆs�6‰{Œ{ˆØˆr7   Úcommandr   Úresult_formatú	pq.FormatúPQGen[PGresult | None]c              #  ó¸  K  — |                       ¦   «          t          |t          ¦  «        r |                     | j        j        ¦  «        }n*t          |t          ¦  «        r|                     | ¦  «        }| j        r]t          | j        j
        |d|¬¦  «        }| j        j                             |¦  «         | j        j                             d¦  «         dS |t          k    r| j                             |¦  «         n| j         
                    |d|¬¦  «         t!          j        | j        ¦  «        E d{V —†d         }|j        t&          k    rˆ|j        t(          k    rx|j        t*          k    r t-          j        || j        j        ¬¦  «        ‚t-          j        dt3          j        |j        ¦  «        j        › d|                     ¦   «         ›�¦  «        ‚|S )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)rì   éÿÿÿÿ©Ú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   Úexecuterk   Ú
COMMAND_OKÚ	TUPLES_OKÚFATAL_ERRORrœ   Úerror_from_resultÚInterfaceErrorr   Ú
ExecStatusrŸ   rÓ   )rQ   rë   rì   ÚcmdÚresults        r8   Ú_exec_commandzBaseConnection._exec_command½  sÑ  è è € ð 	×!Ò!Ñ#Ô#Ð#å�g�sÑ#Ô#ð 	-Ø—n’n T¤[Ô%:Ñ;Ô;ˆGˆGÝ˜¥Ñ,Ô,ð 	-Ø×&Ò& tÑ,Ô,ˆGàŒ>ð 		ÝØ”Ô-ØØØ+ð	ñ ô ˆCð ŒNÔ(×/Ò/°Ñ4Ô4Ð4ØŒNÔ'×.Ò.¨tÑ4Ô4Ð4Ø�4ð
 �DÒ Ð ØŒK×"Ò" 7Ñ+Ô+Ð+Ð+àŒK×)Ò)¨'°4À}Ð)ÑUÔUÐUå'1Ô'9¸$¼+Ñ'FÔ'FÐFÐFÐFÐFÐFÐFÈÔKˆØŒ=�JÒ&Ð&¨6¬=½IÒ+EÐ+EØŒ}¥Ò+Ð+ÝÔ)¨&¸4¼;Ô;PÐQÑQÔQÐQåÔ&ð:­¬°v´}Ñ)EÔ)EÔ)Jð :ð :Ø%,§^¢^Ñ%5Ô%5ð:ð :ñô ð ð ˆr7   rŸ   úbytes | Nonec              #  ó¸  K  — |�t           s&|�d|z   nd}|                      |¦  «        E d{V —† dS |                      ¦   «          | j        rZt	          | j        j        |¦  «        }| j        j                             |¦  «         | j        j	                             d¦  «         dS | j                             |¦  «         t          j        | j        ¦  «        E d{V —†d         }|j        t          k    rd|j        t          k    r t          j        || j        j        ¬¦  «        ‚t          j        dt'          j        |j        ¦  «        j        › d�¦  «        ‚dS )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ý   rk   rþ   r   rœ   r  rÄ   r  r   r  rŸ   )rQ   rŸ   Ústmtr  r  s        r8   Ú_deallocatezBaseConnection._deallocateë  sr  è è € ð ˆ<�ˆ<Ø,0Ð,<�> DÑ(Ð(ÐBSˆDØ×)Ò)¨$Ñ/Ô/Ð/Ð/Ð/Ð/Ð/Ð/Ð/ØˆFà×!Ò!Ñ#Ô#Ð#àŒ>ð 	Ý˜$œ+Ô9¸4Ñ@Ô@ˆCØŒNÔ(×/Ò/°Ñ4Ô4Ð4ØŒNÔ'×.Ò.¨tÑ4Ô4Ð4ØˆFàŒ×'Ò'¨Ñ-Ô-Ð-å'Ô/°´Ñ<Ô<Ð<Ð<Ð<Ð<Ð<Ð<¸bÔAˆØŒ=�JÒ&Ð&ØŒ}¥Ò+Ð+ÝÔ)¨&¸4¼;Ô;PÐQÑQÔQÐQåÔ&ðG­¬°v´}Ñ)EÔ)EÔ)Jð Gð Gð Gñô ð ð	 'Ð&r7   c                óÄ   — | j         j        t          k    rd S | 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=   rk   ÚOKrl   rœ   ÚOperationalErrorr  rm   s    r8   rô   z#BaseConnection._check_connection_ok  se   € ØŒ;Ô¥Ò#Ð#ØˆFàŒ;Ô¥Ò$Ð$ÝÔ$Ð%?Ñ@Ô@Ð@ÝÔð/Øœ+Ô,ð/ð /ñ
ô 
ð 	
r7   c              #  óô   K  — | j         rdS | j        j        t          k    rdS |                      |                      ¦   «         ¦  «        E d{V —† | j        r!| j                             ¦   «         E d{V —† dS dS )z.Generator to start a transaction if necessary.N)r?   r=   r™   rš   r  Ú_get_tx_start_commandrL   r›   rm   s    r8   Ú_start_queryzBaseConnection._start_query  s�   è è € àÔð 	ØˆFàŒ;Ô)­TÒ1Ð1ØˆFà×%Ò% d×&@Ò&@Ñ&BÔ&BÑCÔCÐCÐCÐCÐCÐCÐCÐCØŒ>ð 	2Ø”~×/Ò/Ñ1Ô1Ð1Ð1Ð1Ð1Ð1Ð1Ð1Ð1Ð1ð	2ð 	2r7   Úbytesc                óÚ  — | j         r| j         S dg}| j        �it          | j        ¦  «        }|                     d¦  «         |                     |j                             dd¦  «                             ¦   «         ¦  «         | j        �|                     | j        rdnd¦  «         | j        �|                     | j        rdnd¦  «         d	 	                    |¦  «        | _         | j         S )
Ns   BEGINs   ISOLATION LEVELÚ_rb   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Ñ6Ô6ˆCØ�LŠLÐ+Ñ,Ô,Ð,Ø�LŠL˜œ×)Ò)¨#¨sÑ3Ô3×:Ò:Ñ<Ô<Ñ=Ô=Ð=àŒ>Ð%Ø�LŠL¨¬ÐJ˜˜¸]ÑKÔKÐKàŒ?Ð&Ø�LŠL¨$¬/ÐP˜˜Ð?PÑQÔQÐQà $§	¢	¨%Ñ 0Ô 0ˆÔØÔ$Ð$r7   c              #  ó*  K  — | j         rt          j        d¦  «        ‚| j        rt          j        d¦  «        ‚| j        j        t          k    rdS |                      d¦  «        E d{V —† | j        r!| j         	                    ¦   «         E d{V —† dS dS )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›   rm   s    r8   Ú_commit_genzBaseConnection._commit_gen:  sÌ   è è € àÔ!ð 	ÝÔ$ð4ñô ð ð
 Œ9ð 	ÝÔ$ØHñô ð ð Œ;Ô)­TÒ1Ð1ØˆFà×%Ò% iÑ0Ô0Ð0Ð0Ð0Ð0Ð0Ð0Ð0àŒ>ð 	2Ø”~×/Ò/Ñ1Ô1Ð1Ð1Ð1Ð1Ð1Ð1Ð1Ð1Ð1ð	2ð 	2r7   c              #  óè  K  — | j         rt          j        d¦  «        ‚| j        rt          j        d¦  «        ‚| j        r| j                             ¦   «         E d{V —† | j        j        t          k    rdS |  	                    d¦  «        E d{V —† | j
                             ¦   «          | j
                             | ¦  «        E d{V —† | j        r!| j                             ¦   «         E d{V —† dS dS )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_genrm   s    r8   Ú_rollback_genzBaseConnection._rollback_genN  s9  è è € àÔ!ð 	ÝÔ$ðAñô ð ð
 Œ9ð 	ÝÔ$ØJñô ð ð
 Œ>ð 	2Ø”~×/Ò/Ñ1Ô1Ð1Ð1Ð1Ð1Ð1Ð1Ð1àŒ;Ô)­TÒ1Ð1ØˆFà×%Ò% kÑ2Ô2Ð2Ð2Ð2Ð2Ð2Ð2Ð2ØŒ×ÒÑÔÐØ”>×.Ò.¨tÑ4Ô4Ð4Ð4Ð4Ð4Ð4Ð4Ð4àŒ>ð 	2Ø”~×/Ò/Ñ1Ô1Ð1Ð1Ð1Ð1Ð1Ð1Ð1Ð1Ð1ð	2ð 	2r7   Ú	format_idÚgtridÚbqualr   c                óV   — |                       ¦   «          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   r!  r"  r#  s       r8   ÚxidzBaseConnection.xidi  s(   € ð 	�ŠÑÔÐÝŒ~˜i¨°Ñ6Ô6Ð6r7   r'  ú	Xid | strc              #  óÀ  K  — |                       ¦   «          t          |t          ¦  «        st          j        |¦  «        }| j        j        t          k    r8t          j        dt          j
        | j        j        ¦  «        j        › �¦  «        ‚| j        rt          j        d¦  «        ‚|df| _        |                      |                      ¦   «         ¦  «        E d {V —† d S )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_genv  sî   è è € Ø�ŠÑÔÐå˜#�sÑ#Ô#ð 	'Ý”/ #Ñ&Ô&ˆCàŒ;Ô)­TÒ1Ð1ÝÔ$ðPÝÔ(¨¬Ô)GÑHÔHÔMðPð Pñô ð ð
 Ôð 	ÝÔ$ØEñô ð ð ˜%�LˆŒ	Ø×%Ò% d×&@Ò&@Ñ&BÔ&BÑCÔCÐCÐCÐCÐCÐCÐCÐCÐCÐCr7   c              #  óŽ  K  — | j         st          j        d¦  «        ‚| j         d         rt          j        d¦  «        ‚| j         d         }|df| _         |                      t	          d¦  «                             t          |¦  «        ¦  «        ¦  «        E d {V —† | j        r!| j                             ¦   «         E d {V —† d S d S )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ð 	ÝÔ$ØOñô ð ð Œ9�QŒ<ð 	ÝÔ$ØXñô ð ð Œi˜ŒlˆØ˜$�KˆŒ	Ø×%Ò%¥cÐ*BÑ&CÔ&C×&JÒ&JÍ3ÈsÉ8Ì8Ñ&TÔ&TÑUÔUÐUÐUÐUÐUÐUÐUÐUØŒ>ð 	2Ø”~×/Ò/Ñ1Ô1Ð1Ð1Ð1Ð1Ð1Ð1Ð1Ð1Ð1ð	2ð 	2r7   Úactionr   úXid | str | Nonec              #  ó„  K  — d|                      ¦   «         › d�}|€,| j        st          j        |› d�¦  «        ‚| j        d         }nG| j        rt          j        |› d�¦  «        ‚t	          |t
          ¦  «        st          j        |¦  «        }| j        rL| j        d         s?t          | d|                      ¦   «         › d�¦  «        }d | _         |¦   «         E d {V —† d S |                      t          d	¦  «         
                    t          |¦  «        t          |¦  «        ¦  «        ¦  «        E d {V —† d | _        d S )
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   r0  r'  ÚfnameÚmeths        r8   Ú_tpc_finish_genzBaseConnection._tpc_finish_gen™  s‰  è è € ð *�v—|’|‘~”~Ð)Ð)Ð)ˆØˆ;Ø”9ð ÝÔ(Øð =ð =ð =ñô ð ð ”)˜A”,ˆCˆCàŒyð ÝÔ(Øð 7ð 7ð 7ñô ð õ ˜c¥3Ñ'Ô'ð +Ý”o cÑ*Ô*�àŒ9ð 		˜TœY qœ\ð 		å˜4Ð!9 V§\¢\¡^¤^Ð!9Ð!9Ð!9Ñ:Ô:ˆDØˆDŒIØ�t‘v”vÐÐÐÐÐÐÐÐÐà×)Ò)ÝÐ$Ñ%Ô%×,Ò,­S°©[¬[½#¸c¹(¼(ÑCÔCñô ð ð ð ð ð ð ð ð ˆDŒIˆIˆIr7   c                ó   — dS )z0Raise NotSupportedError if TPC is not supported.Nr6   rm   s    r8   r%  zBaseConnection._check_tpc¸  s	   € ð 	ˆr7   N)r=   r&   )rT   r   rU   rV   )rU   r,   )rU   ri   )rr   ri   rU   rV   )rr   ri   rU   r|   )rU   r€   )rr   r€   rU   rV   )rr   r€   rU   r|   )rU   rˆ   )rr   rˆ   rU   rV   )rr   rˆ   rU   r|   )r—   r,   rU   r|   )rU   r$   )rU   r   )rU   r£   )rU   r/   )rU   rV   )r¯   r°   rU   r±   )r·   r9   rU   rV   )rR   rÀ   rÁ   r'   rU   rV   )r·   r:   rU   rV   )rR   rÀ   rÏ   rÐ   rU   rV   )rU   rÙ   )rr   rÙ   rU   rV   )rä   )rå   r,   r¯   r°   rU   ræ   )rë   r   rì   rí   rU   rî   )rŸ   r  rU   r|   )rU   r|   )rU   r  )r!  r/   r"  r,   r#  r,   rU   r   )r'  r(  rU   r|   )r0  r   r'  r1  rU   r|   )Cr1   r2   r3   r4   rœ   ÚWarningÚErrorr  ÚDatabaseErrorÚ	DataErrorr  ÚIntegrityErrorÚInternalErrorr�   ÚNotSupportedErrorrS   r   r^   r\   ÚpropertyrZ   ro   rq   Úsetterru   r   r‚   r„   r‡   rŠ   rŒ   r�   r‘   r“   r–   r~   rh   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/  r9  r%  r6   r7   r8   r<   r<   O   sÀ  € € € € € ðð ð Œi€GØŒG€EØÔ%€NØ”O€MØ”€IØÔ)ÐØÔ%€NØ”O€MØÔ)ÐØÔ+Ðð'$ð '$ð '$ð '$ðR %)ð 
ð 
ð 
ð 
ð 
ð&3ð 3ð 3ð 3ð
 ð)ð )ð )ñ „Xð)ð ð>ð >ð >ñ „Xð>ð ð ð  ð  ñ „Xð ð Ôð$ð $ð $ñ Ôð$ð"ð "ð "ð "ð'ð 'ð 'ð 'ð ð%ð %ð %ñ „Xð%ð Ôð)ð )ð )ñ Ôð)ð"ð "ð "ð "ð$ð $ð $ð $ð
 ðð ð ñ „Xðð Ôð#ð #ð #ñ Ôð#ð"ð "ð "ð "ð$ð $ð $ð $ð
 ð ð  ð  ñ „Xð ð Ôð$ð $ð $ñ Ôð$ð"ð "ð "ð "ð$ð $ð $ð $ð
ð ð ð ð$ ð+ð +ð +ñ „Xð+ð ðð ð ñ „Xðð ðð ð ñ „Xðð"ð "ð "ð "ðð ð ð ðð ð ð ðCð Cð Cð Cð
/ð /ð /ð /ð/ð /ð /ð /ð ðVð Vð Vñ „\ðVð/ð /ð /ð /ð/ð /ð /ð /ð ðð ð ñ „\ðð" ð0ð 0ð 0ñ „Xð0ð Ôð1ð 1ð 1ñ Ôð1ð ð1ð 1ð 1ñ „Xð1ð Ôð,ð ,ð ,ñ Ôð,ð àðØ58ðð ð ð ð ñ „[ðð DHð,ð ,ð ,ð ,ð ,ð\"ð "ð "ð "ðH	
ð 	
ð 	
ð 	
ð
2ð 
2ð 
2ð 
2ð%ð %ð %ð %ð(2ð 2ð 2ð 2ð(2ð 2ð 2ð 2ð67ð 7ð 7ð 7ðDð Dð Dð Dð(2ð 2ð 2ð 2ðð ð ð ð>ð ð ð ð ð r7   r<   )Wr4   Ú
__future__r   rà   ÚloggingÚtypingr   r   r   r   r   Úweakrefr	   r
   Úwarningsr   Ú	functoolsr   Úcollectionsr   Úcollections.abcr   rä   r   rœ   r   r   r   Úabcr   r   r   Úsqlr   r   rF   r   Úrowsr   Úadaptr   Ú_enumsr   Ú_compatr   r   r   Úpq.miscr    Ú
_preparingr!   Ú_capabilitiesr"   Ú_pipeline_baser#   Ú_connection_infor$   Úpsycopg_pool.baser%   Úpq.abcr&   r'   r(   ÚFormatrû   ÚBINARYÚ
ConnStatusr  rl   r  rþ   rÿ   r   rž   rš   ÚINTRANSÚhas_send_close_preparedr	  Ú	getLoggerrÆ   r+   r2   rÃ   r9   r5   r:   r<   r6   r7   r8   ú<module>ra     sc  ððð ð ð #Ð "Ð "Ð "Ð "Ð "à 
€
€
€
Ø €€€Ø EÐ EÐ EÐ EÐ EÐ EÐ EÐ EÐ EÐ EÐ EÐ EÐ EÐ EØ &Ð &Ð &Ð &Ð &Ð &Ð &Ð &Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø $Ð $Ð $Ð $Ð $Ð $à Ð Ð Ð Ð Ð Ø &Ð &Ð &Ð &Ð &Ð &Ð &Ð &Ð &Ð &Ø 2Ð 2Ð 2Ð 2Ð 2Ð 2Ð 2Ð 2Ð 2Ð 2Ø  Ð  Ð  Ð  Ð  Ð  Ð  Ð  Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø "Ð "Ð "Ð "Ð "Ð "Ø 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ø 'Ð 'Ð 'Ð 'Ð 'Ð 'Ø &Ð &Ð &Ð &Ð &Ð &Ø 'Ð 'Ð 'Ð 'Ð 'Ð 'Ø (Ð (Ð (Ð (Ð (Ð (Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,àð )Ø*Ð*Ð*Ð*Ð*Ð*à(Ð(Ð(Ð(Ð(Ð(Ð(Ð(ð ˆG�KÑ Ô €	à	„y„~€Ø	ŒÔ	€à„]Ô€Ø„mÔ€àŒ]Ô%€
ØŒMÔ#€	ØŒmÔ'€à	ÔÔ €Ø
Ô
Ô
&€à6�,Ô6Ñ8Ô8€à	ˆÔ	˜9Ñ	%Ô	%€ð
Fð 
Fð 
Fð 
Fð 
FˆZñ 
Fô 
Fð 
Fð €Ô à# Q¤\ N°DÐ$8Ô9€Ð 9Ð 9Ð 9Ñ 9Ø# V H¨d NÔ3€Ð 3Ð 3Ð 3Ñ 3ðl	ð l	ð l	ð l	ð l	�W˜S”\ñ l	ô l	ð l	ð l	ð l	r7   