ó
    øÞ jý‚ ã                   óv  • S SK r S SKrS SKrS SKrS SKrS SKrS SKrS SKrS SKrS SK	r	S SK
r
S SKrS SKrS SKrS SKrSSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SS	KJr  SS
KJr  SSKJr  SSKJr   " S S\5      r " S S\S9rS,SSSSSSSSSSSSSSSS\\R:                  SSSSS.S jjr " S S5      r " S S5      r  " S S\RB                  5      r" " S S5      r# " S  S!5      r$\RJ                  " S"/ S#Q5      r&S$\&l'        \RJ                  " S%/ S&Q5      r(S'\(l'        S( r)S-S) jr*S* r+S+ r,S q-g).é    Né   )Úcompat)Úconnect_utils)Úcursor)Ú
exceptions)Úintrospection)Úprepared_stmt)Úprotocol)Úserverversion)Útransaction)Úutilsc                   ó   • \ rS rSrS rSrg)ÚConnectionMetaé$   c                 ó^   • [        U5      R                  n[        U;   =(       d	    [        U;   $ ©N)ÚtypeÚ__mro__Ú
ConnectionÚ_ConnectionProxy)ÚclsÚinstanceÚmros      ÚL/var/www/html/gaurav/venv/lib/python3.13/site-packages/asyncpg/connection.pyÚ__instancecheck__Ú ConnectionMeta.__instancecheck__&   s'   € Ü�8‹n×$Ñ$ˆÜ˜SÑ ×;Ô$4¸Ñ$;Ð;ó    © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r   Ú__static_attributes__r   r   r   r   r   $   s   † õ<r   r   c                   ól  • \ rS rSrSrSrS\R                  S\R                  4S jr	S r
S rS	 rS
 rS rS rS rS rS rS rS rS rSSSS.S jrS rSS.S\S\R4                  \   S\4S jjrSS.S\S\R4                  \   4S jjrSSSSS .S!\R<                  \\S4   4S" jjr S# r!S$ r"SSSS%.S& jr#SSSS'.S( jr$SSSSS).S*\R<                  \\S4   S+\4S, jjr%SSS-.S\&4S. jjr'S/SS0.S1 jr(SSS-.S2 jr)SSS-.S\R4                  \   4S3 jjr*SSSSSSSSSSSSS4.S5 jr+SSSSSSSSSSS6.
S7 jr,SSSSSSSSSSSSSSSSS8.S9 jr-SSSSS:.S; jr.S< r/SSSSSSSSSSSSS=.S> jr0S? r1S@ r2SASBSC.SD jr3SASE.SF jr4SASSC.SG jr5SH r6SS.SI jr7SJ r8SK r9SS.SL jr:SM r;SN r<SO r=SP r>SQ r?SR r@SS rAST rBSU rCSV rDSW rESX rFSY rGSZ rHS[ rIS\ rJS] rKSmS^ jrLS_ rMS` rNSa rOSb rPSc rQSSSSd.Se jrR\SR¨                  Sf 5       rU\SR¨                  Sg 5       rVSSSSd.Sh jrW  SnSi jrX SoSSSj.Sk jjrYSlrZg)pr   é+   zqA representation of a database session.

Connections are created by calling :func:`~asyncpg.connection.connect`.
)Ú	_protocolÚ
_transportÚ_loopÚ	_top_xactÚ_abortedÚ_pool_release_ctrÚ_stmt_cacheÚ_stmts_to_closeÚ_stmt_cache_enabledÚ
_listenersÚ_server_versionÚ_server_capsÚ_intro_queryÚ_reset_queryÚ_proxyÚ_stmt_exclusive_sectionÚ_configÚ_paramsÚ_addrÚ_log_listenersÚ_termination_listenersÚ_cancellationsÚ_source_tracebackÚ_query_loggersÚ__weakref__ÚconfigÚparamsc           
      ó¦  • Xl         X l        X0l        S U l        SU l        SU l        X@l        XPl        X`l        [        UUR                  [        R                  " [        [        R                  " U 5      5      UR                   S9U l        [%        5       U l        UR                  S:„  U l        0 U l        [%        5       U l        [%        5       U l        [%        5       U l        [%        5       U l        U R                   R5                  5       nUR6                  n[8        R:                  " U5      U l        [?        U R<                  U5      U l         U R<                  S:  a  [B        RD                  U l#        O[B        RH                  U l#        S U l%        S U l&        [O        5       U l(        URS                  5       (       a  [U        5       U l+        g S U l+        g )NFr   )ÚloopÚmax_sizeÚ	on_removeÚmax_lifetime)é   r   ),r&   r'   r(   r)   r*   r+   r8   r6   r7   Ú_StatementCacheÚstatement_cache_sizeÚ	functoolsÚpartialÚ_weak_maybe_gc_stmtÚweakrefÚrefÚmax_cached_statement_lifetimer,   Úsetr-   r.   r/   r9   r;   r:   r=   Úget_settingsÚserver_versionr   Úsplit_server_version_stringr0   Ú_detect_server_capabilitiesr1   r   ÚINTRO_LOOKUP_TYPES_13r2   ÚINTRO_LOOKUP_TYPESr3   r4   Ú_Atomicr5   Ú	get_debugÚ_extract_stackr<   )	Úselfr
   Ú	transportrB   Úaddrr?   r@   ÚsettingsÚ
ver_strings	            r   Ú__init__ÚConnection.__init__;   sz  € ð "ŒØ#ŒØŒ
ØˆŒØˆŒð "#ˆÔàŒ
ØŒØŒä*ØØ×0Ñ0Ü×'Ò'Ü#¤W§[¢[°Ó%6ó8à×=Ñ=ñ?ˆÔô  #›uˆÔØ#)×#>Ñ#>ÀÑ#BˆÔ àˆŒÜ!›eˆÔÜ!›eˆÔÜ&)£eˆÔ#Ü!›eˆÔà—>‘>×.Ñ.Ó0ˆØ×,Ñ,ˆ
ä×5Ò5°jÓAð 	Ôô 8Ø× Ñ  (ó,ˆÔð ×Ñ 'Ó)Ü -× CÑ CˆDÕä -× @Ñ @ˆDÔà ˆÔØˆŒô (/£yˆÔ$à�>‰>×ÑÜ%3Ó%5ˆDÕ"à%)ˆDÕ"r   c                 ó^  • U R                  5       (       d˜  U R                  bŠ  U R                  (       a  SR                  X R                  5      nOSR                  U 5      n[        R
                  " U[        5        U R                  R                  5       (       d  U R                  5         g g g g )Nz)unclosed connection {!r}; created at:
 {}z^unclosed connection {!r}; run in asyncio debug mode to show the traceback of connection origin)	Ú	is_closedr&   r<   ÚformatÚwarningsÚwarnÚResourceWarningr(   Ú	terminate)rY   Úmsgs     r   Ú__del__ÚConnection.__del__{   s‡   € Ø�~‰~×Ñ D§N¡NÑ$>Ø×%×%ØB×IÑIØ×0Ñ0ó2‘ðç#™V D›\ð ô �MŠM˜#œÔ/Ø—:‘:×'Ñ'×)Ñ)Ø—‘Õ ð *ð %?Ðr   c              ƒ   óV  #   • U R                  5         XR                  ;  aS  U R                  SR                  [        R
                  " U5      5      5      I Sh  v•N   [        5       U R                  U'   U R                  U   R                  [        R                  U5      5        g NM7f)aý  Add a listener for Postgres notifications.

:param str channel: Channel to listen on.

:param callable callback:
    A callable or a coroutine function receiving the following
    arguments:
    **connection**: a Connection the callback is registered with;
    **pid**: PID of the Postgres server that sent the notification;
    **channel**: name of the channel the notification was sent to;
    **payload**: the payload.

.. versionchanged:: 0.24.0
    The ``callback`` argument may be a coroutine function.
z	LISTEN {}N)
Ú_check_openr/   Úfetchrb   r   Ú_quote_identrO   ÚaddÚ	_CallbackÚfrom_callable)rY   ÚchannelÚcallbacks      r   Úadd_listenerÚConnection.add_listener‹   s}   é € ð  	×ÑÔØŸ/™/Ó)Ø—*‘*˜[×/Ñ/´×0BÒ0BÀ7Ó0KÓLÓM×MÐMÜ'*£uˆD�O‰O˜GÑ$Ø�‰˜Ñ ×$Ñ$¤Y×%<Ñ%<¸XÓ%FÕGñ Nùs   ‚AB)ÁB'ÁAB)c              ƒ   ó¤  #   • U R                  5       (       a  gXR                  ;  a  g[        R                  U5      nX0R                  U   ;  a  gU R                  U   R	                  U5        U R                  U   (       dJ  U R                  U	 U R                  SR                  [        R                  " U5      5      5      I Sh  v•N   gg N7f)z5Remove a listening callback on the specified channel.NzUNLISTEN {})	ra   r/   ro   rp   Úremoverl   rb   r   rm   )rY   rq   rr   Úcbs       r   Úremove_listenerÚConnection.remove_listener¡   s£   é € à�>‰>×ÑØØŸ/™/Ó)ØÜ×$Ñ$ XÓ.ˆØ—_‘_ WÑ-Ó-ØØ�‰˜Ñ ×'Ñ'¨Ô+Ø�‰˜w×'Ø—‘ Ð(Ø—*‘*˜]×1Ñ1´%×2DÒ2DÀWÓ2MÓNÓO×OÑOð (áOùs   ‚CCÃCÃCc                 ó¶   • U R                  5       (       a  [        R                  " S5      eU R                  R	                  [
        R                  U5      5        g)a  Add a listener for Postgres log messages.

It will be called when asyncronous NoticeResponse is received
from the connection.  Possible message types are: WARNING, NOTICE,
DEBUG, INFO, or LOG.

:param callable callback:
    A callable or a coroutine function receiving the following
    arguments:
    **connection**: a Connection the callback is registered with;
    **message**: the `exceptions.PostgresLogMessage` message.

.. versionadded:: 0.12.0

.. versionchanged:: 0.24.0
    The ``callback`` argument may be a coroutine function.
úconnection is closedN)ra   r   ÚInterfaceErrorr9   rn   ro   rp   ©rY   rr   s     r   Úadd_log_listenerÚConnection.add_log_listener¯   sB   € ð$ �>‰>×ÑÜ×+Ò+Ð,BÓCÐCØ×Ñ×Ñ¤	× 7Ñ 7¸Ó AÕBr   c                 ó`   • U R                   R                  [        R                  U5      5        g)zHRemove a listening callback for log messages.

.. versionadded:: 0.12.0
N)r9   Údiscardro   rp   r}   s     r   Úremove_log_listenerÚConnection.remove_log_listenerÅ   s#   € ð
 	×Ñ×#Ñ#¤I×$;Ñ$;¸HÓ$EÕFr   c                 ó`   • U R                   R                  [        R                  U5      5        g)aO  Add a listener that will be called when the connection is closed.

:param callable callback:
    A callable or a coroutine function receiving one argument:
    **connection**: a Connection the callback is registered with.

.. versionadded:: 0.21.0

.. versionchanged:: 0.24.0
    The ``callback`` argument may be a coroutine function.
N)r:   rn   ro   rp   r}   s     r   Úadd_termination_listenerÚ#Connection.add_termination_listenerÌ   s#   € ð 	×#Ñ#×'Ñ'¬	×(?Ñ(?ÀÓ(IÕJr   c                 ó`   • U R                   R                  [        R                  U5      5        g)zØRemove a listening callback for connection termination.

:param callable callback:
    The callable or coroutine function that was passed to
    :meth:`Connection.add_termination_listener`.

.. versionadded:: 0.21.0
N)r:   r�   ro   rp   r}   s     r   Úremove_termination_listenerÚ&Connection.remove_termination_listenerÚ   s#   € ð 	×#Ñ#×+Ñ+¬I×,CÑ,CÀHÓ,MÕNr   c                 ó`   • U R                   R                  [        R                  U5      5        g)a1  Add a logger that will be called when queries are executed.

:param callable callback:
    A callable or a coroutine function receiving one argument:
    **record**, a LoggedQuery containing `query`, `args`, `timeout`,
    `elapsed`, `exception`, `conn_addr`, and `conn_params`.

.. versionadded:: 0.29.0
N)r=   rn   ro   rp   r}   s     r   Úadd_query_loggerÚConnection.add_query_loggerå   s#   € ð 	×Ñ×Ñ¤	× 7Ñ 7¸Ó AÕBr   c                 ó`   • U R                   R                  [        R                  U5      5        g)z¸Remove a query logger callback.

:param callable callback:
    The callable or coroutine function that was passed to
    :meth:`Connection.add_query_logger`.

.. versionadded:: 0.29.0
N)r=   r�   ro   rp   r}   s     r   Úremove_query_loggerÚConnection.remove_query_loggerñ   s#   € ð 	×Ñ×#Ñ#¤I×$;Ñ$;¸HÓ$EÕFr   c                 ó6   • U R                   R                  5       $ )zAReturn the PID of the Postgres server the connection is bound to.)r&   Úget_server_pid©rY   s    r   r‘   ÚConnection.get_server_pidü   s   € à�~‰~×,Ñ,Ó.Ð.r   c                 ó   • U R                   $ )a6  Return the version of the connected PostgreSQL server.

The returned value is a named tuple similar to that in
``sys.version_info``:

.. code-block:: pycon

    >>> con.get_server_version()
    ServerVersion(major=9, minor=6, micro=1,
                  releaselevel='final', serial=0)

.. versionadded:: 0.8.0
)r0   r’   s    r   Úget_server_versionÚConnection.get_server_version   s   € ð ×#Ñ#Ð#r   c                 ó6   • U R                   R                  5       $ )zLReturn connection settings.

:return: :class:`~asyncpg.ConnectionSettings`.
)r&   rP   r’   s    r   rP   ÚConnection.get_settings  s   € ð
 �~‰~×*Ñ*Ó,Ð,r   NF)Ú	isolationÚreadonlyÚ
deferrablec                óP   • U R                  5         [        R                  " XX#5      $ )aô  Create a :class:`~transaction.Transaction` object.

Refer to `PostgreSQL documentation`_ on the meaning of transaction
parameters.

:param isolation: Transaction isolation mode, can be one of:
                  `'serializable'`, `'repeatable_read'`,
                  `'read_uncommitted'`, `'read_committed'`. If not
                  specified, the behavior is up to the server and
                  session, which is usually ``read_committed``.

:param readonly: Specifies whether or not this transaction is
                 read-only.

:param deferrable: Specifies whether or not this transaction is
                   deferrable.

.. _`PostgreSQL documentation`:
        https://www.postgresql.org/docs/
        current/static/sql-set-transaction.html
)rk   r   ÚTransaction)rY   r™   rš   r›   s       r   r   ÚConnection.transaction  s#   € ð. 	×ÑÔÜ×&Ò& t¸ÓMÐMr   c                 ó6   • U R                   R                  5       $ )z“Return True if Connection is currently inside a transaction.

:return bool: True if inside transaction, False otherwise.

.. versionadded:: 0.16.0
)r&   Úis_in_transactionr’   s    r   r    ÚConnection.is_in_transaction1  s   € ð �~‰~×/Ñ/Ó1Ð1r   )ÚtimeoutÚqueryr¢   Úreturnc             ‡   ó°  #   • U R                  5         U(       dv  U R                  (       a@  U R                  XU5         U R                  R	                  X5      I Sh  v•N nSSS5        U$ U R                  R	                  X5      I Sh  v•N nU$ U R                  UUSUSS9I Sh  v•N u  pVnUR                  5       $  Na! , (       d  f       W$ = f NH N-7f)a€  Execute an SQL command (or commands).

This method can execute many SQL commands at once, when no arguments
are provided.

Example:

.. code-block:: pycon

    >>> await con.execute('''
    ...     CREATE TABLE mytab (a int);
    ...     INSERT INTO mytab (a) VALUES (100), (200), (300);
    ... ''')
    INSERT 0 3

    >>> await con.execute('''
    ...     INSERT INTO mytab (a) VALUES ($1), ($2)
    ... ''', 10, 20)
    INSERT 0 2

:param args: Query arguments.
:param float timeout: Optional timeout value in seconds.
:return str: Status of the last SQL command.

.. versionchanged:: 0.5.4
   Made it possible to pass query arguments.
Nr   T)Úreturn_status)rk   r=   Ú_time_and_logr&   r£   Ú_executeÚdecode)rY   r£   r¢   ÚargsÚresultÚ_Ústatuss          r   ÚexecuteÚConnection.execute:  sË   é € ðB 	×ÑÔæØ×"×"Ø×'Ñ'¨°WÕ=Ø#'§>¡>×#7Ñ#7¸Ó#G×G�F÷ >ð ˆMð  $Ÿ~™~×3Ñ3°EÓC×C�ØˆMà!Ÿ]™]ØØØØØð +ð 
÷ 
‰ˆ�1ð �}‰}‹Ðñ H÷ >Ô=ð ˆMúñ Dñ
ùsL   ‚;C½C ÁB>ÁC Á!(CÂ	CÂ
CÂ&CÂ'CÂ>C Ã 
CÃ
	CÃCÚcommandc             ƒ   ób   #   • U R                  5         U R                  XU5      I Sh  v•N $  N7f)a|  Execute an SQL *command* for each sequence of arguments in *args*.

Example:

.. code-block:: pycon

    >>> await con.executemany('''
    ...     INSERT INTO mytab (a) VALUES ($1, $2, $3);
    ... ''', [(1, 2, 3), (4, 5, 6)])

:param command: Command to execute.
:param args: An iterable containing sequences of arguments.
:param float timeout: Optional timeout value in seconds.
:return None: This method discards the results of the operations.

.. versionadded:: 0.7.0

.. versionchanged:: 0.11.0
   `timeout` became a keyword-only parameter.

.. versionchanged:: 0.22.0
   ``executemany()`` is now an atomic operation, which means that
   either all executions succeed, or none at all.  This is in contrast
   to prior versions, where the effect of already-processed iterations
   would remain in place when an error has occurred, unless
   ``executemany()`` was called in a transaction.
N©rk   Ú_executemany)rY   r°   rª   r¢   s       r   ÚexecutemanyÚConnection.executemanyn  s-   é € ðD 	×ÑÔØ×&Ñ& w°gÓ>×>Ð>Ñ>ùó   ‚&/¨-©/T)ÚnamedÚ	use_cacheÚignore_custom_codecÚrecord_classr·   c             ƒ   ó  #   • Uc  U R                   R                  5       nO[        U5        U(       ay  U R                  R	                  XU45      nUb  U$ U R
                  =(       aD    U R                  R                  (       + =(       d"    [        U5      U R                  R                  :*  n[        U[        5      (       a  UnO"U(       d  U(       a  U R                  S5      nOSnU R                   R                  UUUUUS9I S h  v•N nSn	UR                  5       n
SnU
(       a¸  U R                   R                  5       nU R                  X¢5      I S h  v•N u  pÞUR!                  U5        UR"                  (       + =(       a    UR"                  (       + n	UR                  5       n
US-  nUS:”  a%  [$        R&                  " SR)                  U5      5      eU
(       a  M¸  UR+                  5         U	(       d"  UR"                  (       d!  U R
                  (       d  UR-                  5         U(       a  U R                  R/                  XU4U5        U R0                  (       a  U R3                  5       I S h  v•N   U$  GNq GN& N7f)	NÚstmtÚ ©rº   r¹   Fr   r   é   zCcould not resolve query result and/or argument types in {} attempts)r&   Úget_record_classÚ_check_record_classr,   Úgetr.   r6   Úmax_cacheable_statement_sizeÚlenÚ
isinstanceÚstrÚ_get_unique_idÚprepareÚ_init_typesrP   Ú_introspect_typesÚregister_data_typesÚnamer   ÚInternalClientErrorrb   Ú_init_codecsÚmark_unpreparedÚputr-   Ú_cleanup_stmts)rY   r£   r¢   r·   r¸   r¹   rº   Ú	statementÚ	stmt_nameÚneed_reprepareÚtypes_with_missing_codecsÚtriesr\   ÚtypesÚ
intro_stmts                  r   Ú_get_statementÚConnection._get_statement“  s;  é € ð ÑØŸ>™>×:Ñ:Ó<‰Lä Ô-æØ×(Ñ(×,Ñ,ØÐ&9Ð:óˆIð Ñ$Ø Ð ð ×(Ñ(÷ àŸ™×AÑAÔA÷ OÜ˜5“z T§\¡\×%NÑ%NÑNð	 ô �eœS×!Ñ!Ø‰IÞž%Ø×+Ñ+¨FÓ3‰IàˆIàŸ.™.×0Ñ0ØØØØ%Ø 3ð 1ð 
÷ 
ˆ	ð ˆØ$-×$9Ñ$9Ó$;Ð!ØˆÞ'Ø—~‘~×2Ñ2Ó4ˆHð '+×&<Ñ&<Ø)ó'4÷ !4ÑˆEð ×(Ñ(¨Ô/ð
 ",§¡Ô0×G¸¿¹Ô5GˆNØ(1×(=Ñ(=Ó(?Ð%Ø�Q‰JˆEØ�q‹yô
 !×4Ò4ð%ß%+¡V¨E£]óð ÷+ (Ð'ð8 	×ÑÔ ö Ø—N—N¨4×+C×+Cð ×%Ñ%Ô'æØ×Ñ× Ñ ØÐ&9Ð:¸IôGð
 ××Ø×%Ñ%Ó'×'Ð'àÐòy
ò!4ñV (ùs?   ‚DI?ÄI7ÄAI?ÅI:ÅBI?ÇBI?É0I=É1I?É:I?É=I?c              ƒ   ó|  #   • U R                   R                  (       a'   U R                  SSSUSS9I S h  v•N u  p4US   S   nOSnU R                  U R
                  [        U5      4SUSS9I S h  v•N nUS:w  a  U R                  SU4SUSS9I S h  v•N   U$  Nd! [        R                   a    Sn Nmf = f NF N&7f)	Nz¦
                    SELECT
                        current_setting('jit') AS cur,
                        set_config('jit', 'off', false) AS new
                    r   r   T)r¹   ÚcurÚoffzY
                SELECT
                    set_config('jit', $1, false)
                )r1   ÚjitÚ_Connection__executer   ÚUndefinedObjectErrorr2   Úlist)rY   Útypeoidsr¢   Úcfgrowr¬   Ú	jit_stater«   s          r   rÊ   ÚConnection._introspect_typesù  sþ   é € Ø×Ñ× × ð"Ø"&§.¡.ðð
 ØØØ(,ð #1ð 
#÷ 
‘	�ð # 1™I eÑ,‘	ð ˆIà—~‘~Ø×ÑÜ�(‹^ÐØØØ $ð &ð 
÷ 
ˆð ˜ÓØ—.‘.ðð �ØØØ$(ð !ð 	÷ 	ð 	ð ˆñK
øô ×2Ñ2ó "Ø!’	ð"úñ

ñ	ùsV   ‚B<ŸB µB¶B Á-B<Á1B8Á2!B<ÂB:ÂB<ÂB ÂB5Â2B<Â4B5Â5B<Â:B<c              ƒ   óx  #   • US:X  a_  UR                  S5      (       dI  [        R                  R                  UR	                  5       5      nUb  [
        R                  " US S45      $ U R                  [
        R                  X/SS SS9I S h  v•N nU(       d  [        SR                  X!5      5      eUS   $  N*7f)	NÚ
pg_catalogz[]ó   br   T)Úlimitr¢   r¹   zunknown type: {}.{}r   )Úendswithr
   ÚBUILTIN_TYPE_NAME_MAPrÂ   Úlowerr   Ú
TypeRecordr¨   ÚTYPE_BY_NAMEÚ
ValueErrorrb   )rY   ÚtypenameÚschemaÚtypeoidÚrowss        r   Ú_introspect_typeÚConnection._introspect_type#  sº   é € Ø�\Ó!¨(×*;Ñ*;¸D×*AÑ*AÜ×4Ñ4×8Ñ8¸¿¹Ó9IÓJˆGØÑ"Ü$×/Ò/°¸$ÀÐ0EÓFÐFà—]‘]Ü×&Ñ&ØÐØØØ $ð #ð 
÷ 
ˆö ÜØ%×,Ñ,¨VÓ>ó@ð @ð �A‰wˆñ
ùs   ‚BB:ÂB8Â+B:)Úprefetchr¢   rº   c          	      óZ   • U R                  5         [        R                  " U USUUUU5      $ )aH  Return a *cursor factory* for the specified query.

:param args:
    Query arguments.
:param int prefetch:
    The number of rows the *cursor iterator*
    will prefetch (defaults to ``50``.)
:param float timeout:
    Optional timeout in seconds.
:param type record_class:
    If specified, the class to use for records returned by this cursor.
    Must be a subclass of :class:`~asyncpg.Record`.  If not specified,
    a per-connection *record_class* is used.

:return:
    A :class:`~cursor.CursorFactory` object.

.. versionchanged:: 0.22.0
    Added the *record_class* parameter.
N)rk   r   ÚCursorFactory)rY   r£   rö   r¢   rº   rª   s         r   r   ÚConnection.cursor7  s8   € ð8 	×ÑÔÜ×#Ò#ØØØØØØØó
ð 	
r   ©rÌ   r¢   rº   c             ƒ   óB   #   • U R                  UUUUS9I Sh  v•N $  N7f)aå  Create a *prepared statement* for the specified query.

:param str query:
    Text of the query to create a prepared statement for.
:param str name:
    Optional name of the returned prepared statement.  If not
    specified, the name is auto-generated.
:param float timeout:
    Optional timeout value in seconds.
:param type record_class:
    If specified, the class to use for records returned by the
    prepared statement.  Must be a subclass of
    :class:`~asyncpg.Record`.  If not specified, a per-connection
    *record_class* is used.

:return:
    A :class:`~prepared_stmt.PreparedStatement` instance.

.. versionchanged:: 0.22.0
    Added the *record_class* parameter.

.. versionchanged:: 0.25.0
    Added the *name* parameter.
rú   N)Ú_prepare)rY   r£   rÌ   r¢   rº   s        r   rÈ   ÚConnection.prepare^  s4   é € ð@ —]‘]ØØØØ%ð	 #ð 
÷ 
ð 	
ñ 
ùs   ‚˜™)rÌ   r¢   r¸   rº   rÌ   r¸   c             ƒ   ó°   #   • U R                  5         Uc  U R                  nU R                  UUUUUS9I S h  v•N n[        R                  " XU5      $  N7f)N)r·   r¸   rº   )rk   r.   rÙ   r	   ÚPreparedStatement)rY   r£   rÌ   r¢   r¸   rº   r¼   s          r   rü   ÚConnection._prepare…  sf   é € ð 	×ÑÔØ‰<Ø×+Ñ+ˆDØ×(Ñ(ØØØØØ%ð )ð 
÷ 
ˆô ×.Ò.¨t¸DÓAÐAñ
ùs   ‚6A¸A¹A)r¢   rº   c             ‡   ód   #   • U R                  5         U R                  UUSUUS9I Sh  v•N $  N7f)ak  Run a query and return the results as a list of :class:`Record`.

:param str query:
    Query text.
:param args:
    Query arguments.
:param float timeout:
    Optional timeout value in seconds.
:param type record_class:
    If specified, the class to use for records returned by this method.
    Must be a subclass of :class:`~asyncpg.Record`.  If not specified,
    a per-connection *record_class* is used.

:return list:
    A list of :class:`~asyncpg.Record` instances.  If specified, the
    actual type of list elements would be *record_class*.

.. versionchanged:: 0.22.0
    Added the *record_class* parameter.
r   ©rº   N©rk   r¨   )rY   r£   r¢   rº   rª   s        r   rl   ÚConnection.fetchš  sB   é € ð6 	×ÑÔØ—]‘]ØØØØØ%ð #ð 
÷ 
ð 	
ñ 
ùs   ‚'0©.ª0r   )Úcolumnr¢   c             ‡   ó„   #   • U R                  5         U R                  XSU5      I Sh  v•N nU(       d  gUS   U   $  N7f)aA  Run a query and return a value in the first row.

:param str query: Query text.
:param args: Query arguments.
:param int column: Numeric index within the record of the value to
                   return (defaults to 0).
:param float timeout: Optional timeout value in seconds.
                    If not specified, defaults to the value of
                    ``command_timeout`` argument to the ``Connection``
                    instance constructor.

:return: The value of the specified column of the first record, or
         None if no records were returned by the query.
r   Nr   r  )rY   r£   r  r¢   rª   Údatas         r   ÚfetchvalÚConnection.fetchval¾  sA   é € ð 	×ÑÔØ—]‘] 5°°7Ó;×;ˆÞØØ�A‰w�v‰Ðñ <ùs   ‚'A ©>ªA c             ‡   ó~   #   • U R                  5         U R                  UUSUUS9I Sh  v•N nU(       d  gUS   $  N7f)aˆ  Run a query and return the first row.

:param str query:
    Query text
:param args:
    Query arguments
:param float timeout:
    Optional timeout value in seconds.
:param type record_class:
    If specified, the class to use for the value returned by this
    method.  Must be a subclass of :class:`~asyncpg.Record`.
    If not specified, a per-connection *record_class* is used.

:return:
    The first row as a :class:`~asyncpg.Record` instance, or None if
    no records were returned by the query.  If specified,
    *record_class* is used as the type for the result value.

.. versionchanged:: 0.22.0
    Added the *record_class* parameter.
