Subject: decode/encode backslash to base64

From: ft <[email-masked]>
Date: Sun, 24 Mar 2024 22:29:39 +0100

Hello, 

here is an example for decode and encode 
a string with backslash: 'a\'

select trim(convert_from(decode('YVw=', 'base64'), 'UTF8') )::text; 
answer: 'a\'

the next query throw an error: 
SQL Error [22P02]: ERROR: invalid input syntax for type bytea

select encode(trim(convert_from(decode('YVw=', 'base64'), 'UTF8')
)::text::bytea, 'base64' );

also:
select encode('a\'::text::bytea, 'base64');

What should I do?

Franz

---

From: Tom Lane <[email-masked]>
Date: Mon, 25 Mar 2024 09:48:26 -0400

> a string with backslash: 'a\'

That is not valid input syntax for bytea.  See

https://www.postgresql.org/docs/current/datatype-binary.html

You've said nothing about what your actual purpose is,
so it's difficult to suggest what you should do differently.

			regards, tom lane