Skip to content

Commit eece396

Browse files
committed
Fixed an issue where the PSQL tool would hang when the database encoding was set to SQL_ASCII and certain commands were executed.
1 parent abcb5f8 commit eece396

3 files changed

Lines changed: 18 additions & 8 deletions

File tree

docs/en_US/release_notes_9_4.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Bug fixes
3131
*********
3232

3333
| `Issue #6564 <https://github.com/pgadmin-org/pgadmin4/issues/6564>`_ - Fix the issue where an error is displayed when a table is dropped while a query is running.
34+
| `Issue #6968 <https://github.com/pgadmin-org/pgadmin4/issues/6968>`_ - Fixed an issue where the options key was not working as expected in the PSQL tool.
3435
| `Issue #8595 <https://github.com/pgadmin-org/pgadmin4/issues/8595>`_ - Enhance contrast for selected and hovered items in the Object Explorer to improve visibility and accessibility.
3536
| `Issue #8607 <https://github.com/pgadmin-org/pgadmin4/issues/8607>`_ - Fixed an issue where the query tool returns "cannot unpack non-iterable Response object" when running any query with a database name change.
3637
| `Issue #8608 <https://github.com/pgadmin-org/pgadmin4/issues/8608>`_ - Handle result grid data changes in View/Edit Data mode by automatically reconnecting to the server if a disconnection occurs.

web/pgadmin/tools/psql/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,16 @@ def read_terminal_data(parent, data_ready, max_read_bytes, sid):
205205
if parent in data_ready:
206206
# Read the output from parent fd (terminal).
207207
output = os.read(parent, max_read_bytes)
208+
try:
209+
decode_data = output.decode()
210+
except Exception:
211+
try:
212+
decode_data = output.decode('UTF-8')
213+
except Exception:
214+
decode_data = output.decode('UTF-8', errors='replace')
208215

209216
sio.emit('pty-output',
210-
{'result': output.decode(),
217+
{'result': decode_data,
211218
'error': False},
212219
namespace='/pty', room=sid)
213220

web/pgadmin/utils/driver/psycopg3/typecast.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,12 @@ def load(self, data):
246246
return bytes(data).decode(python_encoding)
247247
return data.decode(python_encoding)
248248
except Exception:
249-
if isinstance(data, memoryview):
250-
return bytes(data).decode('UTF-8')
251-
return data.decode('UTF-8')
252-
else:
253-
if isinstance(data, memoryview):
254-
return bytes(data).decode('ascii', errors='replace')
255-
return data.decode('ascii', errors='replace')
249+
try:
250+
if isinstance(data, memoryview):
251+
return bytes(data).decode('UTF-8')
252+
return data.decode('UTF-8')
253+
except Exception:
254+
if isinstance(data, memoryview):
255+
return bytes(data).decode('ascii',
256+
errors='replace')
257+
return data.decode('ascii', errors='replace')

0 commit comments

Comments
 (0)