agora inbox for pgsql-sql@postgresql.org
help / color / mirror / Atom feedFrom: James Cloos <cloos@jhcloos.com>
To: pgsql-sql@postgresql.org
Subject: getting aroung chr(0)
Date: Fri, 09 Oct 2020 16:01:27 -0400
Message-ID: <m3zh4vxj6w.fsf@carbon.jhcloos.org> (raw)
Is there a better way to do this:
select (case
when octet_length(n) > 0
then chr(octet_length(n))::bytea
else '\x00'
end) || n from some_table;
some_table.n may contain values like ''::text,
but some_table.n is not null.
Obviously, a function like chr() which returns bytea
rather than text would be ideal, but lacking one....
Thanks,
-JimC
--
James Cloos <cloos@jhcloos.com> OpenPGP: 0x997A9F17ED7DAEA6
Message-ID: <m3zh4vxj6w.fsf@carbon.jhcloos.org>
Permalink: ../m3zh4vxj6w.fsf@carbon.jhcloos.org/
Also on: postgresql.org/message-id/m3zh4vxj6w.fsf@carbon.jhcloos.org
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: cloos@jhcloos.com
Subject: Re: getting aroung chr(0)
In-Reply-To: <m3zh4vxj6w.fsf@carbon.jhcloos.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox