Skip to content

Commit 0ef4d9c

Browse files
committed
Fixed an issue where utilities such as pg_dump and pg_restore failed to log error messages when required dependency files were missing. #7466
1 parent 4a4d456 commit 0ef4d9c

3 files changed

Lines changed: 35 additions & 2 deletions

File tree

docs/en_US/release_notes_9_5.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@ Bug fixes
2929
*********
3030

3131
| `Issue #6118 <https://github.com/pgadmin-org/pgadmin4/issues/6118>`_ - Improved PL/pgSQL code folding and support nested blocks.
32+
| `Issue #7466 <https://github.com/pgadmin-org/pgadmin4/issues/7466>`_ - Fixed an issue where utilities such as pg_dump and pg_restore failed to log error messages when required dependency files were missing.
3233
| `Issue #8032 <https://github.com/pgadmin-org/pgadmin4/issues/8032>`_ - Fixed an issue where the Schema Diff Tool incorrectly reported differences due to variations in the order of the privileges.
3334
| `Issue #8691 <https://github.com/pgadmin-org/pgadmin4/issues/8691>`_ - Fixed an issue in the query tool where using multiple cursors to copy text resulted in only the first line being copied.

web/pgadmin/misc/bgprocess/processes.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525

2626
from pgadmin.utils import u_encode, file_quote, fs_encoding, \
2727
get_complete_file_path, get_storage_directory, IS_WIN
28-
from pgadmin.utils.constants import KERBEROS
28+
from pgadmin.utils.constants import (KERBEROS, UTILITIES_ARRAY,
29+
BG_PROCESS_ERROR_MSGS)
2930
from pgadmin.utils.locker import ConnectionLocker
3031
from pgadmin.utils.preferences import Preferences
3132

@@ -45,6 +46,27 @@
4546
PROCESS_NOT_FOUND = _("Could not find a process with the specified ID.")
4647

4748

49+
def set_error_msg(cmd, error_code, stderr):
50+
"""
51+
This function is used to set the error message based on
52+
exit code if stderr is empty.
53+
"""
54+
error_str = ''
55+
# Get the Utility from the cmd.
56+
for utility in UTILITIES_ARRAY:
57+
if utility in cmd:
58+
error_str = utility + _(': error: ')
59+
break
60+
61+
try:
62+
error_str = error_str + BG_PROCESS_ERROR_MSGS[error_code]
63+
except KeyError:
64+
error_str = (error_str + _('utility failed with exit code: ') +
65+
str(error_code))
66+
67+
stderr.append([error_code, error_str])
68+
69+
4870
def get_current_time(format='%Y-%m-%d %H:%M:%S.%f %z'):
4971
"""
5072
Generate the current time string in the given format.
@@ -608,6 +630,10 @@ def status(self, out=0, err=0):
608630
'process_state': self.process_state
609631
}
610632

633+
# Set error message based on exit code if stderr is empty.
634+
if err_completed and len(stderr) == 0:
635+
set_error_msg(self.cmd, self.ecode, stderr)
636+
611637
return {
612638
'out': {
613639
'pos': out,

web/pgadmin/utils/constants.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,13 @@
115115
]
116116
}
117117

118-
UTILITIES_ARRAY = ['pg_dump', 'pg_dumpall', 'pg_restore', 'psql']
118+
UTILITIES_ARRAY = ['pg_dumpall', 'pg_dump', 'pg_restore', 'psql']
119+
120+
BG_PROCESS_ERROR_MSGS = {
121+
3221225781: gettext('Unable to find a dll needed by the utility. Ensuring '
122+
'.dll files needed by the utility are in the same '
123+
'folder as your executable.')
124+
}
119125

120126
ENTER_EMAIL_ADDRESS = "Email address: "
121127
USER_NOT_FOUND = gettext("The specified user ID (%s) could not be found.")

0 commit comments

Comments
 (0)