X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id E184011F6252 for ; Fri, 31 Mar 2006 02:19:45 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 16454-10 for ; Fri, 31 Mar 2006 02:19:44 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from moon.antora.ru (moon.antora.ru [83.222.21.34]) by postgresql.org (Postfix) with ESMTP id B6C8A11F6276 for ; Fri, 31 Mar 2006 02:19:43 -0400 (AST) Received: from [217.26.17.26] (helo=[10.0.0.72]) by moon.antora.ru with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.60 (FreeBSD)) (envelope-from ) id 1FPCyy-000PBG-CK; Fri, 31 Mar 2006 10:19:40 +0400 Message-ID: <442CC95C.1030700@bankir.ru> Date: Fri, 31 Mar 2006 10:17:00 +0400 From: "Eugene E." User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050517) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Peter Eisentraut CC: Achilleus Mantzios , pgsql-sql@postgresql.org Subject: Re: have you feel anything when you read this ? References: <441EA0A7.8030601@bankir.ru> <200603201415.30719.peter_e@gmx.net> In-Reply-To: <200603201415.30719.peter_e@gmx.net> Content-Type: text/plain; charset=ISO-8859-7; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] X-Spam-Score: 0.12 X-Spam-Level: X-Archive-Number: 200603/462 X-Sequence-Number: 24808 Peter Eisentraut wrote: > Eugene E. wrote: > >>the problem is: you'll get this four byte sequence '\000' _instead_ >>of NUL-byte anyway. > > > What you seem to be missing is that PostgreSQL data can be represented > in textual and in binary form. What you in psql is the textual form. > If you want the binary form you need to select it. Then you can pass > the exact bytes back and forth. your sentence is not true. I can not select exact bytes even if i use BYTEA type the folloiwing tiny C-program shows this pretty clear #include #include #include "libpq-fe.h" int main (void) { PGconn * conn; PGresult * res; char * val; char * l; int len; conn = PQconnectdb("user=scott password=tiger dbname=test_db"); PQexec(conn, "CREATE TABLE t (a BYTEA)"); PQexec(conn, "INSERT INTO t VALUES ('ab\\\\000cd')"); res = PQexec(conn, "SELECT a,length(a) FROM t"); val = PQgetvalue(res,0,0); l = PQgetvalue(res,0,1); len = PQgetlength(res,0,0); printf("what_we_retrive='%s' its_value_length=%i but orig_length=%s\n",val,len,l); PQclear(res); PQfinish(conn); return 0; }