mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Update the user and datbaase information everytime, we connect the
server. And, delete them as soon as all connections are released.
This commit is contained in:
@@ -190,7 +190,7 @@ Failed to fetch the version information on the established connection to the dat
|
|||||||
)
|
)
|
||||||
return False, res
|
return False, res
|
||||||
|
|
||||||
status, res = self.execute_dict("""
|
status, res = self.execute_dict("""
|
||||||
SELECT
|
SELECT
|
||||||
db.oid as did, db.datname, db.datallowconn, pg_encoding_to_char(db.encoding) AS serverencoding,
|
db.oid as did, db.datname, db.datallowconn, pg_encoding_to_char(db.encoding) AS serverencoding,
|
||||||
has_database_privilege(db.oid, 'CREATE') as cancreate, datlastsysoid
|
has_database_privilege(db.oid, 'CREATE') as cancreate, datlastsysoid
|
||||||
@@ -198,12 +198,12 @@ FROM
|
|||||||
pg_database db
|
pg_database db
|
||||||
WHERE db.datname = current_database()""")
|
WHERE db.datname = current_database()""")
|
||||||
|
|
||||||
if status:
|
if status:
|
||||||
mgr.db_info = dict()
|
mgr.db_info = dict()
|
||||||
f_row = res['rows'][0]
|
f_row = res['rows'][0]
|
||||||
mgr.db_info[f_row['did']] = f_row.copy()
|
mgr.db_info[f_row['did']] = f_row.copy()
|
||||||
|
|
||||||
status, res = self.execute_dict("""
|
status, res = self.execute_dict("""
|
||||||
SELECT
|
SELECT
|
||||||
oid as id, rolname as name, rolsuper as is_superuser,
|
oid as id, rolname as name, rolsuper as is_superuser,
|
||||||
rolcreaterole as can_create_role, rolcreatedb as can_create_db
|
rolcreaterole as can_create_role, rolcreatedb as can_create_db
|
||||||
@@ -212,10 +212,10 @@ FROM
|
|||||||
WHERE
|
WHERE
|
||||||
rolname = current_user""")
|
rolname = current_user""")
|
||||||
|
|
||||||
if status:
|
if status:
|
||||||
mgr.user_info = dict()
|
mgr.user_info = dict()
|
||||||
f_row = res['rows'][0]
|
f_row = res['rows'][0]
|
||||||
mgr.user_info = f_row.copy()
|
mgr.user_info = f_row.copy()
|
||||||
|
|
||||||
if 'password' in kwargs:
|
if 'password' in kwargs:
|
||||||
mgr.password = kwargs['password']
|
mgr.password = kwargs['password']
|
||||||
@@ -617,6 +617,12 @@ WHERE db.oid = {0}""".format(did))
|
|||||||
self.connections[my_id]._release()
|
self.connections[my_id]._release()
|
||||||
del self.connections[my_id]
|
del self.connections[my_id]
|
||||||
|
|
||||||
|
if len(self.connections) == 0:
|
||||||
|
self.ver = None
|
||||||
|
self.sversion = None
|
||||||
|
self.server_type = None
|
||||||
|
self.password = None
|
||||||
|
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
@@ -625,6 +631,9 @@ WHERE db.oid = {0}""".format(did))
|
|||||||
self.connections[con]._release()
|
self.connections[con]._release()
|
||||||
|
|
||||||
self.connections = dict()
|
self.connections = dict()
|
||||||
|
self.ver = None
|
||||||
|
self.sversion = None
|
||||||
|
self.server_type = None
|
||||||
self.password = None
|
self.password = None
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|||||||
Reference in New Issue
Block a user