X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 143725289B for ; Mon, 20 Jun 2005 21:12:45 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 89612-01 for ; Tue, 21 Jun 2005 00:12:43 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id 4129E528CA for ; Mon, 20 Jun 2005 21:12:42 -0300 (ADT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j5L0CeTR074618 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 20 Jun 2005 18:12:43 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j5L0CeOC028190; Mon, 20 Jun 2005 18:12:40 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j5L0Cern028189; Mon, 20 Jun 2005 18:12:40 -0600 (MDT) (envelope-from mfuhr) Date: Mon, 20 Jun 2005 18:12:40 -0600 From: Michael Fuhr To: Markus Bertheau ??? Cc: pgsql-sql@postgresql.org Subject: Re: SQL repr of bytea val Message-ID: <20050621001240.GA28117@winnie.fuhr.org> References: <1119275221.4688.14.camel@dicaprio.akademie1.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1119275221.4688.14.camel@dicaprio.akademie1.de> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200506/260 X-Sequence-Number: 21861 On Mon, Jun 20, 2005 at 03:47:01PM +0200, Markus Bertheau ??? wrote: > > I'm constructing querys on the fly in PL/pgSQL_ and need a function that > returns the SQL representation of a bytea value. I tried encode(.., > 'escape') but it seems to return 8 bit ASCII values, not the \377 stuff > that's supposed to be in the bytea input syntax. Does anyone know a way > to do that? How about textin(byteaout(bytea_value))? Or a function that performs the conversion by magic: CREATE FUNCTION bytea2text(bytea) RETURNS text AS $$ BEGIN RETURN $1; END; $$ LANGUAGE plpgsql IMMUTABLE STRICT; -- Michael Fuhr http://www.fuhr.org/~mfuhr/