Re: invalidly encoded strings

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Tatsuo Ishii <ishii(at)postgresql(dot)org>, andrew(at)dunslane(dot)net, laurenz(dot)albe(at)wien(dot)gv(dot)at, pgsql-hackers(at)postgresql(dot)org
Subject: Re: invalidly encoded strings
Date: 2007-09-11 19:07:45
Message-ID: 1189537665.6497.12.camel@dogma.ljc.laika.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

On Tue, 2007-09-11 at 14:48 -0400, Tom Lane wrote:
> Jeff Davis <pgsql(at)j-davis(dot)com> writes:
> > On Mon, 2007-09-10 at 23:20 -0400, Tom Lane wrote:
> >> It might work the way you are expecting if the database uses SQL_ASCII
> >> encoding and C locale --- and I'd be fine with allowing convert() only
> >> when the database encoding is SQL_ASCII.
>
> > I prefer this option.
>
> I think really the technically cleanest solution would be to make
> convert() return bytea instead of text; then we'd not have to put
> restrictions on what encoding or locale it's working inside of.
> However, it's not clear to me whether there are valid usages that
> that would foreclose. Tatsuo mentioned length() but bytea has that.

Once it's in bytea, you can make operators to achieve the old
functionality. If I understood correctly, he was making a backwards
compatibility argument, not a functionality argument. I can't think of a
problem without a workaround, but maybe there are some.

> What I think we'd need to have a complete solution is
>
> convert(text, name) returns bytea
> -- convert from DB encoding to arbitrary encoding
>
> convert(bytea, name, name) returns bytea
> -- convert between any two encodings
>
> convert(bytea, name) returns text
> -- convert from arbitrary encoding to DB encoding
>
> The second and third would need to do a verify step before
> converting, of course.
>

I like it.

Regards,
Jeff Davis

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2007-09-11 19:15:04 Re: Final Thoughts for 8.3 on LWLocking and Scalability
Previous Message Tom Lane 2007-09-11 18:48:54 Re: invalidly encoded strings

Browse pgsql-patches by date

  From Date Subject
Next Message Simon Riggs 2007-09-11 19:15:04 Re: Final Thoughts for 8.3 on LWLocking and Scalability
Previous Message Tom Lane 2007-09-11 18:48:54 Re: invalidly encoded strings