From a69565fc5f6a002c97faea8e6e544ecb17aeae73 Mon Sep 17 00:00:00 2001 From: Alexander Kukushkin Date: Fri, 4 Sep 2015 13:22:44 +0200 Subject: [PATCH] Set Postgresql._SERVER_VERSION only after real connect. --- helpers/postgresql.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/helpers/postgresql.py b/helpers/postgresql.py index 642c48f4..3fc7983a 100644 --- a/helpers/postgresql.py +++ b/helpers/postgresql.py @@ -82,7 +82,7 @@ class Postgresql: r = parseurl('postgres://{}/postgres'.format(self.local_address)) self._connection = psycopg2.connect(**r) self._connection.autocommit = True - Postgresql._SERVER_VERSION = self._connection.server_version + Postgresql._SERVER_VERSION = self._connection.server_version return self._connection def _cursor(self): @@ -358,8 +358,8 @@ recovery_target_timeline = 'latest' def xlog_position(self): lsn = self.query("""SELECT CASE WHEN pg_is_in_recovery() - THEN pg_last_xlog_replay_location() - ELSE pg_current_xlog_location() END""").fetchone()[0] + THEN pg_last_xlog_replay_location() + ELSE pg_current_xlog_location() END""").fetchone()[0] return self.lsn_to_bytes(lsn) def load_replication_slots(self):