summaryrefslogtreecommitdiff
path: root/django/db/backends/postgresql/version.py
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2017-03-01 13:17:34 -0500
committerTim Graham <timograham@gmail.com>2017-03-01 13:17:34 -0500
commit29ea9714ee23525000dd8bdb7a9aafb2147de8c7 (patch)
treef2d2217735ac8b769449684a8303a63a7e9833c6 /django/db/backends/postgresql/version.py
parent49a63d08d3b3e2ac32e391d1413a4ac99429e4af (diff)
downloaddjango-29ea9714ee23525000dd8bdb7a9aafb2147de8c7.tar.gz
Removed PostgreSQL version detection for psycopg2 < 2.0.12.
Diffstat (limited to 'django/db/backends/postgresql/version.py')
-rw-r--r--django/db/backends/postgresql/version.py44
1 files changed, 0 insertions, 44 deletions
diff --git a/django/db/backends/postgresql/version.py b/django/db/backends/postgresql/version.py
deleted file mode 100644
index 3b219159f5..0000000000
--- a/django/db/backends/postgresql/version.py
+++ /dev/null
@@ -1,44 +0,0 @@
-"""
-Extract the version of the PostgreSQL server.
-"""
-
-import re
-
-# This reg-exp is intentionally fairly flexible here.
-# Needs to be able to handle stuff like:
-# PostgreSQL #.#.#
-# EnterpriseDB #.#
-# PostgreSQL #.# beta#
-# PostgreSQL #.#beta#
-VERSION_RE = re.compile(r'\S+ (\d+)\.(\d+)\.?(\d+)?')
-
-
-def _parse_version(text):
- "Internal parsing method. Factored out for testing purposes."
- major, major2, minor = VERSION_RE.search(text).groups()
- try:
- return int(major) * 10000 + int(major2) * 100 + int(minor)
- except (ValueError, TypeError):
- return int(major) * 10000 + int(major2) * 100
-
-
-def get_version(connection):
- """
- Return 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.
- """
- if hasattr(connection, 'server_version'):
- return connection.server_version
- else:
- with connection.cursor() as cursor:
- cursor.execute("SELECT version()")
- return _parse_version(cursor.fetchone()[0])