From 08990cb1de091a21d23135c8318bbd24bd10e8c5 Mon Sep 17 00:00:00 2001 From: Akshay Joshi Date: Mon, 28 May 2018 17:35:33 -0400 Subject: [PATCH] Handle errors properly if they occur when renaming a database. Fixes #3353 --- docs/en_US/release_notes_3_1.rst | 3 ++- .../server_groups/servers/databases/__init__.py | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/en_US/release_notes_3_1.rst b/docs/en_US/release_notes_3_1.rst index 32ae1703a..4dea08242 100644 --- a/docs/en_US/release_notes_3_1.rst +++ b/docs/en_US/release_notes_3_1.rst @@ -31,4 +31,5 @@ Bug fixes | `Bug #3307 `_ - Allow connections to servers with port numbers < 1024 which may be seen in container environments | `Bug #3324 `_ - Fix the template loader to work reliably under Windows (fixing external tables under Greenplum) | `Bug #3333 `_ - Ensure the runtime core application is setup before trying to access any settings -| `Bug #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 \ No newline at end of file +| `Bug #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 `_ - Handle errors properly if they occur when renaming a database \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/__init__.py index f3471efad..4590d6ca1 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/__init__.py @@ -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