Re: quote_boolean() and friends missing - Mailing list pgsql-hackers

From Tom Lane
Subject Re: quote_boolean() and friends missing
Date
Msg-id 6852.1119278348@sss.pgh.pa.us
Whole thread Raw
In response to Re: quote_boolean() and friends missing  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
List pgsql-hackers
Stephan Szabo <sszabo@megazone.bigpanda.com> writes:
> On Mon, 20 Jun 2005, Tom Lane wrote:
>> I don't think so --- at least not in plpgsql, which can do this already.
>> Just assign the value to a text variable and then use quote_literal.

> Would that work for a bytea with embedded nul characters or does that run
> the risk of terminating the value early?

Works for me:

regression=# create function froob(bytea) returns text as $$
regression$# declare t text;
regression$# begin
regression$#   t := $1;
regression$#   return quote_literal(t);
regression$# end$$ language plpgsql;
CREATE FUNCTION
regression=# select froob('\\377\\000\\377'::bytea);      froob
-------------------'\\377\\000\\377'
(1 row)

regression=#
        regards, tom lane


pgsql-hackers by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: quote_boolean() and friends missing
Next
From: Andreas Pflug
Date:
Subject: Re: [PATCHES] default database creation with initdb