r   r  Nr   r  )rY   r£   r¢   rº   rª   r  s         r   ÚfetchrowÚConnection.fetchrowÓ  sP   é € ð8 	×ÑÔØ—]‘]ØØØØØ%ð #ð 
÷ 
ˆö ØØ�A‰wˆñ
ùs   ‚'=©;ª=c             ƒ   ób   #   • U R                  5         U R                  XUSUS9I Sh  v•N $  N7f)a©  Run a query for each sequence of arguments in *args*
and return the results as a list of :class:`Record`.

:param query:
    Query to execute.
:param args:
    An iterable containing sequences of arguments for the query.
:param float timeout:
    Optional timeout value in seconds.
:param type record_class:
    If specified, the class to use for records returned by this method.
    Must be a subclass of :class:`~asyncpg.Record`.  If not specified,
    a per-connection *record_class* is used.

:return list:
    A list of :class:`~asyncpg.Record` instances.  If specified, the
    actual type of list elements would be *record_class*.

Example:

.. code-block:: pycon

    >>> rows = await con.fetchmany('''
    ...         INSERT INTO mytab (a, b) VALUES ($1, $2) RETURNING a;
    ...     ''', [('x', 1), ('y', 2), ('z', 3)])
    >>> rows
    [<Record row=('x',)>, <Record row=('y',)>, <Record row=('z',)>]

.. versionadded:: 0.30.0
T)Úreturn_rowsrº   Nr²   )rY   r£   rª   r¢   rº   s        r   Ú	fetchmanyÚConnection.fetchmanyû  s?   é € ðL 	×ÑÔØ×&Ñ&Ø˜¨dÀð 'ð 
÷ 
ð 	
ñ 
ùr¶   )ÚcolumnsÚschema_namer¢   rb   ÚoidsÚ	delimiterÚnullÚheaderÚquoteÚescapeÚforce_quoteÚencodingc             ƒ   ó^  #   • [         R                  " U5      nU(       a  [         R                  " U5      S-   U-   nU(       a(  SR                  SR                  S U 5       5      5      nOSnU R	                  XgUXšX¼XÞS9	nSR                  UUUS9nU R                  UX%5      I S	h  v•N $  N7f)
aé  Copy table contents to a file or file-like object.

:param str table_name:
    The name of the table to copy data from.

:param output:
    A :term:`path-like object <python:path-like object>`,
    or a :term:`file-like object <python:file-like object>`, or
    a :term:`coroutine function <python:coroutine function>`
    that takes a ``bytes`` instance as a sole argument.

:param list columns:
    An optional list of column names to copy.

:param str schema_name:
    An optional schema name to qualify the table.

:param float timeout:
    Optional timeout value in seconds.

The remaining keyword arguments are ``COPY`` statement options,
see `COPY statement documentation`_ for details.

:return: The status string of the COPY command.

Example:

.. code-block:: pycon

    >>> import asyncpg
    >>> import asyncio
    >>> async def run():
    ...     con = await asyncpg.connect(user='postgres')
    ...     result = await con.copy_from_table(
    ...         'mytable', columns=('foo', 'bar'),
    ...         output='file.csv', format='csv')
    ...     print(result)
    ...
    >>> asyncio.run(run())
    'COPY 100'

.. _`COPY statement documentation`:
    https://www.postgresql.org/docs/current/static/sql-copy.html

