
    gi
                    t   U d Z ddlmZ ddlZddlmZmZ ddlmZ	 ddlm
Z
 ddlmZmZ dd	lmZmZ dd
lmZ ddlmZmZmZ ddlmZ erddlmZ ddlmZmZ ddlmZ ddl m!Z! dZ"de#d<   e
j$        j%        Z%e
j$        j&        Z&e
j'        j(        Z(e
j)        j*        Z* ej+        d          Z, G d d          Z-dS )z
commands pipeline management
    )annotationsN)TYPE_CHECKINGAny   )errors)pq)PipelineCommandPQGen)Deque	TypeAlias)connection_summary)
fetch_manypipeline_communicatesend)capabilities)PGresult)KeyPrepare)
BaseCursor)BaseConnectionzEtuple[BaseCursor[Any, Any], tuple[Key, Prepare, bytes] | None] | Noner   PendingResultpsycopgc                      e Zd ZU ded<   ded<   d!d	Zd"dZed#d            Zed$d            Z	d%dZ
d&dZd%dZd%dZd%dZd'dZd(dZd)dZd S )*BasePipelinezDeque[PipelineCommand]command_queuezDeque[PendingResult]result_queueconnBaseConnection[Any]returnNonec                    || _         |j        | _        t          t                               | _        t          t
                               | _        d| _        d S )Nr   )_connpgconnr   r	   r   r   r   level)selfr   s     f/var/www/html/Pagina-Ingenieria-Requisitos/venv/lib/python3.11/site-packages/psycopg/_pipeline_base.py__init__zBasePipeline.__init__,   sC    
k"?355!-022


    strc                    | j         j         d| j         j         }t          | j        j                  }d| d| dt          |           ddS )N.< z at 0xx>)	__class__
__module____qualname__r   r"   r#   id)r%   clsinfos      r&   __repr__zBasePipeline.__repr__3   s[    *JJT^-HJJ!$*"344232222RXX22222r(   pq.PipelineStatusc                >    t          j        | j        j                  S )N)r   PipelineStatusr#   pipeline_statusr%   s    r&   statuszBasePipeline.status8   s     !<===r(   boolc                (    t          j                    S )zCReturn `!True` if the psycopg libpq wrapper supports pipeline mode.)r   has_pipeline)r4   s    r&   is_supportedzBasePipeline.is_supported<   s     (***r(   PQGen[None]c              #  
  K   t          j        d           | j        dk    r| j                                         n6| j        s| j        j        t          k    r|                                 E d {V  | xj        dz  c_        d S )NT)checkr   r   )	r   r?   r$   r#   enter_pipeline_moder   transaction_statusACTIVE	_sync_genr;   s    r&   
_enter_genzBasePipeline._enter_genA   s      !----:??K++---- 	(4;#AV#K#K ~~'''''''''

a



r(   excBaseException | Nonec                D   | xj         dz  c_         | j         dk    r| j        j        t          k    ro	 | j                                         d S # t
          j        $ r?}|rt                              d| |           n|	                    d           Y d }~d S d }~ww xY wd S d S )Nr   r   zerror ignored exiting %r: %s)
r$   r#   r<   BADexit_pipeline_modeeOperationalErrorloggerwarningwith_traceback)r%   rI   exc2s      r&   _exitzBasePipeline._exitO   s    

a

