Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id CDB4A633BB1 for ; Tue, 28 Apr 2009 13:51:01 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 33044-06 for ; Tue, 28 Apr 2009 13:51:00 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smtp-gw51.mailanyone.net (smtp-gw51.mailanyone.net [208.70.128.77]) by mail.postgresql.org (Postfix) with ESMTP id 98A53633712 for ; Tue, 28 Apr 2009 13:50:59 -0300 (ADT) Received: from mailanyone.net by smtp-gw51.mailanyone.net with esmtpa (MailAnyone extSMTP andy@networkmail.eu) id 1LyqV2-0008Cm-6Z; Tue, 28 Apr 2009 11:49:40 -0500 Message-ID: <49F73378.7000100@networkmail.eu> Date: Tue, 28 Apr 2009 17:48:56 +0100 From: Andy Shellam User-Agent: Thunderbird 2.0.0.21 (Windows/20090302) MIME-Version: 1.0 To: Tom Lane CC: pgsql-sql@postgresql.org Subject: Re: Storing null bytes in bytea References: <49F5F02A.1070505@networkmail.eu> <11364.1240864149@sss.pgh.pa.us> In-Reply-To: <11364.1240864149@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200904/133 X-Sequence-Number: 32479 Hi Tom, > Your example works fine in psql: > > regression=# create table t1 (f1 bytea); > CREATE TABLE > regression=# insert into t1 values (E'IsLoggedIn|b:1;CurrentUser|O:17:"Class_SystemUser":4:{s:26:"\\000Class_SystemUser}'::bytea); > INSERT 0 1 > regression=# select * from t1; > f1 > ----------------------------------------------------------------------------------- > IsLoggedIn|b:1;CurrentUser|O:17:"Class_SystemUser":4:{s:26:"\000Class_SystemUser} > (1 row) > > > I suspect what is happening is that some layer on the client side is > doubling (or perhaps undoubling?) the backslashes for you. Exactly > what are you doing with that literal as you build the query? It might > help to turn on log_statements so that you can see just what the > server is getting. > Many thanks for your reply. I was a bit naive about the quality of the client I was using (Navicat 8.1.) It turns out in the "Memo" view it doesn't show anything past the first zero byte. However switch it to hex view and you see the full bytes. I think my issue that it wasn't working on the client side (and caused me to examine it in more detail in the database) was because it wasn't unescaping correctly in the application code when it read the data back out of the database. Next time I won't be so lazy and try it out in psql first... Regards, Andy