.. versionadded:: 0.11.0
Ú.ú({})ú, c              3   óL   #   • U H  n[         R                  " U5      v •  M     g 7fr   ©r   rm   ©Ú.0Úcs     r   Ú	<genexpr>Ú-Connection.copy_from_table.<locals>.<genexpr>_  ó   é € ÐA¹°Aœ%×,Ò,¨Q×/Ð/ºùó   ‚"$r½   ©	rb   r  r  r  r  r  r  r  r  z!COPY {tab}{cols} TO STDOUT {opts})ÚtabÚcolsÚoptsN)r   rm   rb   ÚjoinÚ_format_copy_optsÚ	_copy_out)rY   Ú
table_nameÚoutputr  r  r¢   rb   r  r  r  r  r  r  r  r  Útabnamer*  r+  Ú	copy_stmts                      r   Úcopy_from_tableÚConnection.copy_from_table&  s¹   é € ôf ×$Ò$ ZÓ0ˆÞÜ×(Ò(¨Ó5¸Ñ;¸gÑEˆGæØ—=‘=Ø—	‘	ÑA¹ÓAÓAóC‰Dð ˆDà×%Ñ%Ø°	Ø¨EØ#ð &ð 
ˆð 8×>Ñ>Ø˜d¨ð ?ð /ˆ	ð —^‘^ I¨vÓ?×?Ð?Ñ?ùs   ‚B$B-Â&B+Â'B-)
r¢   rb   r  r  r  r  r  r  r  r  c             ‡   óÖ   #   • U R                  XEUXxXšX¼S9	nU(       a  [        R                  " XU5      I Sh  v•N nSR                  XS9nU R	                  XòU5      I Sh  v•N $  N- N7f)aˆ  Copy the results of a query to a file or file-like object.

:param str query:
    The query to copy the results of.

:param args:
    Query arguments.

:param output:
    A :term:`path-like object <python:path-like object>`,
    or a :term:`file-like object <python:file-like object>`, or
    a :term:`coroutine function <python:coroutine function>`
    that takes a ``bytes`` instance as a sole argument.

:param float timeout:
    Optional timeout value in seconds.

The remaining keyword arguments are ``COPY`` statement options,
see `COPY statement documentation`_ for details.

:return: The status string of the COPY command.

Example:

.. code-block:: pycon

    >>> import asyncpg
    >>> import asyncio
    >>> async def run():
    ...     con = await asyncpg.connect(user='postgres')
    ...     result = await con.copy_from_query(
    ...         'SELECT foo, bar FROM mytable WHERE foo > $1', 10,
    ...         output='file.csv', format='csv')
    ...     print(result)
    ...
    >>> asyncio.run(run())
    'COPY 10'

.. _`COPY statement documentation`:
    https://www.postgresql.org/docs/current/static/sql-copy.html

.. versionadded:: 0.11.0
r(  NzCOPY ({query}) TO STDOUT {opts})r£   r+  )r-  r   Ú_mogrifyrb   r.  )rY   r£   r0  r¢   rb   r  r  r  r  r  r  r  r  rª   r+  r2  s                   r   Úcopy_from_queryÚConnection.copy_from_queryn  s{   é € ð` ×%Ñ%Ø°	Ø¨EØ#ð &ð 
ˆö ÜŸ.š.¨°dÓ;×;ˆEà5×<Ñ<Øð =ð $ˆ	ð —^‘^ I°wÓ?×?Ð?ñ <ñ
 @ùs!   ‚5A)·A%¸(A)Á A'Á!A)Á'A))r  r  r¢   rb   r  Úfreezer  r  r  r  r  r  Úforce_not_nullÚ
force_nullr  Úwherec             ƒ   ó†  #   • [         R                  " U5      nU(       a  [         R                  " U5      S-   U-   nU(       a(  SR                  SR                  S U 5       5      5      nOSnU R	                  U5      nU R                  XgX‰X«XÍUUUS9nSR                  UUUUS9nU R                  UX%5      I S	h  v•N $  N7f)
a  Copy data to the specified table.

:param str table_name:
    The name of the table to copy data to.

:param source:
    A :term:`path-like object <python:path-like object>`,
    or a :term:`file-like object <python:file-like object>`, or
    an :term:`asynchronous iterable <python:asynchronous iterable>`
    that returns ``bytes``, or an object supporting the
    :ref:`buffer protocol <python:bufferobjects>`.

:param list columns:
    An optional list of column names to copy.

:param str schema_name:
    An optional schema name to qualify the table.

:param str where:
    An optional SQL expression used to filter rows when copying.

    .. note::

        Usage of this parameter requires support for the
        ``COPY FROM ... WHERE`` syntax, introduced in
        PostgreSQL version 12.

:param float timeout:
    Optional timeout value in seconds.

The remaining keyword arguments are ``COPY`` statement options,
see `COPY statement documentation`_ for details.

:return: The status string of the COPY command.

Example:

.. code-block:: pycon

    >>> import asyncpg
    >>> import asyncio
    >>> async def run():
    ...     con = await asyncpg.connect(user='postgres')
    ...     result = await con.copy_to_table(
    ...         'mytable', source='datafile.tbl')
    ...     print(result)
    ...
    >>> asyncio.run(run())
    'COPY 140000'

.. _`COPY statement documentation`:
    https://www.postgresql.org/docs/current/static/sql-copy.html

.. versionadded:: 0.11.0

.. versionadded:: 0.29.0
    Added the *where* parameter.
r  r  r  c              3   óL   #   • U H  n[         R                  " U5      v •  M     g 7fr   r   r!  s     r   r$  Ú+Connection.copy_to_table.<locals>.<genexpr>ó  r&  r'  r½   )rb   r  r9  r  r  r  r  r  r:  r;  r  ú)COPY {tab}{cols} FROM STDIN {opts} {cond}©r)  r*  r+  ÚcondN)r   rm   rb   r,  Ú_format_copy_wherer-  Ú_copy_in)rY   r/  Úsourcer  r  r¢   rb   r  r9  r  r  r  r  r  r  r:  r;  r  r<  r1  r*  rB  r+  r2  s                           r   Úcopy_to_tableÚConnection.copy_to_table¬  sÒ   é € ôB ×$Ò$ ZÓ0ˆÞÜ×(Ò(¨Ó5¸Ñ;¸gÑEˆGæØ—=‘=Ø—	‘	ÑA¹ÓAÓAóC‰Dð ˆDà×&Ñ& uÓ-ˆØ×%Ñ%Ø¨VØ¨EØ)°jØð	 &ð 
ˆð @×FÑFØ˜d¨°Dð Gð :ˆ	ð —]‘] 9¨fÓ>×>Ð>Ñ>ùs   ‚B8CÂ:B?Â;C)r  r  r¢   r<  c             ƒ   óæ  #   • [         R                  " U5      nU(       a  [         R                  " U5      S-   U-   nU(       a*  SR                  S U 5       5      nSR                  U5      n	OSnSn	SR                  XxS9n
U R	                  U
5      I S	h  v•N nU R                  U5      nS
nSR                  XyXÜS9nU R                  R                  US	S	X+R                  U5      I S	h  v•N $  NX N7f)aQ  Copy a list of records to the specified table using binary COPY.

:param str table_name:
    The name of the table to copy data to.

:param records:
    An iterable returning row tuples to copy into the table.
    :term:`Asynchronous iterables <python:asynchronous iterable>`
    are also supported.

:param list columns:
    An optional list of column names to copy.

:param str schema_name:
    An optional schema name to qualify the table.

:param str where:
    An optional SQL expression used to filter rows when copying.

    .. note::

        Usage of this parameter requires support for the
        ``COPY FROM ... WHERE`` syntax, introduced in
        PostgreSQL version 12.


:param float timeout:
    Optional timeout value in seconds.

:return: The status string of the COPY command.

Example:

.. code-block:: pycon

    >>> import asyncpg
    >>> import asyncio
    >>> async def run():
    ...     con = await asyncpg.connect(user='postgres')
    ...     result = await con.copy_records_to_table(
    ...         'mytable', records=[
    ...             (1, 'foo', 'bar'),
    ...             (2, 'ham', 'spam')])
    ...     print(result)
    ...
    >>> asyncio.run(run())
    'COPY 2'

Asynchronous record iterables are also supported:

.. code-block:: pycon

    >>> import asyncpg
    >>> import asyncio
    >>> async def run():
    ...     con = await asyncpg.connect(user='postgres')
    ...     async def record_gen(size):
    ...         for i in range(size):
    ...             yield (i,)
    ...     result = await con.copy_records_to_table(
    ...         'mytable', records=record_gen(100))
    ...     print(result)
    ...
    >>> asyncio.run(run())
    'COPY 100'

.. versionadded:: 0.11.0

.. versionchanged:: 0.24.0
    The ``records`` argument may be an asynchronous iterable.

.. versionadded:: 0.29.0
    Added the *where* parameter.
r  r  c              3   óL   #   • U H  n[         R                  " U5      v •  M     g 7fr   r   r!  s     r   r$  Ú3Connection.copy_records_to_table.<locals>.<genexpr>V  s   é € Ð HÁ¸1¤×!3Ò!3°A×!6Ð!6Âùr'  r  Ú*r½   z SELECT {cols} FROM {tab} LIMIT 1)r)  r*  Nz(FORMAT binary)r@  rA  )	r   rm   r,  rb   rÈ   rC  r&   Úcopy_inÚ_state)rY   r/  Úrecordsr  r  r¢   r<  r1  Úcol_listr*  Úintro_queryÚintro_psrB  r+  r2  s                  r   Úcopy_records_to_tableÚ Connection.copy_records_to_table  sû   é € ôZ ×$Ò$ ZÓ0ˆÞÜ×(Ò(¨Ó5¸Ñ;¸gÑEˆGæØ—y‘yÑ HÁÓ HÓHˆHØ—=‘= Ó*‰DàˆHØˆDà8×?Ñ?Øð @ð (ˆð Ÿ™ kÓ2×2ˆà×&Ñ& uÓ-ˆØ ˆà?×FÑFØ¨ð Gð :ˆ	ð —^‘^×+Ñ+Ø�t˜T 7¯O©O¸WóF÷ Fð 	Fñ 3ñFùs%   ‚BC1ÂC-ÂAC1Ã(C/Ã)C1Ã/C1c                 ó–   • U(       a1  U R                   R                  (       d  [        R                  " S5      eU(       a  SU-   nU$ SnU$ )Nz5the `where` parameter requires PostgreSQL 12 or laterzWHERE r½   )r1   Úsql_copy_from_wherer   ÚUnsupportedServerFeatureError)rY   r<  Úwhere_clauses      r   rC  ÚConnection._format_copy_wherej  sO   € Þ˜×*Ñ*×>×>Ü×:Ò:ØGóIð Iö Ø# eÑ+ˆLð Ðð ˆLàÐr   )rb   r  r9  r  r  r  r  r  r  r:  r;  r  c                óD  • [        [        5       5      nUR                  S5        / nU	b>  [        U	[        5      (       a)  UR                  S5        U	(       a  UR                  S5        UR                  5        H‡  u  nnUc  M  US;   a  SSR                  S U 5       5      -   S-   nO(US	;   a  [        U5      nO[        R                  " U5      nUR                  S
R                  UR                  5       U5      5        M‰     U(       a  SSR                  U5      -   S-   $ g)NrY   r  zFORCE_QUOTE *)r:  r;  r  Ú(r  c              3   óL   #   • U H  n[         R                  " U5      v •  M     g 7fr   r   r!  s     r   r$  Ú/Connection._format_copy_opts.<locals>.<genexpr>†  s   é € Ð'IÁqÀ!¬×(:Ò(:¸1×(=Ð(=Âqùr'  Ú))r  r9  r  z{} {}r½   )ÚdictÚlocalsÚpoprÅ   ÚboolÚappendÚitemsr,  rÆ   r   Ú_quote_literalrb   Úupper)rY   rb   r  r9  r  r  r  r  r  r  r:  r;  r  Úkwargsr+  ÚkÚvs                    r   r-  ÚConnection._format_copy_optsv  sì   € ô ”f“h“ˆØ�
‰
�6ÔØˆàÑ"¤z°+¼t×'DÑ'DØ�J‰J�}Ô%ÞØ—‘˜OÔ,à—L‘L–N‰DˆAˆqØ‹}ØÐGÓGØ˜dŸi™iÑ'IÁqÓ'IÓIÑIÈCÑO‘AØÐ6Ó6Ü˜A›‘Aä×,Ò,¨QÓ/�Aà—‘˜GŸN™N¨1¯7©7«9°aÓ8Ö9ñ #ö Ø˜Ÿ™ 4›Ñ(¨3Ñ.Ð.àr   c              ƒ   óJ  ^^	#   •  [         R                  " U5      nS nSnU R                  R                  m	Ub  T	" S [
        US5      I S h  v•N mSnOT[        US5      (       a  UmO@[        U5      (       a  UnO-[        SR                  [        U5      R                  5      5      eUc	  UU	4S jnUn U R                  R                  XU5      I S h  v•N U(       a  TR                  5         $ $ ! [         a    S n Nâf = f N¶ N0! U(       a  TR                  5         f f = f7f)NFÚwbTÚwritez_output is expected to be a file-like object, a path-like object or a coroutine function, not {}c              “   óJ   >#   • T" S TR                   U 5      I S h  v•N   g  N7fr   )rl  )r  ÚfÚrun_in_executors    €€r   Ú_writerÚ%Connection._copy_out.<locals>._writer°  s   øé € Ù% d¨A¯G©G°TÓ:×:Ó:ùs   ƒ#›!œ#)ÚosÚfspathÚ	TypeErrorr(   ro  ÚopenÚhasattrÚcallablerb   r   r   r&   Úcopy_outÚclose)
rY   r2  r0  r¢   ÚpathÚwriterÚopened_by_usrp  rn  ro  s
           @@r   r.  ÚConnection._copy_out“  s  ùé € ð	Ü—9’9˜VÓ$ˆDð
 ˆØˆØŸ*™*×4Ñ4ˆàÑá% d¬D°$¸Ó=×=ˆAØ‰LÜ�V˜W×%Ñ%à‰AÜ�f×Ñà‰Fäðç™¤ V£× 5Ñ 5Ó6óð ð ‰>ö;àˆFð	ØŸ™×0Ñ0°ÀGÓL×LæØ—‘•	ð øôC ó 	àŠDð	úñ >ñ* MøæØ—‘•	ð üs^   „D#†C0 œ/D#ÁDÁA'D#Â4D ÃDÃD ÃD#Ã0C?Ã<D#Ã>C?Ã?D#ÄD ÄD Ä D#c              ƒ   ó~  ^	^
#   •  [         R                  " U5      nS m	S nS nSnU R                  R                  m
Ub  T
" S [
        US5      I S h  v•N m	SnOB[        US5      (       a  Um	O.[        U[        R                  R                  5      (       a  UnOUnT	b   " U	U
4S jS5      nU" 5       n U R                  R                  XUS S U5      I S h  v•N U(       a  T
" S T	R                  5      I S h  v•N   $ $ ! [         a    S n Nîf = f N¾ N; N! U(       a  T
" S T	R                  5      I S h  v•N    f f = f7f)NFÚrbTÚreadc                   ó*   >• \ rS rSrS rU U4S jrSrg)Ú$Connection._copy_in.<locals>._ReaderiÚ  c                 ó   • U $ r   r   r’   s    r   Ú	__aiter__Ú.Connection._copy_in.<locals>._Reader.__aiter__Û  s   € Ø�Kr   c              “   óv   >#   • T" S TR                   S5      I S h  v•N n[        U5      S:X  a  [        eU$  N7f)Ni   r   )r€  rÄ   ÚStopAsyncIteration)rY   r  rn  ro  s     €€r   Ú	__anext__Ú.Connection._copy_in.<locals>._Reader.__anext__Þ  s7   øé € Ù!0°°q·v±v¸vÓ!F×F�DÜ˜4“y A“~Ü0Ð0à#˜ñ	 Gùs   ƒ9›7œ9r   N)r   r    r!   r"   r„  rˆ  r#   )rn  ro  s   €€r   Ú_Readerr‚  Ú  s   ø† ò ÷$ñ $r   rŠ  )rr  rs  rt  r(   ro  ru  rv  rÅ   ÚcollectionsÚabcÚAsyncIterabler&   rL  ry  )rY   r2  rE  r¢   rz  Úreaderr  r|  rŠ  rn  ro  s            @@r   rD  ÚConnection._copy_inº  s5  ùé € ð	Ü—9’9˜VÓ$ˆDð
 ˆØˆØˆØˆØŸ*™*×4Ñ4ˆàÑá% d¬D°$¸Ó=×=ˆAØ‰LÜ�V˜V×$Ñ$à‰AÜ˜¤§¡× =Ñ =×>Ñ>ð
 ‰Fð ˆDà‰=÷	$õ 	$ñ “YˆFð	5ØŸ™×/Ñ/Ø 4¨¨t°Wó>÷ >ö Ù% d¨A¯G©GÓ4×4Ñ4ð øô] ó 	àŠDð	úñ >ñ>>ñ 5øö Ù% d¨A¯G©GÓ4×4Ò4ð üs|   „D=†C< œ3D=ÁDÁA!D=Â2"D ÃDÃD ÃD=Ã5DÃ6D=Ã<DÄD=Ä
DÄD=ÄD ÄD=ÄD:Ä2D5Ä3D:Ä:D=ÚpublicÚtext)rñ   rb   c          
   ƒ   ó|  #   • U R                  5         U R                  R                  5       nU R                  X5      I Sh  v•N n/ n[        R
                  " U5      (       a  Sn	Ov[        R                  " U5      (       a>  US:w  a  [        R                  " SSS9eSn	U R                  US   4S	5      I Sh  v•N u  pŠO[        R                  " S
U SU S35      e[        R                  " U5      (       a  [        R                  " SSSS9eUS   nUR                  X±X(U	X4U5        U R                  5         g Nö N‚7f)a  Set an encoder/decoder pair for the specified data type.

:param typename:
    Name of the data type the codec is for.

:param schema:
    Schema name of the data type the codec is for
    (defaults to ``'public'``)

:param format:
    The type of the argument received by the *decoder* callback,
    and the type of the *encoder* callback return value.

    If *format* is ``'text'`` (the default), the exchange datum is a
    ``str`` instance containing valid text representation of the
    data type.

    If *format* is ``'binary'``, the exchange datum is a ``bytes``
    instance containing valid _binary_ representation of the
    data type.

    If *format* is ``'tuple'``, the exchange datum is a type-specific
    ``tuple`` of values.  The table below lists supported data
    types and their format for this mode.

    +-----------------+---------------------------------------------+
    |  Type           |                Tuple layout                 |
    +=================+=============================================+
    | ``interval``    | (``months``, ``days``, ``microseconds``)    |
    +-----------------+---------------------------------------------+
    | ``date``        | (``date ordinal relative to Jan 1 2000``,)  |
    |                 | ``-2^31`` for negative infinity timestamp   |
    |                 | ``2^31-1`` for positive infinity timestamp. |
    +-----------------+---------------------------------------------+
    | ``timestamp``   | (``microseconds relative to Jan 1 2000``,)  |
    |                 | ``-2^63`` for negative infinity timestamp   |
    |                 | ``2^63-1`` for positive infinity timestamp. |
    +-----------------+---------------------------------------------+
    | ``timestamp     | (``microseconds relative to Jan 1 2000      |
    | with time zone``| UTC``,)                                     |
    |                 | ``-2^63`` for negative infinity timestamp   |
    |                 | ``2^63-1`` for positive infinity timestamp. |
    +-----------------+---------------------------------------------+
    | ``time``        | (``microseconds``,)                         |
    +-----------------+---------------------------------------------+
    | ``time with     | (``microseconds``,                          |
    | time zone``     | ``time zone offset in seconds``)            |
    +-----------------+---------------------------------------------+
    | any composite   | Composite value elements                    |
    | type            |                                             |
    +-----------------+---------------------------------------------+

:param encoder:
    Callable accepting a Python object as a single argument and
    returning a value encoded according to *format*.

:param decoder:
    Callable accepting a single argument encoded according to *format*
    and returning a decoded Python object.

Example:

.. code-block:: pycon

    >>> import asyncpg
    >>> import asyncio
    >>> import datetime
    >>> from dateutil.relativedelta import relativedelta
    >>> async def run():
    ...     con = await asyncpg.connect(user='postgres')
    ...     def encoder(delta):
    ...         ndelta = delta.normalized()
    ...         return (ndelta.years * 12 + ndelta.months,
    ...                 ndelta.days,
    ...                 ((ndelta.hours * 3600 +
    ...                    ndelta.minutes * 60 +
    ...                    ndelta.seconds) * 1000000 +
    ...                  ndelta.microseconds))
    ...     def decoder(tup):
    ...         return relativedelta(months=tup[0], days=tup[1],
    ...                              microseconds=tup[2])
    ...     await con.set_type_codec(
    ...         'interval', schema='pg_catalog', encoder=encoder,
    ...         decoder=decoder, format='tuple')
    ...     result = await con.fetchval(
    ...         "SELECT '2 years 3 mons 1 day'::interval")
    ...     print(result)
    ...     print(datetime.datetime(2002, 1, 1) + result)
    ...
    >>> asyncio.run(run())
    relativedelta(years=+2, months=+3, days=+1)
    2004-04-02 00:00:00

.. versionadded:: 0.12.0
    Added the ``format`` keyword argument and support for 'tuple'
    format.

.. versionchanged:: 0.12.0
    The ``binary`` keyword argument is deprecated in favor of
    ``format``.

.. versionchanged:: 0.13.0
    The ``binary`` keyword argument was removed in favor of
    ``format``.

.. versionchanged:: 0.29.0
    Custom codecs for composite types are now supported with
    ``format='tuple'``.

.. note::

   It is recommended to use the ``'binary'`` or ``'tuple'`` *format*
   whenever possible and if the underlying type supports it. Asyncpg
   currently does not support text I/O for composite and range types,
   and some other functionality, such as
   :meth:`Connection.copy_to_table`, does not support types with text
   codecs.
NÚscalarÚtuplez7only tuple-format codecs can be used on composite typesz¾Use `set_type_codec(..., format='tuple')` and pass/interpret data as a Python tuple.  See an example at https://magicstack.github.io/asyncpg/current/usage.html#example-decoding-complex-types)ÚhintÚ	compositeÚoidé
   z cannot use custom codec on type r  z2: it is neither a scalar type nor a composite typez/custom codecs on domain types are not supportedzSet the codec on the base type.zePostgreSQL does not distinguish domains from their base types in query results at the protocol level.)r•  Údetail)rk   r&   rP   rô   r   Úis_scalar_typeÚis_composite_typer   ÚUnsupportedClientFeatureErrorrÊ   r|   Úis_domain_typeÚadd_python_codecÚ_drop_local_statement_cache)rY   rð   rñ   ÚencoderÚdecoderrb   r\   ÚtypeinfoÚfull_typeinfosÚkindr¬   r—  s               r   Úset_type_codecÚConnection.set_type_codecî  sV  é € ðr 	×ÑÔØ—>‘>×.Ñ.Ó0ˆØ×.Ñ.¨xÓ@×@ˆØˆÜ×'Ò'¨×1Ñ1Ø‰DÜ×,Ò,¨X×6Ñ6Ø˜Ó Ü ×>Ò>ØMðMñð ð ˆDØ&*×&<Ñ&<Ø˜%‘Ð" Bó'(÷ !(ÑˆN˜Aô ×+Ò+Ø2°6°(¸!¸H¸:ð FCð Dóð ô ×'Ò'¨×1Ñ1Ü×:Ò:ØAØ6ðOñ	ð ð �u‰oˆØ×!Ñ!Ø˜6°4Ø˜fô	&ð
 	×(Ñ(Õ*ñK Añ!(ùs%   ‚?D<ÁD8ÁA5D<Â7D:Â8BD<Ä:D<)rñ   c             ƒ   ó¼   #   • U R                  X5      I Sh  v•N nU R                  R                  5       R                  US   X5        U R	                  5         g NB7f)zïReset *typename* codec to the default implementation.

:param typename:
    Name of the data type the codec is for.

:param schema:
    Schema name of the data type the codec is for
    (defaults to ``'public'``)

.. versionadded:: 0.12.0
Nr—  )rô   r&   rP   Úremove_python_codecrŸ  )rY   rð   rñ   r¢  s       r   Úreset_type_codecÚConnection.reset_type_codec�  sR   é € ð ×.Ñ.¨xÓ@×@ˆØ�‰×#Ñ#Ó%×9Ñ9Ø�U‰O˜Xô	/ð 	×(Ñ(Õ*ñ Aùs   ‚A—A˜AAc             ƒ   ód  #   • U R                  5         U R                  X5      I Sh  v•N n[        R                  " U5      (       d%  [        R
                  " SR                  X!5      5      eUS   nU R                  R                  5       R                  XaUSX45        U R                  5         g N†7f)a¹  Set a builtin codec for the specified scalar data type.

This method has two uses.  The first is to register a builtin
codec for an extension type without a stable OID, such as 'hstore'.
The second use is to declare that an extension type or a
user-defined type is wire-compatible with a certain builtin
data type and should be exchanged as such.

:param typename:
    Name of the data type the codec is for.

:param schema:
    Schema name of the data type the codec is for
    (defaults to ``'public'``).

:param codec_name:
    The name of the builtin codec to use for the type.
    This should be either the name of a known core type
    (such as ``"int"``), or the name of a supported extension
    type.  Currently, the only supported extension type is
    ``"pg_contrib.hstore"``.

:param format:
    If *format* is ``None`` (the default), all formats supported
    by the target codec are declared to be supported for *typename*.
    If *format* is ``'text'`` or ``'binary'``, then only the
    specified format is declared to be supported for *typename*.

.. versionchanged:: 0.18.0
    The *codec_name* argument can be the name of any known
    core data type.  Added the *format* keyword argument.
Nz"cannot alias non-scalar type {}.{}r—  r“  )rk   rô   r   rš  r   r|   rb   r&   rP   Úset_builtin_type_codecrŸ  )rY   rð   rñ   Ú
codec_namerb   r¢  r—  s          r   r¬  Ú!Connection.set_builtin_type_codec¤  s    é € ðF 	×ÑÔØ×.Ñ.¨xÓ@×@ˆÜ×+Ò+¨H×5Ñ5Ü×+Ò+Ø4×;Ñ;Øó&ó'ð 'ð �u‰oˆà�‰×#Ñ#Ó%×<Ñ<Ø˜6 8¨Zô	Að 	×(Ñ(Õ*ñ Aùs   ‚%B0§B.¨BB0c                 óf   • U R                   =(       d    U R                  R                  5       (       + $ )zšReturn ``True`` if the connection is closed, ``False`` otherwise.

:return bool: ``True`` if the connection is closed, ``False``
              otherwise.
)r*   r&   Úis_connectedr’   s    r   ra   ÚConnection.is_closedÖ  s#   € ð �}‰}×A D§N¡N×$?Ñ$?Ó$AÔ AÐAr   c             ƒ   ó*  #   •  U R                  5       (       d#  U R                  R                  U5      I Sh  v•N   U R                  5         g N! [        [        R
                  4 a    U R                  5         e f = f! U R                  5         f = f7f)z�Close the connection gracefully.

:param float timeout:
    Optional timeout value in seconds.

.. versionchanged:: 0.14.0
   Added the *timeout* parameter.
N)ra   r&   ry  Ú	ExceptionÚasyncioÚCancelledErrorÚ_abortÚ_cleanup)rY   r¢   s     r   ry  ÚConnection.closeÞ  sp   é € ð	Ø—>‘>×#Ñ#Ø—n‘n×*Ñ*¨7Ó3×3Ð3ð �M‰M�Oñ 4øÜœ7×1Ñ1Ð2ó 	à�K‰KŒMØð	ûð
 �M‰M�Oüs7   ‚B„3A ·A¸A ¼BÁA Á,A;Á;A> Á>BÂBc                 ón   • U R                  5       (       d  U R                  5         U R                  5         g)z:Terminate the connection without waiting for pending data.N)ra   r¶  r·  r’   s    r   rf   ÚConnection.terminateñ  s!   € à�~‰~×ÑØ�K‰KŒMØ�‰�r   c              ƒ   óÚ  #   • U R                  5         U R                  R                  5         U R                  R                  5         U R                  R                  5       (       d  U R                  bu  U R                  b  U R                  R                  (       d,  U R                  R                  SSR                  U 5      05        S U l        U R                  S5      I S h  v•N   g g  N7f)NÚmessagez4Resetting connection with an active transaction {!r}ÚROLLBACK)rk   r/   Úclearr9   r&   r    r)   Ú_managedr(   Úcall_exception_handlerrb   r®   r’   s    r   Ú_resetÚConnection._reset÷  sµ   é € Ø×ÑÔØ�‰×ÑÔØ×Ñ×!Ñ!Ô#à�>‰>×+Ñ+×-Ñ-°·±Ñ1KØ�~‰~Ñ%¨T¯^©^×-D×-Dð —
‘
×1Ñ1Øð  9ß9?¹À»ð3ô ð
 "ˆDŒNØ—,‘,˜zÓ*×*Ñ*ð 2Lñ +ùs   ‚C C+Ã"C)Ã#C+c             ƒ   ó>  #   • [         R                  " U5       ISh  v•N   U R                  5       I Sh  v•N   U R                  5       nU(       a  U R	                  U5      I Sh  v•N   SSS5      ISh  v•N   g N] NG N N! , ISh  v•N  (       d  f       g= f7f)až  Reset the connection state.

Calling this will reset the connection session state to a state
resembling that of a newly obtained connection.  Namely, an open
transaction (if any) is rolled back, open cursors are closed,
all `LISTEN <https://www.postgresql.org/docs/current/sql-listen.html>`_
registrations are removed, all session configuration
variables are reset to their default values, and all advisory locks
are released.

Note that the above describes the default query returned by
:meth:`Connection.get_reset_query`.  If one overloads the method
by subclassing ``Connection``, then this method will do whatever
the overloaded method returns, except open transactions are always
terminated and any callbacks registered by
:meth:`Connection.add_listener` or :meth:`Connection.add_log_listener`
are removed.

:param float timeout:
    A timeout for resetting the connection.  If not specified, defaults
    to no timeout.
N)r   r¢   rÁ  Úget_reset_queryr®   )rY   r¢   Úreset_querys      r   ÚresetÚConnection.reset  si   é € ô. —>’> '×*Õ*Ø—+‘+“-×ÐØ×.Ñ.Ó0ˆKÞØ—l‘l ;Ó/×/Ð/÷	 +×*Ò*Ùñ 0÷	 +×*×*Ð*üsf   ‚B�A;žB¡BµA=¶/BÁ%A?Á&BÁ*BÁ5BÁ6BÁ=BÁ?BÂBÂBÂ	BÂ
BÂBc                 óT   • SU l         U R                  R                  5         S U l        g )NT)r*   r&   Úabortr’   s    r   r¶  ÚConnection._abort%  s    € àˆŒØ�‰×ÑÔØˆ�r   c                 ób  • U R                  5         U R                  b$  U R                  R                  R                  5         U R	                  5         U R
                  R                  5         U R                  R                  5         U R                  R                  5         U R                  5         g r   )
