X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id AF7C5D1DD59 for ; Wed, 18 Feb 2004 06:44:54 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 97088-01 for ; Wed, 18 Feb 2004 02:44:53 -0400 (AST) Received: from screamer.tcp-ip.info (screamer.tcp-ip.info [68.167.18.162]) by svr1.postgresql.org (Postfix) with ESMTP id 0649CD1D25D for ; Wed, 18 Feb 2004 02:44:52 -0400 (AST) Received: from localhost (localhost [127.0.0.1]) by screamer.tcp-ip.info (8.12.10/8.12.10/SuSE Linux 0.7) with ESMTP id i1I6iqMP006236 for ; Wed, 18 Feb 2004 01:44:52 -0500 Date: Wed, 18 Feb 2004 01:44:52 -0500 (EST) From: Dana Hudes X-X-Sender: dhudes@screamer.tcp-ip.info To: pgsql-sql@postgresql.org Subject: Re: bytea or blobs? In-Reply-To: <200402180914.29318.sad@bankir.ru> Message-ID: References: <40322E69.30606@Yahoo.com> <200402180914.29318.sad@bankir.ru> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/244 X-Sequence-Number: 16934 The documentation indicates that bytea will -store- binary data The problem is getting the data into the column through SQL. The Postgresql SQL is character data only (side note: what about unicode? is this USASCII only?). You cannot just wrap your binary stream in a pair of quotes and off you go. You must encode before saving and decode after retrieving. The encoded form is stored in the column. What I have not figured out is how to pass my data to encode. This is a builtin function but it doesn't take a filename so how can you use it! At least with base64 I have ample libraries and can convert my data before sending to sql or after receiving from sql. It becomes my application's issue. Mind, this bloats the data considerably. escape is less bloat but I have to recreate the encode/decode in my app, so far as I see. On Wed, 18 Feb 2004, sad wrote: > On Tuesday 17 February 2004 18:08, you wrote: > > > I'd recommend to let the application convert the binary > > data to and from base64, > > Don't, please don't ! > > Since you have the good bytea rule to convert so called "binary" data into so > called "text". You have no need another encoding at all. > > Generally, the problem is to represent zero (0x00) when input/output. Any > other byte might be stored, dumped, input, output without any problem. Then > why to avoid 8bit chars ? > > Bytea notation rule completely resolve the problem of zeroes. > (and also apostrophes :-) naturally) > > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 9: the planner will ignore your desire to choose an index scan if your > joining column's datatypes do not match >