mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Disconnect the database connection only once not every time before
running the offline queries i.e. renaming of the database, using different tablespce for the database, etc.
This commit is contained in:
committed by
Ashesh Vashi
parent
3d134a3d07
commit
a3d23a65bb
@@ -290,10 +290,7 @@ class DatabaseView(NodeView):
|
|||||||
def formatdbacl(res, dbacl):
|
def formatdbacl(res, dbacl):
|
||||||
for row in dbacl:
|
for row in dbacl:
|
||||||
priv = parse_priv_from_db(row)
|
priv = parse_priv_from_db(row)
|
||||||
if row['deftype'] in res['rows'][0]:
|
res['rows'][0].setdefault(row['deftype'], []).append(priv)
|
||||||
res['rows'][0][row['deftype']].append(priv)
|
|
||||||
else:
|
|
||||||
res['rows'][0][row['deftype']] = [priv]
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def module_js(self):
|
def module_js(self):
|
||||||
@@ -500,22 +497,21 @@ class DatabaseView(NodeView):
|
|||||||
data['name'] = name
|
data['name'] = name
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
status = self.manager.release(did=did)
|
||||||
|
conn = self.manager.connection()
|
||||||
for action in ["rename_database", "tablespace"]:
|
for action in ["rename_database", "tablespace"]:
|
||||||
SQL = self.getOfflineSQL(gid, sid, data, did, action)
|
SQL = self.getOfflineSQL(gid, sid, data, did, action)
|
||||||
SQL = SQL.strip('\n').strip(' ')
|
SQL = SQL.strip('\n').strip(' ')
|
||||||
if SQL and SQL != "":
|
if SQL and SQL != "":
|
||||||
status = self.manager.release(did=did)
|
|
||||||
|
|
||||||
conn = self.manager.connection()
|
|
||||||
status, msg = conn.execute_scalar(SQL)
|
status, msg = conn.execute_scalar(SQL)
|
||||||
|
|
||||||
if not status:
|
if not status:
|
||||||
return internal_server_error(errormsg=msg)
|
return internal_server_error(errormsg=msg)
|
||||||
|
|
||||||
self.conn = self.manager.connection(database=data['name'], auto_reconnect=True)
|
|
||||||
status, errmsg = self.conn.connect()
|
|
||||||
info = "Database updated."
|
info = "Database updated."
|
||||||
|
|
||||||
|
self.conn = self.manager.connection(database=data['name'], auto_reconnect=True)
|
||||||
|
status, errmsg = self.conn.connect()
|
||||||
|
|
||||||
SQL = self.getOnlineSQL(gid, sid, data, did)
|
SQL = self.getOnlineSQL(gid, sid, data, did)
|
||||||
SQL = SQL.strip('\n').strip(' ')
|
SQL = SQL.strip('\n').strip(' ')
|
||||||
if SQL and SQL != "":
|
if SQL and SQL != "":
|
||||||
|
|||||||
Reference in New Issue
Block a user