Ú_call_termination_listenersr4   Ú_holderÚ_release_on_closeÚ_mark_stmts_as_closedr/   r¾  r9   r=   Ú_clean_tasksr’   s    r   r·  ÚConnection._cleanup+  s~   € Ø×(Ñ(Ô*ð �;‰;Ñ"ð �K‰K×Ñ×1Ñ1Ô3à×"Ñ"Ô$Ø�‰×ÑÔØ×Ñ×!Ñ!Ô#Ø×Ñ×!Ñ!Ô#Ø×ÑÕr   c                 óÐ   • U R                   (       aU  U R                    H*  nUR                  5       (       a  M  UR                  5         M,     U R                   R                  5         g g r   )r;   ÚdoneÚcancelr¾  )rY   Úfuts     r   rÐ  ÚConnection._clean_tasks;  sH   € à××Ø×*Ô*�Ø—x‘x—z“zØ—J‘J–Lñ +ð ×Ñ×%Ñ%Õ'ð	 r   c                 óZ   • U R                  5       (       a  [        R                  " S5      eg )Nr{   )ra   r   r|   r’   s    r   rk   ÚConnection._check_openC  s&   € Ø�>‰>×ÑÜ×+Ò+Ð,BÓCÐCð r   c                 ó@   • [         S-  q SR                  U[         5      $ )Nr   z__asyncpg_{}_{:x}__)Ú_uidrb   )rY   Úprefixs     r   rÇ   ÚConnection._get_unique_idG  s   € ä�‰	ˆØ$×+Ñ+¨F´DÓ9Ð9r   c                 ó  • U R                   R                  5        H  nUR                  5         M     U R                   H  nUR                  5         M     U R                   R	                  5         U R                  R	                  5         g r   )r,   Úiter_statementsÚmark_closedr-   r¾  ©rY   r¼   s     r   rÏ  Ú Connection._mark_stmts_as_closedL  sk   € Ø×$Ñ$×4Ñ4Ö6ˆDØ×ÑÖñ 7ð ×(Ô(ˆDØ×ÑÖñ )ð 	×Ñ×ÑÔ Ø×Ñ×"Ñ"Õ$r   c                 ó$  • UR                   S:X  a€  UR                  (       an  U R                  R                  UR                  UR
                  UR                  45      (       d,  UR                  5         U R                  R                  U5        g g g g ©Nr   )
ÚrefsrÌ   r,   Úhasr£   rº   r¹   rß  r-   rn   rà  s     r   Ú_maybe_gc_stmtÚConnection._maybe_gc_stmtV  sx   € à�I‰I˜‹NØ—	—	Ø×$Ñ$×(Ñ(Ø—‘˜T×.Ñ.°×0HÑ0HÐI÷ñ ð ×ÑÔØ× Ñ ×$Ñ$ TÕ*ðð ð r   c              ƒ   ó¼   #   • U R                   n[        5       U l         U H5  nU R                  R                  U[        R
                  5      I S h  v•N   M7     g  N	7fr   )r-   rO   r&   Úclose_statementr
   Ú
NO_TIMEOUT)rY   Úto_closer¼   s      r   rÑ   ÚConnection._cleanup_stmtsi  sN   é € ð ×'Ñ'ˆÜ"›uˆÔÛˆDð —.‘.×0Ñ0°´x×7JÑ7JÓK×KÒKò ñ Lùs   ‚AAÁAÁ
Ac              ƒ   óœ  #   •  [         R                  " U R                  U R                  U R                  U R
                  R                  U R
                  R                  S9I S h  v•N   U R                  R                  [        R                   " U R                  5      5        UR                  5       (       d  UR#                  S 5        g g  Ne! [         a0  nUR                  5       (       d  UR                  U5         S nAN˜S nAf[        R                   a     N±[        [        R                  4 a0  nUR                  5       (       d  UR                  U5         S nANõS nAff = f! U R                  R                  [        R                   " U R                  5      5        UR                  5       (       d  UR#                  S 5        f f = f7f)N)rB   r[   r@   Úbackend_pidÚbackend_secret)r   Ú_cancelr(   r8   r7   r&   rî  rï  ÚConnectionResetErrorrÓ  Úset_exceptionr´  rµ  r³  r;   r�   Úcurrent_taskÚ
set_result)rY   ÚwaiterÚexs      r   rð  ÚConnection._cancelt  sO  é € ð	(ä×'Ò'Ø—Z‘Z d§j¡j¸¿¹Ø ŸN™N×6Ñ6Ø#Ÿ~™~×<Ñ<ñ>÷ >ð >ð* ×Ñ×'Ñ'Ü×$Ò$ T§Z¡ZÓ0ô2à—;‘;—=‘=Ø×!Ñ! $Õ'ð !ñ/>øô $ó 	)ð —;‘;—=‘=Ø×$Ñ$ RÔ(ÿøÜ×%Ñ%ó 	ñ Üœ7×1Ñ1Ð2ó 	)Ø—;‘;—=‘=Ø×$Ñ$ RÔ(ÿøð	)ûð ×Ñ×'Ñ'Ü×$Ò$ T§Z¡ZÓ0ô2à—;‘;—=‘=Ø×!Ñ! $Õ'ð !üsm   ‚G„A!C Á%CÁ&C Á*A!GÃC Ã
E$Ã&DÃ=E' ÄE$ÄE' ÄE$Ä4&EÅE' ÅE$Å$E' Å'A"G	Ç	Gc                 óŠ   • U R                   R                  U R                  R                  U R	                  U5      5      5        g r   )r;   rn   r(   Úcreate_taskrð  )rY   rõ  s     r   Ú_cancel_current_commandÚ"Connection._cancel_current_command‘  s.   € Ø×Ñ×Ñ §
¡
× 6Ñ 6°t·|±|ÀFÓ7KÓ LÕMr   c                 ón  • U R                   (       d  g [        R                  R                  XS9nU R	                  5       nU R                    Hf  nUR
                  (       a,  U R                  R                  UR                  XC5      5        M@  U R                  R                  UR                  XC5        Mh     g )N)r£   )
r9   r   ÚPostgresLogMessageÚnewÚ_unwrapÚis_asyncr(   rù  rw   Ú	call_soon)rY   ÚfieldsÚ
last_queryr¼  Úcon_refrw   s         r   Ú_process_log_messageÚConnection._process_log_message”  s|   € Ø×"×"Øä×/Ñ/×3Ñ3°FÐ3ÐMˆà—,‘,“.ˆØ×%Ô%ˆBØ�{�{Ø—
‘
×&Ñ& r§u¡u¨WÓ'>Ö?à—
‘
×$Ñ$ R§U¡U¨GÖ=ò	 &r   c                 óh  • U R                   (       d  g U R                  5       nU R                    Hf  nUR                  (       a,  U R                  R	                  UR                  U5      5        M@  U R                  R                  UR
                  U5        Mh     U R                   R                  5         g r   )r:   rÿ  r   r(   rù  rw   r  r¾  )rY   r  rw   s      r   rÌ  Ú&Connection._call_termination_listeners¡  sv   € Ø×*×*Øà—,‘,“.ˆØ×-Ô-ˆBØ�{�{Ø—
‘
×&Ñ& r§u¡u¨W£~Ö6à—
‘
×$Ñ$ R§U¡U¨GÖ4ñ	 .ð 	×#Ñ#×)Ñ)Õ+r   c           	      ó:  • X R                   ;  a  g U R                  5       nU R                   U    Hh  nUR                  (       a-  U R                  R	                  UR                  XAX#5      5        MA  U R                  R                  UR
                  XAX#5        Mj     g r   )r/   rÿ  r   r(   rù  rw   r  )rY   Úpidrq   Úpayloadr  rw   s         r   Ú_process_notificationÚ Connection._process_notification®  sk   € ØŸ/™/Ó)Øà—,‘,“.ˆØ—/‘/ 'Ô*ˆBØ�{�{Ø—
‘
×&Ñ& r§u¡u¨W¸7Ó'LÖMà—
‘
×$Ñ$ R§U¡U¨G¸'ÖKò	 +r   c                 ó@   • U R                   c  U nU$ U R                   nU$ r   )r4   )rY   r  s     r   rÿ  ÚConnection._unwrap¹  s(   € Ø�;‰;ÑØˆGð ˆð —k‘kˆGØˆr   c                 ó´  • U R                   b  U R                   $ U R                  n/ nUR                  (       a  UR                  S5        UR                  (       a  UR                  S5        UR
                  (       a"  UR                  (       a  UR                  S5        UR                  (       a  UR                  S5        SR                  U5      nX l         U$ )a  Return the query sent to server on connection release.

The query returned by this method is used by :meth:`Connection.reset`,
which is, in turn, used by :class:`~asyncpg.pool.Pool` before making
the connection available to another acquirer.

.. versionadded:: 0.30.0
z SELECT pg_advisory_unlock_all();z
CLOSE ALL;zUNLISTEN *;z
RESET ALL;Ú
)	r3   r1   Úadvisory_locksrb  Úsql_close_allÚnotificationsÚplpgsqlÚ	sql_resetr,  )rY   Úcapsr3   s      r   rÄ  ÚConnection.get_reset_queryÄ  s§   € ð ×ÑÑ(Ø×$Ñ$Ð$à× Ñ ˆàˆØ××Ø×ÑÐ BÔCØ××Ø×Ñ Ô-Ø×× $§,§,Ø×Ñ Ô.Ø�>�>Ø×Ñ Ô-à—y‘y Ó.ˆØ(ÔàÐr   c                 ó\   • U R                   b  Ub  [        R                  " S5      eXl         g )Nz5internal asyncpg error: connection is already proxied)r4   r   r|   )rY   Úproxys     r   Ú
_set_proxyÚConnection._set_proxyá  s0   € Ø�;‰;Ñ" uÑ'8ä×+Ò+ØGóIð Ið �r   c           	      ó°   • U(       aO  [        U5      n[        R                  " SR                  XUUS:”  a  SOSS95      n[        R
                  " U5        g g )NzL{conn!r} is being released to the pool but has {c} active {type} listener{s}r   Úsr½   )Úconnr#  r   r  )rÄ   r   ÚInterfaceWarningrb   rc   rd   )rY   Ú	listenersÚlistener_typeÚcountÚws        r   Ú_check_listenersÚConnection._check_listenersé  sU   € ÞÜ˜	“NˆEä×+Ò+ð%ß%+¡VØ¨]Ø" Q›Y‘c¨Bð &,ð &0ó1ˆAô �MŠM˜!Õð r   c                 ó  • U =R                   S-  sl         U R                  [        [        R                  R                  U R                  R                  5       5      5      S5        U R                  U R                  S5        g )Nr   ÚnotificationÚlog)	r+   r%  rá   Ú	itertoolsÚchainÚfrom_iterabler/   Úvaluesr9   )rY   Ú
stacklevels     r   Ú_on_releaseÚConnection._on_releaseõ  se   € à×Ò !Ñ#Õð 	×ÑÜ”—‘×.Ñ.¨t¯©×/EÑ/EÓ/GÓHÓIØô	ð 	×ÑØ×Ñ õ	(r   c                 ó8   • U R                   R                  5         g r   )r,   r¾  r’   s    r   rŸ  Ú&Connection._drop_local_statement_cache   s   € Ø×Ñ×ÑÕ r   c                 ó    • U R                   b1  U R                   R                  R                  nUR                  5         g U R	                  5         g r   )r4   rÍ  Ú_poolÚ_drop_statement_cacherŸ  ©rY   Úpools     r   Ú_drop_global_statement_cacheÚ'Connection._drop_global_statement_cache  s;   € Ø�;‰;Ñ"ð —;‘;×&Ñ&×,Ñ,ˆDØ×&Ñ&Õ(à×,Ñ,Õ.r   c                 óT   • U R                   R                  5       R                  5         g r   )r&   rP   Úclear_type_cacher’   s    r   Ú_drop_local_type_cacheÚ!Connection._drop_local_type_cache  s   € Ø�‰×#Ñ#Ó%×6Ñ6Õ8r   c                 ó    • U R                   b1  U R                   R                  R                  nUR                  5         g U R	                  5         g r   )r4   rÍ  r4  Ú_drop_type_cacher<  r6  s     r   Ú_drop_global_type_cacheÚ"Connection._drop_global_type_cache  s;   € Ø�;‰;Ñ"ð —;‘;×&Ñ&×,Ñ,ˆDØ×!Ñ!Õ#à×'Ñ'Õ)r   c              ƒ   óL   #   • U R                  5         U R                  5         g7f)a?  Indicate that the database schema information must be reloaded.

For performance reasons, asyncpg caches certain aspects of the
database schema, such as the layout of composite types.  Consequently,
when the database schema changes, and asyncpg is not able to
gracefully recover from an error caused by outdated schema
assumptions, an :exc:`~asyncpg.exceptions.OutdatedSchemaCacheError`
is raised.  To prevent the exception, this method may be used to inform
asyncpg that the database schema has changed.

Example:

.. code-block:: pycon

    >>> import asyncpg
    >>> import asyncio
    >>> async def change_type(con):
    ...     result = await con.fetch('SELECT id, info FROM tbl')
    ...     # Change composite's attribute type "int"=>"text"
    ...     await con.execute('ALTER TYPE custom DROP ATTRIBUTE y')
    ...     await con.execute('ALTER TYPE custom ADD ATTRIBUTE y text')
    ...     await con.reload_schema_state()
    ...     for id_, info in result:
    ...         new = (info['x'], str(info['y']))
    ...         await con.execute(
    ...             'UPDATE tbl SET info=$2 WHERE id=$1', id_, new)
    ...
    >>> async def run():
    ...     # Initial schema:
    ...     # CREATE TYPE custom AS (x int, y int);
    ...     # CREATE TABLE tbl(id int, info custom);
    ...     con = await asyncpg.connect(user='postgres')
    ...     async with con.transaction():
    ...         # Prevent concurrent changes in the table
    ...         await con.execute('LOCK TABLE tbl')
    ...         await change_type(con)
    ...
    >>> asyncio.run(run())

.. versionadded:: 0.14.0
N)r@  r8  r’   s    r   Úreload_schema_stateÚConnection.reload_schema_state  s    é € ðT 	×$Ñ$Ô&Ø×)Ñ)Õ+ùr'  )r¦   r¹   rº   c             ƒ   óž   #   • U R                      U R                  UUUUUUUS9I S h  v•N u  p‰S S S 5        U$  N! , (       d  f       W$ = f7f)N)r¦   rº   r¹   )r5   rß   )
rY   r£   rª   ré   r¢   r¦   r¹   rº   r«   r¬   s
             r   r¨   ÚConnection._executeE  s_   é € ð ×)Ó)Ø"Ÿn™nØØØØØ+Ø)Ø$7ð -ð ÷ ‰IˆF÷ *ð ˆñ÷ *Ô)ð ˆüs%   ‚A�;¨9©;¯
A¹;»
A
ÁAc              #   óX   #   • U R                  U5        Sv •  U R                  U5        g7f)a­  Context manager that adds `callback` to the list of query loggers,
and removes it upon exit.

:param callable callback:
    A callable or a coroutine function receiving one argument:
    **record**, a LoggedQuery containing `query`, `args`, `timeout`,
    `elapsed`, `exception`, `conn_addr`, and `conn_params`.

Example:

.. code-block:: pycon

    >>> class QuerySaver:
            def __init__(self):
                self.queries = []
            def __call__(self, record):
                self.queries.append(record.query)
    >>> with con.query_logger(QuerySaver()):
    >>>     await con.execute("SELECT 1")
    >>> print(log.queries)
    ['SELECT 1']

.. versionadded:: 0.29.0
N)r‹   rŽ   r}   s     r   Úquery_loggerÚConnection.query_logger\  s&   é € ð4 	×Ñ˜hÔ'ÛØ× Ñ  Õ*ùs   ‚(*c              #   ó>  #   • [         R                  " 5       nS n S v •   [         R                  " 5       U-
  n[        UUUUUU R                  U R
                  S9nU R                   Hf  n	U	R                  (       a,  U R                  R                  U	R                  U5      5        M@  U R                  R                  U	R                  U5        Mh     g ! [         a  nUne S nAff = f! [         R                  " 5       U-
  n[        UUUUUU R                  U R
                  S9nU R                   Hf  n	U	R                  (       a,  U R                  R                  U	R                  U5      5        M@  U R                  R                  U	R                  U5        Mh     f = f7f)N©r£   rª   r¢   ÚelapsedÚ	exceptionÚ	conn_addrÚconn_params)ÚtimeÚ	monotonicÚBaseExceptionÚLoggedQueryr8   r7   r=   r   r(   rù  rw   r  )
rY   r£   rª   r¢   ÚstartrM  rö  rL  Úrecordrw   s
             r   r§   ÚConnection._time_and_logz  sB  é € ä—’Ó ˆØˆ	ð	8Üô
 —n’nÓ&¨Ñ.ˆGÜ ØØØØØ#ØŸ*™*Ø ŸL™LñˆFð ×)Ô)�Ø—;—;Ø—J‘J×*Ñ*¨2¯5©5°«=Ö9à—J‘J×(Ñ(¨¯©°Ö7ò	 *øô ó 	ØˆIØûð	ûô —n’nÓ&¨Ñ.ˆGÜ ØØØØØ#ØŸ*™*Ø ŸL™LñˆFð ×)Ô)�Ø—;—;Ø—J‘J×*Ñ*¨2¯5©5°«=Ö9à—J‘J×(Ñ(¨¯©°Ö7ò	 *üs5   ‚F›C  B2FÃ
C$ÃCÃC$Ã$C' Ã'B3FÆFc          	   ƒ   ód  ^ ^^^#   • UUUU 4S jnT R                   R                  U5      nT R                  (       a<  T R                  UTU5         T R	                  UUUUUS9I S h  v•N u  pšS S S 5        Xš4$ T R	                  UUUUUS9I S h  v•N u  pšXš4$  N1! , (       d  f       W	W
4$ = f N7f)Nc           	      ó@   >• TR                   R                  U TSTTUS9$ )Nr½   )Ústaterª   Úportal_nameré   Úreturn_extrar¢   )r&   Úbind_execute)r¼   r¢   rª   ré   r¦   rY   s     €€€€r   Ú<lambda>Ú&Connection.__execute.<locals>.<lambda>Ÿ  s,   ø€ ¨¯©×)DÑ)DØØØØØ&Øð *Eñ *
r   r¾   )r&   Ú_get_timeoutr=   r§   Ú_do_execute)rY   r£   rª   ré   r¢   r¦   r¹   rº   Úexecutorr«   r¼   s   ` `` `     r   Ú	__executeÚConnection.__execute”  sÎ   ûé € ÷
ˆð —.‘.×-Ñ-¨gÓ6ˆØ××Ø×#Ñ# E¨4°Õ9Ø%)×%5Ñ%5ØØØØ!-Ø(;ð &6ð &÷  ‘�÷ :ð  ˆ|Ðð "&×!1Ñ!1ØØØØ)Ø$7ð "2ð "÷ ‰LˆFð ˆ|Ðñ ÷ :Ô9ð  �tˆ|Ðúñùs<   †A	B0ÁBÁ&BÁ'BÁ-!B0ÂB.Â	B0ÂBÂ
B+Â$B0c           	   ƒ   ó:  ^ ^^#   • UUU 4S jnT R                   R                  U5      nT R                     T R                  UTU5         T R	                  XX5S9I S h  v•N u  pxS S S 5        S S S 5        W$  N! , (       d  f       N= f! , (       d  f       W$ = f7f)Nc                 ó>   >• TR                   R                  U TSUTS9$ )Nr½   )rY  rª   rZ  r¢   r  )r&   Úbind_execute_many)r¼   r¢   rª   r  rY   s     €€€r   r]  Ú)Connection._executemany.<locals>.<lambda>Ã  s)   ø€ ¨¯©×)IÑ)IØØØØØ#ð *Jñ *
r   r  )r&   r_  r5   r§   r`  )	rY   r£   rª   r¢   r  rº   ra  r«   r¬   s	   ` ` `    r   r³   ÚConnection._executemany»  s�   úé € ö
ˆð —.‘.×-Ñ-¨gÓ6ˆØ×)Ó)Ø×#Ñ# E¨4°Õ9Ø"&×"2Ñ"2Ø Wð #3ð #÷ ‘	�÷ :÷ *ð
 ˆñ÷ :Õ9ú÷ *Ô)ð
 ˆüsF   …0BµB	Á	A8ÁA6ÁA8Á$B	Á,
