Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kQyaF-0004jg-EE for pgsql-sql@arkaria.postgresql.org; Fri, 09 Oct 2020 20:01:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kQyaB-0005l0-L6 for pgsql-sql@arkaria.postgresql.org; Fri, 09 Oct 2020 20:01:39 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kQyaB-0005kt-9F for pgsql-sql@lists.postgresql.org; Fri, 09 Oct 2020 20:01:39 +0000 Received: from ore.jhcloos.com ([192.40.56.151]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kQya8-0002Yj-Tm for pgsql-sql@postgresql.org; Fri, 09 Oct 2020 20:01:38 +0000 Received: by ore.jhcloos.com (Postfix, from userid 10) id 343C71FA02; Fri, 9 Oct 2020 20:01:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jhcloos.com; s=ore17; t=1602273694; bh=YULgQNAcmG0aV7R0PjWEWlucBg6EjXKMaJK5DHb/Kos=; h=From:To:Subject:Date:From; b=HO89LOdjr4wkq6Cfg0boi9MKb1dkvbgEMgfGFoHn2qkWW+Wo+vL9REWbtfhzkcnQ5 iIUQbIB3Zmdtc9na/L6cxyrHttiA+OwJKqFGi5lfeQO2rSrPpplQ67r+jT9rc0XUlF Kc/cKnl7iZp8rJqGk5qwR30lrVjO+rJVElcsmyEtiXxnzKQmK4D5PzIb2iIAyrtPCv cZZzSg+N4ppkDdbS/uR53fJX3bEXyD5ljMoM4186awvj+ZV6fbqki00KEQwEY46OrQ Taax3X8bIivuZV+q9BxCdV9xGncYbWmK9R0+UxWmsynYShOukt5pj6A1yECenGb8XS Ey9Kg1nvGXFxQ== Received: by carbon.jhcloos.org (Postfix, from userid 500) id ABC14CD48; Fri, 9 Oct 2020 20:01:27 +0000 (UTC) From: James Cloos To: pgsql-sql@postgresql.org Subject: getting aroung chr(0) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Face: iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAgMAAABinRfyAAAACVBMVEX///8ZGXBQKKnCrDQ3 AAAAJElEQVQImWNgQAAXzwQg4SKASgAlXIEEiwsSIYBEcLaAtMEAADJnB+kKcKioAAAAAElFTkSu QmCC Copyright: Copyright 2020 James Cloos OpenPGP: 0x997A9F17ED7DAEA6; url=https://jhcloos.com/public_key/0x997A9F17ED7DAEA6.asc OpenPGP-Fingerprint: E9E9 F828 61A4 6EA9 0F2B 63E7 997A 9F17 ED7D AEA6 Date: Fri, 09 Oct 2020 16:01:27 -0400 Message-ID: Lines: 19 MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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 OpenPGP: 0x997A9F17ED7DAEA6