Handle errors properly if they occur when renaming a database. Fixes #3353

This commit is contained in:
Akshay Joshi
2018-05-28 17:35:33 -04:00
committed by Dave Page
parent 9f13865777
commit 08990cb1de
2 changed files with 13 additions and 1 deletions

View File

@@ -634,6 +634,17 @@ class DatabaseView(PGChildNodeView):
if SQL and SQL != "":
status, msg = conn.execute_scalar(SQL)
if not status:
# In case of error from server while rename it,
# reconnect to the database with old name again.
self.conn = self.manager.connection(
database=data['old_name'], auto_reconnect=True
)
status, errmsg = self.conn.connect()
if not status:
current_app.logger.error(
'Could not reconnected to database(#{0}).\n'
'Error: {1}'.format(did, errmsg)
)
return internal_server_error(errormsg=msg)
# Make connection for database again