BÁ6A8Á8
B	ÂB	Â	
BÂB)r¹   rº   c             ƒ   óò  #   • Uc  U R                  US UUS9I S h  v•N nOM[        R                  " 5       nU R                  UUUUS9I S h  v•N n[        R                  " 5       n	X9U-
  -  nU	n Uc  U" US 5      I S h  v•N n
X§4$  U" Xs5      I S h  v•N n
[        R                  " 5       n	X9W-
  -  nX§4$  Nš Nl N; N)! [        R                  " 5       n	X9W-
  -  nf = f! [        R                   a    U R                  5       I S h  v•N    e [        R                   aT    U R                  5         U R                  R                  5       (       d  U(       d  e U R                  XUSS9I S h  v•N  s $ f = f7f)Nr¾   F)Úretry)rÙ   rP  rQ  r   ÚOutdatedSchemaCacheErrorrC  ÚInvalidCachedStatementErrorr8  r&   r    r`  )rY   r£   ra  r¢   rj  r¹   rº   r¼   ÚbeforeÚafterr«   s              r   r`  ÚConnection._do_executeÒ  s•  é € ð ‰?Ø×,Ñ,ØØØ)Ø$7ð	 -ð ÷ ‰Dô —^’^Ó%ˆFØ×,Ñ,ØØØ)Ø$7ð	 -ð ÷ ˆDô —N’NÓ$ˆEØ˜v‘~Ñ%ˆGØˆFð/	;Ø‰Ù'¨¨dÓ3×3�ð^ ˆ|Ðð[.Ù#+¨DÓ#:×:�Fä ŸNšNÓ,�EØ v™~Ñ-�GðR ˆ|ÐñGññ 4ñ ;øä ŸNšNÓ,�EØ v™~Ñ-‘Gûä×2Ñ2ó 	ð ×*Ñ*Ó,×,Ñ,ØÜ×5Ñ5ó 	;ð. ×-Ñ-Ô/Ø�~‰~×/Ñ/×1Ñ1¾Øà!×-Ñ-Ø W°Eð .ð ;÷ ;ð ;ò ;ð7	;üs    ‚E7›B6œ/E7ÁB8Á"E7Á/C Á>B:Á?C ÂE7ÂB> ÂB<ÂB> ÂC Â3E7Â8E7Â:C Â<B> Â>CÃC Ã'E4ÄD	ÄA$E4Å+E.Å,E4Å1E7Å3E4Å4E7)r*   r8   r;   r6   r2   r/   r9   r(   r7   r+   r&   r4   r=   r3   r1   r0   r<   r,   r.   r5   r-   r:   r)   r'   )r   )FN)T)[r   r    r!   r"   Ú__doc__Ú	__slots__r   Ú_ClientConfigurationÚ_ConnectionParametersr^   rh   rs   rx   r~   r‚   r…   rˆ   r‹   rŽ   r‘   r•   rP   r   r    rÆ   ÚtypingÚOptionalÚfloatr®   r´   ÚUnionra  rÙ   rÊ   rô   r   rÈ   rü   rá   rl   r  r  r  r3  r7  rF  rR  rC  r-  r.  rD  r¥  r©  r¬  ra   ry  rf   rÁ  rÆ  r¶  r·  rÐ  rk   rÇ   rÏ  ræ  rÑ   rð  rú  r  rÌ  r  rÿ  rÄ  r  r%  r/  rŸ  r8  r<  r@  rC  r¨   Ú
