From 7f790a7f4965bb0f0908127be2f554b5a4323a60 Mon Sep 17 00:00:00 2001 From: Ashesh Vashi Date: Thu, 12 May 2016 13:08:36 +0530 Subject: [PATCH] Use the same cursor object of a connection object only from the same server. Current implementation keeps the cursor object in the 'g' (current request context) object identified by the connection-id. But - it fails to identify a different connection object request, when we have same database name in different database server, it does not able to identify it as separate request, Hence - now we will use server-id qualified identifier for the same object. Thanks Neel Patel for pointing out the issue. --- web/pgadmin/utils/driver/psycopg2/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/pgadmin/utils/driver/psycopg2/__init__.py b/web/pgadmin/utils/driver/psycopg2/__init__.py index 7128238c1..208b52f2a 100644 --- a/web/pgadmin/utils/driver/psycopg2/__init__.py +++ b/web/pgadmin/utils/driver/psycopg2/__init__.py @@ -342,7 +342,7 @@ WHERE return True, None def __cursor(self): - cur = getattr(g, self.conn_id, None) + cur = getattr(g, str(self.manager.sid) + '#' + self.conn_id, None) if self.connected() and cur and not cur.closed: return True, cur @@ -408,7 +408,7 @@ Attempt to reconnect it failed with the error: else: return False, errmsg - setattr(g, self.conn_id, cur) + setattr(g, str(self.manager.sid) + '#' + self.conn_id, cur) return True, cur