From eb3d3980e03df792afb7d53c9470827c29e6e4a2 Mon Sep 17 00:00:00 2001 From: Ashesh Vashi Date: Fri, 8 Feb 2019 10:10:55 +0530 Subject: [PATCH] Use 'set_config(...)' function to update the 'bytea_output' settings instead of 'UPDATE' statement, which is not allowed in the the read-only instances. Reported by: Robert J. Rotter Solution provided by: Tom Lane Fixes #3973 --- web/pgadmin/utils/driver/psycopg2/connection.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/web/pgadmin/utils/driver/psycopg2/connection.py b/web/pgadmin/utils/driver/psycopg2/connection.py index f584ab60b..bbbf0bc76 100644 --- a/web/pgadmin/utils/driver/psycopg2/connection.py +++ b/web/pgadmin/utils/driver/psycopg2/connection.py @@ -406,12 +406,14 @@ class Connection(BaseConnection): # Note that we use 'UPDATE pg_settings' for setting bytea_output as a # convenience hack for those running on old, unsupported versions of # PostgreSQL 'cos we're nice like that. - status = _execute(cur, "SET DateStyle=ISO; " - "SET client_min_messages=notice;" - "UPDATE pg_settings SET setting = 'escape'" - " WHERE name = 'bytea_output';" - "SET client_encoding='{0}';" - .format(postgres_encoding)) + status = _execute( + cur, + "SET DateStyle=ISO; " + "SET client_min_messages=notice; " + "SELECT set_config('bytea_output','escape',false) FROM pg_settings" + " WHERE name = 'bytea_output'; " + "SET client_encoding='{0}';".format(postgres_encoding) + ) if status is not None: self.conn.close()