diff --git a/docs/en_US/release_notes_7_5.rst b/docs/en_US/release_notes_7_5.rst index e3948be4d..8b1455bc9 100644 --- a/docs/en_US/release_notes_7_5.rst +++ b/docs/en_US/release_notes_7_5.rst @@ -40,10 +40,12 @@ Bug fixes | `Issue #6317 `_ - Fix an issue where queries longer than 1 minute get stuck - Container 7.1 | `Issue #6356 `_ - Fix an issue where queries get stuck with auto-completion enabled. | `Issue #6364 `_ - Fixed Query Tool/ PSQL tool tab title not getting updated on database rename. + | `Issue #6499 `_ - Ensure that Backup, Restore, and Maintenance should work properly when pgpass file is used. | `Issue #6501 `_ - Fix the query tool auto-complete issue on the server reconnection. | `Issue #6502 `_ - Fix the query tool restore connection issue. | `Issue #6509 `_ - Fix the reconnecton issue if the PostgreSQL server is restarted from the backend. | `Issue #6514 `_ - Fix the connection and stability issues since v7, possibly related to background schema changes. | `Issue #6515 `_ - Fixed an issue where the query tool is unable to execute a query on Postgres 10 and below versions. | `Issue #6524 `_ - Fix the lost connection error in v7.4. + | `Issue #6537 `_ - Fixed an issue where filters are not working and query history shows empty queries. | `Issue #6544 `_ - Fix an issue where adding a sub-folder inside a folder is not working as expected in File Manager. diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py index 382467a29..41a1addd3 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py @@ -2256,19 +2256,9 @@ class MViewNode(ViewNode, VacuumSettings): try: p = BatchProcess( desc=Message(sid, data, SQL), - cmd=utility, args=args + cmd=utility, args=args, manager_obj=manager ) - manager.export_password_env(p.id) - # Check for connection timeout and if it is greater than 0 - # then set the environment variable PGCONNECT_TIMEOUT. - timeout = manager.get_connection_param_value('connect_timeout') - if timeout and int(timeout) > 0: - env = dict() - env['PGCONNECT_TIMEOUT'] = str(timeout) - p.set_env_variables(server, env=env) - else: - p.set_env_variables(server) - + p.set_env_variables(server) p.start() jid = p.id except Exception as e: diff --git a/web/pgadmin/misc/bgprocess/processes.py b/web/pgadmin/misc/bgprocess/processes.py index d3ca55481..4847b7624 100644 --- a/web/pgadmin/misc/bgprocess/processes.py +++ b/web/pgadmin/misc/bgprocess/processes.py @@ -15,7 +15,7 @@ import csv import os import sys import psutil -from abc import ABCMeta, abstractproperty, abstractmethod +from abc import ABCMeta, abstractmethod from datetime import datetime, timedelta from pickle import dumps, loads from subprocess import Popen, PIPE @@ -70,16 +70,16 @@ class IProcessDesc(metaclass=ABCMeta): if config.SERVER_MODE: - file = self.bfile + process_file = self.bfile try: # check if file name is encoded with UTF-8 - file = self.bfile.decode('utf-8') + process_file = self.bfile.decode('utf-8') except Exception: # do nothing if bfile is not encoded. pass - path = get_complete_file_path(file) - path = file if path is None else path + path = get_complete_file_path(process_file) + path = process_file if path is None else path if IS_WIN: path = os.path.realpath(path) @@ -91,7 +91,7 @@ class IProcessDesc(metaclass=ABCMeta): end = start + (len(storage_directory)) last_dir = os.path.dirname(path[end:]) else: - last_dir = file + last_dir = process_file last_dir = replace_path_for_win(last_dir) @@ -111,12 +111,12 @@ def replace_path_for_win(last_dir=None): return last_dir -class BatchProcess(): +class BatchProcess: def __init__(self, **kwargs): self.id = self.desc = self.cmd = self.args = self.log_dir = \ self.stdout = self.stderr = self.stime = self.etime = \ - self.ecode = None + self.ecode = self.manager_obj = None self.env = dict() if 'id' in kwargs: @@ -131,6 +131,9 @@ class BatchProcess(): kwargs['desc'], _cmd, kwargs['args'] ) + if 'manager_obj' in kwargs: + self.manager_obj = kwargs['manager_obj'] + def _retrieve_process(self, _id): p = Process.query.filter_by(pid=_id, user_id=current_user.id).first() @@ -833,6 +836,25 @@ class BatchProcess(): if server.service: self.env['PGSERVICE'] = server.service + if self.manager_obj: + # Set the PGPASSFILE environment variable + if self.manager_obj.connection_params and \ + isinstance(self.manager_obj.connection_params, dict) and \ + 'passfile' in self.manager_obj.connection_params and \ + self.manager_obj.connection_params['passfile']: + self.env['PGPASSFILE'] = get_complete_file_path( + self.manager_obj.connection_params['passfile']) + + # Check for connection timeout and if it is greater than 0 then + # set the environment variable PGCONNECT_TIMEOUT. + timeout = self.manager_obj.get_connection_param_value( + 'connect_timeout') + if timeout and int(timeout) > 0: + self.env['PGCONNECT_TIMEOUT'] = str(timeout) + + # export password environment + self.manager_obj.export_password_env(self.id) + if 'env' in kwargs: self.env.update(kwargs['env']) diff --git a/web/pgadmin/tools/backup/__init__.py b/web/pgadmin/tools/backup/__init__.py index 70e56ed9a..adc0c177d 100644 --- a/web/pgadmin/tools/backup/__init__.py +++ b/web/pgadmin/tools/backup/__init__.py @@ -437,7 +437,7 @@ def create_backup_objects_job(sid): *args, database=data['database'] ), - cmd=utility, args=escaped_args + cmd=utility, args=escaped_args, manager_obj=manager ) else: p = BatchProcess( @@ -447,20 +447,10 @@ def create_backup_objects_job(sid): server.id, bfile, *args ), - cmd=utility, args=escaped_args + cmd=utility, args=escaped_args, manager_obj=manager ) - manager.export_password_env(p.id) - # Check for connection timeout and if it is greater than 0 then - # set the environment variable PGCONNECT_TIMEOUT. - timeout = manager.get_connection_param_value('connect_timeout') - if timeout and int(timeout) > 0: - env = dict() - env['PGCONNECT_TIMEOUT'] = str(timeout) - p.set_env_variables(server, env=env) - else: - p.set_env_variables(server) - + p.set_env_variables(server) p.start() jid = p.id except Exception as e: diff --git a/web/pgadmin/tools/import_export/__init__.py b/web/pgadmin/tools/import_export/__init__.py index 6439f3272..7a7423c50 100644 --- a/web/pgadmin/tools/import_export/__init__.py +++ b/web/pgadmin/tools/import_export/__init__.py @@ -328,15 +328,10 @@ def create_import_export_job(sid): *args, **io_params ), - cmd=utility, args=args + cmd=utility, args=args, manager_obj=manager ) - manager.export_password_env(p.id) env = dict() - - if manager.service: - env['PGSERVICE'] = manager.service - env['PGHOST'] = \ manager.local_bind_host if manager.use_ssh_tunnel else server.host env['PGPORT'] = \ @@ -350,14 +345,6 @@ def create_import_export_job(sid): if value is None: del env[key] - # Export PGPASSFILE to work with PGPASSFILE authenthification - if manager.connection_params \ - and isinstance(manager.connection_params, dict): - if 'passfile' in manager.connection_params \ - and manager.connection_params['passfile']: - env['PGPASSFILE'] = get_complete_file_path( - manager.connection_params['passfile']) - p.set_env_variables(server, env=env) p.start() jid = p.id diff --git a/web/pgadmin/tools/maintenance/__init__.py b/web/pgadmin/tools/maintenance/__init__.py index dcb52d24d..1be06461e 100644 --- a/web/pgadmin/tools/maintenance/__init__.py +++ b/web/pgadmin/tools/maintenance/__init__.py @@ -246,19 +246,9 @@ def create_maintenance_job(sid, did): try: p = BatchProcess( desc=Message(server.id, data, query), - cmd=utility, args=args + cmd=utility, args=args, manager_obj=manager ) - manager.export_password_env(p.id) - # Check for connection timeout and if it is greater than 0 then - # set the environment variable PGCONNECT_TIMEOUT. - timeout = manager.get_connection_param_value('connect_timeout') - if timeout and int(timeout) > 0: - env = dict() - env['PGCONNECT_TIMEOUT'] = str(timeout) - p.set_env_variables(server, env=env) - else: - p.set_env_variables(server) - + p.set_env_variables(server) p.start() jid = p.id except Exception as e: diff --git a/web/pgadmin/tools/restore/__init__.py b/web/pgadmin/tools/restore/__init__.py index 95fa29c03..bf15fcf4b 100644 --- a/web/pgadmin/tools/restore/__init__.py +++ b/web/pgadmin/tools/restore/__init__.py @@ -377,19 +377,9 @@ def create_restore_job(sid): *args, database=data['database'] ), - cmd=utility, args=args + cmd=utility, args=args, manager_obj=manager ) - manager.export_password_env(p.id) - # Check for connection timeout and if it is greater than 0 then - # set the environment variable PGCONNECT_TIMEOUT. - timeout = manager.get_connection_param_value('connect_timeout') - if timeout and int(timeout) > 0: - env = dict() - env['PGCONNECT_TIMEOUT'] = str(timeout) - p.set_env_variables(server, env=env) - else: - p.set_env_variables(server) - + p.set_env_variables(server) p.start() jid = p.id except Exception as e: