Re: pltcl bug in 7.2?

From: Yury Don <yura(at)vpcit(dot)ru>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: pltcl bug in 7.2?
Date: 2002-04-19 18:15:54
Message-ID: 11514697604.20020420001554@vpcit.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello Tom,

Friday, April 19, 2002, 8:32:16 PM, you wrote:

TL> Yury Don <yura(at)vpcit(dot)ru> writes:
>> Hello All,
>> We have a database with koi8-r encoding, tables and fields names
>> mostly in russian, and we have a trigger function on pltcl. With postgresql 7.1 everything
>> worked well, but in 7.2 we are getting an error "utf_to_local: could
>> not convert UTF-8" in the following construction
>> foreach field [array names NEW] {
>> if {[info exists OLD(${field})]} ....

TL> Hmm. Someone added code in 7.2 to support conversion between the
TL> database's encoding (whatever you specified with -E) and the UTF-8
TL> encoding that Tcl wants to use all the time. Sounds like you've
TL> found a bug in that code.

>> Also this error occures in any calling of NEW or OLD, for example
>> [array get NEW] also raises those error.

TL> Do you see it *only* in references to NEW/OLD? Can you pass the
TL> same data in normal parameters to a Tcl function?

TL> regards, tom lane

I can see this error only in trigger functions when I call NEW or OLD
and trigger table has a fields with names containing cyrillic characters.
Any other variables, parameters, with cyrillic characters don't raise
this error. For example following code works well (relname contains cyrillic characters):

spi_exec "SELECT relname FROM pg_class WHERE oid=$TG_relid"
elog DEBUG "$relname"

This code also works without errors:
CREATE or replace FUNCTION tmp1(text) RETURNS text AS '
return $1
}
' LANGUAGE 'pltcl';
select tmp1('<here some text with cyrillic characters>');

But the following code raises an error "utf_to_local: could not convert
UTF-8" (trigger table has a fields with names containing cyrillic characters)

CREATE or replace FUNCTION log_event() RETURNS opaque AS '
foreach field [array names NEW] {
elog DEBUG "field=$field"
}
return OK
}
' LANGUAGE 'pltcl';

And in postgresql.log I see strings
field=<field name>
for fields whose names consist of only latin characters and string
field=
for fields whose names include cyrillic characters

Postgres 7.2.1 on Debian Linux, compiled with --enable-multibyte,
--enable-unicode-conversion, --enable-locale. Tcl version 8.3.

--
Best regards,
Yury mailto:yura(at)vpcit(dot)ru

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Yury Don 2002-04-19 18:41:53 Re: pltcl bug in 7.2?
Previous Message Tom Lane 2002-04-19 18:00:15 Re: Disabling libpq clients stderr output from backend