contextlibÚcontextmanagerrH  r§   rß   r³   r`  r#   r   r   r   r   r   +   sÎ  † ñð
G€Ið>*à&×;Ñ;ð>*ð '×<Ñ<ô>*ò@!ò Hò,PòCò,GòKò	Oò
Cò	Gò/ò$ò -ð (,°eØ$õNò42ð )-ò	2àð2ð —‘ Ñ'ð	2ð
 
õ2ðr )-ò#?àð#?ð
 —‘ Ñ'õ#?ðT 05ØØ!Øòdð
 �|‰|˜C  t˜OÑ,õdòL(òTð0 ØØõ%
ðV ØØõ%
ðV /3ØØØòBð �l‰l˜3  d˜?Ñ+ð	Bð õBð2 Øò"
ð 
õ"
ðH 34¸Tõ ð2 Øõ&ðZ )-Øò)
ð
 —‘ Ñ'õ)
ðX '+¸ÀdØ%)°ÀØ#'°¸DØ%)°tÀdõ	F@ðR '+°4¸dØ(,°4ÀØ$(°À4Ø'+õ	<@ð~ %)°dÀDØ#'¨d¸4Ø&*°¸dØ"&¨tÀØ+/¸DØ%)°õV?ðr -1¸dØ,0¸õdFòL
ð +/°TÀ$Ø$(¨t¸DÈØ!%°4ÈØ%)°Dõò:%òN25ðj %-Ø$*õ`+ðD :Bõ +ð* -5Ø,0õ0+òdBð &*õ ò&ò+ð" &*õ 0ò:òò (òDò:ò
%ò+ò&	Lò(ò:Nò>ò,ò	Lò	òò:ò
ô	(ò!ò/ò9ò*ò+,ðh Ø!Øõð. ×Ññ+ó ð+ð: ×Ññ8ó ð8ð@ Ø!Øõ%ðX Øôð8 ðNð "Ø÷Nñ Nr   r   )Ú	metaclassé<   éd   i,  i <  )ÚhostÚportÚuserÚpasswordÚpassfileÚserviceÚservicefileÚdatabaserB   r¢   rH   rN   rÃ   Úcommand_timeoutÚsslÚ
direct_tlsÚconnection_classrº   Úserver_settingsÚtarget_session_attrsÚ
krbsrvnameÚgsslibc             ƒ   óF  #   • [        U[        5      (       d%  [        R                  " SR	                  U5      5      eU[
        R                  La  [        U5        U	c  [        R                  " 5       n	[        R                  " U
5       ISh  v•N   [        R                  " S0 SU	_SU_SU_SU _SU_SU_S	U_S
U_SU_SU_SU_SU_SU_SU_SU_SU_SU_SU_SU_SU_SU_SU_6I Sh  v•N sSSS5      ISh  v•N   $  Ns N N	! , ISh  v•N  (       d  f       g= f7f)aÿ/  A coroutine to establish a connection to a PostgreSQL server.

The connection parameters may be specified either as a connection
URI in *dsn*, or as specific keyword arguments, or both.
If both *dsn* and keyword arguments are specified, the latter
override the corresponding values parsed from the connection URI.
The default values for the majority of arguments can be specified
using `environment variables <postgres envvars_>`_.

Returns a new :class:`~asyncpg.connection.Connection` object.

:param dsn:
    Connection arguments specified using as a single string in the
    `libpq connection URI format`_:
    ``postgres://user:password@host:port/database?option=value``.
    The following options are recognized by asyncpg: ``host``,
    ``port``, ``user``, ``database`` (or ``dbname``), ``password``,
    ``passfile``, ``sslmode``, ``sslcert``, ``sslkey``, ``sslrootcert``,
    and ``sslcrl``.  Unlike libpq, asyncpg will treat unrecognized
    options as `server settings`_ to be used for the connection.

    .. note::

       The URI must be *valid*, which means that all components must
       be properly quoted with :py:func:`urllib.parse.quote_plus`, and
       any literal IPv6 addresses must be enclosed in square brackets.
       For example:

       .. code-block:: text

          postgres://dbuser@[fe80::1ff:fe23:4567:890a%25eth0]/dbname

:param host:
    Database host address as one of the following:

    - an IP address or a domain name;
    - an absolute path to the directory containing the database
      server Unix-domain socket (not supported on Windows);
    - a sequence of any of the above, in which case the addresses
      will be tried in order, and the first successful connection
      will be returned.

    If not specified, asyncpg will try the following, in order:

    - host address(es) parsed from the *dsn* argument,
    - the value of the ``PGHOST`` environment variable,
    - on Unix, common directories used for PostgreSQL Unix-domain
      sockets: ``"/run/postgresql"``, ``"/var/run/postgresl"``,
      ``"/var/pgsql_socket"``, ``"/private/tmp"``, and ``"/tmp"``,
    - ``"localhost"``.

:param port:
    Port number to connect to at the server host
    (or Unix-domain socket file extension).  If multiple host
    addresses were specified, this parameter may specify a
    sequence of port numbers of the same length as the host sequence,
    or it may specify a single port number to be used for all host
    addresses.

    If not specified, the value parsed from the *dsn* argument is used,
    or the value of the ``PGPORT`` environment variable, or ``5432`` if
    neither is specified.

:param user:
    The name of the database role used for authentication.

    If not specified, the value parsed from the *dsn* argument is used,
    or the value of the ``PGUSER`` environment variable, or the
    operating system name of the user running the application.

:param database:
    The name of the database to connect to.

    If not specified, the value parsed from the *dsn* argument is used,
    or the value of the ``PGDATABASE`` environment variable, or the
    computed value of the *user* argument.

:param password:
    Password to be used for authentication, if the server requires
    one.  If not specified, the value parsed from the *dsn* argument
    is used, or the value of the ``PGPASSWORD`` environment variable.
    Note that the use of the environment variable is discouraged as
    other users and applications may be able to read it without needing
    specific privileges.  It is recommended to use *passfile* instead.

    Password may be either a string, or a callable that returns a string.
    If a callable is provided, it will be called each time a new connection
    is established.

:param passfile:
    The name of the file used to store passwords
    (defaults to ``~/.pgpass``, or ``%APPDATA%\postgresql\pgpass.conf``
    on Windows).

:param service:
    The name of the postgres connection service stored in the postgres
    connection service file.

:param servicefile:
    The location of the connnection service file used to store
    connection parameters.

:param loop:
    An asyncio event loop instance.  If ``None``, the default
    event loop will be used.

:param float timeout:
    Connection timeout in seconds.

:param int statement_cache_size:
    The size of prepared statement LRU cache.  Pass ``0`` to
    disable the cache.

:param int max_cached_statement_lifetime:
    The maximum time in seconds a prepared statement will stay
    in the cache.  Pass ``0`` to allow statements be cached
    indefinitely.

:param int max_cacheable_statement_size:
    The maximum size of a statement that can be cached (15KiB by
    default).  Pass ``0`` to allow all statements to be cached
    regardless of their size.

:param float command_timeout:
    The default timeout for operations on this connection
    (the default is ``None``: no timeout).

:param ssl:
    Pass ``True`` or an `ssl.SSLContext <SSLContext_>`_ instance to
    require an SSL connection.  If ``True``, a default SSL context
    returned by `ssl.create_default_context() <create_default_context_>`_
    will be used.  The value can also be one of the following strings:

    - ``'disable'`` - SSL is disabled (equivalent to ``False``)
    - ``'prefer'`` - try SSL first, fallback to non-SSL connection
      if SSL connection fails
    - ``'allow'`` - try without SSL first, then retry with SSL if the first
      attempt fails.
    - ``'require'`` - only try an SSL connection.  Certificate
      verification errors are ignored
    - ``'verify-ca'`` - only try an SSL connection, and verify
      that the server certificate is issued by a trusted certificate
      authority (CA)
    - ``'verify-full'`` - only try an SSL connection, verify
      that the server certificate is issued by a trusted CA and
      that the requested server host name matches that in the
      certificate.

    The default is ``'prefer'``: try an SSL connection and fallback to
    non-SSL connection if that fails.

    .. note::

       *ssl* is ignored for Unix domain socket communication.

    Example of programmatic SSL context configuration that is equivalent
    to ``sslmode=verify-full&sslcert=..&sslkey=..&sslrootcert=..``:

    .. code-block:: pycon

        >>> import asyncpg
        >>> import asyncio
        >>> import ssl
        >>> async def main():
        ...     # Load CA bundle for server certificate verification,
        ...     # equivalent to sslrootcert= in DSN.
        ...     sslctx = ssl.create_default_context(
        ...         ssl.Purpose.SERVER_AUTH,
        ...         cafile="path/to/ca_bundle.pem")
        ...     # If True, equivalent to sslmode=verify-full, if False:
        ...     # sslmode=verify-ca.
        ...     sslctx.check_hostname = True
        ...     # Load client certificate and private key for client
        ...     # authentication, equivalent to sslcert= and sslkey= in
        ...     # DSN.
        ...     sslctx.load_cert_chain(
        ...         "path/to/client.cert",
        ...         keyfile="path/to/client.key",
        ...     )
        ...     con = await asyncpg.connect(user='postgres', ssl=sslctx)
        ...     await con.close()
        >>> asyncio.run(main())

    Example of programmatic SSL context configuration that is equivalent
    to ``sslmode=require`` (no server certificate or host verification):

    .. code-block:: pycon

        >>> import asyncpg
        >>> import asyncio
        >>> import ssl
        >>> async def main():
        ...     sslctx = ssl.create_default_context(
        ...         ssl.Purpose.SERVER_AUTH)
        ...     sslctx.check_hostname = False
        ...     sslctx.verify_mode = ssl.CERT_NONE
        ...     con = await asyncpg.connect(user='postgres', ssl=sslctx)
        ...     await con.close()
        >>> asyncio.run(main())

:param bool direct_tls:
    Pass ``True`` to skip PostgreSQL STARTTLS mode and perform a direct
    SSL connection. Must be used alongside ``ssl`` param.

:param dict server_settings:
    An optional dict of server runtime parameters.  Refer to
    PostgreSQL documentation for
    a `list of supported options <server settings_>`_.

:param type connection_class:
    Class of the returned connection object.  Must be a subclass of
    :class:`~asyncpg.connection.Connection`.

:param type record_class:
    If specified, the class to use for records returned by queries on
    this connection object.  Must be a subclass of
    :class:`~asyncpg.Record`.

:param SessionAttribute target_session_attrs:
    If specified, check that the host has the correct attribute.
    Can be one of:

    - ``"any"`` - the first successfully connected host
    - ``"primary"`` - the host must NOT be in hot standby mode
    - ``"standby"`` - the host must be in hot standby mode
    - ``"read-write"`` - the host must allow writes
    - ``"read-only"`` - the host most NOT allow writes
    - ``"prefer-standby"`` - first try to find a standby host, but if
      none of the listed hosts is a standby server,
      return any of them.

    If not specified, the value parsed from the *dsn* argument is used,
    or the value of the ``PGTARGETSESSIONATTRS`` environment variable,
    or ``"any"`` if neither is specified.

:param str krbsrvname:
    Kerberos service name to use when authenticating with GSSAPI. This
    must match the server configuration. Defaults to 'postgres'.

:param str gsslib:
    GSS library to use for GSSAPI/SSPI authentication. Can be 'gssapi'
    or 'sspi'. Defaults to 'sspi' on Windows and 'gssapi' otherwise.

:return: A :class:`~asyncpg.connection.Connection` instance.

Example:

.. code-block:: pycon

    >>> import asyncpg
    >>> import asyncio
    >>> async def run():
    ...     con = await asyncpg.connect(user='postgres')
    ...     types = await con.fetch('SELECT * FROM pg_type')
    ...     print(types)
    ...
    >>> asyncio.run(run())
    [<Record typname='bool' typnamespace=11 ...

.. versionadded:: 0.10.0
   Added ``max_cached_statement_use_count`` parameter.

.. versionchanged:: 0.11.0
   Removed ability to pass arbitrary keyword arguments to set
   server settings.  Added a dedicated parameter ``server_settings``
   for that.

.. versionadded:: 0.11.0
   Added ``connection_class`` parameter.

.. versionadded:: 0.16.0
   Added ``passfile`` parameter
   (and support for password files in general).

.. versionadded:: 0.18.0
   Added ability to specify multiple hosts in the *dsn*
   and *host* arguments.

.. versionchanged:: 0.21.0
   The *password* argument now accepts a callable or an async function.

.. versionchanged:: 0.22.0
   Added the *record_class* parameter.

.. versionchanged:: 0.22.0
   The *ssl* argument now defaults to ``'prefer'``.

.. versionchanged:: 0.24.0
   The ``sslcert``, ``sslkey``, ``sslrootcert``, and ``sslcrl`` options
   are supported in the *dsn* argument.

.. versionchanged:: 0.25.0
   The ``sslpassword``, ``ssl_min_protocol_version``,
   and ``ssl_max_protocol_version`` options are supported in the *dsn*
   argument.

.. versionchanged:: 0.25.0
   Default system root CA certificates won't be loaded when specifying a
   particular sslmode, following the same behavior in libpq.

.. versionchanged:: 0.25.0
   The ``sslcert``, ``sslkey``, ``sslrootcert``, and ``sslcrl`` options
   in the *dsn* argument now have consistent default values of files under
   ``~/.postgresql/`` as libpq.

.. versionchanged:: 0.26.0
   Added the *direct_tls* parameter.

.. versionchanged:: 0.28.0
   Added the *target_session_attrs* parameter.

.. versionchanged:: 0.30.0
   Added the *krbsrvname* and *gsslib* parameters.

.. versionchanged:: 0.31.0
   Added the *servicefile* and *service* parameters.

.. _SSLContext: https://docs.python.org/3/library/ssl.html#ssl.SSLContext
.. _create_default_context:
    https://docs.python.org/3/library/ssl.html#ssl.create_default_context
.. _server settings:
    https://www.postgresql.org/docs/current/static/runtime-config.html
.. _postgres envvars:
    https://www.postgresql.org/docs/current/static/libpq-envars.html
.. _libpq connection URI format:
    https://www.postgresql.org/docs/current/static/
    libpq-connect.html#LIBPQ-CONNSTRING
zMconnection_class is expected to be a subclass of asyncpg.Connection, got {!r}NrB   rˆ  rº   Údsnr}  r~  r  r€  r�  r‚  rƒ  r†  r‡  r„  r‰  r…  rH   rN   rÃ   rŠ  r‹  rŒ  r   )Ú
issubclassr   r   r|   rb   r
   ÚRecordrÁ   r´  Úget_event_loopr   r¢   r   Ú_connect)rŽ  r}  r~  r  r€  r�  r‚  rƒ  r„  rB   r¢   rH   rN   rÃ   r…  r†  r‡  rˆ  rº   r‰  rŠ  r‹  rŒ  s                          r   Úconnectr“  #  s~  é € ôx
 Ð&¬
×3Ñ3Ü×'Ò'ð+ß+1©6Ð2BÓ+CóEð 	Eð œ8Ÿ?™?Ò*Ü˜LÔ)à�|Ü×%Ò%Ó'ˆä�~Š~˜g×&Õ&Ü"×+Ò+ò 
Ùð
á-ð
ñ &ð
ñ ð	
ñ
 ð
ñ ð
ñ ð
ñ ð
ñ ð
ñ ð
ñ $ð
ñ ð
ñ "ð
ñ ð
ñ ,ð
ñ  ,ð!
ñ" "6ð#
ñ$ +Hð%
ñ& *Fð'
ñ( "6ð)
ñ* "ð+
ñ, ð-
÷ 
÷ '×&Ó&ñ
÷ '×&×&Ð&üs[   ‚BD!ÂDÂD!ÂADÃ+DÃ,DÃ/D!Ã;DÃ<D!ÄDÄD!ÄDÄDÄDÄD!c                   ó   • \ rS rSrSrS rSrg)Ú_StatementCacheEntryi¥	  )Ú_queryÚ
_statementÚ_cacheÚ_cleanup_cbc                 ó6   • Xl         X l        X0l        S U l        g r   )r˜  r–  r—  r™  )rY   Úcacher£   rÒ   s       r   r^   Ú_StatementCacheEntry.__init__©	  s   € ØŒØŒØ#ŒØˆÕr   )r˜  r™  r–  r—  N)r   r    r!   r"   rq  r^   r#   r   r   r   r•  r•  ¥	  s   † àA€Iõ r   r•  c                   ó€   • \ rS rSrSrS rS rS rS rS r	S r
S	S
.S jrS rS rS rS rS rS rS rS rS rSrg)rG   i°	  )r(   Ú_entriesÚ	_max_sizeÚ
_on_removeÚ_max_lifetimec                óh   • Xl         X l        X0l        X@l        [        R
                  " 5       U l        g r   )r(   rŸ  r   r¡  r‹  ÚOrderedDictrž  )rY   rB   rC   rD   rE   s        r   r^   Ú_StatementCache.__init__µ	  s)   € ØŒ
Ø!ŒØ#ŒØ)Ôô& $×/Ò/Ó1ˆ�r   c                 ó,   • [        U R                  5      $ r   )rÄ   rž  r’   s    r   Ú__len__Ú_StatementCache.__len__Î	  s   € Ü�4—=‘=Ó!Ð!r   c                 ó   • U R                   $ r   )rŸ  r’   s    r   Úget_max_sizeÚ_StatementCache.get_max_sizeÑ	  s   € Ø�~‰~Ðr   c                 ó@   • US:¼  d   eXl         U R                  5         g rã  )rŸ  Ú_maybe_cleanup)rY   Únew_sizes     r   Úset_max_sizeÚ_StatementCache.set_max_sizeÔ	  s   € Ø˜1‹}Ðˆ}Ø!ŒØ×ÑÕr   c                 ó   • U R                   $ r   )r¡  r’   s    r   Úget_max_lifetimeÚ _StatementCache.get_max_lifetimeÙ	  s   € Ø×!Ñ!Ð!r   c                 ó„   • US:¼  d   eXl         U R                  R                  5        H  nU R                  U5        M     g rã  )r¡  rž  r-  Ú_set_entry_timeout)rY   Únew_lifetimeÚentrys      r   Úset_max_lifetimeÚ _StatementCache.set_max_lifetimeÜ	  s=   € Ø˜qÓ Ð Ð Ø)ÔØ—]‘]×)Ñ)Ö+ˆEð ×#Ñ# EÖ*ò ,r   T©Úpromotec                óN  • U R                   (       d  g U R                  R                  U5      nUc  g UR                  R                  (       a-  U R                  R                  U5        U R                  U5        g U(       a  U R                  R                  USS9  UR                  $ )NT©Úlast)rŸ  rž  rÂ   r—  Úclosedr`  Ú_clear_entry_callbackÚmove_to_end)rY   r£   rº  r¶  s       r   rÂ   Ú_StatementCache.getä	  s‚   € Ø�~�~àà—‘×!Ñ! %Ó(ˆØ‰=Øà×Ñ×"×"ð �M‰M×Ñ˜eÔ$Ø×&Ñ& uÔ-Øæà�M‰M×%Ñ% e°$Ð%Ñ7à×ÑÐr   c                 ó&   • U R                  USS9S L$ )NFr¹  )rÂ   )rY   r£   s     r   rå  Ú_StatementCache.hasû	  s   € Ø�x‰x˜ uˆxÐ-°TÐ9Ð9r   c                 ó„   • U R                   (       d  g U R                  X5      U R                  U'   U R                  5         g r   )rŸ  Ú
_new_entryrž  r¬  )rY   r£   rÒ   s      r   rÐ   Ú_StatementCache.putþ	  s1   € Ø�~�~àà#Ÿ™¨uÓ@ˆ�‰�eÑð 	×ÑÕr   c                 óD   • S U R                   R                  5        5       $ )Nc              3   ó6   #   • U H  oR                   v •  M     g 7fr   )r—  )r"  Úes     r   r$  Ú2_StatementCache.iter_statements.<locals>.<genexpr>

  s   é € Ð=Ñ&< —–Ò&<ùs   ‚)rž  r-  r’   s    r   rÞ  Ú_StatementCache.iter_statements	
  s   € Ù= d§m¡m×&:Ñ&:Ô&<Ó=Ð=r   c                 óè   • [        U R                  R                  5       5      nU R                  R                  5         U H/  nU R	                  U5        U R                  UR                  5        M1     g r   )r”  rž  r-  r¾  r¿  r   r—  )rY   Úentriesr¶  s      r   r¾  Ú_StatementCache.clear
  sW   € ä˜Ÿ™×,Ñ,Ó.Ó/ˆð 	�‰×ÑÔó ˆEØ×&Ñ& uÔ-Ø�O‰O˜E×,Ñ,Ö-ò r   c                 ó¶   • U R                  U5        U R                  (       a7  U R                  R                  U R                  U R                  U5      Ul        g g r   )r¿  r¡  r(   Ú
call_laterÚ_on_entry_expiredr™  ©rY   r¶  s     r   r´  Ú"_StatementCache._set_entry_timeout
  sK   € à×"Ñ" 5Ô)ð ××Ø $§