:??t{1S88	4..00000% 4 4 4  4NN#A4NNNN--d333 ONNNNN4 ?88s   A B4BBc              #     K   |                                   |                                 E d {V  |                     d          E d {V  d S )NFflush_enqueue_sync_communicate_gen
_fetch_genr;   s    r&   rG   zBasePipeline._sync_gen]   sh      ((*********???///////////r(   c              #     K   	 |                                   |                                 E d{V  |                     d          E d{V  dS # |                     d          E d{V  w xY w)z_
        Exit current pipeline by sending a Sync and fetch back all remaining results.
        NTrV   rX   r;   s    r&   	_exit_genzBasePipeline._exit_genb   s      	3   ,,.........T22222222222tT2222222222s   .A A.c              #     K   t          | j        | j                  E d{V }d}|D ]R}| j                                        }	 |                     ||           3# t          j        $ r}||}Y d}~Kd}~ww xY w||dS )zqCommunicate with pipeline to send commands and possibly fetch
        results, which are then processed.
        N)r   r#   r   r   popleft_process_resultsrN   Error)r%   fetched	exceptionresultsqueuedrI   s         r&   rZ   zBasePipeline._communicate_genl   s       2$+t?QRRRRRRRR	 	$ 	$G&..00F$%%fg66667 $ $ $$ #I$  O ! s   AA7)A22A7rW   c             #    K   | j         sdS |r3| j                                         t          | j                  E d{V  d}| j         rut	          | j                  E d{V x}snX| j                                         }	 |                     ||           n # t          j        $ r}||}Y d}~nd}~ww xY w| j         u||dS )a^  Fetch available results from the connection and process them with
        pipeline queued items.

        If 'flush' is True, a PQsendFlushRequest() is issued in order to make
        sure results can be fetched. Otherwise, the caller may emit a
        PQpipelineSync() call to ensure the output buffer gets flushed before
        fetching.
        N)	r   r#   send_flush_requestr   r   r_   r`   rN   ra   )r%   rW   rc   rd   re   rI   s         r&   r[   zBasePipeline._fetch_gen|   s        	F 	)K**,,,DK(((((((((	 
	$+5dk+B+B B B B B B BCG  &..00F$%%fg66667 $ $ $$ #I$  
	$  O ! s   B B5'B00B5re   r   rd   list[PGresult]c                p   |Z|\  }|j         t          k    r t          j        || j        j                  |j         t          k    rt          j        d          dS |\  }}|r(|\  }}}|j        j	        
                    ||||           |                    |           |                    |           dS )ar  Process a results set fetched from the current pipeline.

        This matches 'results' with its respective element in the pipeline
        queue. For commands (None value in the pipeline queue), results are
        checked directly. For prepare statement creation requests, update the
        cache. Otherwise, results are attached to their respective cursor.
        N)encodingzpipeline aborted)r<   FATAL_ERRORrN   error_from_resultr#   	_encodingPIPELINE_ABORTEDPipelineAbortedr"   	_preparedvalidate_check_results_set_results)	r%   re   rd   resultcursorprepinfokeyprepnames	            r&   r`   zBasePipeline._process_results   s     >IV}++)&4;;PQQQQ"222'(:;;; 32  &FH J"*T4&//T4III!!'***(((((r(   c                    | j                             | j        j                   | j                            d           dS )z#Enqueue a PQpipelineSync() command.N)r   appendr#   pipeline_syncr   r;   s    r&   rY   zBasePipeline._enqueue_sync   s;    !!$+";<<<  &&&&&r(   N)r   r   r   r    )r   r)   )r   r7   )r   r=   )r   rA   )rI   rJ   r   r    )rW   r=   r   rA   )re   r   rd   rh   r   r    )r   r    )__name__r1   r2   __annotations__r'   r6   propertyr<   classmethodr@   rH   rT   rG   r]   rZ   r[   r`   rY    r(   r&   r   r   (   s6        ))))&&&&   3 3 3 3
 > > > X> + + + [+   4 4 4 40 0 0 0
3 3 3 3       >) ) ) ).' ' ' ' ' 'r(   r   ).__doc__
__future__r   loggingtypingr   r    r   rN   r   abcr	   r
   _compatr   r   pq.miscr   
generatorsr   r   r   _capabilitiesr   pq.abcr   
_preparingr   r   _cursor_baser   _connection_baser   r   r~   
ExecStatusrk   rn   
ConnStatusrL   TransactionStatusrF   	getLoggerrP   r   r   r(   r&   <module>r      s     # " " " " "  % % % % % % % %             ' ' ' ' ' ' ' ' % % % % % % % % ' ' ' ' ' ' > > > > > > > > > > ' ' ' ' ' ' 1      ((((((((((((((000000 L      m'=1 m			$		9	%	%M' M' M' M' M' M' M' M' M' M'r(   