Re: Unexpected behaviour of encode() - Mailing list pgsql-general

From Bill Moran
Subject Re: Unexpected behaviour of encode()
Date
Msg-id 20130326143604.b43f120ce961684f4a232c8d@potentialtech.com
Whole thread Raw
In response to Re: Unexpected behaviour of encode()  (Merlin Moncure <mmoncure@gmail.com>)
Responses Re: Unexpected behaviour of encode()
Re: Unexpected behaviour of encode()
List pgsql-general
In response to Merlin Moncure <mmoncure@gmail.com>:

> On Tue, Mar 26, 2013 at 12:47 PM, Bill Moran <wmoran@potentialtech.com> wrote:
> >
> > psql -U postgres
> > psql (9.2.3)
> > Type "help" for help.
> >
> > postgres=# select encode('can''t', 'escape');
> >  encode
> > --------
> >  can't
> > (1 row)
> >
> > I observed the same behaviour on one of our older systems (8.3.11) as well.
> >
> > Am I missing something?  I expected "can''t" as the output.
>
> why? that isn't what you passed it.  the input string doubled single
> quotes is converted to single single quote per spec.  it's 'ghetto
> escaping'.

Not sure what you mean by "ghetto secaping" ... but doubling up a '
is the SQL standard escaping method, AFAIK.

If I just do:
SELECT 'can''t'::text;
I get "can't" which is what I'd expect.  I would then expect
encode to escape the ' somehow.  Even c-style escaping, like
"can\'t" would have been less surprising to me.

If there's something I'm missing, I'm still missing it.

--
Bill Moran
http://www.potentialtech.com
http://people.collaborativefusion.com/~wmoran/


pgsql-general by date:

Previous
From: Kevin Grittner
Date:
Subject: Re: pg_stat_get_last_vacuum_time(): why non-FULL?
Next
From: Merlin Moncure
Date:
Subject: Re: Unexpected behaviour of encode()