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

@ -32,3 +32,4 @@ Bug fixes
| `Bug #3324 <https://redmine.postgresql.org/issues/3324>`_ - Fix the template loader to work reliably under Windows (fixing external tables under Greenplum) | `Bug #3324 <https://redmine.postgresql.org/issues/3324>`_ - Fix the template loader to work reliably under Windows (fixing external tables under Greenplum)
| `Bug #3333 <https://redmine.postgresql.org/issues/3333>`_ - Ensure the runtime core application is setup before trying to access any settings | `Bug #3333 <https://redmine.postgresql.org/issues/3333>`_ - Ensure the runtime core application is setup before trying to access any settings
| `Bug #3342 <https://redmine.postgresql.org/issues/3342>`_ - Set SESSION_COOKIE_SAMESITE='Lax' per Flask recommendation to prevents sending cookies with CSRF-prone requests from external sites, such as submitting a form | `Bug #3342 <https://redmine.postgresql.org/issues/3342>`_ - Set SESSION_COOKIE_SAMESITE='Lax' per Flask recommendation to prevents sending cookies with CSRF-prone requests from external sites, such as submitting a form
| `Bug #3353 <https://redmine.postgresql.org/issues/3353>`_ - Handle errors properly if they occur when renaming a database

View File

@ -634,6 +634,17 @@ class DatabaseView(PGChildNodeView):
if SQL and SQL != "": if SQL and SQL != "":
status, msg = conn.execute_scalar(SQL) status, msg = conn.execute_scalar(SQL)
if not status: 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) return internal_server_error(errormsg=msg)
# Make connection for database again # Make connection for database again