¡
× 5Ñ 5Ø×"Ñ" D×$:Ñ$:¸Eó!CˆEÕð r   c                 ó@   • [        XU5      nU R                  U5        U$ r   )r•  r´  )rY   r£   rÒ   r¶  s       r   rÅ  Ú_StatementCache._new_entry"
  s!   € Ü$ T°)Ó<ˆØ×Ñ Ô&Øˆr   c                 óÖ   • U R                   R                  UR                  5      UL aA  U R                   R                  UR                  5        U R	                  UR
                  5        g g r   )rž  rÂ   r–  r`  r   r—  rÒ  s     r   rÑ  Ú!_StatementCache._on_entry_expired'
  sL   € ð �=‰=×Ñ˜UŸ\™\Ó*¨eÒ3Ø�M‰M×Ñ˜eŸl™lÔ+Ø�O‰O˜E×,Ñ,Õ-ð 4r   c                 óT   • UR                   b  UR                   R                  5         g g r   )r™  rÔ  rÒ  s     r   r¿  Ú%_StatementCache._clear_entry_callback.
  s%   € Ø×ÑÑ(Ø×Ñ×$Ñ$Õ&ð )r   c                 ó$  • [        U R                  5      U R                  :”  am  U R                  R                  SS9u  pU R	                  U5        U R                  UR                  5        [        U R                  5      U R                  :”  a  Ml  g g )NFr¼  )rÄ   rž  rŸ  Úpopitemr¿  r   r—  )rY   Ú	old_queryÚ	old_entrys      r   r¬  Ú_StatementCache._maybe_cleanup2
  sj   € ä�$—-‘-Ó  4§>¡>Ó1Ø#'§=¡=×#8Ñ#8¸eÐ#8Ð#DÑ ˆIØ×&Ñ& yÔ1ð �O‰O˜I×0Ñ0Ô1ô �$—-‘-Ó  4§>¡>×1r   )rž  r(   r¡  rŸ  r   N)r   r    r!   r"   rq  r^   r¦  r©  r®  r±  r·  rÂ   rå  rÐ   rÞ  r¾  r´  rÅ  rÑ  r¿  r¬  r#   r   r   r   rG   rG   °	  s_   † ð"€Iò2ò2"òòò
"ò+ð %)õ  ò.:ò	ò>ò.òCòò
.ò'õ2r   rG   c                   óz   • \ rS rSr% \R
                  S   \S'   \\S'   \S\R
                  S   SS 4S j5       r	Sr
g)	ro   i=
  ).Nrw   r   r¤   c                 ó¾   • [         R                  " U5      (       a  SnO8[        U5      (       a  SnO%[        R                  " SR                  U5      5      eU " X5      $ )NTFz7expected a callable or an `async def` function,got {!r})ÚinspectÚiscoroutinefunctionrw  r   r|   rb   )r   rw   r   s      r   rp   Ú_Callback.from_callableB
  sT   € ä×&Ò& r×*Ñ*Ø‰HÜ�b�\‰\Ø‰Hä×+Ò+ðß!™6 "›:óð ñ
 �2Ó Ð r   r   N)r   r    r!   r"   rt  ÚCallableÚ__annotations__ra  Úclassmethodrp   r#   r   r   r   ro   ro   =
  s?   ‡ à�‰˜	Ñ"Ó"ØƒNàð!˜vŸ™¨yÑ9ð !¸kó !ó ó!r   ro   c                   ó*   • \ rS rSrSrS rS rS rSrg)rV   iQ
  ©Ú	_acquiredc                 ó   • SU l         g rã  rè  r’   s    r   r^   Ú_Atomic.__init__T
  ó	   € Øˆ�r   c                 ó`   • U R                   (       a  [        R                  " S5      eSU l         g )Nz:cannot perform operation: another operation is in progressr   )ré  r   r|   r’   s    r   Ú	__enter__Ú_Atomic.__enter__W
  s(   € Ø�>�>Ü×+Ò+ØLóNð Nàˆ�r   c                 ó   • SU l         g rã  rè  )rY   ÚtrÉ  Útbs       r   Ú__exit__Ú_Atomic.__exit__]
  rì  r   N)	r   r    r!   r"   rq  r^   rî  ró  r#   r   r   r   rV   rV   Q
  s   † Ø€Iòòõr   rV   c                   ó   • \ rS rSrSrSrg)r   ia
  r   N)r   r    r!   r"   rq  r#   r   r   r   r   r   a
  s   † àƒIr   r   rS  rK  z Log record of an executed query.ÚServerCapabilities©r  r  r  r  r  rU  rÞ   zPostgreSQL server capabilities.c           
      ó  • [        US5      (       a  SnSnSnSnSnSnSnO^[        US5      (       a  SnSnSnSnSnSnSnO>[        US5      (       a  SnSnSnSnSnSnSnOSnSnSnSnSnU S:¬  nU R                  S:¬  n[        UUUUUUUS9$ )	NÚpadb_revisionFTÚcrdb_versionÚcrate_version)é   r   é   r÷  )rv  Úmajorrö  )	rQ   Úconnection_settingsr  r  r  r  r  rÞ   rU  s	            r   rS   rS   t
  sð   € ÜÐ" O×4Ñ4àˆØˆØˆØˆ	ØˆØˆØ#ÑÜ	Ð$ n×	5Ñ	5àˆØˆØˆØˆ	ØˆØˆØ#ÑÜ	Ð$ o×	6Ñ	6àˆØˆØˆØˆ	ØˆØˆØ#Ñð ˆØˆØˆØˆ	ØˆØ Ñ'ˆØ,×2Ñ2°bÑ8ÐäØ%Ø#ØØØ#Ø/Øñð r   c                 ó
  • [         R                  " 5       R                  n [        R                  R                  [        R                  " U5      SS9nA[        R                  S   nSnU[        U5      :  aL  X$   S   R                  U5      (       a1  US-  nU[        U5      :  a  X$   S   R                  U5      (       a  M1  X$X@-    nUR                  5         SR                  [        R                  " U5      5      $ ! Af = f)zdReplacement for traceback.extract_stack() that only does the
necessary work for asyncio debug mode.
F)Úlookup_linesr   r   r½   )ÚsysÚ	_getframeÚf_backÚ	tracebackÚStackSummaryÚextractÚ
walk_stackÚasyncpgÚ__path__rÄ   Ú
startswithÚreverser,  Úformat_list)ré   ÚframeÚstackÚapg_pathÚis        r   rX   rX   ¥
  sâ   € ô �MŠM‹O×"Ñ"€EðÜ×&Ñ&×.Ñ.Ü× Ò  Ó'°eð /ð =ˆð ä×Ñ Ñ"€HØ	€AØ
Œc�%‹j‹.˜U™X a™[×3Ñ3°H×=Ñ=Ø	ˆQ‰ˆð Œc�%‹j‹.˜U™X a™[×3Ñ3°H×=Ó=à�A‘IÐ€Eà	‡M�M„OØ�7‰7”9×(Ò(¨Ó/Ó0Ð0øñ ús   ¡2C? Ã?Dc                 ó¦  • U [         R                  L a  g [        U [        5      (       a„  [	        U [         R                  5      (       ae  U R
                  [         R                  R
                  Ld'  U R                  [         R                  R                  La  [        R                  " S5      eg [        R                  " SR                  U 5      5      e)Nz2record_class must not redefine __new__ or __init__zErecord_class is expected to be a subclass of asyncpg.Record, got {!r})
r
   r�  rÅ   r   r�  Ú__new__r^   r   r|   rb   r  s    r   rÁ   rÁ   º
  s¡   € Ø”x—‘Ò&Øä�<¤×&Ñ&Ü�|¤X§_¡_×5Ñ5ð × Ñ ¬¯©×(?Ñ(?Ò?Ø×$Ñ$¬H¯O©O×,DÑ,DÒDä×+Ò+ØDóð ð Eô ×'Ò'ð'ß'-¡v¨lÓ';ó
ð 	
r   c                 ó<   • U " 5       nUb  UR                  U5        g g r   )ræ  )Úweak_refr¼   rY   s      r   rK   rK   Ï
  s"   € Ù‹:€DØÑØ×Ñ˜DÕ!ð r   r   )r˜  ).r´  r	  r‹  Úcollections.abcrx  rI   r*  rá  rr  r  rP  r  rt  rc   rL   r½   r   r   r   r   r   r	   r
   r   r   r   r   r   r   r�  r“  r•  rG   Ú
NamedTuplero   rV   r   Ú
namedtuplerS  rp  rö  rS   rX   rÁ   rK   rÚ  r   r   r   Ú<module>r     s`  ðó Û Û Û Û Û Û Û Û 	Û 
Û Û Û Û Û å Ý Ý Ý Ý Ý Ý Ý Ý Ý ô<�Tô <ôu˜>ò uðp?
Ø $Ø d°TØØ"ØØØØ'*Ø03Ø/8Ø"&ØØ!Ø#-Ø'Ÿ™Ø"&Ø'+Ø!Øö'
÷D ñ  ÷J2ñ J2ôZ!�×!Ñ!ô !÷(ñ ÷ ñ ð
 ×$Ò$Øòó€ð 9€Ô ð !×+Ò+Øò4ó5Ð ð ?Ð Ô ò.ôb1ò*
ò*"ð 	�r   