Received: from ara.zf.jcu.cz (ara.zf.jcu.cz [160.217.161.4]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f5MFZqa41648 for ; Fri, 22 Jun 2001 11:35:52 -0400 (EDT) (envelope-from zakkr@zf.jcu.cz) Received: (from zakkr@localhost) by ara.zf.jcu.cz (8.9.3/8.9.3/Debian 8.9.3-21) id RAA14647; Fri, 22 Jun 2001 17:35:37 +0200 Date: Fri, 22 Jun 2001 17:35:37 +0200 From: Karel Zak To: Tom Lane Cc: Hugh Mandeville , pgsql-sql@postgresql.org Subject: Re: Re: Re: binary data Message-ID: <20010622173537.A14265@ara.zf.jcu.cz> References: <9gtovc$mnr$1@news.tht.net> <3791.993219752@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii User-Agent: Mutt/1.0.1i In-Reply-To: <3791.993219752@sss.pgh.pa.us>; from tgl@sss.pgh.pa.us on Fri, Jun 22, 2001 at 10:22:32AM -0400 X-Archive-Number: 200106/373 X-Sequence-Number: 3663 On Fri, Jun 22, 2001 at 10:22:32AM -0400, Tom Lane wrote: > He did say the rules for escaping things are tricky ;-). You need to > double the backslashes, because interpretation of the string literal > takes off one level of backslashing before bytea ever sees it: > > regression=# INSERT INTO log (data) VALUES ('null \\000 null'); > INSERT 273181 1 > regression=# SELECT octet_length(data), data FROM log; > octet_length | data > --------------+------------------------------ > 10 | plain text > 19 | special chars \012 \001 \002 > 5 | null > 11 | null \000 null > (4 rows) And what use some better encoding if you have a lot of binary chars in data. For example base64, that code 2 chars to 3 instead \\000 that encode 1 char to 4. Karel -- Karel Zak http://home.zf.jcu.cz/~zakkr/ C, PostgreSQL, PHP, WWW, http://docs.linux.cz, http://mape.jcu.cz