From 665e9dc665cf72086c00871756c48e8d38bade2f Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Sat, 4 Feb 2017 14:43:54 +0000 Subject: [PATCH] Exposing ISOLATION_LEVEL_DEFAULT to Python This is now the state that is returned to Python if nothing has been explicitly set. --- doc/src/extensions.rst | 9 +++++++++ lib/extensions.py | 1 + tests/test_connection.py | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/doc/src/extensions.rst b/doc/src/extensions.rst index 8d70ba38..2475d7b6 100644 --- a/doc/src/extensions.rst +++ b/doc/src/extensions.rst @@ -651,6 +651,15 @@ set to one of the following constants: .. __: http://www.postgresql.org/docs/current/static/transaction-iso.html#XACT-SERIALIZABLE +.. data:: ISOLATION_LEVEL_DEFAULT + + Whatever is defined by the server, either via server configuration or by + statements executed within the session outside Pyscopg control; Psycopg + will not force an isolation level of its own. If you want to know what the + value is you can use a query such as :sql:`show transaction_isolation` or + :sql:`show default_transaction_isolation`. + + .. versionadded:: 2.7 .. index:: diff --git a/lib/extensions.py b/lib/extensions.py index b123e881..f4dc706f 100644 --- a/lib/extensions.py +++ b/lib/extensions.py @@ -72,6 +72,7 @@ ISOLATION_LEVEL_READ_UNCOMMITTED = 4 ISOLATION_LEVEL_READ_COMMITTED = 1 ISOLATION_LEVEL_REPEATABLE_READ = 2 ISOLATION_LEVEL_SERIALIZABLE = 3 +ISOLATION_LEVEL_DEFAULT = 5 """psycopg connection status values.""" diff --git a/tests/test_connection.py b/tests/test_connection.py index 15d99b40..5b304ee4 100755 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -488,7 +488,7 @@ class IsolationLevelsTestCase(ConnectingTestCase): conn = self.connect() self.assertEqual( conn.isolation_level, - psycopg2.extensions.ISOLATION_LEVEL_READ_COMMITTED) + psycopg2.extensions.ISOLATION_LEVEL_DEFAULT) def test_encoding(self): conn = self.connect()