pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Markus Schaber <schabi@logix-tt.com>
To: pgsql-sql@postgresql.org
Cc: Bart Degryse <Bart.Degryse@indicator.be>
Subject: Re: UNICODE and PL/PGSQL
Date: Mon, 27 Nov 2006 16:16:35 +0100
Message-ID: <456B0153.3010603@logix-tt.com> (raw)
In-Reply-To: <456B0A47020000300000FC1E@webaccess.indicator.be>
References: <456AD17A020000300000FB60@webaccess.indicator.be>
	<1164638251.270 70.45.camel@localhost.localdomain>
	<456B0A47020000300000FC1E@webaccess.indicator.be>

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



view thread (16+ messages)  latest in thread

Message-ID: <456B0153.3010603@logix-tt.com>
Permalink:  ../456B0153.3010603@logix-tt.com/
Also on:    postgresql.org/message-id/456B0153.3010603@logix-tt.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: schabi@logix-tt.com, Bart.Degryse@indicator.be
  Subject: Re: UNICODE and PL/PGSQL
  In-Reply-To: <456B0153.3010603@logix-tt.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox