I have string 'test\data'
or just one backslash symbol '\'
.
How it convert to bytea?
I have string 'test\data'
or just one backslash symbol '\'
.
How it convert to bytea?
Backlashes need special handling if casted from to bytea
see src/backend/utils/adt/varlena.c
.
Thus escape each backslash using replace('test\data', '\', '\\')::bytea
before casting to bytea
.
You could also use the already suggested function convert_to(text, encoding) bytea
. But note that this function is not IMMUTABLE
and thus it can't be used in any context out of the box.