diff --git a/docs/en_US/release_notes_5_7.rst b/docs/en_US/release_notes_5_7.rst index fbcebac32..1474d58df 100644 --- a/docs/en_US/release_notes_5_7.rst +++ b/docs/en_US/release_notes_5_7.rst @@ -10,6 +10,7 @@ New features ************ | `Issue #4264 `_ - Make code folding case insensitive in the code mirror. +| `Issue #6691 `_ - Set PSQLRC and PSQL_HISTORY env vars to apt. user storage path in the server mode. Housekeeping ************ diff --git a/web/pgadmin/tools/psql/__init__.py b/web/pgadmin/tools/psql/__init__.py index 1bd57066b..99b1cd62a 100644 --- a/web/pgadmin/tools/psql/__init__.py +++ b/web/pgadmin/tools/psql/__init__.py @@ -109,6 +109,13 @@ def panel(trans_id): # Set TERM env for xterm. os.environ['TERM'] = 'xterm' + # If psql is enabled in server mode, set psqlrc and hist paths + # to individual user storage. + if config.ENABLE_PSQL and config.SERVER_MODE: + os.environ['PSQLRC'] = get_complete_file_path('.psqlrc', False) + os.environ['PSQL_HISTORY'] = \ + get_complete_file_path('.psql_history', False) + o_db_name = _get_database(params['sid'], params['did']) return render_template('editor_template.html', diff --git a/web/pgadmin/utils/__init__.py b/web/pgadmin/utils/__init__.py index c10500e94..11d742b97 100644 --- a/web/pgadmin/utils/__init__.py +++ b/web/pgadmin/utils/__init__.py @@ -241,7 +241,7 @@ else: return os.path.realpath(os.path.expanduser('~/')) -def get_complete_file_path(file): +def get_complete_file_path(file, validate=True): """ Args: file: File returned by file manager @@ -266,7 +266,10 @@ def get_complete_file_path(file): file = file.replace('\\', '/') file = fs_short_path(file) - return file if os.path.isfile(file) else None + if validate: + return file if os.path.isfile(file) else None + else: + return file def does_utility_exist(file):