Skip to content

Commit a3e43e4

Browse files
authored
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 0a2db9b commit a3e43e4

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

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: 28 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,26 @@
4546
PROCESS_NOT_FOUND = _("Could not find a process with the specified ID.")
4647

4748

49+
def get_error_msg(cmd, error_code):
50+
"""
51+
This function is used to get the error message based on exit code.
52+
"""
53+
error_str = ''
54+
# Get the Utility from the cmd.
55+
for utility in UTILITIES_ARRAY:
56+
if utility in cmd:
57+
error_str = utility + _(': error: ')
58+
break
59+
60+
try:
61+
error_str = error_str + BG_PROCESS_ERROR_MSGS[error_code]
62+
except KeyError:
63+
error_str = (error_str + _('utility failed with exit code: ') +
64+
str(error_code))
65+
66+
return error_str
67+
68+
4869
def get_current_time(format='%Y-%m-%d %H:%M:%S.%f %z'):
4970
"""
5071
Generate the current time string in the given format.
@@ -608,6 +629,12 @@ def status(self, out=0, err=0):
608629
'process_state': self.process_state
609630
}
610631

632+
# Get the error message based on exit code.
633+
if err_completed and self.ecode != 0:
634+
err_msg = get_error_msg(self.cmd, self.ecode)
635+
# This should be the last line as added 'Z' for sorting.
636+
stderr.append(['Z', err_msg])
637+
611638
return {
612639
'out': {
613640
'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. Ensure '
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)