Parameter · Client Connection Defaults / Statement Behavior
bytea_output
Sets the output format for bytea.
- Default:
hex - Type: enum
- Values: escape · hex
- Applies: Session (any user)
In plain words
Binary data has to be turned into text to be shown. hex (default) writes every byte as two hex digits after \x. escape is the old format: printable bytes as characters, others as octal escapes.
For DBAs and operators
Only output is affected; bytea input always accepts both formats. hex became the default in PostgreSQL 9.0. It is faster to produce and parse, and its size is predictable (2 × bytes + 2).
Support pitfall: very old drivers or applications written for 8.x expect the escape format and show corrupted images or files when they receive \x89504e47…. Fix the driver if possible; otherwise set bytea_output = 'escape' for that role or database only (ALTER ROLE legacy_app SET bytea_output = 'escape').
Binary-protocol clients receive raw bytes and are unaffected. For readable output in SQL use encode(data, 'base64') or encode(data, 'escape').
How to change it
Any user can change it for their session with SET.