Re: UNICODE and PL/PGSQL

From: Markus Schaber <schabi(at)logix-tt(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Cc: Bart Degryse <Bart(dot)Degryse(at)indicator(dot)be>
Subject: Re: UNICODE and PL/PGSQL
Date: 2006-11-27 15:16:35
Message-ID: 456B0153.3010603@logix-tt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi, Bart,

Bart Degryse wrote:

> I suppose your statement
> test=# select '\x'||'65';
> is done on some command line interface. I don't have that. I can only
> use some client program.

All versions of PostgreSQL I know are shipped with "psql" as command
line interface. (It's a client program, actually. :-)

> I'm using EMS SQL Manager 2007 and pgAdmin III 1.3
> None of them accepts your statement.

I just tried with pgAdmin III 1.4.3, and it worked fine.

> When I try to do the same for a range of hex values ( FOR i IN 101..101
> LOOP charset := charset || '\x' || to_hex(i); ) it is not longer a
> bunch of hex values that get stored but a series of varchars.

The problem is that the \x escaping is done in the parser, so in your
first function, the query engine actually sees
"charset := charset || 'e';"

In the second function, the '\x' string is parsed as is, and converted
to the String 'x' instead of being rejected as broken \x sequence, I
think for compatibility reasons. Then, the engine sees:
"charset := charset || 'x' || to_hex(i);"

Maybe you can change it to (ASCII version):
"charset := charset || chr(i);"
or (256-bit version):
"charset := charset || decode(to_hex(i),'hex');

HTH,
Markus
--
Markus Schaber | Logical Tracking&Tracing International AG
Dipl. Inf. | Software Development GIS

Fight against software patents in Europe! www.ffii.org
www.nosoftwarepatents.org

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message atrentacost 2006-11-27 15:17:51 Auto-Response: Re: UNICODE and PL/PGSQL
Previous Message Bart Degryse 2006-11-27 14:54:47 Re: UNICODE and PL/PGSQL