Hello Tom,
Friday, April 19, 2002, 8:32:16 PM, you wrote:
TL> Yury Don <yura@vpcit.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@vpcit.ru