
 X                 @   s=   d  Z  d d l Z e j d  Z d d   Z d d   Z d S)z0
Extracts the version of the PostgreSQL server.
    Nz\S+ (\d+)\.(\d+)\.?(\d+)?c             C   s   t  j |   j   \ } } } y* t |  d t |  d t |  SWn4 t t f k
 r~ t |  d t |  d SYn Xd S)z;Internal parsing method. Factored out for testing purposes.i'  d   N)
VERSION_REsearchgroupsint
ValueError	TypeError)textmajorZmajor2minor r   S/home/ubuntu/projects/ifolica/build/django/django/db/backends/postgresql/version.py_parse_version   s
    *r   c          
   C   sP   t  |  d  r |  j S|  j   ( } | j d  t | j   d  SWd QXd S)a\  
    Returns an integer representing the major, minor and revision number of the
    server. Format is the one used for the return value of libpq
    PQServerVersion()/``server_version`` connection attribute (available in
    newer psycopg2 versions.)

    For example, 90304 for 9.3.4. The last two digits will be 00 in the case of
    releases (e.g., 90400 for 'PostgreSQL 9.4') or in the case of beta and
    prereleases (e.g. 90100 for 'PostgreSQL 9.1beta2').

    PQServerVersion()/``server_version`` doesn't execute a query so try that
    first, then fallback to a ``SELECT version()`` query.
    server_versionzSELECT version()r   N)hasattrr   cursorexecuter   Zfetchone)
connectionr   r   r   r   get_version   s
    r   )__doc__recompiler   r   r   r   r   r   r   <module>   s   	